-
Notifications
You must be signed in to change notification settings - Fork 0
/
worldFilter.cs
304 lines (250 loc) · 11.5 KB
/
worldFilter.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
using Decal.Adapter.Wrappers;
using Decal.Interop.D3DService;
using System;
using System.Collections.Generic;
using System.Media;
namespace EdsACPlugin
{
public partial class PluginCore
{
private void initWorldFilter()
{
//////////////////////////////////////////////////////////////
// To initialize any of the World Filter Events, //
// simply uncomment the appropriate initialization //
// statement(s) below to enable the event handler //
//////////////////////////////////////////////////////////////
// Initialize the ResetTrade event handler
Core.WorldFilter.ResetTrade += new EventHandler<ResetTradeEventArgs>(WorldFilter_ResetTrade);
// Initialize the ReleaseObject event handler
Core.WorldFilter.ReleaseObject += new EventHandler<ReleaseObjectEventArgs>(WorldFilter_ReleaseObject);
// Initialize the ReleaseDone event handler
Core.WorldFilter.ReleaseDone += new EventHandler(WorldFilter_ReleaseDone);
// Initialize the MoveObject event handler
Core.WorldFilter.MoveObject += new EventHandler<MoveObjectEventArgs>(WorldFilter_MoveObject);
// Initialize the FailToCompleteTrade event handler
Core.WorldFilter.FailToCompleteTrade += new EventHandler(WorldFilter_FailToCompleteTrade);
// Initialize the FailToAddTradeItem event handler
Core.WorldFilter.FailToAddTradeItem += new EventHandler<FailToAddTradeItemEventArgs>(WorldFilter_FailToAddTradeItem);
// Initialize the EnterTrade event handler
Core.WorldFilter.EnterTrade += new EventHandler<EnterTradeEventArgs>(WorldFilter_EnterTrade);
// Initialize the EndTrade event handler
Core.WorldFilter.EndTrade += new EventHandler<EndTradeEventArgs>(WorldFilter_EndTrade);
// Initialize the DeclineTrade event handler
Core.WorldFilter.DeclineTrade += new EventHandler<DeclineTradeEventArgs>(WorldFilter_DeclineTrade);
// Initialize the CreateObject event handler
Core.WorldFilter.CreateObject += new EventHandler<CreateObjectEventArgs>(WorldFilter_CreateObject);
// Initialize the ChangeObject event handler
Core.WorldFilter.ChangeObject += new EventHandler<ChangeObjectEventArgs>(WorldFilter_ChangeObject);
// Initialize the ApproachVendor event handler
Core.WorldFilter.ApproachVendor += new EventHandler<ApproachVendorEventArgs>(WorldFilter_ApproachVendor);
// Initialize the AddTradeItem event handler
Core.WorldFilter.AddTradeItem += new EventHandler<AddTradeItemEventArgs>(WorldFilter_AddTradeItem);
// Initialize the AcceptTrade event handler
Core.WorldFilter.AcceptTrade += new EventHandler<AcceptTradeEventArgs>(WorldFilter_AcceptTrade);
}
void WorldFilter_AcceptTrade(object sender, AcceptTradeEventArgs e)
{
wtc($"{System.Reflection.MethodBase.GetCurrentMethod().Name}");
}
void WorldFilter_AddTradeItem(object sender, AddTradeItemEventArgs e)
{
wtc($"{System.Reflection.MethodBase.GetCurrentMethod().Name}");
}
void WorldFilter_ApproachVendor(object sender, ApproachVendorEventArgs e)
{
Vendor vendor = e.Vendor;
// The vendor obj has neat attributes about their buy and sell rates.
wtc($"{vendor} triggered WorldFilter_ApproachVendor.");
wtc($"{System.Reflection.MethodBase.GetCurrentMethod().Name}");
}
private void pointArrowAt(int id)
{
try
{
ID3DService d3d = (ID3DService)Host.GetObject("services\\D3DService.Service");
d3d.PointToObject(id, -32900);
}
catch (Exception ex)
{
WriteToChat(ex.Message);
}
}
private void bark()
{
try
{
string wav = "C:/Users/ekozl/plugins/EdsACPlugin/bin/Debug/wav/monster_02.wav";
SoundPlayer s = new SoundPlayer(wav);
s.Play();
}
catch (Exception ex)
{
WriteToChat(ex.Message);
}
}
private void scanMonster(WorldObject monster)
{
return; // DISABLE for now.
if(monster.Name.IndexOf("Golem") != -1)
{
wtc($"Found {o.Name} - Coords: ({o.Coordinates()})");
// bark
bark();
// point
pointArrowAt(o.Id);
}
}
private void scanItem(WorldObject item)
{
return; // DISABLE for now.
}
private void scanCorpse(WorldObject corpse)
{
if(corpse.Container != 0)
{
wtc($"Alinco says {corpse.Name} with ID: {corpse.Id} hasn't been opened.");
} else
{
wtc($"Alinco says {corpse.Name} with ID: {corpse.Id} has already been opened...");
}
}
private Dictionary<int, WorldObject> KnownWOs = new Dictionary<int, WorldObject>();
private void removeFromDict(int id)
{
if (KnownWOs.ContainsKey(id))
{
KnownWOs.Remove(id);
wtc($"Removed {id} from KnownWOs");
} else
{
wtc($"Request to remove {id}, and {id} not found in KnownWOs.");
}
}
private void addToDict(int id, WorldObject wo)
{
if (!KnownWOs.ContainsKey(id))
{
KnownWOs.Add(id, wo);
wtc($"Added {wo.Name} - {id} to KnownWOs - Now {KnownWOs.Count} known.");
}
}
private void scanIt(WorldObject o)
{
// TODO:
// Set these into a "known" object container...
// PURGE THEM with the ReleaseObject event.
if
try
{
switch (o.ObjectClass) {
case ObjectClass.Monster:
scanMonster(o);
break;
case (ObjectClass.Armor):
case (ObjectClass.Clothing):
case (ObjectClass.Jewelry):
case (ObjectClass.MeleeWeapon):
case (ObjectClass.MissileWeapon):
case (ObjectClass.WandStaffOrb):
scanItem(o);
break;
case (ObjectClass.Corpse):
scanCorpse(o);
break;
}
}
catch (Exception ex)
{
WriteToChat(ex.Message);
}
}
void WorldFilter_ChangeObject(object sender, ChangeObjectEventArgs e)
{
WorldObject wo = e.Changed;
wtc($"{wo.Name} triggered WorldFilter_ChangeObject");
scanIt(wo);
}
void WorldFilter_CreateObject(object sender, CreateObjectEventArgs e)
{
WorldObject wo = e.New;
wtc($"{wo.Name} triggered WorldFilter_CreateObject");
scanIt(wo);
}
void WorldFilter_DeclineTrade(object sender, DeclineTradeEventArgs e)
{
wtc($"{System.Reflection.MethodBase.GetCurrentMethod().Name}");
}
void WorldFilter_EndTrade(object sender, EndTradeEventArgs e)
{
wtc($"{System.Reflection.MethodBase.GetCurrentMethod().Name}");
}
void WorldFilter_EnterTrade(object sender, EnterTradeEventArgs e)
{
wtc($"{System.Reflection.MethodBase.GetCurrentMethod().Name}");
}
void WorldFilter_FailToAddTradeItem(object sender, FailToAddTradeItemEventArgs e)
{
wtc($"{System.Reflection.MethodBase.GetCurrentMethod().Name}");
}
void WorldFilter_FailToCompleteTrade(object sender, EventArgs e)
{
wtc($"{System.Reflection.MethodBase.GetCurrentMethod().Name}");
}
void WorldFilter_MoveObject(object sender, MoveObjectEventArgs e)
{
// If this is a Monster, or Player... don't echo _anything_.
WorldObject wo = e.Moved;
if (wo.ObjectClass != ObjectClass.Monster && wo.ObjectClass != ObjectClass.Player)
{
wtc($"{wo.Name} fired WorldFilter_MoveObject");
wtc($"{wo.Type} is type of {wo.Name}");
}
}
void WorldFilter_ReleaseDone(object sender, EventArgs e)
{
wtc($"WorldFilter_ReleaseDone - e is: {e}");
}
void WorldFilter_ReleaseObject(object sender, ReleaseObjectEventArgs e)
{
WorldObject wo = e.Released;
wtc($"{wo.Name} triggered WorldFilter_ReleaseObject");
removeFromDict(wo.Id);
}
void WorldFilter_ResetTrade(object sender, ResetTradeEventArgs e)
{
wtc($"{System.Reflection.MethodBase.GetCurrentMethod().Name}");
}
private void destroyWorldFilter()
{
// UnInitialize the ResetTrade event handler
Core.WorldFilter.ResetTrade -= new EventHandler<ResetTradeEventArgs>(WorldFilter_ResetTrade);
// UnInitialize the ReleaseObject event handler
Core.WorldFilter.ReleaseObject -= new EventHandler<ReleaseObjectEventArgs>(WorldFilter_ReleaseObject);
// UnInitialize the ReleaseDone event handler
Core.WorldFilter.ReleaseDone -= new EventHandler(WorldFilter_ReleaseDone);
// UnInitialize the MoveObject event handler
Core.WorldFilter.MoveObject -= new EventHandler<MoveObjectEventArgs>(WorldFilter_MoveObject);
// UnInitialize the FailToCompleteTrade event handler
Core.WorldFilter.FailToCompleteTrade -= new EventHandler(WorldFilter_FailToCompleteTrade);
// UnInitialize the FailToAddTradeItem event handler
Core.WorldFilter.FailToAddTradeItem -= new EventHandler<FailToAddTradeItemEventArgs>(WorldFilter_FailToAddTradeItem);
// UnInitialize the EnterTrade event handler
Core.WorldFilter.EnterTrade -= new EventHandler<EnterTradeEventArgs>(WorldFilter_EnterTrade);
// UnInitialize the EndTrade event handler
Core.WorldFilter.EndTrade -= new EventHandler<EndTradeEventArgs>(WorldFilter_EndTrade);
// UnInitialize the DeclineTrade event handler
Core.WorldFilter.DeclineTrade -= new EventHandler<DeclineTradeEventArgs>(WorldFilter_DeclineTrade);
// UnInitialize the CreateObject event handler
Core.WorldFilter.CreateObject -= new EventHandler<CreateObjectEventArgs>(WorldFilter_CreateObject);
// UnInitialize the ChangeObject event handler
Core.WorldFilter.ChangeObject -= new EventHandler<ChangeObjectEventArgs>(WorldFilter_ChangeObject);
// UnInitialize the ApproachVendor event handler
Core.WorldFilter.ApproachVendor -= new EventHandler<ApproachVendorEventArgs>(WorldFilter_ApproachVendor);
// UnInitialize the AddTradeItem event handler
Core.WorldFilter.AddTradeItem -= new EventHandler<AddTradeItemEventArgs>(WorldFilter_AddTradeItem);
// UnInitialize the AcceptTrade event handler
Core.WorldFilter.AcceptTrade -= new EventHandler<AcceptTradeEventArgs>(WorldFilter_AcceptTrade);
}
}
}