public Party(string name, MobileAvatar leader) { Contract.Requires<ArgumentNullException>(leader != null); Contract.Requires<ArgumentNullException>(!string.IsNullOrEmpty(name)); Name = name; Leader = leader; }
public static void UseSkillNow(MobileAvatar caster, UseSkill message) { Schema.EnumSkillRow esr = Global.ModelSchema.EnumSkill.FindByEnumSkillID(message.SkillId); if (esr == null) { caster.SendLog("Requested an invalid skill " + message.SkillId); return; } if (esr.EnergyCost > caster.Energy) { caster.SendLog("Not enough energy to use " + esr.EnumSkillName + ", require " + esr.EnergyCost + "."); return; } // TODO: make this work /* if ( esr.EnumMobileState > caster.MobileState ) { caster.SendLog( "Not while " + caster.MobileState.Name ); } */ MobileAvatar target; switch ((EnumTargetType)esr.EnumTargetTypeID) { case EnumTargetType.TargetSelf: target = caster; break; case EnumTargetType.TargetMobile: if (message.TargetPhysicalObjectIDs.Length == 0) { caster.SendLog("No target specified, this skill may only be used on Mobiles."); return; } target = (MobileAvatar)Global.World.PhysicalObjects[message.TargetPhysicalObjectIDs[0]]; if (target == null) { caster.SendLog("Target " + message.TargetPhysicalObjectIDs[0] + " not found."); return; } if ((caster.Position - target.Position).Length > esr.Range) { // target is out of range caster.SendLog(target.TemplateObjectName + " is out of range"); return; } break; default: caster.SendLog("That skill does not work yet, contact admin."); Log.Error("Unhandled target type " + esr.EnumTargetTypeID + " for skill " + esr.EnumSkillID); return; } if (TargetSkill(caster, target, esr)) { // successful casting affects affinity with the elements caster.AffinityAir += esr.AirAffinity / 1000f; caster.AffinityEarth += esr.EarthAffinity / 1000f; caster.AffinityFire += esr.FireAffinity / 1000f; caster.AffinityLife += esr.LifeAffinity / 1000f; caster.AffinityWater += esr.WaterAffinity / 1000f; } // deduct energy regardless caster.Energy -= esr.EnergyCost; }
public static void DoKick(MobileAvatar caster, PhysicalObject target) { caster.Kick(target); }
/// <summary> /// returns true on success, false on failure /// </summary> /// <param name="caster"></param> /// <param name="target"></param> /// <param name="esr"></param> /// <returns></returns> public static bool TargetSkill(MobileAvatar caster, MobileAvatar target, Schema.EnumSkillRow esr) { // test adeptness float competancy = caster.GetCompetancy((EnumSkill)esr.EnumSkillID); double roll = Global.Rand.NextDouble(); if (competancy < roll * 100) { // failed caster.SendLog("You failed " + esr.EnumSkillName + "."); return false; } switch ((EnumActivationType)esr.EnumActivationTypeID) { case EnumActivationType.AttackSpell: float damage = esr.EnergyCost; damage += esr.AirAffinity * caster.AffinityAir / target.AffinityAir; damage += esr.EarthAffinity * caster.AffinityEarth / target.AffinityEarth; damage += esr.FireAffinity * caster.AffinityFire / target.AffinityFire; damage += esr.LifeAffinity * caster.AffinityLife / target.AffinityLife; damage += esr.WaterAffinity * caster.AffinityWater / target.AffinityWater; caster.MagicalAttack(target, damage); Log.Info("Attack spell cast!"); break; case EnumActivationType.Enchantment: break; case EnumActivationType.Glamour: break; case EnumActivationType.HealingSpell: break; case EnumActivationType.Skill: if (esr.EnumSkillID == (int)EnumSkill.Kill) DoKill(caster, target); else if (esr.EnumSkillID == (int)EnumSkill.Kick) DoKick(caster, target); else Log.Warn("Unhandled SkillID " + esr.EnumSkillID); break; case EnumActivationType.Sorcery: break; default: caster.SendLog("That skill does not work yet, contact admin."); Log.Error("Unhandled activation type " + esr.EnumActivationTypeID + " for skill " + esr.EnumSkillID); return false; } // if we made it this far, the skill was successful :) return true; }
public void Add(MobileAvatar m) { _members.Add(m.ObjectInstanceId, m); }