예제 #1
0
    public override void CalculateGoalRelevancy()
    {
        GoalRelevancy = 0;

        if (Owner.BlackBoard.DesiredTarget == null)
        {
            return;
        }

        if (Owner.BlackBoard.Dodge < Owner.BlackBoard.DodgeMax * 0.25f)
        {
            return;
        }

        if (Owner.BlackBoard.DesiredTarget != null && Owner.BlackBoard.DistanceToTarget > 3.5f)
        {
            return;
        }

        WorldStateProp prop  = Owner.WorldState.GetWSProperty(E_PropKey.E_IN_BLOCK);
        WorldStateProp prop2 = Owner.WorldState.GetWSProperty(E_PropKey.E_LOOKING_AT_TARGET);
        WorldStateProp prop3 = Owner.WorldState.GetWSProperty(E_PropKey.E_IN_COMBAT_RANGE);
        WorldStateProp prop4 = Owner.WorldState.GetWSProperty(E_PropKey.E_AHEAD_OF_ENEMY);

        // if (Owner.debugGOAP && prop != null) Debug.Log(this.ToString() + " " + prop.GetBool() + prop2.GetBool() + prop3.GetBool() + prop4.GetBool());

        if (prop != null && prop.GetBool() == false && prop2.GetBool() == true && prop3.GetBool() == true && prop4.GetBool() == true)
        {
            GoalRelevancy = Owner.BlackBoard.GOAP_BlockRelevancy * Owner.BlackBoard.Dodge * 0.01f;
        }


        // if(Owner.debugGOAP)  Debug.Log(this.ToString() + " " + GoalRelevancy);
    }
예제 #2
0
    /* 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;
            }
        }
    }
예제 #3
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;
        }
    }
예제 #4
0
    public override void CalculateGoalRelevancy()
    {
        GoalRelevancy = 0;

        if (Owner.BlackBoard.DesiredTarget == null)
        {
            return;
        }

        WorldStateProp prop  = Owner.WorldState.GetWSProperty(E_PropKey.E_ALERTED);
        WorldStateProp prop2 = Owner.WorldState.GetWSProperty(E_PropKey.E_LOOKING_AT_TARGET);

        if (prop.GetBool() == true && prop2.GetBool() == true && Mission.Instance.CurrentGameZone.GetNearestAliveEnemy(Owner, E_Direction.Left, 0.4f) != null)
        {
            if (isGroundThere(Owner.Position + Owner.Right * 2.0f))             //left
            {
                GoalRelevancy = Owner.BlackBoard.GOAP_CombatMoveRightRelevancy; // * Mathfx.Hermite(0, 1, Mathf.Min(2, Owner.BlackBoard.DistanceToTarget / 4.0f));
            }
            else
            {
                GoalRelevancy = 0;
            }
        }
        else
        {
            GoalRelevancy = 0;
        }
    }
예제 #5
0
    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();
    }
예제 #6
0
    public override void CalculateGoalRelevancy()
    {
        if (Owner.BlackBoard.DesiredTarget == null)
        {
            return;
        }

        if (MissionZone.Instance.CurrentGameZone.GetNearestAliveEnemy(Owner, E_Direction.Forward, 0.4f) != null)
        {
            GoalRelevancy = 0;
            return;
        }

        WorldStateProp prop  = Owner.WorldState.GetWSProperty(E_PropKey.E_ALERTED);
        WorldStateProp prop2 = Owner.WorldState.GetWSProperty(E_PropKey.E_IN_COMBAT_RANGE);

        if (prop.GetBool() == true && prop2.GetBool() == false && Owner.BlackBoard.DistanceToTarget > Owner.BlackBoard.CombatRange)
        {
            GoalRelevancy = Mathf.Min(Owner.BlackBoard.GOAP_CombatMoveForwardRelevancy, (Owner.BlackBoard.DistanceToTarget - Owner.BlackBoard.CombatRange) * 0.2f);
        }
        else
        {
            GoalRelevancy = 0;
        }
    }
예제 #7
0
    public override bool IsPreConditionSatisfied(WorldState ws)
    {
        WorldStateProp prop1 = ws.GetWSProperty(WorldStatePropKey.WEAPON_IN_HANDS);
        WorldStateProp prop2 = ws.GetWSProperty(WorldStatePropKey.IN_WEAPONS_RANGE);

        return(prop1.GetBool() && prop2.GetBool());
    }
예제 #8
0
    private void DoAction()
    {
        Action = null;

        if (Owner.BlackBoard.DesiredTarget == null)
        {
            return;
        }

        Action = AgentActionFactory.Create(AgentActionFactory.E_Type.E_BLOCK) as AgentActionBlock;

        Action.Attacker = Owner.BlackBoard.DesiredTarget;
        Action.Time     = 3.0f;

        Owner.BlackBoard.ActionAdd(Action);

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

        if (prop == null || prop.GetBool() == true)
        {
            return;
        }

        //WorldStateTime = prop.Time;


        //UnityEngine.Debug.Log(this.ToString() + "Send new roll action to pos " + Action.Direction.ToString());
    }
예제 #9
0
    public override void CalculateGoalRelevancy()
    {
        //AgentOrder order = Ai.BlackBoard.OrderGet();
        //if(order != null && order.Type == AgentOrder.E_OrderType.E_GOTO)
        WorldStateProp prop  = Owner.WorldState.GetWSProperty(E_PropKey.E_LOOKING_AT_TARGET);
        WorldStateProp prop2 = Owner.WorldState.GetWSProperty(E_PropKey.E_AT_TARGET_POS);

        if (prop.GetBool() == false)
        {
            if (Owner.BlackBoard.DesiredTarget != null && prop2.GetBool() == true)
            {
                Vector3 dirToTarget = Owner.BlackBoard.DesiredTarget.Position - Owner.Position;
                GoalRelevancy = Mathf.Min(Owner.BlackBoard.GOAP_LookAtTargetRelevancy, Vector3.Angle(Owner.Forward, dirToTarget) * 0.01f);
                return;
            }

            Fact fact = Owner.Memory.GetFact(Query);

            if (fact != null && fact.Belief > 0.2f)
            {
                //Debug.Log(this.ToString() + " CalculateGoalRelevancy " + Owner.BlackBoard.GOAP_LookAtTargetRelevancy);
                GoalRelevancy = Owner.BlackBoard.GOAP_LookAtTargetRelevancy;
                return;
            }
        }
        GoalRelevancy = 0;
    }
예제 #10
0
    public override void CalculateGoalRelevancy()
    {
        //AgentOrder order = Ai.BlackBoard.OrderGet();
        //if(order != null && order.Type == AgentOrder.E_OrderType.E_GOTO)

        GoalRelevancy = 0;

        if (Owner.BlackBoard.Cover)
        {
            return;
        }

        if (Owner.BlackBoard.MotionType != E_MotionType.None)
        {
            return;
        }

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

        if (prop != null && prop.GetBool() == true)
        {
            return;
        }

        GoalRelevancy = Owner.BlackBoard.GoapSetup.MoveRelevancy;
    }
예제 #11
0
	public override void CalculateGoalRelevancy()
	{
        WorldStateProp prop = Owner.WorldState.GetWSProperty(E_PropKey.E_TELEPORT);
        if (prop != null  &&  prop.GetBool() == true)
            GoalRelevancy = Owner.BlackBoard.GOAP_TeleportRelevancy;
        else
            GoalRelevancy = 0;
	}
예제 #12
0
    public override void CalculateGoalRelevancy()
    {
        GoalRelevancy = 0;

        if (Owner.BlackBoard.DesiredTarget == null)
        {
            return;
        }

        if (Owner.BlackBoard.Fear < Owner.BlackBoard.FearMax * 0.25f)
        {
            return;
        }

        if (MissionZone.Instance.CurrentGameZone.GetNearestAliveEnemy(Owner, E_Direction.Backward, 0.4f) != null)
        {
            return;
        }


        WorldStateProp prop  = Owner.WorldState.GetWSProperty(E_PropKey.E_ALERTED);
        WorldStateProp prop2 = Owner.WorldState.GetWSProperty(E_PropKey.E_IN_COMBAT_RANGE);

        if (prop.GetBool() != true || prop2.GetBool() != true)
        {
            return;
        }

        if (isGroundThere(Owner.Position - Owner.Forward * 2.0f) == false)
        {
            return;
        }


        GoalRelevancy = Owner.BlackBoard.GOAP_CombatMoveBackwardRelevancy * (Owner.BlackBoard.Fear * 0.01f);

        if (Owner.BlackBoard.DistanceToTarget < 2.0f)
        {
            GoalRelevancy += 0.2f;
        }

        if (isGroundThere(Owner.Position - Owner.Forward * 4.0f) == false)
        {
            GoalRelevancy *= 0.5f;
        }

        WorldStateProp prop3 = Owner.WorldState.GetWSProperty(E_PropKey.E_AHEAD_OF_ENEMY);

        if (prop3.GetBool() == false)
        {
            GoalRelevancy *= 0.5f;
        }

        if (GoalRelevancy > Owner.BlackBoard.GOAP_CombatMoveBackwardRelevancy)
        {
            GoalRelevancy = Owner.BlackBoard.GOAP_CombatMoveBackwardRelevancy;
        }
    }
예제 #13
0
	public override bool IsWSSatisfiedForPlanning(WorldState worldState)
	{
        WorldStateProp prop = worldState.GetWSProperty(E_PropKey.E_TELEPORT);

		if (prop.GetBool() == false)
			return true;

		return false;
	}
예제 #14
0
    public override bool IsSatisfied()
    {
        WorldStateProp prop = Owner.WorldState.GetWSProperty(E_PropKey.E_AT_TARGET_POS);

        if (prop != null && prop.GetBool() == true)
        {
            return(true);
        }
        return(false);
    }
예제 #15
0
    public override bool IsWSSatisfiedForPlanning(WorldState worldState)
    {
        WorldStateProp prop = worldState.GetWSProperty(E_PropKey.E_AT_TARGET_POS);

        if (prop != null && prop.GetBool() == true)
        {
            return(true);
        }
        return(false);
    }
예제 #16
0
    public override void Deactivate()
    {
        WorldStateProp prop = Owner.WorldState.GetWSProperty(E_PropKey.E_ORDER);

        if (prop.GetOrder() == AgentOrder.E_OrderType.E_ATTACK)
        {
            Owner.WorldState.SetWSProperty(E_PropKey.E_ORDER, AgentOrder.E_OrderType.E_NONE);
        }
        base.Deactivate();
    }
예제 #17
0
    public override bool IsWSSatisfiedForPlanning(WorldState worldState)
    {
        WorldStateProp prop = worldState.GetWSProperty(E_PropKey.E_IDLING);

        if (prop.GetBool() == false)
        {
            return(true);
        }
        return(false);
    }
예제 #18
0
    public override bool IsWSSatisfiedForPlanning(WorldState worldState)
    {
        WorldStateProp prop = Owner.WorldState.GetWSProperty(E_PropKey.E_PLAY_ANIM);

        if (prop != null && prop.GetBool() == false)
        {
            return(true);
        }
        return(false);
    }
예제 #19
0
    public override bool IsPlanValid()
    {
        WorldStateProp prop = Owner.WorldState.GetWSProperty(E_PropKey.E_LOOKING_AT_TARGET);

        if (prop.GetBool() == true)
        {
            return(false);
        }

        return(base.IsPlanValid());
    }
예제 #20
0
    public override void SolvePlanWSVariable(WorldState currentState, WorldState goalState)
    {
        base.SolvePlanWSVariable(currentState, goalState);

        WorldStateProp prop = goalState.GetWSProperty(E_PropKey.TargetNode);

        if (prop != null)
        {
            currentState.SetWSProperty(prop);
        }
    }
예제 #21
0
    public override bool IsSatisfied()
    {
        WorldStateProp prop = Owner.WorldState.GetWSProperty(E_PropKey.E_WEAPON_IN_HANDS);

        if (prop.GetBool() == true)
        {
            return(true);
        }

        return(false);
    }
예제 #22
0
    public override bool IsWSSatisfiedForPlanning(WorldState worldState)
    {
        WorldStateProp prop = worldState.GetWSProperty(E_PropKey.CoverState);

        if (prop.GetCoverState() == E_CoverState.None)
        {
            return(true);
        }

        return(false);
    }
예제 #23
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);
    }
예제 #24
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();
    }
예제 #25
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);
    }
예제 #26
0
    public override void CalculateGoalRelevancy()
    {
        WorldStateProp prop = Owner.WorldState.GetWSProperty(E_PropKey.E_ORDER);

        if (prop != null && prop.GetOrder() == AgentOrder.E_OrderType.E_USE)
        {
            GoalRelevancy = Owner.BlackBoard.GOAP_UseWorlObjectRelevancy;
        }
        else
        {
            GoalRelevancy = 0;
        }
    }
예제 #27
0
    public override void CalculateGoalRelevancy()
    {
        WorldStateProp prop = Owner.WorldState.GetWSProperty(E_PropKey.E_ATTACK_TARGET);

        if (prop != null && prop.GetOrder() == AgentOrder.E_OrderType.E_ATTACK)
        {
            GoalRelevancy = Owner.BlackBoard.GOAP_KillTargetDelay;
        }
        else
        {
            GoalRelevancy = 0;
        }
    }
예제 #28
0
    public override void CalculateGoalRelevancy()
    {
        WorldStateProp prop = Owner.WorldState.GetWSProperty(E_PropKey.UseGadget);

        if (prop != null && prop.GetBool() == true)
        {
            GoalRelevancy = Owner.BlackBoard.GoapSetup.UseWorlObjectRelevancy;
        }
        else
        {
            GoalRelevancy = 0;
        }
    }
예제 #29
0
    public override void CalculateGoalRelevancy()
    {
        WorldStateProp prop = Owner.WorldState.GetWSProperty(E_PropKey.E_PLAY_ANIM);

        if (prop != null && prop.GetBool() == true)
        {
            GoalRelevancy = Owner.BlackBoard.GOAP_PlayAnimRelevancy;
        }
        else
        {
            GoalRelevancy = 0;
        }
    }
예제 #30
0
    public override void CalculateGoalRelevancy()
    {
        WorldStateProp prop = Owner.WorldState.GetWSProperty(E_PropKey.E_USE_WORLD_OBJECT);

        if (prop != null && prop.GetBool() == true)
        {
            GoalRelevancy = Owner.BlackBoard.GOAP_UseWorlObjectRelevancy;
        }
        else
        {
            GoalRelevancy = 0;
        }
    }