HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Detecting unit's movement

02-16-2004, 02:24 AM#1
Pesmerga
How would I detect when a unit is moving?

Event : Every 1 seconds of game time

Condition : ???

Action : Set Points = Points - 1


Ideas please.

Edit : If thats not possible, then is there a way to detect when a unit is NOT moving or has stopped?
02-16-2004, 02:37 AM#2
ObsidianTitan
I created a simple trigger that will check to see if the unit has moved. set it to initially off so it doesn't trigger before you want it to (it will think the unit moved if on from the start)

move check
Events
Time - Every 1.00 seconds of game time
Conditions
Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
((Region centered at unitloc with size (5.00, 5.00)) contains unit) Equal to True
Then - Actions
Do nothing
Else - Actions
-------- Actions because has moved --------(enter whatever here)
Set unitloc = (Position of unit)

and this next one i made just to show how to get it not to trigger till you want it to.

Turn on move check
Events
Time - Elapsed game time is 5.00 seconds
Conditions
Actions
Trigger - Turn on move check <gen>
Set unitloc = (Position of unit)
02-16-2004, 02:46 AM#3
Pesmerga
Ahh nice idea, thanks. I'll try that immediately.

Eh heh, nooby question : Where can I find that condition under? Real? Or Boolean?
02-16-2004, 02:59 AM#4
ObsidianTitan
((Region centered at unitloc with size (5.00, 5.00)) contains unit) Equal to True
is found under Boolean
02-16-2004, 04:36 AM#5
Dalten
You could also(easiest imo) use the X of Unit and Y of Unit too.

1) Store the current location of the unit into Variables X1 and Y1
2) Check to see if X1 and Y1 match exactly with x2 and y2
if x2 = 0 then x2 = X1; and if y2 = 0 then y2= y1. Or Predefine what they're supposed to be with where they already are in map initialization or something.
3) Store X coord of Unit into X2 and Y coord of Unit into Y2.

You could do the above in several ways, I'm actually doing something similar in my adventure map i'm making.

edit: maybe not the easiest, but the most precise by far.
02-16-2004, 08:49 AM#6
Cubasis
Erhm,

Dalten.... your method is pretty much what ObsidianTitan suggested.... although i would use a "Point" instead of X/Y ...

heh, cause Points' precision == XY precision ... why? becouse points are just a co-ordinate from a XY value... The way you create a point in jass is: Location( X, Y )

I'm just not sure if you can do a "Point" condition (which sucks imo).


However... This method you're all suggesting is what I have used since RoC days... but I think there is a new better method to sense if a unit is moving .... to just compare the "Current Order" of a unit to move, patrol or whatever... it may be messy, and there may be tons of problems with it, but it might work.

Anyhow

Cubasis