This isn't working

Started by ShadowDragon7015, May 28, 2013, 09:57:53 PM

Previous topic - Next topic

ShadowDragon7015

I'm trying to get this to work. It is supposed to wait for all other enemy units to die before it activates but it automatically activates at the moment can someone please help?

# Can't fight this.crpl
# Created on: 5/29/2013 10:46:25 PM
# ------------------------------------------
if
(GetEnemyUnitsInRange(0 0 9999)) eq 1
QueueMove(RandCoords 3)
SetCreeper (currentcoords 200)
delay(15)
endif
Hiding the golden creeper for years to come.

knucracker

You probably mean:
if ( GetEnemyUnitsInRange(0 0 9999) eq (1) )

You have the parenthesis messed up in your 'if'.

Withour parens it would be:
0 0 9999 GetEnemyUnitsInRange 1 eq if

ShadowDragon7015

Hiding the golden creeper for years to come.

knucracker

The condition probably is never true, then.
Put a trace inside the condition. (And a ShowTraceLog at the top of the script).

Aside from that, what you have in the condition doesn't really look 'healthy'.  You are going to call QueueMove twice a second whether your unit is already moving or not.  That will build up an ever growing list of movements.

Inside your outer 'if' that checks for enemy units, you want a nested 'if' that calls GetQueuedMoveCount.  Only of that is 0 do you want to queue a new move.

Lastly, why are you checking for enemy units equal to 1?  I don't know anything about your mission and what counts and enemy or not... but just trace the result of GetEnemyUnitsInRange and see what the number is.  It is probably either 0 or more than 1...

J

if he checks if there's only one enemy left, that means that is the core that is running that script.
if (GetEnemyUnitsInRange(0 0 9999) eq (1))
if (GetQueuedMoveCount eq (0))
 QueueMove(RandCoords 3)
 SetCreeper (currentcoords 200)
endif
endif
if you want to emit creeper twice a second instead of when it queues a new movement, use timing functions outside the GetQueuedMoveCount block of code
if (GetEnemyUnitsInRange(0 0 9999) eq (1))
if (GetQueuedMoveCount eq (0))
 QueueMove(RandCoords 3)
endif
GetTimer0 0 lte if
 SetCreeper (currentcoords 200)
 15 SetTimer0
endif
endif