I want to try to make a crpl script that has the unit take damage from anti-creeper but so far I've only managed the unit to take damage by creeper or both anti-creeper and creeper.
# Test.crpl
# Created on: 4/20/2014 1:57:50 AM
# ------------------------------------------
once
	SetUnitAttribute(Self CONST_HEALTH 100.0)
	SetUnitAttribute(Self CONST_HEALRATE 0.0)
endonce
0.0 ->CreeperTotal
CurrentCoords ->myX ->myY
<-myX 4 add <-myX 3 sub do
	<-myY 4 add <-myY 3 sub do
		I J GetCreeper 0.0 gt if
			<-CreeperTotal 1 add ->CreeperTotal
		endif
	loop
loop
Self <-CreeperTotal 64.0 div Damage
Any clue what I've done wrong or what I'm missing?
			
			
			
				Anti-creeper has negative creeper values. So instead of checking if the creeper is more than 0, you should check for creeper less than 0 (or use '0.0 I J GetCreeper sub' before you check if it's greater than 0).
			
			
			
				Thanks and i don't know why i didn't notice the greater than.
			
			
			
				A note, the order should be CurrentCoords ->myY ->myX
Y is pushed second, which means by the rules of a stack you have to store it first.
			
			
			
				Quote from: kwinse on April 20, 2014, 10:56:50 AM
A note, the order should be CurrentCoords ->myY ->myX
Y is pushed second, which means by the rules of a stack you have to store it first.
Along that line, you also need to either 1) do the Y loop on the outside and the X loop inside the Y loop, or 2) call 
J I GetCreeper to get the order right, as I is always the inner most loop counter, not the first loop counter.
The code as-is seems to work because you've got the X values in myY and the Y values in myX, so it effectively is running the Y loop on the outside with the reversed names, in a double-reversal when you get to the GetCreeper call (I contains the current value of the myY loop, which is based on the 'X' component...)