Home   Help Search Login Register  

Author Topic: Question about DISTANCE > HELP!  (Read 1266 times)

0 Members and 1 Guest are viewing this topic.

Durbs

  • Guest
Question about DISTANCE > HELP!
« 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  ::)

Code: [Select]
? ((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.
« Last Edit: 30 Nov 2005, 03:17:43 by ÐurbanPoisonâ„¢ »

LoTekK

  • Guest
Re:Question about DISTANCE > HELP!
« Reply #1 on: 30 Nov 2005, 04:21:23 »
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":
Code: [Select]
? ((side player==EAST) and (player distance _MINE) <= 25) : goto "Detonate";

Durbs

  • Guest
Re:Question about DISTANCE > HELP!
« Reply #2 on: 30 Nov 2005, 06:55:38 »
cool - i'll try that  :)
ty

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:Question about DISTANCE > HELP!
« Reply #3 on: 30 Nov 2005, 13:35:19 »
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
« Last Edit: 30 Nov 2005, 13:35:57 by THobson »

Offline General Barron

  • Former Staff
  • ****
  • Semper Fi!
Re:Question about DISTANCE > HELP!
« Reply #4 on: 30 Nov 2005, 18:33:17 »
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.

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:

Code: [Select]
#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.
« Last Edit: 30 Nov 2005, 19:19:18 by General Barron »
HANDSIGNALS COMMAND SYSTEM-- A realistic squad-control modification for OFP
kexp.org-- The best radio station in the world, right here at home! Listen to John Richards!

Durbs

  • Guest
Re:Question about DISTANCE > HELP!
« Reply #5 on: 03 Dec 2005, 07:34:33 »
I think that is gonna work - thx guys :)