Ejemplo n.º 1
0
    public void StealFromEnemy(Character user, Enemy target)
    {
        ItemDropType t = ItemDropType.ITEM;
        int id = -1;
        int m = -1;

        // steal item
        if(this.stealItem && target.stealItem && !target.itemStolen &&
            DataHolder.GameSettings().GetRandom() <=
            (DataHolder.Formula(this.itemChance).Calculate(user, target)+
                user.GetItemStealBonus()+this.itemBonus)*target.stealItemFactor)
        {
            if(this.fixItem)
            {
                GameHandler.AddToInventory(this.itemType, this.itemID, 1);
                t = this.itemType;
                id = this.itemID;
            }
            else
            {
                GameHandler.AddToInventory(target.stealItemType, target.stealItemID, 1);
                t = target.stealItemType;
                id = target.stealItemID;
            }
            if(target.stealItemOnce) target.itemStolen = true;
            if(id >= 0)
            {
                // TODO: info text display
            }
        }

        // steal money
        if(this.stealMoney && target.stealMoney && !target.moneyStolen &&
            DataHolder.GameSettings().GetRandom() <=
            (DataHolder.Formula(this.moneyChance).Calculate(user, target)+
                user.GetMoneyStealBonus()+this.moneyBonus)*target.stealMoneyFactor)
        {
            if(this.fixMoney)
            {
                GameHandler.AddMoney(this.money);
                m = this.money;
            }
            else
            {
                GameHandler.AddMoney(target.stealMoneyAmount);
                m = target.stealMoneyAmount;
            }
            if(target.stealMoneyOnce) target.moneyStolen = true;
        }
        this.ShowStealInfo(user.GetName(), t, id, m);
    }