Author Topic: Emiter that produces more creeper overtime, but has delay between emits?  (Read 114 times)

StardustAlpha

  • Newbie
  • *
  • Posts: 3
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]:
Code: [Select]
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.
« Last Edit: November 27, 2017, 07:43:36 pm by StardustAlpha »

GoodMorning

  • Map Maker
  • *****
  • Posts: 3031
  • (Pusillanimous)
Re: Emiter that produces more creeper overtime, but delay between emits?
« Reply #1 on: November 27, 2017, 07:53:19 pm »
Here's something to perform the functional elements:

Code: [Select]
$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

  • Newbie
  • *
  • Posts: 3
Re: Emiter that produces more creeper overtime, but has delay between emits?
« Reply #2 on: November 27, 2017, 09:50:55 pm »
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

  • Map Maker
  • *****
  • Posts: 3031
  • (Pusillanimous)
Re: Emiter that produces more creeper overtime, but has delay between emits?
« Reply #3 on: November 27, 2017, 10:32:50 pm »
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:
Code: [Select]
<-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.