Home   Help Search Login Register  

Author Topic: name closest east unit help  (Read 933 times)

0 Members and 2 Guests are viewing this topic.

kevinfostereditguy

  • Guest
name closest east unit help
« on: 13 Dec 2002, 20:34:12 »
for my script, i need a unit to stand still, and when an east unit gets in range i need the unit to turn to face in the direction of the east unit. the east unit needs its name changed so it can be used in another script, for example, this script will always be running-

#loop
?(man distance victim =<100) : victim setdammage 1
goto "loop"

this is checking all the time for a unit named victim within a certian radius, but i need ANY eastern unit within range to be named "victim". is this possible?

kevinfostereditguy

  • Guest
Re:name closest east unit help
« Reply #1 on: 14 Dec 2002, 16:13:11 »
if this helps to explain, simply, i need a radius that when a EAST unit enters it, he is named "victim", is this possible. recently coming back to scripting this is kicking my arse  ::)

iv just had a thought, could these commands combined get the desired effect?

nearestObject [player, "east"] (closest unit from east side)

and/or

east setidentity "victim" (set any or all the units identity, or preferably names to "victim")

and/or

distance player <=10 east (be used to trigger the effect)

anyone with good scripting knowledge know a way to accomplish this?
« Last Edit: 14 Dec 2002, 16:34:19 by kevinfostereditguy »

Offline LCD

  • Former Staff
  • ****
    • Everon Cartel
Re:name closest east unit help
« Reply #2 on: 15 Dec 2002, 01:43:54 »
didnt u get my mail ? bout davirus attack  ::) ;) ;D

LCD OUT
"guess being the community has downsides .." - cheetah
Help Perfecting Da Next Best Thing - O-Team Beta

kevinfostereditguy

  • Guest
Re:name closest east unit help
« Reply #3 on: 15 Dec 2002, 01:48:41 »
yes, but it was far too complicated for me to understand will all those other commands and i thought id get some other peoples solutions aswell as yours so i can see different ways of doing it

Offline LCD

  • Former Staff
  • ****
    • Everon Cartel
Re:name closest east unit help
« Reply #4 on: 15 Dec 2002, 02:13:40 »
Lol  ::)

no way u get me back 2 old knid of editing :P ;)

LCD OUT
"guess being the community has downsides .." - cheetah
Help Perfecting Da Next Best Thing - O-Team Beta

kevinfostereditguy

  • Guest
Re:name closest east unit help
« Reply #5 on: 15 Dec 2002, 02:20:35 »
i need to take it step by step at the mo, re teaching myself after months of not scripting, so your uberscripts boggle the mind, lol

Captain Winters

  • Guest
Re:name closest east unit help
« Reply #6 on: 15 Dec 2002, 02:50:52 »
I THINK this would work, using this u jus set up the trigger like with this in the activation field
[guysname] exec "scriptname.sqs"

#loop
?(_this = select0 distance victim =<100) : victim setdammage 1
goto "loop"


i think that should work, its been boujt a year since i gave up on scripting so please dont get mad at me if dont work!
it should tho.
__________________________________
__________________________________
Capn' Winters Out!





Captain Winters

  • Guest
Re:name closest east unit help
« Reply #7 on: 15 Dec 2002, 02:53:59 »
OH SORRY! my bad! you also have to change the "victim" to

_this = select0


______________________________
______________________________
Capn' Winters Out!

Bremmer

  • Guest
Re:name closest east unit help
« Reply #8 on: 16 Dec 2002, 11:22:15 »
Its actually a bit of a pain to find which enemy are within a certain range - you need to cycle through all the enemy units to find which is nearest. Heres a quick example:

First set a a trigger covering the entire map area. Make it East Present, and in the On Activation field put: eastlist = thislist. This creates the array of units you will check.

Next run your script.


;inrange.sqs
#start
;set the minimum distance
_distance = 100
;set the parameter to control the loop
_i = (count eastlist) - 1
;check that there are still units in the east list
? _i < 0 : hint "All east units are dead"; exit

#loop
~0.1
;cycle through all available units
_unit = eastlist select _i
;check if the unit is in range
? _unit distance man < _distance : _victim = _unit; _distance = _unit distance man
;get the next unit
_i = _i - 1
? _i >= 0 : goto "loop"

?_distance < 100 : [_victim] exec "your_next_script.sqs"
goto "start"


At the end of each loop the script executes a secondary script using the closest east unit, if that unit is within range.
There may be an easier way of doing it, but this is the method I use.

Cheers  :)
 
« Last Edit: 16 Dec 2002, 12:01:58 by Bremmer »

Offline LCD

  • Former Staff
  • ****
    • Everon Cartel
Re:name closest east unit help
« Reply #9 on: 16 Dec 2002, 11:31:53 »
dat wat i gave him  ::)

LCD OUT
"guess being the community has downsides .." - cheetah
Help Perfecting Da Next Best Thing - O-Team Beta