-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathPathBlocker.cs
522 lines (473 loc) · 17 KB
/
PathBlocker.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
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
#region Header
/*
* JustUO.com / PlayUO.org
* PathBlocker.cs
* Tile that will block the path of Mobiles by the set properties provided
*
* To Add:
* LOS blocker,
* Specific skills - stats?
*
*/
#endregion
#region References
using System;
using System.Collections.Generic;
using Server.Items;
using Server.Gumps;
using Server.Mobiles;
using Server.Spells;
#endregion
namespace Server.Items
{
public class PathBlocker : Item
{
private DateTime m_NextMessage;
private bool m_Active;
private bool m_RestrictPlayers;
private bool m_RestrictCreatures;
private bool m_RestrictTamedCreatures;
private bool m_RestrictCombat;
private bool m_RestrictCriminal;
private bool m_RestrictMurderer;
private bool m_RestrictHiddenPlayers;
private bool m_RestrictMountedPlayers;
private bool m_RestrictDeadPlayers;
private bool m_DeadPlayersOnly;
private bool m_RestrictMale;
private bool m_RestrictFemale;
private bool m_RestrictHuman;
private bool m_RestrictElf;
private bool m_RestrictGargoyle;
//private bool m_SourceEffect;
//private bool m_DestEffect;
//private int m_SoundID;
#region Command Properties
[CommandProperty(AccessLevel.GameMaster)]
public bool Active
{
get { return m_Active; }
set
{
m_Active = value;
InvalidateProperties();
}
}
[CommandProperty(AccessLevel.GameMaster)]
public bool RestrictPlayers
{
get { return m_RestrictPlayers; }
set
{
m_RestrictPlayers = value;
InvalidateProperties();
}
}
[CommandProperty(AccessLevel.GameMaster)]
public bool RestrictCreatures
{
get { return m_RestrictCreatures; }
set
{
m_RestrictCreatures = value;
InvalidateProperties();
}
}
[CommandProperty(AccessLevel.GameMaster)]
public bool RestrictTamedCreatures
{
get { return m_RestrictTamedCreatures; }
set
{
m_RestrictTamedCreatures = value;
InvalidateProperties();
}
}
[CommandProperty(AccessLevel.GameMaster)]
public bool RestrictCombat
{
get { return m_RestrictCombat; }
set
{
m_RestrictCombat = value;
InvalidateProperties();
}
}
[CommandProperty(AccessLevel.GameMaster)]
public bool RestrictCriminal
{
get { return m_RestrictCriminal; }
set
{
m_RestrictCriminal = value;
InvalidateProperties();
}
}
[CommandProperty(AccessLevel.GameMaster)]
public bool RestrictMurderer
{
get { return m_RestrictMurderer; }
set
{
m_RestrictMurderer = value;
InvalidateProperties();
}
}
[CommandProperty(AccessLevel.GameMaster)]
public bool RestrictHiddenPlayers
{
get { return m_RestrictHiddenPlayers; }
set
{
m_RestrictHiddenPlayers = value;
InvalidateProperties();
}
}
[CommandProperty(AccessLevel.GameMaster)]
public bool RestrictMountedPlayers
{
get { return m_RestrictMountedPlayers; }
set
{
m_RestrictMountedPlayers = value;
InvalidateProperties();
}
}
[CommandProperty(AccessLevel.GameMaster)]
public bool RestrictDeadPlayers
{
get { return m_RestrictDeadPlayers; }
set
{
m_RestrictDeadPlayers = value;
InvalidateProperties();
}
}
[CommandProperty(AccessLevel.GameMaster)]
public bool DeadPlayersOnly
{
get { return m_DeadPlayersOnly; }
set
{
m_DeadPlayersOnly = value;
InvalidateProperties();
}
}
/* Intended to involve sound and effects but decided to remove it for now
* This may be added in in the future; Dian
[CommandProperty(AccessLevel.GameMaster)]
public bool SourceEffect
{
get { return m_SourceEffect; }
set
{
m_SourceEffect = value;
InvalidateProperties();
}
}
[CommandProperty(AccessLevel.GameMaster)]
public bool DestEffect
{
get { return m_DestEffect; }
set
{
m_DestEffect = value;
InvalidateProperties();
}
}
[CommandProperty(AccessLevel.GameMaster)]
public int SoundID
{
get { return m_SoundID; }
set
{
m_SoundID = value;
InvalidateProperties();
}
}
*/
[CommandProperty(AccessLevel.GameMaster)]
public bool RestrictMale
{
get { return m_RestrictMale; }
set
{
m_RestrictMale = value;
InvalidateProperties();
}
}
[CommandProperty(AccessLevel.GameMaster)]
public bool RestrictFemale
{
get { return m_RestrictFemale; }
set
{
m_RestrictFemale = value;
InvalidateProperties();
}
}
[CommandProperty(AccessLevel.GameMaster)]
public bool RestrictHuman
{
get { return m_RestrictHuman; }
set
{
m_RestrictHuman = value;
InvalidateProperties();
}
}
[CommandProperty(AccessLevel.GameMaster)]
public bool RestrictElf
{
get { return m_RestrictElf; }
set
{
m_RestrictElf = value;
InvalidateProperties();
}
}
[CommandProperty(AccessLevel.GameMaster)]
public bool RestrictGargoyle
{
get { return m_RestrictGargoyle; }
set
{
m_RestrictGargoyle = value;
InvalidateProperties();
}
}
#endregion
/*
* Default 'Active' setting allows everything to pass over
* Staff will need to set the properties of what to restrict
* */
[Constructable]
public PathBlocker() : base(0x1822)
{
Name = "Path Blocker";
m_Active = true;
Movable = false;
Visible = false;
}
public PathBlocker(Serial serial) : base(serial)
{
}
public override void OnDoubleClick(Mobile from)
{
if (from.AccessLevel > AccessLevel.Player)
{
from.CloseGump(typeof(PropertiesGump));
from.SendGump(new PropertiesGump(from, this));
}
else
from.SendMessage("You have no idea what to do with that");
}
public override bool OnMoveOver(Mobile m)
{
if (!Active)
return true;
if (m is PlayerMobile)
{
PlayerMobile player = m as PlayerMobile;
if (player.AccessLevel == AccessLevel.Player)
{
if (RestrictPlayers)
{
if(ReadyToMessage())
RestrictionMessage(player, "Only the staff members of this shard may pass");
//player.SendMessage("Only the staff members of this shard may pass");
return false;
}
if (DeadPlayersOnly && player.Alive)
{
if (ReadyToMessage())
RestrictionMessage(player, "Only the dead may pass");
//player.SendMessage("Only the dead may pass");
return false;
}
if (RestrictDeadPlayers && !player.Alive)
{
if (ReadyToMessage())
RestrictionMessage(player, "Only the living may pass");
//player.SendMessage("Only the living may pass");
return false;
}
if (RestrictMountedPlayers && player.Mounted)
{
if (ReadyToMessage())
RestrictionMessage(player, "You may not pass while mounted");
//player.SendMessage("You may not pass while mounted");
return false;
}
if (RestrictHiddenPlayers && player.Hidden)
{
if (ReadyToMessage())
RestrictionMessage(player, "You must reveal yourself to pass");
//player.SendMessage("You must reveal yourself to pass");
return false;
}
if (RestrictMurderer && player.Kills >= 5)
{
if (ReadyToMessage())
RestrictionMessage(player, "Only the more innocent may pass");
//player.SendMessage("Only the more innocent may pass");
return false;
}
if (RestrictCriminal && player.Criminal)
{
if (ReadyToMessage())
RestrictionMessage(player, "You are a criminal and may not pass");
//player.SendMessage("You are a criminal and may not pass");
return false;
}
if (RestrictCombat && SpellHelper.CheckCombat(player))
{
if (ReadyToMessage())
RestrictionMessage(player, "You may not pass while involved in combat");
//player.SendMessage("You may not pass while involved in combat");
return false;
}
if (RestrictMale && !player.Female)
{
if (ReadyToMessage())
RestrictionMessage(player, "Only the female race may pass");
//player.SendMessage("Only the female race may pass");
return false;
}
if (RestrictFemale && player.Female)
{
if (ReadyToMessage())
RestrictionMessage(player, "Only the male race may pass");
//player.SendMessage("Only the male race may pass");
return false;
}
if (RestrictHuman && player.Race == Race.Human)
{
if (ReadyToMessage())
RestrictionMessage(player, "Human race are not allowed to pass");
//player.SendMessage("Human race are not allowed to pass");
return false;
}
if (RestrictElf && player.Race == Race.Elf)
{
if (ReadyToMessage())
RestrictionMessage(player, "Elf race are not allowed to pass");
//player.SendMessage("Elf race are not allowed to pass");
return false;
}
if (RestrictGargoyle && player.Race == Race.Gargoyle)
{
if (ReadyToMessage())
RestrictionMessage(player, "Gargoyle race are not allowed to pass");
//player.SendMessage("Gargoyle race are not allowed to pass");
return false;
}
}
}
if (m is BaseCreature)
{
BaseCreature creature = m as BaseCreature;
if(RestrictCreatures && !creature.Controlled)
{
return false;
}
if (m_RestrictTamedCreatures && creature.Controlled)
{
//To do: Dismount if tamed creature has a player mounted?
if (ReadyToMessage())
RestrictionMessage(creature.ControlMaster, "You cannot bring pets past this point");
//creature.ControlMaster.SendMessage("You cannot bring pets past this point");
return false;
}
}
return true;
}
public bool ReadyToMessage()
{
if (m_NextMessage > DateTime.UtcNow)
return false;
else
return true;
}
public void RestrictionMessage(Mobile mob, String message)
{
mob.SendMessage("{0}", message);
m_NextMessage = DateTime.UtcNow + TimeSpan.FromSeconds(5);
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write(4);
//writer.Write(m_SoundID);
//writer.Write(m_DestEffect);
//writer.Write(m_SourceEffect);
writer.Write(m_RestrictGargoyle);
writer.Write(m_RestrictElf);
writer.Write(m_RestrictHuman);
writer.Write(RestrictFemale);
writer.Write(RestrictMale);
writer.Write(m_DeadPlayersOnly);
writer.Write(m_RestrictDeadPlayers);
writer.Write(m_RestrictMountedPlayers);
writer.Write(m_RestrictHiddenPlayers);
writer.Write(m_RestrictMurderer);
writer.Write(m_RestrictCriminal);
writer.Write(m_RestrictCombat);
writer.Write(m_RestrictTamedCreatures);
writer.Write(m_RestrictCreatures);
writer.Write(m_RestrictPlayers);
writer.Write(m_Active);
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
switch (version)
{
//case 5:
// {
// m_SoundID = reader.ReadInt();
// m_DestEffect = reader.ReadBool();
// m_SourceEffect = reader.ReadBool();
// break;
// }
case 4:
{
m_RestrictGargoyle = reader.ReadBool();
m_RestrictElf = reader.ReadBool();
m_RestrictHuman = reader.ReadBool();
m_RestrictFemale = reader.ReadBool();
m_RestrictMale = reader.ReadBool();
goto case 3;
}
case 3:
{
m_DeadPlayersOnly = reader.ReadBool();
m_RestrictDeadPlayers = reader.ReadBool();
m_RestrictMountedPlayers = reader.ReadBool();
m_RestrictHiddenPlayers = reader.ReadBool();
goto case 2;
}
case 2:
{
m_RestrictMurderer = reader.ReadBool();
m_RestrictCriminal = reader.ReadBool();
m_RestrictCombat = reader.ReadBool();
goto case 1;
}
case 1:
{
m_RestrictTamedCreatures = reader.ReadBool();
m_RestrictCreatures = reader.ReadBool();
m_RestrictPlayers = reader.ReadBool();
goto case 0;
}
case 0:
{
m_Active = reader.ReadBool();
break;
}
}
}
}
}