/
PlayerMobile.cs
5178 lines (4141 loc) · 131 KB
/
PlayerMobile.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
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
using System;
using System.Collections;
using System.Collections.Generic;
using Server.Misc;
using Server.Items;
using Server.Gumps;
using Server.Multis;
using Server.Engines.Help;
using Server.Engines.ConPVP;
using Server.ContextMenus;
using Server.Network;
using Server.Spells;
using Server.Spells.Fifth;
using Server.Spells.Seventh;
using Server.Spells.Necromancy;
using Server.Spells.Ninjitsu;
using Server.Spells.Bushido;
using Server.Targeting;
using Server.Engines.Quests;
using Server.Factions;
using Server.Regions;
using Server.Accounting;
using Server.Engines.CannedEvil;
using Server.Engines.Craft;
using Server.Spells.Spellweaving;
using Server.Engines.PartySystem;
using Server.Engines.MLQuests;
namespace Server.Mobiles
{
#region Enums
[Flags]
public enum PlayerFlag // First 16 bits are reserved for default-distro use, start custom flags at 0x00010000
{
None = 0x00000000,
Glassblowing = 0x00000001,
Masonry = 0x00000002,
SandMining = 0x00000004,
StoneMining = 0x00000008,
ToggleMiningStone = 0x00000010,
KarmaLocked = 0x00000020,
AutoRenewInsurance = 0x00000040,
UseOwnFilter = 0x00000080,
PublicMyRunUO = 0x00000100,
PagingSquelched = 0x00000200,
Young = 0x00000400,
AcceptGuildInvites = 0x00000800,
DisplayChampionTitle = 0x00001000,
HasStatReward = 0x00002000,
RefuseTrades = 0x00004000
}
public enum NpcGuild
{
None,
MagesGuild,
WarriorsGuild,
ThievesGuild,
RangersGuild,
HealersGuild,
MinersGuild,
MerchantsGuild,
TinkersGuild,
TailorsGuild,
FishermensGuild,
BardsGuild,
BlacksmithsGuild
}
public enum SolenFriendship
{
None,
Red,
Black
}
public enum BlockMountType
{
None = -1,
Dazed = 1040024,
BolaRecovery = 1062910,
DismountRecovery = 1070859
}
#endregion
public partial class PlayerMobile : Mobile, IHonorTarget
{
#region Stygian Abyss
public override void ToggleFlying()
{
if (Race != Race.Gargoyle)
{
return;
}
else if (Flying)
{
Freeze(TimeSpan.FromSeconds(1));
Animate(61, 10, 1, true, false, 0);
Flying = false;
BuffInfo.RemoveBuff(this, BuffIcon.Fly);
SendMessage("You have landed.");
BaseMount.Dismount(this);
return;
}
BlockMountType type = MountBlockReason;
if (!Alive)
{
SendLocalizedMessage(1113082); // You may not fly while dead.
}
else if (IsBodyMod && !(BodyMod == 666 || BodyMod == 667))
{
SendLocalizedMessage(1112453); // You can't fly in your current form!
}
else if (type != BlockMountType.None)
{
switch (type)
{
case BlockMountType.Dazed:
SendLocalizedMessage(1112457);
break; // You are still too dazed to fly.
case BlockMountType.BolaRecovery:
SendLocalizedMessage(1112455);
break; // You cannot fly while recovering from a bola throw.
case BlockMountType.DismountRecovery:
SendLocalizedMessage(1112456);
break; // You cannot fly while recovering from a dismount maneuver.
}
return;
}
else if (Hits < 25) // TODO confirm
{
SendLocalizedMessage(1112454); // You must heal before flying.
}
else
{
if (!Flying)
{
// No message?
if (Spell is FlySpell)
{
FlySpell spell = (FlySpell)Spell;
spell.Stop();
}
new FlySpell(this).Cast();
}
else
{
Flying = false;
BuffInfo.RemoveBuff(this, BuffIcon.Fly);
}
}
}
#endregion
private class CountAndTimeStamp
{
private int m_Count;
private DateTime m_Stamp;
public CountAndTimeStamp()
{
}
public DateTime TimeStamp { get{ return m_Stamp; } }
public int Count
{
get { return m_Count; }
set { m_Count = value; m_Stamp = DateTime.UtcNow; }
}
}
private DesignContext m_DesignContext;
private NpcGuild m_NpcGuild;
private DateTime m_NpcGuildJoinTime;
private DateTime m_NextBODTurnInTime;
private TimeSpan m_NpcGuildGameTime;
private PlayerFlag m_Flags;
private int m_StepsTaken;
private int m_Profession;
private bool m_IsStealthing; // IsStealthing should be moved to Server.Mobiles
private bool m_IgnoreMobiles; // IgnoreMobiles should be moved to Server.Mobiles
private int m_NonAutoreinsuredItems; // number of items that could not be automatically reinsured because gold in bank was not enough
private bool m_NinjaWepCooldown;
/*
* a value of zero means, that the mobile is not executing the spell. Otherwise,
* the value should match the BaseMana required
*/
private int m_ExecutesLightningStrike; // move to Server.Mobiles??
private DateTime m_LastOnline;
private Guilds.RankDefinition m_GuildRank;
private int m_GuildMessageHue, m_AllianceMessageHue;
private List<Mobile> m_AutoStabled;
private List<Mobile> m_AllFollowers;
private List<Mobile> m_RecentlyReported;
#region Getters & Setters
public List<Mobile> RecentlyReported
{
get
{
return m_RecentlyReported;
}
set
{
m_RecentlyReported = value;
}
}
public List<Mobile> AutoStabled { get { return m_AutoStabled; } }
public bool NinjaWepCooldown
{
get
{
return m_NinjaWepCooldown;
}
set
{
m_NinjaWepCooldown = value;
}
}
public List<Mobile> AllFollowers
{
get
{
if( m_AllFollowers == null )
m_AllFollowers = new List<Mobile>();
return m_AllFollowers;
}
}
public Server.Guilds.RankDefinition GuildRank
{
get
{
if( this.AccessLevel >= AccessLevel.GameMaster )
return Server.Guilds.RankDefinition.Leader;
else
return m_GuildRank;
}
set{ m_GuildRank = value; }
}
[CommandProperty( AccessLevel.GameMaster )]
public int GuildMessageHue
{
get{ return m_GuildMessageHue; }
set{ m_GuildMessageHue = value; }
}
[CommandProperty( AccessLevel.GameMaster )]
public int AllianceMessageHue
{
get { return m_AllianceMessageHue; }
set { m_AllianceMessageHue = value; }
}
[CommandProperty( AccessLevel.GameMaster )]
public int Profession
{
get{ return m_Profession; }
set{ m_Profession = value; }
}
public int StepsTaken
{
get{ return m_StepsTaken; }
set{ m_StepsTaken = value; }
}
[CommandProperty( AccessLevel.GameMaster )]
public bool IsStealthing // IsStealthing should be moved to Server.Mobiles
{
get { return m_IsStealthing; }
set { m_IsStealthing = value; }
}
[CommandProperty( AccessLevel.GameMaster )]
public bool IgnoreMobiles // IgnoreMobiles should be moved to Server.Mobiles
{
get
{
return m_IgnoreMobiles;
}
set
{
if( m_IgnoreMobiles != value )
{
m_IgnoreMobiles = value;
Delta( MobileDelta.Flags );
}
}
}
[CommandProperty( AccessLevel.GameMaster )]
public NpcGuild NpcGuild
{
get{ return m_NpcGuild; }
set{ m_NpcGuild = value; }
}
[CommandProperty( AccessLevel.GameMaster )]
public DateTime NpcGuildJoinTime
{
get{ return m_NpcGuildJoinTime; }
set{ m_NpcGuildJoinTime = value; }
}
[CommandProperty( AccessLevel.GameMaster )]
public DateTime NextBODTurnInTime
{
get{ return m_NextBODTurnInTime; }
set{ m_NextBODTurnInTime = value; }
}
[CommandProperty( AccessLevel.GameMaster )]
public DateTime LastOnline
{
get{ return m_LastOnline; }
set{ m_LastOnline = value; }
}
[CommandProperty( AccessLevel.GameMaster )]
public long LastMoved
{
get{ return LastMoveTime; }
}
[CommandProperty( AccessLevel.GameMaster )]
public TimeSpan NpcGuildGameTime
{
get{ return m_NpcGuildGameTime; }
set{ m_NpcGuildGameTime = value; }
}
private int m_ToTItemsTurnedIn;
[CommandProperty( AccessLevel.GameMaster )]
public int ToTItemsTurnedIn
{
get { return m_ToTItemsTurnedIn; }
set { m_ToTItemsTurnedIn = value; }
}
private int m_ToTTotalMonsterFame;
[CommandProperty( AccessLevel.GameMaster )]
public int ToTTotalMonsterFame
{
get { return m_ToTTotalMonsterFame; }
set { m_ToTTotalMonsterFame = value; }
}
public int ExecutesLightningStrike
{
get { return m_ExecutesLightningStrike; }
set { m_ExecutesLightningStrike = value; }
}
[CommandProperty( AccessLevel.GameMaster )]
public int ToothAche
{
get { return CandyCane.GetToothAche( this ); }
set { CandyCane.SetToothAche( this, value ); }
}
#endregion
#region PlayerFlags
public PlayerFlag Flags
{
get{ return m_Flags; }
set{ m_Flags = value; }
}
[CommandProperty( AccessLevel.GameMaster )]
public bool PagingSquelched
{
get{ return GetFlag( PlayerFlag.PagingSquelched ); }
set{ SetFlag( PlayerFlag.PagingSquelched, value ); }
}
[CommandProperty( AccessLevel.GameMaster )]
public bool Glassblowing
{
get{ return GetFlag( PlayerFlag.Glassblowing ); }
set{ SetFlag( PlayerFlag.Glassblowing, value ); }
}
[CommandProperty( AccessLevel.GameMaster )]
public bool Masonry
{
get{ return GetFlag( PlayerFlag.Masonry ); }
set{ SetFlag( PlayerFlag.Masonry, value ); }
}
[CommandProperty( AccessLevel.GameMaster )]
public bool SandMining
{
get{ return GetFlag( PlayerFlag.SandMining ); }
set{ SetFlag( PlayerFlag.SandMining, value ); }
}
[CommandProperty( AccessLevel.GameMaster )]
public bool StoneMining
{
get{ return GetFlag( PlayerFlag.StoneMining ); }
set{ SetFlag( PlayerFlag.StoneMining, value ); }
}
[CommandProperty( AccessLevel.GameMaster )]
public bool ToggleMiningStone
{
get{ return GetFlag( PlayerFlag.ToggleMiningStone ); }
set{ SetFlag( PlayerFlag.ToggleMiningStone, value ); }
}
[CommandProperty( AccessLevel.GameMaster )]
public bool KarmaLocked
{
get{ return GetFlag( PlayerFlag.KarmaLocked ); }
set{ SetFlag( PlayerFlag.KarmaLocked, value ); }
}
[CommandProperty( AccessLevel.GameMaster )]
public bool AutoRenewInsurance
{
get{ return GetFlag( PlayerFlag.AutoRenewInsurance ); }
set{ SetFlag( PlayerFlag.AutoRenewInsurance, value ); }
}
[CommandProperty( AccessLevel.GameMaster )]
public bool UseOwnFilter
{
get{ return GetFlag( PlayerFlag.UseOwnFilter ); }
set{ SetFlag( PlayerFlag.UseOwnFilter, value ); }
}
[CommandProperty( AccessLevel.GameMaster )]
public bool PublicMyRunUO
{
get{ return GetFlag( PlayerFlag.PublicMyRunUO ); }
set{ SetFlag( PlayerFlag.PublicMyRunUO, value ); InvalidateMyRunUO(); }
}
[CommandProperty( AccessLevel.GameMaster )]
public bool AcceptGuildInvites
{
get{ return GetFlag( PlayerFlag.AcceptGuildInvites ); }
set{ SetFlag( PlayerFlag.AcceptGuildInvites, value ); }
}
[CommandProperty( AccessLevel.GameMaster )]
public bool HasStatReward
{
get{ return GetFlag( PlayerFlag.HasStatReward ); }
set{ SetFlag( PlayerFlag.HasStatReward, value ); }
}
[CommandProperty( AccessLevel.GameMaster )]
public bool RefuseTrades
{
get{ return GetFlag( PlayerFlag.RefuseTrades ); }
set{ SetFlag( PlayerFlag.RefuseTrades, value ); }
}
#endregion
#region Auto Arrow Recovery
private Dictionary<Type, int> m_RecoverableAmmo = new Dictionary<Type,int>();
public Dictionary<Type, int> RecoverableAmmo
{
get { return m_RecoverableAmmo; }
}
public void RecoverAmmo()
{
if ( Core.SE && Alive )
{
foreach ( KeyValuePair<Type, int> kvp in m_RecoverableAmmo )
{
if ( kvp.Value > 0 )
{
Item ammo = null;
try
{
ammo = Activator.CreateInstance( kvp.Key ) as Item;
}
catch
{
}
if ( ammo != null )
{
string name = ammo.Name;
ammo.Amount = kvp.Value;
if ( name == null )
{
if ( ammo is Arrow )
name = "arrow";
else if ( ammo is Bolt )
name = "bolt";
}
if ( name != null && ammo.Amount > 1 )
name = String.Format( "{0}s", name );
if ( name == null )
name = String.Format( "#{0}", ammo.LabelNumber );
PlaceInBackpack( ammo );
SendLocalizedMessage( 1073504, String.Format( "{0}\t{1}", ammo.Amount, name ) ); // You recover ~1_NUM~ ~2_AMMO~.
}
}
}
m_RecoverableAmmo.Clear();
}
}
#endregion
private DateTime m_AnkhNextUse;
[CommandProperty( AccessLevel.GameMaster )]
public DateTime AnkhNextUse
{
get{ return m_AnkhNextUse; }
set{ m_AnkhNextUse = value; }
}
[CommandProperty( AccessLevel.GameMaster )]
public TimeSpan DisguiseTimeLeft
{
get{ return DisguiseTimers.TimeRemaining( this ); }
}
private DateTime m_PeacedUntil;
[CommandProperty( AccessLevel.GameMaster )]
public DateTime PeacedUntil
{
get { return m_PeacedUntil; }
set { m_PeacedUntil = value; }
}
#region Scroll of Alacrity
private DateTime m_AcceleratedStart;
[CommandProperty(AccessLevel.GameMaster)]
public DateTime AcceleratedStart
{
get { return m_AcceleratedStart; }
set { m_AcceleratedStart = value; }
}
private SkillName m_AcceleratedSkill;
[CommandProperty(AccessLevel.GameMaster)]
public SkillName AcceleratedSkill
{
get { return m_AcceleratedSkill; }
set { m_AcceleratedSkill = value; }
}
#endregion
public static Direction GetDirection4( Point3D from, Point3D to )
{
int dx = from.X - to.X;
int dy = from.Y - to.Y;
int rx = dx - dy;
int ry = dx + dy;
Direction ret;
if ( rx >= 0 && ry >= 0 )
ret = Direction.West;
else if ( rx >= 0 && ry < 0 )
ret = Direction.South;
else if ( rx < 0 && ry < 0 )
ret = Direction.East;
else
ret = Direction.North;
return ret;
}
public override bool OnDroppedItemToWorld( Item item, Point3D location )
{
if ( !base.OnDroppedItemToWorld( item, location ) )
return false;
if ( Core.AOS )
{
IPooledEnumerable mobiles = Map.GetMobilesInRange( location, 0 );
foreach ( Mobile m in mobiles )
{
if ( m.Z >= location.Z && m.Z < location.Z + 16 && ( !m.Hidden || m.AccessLevel == AccessLevel.Player ) )
{
mobiles.Free();
return false;
}
}
mobiles.Free();
}
BounceInfo bi = item.GetBounce();
if ( bi != null )
{
Type type = item.GetType();
if ( type.IsDefined( typeof( FurnitureAttribute ), true ) || type.IsDefined( typeof( DynamicFlipingAttribute ), true ) )
{
object[] objs = type.GetCustomAttributes( typeof( FlipableAttribute ), true );
if ( objs != null && objs.Length > 0 )
{
FlipableAttribute fp = objs[0] as FlipableAttribute;
if ( fp != null )
{
int[] itemIDs = fp.ItemIDs;
Point3D oldWorldLoc = bi.m_WorldLoc;
Point3D newWorldLoc = location;
if ( oldWorldLoc.X != newWorldLoc.X || oldWorldLoc.Y != newWorldLoc.Y )
{
Direction dir = GetDirection4( oldWorldLoc, newWorldLoc );
if ( itemIDs.Length == 2 )
{
switch ( dir )
{
case Direction.North:
case Direction.South: item.ItemID = itemIDs[0]; break;
case Direction.East:
case Direction.West: item.ItemID = itemIDs[1]; break;
}
}
else if ( itemIDs.Length == 4 )
{
switch ( dir )
{
case Direction.South: item.ItemID = itemIDs[0]; break;
case Direction.East: item.ItemID = itemIDs[1]; break;
case Direction.North: item.ItemID = itemIDs[2]; break;
case Direction.West: item.ItemID = itemIDs[3]; break;
}
}
}
}
}
}
}
return true;
}
public override int GetPacketFlags()
{
int flags = base.GetPacketFlags();
if ( m_IgnoreMobiles )
flags |= 0x10;
return flags;
}
public override int GetOldPacketFlags()
{
int flags = base.GetOldPacketFlags();
if ( m_IgnoreMobiles )
flags |= 0x10;
return flags;
}
public bool GetFlag( PlayerFlag flag )
{
return ( (m_Flags & flag) != 0 );
}
public void SetFlag( PlayerFlag flag, bool value )
{
if ( value )
m_Flags |= flag;
else
m_Flags &= ~flag;
}
public DesignContext DesignContext
{
get{ return m_DesignContext; }
set{ m_DesignContext = value; }
}
public static void Initialize()
{
if ( FastwalkPrevention )
PacketHandlers.RegisterThrottler( 0x02, new ThrottlePacketCallback( MovementThrottle_Callback ) );
EventSink.Login += new LoginEventHandler( OnLogin );
EventSink.Logout += new LogoutEventHandler( OnLogout );
EventSink.Connected += new ConnectedEventHandler( EventSink_Connected );
EventSink.Disconnected += new DisconnectedEventHandler( EventSink_Disconnected );
if( Core.SE )
{
Timer.DelayCall( TimeSpan.Zero, new TimerCallback( CheckPets ) );
}
}
private static void CheckPets()
{
foreach( Mobile m in World.Mobiles.Values )
{
if( m is PlayerMobile )
{
PlayerMobile pm = (PlayerMobile)m;
if((( !pm.Mounted || ( pm.Mount != null && pm.Mount is EtherealMount )) && ( pm.AllFollowers.Count > pm.AutoStabled.Count )) ||
( pm.Mounted && ( pm.AllFollowers.Count > ( pm.AutoStabled.Count +1 ))))
{
pm.AutoStablePets(); /* autostable checks summons, et al: no need here */
}
}
}
}
private MountBlock m_MountBlock;
public BlockMountType MountBlockReason
{
get
{
return ( CheckBlock( m_MountBlock ) ) ? m_MountBlock.m_Type : BlockMountType.None;
}
}
private static bool CheckBlock( MountBlock block )
{
return ( ( block is MountBlock ) && block.m_Timer.Running );
}
private class MountBlock
{
public BlockMountType m_Type;
public Timer m_Timer;
public MountBlock( TimeSpan duration, BlockMountType type, Mobile mobile )
{
m_Type = type;
m_Timer = Timer.DelayCall( duration, new TimerStateCallback<Mobile>( RemoveBlock ), mobile );
}
private void RemoveBlock( Mobile mobile )
{
( mobile as PlayerMobile ).m_MountBlock = null;
}
}
public void SetMountBlock( BlockMountType type, TimeSpan duration, bool dismount )
{
if( dismount )
{
if ( this.Mount != null )
{
this.Mount.Rider = null;
}
else if( AnimalForm.UnderTransformation( this ) )
{
AnimalForm.RemoveContext(this, true);
}
}
if( ( m_MountBlock == null ) || !m_MountBlock.m_Timer.Running || ( m_MountBlock.m_Timer.Next < ( DateTime.UtcNow + duration ) ) )
{
m_MountBlock = new MountBlock( duration, type, this );
}
}
public override void OnSkillInvalidated( Skill skill )
{
if ( Core.AOS && skill.SkillName == SkillName.MagicResist )
UpdateResistances();
}
public override int GetMaxResistance( ResistanceType type )
{
if ( AccessLevel > AccessLevel.Player )
return 100;
int max = base.GetMaxResistance( type );
if ( type != ResistanceType.Physical && 60 < max && Spells.Fourth.CurseSpell.UnderEffect( this ) )
max = 60;
if( Core.ML && this.Race == Race.Elf && type == ResistanceType.Energy )
max += 5; //Intended to go after the 60 max from curse
return max;
}
protected override void OnRaceChange( Race oldRace )
{
ValidateEquipment();
UpdateResistances();
}
public override int MaxWeight { get { return (((Core.ML && this.Race == Race.Human) ? 100 : 40) + (int)(3.5 * this.Str)); } }
private int m_LastGlobalLight = -1, m_LastPersonalLight = -1;
public override void OnNetStateChanged()
{
m_LastGlobalLight = -1;
m_LastPersonalLight = -1;
}
public override void ComputeBaseLightLevels( out int global, out int personal )
{
global = LightCycle.ComputeLevelFor( this );
bool racialNightSight = (Core.ML && this.Race == Race.Elf);
if ( this.LightLevel < 21 && ( AosAttributes.GetValue( this, AosAttribute.NightSight ) > 0 || racialNightSight ))
personal = 21;
else
personal = this.LightLevel;
}
public override void CheckLightLevels( bool forceResend )
{
NetState ns = this.NetState;
if ( ns == null )
return;
int global, personal;
ComputeLightLevels( out global, out personal );
if ( !forceResend )
forceResend = ( global != m_LastGlobalLight || personal != m_LastPersonalLight );
if ( !forceResend )
return;
m_LastGlobalLight = global;
m_LastPersonalLight = personal;
ns.Send( GlobalLightLevel.Instantiate( global ) );
ns.Send( new PersonalLightLevel( this, personal ) );
}
public override int GetMinResistance( ResistanceType type )
{
int magicResist = (int)(Skills[SkillName.MagicResist].Value * 10);
int min = int.MinValue;
if ( magicResist >= 1000 )
min = 40 + ((magicResist - 1000) / 50);
else if ( magicResist >= 400 )
min = (magicResist - 400) / 15;
if ( min > MaxPlayerResistance )
min = MaxPlayerResistance;
int baseMin = base.GetMinResistance( type );
if ( min < baseMin )
min = baseMin;
return min;
}
public override void OnManaChange(int oldValue)
{
base.OnManaChange(oldValue);
if (m_ExecutesLightningStrike > 0)
{
if (Mana < m_ExecutesLightningStrike)
{
LightningStrike.ClearCurrentMove(this);
}
}
}
private static void OnLogin( LoginEventArgs e )
{
Mobile from = e.Mobile;
CheckAtrophies( from );
if ( AccountHandler.LockdownLevel > AccessLevel.Player )
{
string notice;
Accounting.Account acct = from.Account as Accounting.Account;
if ( acct == null || !acct.HasAccess( from.NetState ) )
{
if ( from.AccessLevel == AccessLevel.Player )
notice = "The server is currently under lockdown. No players are allowed to log in at this time.";
else
notice = "The server is currently under lockdown. You do not have sufficient access level to connect.";
Timer.DelayCall( TimeSpan.FromSeconds( 1.0 ), new TimerStateCallback( Disconnect ), from );
}
else if ( from.AccessLevel >= AccessLevel.Administrator )
{
notice = "The server is currently under lockdown. As you are an administrator, you may change this from the [Admin gump.";
}
else
{
notice = "The server is currently under lockdown. You have sufficient access level to connect.";
}
from.SendGump( new NoticeGump( 1060637, 30720, notice, 0xFFC000, 300, 140, null, null ) );
return;
}
if( from is PlayerMobile )
((PlayerMobile)from).ClaimAutoStabledPets();
}
private bool m_NoDeltaRecursion;
public void ValidateEquipment()
{
if ( m_NoDeltaRecursion || Map == null || Map == Map.Internal )
return;
if ( this.Items == null )
return;
m_NoDeltaRecursion = true;
Timer.DelayCall( TimeSpan.Zero, new TimerCallback( ValidateEquipment_Sandbox ) );
}
private void ValidateEquipment_Sandbox()
{
try
{
if ( Map == null || Map == Map.Internal )
return;
List<Item> items = this.Items;
if ( items == null )
return;
bool moved = false;
int str = this.Str;
int dex = this.Dex;
int intel = this.Int;
#region Factions
int factionItemCount = 0;
#endregion
Mobile from = this;
#region Ethics
Ethics.Ethic ethic = Ethics.Ethic.Find( from );
#endregion
for ( int i = items.Count - 1; i >= 0; --i )
{
if ( i >= items.Count )
continue;
Item item = items[i];
#region Ethics
if ( ( item.SavedFlags & 0x100 ) != 0 )
{
if ( item.Hue != Ethics.Ethic.Hero.Definition.PrimaryHue )
{
item.SavedFlags &= ~0x100;