Knuckle Cracker

Creeper World 3 => The Coder's Corner => Topic started by: Clean0nion on November 07, 2013, 03:10:57 PM

Title: (all answered) Clean0nion's CRPL problems
Post by: Clean0nion on November 07, 2013, 03:10:57 PM
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]
Title: Re: Why won't this code work?
Post by: eduran on November 07, 2013, 04:06:14 PM
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
Title: Re: Why won't this code work?
Post by: 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
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

Title: Re: Why won't this code work?
Post by: Clean0nion on November 07, 2013, 04:57:46 PM
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)
Title: Re: (answered) Why won't this code work?
Post by: Grayzzur on November 07, 2013, 05:01:32 PM
I fear the map you are making. :)
Title: Re: (answered) Why won't this code work?
Post by: Clean0nion on November 07, 2013, 05:07:15 PM
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.
Title: Re: Why are the spores from a CRPLcore invincible?
Post by: Grayzzur on November 07, 2013, 06:57:25 PM
What are you setting the Spore Health at when you create the Spore? I think 1.0 (one) is your average game spore.
Title: Re: Why are the spores from a CRPLcore invincible?
Post by: Lost in Nowhere on November 07, 2013, 07:52:15 PM
I'm going to make a wild guess and say you switched the spore payload and the spore health.
Title: Re: Why are the spores from a CRPLcore invincible?
Post by: Clean0nion on November 08, 2013, 04:37:00 AM
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.
Title: Re: (unanswered) Why are the spores from a CRPLcore invincible?
Post by: 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?
Title: Re: (unanswered) Why are the spores from a CRPLcore invincible?
Post by: Clean0nion on November 08, 2013, 05:04:39 AM
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.
Title: Re: (unanswered) Why are the spores from a CRPLcore invincible?
Post by: 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.
Title: Re: (unanswered) Why are the spores from a CRPLcore invincible?
Post by: Clean0nion on November 08, 2013, 05:51:59 AM
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.