HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

nearest unit action

08-26-2002, 08:44 PM#1
ChronOmega
is there a action that says oreder unit to devour nearest unit?

i dont mind using custom text if you tell me what to put there
08-27-2002, 01:09 AM#2
Guest
There isn't a "nearest unit" function. What exactly are you trying to accomplish? Could it be solved by using event: Unit within Range?
08-27-2002, 02:30 AM#3
ChronOmega
its for my hungry hungry kodos map im trying to make it so when a kodo enters a regionx it will be ordered to devour the nearest target in regionx

note im using regionx as an example


also does anyone know the rate at which devour damages a unit?

p.s. ill try unit in range
08-27-2002, 05:52 AM#4
Guest
you could make a complicated trigger that will search for ANY units in range 100, then range 150, range 200 etc
08-27-2002, 06:08 AM#5
Guest
As I said before there is no "closest unit" function, but you can check units with range. I made a simple map to test this idea. Basically you need just 2 triggers and 2 variables.

Variables:
(unit) ClosestPeon
(real) PeonRange

Trigger: (PeonMuncher)
Event: Unit enters Region X
Condition: (Entering unit) Equals Kodo Beast X
Actions:
Set ClosestPeon = No Unit
Set PeonRange = 128
For each (Integer A) from 1 to 10, do (Trigger - Run PeonInRange) (CHECKING Conditions)
If (ClosestPeon = No Unit) then do (skip remaining actions) else (do nothing)
Unit - Order Kodo Beast X to Orc Kodo Beast - Devour ClosestPeon



and...




Trigger: (PeonInRange)
Event: None
Condition: ClosestPeon Equal to No Unit
Actions:
Unit Group - Pick every unit in (Units in Region X matching ((Distance between (Position of Kodo Beast X) and (Position of (Matching Unit))) Less than or equal to PeonRange)) And do (Set ClosestPeon = (Picked Unit))
If (ClosestPeon Equal to No Unit) then do (Set PeonRange = (PeonRange + 128.0)) else do (Do nothin
08-27-2002, 08:54 PM#6
ChronOmega
i cant seem to find the
Quote:
((Distance between (Position of Kodo Beast X) and (Position of (Matching Unit))

part could you point me to it?
08-27-2002, 09:05 PM#7
Guest
I'd say this..
Trigger1
-order the unit to attack move to a location
(that way it will attack the closest unit)

Trigger2
-when the unit is attacking, order the unit to devour the (attacked unit))

this way the unit will chose the closest unit to attack, and when it attacks the unit, it will devour it.
08-27-2002, 09:08 PM#8
ChronOmega
have you tred this? :confused: id rather stick to Aschweepe's method since i know it works
08-27-2002, 10:01 PM#9
Guest
quote:
--------------------------------------------------------------------------------

((Distance between (Position of Kodo Beast X) and (Position of (Matching Unit))

--------------------------------------------------------------------------------


Look under "real comparison" and Math-distance between two points
08-27-2002, 10:07 PM#10
Guest
If ya need ill post the test map i made...
08-27-2002, 11:49 PM#11
Guest
pseudocode:
variables:
p_point <- parameter var
r_unit <- return var

trigger1:
actions:
set min=9999
pick all units in whole map and do run trigger2

trigger2:
conditions:
distance between p_point and location(picked unit)<min
actions:
set min=temp
set r_unit=picket unit

After running trigger1 with parameter p_point, r_unit becomes the nearest unit to p_point.
08-28-2002, 12:16 AM#12
ChronOmega
actuly ive thought of another way too do it without varibles and one trigger with very long actions and im etting it up to see if it works