예제 #1
0
    public static bool ConsumeProduct(int EntityID, ItemValue item)
    {
        bool result = false;

        EntityAliveSDX myEntity = GameManager.Instance.World.GetEntity(EntityID) as EntityAliveSDX;

        if (!myEntity)
        {
            return(false);
        }

        // No Item, no consumption
        if (item == null)
        {
            return(false);
        }


        DisplayLog(" ConsumeProduct() " + item.ItemClass.GetItemName());
        ItemClass original = myEntity.inventory.holdingItem;

        myEntity.inventory.SetBareHandItem(item);
        ItemAction itemAction = myEntity.inventory.holdingItem.Actions[0];

        if (itemAction != null)
        {
            myEntity.Attack(true);
            DisplayLog("ConsumeProduct(): Hold Item has Action0. Executing..");
            itemAction.ExecuteAction(myEntity.inventory.holdingItemData.actionData[0], true);

            //// We want to consume the food, but the consumption of food isn't supported on the non-players, so just fire off the buff
            ///
            DisplayLog("ConsumeProduct(): Trigger Events");
            myEntity.FireEvent(MinEventTypes.onSelfPrimaryActionEnd);
            myEntity.FireEvent(MinEventTypes.onSelfHealedSelf);


            myEntity.SetInvestigatePosition(Vector3.zero, 0);
        }

        DisplayLog(" ConsumeProduct(): Restoring hand item");
        myEntity.inventory.SetBareHandItem(ItemClass.GetItem(original.Name, false));

        return(result);
    }
예제 #2
0
    // Since the entity will attack anything that gets in its way, throttle it so we can do some extra checks.
    public override bool Attack(bool _bAttackReleased)
    {
        if (!_bAttackReleased && !this.IsAttackValid())
        {
            return(false);
        }

        DisplayLog("Attack():");

        this.attackingTime = 60;

        // Check if there's a door in our way, then open it.
        if (this.attackTarget == null)
        {
            // If a door is found, try to open it. If it returns false, start attacking it.
            if (OpenDoor())
            {
                return(true);
            }
        }

        if (this.GetAttackTarget() != null)
        {
            this.RotateTo(this.GetAttackTarget(), 30f, 30f);
        }

        ItemAction itemAction = this.inventory.holdingItem.Actions[0];

        if (itemAction != null)
        {
            itemAction.ExecuteAction(this.inventory.holdingItemData.actionData[0], _bAttackReleased);
        }

        DisplayLog("Attack!");
        return(true);
    }