Emiter that produces more creeper overtime, but has delay between emits?

Started by StardustAlpha, November 27, 2017, 07:40:39 PM

Previous topic - Next topic

StardustAlpha

I'm making a tower defence-ish map and would like to make some sort of wave system [creeper appears, wait some time, more creeper appears, ect].
Detailed list of what I would like to happen [not actual code]:
Wait 120 seconds[with timer counting down]
set {variable} to 5
INFINITE-LOOP[
Add {variable} creeper
increase {variable} by 2.5
show {variable} onscreen in the upper left
wait 20 seconds[with timer counting down]
]

I dont know how to use CRPL. If someone could script this, that would be awesome!
I have attached the map that I am making [save.cw3] and a screenshot [map.png].
NOTE: The timer written in terrain is just there for showing where the timer would probably go. Timer does not need to be made of terrain.

GoodMorning

Here's something to perform the functional elements:


$StartDelay:3600 #120 seconds, at 30 frames per second
$BaseAmt:5.0
$Increment:2.5
$Interval:600 #Frames

once
    GetGameTimeFrames <-StartDelay add ->Init
    <-Init <-Interval add ->NextEmit
    <-BaseAmt ->Amt
endonce

GetGameTimeFrames <-Init lt if
    return
endif

GetGameTimeFrames <-NextEmit gte if
    CurrentCoords <-Amt AddCreeper #With the kind of numbers you're talking about, this is safe-ish.
    #Consider SetCreeperNoLower in future
   
    <-Amt <-Increment add ->Amt
    <-NextEmit <-Interval add ->NextEmit
endif


As to the display code for the timers, I encourage you to attempt it yourself. You seem to have a good grasp of the structure required for code-writing, and the reference (https://knucklecracker.com/wiki/doku.php?id=crpl:crplreference) should contain all the commands you need.

If you have trouble, feel free to ask about whatever problem you are having.
A narrative is a lightly-marked path to another reality.

StardustAlpha

I've figured out how to show the amount it emits, but not the time until the next emit. What is the name of the variable you used for the time until the next emit?

GoodMorning

The "time until" is never calculated here. I have used "NextEmit" for the time of the next emit.

To get the time until, you would use:

<-NextEmit GetGameTimeFrames sub


Using some invented numbers:
"Emit at time: 455" "Current time: 342"
Time until emit: 455 - 342 = 113 frames, which is a little less than four seconds.
A narrative is a lightly-marked path to another reality.