/// <summary> /// Method to launch a spell /// </summary> /// <param name="spellLevel">The spell level</param> /// <param name="spellLineName">The spell line</param> /// <param name="guard">The guard caster</param> public static void LaunchSpell(int spellLevel, string spellLineName, GameNPC guard) { if (guard.TargetObject == null) { return; } Spell castSpell = null; SpellLine castLine = null; castLine = SkillBase.GetSpellLine(spellLineName); List <Spell> spells = SkillBase.GetSpellList(castLine.KeyName); foreach (Spell spell in spells) { if (spell.Level == spellLevel) { castSpell = spell; break; } } if (guard.AttackState) { guard.StopAttack(); } if (guard.IsMoving) { guard.StopFollowing(); } guard.TurnTo(guard.TargetObject); guard.CastSpell(castSpell, castLine); }
/// <summary> /// Cast a spell on player and its pets/subpets if available. /// </summary> /// <param name="sourceNPC">NPC that is casting the spell</param> /// <param name="player">Player is the owner and first target of the spell</param> /// <param name="spell">Casted spell</param> /// <param name="line">SpellLine the casted spell is derived from</param> /// <param name="checkLOS">Determines if line of sight is checked</param> public static void CastSpellOnOwnerAndPets(this GameNPC sourceNPC, GamePlayer player, Spell spell, SpellLine line, bool checkLOS) { sourceNPC.TargetObject = player; sourceNPC.CastSpell(spell, line, checkLOS); if (player.ControlledBrain != null) { sourceNPC.TargetObject = player.ControlledBrain.Body; sourceNPC.CastSpell(spell, line, checkLOS); if (player.ControlledBrain.Body.ControlledNpcList != null) { foreach (AI.Brain.IControlledBrain subpet in player.ControlledBrain.Body.ControlledNpcList) { if (subpet != null) { sourceNPC.TargetObject = subpet.Body; sourceNPC.CastSpell(spell, line, checkLOS); } } } } }
/// <summary> /// Method to cast a heal spell /// </summary> /// <param name="guard">The guard object</param> /// <param name="target">The spell target</param> public static void CastHealSpell(GameNPC guard, GameLiving target) { //decide which healing spell Spell spell = GetGuardHealSmallSpell((eRealm)guard.Realm); //cast the healing spell if (spell != null && !guard.IsStunned && !guard.IsMezzed) { guard.StopAttack(); guard.TargetObject = target; guard.CastSpell(spell, SpellMgr.GuardSpellLine); } }
public void OnCommand(GameClient client, string[] args) { if (args.Length == 1) { DisplaySyntax(client); return; } if (!(client.Player.TargetObject is GameNPC)) { client.Out.SendMessage("You must target an NPC.", eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } GameNPC npc = client.Player.TargetObject as GameNPC; switch (args[1].ToLower()) { case "say": { if (args.Length < 3) { client.Player.Out.SendMessage("Usage: /npc say <message>", eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } string message = string.Join(" ", args, 2, args.Length - 2); npc.Say(message); break; } case "yell": { if (args.Length < 3) { client.Player.Out.SendMessage("Usage: /npc yell <message>", eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } string message = string.Join(" ", args, 2, args.Length - 2); npc.Yell(message); break; } case "action": { if (args.Length < 3) { client.Player.Out.SendMessage("Usage: /npc action <action message>", eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } string action = string.Join(" ", args, 2, args.Length - 2); action = "<" + npc.Name + " " + action + " >"; foreach (GamePlayer player in npc.GetPlayersInRadius(WorldMgr.SAY_DISTANCE)) { player.Out.SendMessage(action, eChatType.CT_Emote, eChatLoc.CL_ChatWindow); } break; } case "emote": { if (args.Length != 3) { client.Player.Out.SendMessage("Usage: /npc emote <emote>", eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } eEmote emoteID; switch (args[2].ToLower()) { case "angry": emoteID = eEmote.Angry; break; case "bang": emoteID = eEmote.BangOnShield; break; case "beckon": emoteID = eEmote.Beckon; break; case "beg": emoteID = eEmote.Beg; break; case "bindalb": emoteID = eEmote.BindAlb; break; case "bindhib": emoteID = eEmote.BindHib; break; case "bindmid": emoteID = eEmote.BindMid; break; case "blush": emoteID = eEmote.Blush; break; case "bow": emoteID = eEmote.Bow; break; case "charge": emoteID = eEmote.LetsGo; break; case "cheer": emoteID = eEmote.Cheer; break; case "clap": emoteID = eEmote.Clap; break; case "confuse": emoteID = eEmote.Confused; break; case "cry": emoteID = eEmote.Cry; break; case "curtsey": emoteID = eEmote.Curtsey; break; case "dance": emoteID = eEmote.Dance; break; case "dismiss": emoteID = eEmote.Dismiss; break; case "distract": emoteID = eEmote.Distract; break; case "drink": emoteID = eEmote.Drink; break; case "flex": emoteID = eEmote.Flex; break; case "horsecourbette": emoteID = eEmote.Horse_Courbette; break; case "horsegraze": emoteID = eEmote.Horse_Graze; break; case "horsenod": emoteID = eEmote.Horse_Nod; break; case "horserear": emoteID = eEmote.Horse_rear; break; case "horsestartle": emoteID = eEmote.Horse_Startle; break; case "horsewhistle": emoteID = eEmote.Horse_whistle; break; case "hug": emoteID = eEmote.Hug; break; case "induct": emoteID = eEmote.Induct; break; case "knock": emoteID = eEmote.Knock; break; case "kiss": emoteID = eEmote.BlowKiss; break; case "laugh": emoteID = eEmote.Laugh; break; case "levelup": emoteID = eEmote.LvlUp; break; case "meditate": emoteID = eEmote.Meditate; break; case "mememe": emoteID = eEmote.Mememe; break; case "berzerkerfrenzy": emoteID = eEmote.MidgardFrenzy; break; case "military": emoteID = eEmote.Military; break; case "no": emoteID = eEmote.No; break; case "listen": emoteID = eEmote.PlayerListen; break; case "pickup": emoteID = eEmote.PlayerPickup; break; case "prepare": emoteID = eEmote.PlayerPrepare; break; case "point": emoteID = eEmote.Point; break; case "ponder": emoteID = eEmote.Ponder; break; case "pray": emoteID = eEmote.Pray; break; case "present": emoteID = eEmote.Present; break; case "raise": emoteID = eEmote.Raise; break; case "riderhalt": emoteID = eEmote.Rider_Halt; break; case "riderlook": emoteID = eEmote.Rider_LookFar; break; case "riderstench": emoteID = eEmote.Rider_Stench; break; case "riderpet": emoteID = eEmote.Rider_pet; break; case "ridertrick": emoteID = eEmote.Rider_Trick; break; case "roar": emoteID = eEmote.Roar; break; case "rofl": emoteID = eEmote.Rofl; break; case "rude": emoteID = eEmote.Rude; break; case "salute": emoteID = eEmote.Salute; break; case "shrug": emoteID = eEmote.Shrug; break; case "slap": emoteID = eEmote.Slap; break; case "slit": emoteID = eEmote.Slit; break; case "smile": emoteID = eEmote.Smile; break; case "boom": emoteID = eEmote.SpellGoBoom; break; case "herofrenzy": emoteID = eEmote.StagFrenzy; break; case "stagger": emoteID = eEmote.Stagger; break; case "surrender": emoteID = eEmote.Surrender; break; case "taunt": emoteID = eEmote.Taunt; break; case "throwdirt": emoteID = eEmote.ThrowDirt; break; case "victory": emoteID = eEmote.Victory; break; case "wave": emoteID = eEmote.Wave; break; case "worship": emoteID = eEmote.Worship; break; case "yawn": emoteID = eEmote.Yawn; break; case "yes": emoteID = eEmote.Yes; break; default: return; } npc.Emote(emoteID); break; } case "walkto": { if (args.Length < 3 || args.Length > 4) { client.Out.SendMessage("Usage: /npc walkto <targetname> [speed]", eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } short speed = 200; if (args.Length == 4) { speed = Convert.ToInt16(args[3]); } var pos = Vector3.Zero; switch (args[2].ToLower()) { case "me": { pos = client.Player.Position; break; } default: { //Check for players by name in visibility distance foreach (GamePlayer targetplayer in npc.GetPlayersInRadius(WorldMgr.VISIBILITY_DISTANCE)) { if (targetplayer.Name.ToLower() == args[2].ToLower()) { pos = targetplayer.Position; break; } } //Check for NPCs by name in visibility distance foreach (GameNPC target in npc.GetNPCsInRadius(WorldMgr.VISIBILITY_DISTANCE)) { if (target.Name.ToLower() == args[2].ToLower()) { pos = target.Position; break; } } break; } } if (pos == Vector3.Zero) { client.Out.SendMessage("Can't find name " + args[2].ToLower() + " near your target.", eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } npc.PathTo(pos, speed); client.Out.SendMessage("Your target is walking to your location!", eChatType.CT_System, eChatLoc.CL_SystemWindow); break; } case "face": { if (args.Length != 3) { client.Player.Out.SendMessage("Usage: /npc face <targetname>", eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } GameLiving target = null; switch (args[2].ToLower()) { case "me": { target = client.Player; break; } default: { //Check for players by name in visibility distance foreach (GamePlayer targetplayer in npc.GetPlayersInRadius(WorldMgr.VISIBILITY_DISTANCE)) { if (targetplayer.Name.ToLower() == args[2].ToLower()) { target = targetplayer; break; } } //Check for NPCs by name in visibility distance foreach (GameNPC targetNpc in npc.GetNPCsInRadius(WorldMgr.VISIBILITY_DISTANCE)) { if (targetNpc.Name.ToLower() == args[2].ToLower()) { target = targetNpc; break; } } break; } } if (target == null) { client.Out.SendMessage("Can't find name " + args[2].ToLower() + " near your target.", eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } npc.TurnTo(target); break; } case "follow": { if (args.Length != 3) { client.Player.Out.SendMessage("Usage: /npc follow <targetname>", eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } GameLiving target = null; switch (args[2].ToLower()) { case "me": { target = client.Player; break; } default: { //Check for players by name in visibility distance foreach (GamePlayer targetplayer in npc.GetPlayersInRadius(WorldMgr.VISIBILITY_DISTANCE)) { if (targetplayer.Name.ToLower() == args[2].ToLower()) { target = targetplayer; break; } } //Check for NPCs by name in visibility distance foreach (GameNPC targetNpc in npc.GetNPCsInRadius(WorldMgr.VISIBILITY_DISTANCE)) { if (targetNpc.Name.ToLower() == args[2].ToLower()) { target = targetNpc; break; } } break; } } if (target == null) { client.Out.SendMessage("Can't find name " + args[2].ToLower() + " near your target.", eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } npc.Follow(target, 128, short.MaxValue); break; } case "stopfollow": { if (args.Length != 2) { client.Player.Out.SendMessage("Usage: /npc stopfollow", eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } npc.StopFollowing(); break; } case "target": { if (args.Length != 3) { client.Player.Out.SendMessage("Usage: /npc target <targetName>", eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } GameLiving target = null; switch (args[2].ToLower()) { case "self": { target = npc; } break; case "me": { target = client.Player; } break; default: { //Check for players by name in visibility distance foreach (GamePlayer targetplayer in npc.GetPlayersInRadius(WorldMgr.VISIBILITY_DISTANCE)) { if (targetplayer.Name.ToLower() == args[2].ToLower()) { target = targetplayer; break; } } //Check for NPCs by name in visibility distance foreach (GameNPC targetNpc in npc.GetNPCsInRadius(WorldMgr.VISIBILITY_DISTANCE)) { if (targetNpc.Name.ToLower() == args[2].ToLower()) { target = targetNpc; break; } } break; } } if (target == null) { client.Out.SendMessage("Can't find name " + args[2].ToLower() + " near your target.", eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } npc.TargetObject = target; client.Out.SendMessage(npc.Name + " now target " + target.Name + ".", eChatType.CT_System, eChatLoc.CL_SystemWindow); break; } case "cast": { if (args.Length != 4) { client.Player.Out.SendMessage("Usage: /npc cast <spellLine> <spellID>", eChatType.CT_System, eChatLoc.CL_SystemWindow); client.Player.Out.SendMessage("(Be sure the npc target something to be able to cast)", eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } SpellLine line = SkillBase.GetSpellLine(args[2]); List <Spell> spells = SkillBase.GetSpellList(line.KeyName); if (spells.Count <= 0) { client.Out.SendMessage("No spells found in line " + args[2] + "!", eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } if (spells != null) { foreach (Spell spl in spells) { if (spl.ID == Convert.ToInt32(args[3])) { npc.CastSpell(spl, line); return; } } } client.Out.SendMessage("Spell with id " + Convert.ToInt16(args[3]) + " not found in db!", eChatType.CT_System, eChatLoc.CL_SystemWindow); break; } case "weapon": { if (args.Length != 3) { client.Player.Out.SendMessage("Usage: /npc weapon <activeWeaponSlot>", eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } if (Convert.ToInt16(args[2]) < 0 || Convert.ToInt16(args[2]) > 2) { client.Player.Out.SendMessage("The activeWeaponSlot must be between 0 and 2.", eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } GameLiving.eActiveWeaponSlot slot = (GameLiving.eActiveWeaponSlot)Convert.ToInt16(args[2]); npc.SwitchWeapon(slot); client.Player.Out.SendMessage(npc.Name + " will now use its " + Enum.GetName(typeof(GameLiving.eActiveWeaponSlot), slot) + " weapon to attack.", eChatType.CT_System, eChatLoc.CL_SystemWindow); break; } default: { client.Out.SendMessage("Type /npc for command overview.", eChatType.CT_System, eChatLoc.CL_SystemWindow); } break; } }