Esempio n. 1
0
        public override void OnDeath()
        {
            //Shout("AAAAAAAAAAaaaaa!!!");
            // Now that we're dead, award loot.
            // FIXME: Implement loot tables / full looting.
            Condition.Alive = false;
            var hitter = LastHitter as User;

            if (hitter == null)
            {
                Map.Remove(this);
                World.Remove(this);
                return; // Don't handle cases of MOB ON MOB COMBAT just yet
            }

            if (hitter.Grouped)
            {
                ItemDropAllowedLooters = hitter.Group.Members.Select(user => user.Name).ToList();
            }
            else
            {
                ItemDropAllowedLooters.Add(hitter.Name);
            }

            hitter.ShareExperience(LootableXP);
            var itemDropTime = DateTime.Now;

            foreach (var itemname in LootableItems)
            {
                var item = Game.World.CreateItem(itemname);
                if (item == null)
                {
                    GameLog.UserActivityError("User {player}: looting {monster}, loot item {item} is missing", hitter.Name, Name, itemname);
                    continue;
                }
                item.ItemDropType           = ItemDropType.MonsterLootPile;
                item.ItemDropAllowedLooters = ItemDropAllowedLooters;
                item.ItemDropTime           = itemDropTime;
                World.Insert(item);
                Map.Insert(item, X, Y);
            }

            if (LootableGold > 0)
            {
                var golds = new Gold(LootableGold);
                golds.ItemDropType           = ItemDropType.MonsterLootPile;
                golds.ItemDropAllowedLooters = ItemDropAllowedLooters;
                golds.ItemDropTime           = itemDropTime;
                World.Insert(golds);
                Map.Insert(golds, X, Y);
            }
            Map.Remove(this);
            World.Remove(this);
        }
Esempio n. 2
0
        public bool CanBeLooted(string username, out string error)
        {
            error = string.Empty;
            // Let's just be sure here
            if (!(this is Gold || this is ItemObject))
            {
                error = "You can't do that.";
                return(false);
            }

            if (ItemDropTime == null)
            {
                // Item was inserted by the system, a script, or some other mechanism
                return(true);
            }

            var timeDropDifference = (DateTime.Now - ItemDropTime.Value).TotalSeconds;

            // Check if the item is a normal dropped item, monster loot or deathpile
            if (ItemDropType == ItemDropType.Normal)
            {
                return(true);
            }
            else if (ItemDropType == ItemDropType.MonsterLootPile)
            {
                if (ItemDropAllowedLooters.Contains(username))
                {
                    return(true);
                }
                if (timeDropDifference > Constants.MONSTER_LOOT_DROP_RANDO_TIMEOUT)
                {
                    return(true);
                }
            }
            else // (ItemDropType == ItemDropType.UserDeathPile)
            {
                if (DeathPileOwner.Equals(username))
                {
                    return(true);
                }
                if (ItemDropAllowedLooters.Contains(username) && timeDropDifference > Constants.DEATHPILE_GROUP_TIMEOUT)
                {
                    return(true);
                }
                if (timeDropDifference > Constants.DEATHPILE_RANDO_TIMEOUT)
                {
                    return(true);
                }
            }
            error = "These items are cursed.";

            return(false);
        }
Esempio n. 3
0
        public override void OnDeath()
        {
            //Shout("AAAAAAAAAAaaaaa!!!");
            // Now that we're dead, award loot.
            // FIXME: Implement loot tables / full looting.
            var hitter = LastHitter as User;

            if (hitter == null)
            {
                return;                 // Don't handle cases of MOB ON MOB COMBAT just yet
            }
            if (hitter.Grouped)
            {
                ItemDropAllowedLooters = hitter.Group.Members.Select(user => user.Name).ToList();
            }
            else
            {
                ItemDropAllowedLooters.Add(hitter.Name);
            }

            Condition.Alive = false;

            hitter.ShareExperience(LootableXP);
            var golds        = new Gold(LootableGold);
            var itemDropTime = DateTime.Now;

            foreach (var item in LootableItems)
            {
                item.ItemDropType           = ItemDropType.MonsterLootPile;
                item.ItemDropAllowedLooters = ItemDropAllowedLooters;
                item.ItemDropTime           = itemDropTime;
                World.Insert(item);
                Map.Insert(item, X, Y);
            }
            golds.ItemDropType           = ItemDropType.MonsterLootPile;
            golds.ItemDropAllowedLooters = ItemDropAllowedLooters;
            golds.ItemDropTime           = itemDropTime;

            World.Insert(golds);
            Map.Insert(golds, X, Y);
            Map.Remove(this);

            World.Remove(this);
        }
Esempio n. 4
0
        public override void OnDeath()
        {
            if (DeathDisabled)
            {
                Stats.Hp = Stats.MaximumHp;
                return;
            }

            // Don't die twice
            if (DeathProcessed == true)
            {
                return;
            }

            // Even if we encounter an error, we still count the death as processed to avoid
            // repeated processiong
            DeathProcessed = true;

            var hitter = LastHitter as User;

            if (hitter == null)
            {
                Map.Remove(this);
                World.Remove(this);
                GameLog.Error("OnDeath: lasthitter was null");
                return; // Don't handle cases of MOB ON MOB COMBAT just yet
            }

            try
            {
                var deadTime = DateTime.Now;

                if (hitter.Grouped)
                {
                    ItemDropAllowedLooters = hitter.Group.Members.Select(user => user.Name).ToList();
                    hitter.Group.Members.ForEach(x => x.TrackKill(Name, deadTime));
                }
                else
                {
                    ItemDropAllowedLooters.Add(hitter.Name);
                    hitter.TrackKill(Name, deadTime);
                }

                hitter.ShareExperience(LootableXP, Stats.Level);
                var itemDropTime = DateTime.Now;

                foreach (var itemname in LootableItems)
                {
                    var item = Game.World.CreateItem(itemname);
                    if (item == null)
                    {
                        GameLog.UserActivityError("User {player}: looting {monster}, loot item {item} is missing", hitter.Name, Name, itemname);
                        continue;
                    }
                    item.ItemDropType           = ItemDropType.MonsterLootPile;
                    item.ItemDropAllowedLooters = ItemDropAllowedLooters;
                    item.ItemDropTime           = itemDropTime;
                    World.Insert(item);
                    Map.Insert(item, X, Y);
                }

                if (LootableGold > 0)
                {
                    var golds = new Gold(LootableGold);
                    golds.ItemDropType           = ItemDropType.MonsterLootPile;
                    golds.ItemDropAllowedLooters = ItemDropAllowedLooters;
                    golds.ItemDropTime           = itemDropTime;
                    World.Insert(golds);
                    Map.Insert(golds, X, Y);
                }
            }
            catch (Exception e)
            {
                GameLog.Error("OnDeath for {Name}: exception encountered, loot/gold cancelled {e}", Name, e);
                Game.ReportException(e);
            }
            Game.World.RemoveStatusCheck(this);
            Map?.Remove(this);
            World?.Remove(this);
        }