예제 #1
0
        public bool unequipItem(ItemData.EQUIP slot)
        {
            int equipSlotIndex = (int)slot;

            if (player.getInventory().addItem(slots[equipSlotIndex].getItemId(), slots[equipSlotIndex].getItemAmount()))
            {
                if (slot == ItemData.EQUIP.HAT)
                {
                    if (RuneCraft.wearingTiara(player))
                    {
                        RuneCraft.toggleRuin(player, getItemInSlot(slot), false);
                    }
                }
                slots[equipSlotIndex].setItemId(-1);
                slots[equipSlotIndex].setItemAmount(0);
                player.getPackets().refreshEquipment();
                player.getUpdateFlags().setAppearanceUpdateRequired(true);
                refreshBonuses();
                player.setEntityFocus(65535);
                if (slot == ItemData.EQUIP.WEAPON)
                {
                    setWeapon();
                    MagicData.cancelAutoCast(player, true);
                }
                return(true);
            }
            return(false);
        }
예제 #2
0
 public void refreshGlobalObjects(Player p)
 {
     foreach (WorldObject o in objects)
     {
         if (o != null && (o.isFire() || o.getOwner() == null || o.getOwner() == p) || o.isSpawnedObject() || o.shouldDeleteObject())
         {
             if (o.getLocation().withinDistance(p.getLocation(), 60))
             {
                 if (o.shouldDeleteObject())
                 {
                     p.getPackets().removeObject(o.getLocation(), o.getFace(), o.getType());
                 }
                 else if (!o.isFire())
                 {
                     p.getPackets().createObject(o.isSecondForm() ? o.getSecondaryId() : o.getOriginalId(), o.getLocation(), o.getFace(), o.getType());
                 }
                 else
                 {
                     p.getPackets().createObject(o.getOriginalId(), o.getLocation(), o.getFace(), o.getType());
                 }
             }
         }
     }
     doors.refreshDoorsForPlayer(p);
     if (RuneCraft.wearingTiara(p))
     {
         RuneCraft.toggleRuin(p, p.getEquipment().getItemInSlot(0), true);
     }
 }
예제 #3
0
 public void refresh()
 {
     /*
      * This is used to update your game when you first login.
      */
     getFriends().login();
     getPackets().sendConfig(171, !chat ? 1 : 0);
     getPackets().sendConfig(287, split ? 1 : 0);
     if (split)
     {
         getPackets().sendClientScript(83, new object[] { "s" }, "s");
     }
     getPackets().sendConfig(170, !mouse ? 1 : 0);
     getPackets().sendConfig(427, aid ? 1 : 0);
     getPackets().sendConfig(172, !autoRetaliate ? 1 : 0);
     if (magicType != 1)
     {
         getPackets().sendTab(isHd() ? 99 : 89, magicType == 2 ? 193 : 430);
     }
     if (achievementDiaryTab)
     {
         getPackets().sendTab(isHd() ? 95 : 85, 259);
     }
     RuneCraft.toggleRuin(this, getEquipment().getItemInSlot(ItemData.EQUIP.HAT), RuneCraft.wearingTiara(this));
     getSpecialAttack().setSpecialAmount(specialAmount);
     setPoisonAmount(poisonAmount);
     if (poisonAmount > 0)
     {
         Server.registerEvent(new PoisonEvent((Entity)this, poisonAmount));
     }
     if (teleblockTime > 0)
     {
         if (teleblockTime > Environment.TickCount)
         {
             long delay = teleblockTime - Environment.TickCount;
             setTemporaryAttribute("teleblocked", true);
             Event removeTeleBlockEvent = new Event(delay);
             removeTeleBlockEvent.setAction(() =>
             {
                 removeTeleBlockEvent.stop();
                 removeTemporaryAttribute("teleblocked");
                 teleblockTime = 0;
             });
             Server.registerEvent(removeTeleBlockEvent);
         }
     }
     Farming.refreshPatches(this);
     getEquipment().refreshBonuses();
     if (fightCave != null)
     {
         fightCave.setPlayer(this);
         fightCave.resumeGame();
     }
     setSkullCycles(skullCycles);         // This method updates the appearance, so have this last.
 }
예제 #4
0
        public bool equipItem(int itemID, int slot)
        {
            ItemData.EQUIP equipType = ItemData.getItemType(itemID);
            int            amount    = player.getInventory().getAmountInSlot(slot);
            bool           stackable = ItemData.forId(itemID).isStackable();
            bool           twoHanded = ItemData.isTwoHanded(itemID);

            if (equipType == ItemData.EQUIP.NOTHING)
            {
                player.getPackets().sendMessage("Unable to find an item slot for item : " + itemID + " , please report this to a staff member.");
                return(false);
            }
            if (duelRuleActive(equipType))
            {
                return(true);
            }
            if (twoHanded)
            {
                if (player.getInventory().getTotalFreeSlots() < getNeeded2HSlots())
                {
                    player.getPackets().sendMessage("Not enough space in your inventory.");
                    return(false);
                }
            }
            if (!player.getInventory().deleteItem(itemID, slot, amount))
            {
                return(false);
            }
            if (twoHanded && getItemInSlot(ItemData.EQUIP.SHIELD) != -1)
            {
                if (!unequipItem(ItemData.EQUIP.SHIELD))
                {
                    return(false);
                }
            }
            if (equipType == ItemData.EQUIP.SHIELD)
            {
                if (getItemInSlot(ItemData.EQUIP.WEAPON) != -1)
                {
                    if (ItemData.isTwoHanded(slots[3].getItemId()))
                    {
                        if (!unequipItem(ItemData.EQUIP.WEAPON))
                        {
                            return(false);
                        }
                    }
                }
            }
            int equipSlot = Convert.ToInt32(equipType);

            if (slots[equipSlot].getItemId() != itemID && slots[equipSlot].getItemId() > 0)
            {
                if (!player.getInventory().addItem(slots[equipSlot].getItemId(), slots[equipSlot].getItemAmount(), slot))
                {
                    return(false);
                }
                if (equipType == ItemData.EQUIP.HAT)
                {
                    RuneCraft.toggleRuin(player, slots[equipSlot].getItemId(), false);
                    if (RuneCraft.getTiaraIndex(itemID) != -1)                   // switching from tiara to tiara.
                    {
                        RuneCraft.toggleRuin(player, itemID, true);
                    }
                }
            }
            else if (stackable && slots[equipSlot].getItemId() == itemID)
            {
                amount = slots[equipSlot].getItemAmount() + amount;
            }
            else if (slots[equipSlot].getItemId() != -1)
            {
                player.getInventory().addItem(slots[equipSlot].getItemId(), slots[equipSlot].getItemAmount(), slot);
            }
            slots[equipSlot].setItemId(itemID);
            slots[equipSlot].setItemAmount(amount);
            player.getPackets().refreshEquipment();
            player.getUpdateFlags().setAppearanceUpdateRequired(true);
            if (equipType == ItemData.EQUIP.HAT)
            {
                RuneCraft.toggleRuin(player, itemID, RuneCraft.wearingTiara(player));
            }
            if (equipType == ItemData.EQUIP.WEAPON)
            {
                setWeapon();
                MagicData.cancelAutoCast(player, true);
            }
            refreshBonuses();
            player.setEntityFocus(65535);
            return(true);
        }