playMaker

Author Topic: AI4Enemies (asset store) GetAIController.cs  (Read 2155 times)

forcevfx

  • Playmaker Newbie
  • *
  • Posts: 20
    • View Profile
AI4Enemies (asset store) GetAIController.cs
« on: June 05, 2011, 06:23:28 AM »
there a better way...DUH!!!!!!!!!!
bad idea from begininng-
there is a much better way.
why do things twice?? two sets of running vars/twice mem/cpu
have that script change state for you..

----------------------------------------------------
using HutongGames.PlayMaker; |------------HERE NEW REFERENCE


    //my NEW VARS-------------------------------------------------
    //Will Allow exact Impact Point on chars, enviroment
    //Bullet hitting wall = Dirt/Dust particle emission
    //Bullet Hitting Player/Enemy = Blood spurt/splatter
    //playmaker auto event handler
    //This will allow me full access in a third party API:auto switch states
    //***see these associated markers

    public PlayMakerFSM behavior;|------------HERE NEW 'behavior'


----------------inside running code------------------------------------


                    if (!isAttaking && !isWalkingToLastPosition)
                    {
                        //Enemy is Currently Following Waypoint Path
                        waypointModus = true;

                        //*** Start secondary AI Event Manager
                        //*** Enter 'Enemy Patrol' State

                        behavior.Fsm.Event("toPatrol"); //-----here is where you change playmaker state
                    }


this is a serious enhancment to that product.
You do not have to grab "All" the stuff I am.
be selective..
This is every frame, think of it as a bridge.
my ongoing WIP on this topic,
http://www.playmerc.com/merc_SciFiCity/

Code: [Select]
using UnityEngine;

namespace HutongGames.PlayMaker.Actions
{
[ActionCategory(ActionCategory.ScriptControl)]
[Tooltip("Grabs the current data of the AIController.")]
public class GetAIcontroller : FsmStateAction
{
[RequiredField]
public AIController getAi;
[UIHint(UIHint.Variable)]

    public FsmBool isfollowingTarget;
    public FsmEvent Following;
    public FsmEvent notFollowing;

    public FsmBool isAttacking;
    public FsmEvent attacking;
    public FsmEvent notAttacking;

    public FsmVector3 lastVisiblePosition;
    public FsmInt currentWaypoint;

    private FsmBool waypointModus;
    public FsmEvent OnWaypoint;
    public FsmEvent notOnWaypoint;

    public FsmBool isShooting;
    public FsmEvent Shooting;
    public FsmEvent notShooting;

    public FsmBool isHit;
    public FsmEvent Hit;
    public FsmEvent notHit;

    private FsmBool isWaiting;
    public FsmEvent Waiting;
    public FsmEvent notWaiting;

    private FsmBool isDead;
    public FsmEvent Dead;
    public FsmEvent notDead;

    private FsmBool isAlive;
    public FsmEvent Alive;
    public FsmEvent notAlive;

    private FsmBool isWalkingToLastPosition;
    public FsmEvent ToLastPosition;
    public FsmEvent notToLastPosition;

    public FsmFloat health;


    public bool everyFrame;

        public override void Reset()
        {
            isfollowingTarget = false;
            Following = null;
            notFollowing = null;
            isAttacking = false;
            attacking = null;
            notAttacking = null;
            lastVisiblePosition = null;
            currentWaypoint = 0;
            waypointModus = false;
            OnWaypoint = null;
            notOnWaypoint = null; ;
            isShooting = false;
            Shooting = null;
            notShooting = null;
            isHit = false;
            Hit = null;
            notHit = null;
            isWaiting = false;
            Waiting = null;
            notWaiting = null;
            isDead = false;
            Dead = null;
            notDead = null;
            isAlive = true;
            Alive = null;
            notAlive = null;
            isWalkingToLastPosition = false;
            ToLastPosition = null;
            notToLastPosition = null;
            health = 0;
            everyFrame = false;
        }

        public override void OnEnter()
        {
            isfollowingTarget.Value = getAi.isfollowingTarget;
            Fsm.Event(isfollowingTarget.Value ? Following : notFollowing);

            isAttacking = getAi.isAttaking;
            Fsm.Event(isAttacking.Value ? attacking : notAttacking);
            
            lastVisiblePosition = getAi.lastVisiblePosition;
            currentWaypoint = getAi.currentWaypoint;

            waypointModus = getAi.waypointModus;
            Fsm.Event(waypointModus.Value ? OnWaypoint : notOnWaypoint);
            
            isShooting = getAi.isShooting;
            Fsm.Event(isShooting.Value ? Shooting : notShooting);

            isHit = getAi.isHit;
            Fsm.Event(isHit.Value ? Hit : notHit);

            isWaiting = getAi.isWaiting;
            Fsm.Event(isWaiting.Value ? Waiting : notWaiting);

            isDead = getAi.isDead;
            Fsm.Event(isDead.Value ? Dead : notDead);

            isAlive = getAi.isAlive;
            Fsm.Event(isAlive.Value ? Alive : notAlive);

            isWalkingToLastPosition = getAi.isWalkingToLastPosition;
            Fsm.Event(isWalkingToLastPosition.Value ? ToLastPosition : notToLastPosition);

            health = getAi.health;

            if (!everyFrame)
                Finish();
        }
        
        
        public override void OnUpdate()
{
            isfollowingTarget.Value = getAi.isfollowingTarget;
            Fsm.Event(isfollowingTarget.Value ? Following : notFollowing);

            isAttacking = getAi.isAttaking;
            Fsm.Event(isAttacking.Value ? attacking : notAttacking);

            lastVisiblePosition = getAi.lastVisiblePosition;
            currentWaypoint = getAi.currentWaypoint;

            waypointModus = getAi.waypointModus;
            Fsm.Event(waypointModus.Value ? OnWaypoint : notOnWaypoint);

            isShooting = getAi.isShooting;
            Fsm.Event(isShooting.Value ? Shooting : notShooting);

            isHit = getAi.isHit;
            Fsm.Event(isHit.Value ? Hit : notHit);

            isWaiting = getAi.isWaiting;
            Fsm.Event(isWaiting.Value ? Waiting : notWaiting);

            isDead = getAi.isDead;
            Fsm.Event(isDead.Value ? Dead : notDead);

            isAlive = getAi.isAlive;
            Fsm.Event(isAlive.Value ? Alive : notAlive);

            isWalkingToLastPosition = getAi.isWalkingToLastPosition;
            Fsm.Event(isWalkingToLastPosition.Value ? ToLastPosition : notToLastPosition);

            health = getAi.health;
        }

}
}
« Last Edit: June 25, 2011, 08:24:11 AM by forcevfx »

mrbdrm

  • Playmaker Newbie
  • *
  • Posts: 39
    • View Profile
Re: AI4Enemies (asset store) GetAIController.cs
« Reply #1 on: June 10, 2011, 02:21:25 PM »
thank you very much .
so i can use all AI4Enemies features  from playmaker ?