public override string OnIdentify(Mobile from) { if (from == null) { if (Expiration > TimeSpan.Zero) { return(String.Format("Faction Mastery : increased damage vs {0}, {1}% hitchance, expires in {2} mins", m_Enemy, Chance, Expiration.TotalMinutes)); } else { return(String.Format("Faction Mastery : increased damage vs {0}, {1}% hitchance", m_Enemy, Chance)); } } string msg = null; string raisestr = "improve "; int percentincrease = 0; // compute the damage increase based upon the owner's faction level for the specified enemy type ArrayList list = XmlAttach.FindAttachments(XmlAttach.MobileAttachments, from, typeof(XmlMobFactions), "Standard"); if (list != null && list.Count > 0) { XmlMobFactions x = list[0] as XmlMobFactions; // get the percent damage increase based upon total faction level of opponent groups int totalfac = 0; // get the target enemy group XmlMobFactions.Group g = XmlMobFactions.FindGroup(m_EnemyType); if (g != null && g.Opponents != null) { // go through all of the opponents for (int i = 0; i < g.Opponents.Length; i++) { try{ totalfac += (int)(x.GetFactionLevel(g.Opponents[i].GroupType) * g.OpponentGain[i]); raisestr = String.Format("{0}{1}, ", raisestr, g.Opponents[i].GroupType); } catch {} } } percentincrease = ComputeIncrease(totalfac); } if (Expiration > TimeSpan.Zero) { msg = String.Format("Faction Mastery : +{3}% damage vs {0} ({4}% max), {1}% hitchance, expires in {2} mins", m_Enemy, Chance, Expiration.TotalMinutes, percentincrease, PercentCap); } else { msg = String.Format("Faction Mastery : +{2}% damage vs {0} ({3}% max), {1}% hitchance", m_Enemy, Chance, percentincrease, PercentCap); } msg = String.Format("{0} : {1}faction to enhance damage.", msg, raisestr); return(msg); }
// note that this method will be called when attached to either a mobile or a weapon // when attached to a weapon, only that weapon will do additional damage // when attached to a mobile, any weapon the mobile wields will do additional damage public override void OnWeaponHit(Mobile attacker, Mobile defender, BaseWeapon weapon, int damageGiven) { if (m_Chance <= 0 || Utility.Random(100) > m_Chance) { return; } if (defender != null && attacker != null && m_EnemyType != XmlMobFactions.GroupTypes.End_Unused) { // check to the owner's faction levels ArrayList list = XmlAttach.FindAttachments(XmlAttach.MobileAttachments, attacker, typeof(XmlMobFactions), "Standard"); if (list != null && list.Count > 0) { XmlMobFactions x = list[0] as XmlMobFactions; double increase = 0; // go through all of the factions the defender might belong to ArrayList glist = XmlMobFactions.FindGroups(defender); if (glist != null && glist.Count > 0) { foreach (XmlMobFactions.GroupTypes targetgroup in glist) { // found the group that matches the enemy type for this attachment if (targetgroup == m_EnemyType) { // get the percent damage increase based upon total faction level of opponent groups int totalfac = 0; // get the target enemy group XmlMobFactions.Group g = XmlMobFactions.FindGroup(m_EnemyType); if (g.Opponents != null) { // go through all of the opponents of this group for (int i = 0; i < g.Opponents.Length; i++) { // and sum the faction levels try{ totalfac += (int)(x.GetFactionLevel(g.Opponents[i].GroupType) * g.OpponentGain[i]); } catch {} } } // what is the damage increase based upon the total opponent faction level increase = (double)ComputeIncrease(totalfac) / 100.0; break; } } } if (increase > 0) { // apply the additional damage if any defender.Damage((int)(damageGiven * increase), attacker); } } } }