Following from the previous page, we have a script used by Behave ED, to make our storm trooper run to particular place in the level.
//Generated by BehavEd
rem ( "comment" );
set ( /*@SET_TYPES*/ "SET_NO_COMBAT_TALK", /*@BOOL_TYPES*/ "true"
);
//$"patrolRunNoChase"@5
set ( /*!*/ "SET_BEHAVIOR_STATE", /*!*/ "BS_DEFAULT"
);
set ( /*!*/ "SET_WALKING", /*!*/ "false" );
set ( /*!*/ "SET_RUNNING", /*!*/ "true" );
set ( /*!*/ "SET_LOOK_FOR_ENEMIES", /*!*/ "true" );
set ( /*!*/ "SET_CHASE_ENEMIES", /*!*/ "false" );
task ( "go1" )
{
set ( /*@SET_TYPES*/ "SET_NAVGOAL", $get( STRING, "SET_PARM1")$
);
}
task ( "go2" )
{
set ( /*@SET_TYPES*/ "SET_NAVGOAL", $get( STRING, "SET_PARM2")$
);
}
wait ( $get( FLOAT, "SET_PARM3")$ );
dowait ( "go1" );
//(BHVDREM) set ( /*@SET_TYPES*/ "SET_ENEMY", "kyle"
);
dowait ( "go2" );
set ( /*@SET_TYPES*/ "SET_NO_COMBAT_TALK", /*@BOOL_TYPES*/ "false"
);
//$"default"@6
set ( /*!*/ "SET_BEHAVIOR_STATE", /*!*/ "BS_DEFAULT"
);
set ( /*!*/ "SET_CHASE_ENEMIES", /*!*/ "true" );
set ( /*!*/ "SET_LOOK_FOR_ENEMIES", /*!*/ "true" );
set ( /*!*/ "SET_IGNOREALERTS", /*!*/ "false" );
set ( /*!*/ "SET_WALKING", /*!*/ "false" );
Click on the image above to see a rough layout of waypoint and navgoals in relation to where the NPC spawns.
Dont panic, its not too dificult to understand, but all we need to know is it works, look at the text for a minute and see the "SET NAVGOAL" part, on the next line it says "SET PARM1", this is what we need to "tell" the NPC where to go in the level.
You
will see in the script,the line "set ( /*@SET_TYPES*/ "SET_NAVGOAL",
$get( STRING, "SET_PARM1")$ );"this is how the npc "sees"
the navgoal,look above again and you will see the key "parm1" and
the value "kill2", kill2 is the targetname of the waypoint navgoal,(click to enlarge
picture below) so when the npc carries out its spawnscript it looks for parm1,which
is the navgoal.so it will make its way to that point. "parm2" i usually
give a value relative to the distance between npc and navgoal, this may not
be usual but i have had no problems with that.
So we now know that when a NPC spawns if it has been given a spwnscript it will
carry out the actions laid out in the script, but as far as we are concerned
we just want it to run to a waypoint_navgoal, so we must make sure that we have
our waypoint_navgoals set up correctly(see key image to the left), give each
one a different targetname, i will use kill1, kill2, kill3.
I hope this has helped you to make an npc go to where you wanted it to, you can add to and adapt the values listed here so you can make the npcs in your level behave in a more orginised fashion.