Exemple #1
0
    public override void CalculateGoalRelevancy()
    {
        WorldStateProp prop = Owner.WorldState.GetWSProperty(E_PropKey.E_EVENT);

        if (prop != null)
        {
            if (Owner.BlackBoard.ReactOnHits && prop.GetEvent() == E_EventTypes.Hit)
            {
                /*Fact fact = Owner.Memory.GetFact(Query);
                 * if (fact != null && fact.Belief > 0.7f)*/
                GoalRelevancy = Owner.BlackBoard.GOAP_ReactToDamageRelevancy;
            }
            else if (Owner.BlackBoard.ReactOnHits && prop.GetEvent() == E_EventTypes.Knockdown)
            {
                GoalRelevancy = Owner.BlackBoard.GOAP_ReactToDamageRelevancy;
            }
            else if (prop.GetEvent() == E_EventTypes.Died)
            {
                GoalRelevancy = Owner.BlackBoard.GOAP_ReactToDamageRelevancy;
            }
            else
            {
                GoalRelevancy = 0.0f;
            }
        }
        else
        {
            GoalRelevancy = 0;
        }
    }
    public override void Update()
    {
        WorldStateProp prop = Owner.WorldState.GetWSProperty(E_PropKey.E_EVENT);

        if (prop.GetEvent() != E_EventTypes.Hit && prop.GetEvent() != E_EventTypes.Died)
        {
            return;
        }

        SendActionKill();
    }
    /* public override void MakeSatisfied(WorldState worldState)
     * {
     *   worldState.SetWSProperty(WorldStatePropKey.EVENT, EventTypes.NONE);
     * }*/

    public override void CalcWeight(WorldState worldState, BlackBoard blackBoard)
    {
        Weight = 0;
        WorldStateProp prop = worldState.GetWSProperty(WorldStatePropKey.EVENT);

        if (prop != null)
        {
            /*if (prop.GetEvent() == EventTypes.HIT || prop.GetEvent() == EventTypes.KNOCKDOWN || prop.GetEvent() == EventTypes.DEAD)
             * {
             *  Weight = blackBoard.GOAP_ReactToDamageRelevancy;
             * }*/
            switch (prop.GetEvent())
            {
            case EventTypes.HIT:
                Weight = blackBoard.GOAP_INJURY;
                break;

            case EventTypes.DEAD:
                Weight = blackBoard.GOAP_DEATH;
                break;

            case EventTypes.KNOCKDOWN:
                Weight = blackBoard.GOAP_KNOCKDOWN;
                break;

            default:
                break;
            }
        }
    }
    public override void Update()
    {
        if (Owner.IsAlive == false)
        {
            Interruptible = true;
        }

        if (Count == 3)
        {
            if (Action.IsActive() == false && ActionAttack == null)
            {
                Owner.SoundPlayBerserk();
                Owner.BlackBoard.Invulnerable = true;
                ActionAttack           = AgentActionFactory.Create(AgentActionFactory.E_Type.E_ATTACK) as AgentActionAttack;
                ActionAttack.Data      = Owner.AnimSet.GetFirstAttackAnim(Owner.BlackBoard.WeaponSelected, E_AttackType.O);
                ActionAttack.AttackDir = Owner.Forward;
                Owner.BlackBoard.ActionAdd(ActionAttack);
            }
            return;
        }

        WorldStateProp prop = Owner.WorldState.GetWSProperty(E_PropKey.E_EVENT);

        if (prop == null || prop.GetEvent() != E_EventTypes.Hit || Owner.IsAlive == false)
        {
            return;
        }

        SendAction();
    }
Exemple #5
0
    public void SetWSProperty(WorldStateProp other)
    {
        if (other == null)
        {
            return;
        }

        switch (other.PropType)
        {
        case E_PropType.E_BOOL:
            SetWSProperty(other.PropKey, other.GetBool());
            break;

        case E_PropType.E_INT:
            SetWSProperty(other.PropKey, other.GetInt());
            break;

        case E_PropType.E_FLOAT:
            SetWSProperty(other.PropKey, other.GetFloat());
            break;

        case E_PropType.E_VECTOR:
            SetWSProperty(other.PropKey, other.GetVector());
            break;

        case E_PropType.E_AGENT:
            SetWSProperty(other.PropKey, other.GetAgent());
            break;

        case E_PropType.E_EVENT:
            SetWSProperty(other.PropKey, other.GetEvent());
            break;

        case E_PropType.E_ORDER:
            SetWSProperty(other.PropKey, other.GetEvent());
            break;

        default:
            Debug.LogError("error in SetWSProperty " + other.PropKey.ToString());
            break;
        }
    }
Exemple #6
0
    public override bool IsWSSatisfiedForPlanning(WorldState worldState)
    {
        WorldStateProp prop = worldState.GetWSProperty(E_PropKey.E_EVENT);

        if (prop != null && prop.GetEvent() == E_EventTypes.None)
        {
            return(true);
        }

        return(false);
    }
Exemple #7
0
    public override bool ValidateContextPreconditions(Agent ai)
    {
        WorldStateProp prop = ai.WorldState.GetWSProperty(E_PropKey.E_EVENT);

        if (prop == null || prop.GetEvent() != E_EventTypes.Died)
        {
            return(false);
        }

        return(true);
    }
    public override bool ValidateContextPreconditions(Agent ai)
    {
        WorldStateProp prop = Owner.WorldState.GetWSProperty(E_PropKey.E_EVENT);

        if (prop == null || prop.GetEvent() != E_EventTypes.Knockdown)
        {
            return(false);
        }

        if (Owner.IsAlive == false)
        {
            return(false);
        }

        return(true);
    }
    public override void Deactivate()
    {
        Owner.BlackBoard.Invulnerable = false;
        Action       = null;
        ActionAttack = null;
        base.Deactivate();

        WorldStateProp prop = Owner.WorldState.GetWSProperty(E_PropKey.E_EVENT);

        if (prop == null || prop.GetEvent() != E_EventTypes.Hit)
        {
            return;
        }
        // if there is some hit, clear it !!
        Owner.WorldState.SetWSProperty(E_PropKey.E_EVENT, E_EventTypes.None);
    }
Exemple #10
0
    public override void Activate()
    {
        base.Activate();

        Action = null;

        WorldStateProp prop = Owner.WorldState.GetWSProperty(E_PropKey.E_EVENT);

        if (prop == null || prop.GetEvent() != E_EventTypes.Knockdown)
        {
            return;
        }

        //WorldStateTime = prop.Time;

        SendAction();
    }
Exemple #11
0
    public override void Update()
    {
        if (Owner.IsAlive == false)
        {
            Interruptible = true;
        }


        WorldStateProp prop = Owner.WorldState.GetWSProperty(E_PropKey.E_EVENT);

        if (prop == null || prop.GetEvent() != E_EventTypes.Hit || Owner.IsAlive == false)
        {
            return;
        }

        SendAction();
    }
Exemple #12
0
    public override void Deactivate()
    {
        Action = null;
        base.Deactivate();

        WorldStateProp prop = Owner.WorldState.GetWSProperty(E_PropKey.E_EVENT);

        if (prop == null || prop.GetEvent() != E_EventTypes.ImInPain)
        {
            return;
        }

        if (WorldStateTime == prop.Time)
        {
            Owner.WorldState.SetWSProperty(E_PropKey.E_EVENT, E_EventTypes.None);
        }
    }
Exemple #13
0
    public override void Activate()
    {
        base.Activate();

        Action        = null;
        Interruptible = false;

        WorldStateProp prop = Owner.WorldState.GetWSProperty(E_PropKey.E_EVENT);

        if (prop == null || prop.GetEvent() != E_EventTypes.Hit)
        {
            return;
        }

        WorldStateTime = prop.Time;

        SendAction();
    }
    public override bool IsSatisfied(WorldState worldState)
    {
        WorldStateProp prop = worldState.GetWSProperty(WorldStatePropKey.EVENT);

        return(prop.GetEvent() == EventTypes.NONE);
    }
Exemple #15
0
    public override bool IsPreConditionSatisfied(WorldState ws)
    {
        WorldStateProp prop = ws.GetWSProperty(WorldStatePropKey.EVENT);

        return(prop.GetEvent() == EventTypes.KNOCKDOWN);
    }