private void AddSpecial(SpecialDefenses id) { SpecialDefense s = GetSpecialDefense(id); if (s != null) { Specials.Add(s); } }
private void FillSpecialsList() { Specials = new ArrayList(); foreach (SpecialDefenses sid in tmpSpecialsList) { SpecialDefense s = GetSpecialDefense(sid); if (s != null) { Specials.Add(s); } } }
public override void OnResponse(NetState state, RelayInfo info) { if (m_attachment == null || state == null || state.Mobile == null || info == null) { return; } // go through all of the possible specials and find the matching button for (int i = 0; i < m_attachment.Specials.Count; i++) { SpecialDefense s = (SpecialDefense)m_attachment.Specials[i]; if (s != null && info.ButtonID == (int)s.DefenseID + 1000) { // if clicked again, then deselect if (s == m_attachment.m_SelectedDefense) { m_attachment.m_SelectedDefense = null; } else { // see whether they have the required resources for this defense if (CheckRequirements(state.Mobile, s)) { // if so, then let them select it m_attachment.m_SelectedDefense = s; } else { // otherwise clear it m_attachment.m_SelectedDefense = null; } } state.Mobile.SendGump(new CustomDefenseGump(state.Mobile, m_attachment)); break; } else if (s != null && info.ButtonID == (int)s.DefenseID + 2000) { state.Mobile.CloseGump(typeof(CustomDefenseInfoGump)); state.Mobile.SendGump(new CustomDefenseGump(state.Mobile, m_attachment)); state.Mobile.SendGump(new CustomDefenseInfoGump(state.Mobile, m_attachment, s)); break; } } }
public override int OnArmorHit(Mobile attacker, Mobile defender, Item armor, BaseWeapon weapon, int damageGiven) { if (attacker == null || defender == null || weapon == null || armor == null || m_SelectedDefense == null) { return(0); } if (!CheckRequirements(defender, m_SelectedDefense)) { return(0); } // take the requirements if (defender.Backpack != null && m_SelectedDefense.Reagents != null && m_SelectedDefense.Quantity != null) { defender.Backpack.ConsumeTotal(m_SelectedDefense.Reagents, m_SelectedDefense.Quantity, true); } defender.Mana -= m_SelectedDefense.ManaReq; defender.Stam -= m_SelectedDefense.StamReq; defender.Hits -= m_SelectedDefense.HitsReq; defender.Karma -= m_SelectedDefense.KarmaReq; // apply the attack int damage = DoSpecialDefense(attacker, defender, weapon, damageGiven, m_SelectedDefense); if (m_SelectedDefense.KarmaReq > 0) { defender.SendMessage("and lose a little karma."); } // after applying a special defense activate the specials timer for combo chaining DoComboTimer(defender, m_SelectedDefense.ChainTime); // check all combos to see which have this defense as the next in sequence, and which might be complete CheckCombos(attacker, defender, weapon, damageGiven, m_SelectedDefense); // clear the selected defense m_SelectedDefense = null; // redisplay the gump defender.SendGump(new CustomDefenseGump(defender, this)); return(damage); }
private void SetRandomSpecials(int count) { int nspecials = AllSpecials.Count; if (nspecials > 0) { int ntries = 0; int total = 0; ArrayList tmplist = new ArrayList(); while (total < count) { int rand = Utility.Random(nspecials); int nrtries = 0; while (tmplist.Contains(rand)) { rand = Utility.Random(nspecials); // add some sanity checking if (nrtries++ > 100) { break; } } tmplist.Add(rand); SpecialDefense s = GetSpecialDefense((SpecialDefenses)rand); if (s != null) { Specials.Add(s); total++; } // add some sanity checking if (tmplist.Count >= nspecials) { break; } if (ntries++ > 100) { break; } } } }
public CustomDefenseGump(Mobile from, XmlCustomDefenses a) : base(0, 0) { if (a == null) { return; } if (from != null) { from.CloseGump(typeof(CustomDefenseGump)); } m_attachment = a; int specialcount = a.Specials.Count; // prepare the page AddPage(0); AddBackground(0, 0, 70, 75 + specialcount * vertspacing, 5054); AddLabel(13, 2, 55, "Defense"); // if combos are still active then give it the green light if (m_attachment != null && m_attachment.HasActiveCombos) { // green button //AddImage( 20, 10, 0x2a4e ); AddImage(15, 25, 0x0a53); } else { // red button //AddImage( 20, 10, 0x2a62 ); AddImage(15, 25, 0x0a52); } // go through the list of enabled moves and add buttons for them int y = 70; for (int i = 0; i < specialcount; i++) { SpecialDefense s = (SpecialDefense)m_attachment.Specials[i]; // flag the defense as being selected // this puts a white background behind the selected defense. Doesnt look as nice, but works in both the // 2D and 3D client. I prefer to leave this commented out for best appearance in the 2D client but // feel free to uncomment it for best client compatibility. /* * if(m_attachment != null && m_attachment.m_SelectedDefense != null && m_attachment.m_SelectedDefense == s) * { * AddImageTiled( 2, y-2, 66, vertspacing+2, 0xBBC ); * } */ // add the defense button if (s.IconType == IconTypes.ItemID) { AddButton(5, y, 0x5207, 0x5207, (int)s.DefenseID + 1000, GumpButtonType.Reply, 0); AddImageTiled(5, y, 44, 44, 0x283E); AddItem(5, y, s.Icon); } else { AddButton(5, y, s.Icon, s.Icon, (int)s.DefenseID + 1000, GumpButtonType.Reply, 0); } // flag the defense as being selected // colors the defense icon red. Looks better that the white background highlighting, but only supported by the 2D client. if (m_attachment != null && m_attachment.m_SelectedDefense != null && m_attachment.m_SelectedDefense == s) { if (s.IconType == IconTypes.ItemID) { AddItem(5, y, s.Icon, 33); } else { AddImage(5, y, s.Icon, 33); } } // add the info button AddButton(52, y + 13, 0x4b9, 0x4b9, 2000 + (int)s.DefenseID, GumpButtonType.Reply, 0); y += vertspacing; } }
public CustomDefenseInfoGump(Mobile from, XmlCustomDefenses a, SpecialDefense s) : base(0, 0) { m_attachment = a; m_special = s; // prepare the page AddPage(0); AddBackground(0, 0, 400, 300, 5054); AddAlphaRegion(0, 0, 400, 300); AddLabel(20, 2, 55, String.Format("{0}", s.Name)); StringBuilder text = new StringBuilder(); text.AppendFormat("\n{0}", s.Description); text.AppendFormat("\n\nMinimum Stats/Skills:"); if (s.StrReq > 0) { text.AppendFormat("\n {0} Str", s.StrReq); } if (s.DexReq > 0) { text.AppendFormat("\n {0} Dex", s.DexReq); } if (s.IntReq > 0) { text.AppendFormat("\n {0} Int", s.IntReq); } if (s.Skills != null) { for (int i = 0; i < s.Skills.Length; i++) { if (i < s.MinSkillLevel.Length) { text.AppendFormat("\n {1} {0}", s.Skills[i].ToString(), s.MinSkillLevel[i]); } else { text.AppendFormat("\n {1} {0}", s.Skills[i].ToString(), "???"); } } } text.AppendFormat("\n\nConsumes:"); // generate the text requirements if (s.ManaReq > 0) { text.AppendFormat("\n {0} Mana", s.ManaReq); } if (s.StamReq > 0) { text.AppendFormat("\n {0} Stamina", s.StamReq); } if (s.HitsReq > 0) { text.AppendFormat("\n {0} Hits", s.HitsReq); } if (s.KarmaReq > 0) { text.AppendFormat("\n {0} Karma", s.KarmaReq); } if (s.Reagents != null) { for (int i = 0; i < s.Reagents.Length; i++) { if (i < s.Quantity.Length) { text.AppendFormat("\n {1} {0}", s.Reagents[i].Name, s.Quantity[i]); } else { text.AppendFormat("\n {1} {0}", s.Reagents[i].Name, "???"); } } } AddHtml(20, 20, 360, 260, text.ToString(), true, true); }
public static bool CheckRequirements(Mobile from, SpecialDefense s) { if (from == null || s == null) { return(false); } // test for str, dex, int requirements if (from.Str < s.StrReq) { from.SendMessage("Need {0} Str to perform {1}", s.StrReq, s.Name); return(false); } if (from.Dex < s.DexReq) { from.SendMessage("Need {0} Dex to perform {1}", s.DexReq, s.Name); return(false); } if (from.Int < s.IntReq) { from.SendMessage("Need {0} Int to perform {1}", s.IntReq, s.Name); return(false); } // test for skill requirements if (s.Skills != null && s.MinSkillLevel != null) { if (from.Skills == null) { return(false); } for (int i = 0; i < s.Skills.Length; i++) { // and check level if (i < s.MinSkillLevel.Length) { Skill skill = from.Skills[s.Skills[i]]; if (skill != null && s.MinSkillLevel[i] > skill.Base) { from.SendMessage("Need {0} {1} to perform {2}", s.MinSkillLevel[i], s.Skills[i].ToString(), s.Name); return(false); } } else { from.SendMessage(33, "Error in skill level specification for {0}", s.Name); return(false); } } } // test for mana, stam, and hits requirements if (from.Mana < s.ManaReq) { from.SendMessage("Need {0} Mana to perform {1}", s.ManaReq, s.Name); return(false); } if (from.Stam < s.StamReq) { from.SendMessage("Need {0} Stamina to perform {1}", s.StamReq, s.Name); return(false); } if (from.Hits < s.HitsReq) { // clear the selected defense from.SendMessage("Need {0} Hits to perform {1}", s.HitsReq, s.Name); return(false); } // check for any reagents that are specified if (s.Reagents != null && s.Quantity != null) { if (from.Backpack == null) { return(false); } for (int i = 0; i < s.Reagents.Length; i++) { // go through each reagent Item ret = from.Backpack.FindItemByType(s.Reagents[i], true); // and check quantity if (i < s.Quantity.Length) { if (ret == null || s.Quantity[i] > ret.Amount) { from.SendMessage("Need {1} {0} to perform {2}", s.Reagents[i].Name, s.Quantity[i], s.Name); return(false); } } else { from.SendMessage(33, "Error in quantity specification for {0}", s.Name); return(false); } } } return(true); }
private void CheckCombos(Mobile attacker, Mobile defender, BaseWeapon weapon, int damageGiven, SpecialDefense s) { if (s == null) { return; } foreach (ActiveCombo c in Combos) { if (c != null && c.Combo != null && c.Combo.DefenseSequence != null && c.PositionInSequence < c.Combo.DefenseSequence.Length) { if (c.Combo.DefenseSequence[c.PositionInSequence] == s.DefenseID) { if (++c.PositionInSequence >= c.Combo.DefenseSequence.Length) { // combo is complete so execute it DoComboDefense(attacker, defender, weapon, damageGiven, c.Combo); // and reset it c.PositionInSequence = 0; } } else { // out of sequence so reset the combo c.PositionInSequence = 0; } } } }
// // carry out the special defenses // // If you add a new defense, you must add the code here to define what it actually does when it hits // can optionally return a value that will be used to reduce damage // public int DoSpecialDefense(Mobile attacker, Mobile defender, BaseWeapon weapon, int damageGiven, SpecialDefense special) { if (attacker == null || defender == null || weapon == null || special == null) { return(0); } defender.SendMessage("you defend with {0}!", special.Name); // apply the special defense switch (special.DefenseID) { case SpecialDefenses.MindDrain: { attacker.Mana -= damageGiven; defender.FixedEffect(0x375A, 10, 15); // absorb all of the damage you would have taken return(damageGiven); } case SpecialDefenses.StamDrain: { attacker.Stam -= damageGiven; defender.FixedEffect(0x374A, 10, 15); // absorb all of the damage you would have taken return(damageGiven); } case SpecialDefenses.SpikeShield: { // return the damage to attacker attacker.Damage(damageGiven, defender); defender.SendMessage("{0} damage reflected!", damageGiven); // absorb all of the damage you would have taken return(damageGiven); } case SpecialDefenses.PuffOfSmoke: { defender.Hidden = true; break; } case SpecialDefenses.GiftOfHealth: { defender.FixedEffect(0x376A, 9, 32); defender.PlaySound(0x202); defender.Hits += damageGiven; defender.SendMessage("healed {0}!", damageGiven); // absorb all of the damage you would have taken return(damageGiven); } case SpecialDefenses.ParalyzingFear: { // lose target focus attacker.Combatant = null; // flee if (attacker is BaseCreature) { ((BaseCreature)attacker).BeginFlee(TimeSpan.FromSeconds(6)); } // and become paralyzed attacker.Freeze(TimeSpan.FromSeconds(damageGiven / 10)); attacker.FixedEffect(0x376A, 9, 32); attacker.PlaySound(0x204); break; } default: defender.SendMessage("no effect"); break; } return(0); }
public CustomDefenseInfoGump( Mobile from, XmlCustomDefenses a, SpecialDefense s) : base( 0,0) { m_attachment = a; m_special = s; // prepare the page AddPage( 0 ); AddBackground( 0, 0, 400, 300, 5054 ); AddAlphaRegion( 0, 0, 400, 300 ); AddLabel( 20, 2, 55, String.Format("{0}",s.Name) ); StringBuilder text = new StringBuilder(); text.AppendFormat("\n{0}", s.Description ); text.AppendFormat("\n\nMinimum Stats/Skills:" ); if(s.StrReq > 0) { text.AppendFormat("\n {0} Str", s.StrReq ); } if(s.DexReq > 0) { text.AppendFormat("\n {0} Dex", s.DexReq ); } if(s.IntReq > 0) { text.AppendFormat("\n {0} Int", s.IntReq ); } if(s.Skills != null) for(int i = 0;i < s.Skills.Length;i++) { if(i < s.MinSkillLevel.Length) { text.AppendFormat("\n {1} {0}", s.Skills[i].ToString(), s.MinSkillLevel[i] ); } else { text.AppendFormat("\n {1} {0}", s.Skills[i].ToString(), "???" ); } } text.AppendFormat("\n\nConsumes:" ); // generate the text requirements if(s.ManaReq > 0) { text.AppendFormat("\n {0} Mana", s.ManaReq ); } if(s.StamReq > 0) { text.AppendFormat("\n {0} Stamina", s.StamReq ); } if(s.HitsReq > 0) { text.AppendFormat("\n {0} Hits", s.HitsReq ); } if(s.KarmaReq > 0) { text.AppendFormat("\n {0} Karma", s.KarmaReq ); } if(s.Reagents != null) for(int i = 0;i < s.Reagents.Length;i++) { if(i < s.Quantity.Length) { text.AppendFormat("\n {1} {0}", s.Reagents[i].Name, s.Quantity[i] ); } else { text.AppendFormat("\n {1} {0}", s.Reagents[i].Name, "???" ); } } AddHtml( 20,20, 360, 260, text.ToString(), true , true ); }
public override int OnArmorHit(Mobile attacker, Mobile defender, Item armor, BaseWeapon weapon, int damageGiven) { if(attacker == null || defender == null || weapon == null || armor == null || m_SelectedDefense == null) return 0; if(!CheckRequirements(defender, m_SelectedDefense)) return 0; // take the requirements if(defender.Backpack != null && m_SelectedDefense.Reagents != null && m_SelectedDefense.Quantity != null) { defender.Backpack.ConsumeTotal( m_SelectedDefense.Reagents, m_SelectedDefense.Quantity, true); } defender.Mana -= m_SelectedDefense.ManaReq; defender.Stam -= m_SelectedDefense.StamReq; defender.Hits -= m_SelectedDefense.HitsReq; defender.Karma -= m_SelectedDefense.KarmaReq; // apply the attack int damage = DoSpecialDefense( attacker, defender, weapon, damageGiven, m_SelectedDefense); if(m_SelectedDefense.KarmaReq > 0) { defender.SendMessage("and lose a little karma."); } // after applying a special defense activate the specials timer for combo chaining DoComboTimer(defender, m_SelectedDefense.ChainTime); // check all combos to see which have this defense as the next in sequence, and which might be complete CheckCombos( attacker, defender, weapon, damageGiven, m_SelectedDefense); // clear the selected defense m_SelectedDefense = null; // redisplay the gump defender.SendGump(new CustomDefenseGump(defender, this)); return damage; }
public static bool CheckRequirements(Mobile from, SpecialDefense s) { if(from == null || s == null) return false; // test for str, dex, int requirements if(from.Str < s.StrReq) { from.SendMessage("Need {0} Str to perform {1}", s.StrReq, s.Name); return false; } if(from.Dex < s.DexReq) { from.SendMessage("Need {0} Dex to perform {1}", s.DexReq, s.Name); return false; } if(from.Int < s.IntReq) { from.SendMessage("Need {0} Int to perform {1}", s.IntReq, s.Name); return false; } // test for skill requirements if(s.Skills != null && s.MinSkillLevel != null) { if(from.Skills == null) return false; for(int i = 0; i < s.Skills.Length; i++) { // and check level if(i < s.MinSkillLevel.Length) { Skill skill = from.Skills[s.Skills[i]]; if(skill != null && s.MinSkillLevel[i] > skill.Base) { from.SendMessage("Need {0} {1} to perform {2}", s.MinSkillLevel[i], s.Skills[i].ToString(), s.Name); return false; } } else { from.SendMessage(33,"Error in skill level specification for {0}", s.Name); return false; } } } // test for mana, stam, and hits requirements if(from.Mana < s.ManaReq) { from.SendMessage("Need {0} Mana to perform {1}", s.ManaReq, s.Name); return false; } if(from.Stam < s.StamReq) { from.SendMessage("Need {0} Stamina to perform {1}", s.StamReq, s.Name); return false; } if(from.Hits < s.HitsReq) { // clear the selected defense from.SendMessage("Need {0} Hits to perform {1}", s.HitsReq, s.Name); return false; } // check for any reagents that are specified if(s.Reagents != null && s.Quantity != null) { if(from.Backpack == null) return false; for(int i = 0; i < s.Reagents.Length; i++) { // go through each reagent Item ret = from.Backpack.FindItemByType(s.Reagents[i], true); // and check quantity if(i < s.Quantity.Length) { if(ret == null || s.Quantity[i] > ret.Amount) { from.SendMessage("Need {1} {0} to perform {2}", s.Reagents[i].Name, s.Quantity[i], s.Name); return false; } } else { from.SendMessage(33,"Error in quantity specification for {0}", s.Name); return false; } } } return true; }
private void CheckCombos(Mobile attacker, Mobile defender, BaseWeapon weapon, int damageGiven, SpecialDefense s) { if(s == null) return; foreach(ActiveCombo c in Combos) { if(c != null && c.Combo != null && c.Combo.DefenseSequence != null && c.PositionInSequence < c.Combo.DefenseSequence.Length) { if(c.Combo.DefenseSequence[c.PositionInSequence] == s.DefenseID) { if(++c.PositionInSequence >= c.Combo.DefenseSequence.Length) { // combo is complete so execute it DoComboDefense(attacker, defender, weapon, damageGiven, c.Combo); // and reset it c.PositionInSequence = 0; } } else { // out of sequence so reset the combo c.PositionInSequence = 0; } } } }
// // carry out the special defenses // // If you add a new defense, you must add the code here to define what it actually does when it hits // can optionally return a value that will be used to reduce damage // public int DoSpecialDefense(Mobile attacker, Mobile defender, BaseWeapon weapon, int damageGiven, SpecialDefense special) { if(attacker == null || defender == null || weapon == null || special == null) return 0; defender.SendMessage("you defend with {0}!", special.Name); // apply the special defense switch(special.DefenseID) { case SpecialDefenses.MindDrain: { attacker.Mana -= damageGiven; defender.FixedEffect( 0x375A, 10, 15 ); // absorb all of the damage you would have taken return damageGiven; } case SpecialDefenses.StamDrain: { attacker.Stam -= damageGiven; defender.FixedEffect( 0x374A, 10, 15 ); // absorb all of the damage you would have taken return damageGiven; } case SpecialDefenses.SpikeShield: { // return the damage to attacker attacker.Damage( damageGiven, defender ); defender.SendMessage("{0} damage reflected!", damageGiven); // absorb all of the damage you would have taken return damageGiven; } case SpecialDefenses.PuffOfSmoke: { defender.Hidden = true; break; } case SpecialDefenses.GiftOfHealth: { defender.FixedEffect( 0x376A, 9, 32 ); defender.PlaySound( 0x202 ); defender.Hits += damageGiven; defender.SendMessage("healed {0}!", damageGiven); // absorb all of the damage you would have taken return damageGiven; } case SpecialDefenses.ParalyzingFear: { // lose target focus attacker.Combatant = null; // flee if(attacker is BaseCreature) { ((BaseCreature)attacker).BeginFlee(TimeSpan.FromSeconds(6)); } // and become paralyzed attacker.Freeze( TimeSpan.FromSeconds(damageGiven/10) ); attacker.FixedEffect( 0x376A, 9, 32 ); attacker.PlaySound( 0x204 ); break; } default: defender.SendMessage("no effect"); break; } return 0; }
public PlayerCharacter(SpecialDefense specialDefense) { _specialDefense = specialDefense; }