예제 #1
0
        public void OnCommand(GameClient client, string[] args)
        {
            if (IsSpammingCommand(client.Player, "where"))
            {
                return;
            }

            if (args.Length == 1)
            {
                DisplaySyntax(client);
                return;
            }

            GameNPC targetnpc = client.Player.TargetObject as GameNPC;

            if (targetnpc != null && CheckTargetIsGuard(targetnpc))
            {
                string    name = string.Join(" ", args, 1, args.Length - 1);
                GameNPC[] npcs = WorldMgr.GetObjectsByNameFromRegion <GameNPC>(name, client.Player.CurrentRegionID, client.Player.Realm);
                if (npcs == null || npcs.Length <= 0)
                {
                    targetnpc.SayTo(client.Player, "Sorry, i do not know this person.");
                    return;
                }

                GameNPC npc             = npcs[0];
                ushort  heading         = targetnpc.GetHeading(npc);
                string  directionstring = GetDirectionFromHeading(heading);
                targetnpc.SayTo(client.Player, eChatLoc.CL_SystemWindow, npc.Name + " is in the " + directionstring);
                targetnpc.TurnTo(npc, 10000);
                targetnpc.Emote(eEmote.Point);
            }
        }
예제 #2
0
        /* This is the method we declared as callback for the hooks we set to
         * NPC. It will be called whenever a player right clicks on NPC
         * or when he whispers something to him.
         */

        protected static void TalkToSquireGalune(DOLEvent e, object sender, EventArgs args)
        {
            //We get the player from the event arguments and check if he qualifies
            GamePlayer player = ((SourceEventArgs)args).Source as GamePlayer;

            if (player == null)
            {
                return;
            }

            //We also check if the player is already doing the quest
            ShakenSquire quest = player.IsDoingQuest(typeof(ShakenSquire)) as ShakenSquire;

            squireGalune.TurnTo(player);
            //Did the player rightclick on NPC?
            if (e == GameObjectEvent.Interact)
            {
                if (quest != null)
                {
                    switch (quest.Step)
                    {
                    case 2:
                        squireGalune.SayTo(player, "Oh, no, it's a spider! Please, someone get this awful thing away from me!");
                        squireGalune.Emote(eEmote.Beg);
                        break;

                    case 3:
                        squireGalune.SayTo(player, "Sir Jerem finally sent someone? Nevermind, I don't care who sent you, I'm just relieved that horrible spider is dead! I thought for sure it was going to kill me. I'll never listen to [Master Graent's] stories again.");
                        break;
                    }
                }
            }
            // The player whispered to NPC (clicked on the text inside the [])
            else if (e == GameLivingEvent.WhisperReceive)
            {
                WhisperReceiveEventArgs wArgs = (WhisperReceiveEventArgs)args;
                if (quest != null)
                {
                    switch (wArgs.Text)
                    {
                    case "Master Graent's":
                        if (quest.Step == 3)
                        {
                            squireGalune.SayTo(player, "He's full of stories about hidden treasures and deeds of valor, but he never mentioned spiders! He conveniently left that part out. When I get back to the castle, I'm going to give him a piece of my [mind].");
                        }
                        break;

                    case "mind":
                        if (quest.Step == 3)
                        {
                            squireGalune.SayTo(player, "I think I'll be able to make it back on my own now. Thank you so much for rescuing me from that spider.  Please let Sir Jerem know that I'm safe when you get back to the keep.");
                            quest.Step = 4;
                        }
                        break;
                    }
                }
            }
        }
예제 #3
0
        public int OnCloseToDeadWilburCallBack(RegionTimer timer)
        {
            GameNPC pigHerderWyatt = (GameNPC)timer.Properties.getProperty <object>(questTitle, null);

            if (pigHerderWyatt != null)
            {
                pigHerderWyatt.Yell("The King's men will hear about this!!! Oh, Wilbur...");
                pigHerderWyatt.Emote(eEmote.Cry);
                GameEventMgr.AddHandler(pigHerderWyatt, GameNPCEvent.CloseToTarget, new DOLEventHandler(OnRemovePigHerder));
                pigHerderWyatt.WalkTo(wilburSpawnLocation.Position + new Vector3(-1000, 1500, 0), 200);
            }
            return(0);
        }
예제 #4
0
        protected void OnCloseToDeadWilbur(DOLEvent e, object n, EventArgs args)
        {
            GameNPC pigHerderWyatt = n as GameNPC;

            if (pigHerderWyatt != null)
            {
                GameEventMgr.RemoveHandler(pigHerderWyatt, GameNPCEvent.ArriveAtTarget, new DOLEventHandler(OnCloseToDeadWilbur));
                pigHerderWyatt.Emote(eEmote.Beg);
                pigHerderWyatt.Yell("Wilbur? What have you done to Wilbur, you scoundrel!");

                RegionTimer waitTimer = new RegionTimer(pigHerderWyatt);
                waitTimer.Callback = new RegionTimerCallback(OnCloseToDeadWilburCallBack);
                waitTimer.Properties.setProperty(questTitle, pigHerderWyatt);
                waitTimer.Start(4000);
            }
        }
예제 #5
0
파일: npc.cs 프로젝트: JVirant/DOLSharp
        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;
            }
        }