(all answered) Clean0nion's CRPL problems

Started by Clean0nion, November 07, 2013, 03:10:57 PM

Previous topic - Next topic

Clean0nion

Timer issue solved by Grazzur and eduran:
Spoiler
So I have a code, and here it is:
$payload:10
$sporeHealth:10

SetTimer0(300)
if(GetTimer0 eq0)
    @GetUnitTypeCount("REACTOR") ->reactorCount
do(<-reactorCount 2 pow 0)
CurrentCoords RandUnitCoords <-sporeHealth <-payload CreateSpore
loop
endif

:GetUnitTypeCount
->unitType
0 ->count
do (GetUnitCountInRange(0 0 9999) 0)
->unitUID
if(GetUnitType(<-unitUID) eq(<-unitType))
<-count add(1) ->count
endif
loop
<-count


That was pasted directly from Wordpad.
The code is supposed to do this:
- measure the number of reactors on the map
- fire spores that is the number of reactors squared
[close]

Invincible Spore problem solved by eduran:
Spoiler
My problem: spores released from the CRPLcore are indestructible - except by beamers on power zones.
Here is my current code:
$payload:10
$sporeHealth:0.1

once
SetTimer0(1800)
endonce

if(GetTimer0 eq0)
    @GetUnitTypeCount("REACTOR") ->reactorCount
do(<-reactorCount 2 pow 0)
CurrentCoords RandUnitCoords <-sporeHealth <-payload CreateSpore
loop
SetTimer0(1800)
endif

:GetUnitTypeCount
->unitType
0 ->count
do (GetUnitsInRange(0 0 9999) 0)
->unitUID
if(GetUnitType(<-unitUID) eq(<-unitType))
<-count add(1) ->count
endif
loop
<-count


Can anyone provide any assistance with this?
Any help is greatly appreciated.
[close]

eduran

Your code resets Timer0 to 300 at the start of each frame, which means the if statement never triggers. Try:
$payload:10
$sporeHealth:10
$interval:300
$initialDelay:300
once
SetTimer0(<-initialDelay)
endonce
if(GetTimer0 eq0)
        SetTimer0(<-300)
        @GetUnitTypeCount("REACTOR") ->reactorCount
do(<-reactorCount 2 pow 0)
CurrentCoords RandUnitCoords <-sporeHealth <-payload CreateSpore
loop
endif

:GetUnitTypeCount
->unitType
0 ->count
do (GetUnitCountInRange(0 0 9999) 0)
->unitUID
if(GetUnitType(<-unitUID) eq(<-unitType))
<-count add(1) ->count
endif
loop
<-count

Grayzzur

For starters, you need to set the timer once and then wait for it to expire. you're resetting it every update cycle. Use the "once" block to set it initially, then set it again inside your loop that does the "GetTimer0 eq0".

Also, you want GetUnitsInRange, not GetUnitCountInRange.


once
SetTimer0(300)
endonce

if(GetTimer0 eq0)
     @GetUnitTypeCount("REACTOR") ->reactorCount
do(<-reactorCount 2 pow 0)
CurrentCoords RandUnitCoords <-sporeHealth <-payload CreateSpore
loop
SetTimer0(300)
endif

:GetUnitTypeCount
->unitType
0 ->count
do (GetUnitsInRange(0 0 9999) 0)
->unitUID
if(GetUnitType(<-unitUID) eq(<-unitType))
<-count add(1) ->count
endif
loop
<-count

"Fate. It protects fools, little children, and ships named 'Enterprise.'" -William T. Riker

Clean0nion

#3
Quote from: Grayzzur on November 07, 2013, 04:15:22 PM
For starters, you need to set the timer once and then wait for it to expire. you're resetting it every update cycle. Use the "once" block to set it initially, then set it again inside your loop that does the "GetTimer0 eq0".

Also, you want GetUnitsInRange, not GetUnitCountInRange.


once, endonce, endif, :GetUnits and stuff, codey code code


My God. It works. Thank you sir, thank you so much. May my signature apply to you for the rest of your days.
(and thanks to you, too, eduran)

Grayzzur

"Fate. It protects fools, little children, and ships named 'Enterprise.'" -William T. Riker

Clean0nion

#5
Quote from: Grayzzur on November 07, 2013, 05:01:32 PM
I fear the map you are making. :)
It's pretty much done now, thanks to you. I just need to test the rest of it and make sure it doesn't become tedious like most maps do.

EDIT: Oh no! The spores are invincible! Better change that.

Grayzzur

What are you setting the Spore Health at when you create the Spore? I think 1.0 (one) is your average game spore.
"Fate. It protects fools, little children, and ships named 'Enterprise.'" -William T. Riker

Lost in Nowhere

I'm going to make a wild guess and say you switched the spore payload and the spore health.
Don't die! :)

Clean0nion

#8
Currently the health is 0.1. I'll swap the payload and health, see what that does. Can't believe I didn't think of that before asking for help.
UPDATE: Both values at 0.1. Still invincible.

eduran

Do beams target the spores and they don't die? Or are they not getting shot at in the first place?

Clean0nion

Quote from: eduran on November 08, 2013, 04:58:12 AM
Do beams target the spores and they don't die? Or are they not getting shot at in the first place?
Beams target the spores and expend all ammo uselessly upon them. The one Beam I have on a power zone is capable of destroying spores, but only destroys one before its ammo runs out.

eduran

You are using the script Grayzzur posted earlier? If so, are you sure you set sporeHealth to 1 or less? Variable names are case sensitive. The script does work for me.

Clean0nion

Quote from: eduran on November 08, 2013, 05:20:17 AM
You are using the script Grayzzur posted earlier? If so, are you sure you set sporeHealth to 1 or less? Variable names are case sensitive. The script does work for me.

Just solved it. I had the variables set to 10 in the UI.
Feeling stupid now.
Thanks for your help.