Exemple #1
0
        public bool playerItemDrop(Player player, ItemInfo item, ushort quantity)
        {
            Arena.ItemDrop newDrop = null;

            //Droppable?
            if (!item.droppable)
            {
                return(false);
            }

            if (player.inventoryModify(item, -quantity))
            {   //Create an item spawn
                newDrop            = _arena.itemSpawn(item, quantity, player._state.positionX, player._state.positionY, 0, (int)player._team._id, player);
                newDrop.tickExpire = 0;
            }

            if (player._alias.ToLower() == _owner)
            {
                if (newDrop != null)
                {
                    newItem(newDrop);
                }
            }

            return(false);
        }
Exemple #2
0
 /// <summary>
 /// Constructor
 /// </summary>
 public LootDrop(Arena.ItemDrop item, Player owner, int tickCreation, ushort id)
 {
     _item         = item;
     _owner        = owner;
     _tickCreation = tickCreation;
     _id           = id;
 }
Exemple #3
0
        /// <summary>
        /// Notifies a single player of an item drop
        /// </summary>
        static public void Object_ItemDrop(Player player, Arena.ItemDrop drop)
        {       //Create the notification packet
            SC_Items items = new SC_Items();

            items.singleItem = drop;

            player._client.sendReliable(items);
        }
Exemple #4
0
        public bool playerItemDrop(Player player, ItemInfo item, ushort quantity)
        {
            if (_arena.getTerrainID(player._state.positionX, player._state.positionY) == 10)
            {
                if (player.inventoryModify(item, -quantity))
                {
                    //We want to continue wrapping around the vehicleid limits
                    //looking for empty spots.
                    ushort ik;

                    for (ik = _arena._lastItemKey; ik <= Int16.MaxValue; ++ik)
                    {   //If we've reached the maximum, wrap around
                        if (ik == Int16.MaxValue)
                        {
                            ik = (ushort)ZoneServer.maxPlayers;
                            continue;
                        }

                        //Does such an item exist?
                        if (_arena._items.ContainsKey(ik))
                        {
                            continue;
                        }

                        //We have a space!
                        break;
                    }

                    _arena._lastItemKey = ik;
                    //Create our drop class
                    Arena.ItemDrop id = new Arena.ItemDrop();

                    id.item       = item;
                    id.id         = ik;
                    id.quantity   = (short)quantity;
                    id.positionX  = player._state.positionX;
                    id.positionY  = player._state.positionY;
                    id.relativeID = (0 == 0 ? item.relativeID : 0);
                    id.freq       = player._team._id;

                    id.owner = player; //For bounty abuse upon pickup

                    int expire = _arena.getTerrain(player._state.positionX, player._state.positionY).prizeExpire;
                    id.tickExpire = (expire > 0 ? (Environment.TickCount + (expire * 1000)) : 0);

                    //Add it to our list
                    _arena._items[ik] = id;

                    //Notify JUST the player
                    Helpers.Object_ItemDrop(player, id);
                }
                return(false);
            }
            return(true);
        }
Exemple #5
0
        /// <summary>
        /// Notifies a bunch of players of a new item drop
        /// </summary>
        static public void Object_ItemDrop(IEnumerable <Player> players, Arena.ItemDrop drop)
        {               //Create the notification packet
            SC_Items items = new SC_Items();

            items.singleItem = drop;

            //Route the packet
            foreach (Player p in players)
            {
                p._client.sendReliable(items);
            }
        }
Exemple #6
0
        public void newItem(Arena.ItemDrop drop)
        {
            ushort id = (ushort)(_database.getLastItemID(_owner) + 1);

            StoredItem newItem = new StoredItem(this);

            newItem._id       = id;
            newItem._itemID   = drop.item.id;
            newItem._quantity = drop.quantity;
            newItem._posX     = drop.positionX;
            newItem._posY     = drop.positionY;
            newItem._key      = _owner;
            newItem._drop     = drop;

            _database.addItem(drop.item.id, drop.positionX, drop.positionY, drop.quantity, _owner);
            _items.Add(id, newItem);
        }
Exemple #7
0
        public bool playerItemPickup(Player player, Arena.ItemDrop drop, ushort quantity)
        {
            StoredItem item = _items.Values.FirstOrDefault(itm => itm._drop.id == drop.id);

            if (item != null)
            {
                if (drop.quantity == 0)
                {
                    item.remove();
                }
                else
                {
                    item._quantity -= (short)quantity;
                    _database.updateItem(item, _owner);
                }
            }
            return(true);
        }
Exemple #8
0
 public bool playerItemPickup(Player player, Arena.ItemDrop drop, ushort quantity)
 {
     return(true);
 }
Exemple #9
0
        /// <summary>
        /// Creates an item drop at the specified location
        /// </summary>
        public void itemSpawn(ItemInfo item, ushort quantity, short positionX, short positionY, Player p)
        {
            using (LogAssume.Assume(_logger))
            {
                if (item == null)
                {
                    Log.write(TLog.Error, "Attempted to spawn invalid item.");
                    return;
                }

                if (quantity == 0)
                {
                    Log.write(TLog.Warning, "Attempted to spawn 0 of an item.");
                    return;
                }

                //Too many items?
                if (_arena._items.Count == Arena.maxItems)
                {
                    Log.write(TLog.Warning, "Item count full.");
                    return;
                }

                int   blockedAttempts = 35;
                short pX;
                short pY;
                while (true)
                {
                    pX = positionX;
                    pY = positionY;
                    Helpers.randomPositionInArea(_arena, _arena._server._zoneConfig.arena.pruneDropRadius, ref pX, ref pY);
                    if (_arena.getTile(pX, pY).Blocked)
                    {
                        blockedAttempts--;
                        if (blockedAttempts <= 0)
                        {
                            //Consider the spawn to be blocked
                            return;
                        }
                        continue;
                    }

                    //We want to continue wrapping around the vehicleid limits
                    //looking for empty spots.
                    ushort ik;

                    for (ik = _arena._lastItemKey; ik <= Int16.MaxValue; ++ik)
                    {   //If we've reached the maximum, wrap around
                        if (ik == Int16.MaxValue)
                        {
                            ik = (ushort)ZoneServer.maxPlayers;
                            continue;
                        }

                        //Does such an item exist?
                        if (_arena._items.ContainsKey(ik))
                        {
                            continue;
                        }

                        //We have a space!
                        break;
                    }

                    _arena._lastItemKey = ik;

                    //Create our drop class
                    Arena.ItemDrop id = new Arena.ItemDrop();

                    id.item       = item;
                    id.id         = ik;
                    id.quantity   = (short)quantity;
                    id.positionX  = pX;
                    id.positionY  = pY;
                    id.relativeID = item.relativeID;
                    id.freq       = -1;

                    id.owner = null; //For bounty abuse upon pickup

                    int expire = _arena.getTerrain(positionX, positionY).prizeExpire;
                    id.tickExpire = (expire > 0 ? (Environment.TickCount + (expire * 1000)) : 0);

                    //Add it to our list
                    _arena._items[ik] = id;

                    //Notify the arena
                    Helpers.Object_ItemDrop(_arena.Players, id);
                    break;
                }
            }
        }
Exemple #10
0
        /// <summary>
        /// Creates an item drop at the specified location
        /// </summary>
        public void privateItemSpawn(ItemInfo item, ushort quantity, short positionX, short positionY, Player p, LootType type, Bot dead, string name)
        {
            using (LogAssume.Assume(_logger))
            {
                Log.write("[DROP] - {0} dropped for {1}", item.name, p._alias);

                if (item == null)
                {
                    Log.write(TLog.Error, "Attempted to spawn invalid item.");
                    return;
                }

                if (quantity == 0)
                {
                    Log.write(TLog.Warning, "Attempted to spawn 0 of an item.");
                    return;
                }

                //Too many items?
                if (_arena._items.Count == Arena.maxItems)
                {
                    Log.write(TLog.Warning, "Item count full.");
                    return;
                }

                int            blockedAttempts = 35;
                Arena.ItemDrop spawn           = null;

                short pX;
                short pY;
                while (true)
                {
                    pX = positionX;
                    pY = positionY;
                    Helpers.randomPositionInArea(_arena, _arena._server._zoneConfig.arena.pruneDropRadius, ref pX, ref pY);
                    if (_arena.getTile(pX, pY).Blocked)
                    {
                        blockedAttempts--;
                        if (blockedAttempts <= 0)
                        {
                            //Consider the spawn to be blocked
                            return;
                        }
                        continue;
                    }

                    //We want to continue wrapping around the vehicleid limits
                    //looking for empty spots.
                    ushort ik;

                    for (ik = _arena._lastItemKey; ik <= Int16.MaxValue; ++ik)
                    {   //If we've reached the maximum, wrap around
                        if (ik == Int16.MaxValue)
                        {
                            ik = (ushort)ZoneServer.maxPlayers;
                            continue;
                        }

                        //Does such an item exist?
                        if (_arena._items.ContainsKey(ik))
                        {
                            continue;
                        }

                        //We have a space!
                        break;
                    }



                    _arena._lastItemKey = ik;

                    //Create our drop class
                    Arena.ItemDrop id = new Arena.ItemDrop();

                    id.item       = item;
                    id.id         = ik;
                    id.quantity   = (short)quantity;
                    id.positionX  = pX;
                    id.positionY  = pY;
                    id.relativeID = item.relativeID;
                    id.freq       = p._team._id;

                    id.owner = p; //For bounty abuse upon pickup

                    //Add it to our private loot tracker
                    _script._privateLoot.Add(id.id, new LootDrop(id, p, Environment.TickCount, ik));

                    int expire = _arena.getTerrain(positionX, positionY).prizeExpire;
                    id.tickExpire = (expire > 0 ? (Environment.TickCount + (expire * 1000)) : 0);

                    //Add it to our list
                    _arena._items[ik] = id;
                    //Notify the player
                    Helpers.Object_ItemDrop(_arena.Players, id);


                    if (type > LootType.Common)
                    {
                        foreach (Player player in _arena.Players)
                        {
                            if (player == p)
                            {
                                player.sendMessage(1, String.Format("$A {0} just dropped {1} for you at {2}",
                                                                    dead._type.Name, name, Helpers.posToLetterCoord(id.positionX, id.positionY)));
                            }
                            else
                            {
                                player.triggerMessage(5, 1000, String.Format("A {0} just dropped {1} for {2} at {3}",
                                                                             dead._type.Name, name, p._alias, Helpers.posToLetterCoord(id.positionX, id.positionY)));
                            }
                        }
                    }
                    break;
                }
            }
        }
Exemple #11
0
 public bool playerItemPickup(Player player, Arena.ItemDrop drop, ushort quantity)
 {
     return(_gamePlay.playerItemPickup(player, drop, quantity));
 }