예제 #1
0
        /// <summary>
        /// Heals a vehicle with a specific item
        /// </summary>
        public void heal(Player from, ItemInfo.RepairItem item)
        {
            //New formula
            float percentage = (float)item.repairPercentage / 100;

            //For old formula, too lazy to switch out all item files.. dont judge!
            if (item.repairPercentage > 100)
            {
                percentage = (float)item.repairPercentage / 1000;
            }

            int repairAmount = item.repairAmount;

            //Occupied vehicle?
            if (this._inhabitant != null)
            {
                Helpers.Player_RouteItemUsed(this._inhabitant, from, this._id,
                                             (short)item.id, from._state.positionX, from._state.positionY, (byte)from._state.yaw);
            }
            //Unoccupied or Computer vehicle
            else
            {
                this._state.health = (short)Math.Min(this._type.Hitpoints, (int)(this._state.health + (percentage * this._state.health) + repairAmount));

                if (this is Computer)
                {
                    (this as Computer)._sendUpdate = true;
                }
            }
        }
예제 #2
0
        public bool playerRepair(Player player, ItemInfo.RepairItem item, UInt16 targetVehicle, short posX, short posY)
        {
            int healamount = 0;

            //Let's try to credit him for the heal
            if (item.repairType == 0 || item.repairType == 2)
            {   //It's a player heal!
                if (item.repairDistance > 0)
                {
                    //Credit him for a single heal
                    healamount = (item.repairAmount == 0) ? item.repairPercentage : item.repairAmount;
                }
                else if (item.repairDistance < 0)
                {
                    //Credit him for everybody he healed
                    healamount = (item.repairAmount == 0)
                        ? item.repairPercentage * _arena.getPlayersInRange(player._state.positionX, player._state.positionY, -item.repairDistance).Count
                        : item.repairAmount * _arena.getPlayersInRange(player._state.positionX, player._state.positionY, -item.repairDistance).Count;
                }
            }

            //Keep track of it, mang
            if (_healingDone != null)
            {
                if (_healingDone.ContainsKey(player))
                {
                    _healingDone[player] += healamount;
                }
                else
                {
                    _healingDone.Add(player, healamount);
                }
            }
            return(true);
        }
예제 #3
0
 /// <summary>
 /// Triggered when a player tries to heal
 /// </summary>
 public void PlayerRepair(Player from, ItemInfo.RepairItem item)
 {
 }
예제 #4
0
 public bool playerPlayerRepair(Player player, ItemInfo.RepairItem item, UInt16 target, short posX, short posY)
 {
     _gamePlay.PlayerRepair(player, item);
     return(true);
 }
예제 #5
0
 /// <summary>
 /// Triggered when a player attempts to repair(heal)
 /// </summary>
 public virtual void handlePlayerRepair(Player player, ItemInfo.RepairItem item, UInt16 targetVehicle, short posX, short posY)
 {
 }