Hi guys,
I can't seem to find an answer to this in the scripting tutorials I've down loaded or in the BI forums and with OPFEC still down I'm starting to go a little crazy.
I'm writing a script that will in effect set multiple waypoints to respawning AI units to use with my progressive respawn script (a discussion of which you can find here). ***
So far I've managed to do this for individual AI units using the doMove command.
For instance, I have an AI unit with name set to e1 and have placed the following code in its init line:
<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">init="this addEventHandler ['killed', {[] exec 'Do_Move.sqs'}];[/QUOTE]
My basic script for a specific unit looks like this:
<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">;Do_Move.sqs'
#START
? (WP_0): goto "ONE"
Exit
#ONE
@!alive e1
@ alive e1
#LOOP
;unit moves to 1st waypoint
e1 doMove (getMarkerPos "Obj_WP_0")
@(e1 distance getMarkerPos "Obj_WP_0") < 1
;unit moves to final waypoint
e1 doMove (getMarkerPos "East_0")
Exit[/QUOTE]
I’ve included the if command at the start of the script as once its all running nicely I intend to have multiple waypoints set to each of my progressive respawn points.
Where I’m having problems is when I try and generalise this script for a range of AI units named e1, e2 e3 etc.
In the general script I’ve created a local variable that is meant to take the unit name so I’ve change the script to look like this:
<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">;Do_Move.sqs'
_unit = _this select 0
#START
? (WP_0): goto "ONE"
Exit
#ONE
@!alive _unit
@ alive _unit
#LOOP
_unit doMove (getMarkerPos "Obj_WP_0")
@(_unit distance getMarkerPos "Obj_WP_0") < 1
_unit doMove (getMarkerPos "East_0")
Exit[/QUOTE]
Then in each units init field I’ve placed the following code
<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">init="this addEventHandler ['killed', {[x] exec 'Do_Move.sqs'}];[/QUOTE] where x is the units name eg e1, e2 etc. ***
Now for some reason this is not working and the alive command just is not seeing the units name and therefore is not activating. ***
I’ve tried a variety of syntax including placing the units name in “” in the init line but not surprisingly that just gives me string error with the alive command. ***
I’m sure I’m missing something very simple here in defining my script variable and then passing it from the init line to my script so any help would be much appreciated.
HOME 
Reply With Quote


