-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBabyPowder.cs
151 lines (122 loc) · 3.94 KB
/
BabyPowder.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
/* This quest was made in Honor of Debbie from the DebbaDoo Server and stolen by SphericalSolaris */
using System;
using Server;
using Server.Network;
using Server.Targeting;
using Server.Mobiles;
using System.Collections;
using Server.Accounting;
using Server.Misc;
namespace Server.Items
{
public class BabyPowder : Item
{
[Constructable]
public BabyPowder() : this( 1 )
{
}
[Constructable]
public BabyPowder( int amount ) : base( 0x26B8 )
{
Name = "Baby Powder";
Stackable = true;
Weight = 0.1;
Amount = amount;
Hue = 1153;
}
#region Skill Gain
public const double SkillGainFactor = 1.0 / 3;
public static readonly TimeSpan SkillGainPeriod = TimeSpan.FromMinutes( 30.0 );//effect of 33% more skill for 30 minutes
private static Hashtable m_SkillGain = new Hashtable();
private class SkillGainContext
{
public Timer m_Timer;
public ArrayList m_Mods;
}
public override void OnDoubleClick( Mobile mob )
{
SkillGainContext context = (SkillGainContext)m_SkillGain[mob];
if ( context != null )
return;
context = new SkillGainContext();
m_SkillGain[mob] = context;
ArrayList mods = context.m_Mods = new ArrayList();
for ( int i = 0; i < mob.Skills.Length; ++i )
{
Skill sk = mob.Skills[i];
double baseValue = sk.Base;
if ( mob.InRange( this.GetWorldLocation(), 2 ) )
{
Container pack = mob.Backpack;
int m_Amount = mob.Backpack.GetAmount( typeof( BabyPowder ) );
if ( pack != null && pack.ConsumeTotal( typeof( BabyPowder ), m_Amount) )
{
if( m_Amount != 1 )
{
mob.AddToBackpack( new BabyPowder( m_Amount-1 ));
}
if ( baseValue > 0 )
{
SkillMod mod = new DefaultSkillMod( SkillName.Fencing, true, +(baseValue * SkillGainFactor) );
SkillMod mod1 = new DefaultSkillMod( SkillName.Parry, true, +(baseValue * SkillGainFactor) );
SkillMod mod2 = new DefaultSkillMod( SkillName.Swords, true, +(baseValue * SkillGainFactor) );
SkillMod mod3 = new DefaultSkillMod( SkillName.Archery, true, +(baseValue * SkillGainFactor) );
SkillMod mod4 = new DefaultSkillMod( SkillName.Macing, true, +(baseValue * SkillGainFactor) );
SkillMod mod5 = new DefaultSkillMod( SkillName.Tactics, true, +(baseValue * SkillGainFactor) );
SkillMod mod6 = new DefaultSkillMod( SkillName.Wrestling, true, +(baseValue * SkillGainFactor) );
mods.Add( mod );
mods.Add( mod1 );
mods.Add( mod2 );
mods.Add( mod3 );
mods.Add( mod4 );
mods.Add( mod5 );
mods.Add( mod6 );
mob.AddSkillMod( mod );
mob.AddSkillMod( mod1 );
mob.AddSkillMod( mod2 );
mob.AddSkillMod( mod3 );
mob.AddSkillMod( mod4 );
mob.AddSkillMod( mod5 );
mob.AddSkillMod( mod6 );
mob.SendMessage("You sprinkle some baby powder on your body and it makes your skin more resistant in combat.");
}
else
{
mob.LocalOverheadMessage( MessageType.Regular, 0x3B2, 1019045 ); // I can't reach that.
}
}
}
}
context.m_Timer = Timer.DelayCall( SkillGainPeriod, new TimerStateCallback( ClearSkillGain_Callback ), mob );
}
private static void ClearSkillGain_Callback( object state )
{
ClearSkillGain( (Mobile) state );
}
public static void ClearSkillGain( Mobile mob )
{
SkillGainContext context = (SkillGainContext)m_SkillGain[mob];
if ( context == null )
return;
m_SkillGain.Remove( mob );
ArrayList mods = context.m_Mods;
for ( int i = 0; i < mods.Count; ++i )
mob.RemoveSkillMod( (SkillMod) mods[i] );
context.m_Timer.Stop();
}
#endregion
public BabyPowder( Serial serial ) : base( serial )
{
}
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
writer.WriteEncodedInt( (int) 0 ); // version
}
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
int version = reader.ReadEncodedInt();
}
}
}