public static void InvokeOnEffectExpired(Mobile from, FoodEffect effect) { if (OnEffectExpired != null) { OnEffectExpired(from, effect); } }
public void ApplyButtonPressed(IGumpComponent sender, object param) { String[] values = new String[] { GetTextEntry("Food Type"), GetTextEntry("Hit Point Regen"), GetTextEntry("Stamina Regen"), GetTextEntry("Mana Regen"), GetTextEntry("STR Bonus"), GetTextEntry("DEX Bonus"), GetTextEntry("INT Bonus"), GetTextEntry("Duration") }; Boolean valid = true; valid &= IsFoodType(values[0]); for (Int32 i = 1; i < 8; i++) { valid &= IsValidNumber(values[i], (i < 7)); } if (valid) { Int32[] parsedValues = new Int32[] { 0, 0, 0, 0, 0, 0, 0 }; for (Int32 i = 1; i < 8; i++) { Int32.TryParse(values[i], out parsedValues[i - 1]); } FoodEffect effect = new FoodEffect(parsedValues[0], parsedValues[1], parsedValues[2], parsedValues[3], parsedValues[4], parsedValues[5], parsedValues[6]); Type type = ScriptCompiler.FindTypeByName(values[0]); if (_EffectIndex < _FoodTypes.Count) { _FoodTypes[_EffectIndex] = type; _FoodEffects[_EffectIndex] = effect; } else { _FoodTypes.Add(type); _FoodEffects.Add(effect); } if (Address != null) { Address.SendGump(new FoodEffectsSetupGump(_CoreEnabled, _FoodTypes, _FoodEffects, (_EffectIndex / 10) * 10)); } } else if (Address != null) { Address.SendGump(new FoodEffectGump(_CoreEnabled, _FoodTypes, _FoodEffects, _EffectIndex, values, true)); } }
public void ApplyEffect(FoodEffect effect, Boolean silent) { if (FoodEffectsCore.Core == null || !FoodEffectsCore.Core.Enabled || !Core.AOS) { EffectExpired(true); return; } if (LinkedMobile != null) { if (m_Timer != null) { m_Timer.Stop(); m_Timer = null; } LinkedMobile.RemoveStatMod("Food-StrBonus"); LinkedMobile.RemoveStatMod("Food-DexBonus"); LinkedMobile.RemoveStatMod("Food-IntBonus"); if (m_BuffInfo != null) BuffInfo.RemoveBuff(LinkedMobile, m_BuffInfo); if (m_FoodEffect != null) FoodEffectsCore.InvokeOnEffectCanceled(LinkedMobile, m_FoodEffect); m_FoodEffect = new FoodEffect(effect.RegenHits, effect.RegenStam, effect.RegenMana, effect.StrBonus, effect.DexBonus, effect.IntBonus, effect.Duration); if (m_FoodEffect.StrBonus != 0) LinkedMobile.AddStatMod(new StatMod(StatType.Str, "Food-StrBonus", m_FoodEffect.StrBonus, m_FoodEffect.EffectTimeSpan)); if (m_FoodEffect.DexBonus != 0) LinkedMobile.AddStatMod(new StatMod(StatType.Dex, "Food-DexBonus", m_FoodEffect.DexBonus, m_FoodEffect.EffectTimeSpan)); if (m_FoodEffect.IntBonus != 0) LinkedMobile.AddStatMod(new StatMod(StatType.Int, "Food-IntBonus", m_FoodEffect.IntBonus, m_FoodEffect.EffectTimeSpan)); if (!silent) { LinkedMobile.FixedEffect(0x375A, 10, 15); LinkedMobile.PlaySound(0x1EE); LinkedMobile.SendMessage(12, "The food you ate is now affecting your performance..."); } m_Timer = new EffectTimer(this); FoodEffectsCore.InvokeOnEffectActivated(LinkedMobile, m_FoodEffect); m_BuffInfo = new BuffInfo(BuffIcon.ActiveMeditation, 1074240, 1114057, m_FoodEffect.EffectTimeSpan, LinkedMobile, m_FoodEffect.GetBuffInfoText()); BuffInfo.AddBuff(LinkedMobile, m_BuffInfo); } }
public void EffectExpired(Boolean silent) { if (m_Timer != null) { m_Timer.Stop(); m_Timer = null; } if (m_FoodEffect != null) { if (LinkedMobile != null) { LinkedMobile.RemoveStatMod("Food-StrBonus"); LinkedMobile.RemoveStatMod("Food-DexBonus"); LinkedMobile.RemoveStatMod("Food-IntBonus"); if (m_BuffInfo != null) { BuffInfo.RemoveBuff(LinkedMobile, m_BuffInfo); } if (!silent) { LinkedMobile.PlaySound(0x1E6); LinkedMobile.SendMessage(12, "Your food effect has worn off"); } if (m_FoodEffect != null) { FoodEffectsCore.InvokeOnEffectExpired(LinkedMobile, m_FoodEffect); } } m_FoodEffect = null; } }
public override void Deserialize(GenericReader reader) { base.Deserialize(reader); Int32 version = reader.ReadInt(); switch (version) { case 0: // Version 0 if (reader.ReadBool()) { m_FoodEffect = new FoodEffect(reader.ReadInt(), reader.ReadInt(), reader.ReadInt(), reader.ReadInt(), reader.ReadInt(), reader.ReadInt(), (reader.ReadInt() / 60) + 1); } if (m_FoodEffect != null) { ApplyEffect(m_FoodEffect, true); } break; } }
public void ApplyEffect(FoodEffect effect, Boolean silent) { if (FoodEffectsCore.Core == null || !FoodEffectsCore.Core.Enabled || !Core.AOS) { EffectExpired(true); return; } if (LinkedMobile != null) { if (m_Timer != null) { m_Timer.Stop(); m_Timer = null; } LinkedMobile.RemoveStatMod("Food-StrBonus"); LinkedMobile.RemoveStatMod("Food-DexBonus"); LinkedMobile.RemoveStatMod("Food-IntBonus"); if (m_BuffInfo != null) { BuffInfo.RemoveBuff(LinkedMobile, m_BuffInfo); } if (m_FoodEffect != null) { FoodEffectsCore.InvokeOnEffectCanceled(LinkedMobile, m_FoodEffect); } m_FoodEffect = new FoodEffect(effect.RegenHits, effect.RegenStam, effect.RegenMana, effect.StrBonus, effect.DexBonus, effect.IntBonus, effect.Duration); if (m_FoodEffect.StrBonus != 0) { LinkedMobile.AddStatMod(new StatMod(StatType.Str, "Food-StrBonus", m_FoodEffect.StrBonus, m_FoodEffect.EffectTimeSpan)); } if (m_FoodEffect.DexBonus != 0) { LinkedMobile.AddStatMod(new StatMod(StatType.Dex, "Food-DexBonus", m_FoodEffect.DexBonus, m_FoodEffect.EffectTimeSpan)); } if (m_FoodEffect.IntBonus != 0) { LinkedMobile.AddStatMod(new StatMod(StatType.Int, "Food-IntBonus", m_FoodEffect.IntBonus, m_FoodEffect.EffectTimeSpan)); } if (!silent) { LinkedMobile.FixedEffect(0x375A, 10, 15); LinkedMobile.PlaySound(0x1EE); LinkedMobile.SendMessage(12, "The food you ate is now affecting your performance..."); } m_Timer = new EffectTimer(this); FoodEffectsCore.InvokeOnEffectActivated(LinkedMobile, m_FoodEffect); m_BuffInfo = new BuffInfo(BuffIcon.ActiveMeditation, 1074240, 1114057, m_FoodEffect.EffectTimeSpan, LinkedMobile, m_FoodEffect.GetBuffInfoText()); BuffInfo.AddBuff(LinkedMobile, m_BuffInfo); } }
public void ApplyEffect(FoodEffect effect) { ApplyEffect(effect, false); }
public override void OnResponse(Server.Network.NetState sender, RelayInfo info) { String[] values = new String[] { "", "0", "0", "0", "0", "0", "0", "0" }; values[0] = info.GetTextEntry(ID_FoodType).Text.Trim(); values[1] = info.GetTextEntry(ID_HitsRegen).Text; values[2] = info.GetTextEntry(ID_StamRegen).Text; values[3] = info.GetTextEntry(ID_ManaRegen).Text; values[4] = info.GetTextEntry(ID_StrBonus).Text; values[5] = info.GetTextEntry(ID_DexBonus).Text; values[6] = info.GetTextEntry(ID_IntBonus).Text; values[7] = info.GetTextEntry(ID_Duration).Text; switch (info.ButtonID) { case ID_Apply_Button: Boolean valid = true; valid &= IsFoodType(values[0]); for (Int32 i = 1; i < 8; i++) valid &= IsValidNumber(values[i], (i < 7)); if (valid) { Int32[] parsedValues = new Int32[] { 0, 0, 0, 0, 0, 0, 0 }; for (Int32 i = 1; i < 8; i++) Int32.TryParse(values[i], out parsedValues[i - 1]); FoodEffect effect = new FoodEffect(parsedValues[0], parsedValues[1], parsedValues[2], parsedValues[3], parsedValues[4], parsedValues[5], parsedValues[6]); Type type = ScriptCompiler.FindTypeByName(values[0]); if (m_EffectIndex < m_FoodTypes.Count) { m_FoodTypes[m_EffectIndex] = type; m_FoodEffects[m_EffectIndex] = effect; } else { m_FoodTypes.Add(type); m_FoodEffects.Add(effect); } sender.Mobile.SendGump(new FoodEffectsSetupGump(sender.Mobile, m_CoreEnabled, m_FoodTypes, m_FoodEffects, (m_EffectIndex / 10) * 10)); } else { sender.Mobile.SendGump(new FoodEffectGump(sender.Mobile, m_CoreEnabled, m_FoodTypes, m_FoodEffects, m_EffectIndex, values, true)); } break; default: sender.Mobile.SendGump(new FoodEffectsSetupGump(sender.Mobile, m_CoreEnabled, m_FoodTypes, m_FoodEffects, (m_EffectIndex / 10) * 10)); break; } }
public void ApplyButtonPressed(IGumpComponent sender, object param) { String[] values = new String[] { GetTextEntry("Food Type"), GetTextEntry("Hit Point Regen"), GetTextEntry("Stamina Regen"), GetTextEntry("Mana Regen"), GetTextEntry("STR Bonus"), GetTextEntry("DEX Bonus"), GetTextEntry("INT Bonus"), GetTextEntry("Duration") }; Boolean valid = true; valid &= IsFoodType(values[0]); for (Int32 i = 1; i < 8; i++) valid &= IsValidNumber(values[i], (i < 7)); if (valid) { Int32[] parsedValues = new Int32[] { 0, 0, 0, 0, 0, 0, 0 }; for (Int32 i = 1; i < 8; i++) Int32.TryParse(values[i], out parsedValues[i - 1]); FoodEffect effect = new FoodEffect(parsedValues[0], parsedValues[1], parsedValues[2], parsedValues[3], parsedValues[4], parsedValues[5], parsedValues[6]); Type type = ScriptCompiler.FindTypeByName(values[0]); if (_EffectIndex < _FoodTypes.Count) { _FoodTypes[_EffectIndex] = type; _FoodEffects[_EffectIndex] = effect; } else { _FoodTypes.Add(type); _FoodEffects.Add(effect); } if (Address != null) Address.SendGump(new FoodEffectsSetupGump(_CoreEnabled, _FoodTypes, _FoodEffects, (_EffectIndex / 10) * 10)); } else if (Address != null) Address.SendGump(new FoodEffectGump(_CoreEnabled, _FoodTypes, _FoodEffects, _EffectIndex, values, true)); }
public override void Deserialize(GenericReader reader) { base.Deserialize(reader); Int32 version = reader.ReadInt(); switch (version) { case 0: // Version 0 if (reader.ReadBool()) m_FoodEffect = new FoodEffect(reader.ReadInt(), reader.ReadInt(), reader.ReadInt(), reader.ReadInt(), reader.ReadInt(), reader.ReadInt(), (reader.ReadInt() / 60) + 1); if (m_FoodEffect != null) ApplyEffect(m_FoodEffect, true); break; } }
public void EffectExpired(Boolean silent) { if (m_Timer != null) { m_Timer.Stop(); m_Timer = null; } if (m_FoodEffect != null) { if (LinkedMobile != null) { LinkedMobile.RemoveStatMod("Food-StrBonus"); LinkedMobile.RemoveStatMod("Food-DexBonus"); LinkedMobile.RemoveStatMod("Food-IntBonus"); if (m_BuffInfo != null) BuffInfo.RemoveBuff(LinkedMobile, m_BuffInfo); if (!silent) { LinkedMobile.PlaySound(0x1E6); LinkedMobile.SendMessage(12, "Your food effect has worn off"); } if (m_FoodEffect != null) FoodEffectsCore.InvokeOnEffectExpired(LinkedMobile, m_FoodEffect); } m_FoodEffect = null; } }
public static void InvokeOnEffectExpired(Mobile from, FoodEffect effect) { if (OnEffectExpired != null) OnEffectExpired(from, effect); }