forked from runuo/runuo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathItem.cs
4708 lines (3839 loc) · 109 KB
/
Item.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
/***************************************************************************
* Item.cs
* -------------------
* begin : May 1, 2002
* copyright : (C) The RunUO Software Team
* email : [email protected]
*
* $Id$
*
***************************************************************************/
/***************************************************************************
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
***************************************************************************/
using System;
using System.IO;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Server.Network;
using Server.Items;
using Server.ContextMenus;
namespace Server
{
/// <summary>
/// Enumeration of item layer values.
/// </summary>
public enum Layer : byte
{
/// <summary>
/// Invalid layer.
/// </summary>
Invalid = 0x00,
/// <summary>
/// First valid layer. Equivalent to <c>Layer.OneHanded</c>.
/// </summary>
FirstValid = 0x01,
/// <summary>
/// One handed weapon.
/// </summary>
OneHanded = 0x01,
/// <summary>
/// Two handed weapon or shield.
/// </summary>
TwoHanded = 0x02,
/// <summary>
/// Shoes.
/// </summary>
Shoes = 0x03,
/// <summary>
/// Pants.
/// </summary>
Pants = 0x04,
/// <summary>
/// Shirts.
/// </summary>
Shirt = 0x05,
/// <summary>
/// Helmets, hats, and masks.
/// </summary>
Helm = 0x06,
/// <summary>
/// Gloves.
/// </summary>
Gloves = 0x07,
/// <summary>
/// Rings.
/// </summary>
Ring = 0x08,
/// <summary>
/// Talismans.
/// </summary>
Talisman = 0x09,
/// <summary>
/// Gorgets and necklaces.
/// </summary>
Neck = 0x0A,
/// <summary>
/// Hair.
/// </summary>
Hair = 0x0B,
/// <summary>
/// Half aprons.
/// </summary>
Waist = 0x0C,
/// <summary>
/// Torso, inner layer.
/// </summary>
InnerTorso = 0x0D,
/// <summary>
/// Bracelets.
/// </summary>
Bracelet = 0x0E,
/// <summary>
/// Unused.
/// </summary>
Unused_xF = 0x0F,
/// <summary>
/// Beards and mustaches.
/// </summary>
FacialHair = 0x10,
/// <summary>
/// Torso, outer layer.
/// </summary>
MiddleTorso = 0x11,
/// <summary>
/// Earings.
/// </summary>
Earrings = 0x12,
/// <summary>
/// Arms and sleeves.
/// </summary>
Arms = 0x13,
/// <summary>
/// Cloaks.
/// </summary>
Cloak = 0x14,
/// <summary>
/// Backpacks.
/// </summary>
Backpack = 0x15,
/// <summary>
/// Torso, outer layer.
/// </summary>
OuterTorso = 0x16,
/// <summary>
/// Leggings, outer layer.
/// </summary>
OuterLegs = 0x17,
/// <summary>
/// Leggings, inner layer.
/// </summary>
InnerLegs = 0x18,
/// <summary>
/// Last valid non-internal layer. Equivalent to <c>Layer.InnerLegs</c>.
/// </summary>
LastUserValid= 0x18,
/// <summary>
/// Mount item layer.
/// </summary>
Mount = 0x19,
/// <summary>
/// Vendor 'buy pack' layer.
/// </summary>
ShopBuy = 0x1A,
/// <summary>
/// Vendor 'resale pack' layer.
/// </summary>
ShopResale = 0x1B,
/// <summary>
/// Vendor 'sell pack' layer.
/// </summary>
ShopSell = 0x1C,
/// <summary>
/// Bank box layer.
/// </summary>
Bank = 0x1D,
/// <summary>
/// Last valid layer. Equivalent to <c>Layer.Bank</c>.
/// </summary>
LastValid = 0x1D
}
/// <summary>
/// Internal flags used to signal how the item should be updated and resent to nearby clients.
/// </summary>
[Flags]
public enum ItemDelta
{
/// <summary>
/// Nothing.
/// </summary>
None = 0x00000000,
/// <summary>
/// Resend the item.
/// </summary>
Update = 0x00000001,
/// <summary>
/// Resend the item only if it is equiped.
/// </summary>
EquipOnly = 0x00000002,
/// <summary>
/// Resend the item's properties.
/// </summary>
Properties = 0x00000004
}
/// <summary>
/// Enumeration containing possible ways to handle item ownership on death.
/// </summary>
public enum DeathMoveResult
{
/// <summary>
/// The item should be placed onto the corpse.
/// </summary>
MoveToCorpse,
/// <summary>
/// The item should remain equiped.
/// </summary>
RemainEquiped,
/// <summary>
/// The item should be placed into the owners backpack.
/// </summary>
MoveToBackpack
}
/// <summary>
/// Enumeration containing all possible light types. These are only applicable to light source items, like lanterns, candles, braziers, etc.
/// </summary>
public enum LightType
{
/// <summary>
/// Window shape, arched, ray shining east.
/// </summary>
ArchedWindowEast,
/// <summary>
/// Medium circular shape.
/// </summary>
Circle225,
/// <summary>
/// Small circular shape.
/// </summary>
Circle150,
/// <summary>
/// Door shape, shining south.
/// </summary>
DoorSouth,
/// <summary>
/// Door shape, shining east.
/// </summary>
DoorEast,
/// <summary>
/// Large semicircular shape (180 degrees), north wall.
/// </summary>
NorthBig,
/// <summary>
/// Large pie shape (90 degrees), north-east corner.
/// </summary>
NorthEastBig,
/// <summary>
/// Large semicircular shape (180 degrees), east wall.
/// </summary>
EastBig,
/// <summary>
/// Large semicircular shape (180 degrees), west wall.
/// </summary>
WestBig,
/// <summary>
/// Large pie shape (90 degrees), south-west corner.
/// </summary>
SouthWestBig,
/// <summary>
/// Large semicircular shape (180 degrees), south wall.
/// </summary>
SouthBig,
/// <summary>
/// Medium semicircular shape (180 degrees), north wall.
/// </summary>
NorthSmall,
/// <summary>
/// Medium pie shape (90 degrees), north-east corner.
/// </summary>
NorthEastSmall,
/// <summary>
/// Medium semicircular shape (180 degrees), east wall.
/// </summary>
EastSmall,
/// <summary>
/// Medium semicircular shape (180 degrees), west wall.
/// </summary>
WestSmall,
/// <summary>
/// Medium semicircular shape (180 degrees), south wall.
/// </summary>
SouthSmall,
/// <summary>
/// Shaped like a wall decoration, north wall.
/// </summary>
DecorationNorth,
/// <summary>
/// Shaped like a wall decoration, north-east corner.
/// </summary>
DecorationNorthEast,
/// <summary>
/// Small semicircular shape (180 degrees), east wall.
/// </summary>
EastTiny,
/// <summary>
/// Shaped like a wall decoration, west wall.
/// </summary>
DecorationWest,
/// <summary>
/// Shaped like a wall decoration, south-west corner.
/// </summary>
DecorationSouthWest,
/// <summary>
/// Small semicircular shape (180 degrees), south wall.
/// </summary>
SouthTiny,
/// <summary>
/// Window shape, rectangular, no ray, shining south.
/// </summary>
RectWindowSouthNoRay,
/// <summary>
/// Window shape, rectangular, no ray, shining east.
/// </summary>
RectWindowEastNoRay,
/// <summary>
/// Window shape, rectangular, ray shining south.
/// </summary>
RectWindowSouth,
/// <summary>
/// Window shape, rectangular, ray shining east.
/// </summary>
RectWindowEast,
/// <summary>
/// Window shape, arched, no ray, shining south.
/// </summary>
ArchedWindowSouthNoRay,
/// <summary>
/// Window shape, arched, no ray, shining east.
/// </summary>
ArchedWindowEastNoRay,
/// <summary>
/// Window shape, arched, ray shining south.
/// </summary>
ArchedWindowSouth,
/// <summary>
/// Large circular shape.
/// </summary>
Circle300,
/// <summary>
/// Large pie shape (90 degrees), north-west corner.
/// </summary>
NorthWestBig,
/// <summary>
/// Negative light. Medium pie shape (90 degrees), south-east corner.
/// </summary>
DarkSouthEast,
/// <summary>
/// Negative light. Medium semicircular shape (180 degrees), south wall.
/// </summary>
DarkSouth,
/// <summary>
/// Negative light. Medium pie shape (90 degrees), north-west corner.
/// </summary>
DarkNorthWest,
/// <summary>
/// Negative light. Medium pie shape (90 degrees), south-east corner. Equivalent to <c>LightType.SouthEast</c>.
/// </summary>
DarkSouthEast2,
/// <summary>
/// Negative light. Medium circular shape (180 degrees), east wall.
/// </summary>
DarkEast,
/// <summary>
/// Negative light. Large circular shape.
/// </summary>
DarkCircle300,
/// <summary>
/// Opened door shape, shining south.
/// </summary>
DoorOpenSouth,
/// <summary>
/// Opened door shape, shining east.
/// </summary>
DoorOpenEast,
/// <summary>
/// Window shape, square, ray shining east.
/// </summary>
SquareWindowEast,
/// <summary>
/// Window shape, square, no ray, shining east.
/// </summary>
SquareWindowEastNoRay,
/// <summary>
/// Window shape, square, ray shining south.
/// </summary>
SquareWindowSouth,
/// <summary>
/// Window shape, square, no ray, shining south.
/// </summary>
SquareWindowSouthNoRay,
/// <summary>
/// Empty.
/// </summary>
Empty,
/// <summary>
/// Window shape, skinny, no ray, shining south.
/// </summary>
SkinnyWindowSouthNoRay,
/// <summary>
/// Window shape, skinny, ray shining east.
/// </summary>
SkinnyWindowEast,
/// <summary>
/// Window shape, skinny, no ray, shining east.
/// </summary>
SkinnyWindowEastNoRay,
/// <summary>
/// Shaped like a hole, shining south.
/// </summary>
HoleSouth,
/// <summary>
/// Shaped like a hole, shining south.
/// </summary>
HoleEast,
/// <summary>
/// Large circular shape with a moongate graphic embeded.
/// </summary>
Moongate,
/// <summary>
/// Unknown usage. Many rows of slightly angled lines.
/// </summary>
Strips,
/// <summary>
/// Shaped like a small hole, shining south.
/// </summary>
SmallHoleSouth,
/// <summary>
/// Shaped like a small hole, shining east.
/// </summary>
SmallHoleEast,
/// <summary>
/// Large semicircular shape (180 degrees), north wall. Identical graphic as <c>LightType.NorthBig</c>, but slightly different positioning.
/// </summary>
NorthBig2,
/// <summary>
/// Large semicircular shape (180 degrees), west wall. Identical graphic as <c>LightType.WestBig</c>, but slightly different positioning.
/// </summary>
WestBig2,
/// <summary>
/// Large pie shape (90 degrees), north-west corner. Equivalent to <c>LightType.NorthWestBig</c>.
/// </summary>
NorthWestBig2
}
/// <summary>
/// Enumeration of an item's loot and steal state.
/// </summary>
public enum LootType : byte
{
/// <summary>
/// Stealable. Lootable.
/// </summary>
Regular = 0,
/// <summary>
/// Unstealable. Unlootable, unless owned by a murderer.
/// </summary>
Newbied = 1,
/// <summary>
/// Unstealable. Unlootable, always.
/// </summary>
Blessed = 2,
/// <summary>
/// Stealable. Lootable, always.
/// </summary>
Cursed = 3
}
public class BounceInfo
{
public Map m_Map;
public Point3D m_Location, m_WorldLoc;
public IEntity m_Parent;
public BounceInfo( Item item )
{
m_Map = item.Map;
m_Location = item.Location;
m_WorldLoc = item.GetWorldLocation();
m_Parent = item.Parent;
}
private BounceInfo( Map map, Point3D loc, Point3D worldLoc, IEntity parent )
{
m_Map = map;
m_Location = loc;
m_WorldLoc = worldLoc;
m_Parent = parent;
}
public static BounceInfo Deserialize( GenericReader reader )
{
if ( reader.ReadBool() )
{
Map map = reader.ReadMap();
Point3D loc = reader.ReadPoint3D();
Point3D worldLoc = reader.ReadPoint3D();
IEntity parent;
Serial serial = reader.ReadInt();
if ( serial.IsItem )
parent = World.FindItem( serial );
else if ( serial.IsMobile )
parent = World.FindMobile( serial );
else
parent = null;
return new BounceInfo( map, loc, worldLoc, parent );
}
else
{
return null;
}
}
public static void Serialize( BounceInfo info, GenericWriter writer )
{
if ( info == null )
{
writer.Write( false );
}
else
{
writer.Write( true );
writer.Write( info.m_Map );
writer.Write( info.m_Location );
writer.Write( info.m_WorldLoc );
if ( info.m_Parent is Mobile )
writer.Write( (Mobile) info.m_Parent );
else if ( info.m_Parent is Item )
writer.Write( (Item) info.m_Parent );
else
writer.Write( (Serial) 0 );
}
}
}
public enum TotalType
{
Gold,
Items,
Weight,
}
[Flags]
public enum ExpandFlag
{
None = 0x000,
Name = 0x001,
Items = 0x002,
Bounce = 0x004,
Holder = 0x008,
Blessed = 0x010,
TempFlag = 0x020,
SaveFlag = 0x040,
Weight = 0x080,
Spawner = 0x100
}
public class Item : IEntity, IHued, IComparable<Item>, ISerializable, ISpawnable
{
public static readonly List<Item> EmptyItems = new List<Item>();
public int CompareTo( IEntity other )
{
if ( other == null )
return -1;
return m_Serial.CompareTo( other.Serial );
}
public int CompareTo( Item other )
{
return this.CompareTo( (IEntity) other );
}
public int CompareTo( object other )
{
if ( other == null || other is IEntity )
return this.CompareTo( (IEntity) other );
throw new ArgumentException();
}
#region Standard fields
private Serial m_Serial;
private Point3D m_Location;
private int m_ItemID;
private int m_Hue;
private int m_Amount;
private Layer m_Layer;
private IEntity m_Parent; // Mobile, Item, or null=World
private Map m_Map;
private LootType m_LootType;
private DateTime m_LastMovedTime;
private Direction m_Direction;
#endregion
private ItemDelta m_DeltaFlags;
private ImplFlag m_Flags;
#region Packet caches
private Packet m_WorldPacket;
private Packet m_WorldPacketSA;
private Packet m_WorldPacketHS;
private Packet m_RemovePacket;
private Packet m_OPLPacket;
private ObjectPropertyList m_PropertyList;
#endregion
public int TempFlags
{
get
{
CompactInfo info = LookupCompactInfo();
if ( info != null )
return info.m_TempFlags;
return 0;
}
set
{
CompactInfo info = AcquireCompactInfo();
info.m_TempFlags = value;
if ( info.m_TempFlags == 0 )
VerifyCompactInfo();
}
}
public int SavedFlags
{
get
{
CompactInfo info = LookupCompactInfo();
if ( info != null )
return info.m_SavedFlags;
return 0;
}
set
{
CompactInfo info = AcquireCompactInfo();
info.m_SavedFlags = value;
if ( info.m_SavedFlags == 0 )
VerifyCompactInfo();
}
}
/// <summary>
/// The <see cref="Mobile" /> who is currently <see cref="Mobile.Holding">holding</see> this item.
/// </summary>
public Mobile HeldBy
{
get
{
CompactInfo info = LookupCompactInfo();
if ( info != null )
return info.m_HeldBy;
return null;
}
set
{
CompactInfo info = AcquireCompactInfo();
info.m_HeldBy = value;
if ( info.m_HeldBy == null )
VerifyCompactInfo();
}
}
[Flags]
private enum ImplFlag : byte
{
None = 0x00,
Visible = 0x01,
Movable = 0x02,
Deleted = 0x04,
Stackable = 0x08,
InQueue = 0x10,
Insured = 0x20,
PayedInsurance = 0x40,
QuestItem = 0x80
}
private class CompactInfo
{
public string m_Name;
public List<Item> m_Items;
public BounceInfo m_Bounce;
public Mobile m_HeldBy;
public Mobile m_BlessedFor;
public ISpawner m_Spawner;
public int m_TempFlags;
public int m_SavedFlags;
public double m_Weight = -1;
}
private CompactInfo m_CompactInfo;
public ExpandFlag GetExpandFlags()
{
CompactInfo info = LookupCompactInfo();
ExpandFlag flags = 0;
if ( info != null )
{
if ( info.m_BlessedFor != null )
flags |= ExpandFlag.Blessed;
if ( info.m_Bounce != null )
flags |= ExpandFlag.Bounce;
if ( info.m_HeldBy != null )
flags |= ExpandFlag.Holder;
if ( info.m_Items != null )
flags |= ExpandFlag.Items;
if ( info.m_Name != null )
flags |= ExpandFlag.Name;
if (info.m_Spawner != null)
flags |= ExpandFlag.Spawner;
if ( info.m_SavedFlags != 0 )
flags |= ExpandFlag.SaveFlag;
if ( info.m_TempFlags != 0 )
flags |= ExpandFlag.TempFlag;
if ( info.m_Weight != -1 )
flags |= ExpandFlag.Weight;
}
return flags;
}
private CompactInfo LookupCompactInfo()
{
return m_CompactInfo;
}
private CompactInfo AcquireCompactInfo()
{
if ( m_CompactInfo == null )
m_CompactInfo = new CompactInfo();
return m_CompactInfo;
}
private void ReleaseCompactInfo()
{
m_CompactInfo = null;
}
private void VerifyCompactInfo()
{
CompactInfo info = m_CompactInfo;
if ( info == null )
return;
bool isValid = ( info.m_Name != null )
|| ( info.m_Items != null )
|| ( info.m_Bounce != null )
|| ( info.m_HeldBy != null )
|| ( info.m_BlessedFor != null )
|| ( info.m_Spawner != null )
|| ( info.m_TempFlags != 0 )
|| ( info.m_SavedFlags != 0 )
|| ( info.m_Weight != -1 );
if ( !isValid )
ReleaseCompactInfo();
}
public List<Item> LookupItems()
{
if ( this is Container )
return ( this as Container ).m_Items;
CompactInfo info = LookupCompactInfo();
if ( info != null )
return info.m_Items;
return null;
}
public List<Item> AcquireItems()
{
if ( this is Container )
{
Container cont = this as Container;
if ( cont.m_Items == null )
cont.m_Items = new List<Item>();
return cont.m_Items;
}
CompactInfo info = AcquireCompactInfo();
if ( info.m_Items == null )
info.m_Items = new List<Item>();
return info.m_Items;
}
private void SetFlag( ImplFlag flag, bool value )
{
if ( value )
m_Flags |= flag;
else
m_Flags &= ~flag;
}
private bool GetFlag( ImplFlag flag )
{
return ( (m_Flags & flag) != 0 );
}
public BounceInfo GetBounce()
{
CompactInfo info = LookupCompactInfo();
if ( info != null )
return info.m_Bounce;
return null;
}
public void RecordBounce()
{
CompactInfo info = AcquireCompactInfo();
info.m_Bounce = new BounceInfo( this );
}
public void ClearBounce()
{
CompactInfo info = LookupCompactInfo();
if ( info != null )
{
BounceInfo bounce = info.m_Bounce;
if ( bounce != null )
{
info.m_Bounce = null;
if ( bounce.m_Parent is Item )
{
Item parent = (Item) bounce.m_Parent;
if ( !parent.Deleted )
parent.OnItemBounceCleared( this );
}
else if ( bounce.m_Parent is Mobile )
{
Mobile parent = (Mobile) bounce.m_Parent;
if ( !parent.Deleted )
parent.OnItemBounceCleared( this );
}
VerifyCompactInfo();
}
}
}
/// <summary>
/// Overridable. Virtual event invoked when a client, <paramref name="from" />, invokes a 'help request' for the Item. Seemingly no longer functional in newer clients.
/// </summary>
public virtual void OnHelpRequest( Mobile from )
{
}
/// <summary>
/// Overridable. Method checked to see if the item can be traded.
/// </summary>
/// <returns>True if the trade is allowed, false if not.</returns>
public virtual bool AllowSecureTrade( Mobile from, Mobile to, Mobile newOwner, bool accepted )
{
return true;
}
/// <summary>
/// Overridable. Virtual event invoked when a trade has completed, either successfully or not.
/// </summary>
public virtual void OnSecureTrade( Mobile from, Mobile to, Mobile newOwner, bool accepted )
{
}
/// <summary>
/// Overridable. Method checked to see if the elemental resistances of this Item conflict with another Item on the <see cref="Mobile" />.
/// </summary>
/// <returns>
/// <list type="table">
/// <item>
/// <term>True</term>
/// <description>There is a confliction. The elemental resistance bonuses of this Item should not be applied to the <see cref="Mobile" /></description>
/// </item>
/// <item>
/// <term>False</term>
/// <description>There is no confliction. The bonuses should be applied.</description>
/// </item>
/// </list>
/// </returns>
public virtual bool CheckPropertyConfliction( Mobile m )
{
return false;
}
/// <summary>
/// Overridable. Sends the <see cref="PropertyList">object property list</see> to <paramref name="from" />.
/// </summary>
public virtual void SendPropertiesTo( Mobile from )
{
from.Send( PropertyList );
}
/// <summary>
/// Overridable. Adds the name of this item to the given <see cref="ObjectPropertyList" />. This method should be overriden if the item requires a complex naming format.
/// </summary>
public virtual void AddNameProperty( ObjectPropertyList list )
{
string name = this.Name;
if ( name == null )
{
if ( m_Amount <= 1 )
list.Add( LabelNumber );
else
list.Add( 1050039, "{0}\t#{1}", m_Amount, LabelNumber ); // ~1_NUMBER~ ~2_ITEMNAME~
}
else
{
if ( m_Amount <= 1 )
list.Add( name );
else
list.Add( 1050039, "{0}\t{1}", m_Amount, Name ); // ~1_NUMBER~ ~2_ITEMNAME~
}
}
/// <summary>
/// Overridable. Adds the loot type of this item to the given <see cref="ObjectPropertyList" />. By default, this will be either 'blessed', 'cursed', or 'insured'.
/// </summary>
public virtual void AddLootTypeProperty( ObjectPropertyList list )
{
if ( m_LootType == LootType.Blessed )
list.Add( 1038021 ); // blessed
else if ( m_LootType == LootType.Cursed )
list.Add( 1049643 ); // cursed
else if ( Insured )
list.Add( 1061682 ); // <b>insured</b>
}
/// <summary>
/// Overridable. Adds any elemental resistances of this item to the given <see cref="ObjectPropertyList" />.
/// </summary>
public virtual void AddResistanceProperties( ObjectPropertyList list )
{
int v = PhysicalResistance;
if ( v != 0 )
list.Add( 1060448, v.ToString() ); // physical resist ~1_val~%
v = FireResistance;
if ( v != 0 )
list.Add( 1060447, v.ToString() ); // fire resist ~1_val~%
v = ColdResistance;
if ( v != 0 )
list.Add( 1060445, v.ToString() ); // cold resist ~1_val~%
v = PoisonResistance;