OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: TheGimp on 11 Jun 2006, 14:46:50
-
hi
For a mission i wanted a marker placed on all ural ammo's moving around the battle field. But i want the marker to follow them if they move
how do i do this?
-
well, this is a fast shot from the hips.
a little script:
*markerfollow.sqs
_vehicle = _this select 0
_marker = _this select 1
#loop
~5
_marker setmarkerpos getpos _vehicle
_dammage = getdammage _vehicle
?(_dammage <= 0.1): goto "end"
goto "loop"
#end
_marker setmarkertype "empty"
exit
in the init line of each vehicle insert the following line:
[this, "nameofmarker"] exec "markerfollow.sqs"
In the editor insert a marker for each vehic you like to trace and give it a unique name.
you might shorten the refresh rate by changing the ~5 which will actualize every 5 seconds.
hope this helps
bye
:edit:
i also added a check if vehicle is destroyed, then remove marker (well, make it invisible) and stop script.
-
er, slight change to the script...
#loop
~5
_marker setmarkerpos getpos _vehicle
?not (canmove _vehicle): goto "end"
goto "loop"
in the original version the script will end if the damage on the vehicle is less than or equal to 0.1. so if the truck is undamaged, the script will stop.... ???
-
tell me if i'm wrong but i thought this line
?(_dammage <= 0.1): goto "end"
will check if vehicles dammage is equal or less than 0.1 which is nearly completely destroyed.
if this condition isn't true, then the goto command will be ignored and proceed with the next line which will jump to the beginning of the loop.
I wouldn't use de canmove command since the driver could run the truck against a tree without destroying the vehic but beeing unable to move. But even then you can use this truck for rearm/refuel purposes.
:edit:
i'm a little unsure now...is 0 full health and 1 destroyed or is it vice versa? The 0.1 in the script presumes tha 0 is destroyed. If it's otherwise i'm sorry, just replace 0.1 with 0.9 and the < with > ;)
-
0 damage is undamaged.
1 damage is destroyed.
to check this for yourself, place a unit on the map and put in its init field
this setdamage 1
and if the truck can't move, what's the point of maintaining a loop to keep a marker on its position?
-
thx bedges....sry for messing up the dammage settings.
and about the loop...you're right, for the position the loop is no longer necessarly but to get the health status to know if you can still rearm at it it might be helpful since the script would delete the marker.
However, i think it's up to the mission designer what he needs and then decide which aproach he will follow, since both work and are useful in some circumstances.
greetz
-
thanks guys i used the edit and it worked