Exemple #1
0
        private static void Loot(User.User player, List <string> commands)
        {
            Character.Iactor npc      = null;
            string[]         position = commands[0].Split('.'); //we are separating based on using the decimal operator after the name of the npc/item
            if (position.Count() > 1)
            {
                //ok so the player specified a specific NPC in the room list to loot and not just the first to match
                int pos;
                int.TryParse(position[position.Count() - 1], out pos);
                if (pos != 0)
                {
                    npc = Character.NPCUtils.GetAnNPCByID(GetObjectInPosition(pos, commands[2], player.Player.Location));
                }
            }
            else
            {
                npc = Character.NPCUtils.GetAnNPCByID(player.Player.CurrentTarget);
            }

            if (npc != null && npc.IsDead())
            {
                npc.Loot(player, commands);
            }
            else if (npc != null && !npc.IsDead())
            {
                player.MessageHandler("You can't loot what is not dead! Maybe you should try killing it first.");
            }

            //wasn't an npc we specified so it's probably a player
            if (npc == null)
            {
                User.User lootee = FindTargetByName(commands[commands.Count - 1], player.Player.Location);
                if (lootee != null && lootee.Player.IsDead())
                {
                    lootee.Player.Loot(player, commands);
                }
                else if (lootee != null && !lootee.Player.IsDead())
                {
                    player.MessageHandler("You can't loot what is not dead! Maybe you should try pickpocketing or killing it first.");
                }
                else
                {
                    player.MessageHandler("You can't loot what doesn't exist...unless you see dead people, but you don't.");
                }
            }

            return;
        }