OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: Durbs on 30 Nov 2005, 03:06:21
-
hey - I like to struggle with my own scripting probs...but this 1 i can't seem to figure out....
I would like to know if there is a way to have an object detect enemy when they get close enuf to the object....ie...west guy uses Minefield script to create 1 mine at his possition....then only when east player gets within 25feet of the mine....it will detonate. (A trigger would be great....but im trying to make the activation SCRIPT based ;))
I have another good script to run when mine is activated by enemy presence to create the carnage...but I dunno how to get the original mine to detect enemy.
I tried this.....but it don't work ::)
? ((side player==EAST) and (player distance _MINE) <= 25 : goto "Detonate";
I'm sure one of you brainy ofp fans can help me with this prob! Thanks in advance.
-
Without the use of a trigger, you'll need a looping script to check that the east player is within the defined distance, though I assume you've got that part sussed. In the code you posted, you're missing a closing bracket after "<= 25":
? ((side player==EAST) and (player distance _MINE) <= 25) : goto "Detonate";
-
cool - i'll try that :)
ty
-
I suggest you look at using the @ command
EG:
@ ((side player==EAST) and (player distance _MINE) <= 25)
Have a look at script syntax here:
http://www.ofpec.com/editors/comref.php?letter=3#Script%20syntax (http://www.ofpec.com/editors/comref.php?letter=3#Script%20syntax)
-
I assume there could be more than one unit that sets off this mine? Like, any unit, or any west unit, etc? In that case, the solution, as usual, lies in some of my own work ;). Check out my "find units" function here (http://www.ofpec.com/editors/funcref.php?filter_func=48).
To get the function to work, you will need one trigger to cover the whole mission area though (to catch all the east or west units).
The function just returns an array of every unit within X distance to another object. So in your case, all you would need is a loop that looks like this:
#enemyCheck
? count ([_MINE, 25, east_units] call findUnits) > 0 : goto "DETONATE"
~3
? alive _MINE : goto "enemyCheck"
exit
Where east_units is an array of all east units, found by putting something like this in the activation field of a trigger (activation: east present; covers entire mission area):
east_units = list this
Read the description of the linked function for more info.
-
I think that is gonna work - thx guys :)