예제 #1
0
파일: States.cs 프로젝트: vadian/Novus
 public void Execute(Character.NPC actor, ITrigger trigger = null)
 {
     if (!actor.IsDead() && !actor.InCombat)
     {
         if (DateTime.Now.ToUniversalTime() > actor.NextAiAction)
         {
             //eventuall this literals will be gotten from the literals table for each different NPC
             Commands.CommandParser.ExecuteCommand(actor, "SAY", "brains...");
             Commands.CommandParser.ExecuteCommand(actor, "EMOTE", "reaches out attempting to grab something");
             actor.NextAiAction = DateTime.Now.AddSeconds(Extensions.RandomNumber.GetRandomNumber().NextNumber(15, 60)).ToUniversalTime();
             if (!FSM.ContinueWithThisState())
             {
                 actor.Fsm.ChangeState(Wander.GetState(), actor);
             }
         }
     }
 }
예제 #2
0
파일: States.cs 프로젝트: vadian/Novus
        public void Execute(Character.NPC actor, ITrigger trigger = null)
        {
            if (!actor.IsDead() && !actor.InCombat)
            {
                Rooms.Room room = Rooms.Room.GetRoom(actor.Location);
                room.GetRoomExits();
                List <Rooms.Exits> availableExits = room.RoomExits;
                if (DateTime.Now.ToUniversalTime() > actor.NextAiAction)  //so it's time for this AI state to execute
                {
                    Commands.CommandParser.ExecuteCommand(actor, availableExits[Extensions.RandomNumber.GetRandomNumber().NextNumber(0, availableExits.Count)].Direction);
                    actor.NextAiAction = DateTime.Now.AddSeconds(Extensions.RandomNumber.GetRandomNumber().NextNumber(60, 121)).ToUniversalTime(); //set when we want this action to execute next
                    if (!FSM.ContinueWithThisState())
                    {
                        actor.Fsm.ChangeState(Speak.GetState(), actor);
                    }
                }
            }

            if (actor.InCombat)
            {
                actor.Fsm.ChangeState(Combat.GetState(), actor);
            }
        }
예제 #3
0
파일: Combat.cs 프로젝트: vadian/Novus
        //finisher moves
        //these will actually be skill moves
        private static void Cleave(User.User player, List <string> commands)         //this will need a check in the future to be used with only bladed weapons
        {
            User.User enemy = null;
            if (commands.Count > 2)
            {
                foreach (User.User foe in MySockets.Server.GetAUserByFirstName(commands[2]))
                {
                    if (foe.Player.Location == player.Player.Location)
                    {
                        enemy = foe;
                    }
                }
            }
            else  //did not specify a name let's kill the first player we find unconcious in our same location
            {
                enemy = MySockets.Server.GetCurrentUserList().Where(u => u.Player.Location == player.Player.Location && String.Compare(u.Player.ActionState.ToString(), "unconcious", true) == 0).SingleOrDefault();
            }

            if (enemy == null)
            {
                //ok it's not a player lets look through the NPC list
                foreach (Character.NPC npc in Character.NPCUtils.GetAnNPCByName(commands[2], player.Player.Location))
                {
                    if (npc.ActionState == CharacterEnums.CharacterActionState.Unconcious)
                    {
                        User.User foe = new User.User(true);
                        foe.UserID = npc.ID;
                        foe.Player = npc;
                        enemy      = foe;
                        break;
                    }
                }
            }

            if (enemy == null)
            {
                player.MessageHandler("You can't kill what you can't see!");
                return;
            }
            Room room = Room.GetRoom(player.Player.Location);

            if (String.Compare(enemy.Player.ActionState.ToString(), "unconcious", true) == 0)
            {
                if (commands.Count > 3 && commands[3].ToLower() == "slowly")                    //a slow death for your opponent, bask in it.
                {
                    player.MessageHandler(String.Format("You slowly drive your blade through {0}'s chest and twist it a few times as {1} lays on the ground unconcious.", enemy.Player.FirstName, enemy.Player.Gender == "Male" ? "he" : "she"));
                    enemy.MessageHandler(String.Format("{0} slowly drives {1} blade through your chest and twists it a few times as you lay on the ground unconcious.", player.Player.FirstName, player.Player.Gender == "Male" ? "his" : "her"));
                    string roomMessage = String.Format("{0} slowly drives {1} blade through {2}'s chest and twists it a few times as {3} lay on the ground unconcious.", player.Player.FirstName, player.Player.Gender == "Male" ? "his" : "her", enemy.Player.FirstName, enemy.Player.Gender == "Male" ? "he" : "she");
                    room.InformPlayersInRoom(roomMessage, new List <string>(new string[] { player.UserID, enemy.UserID }));
                    ;
                }
                else
                {
                    player.MessageHandler(String.Format("You cleave {0} as {1} lays on the ground unconcious.", enemy.Player.FirstName, enemy.Player.Gender == "Male" ? "he" : "she"));
                    enemy.MessageHandler(String.Format("{0} cleaved you as you lay on the ground unconcious.", player.Player.FirstName));
                    string roomMessage = String.Format("{0} cleaved {1} as {2} lay on the ground unconcious.", player.Player.FirstName, enemy.Player.FirstName, enemy.Player.Gender == "Male" ? "he" : "she");
                    room.InformPlayersInRoom(roomMessage, new List <string>(new string[] { player.UserID, enemy.UserID }));
                }
                enemy.Player.SetAttributeValue("Hitpoints", -100);
                //SetDead(player, enemy);
                Character.NPC npc = enemy.Player as Character.NPC;
                if (npc != null)
                {
                    if (npc.IsDead())
                    {
                        npc.Fsm.ChangeState(AI.Rot.GetState(), npc);
                    }
                }
            }
            else
            {
                player.MessageHandler(String.Format("You can't cleave {0}, {1} not unconcious.", enemy.Player.FirstName, enemy.Player.Gender == "Male" ? "he's" : "she's"));
            }
        }