Jump to content
Sign in to follow this  
Somerville

Make a newly spawned empty enemy unit?

Recommended Posts

Morning all,

I've been trying to get this working. The below is a script that is designed to spawn an empty T72, but to try and make it 'enemy' so that an A10 can lock on to it. However, it just shows as a white dot on the radar and won't lock on no matter how many times I fly past. Here is the script:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">?!(local Server): exit

_Xpos = _this select 0

_Ypos = _this select 1

_Xspread = _this select 2

_Yspread = _this select 3

time = _this select 4

targets = _this select 5

localtargetcounter = 0

showresult = false

Publicvariable "showresult"

TargetHits = 0

publicVariable "TargetHits"

Targetmiss = 0

publicVariable "Targetmiss"

targetcount = 0

publicVariable "Targetcount"

#loop

_X = _Xpos

_Y = _Ypos

_X = _X + (random _Xspread - _Xspread /2)

_Y = _Y + (random _Yspread - _Yspread /2)

_target = "T72" createvehicle [_X,_Y,0]

_grp1 = createGroup EAST

_spawndrive = "SquadLeaderE" createUnit [position _target, _grp1,"spawndrive = this",1,"PRIVATE"]

spawndrive moveInDriver _target

_target setSide OPFOR

_driver disableAI "MOVE"

_markerf = createMarker ["Fired", position _target]

"Fired" setMarkerSize [250, 250]

"Fired" setMarkerColor "ColorRedAlpha"

"Fired" setMarkerShape "ELLIPSE"

~240

deleteMarker "fired"

targetcount = targetcount + 1

Publicvariable "Targetcount"

localtargetcounter = localtargetcounter + 1

testnumber1 = localtargetcounter

Publicvariable "testnumber1"

testnumber2 = targets

Publicvariable "testnumber2"

timecount = 0

#Time

showhint = false

Publicvariable "Showhint"

~0.25

?(getdammage _target > 0.1) : goto "hit"

timecount = timecount + 0.25

?timecount < time : goto "time"

_target setdammage 1

Targetmiss = Targetmiss + 1

Publicvariable "Targetmiss"

~1

showhint = true

Publicvariable "Showhint"

goto "next"

#Hit

_target setdammage 1

TargetHits = Targethits + 1

Publicvariable "TargetHits"

~1

showhint = true

Publicvariable "Showhint"

goto "next"

#next

~2

deletevehicle _target

~2

?localtargetcounter >= targets : showhint = true; Publicvariable "Showhint"; goto "end"

goto "loop"

#end

testinprogress = false

Publicvariable "testinprogress"

showresult = true

Publicvariable "showresult"

testnumber1 = 0

Publicvariable "testnumber1"

testnumber2 = 0

Publicvariable "testnumber2"

I hope you can help smile_o.gif

Thanks,

Somerville

Share this post


Link to post
Share on other sites

Any vehicle is counted as an enemy as soon it`s occupied by an enemy unit. That should apply to this scenario too.

Empty vehicles are Blue, like civilian stuff.

Share this post


Link to post
Share on other sites

Hi Sommerville,

for a vehicle to be noticed on the radar, the engine has to be switched on. With your current script this will not happen:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">.

.

_spawndrive = "SquadLeaderE" createUnit [position _target, _grp1,"spawndrive = this",1,"PRIVATE"]

spawndrive moveInDriver _target

_target setSide OPFOR

_driver disableAI "MOVE"

.

.

You have mixed _spawndrive and spawndrive (without underscore). So the unit is never moved into the vehicle. Als the variable _driver is not defined anywhere, and thus the disableAI command will not work.

I can't check right now, but creating the vehicle and then switching on the engine with<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_spawndrive action ["engineOn", _target]might work. Otherwise creating the vehicle and assigning the AI unit as commander would be an option, as the commander will not drive away and the turret will activate the engine.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×