User Tools

Site Tools


<-CW3 Home <-CRPL Home <-Interacive tutorials

Creating a custom emitter

Here I'll show you how to create your custom emitter. What will it have:

  • Custom image (optional)
  • Show popup text
  • Leave something other than a PZ
  • Progressive output with limit
  • Support digitalis

I will also cover how to turn it into a slip emitter or flip emitter.
It won't (as that's not what an emitter should do, also remember the game should be fair to the player):

  • Create runners
  • Send spore
  • Create new emitters on death

Custom image

Let's start simple with a custom image. You can easily skip this step as the game has a special emitter image built-in. Go HERE or HERE, download the emitter, open the map, go to edit -> units -> custom images, go to 64×64 and select the downloaded emitter.
To attach the image to a crpl core, simply double-click it and select the correct image in the image dropdown menu.

Basic script framework

We want the script to be very portable, so instead of coding the values into the script, we'll use input variables. These will be Amt, Delay, AmtIncrease, AmtMax, DeathMode and DeathAmt.

Click to display ⇲

Click to hide ⇱


Note that “DeathAmt” holds a string instead of a number, the game will convert these into integers at runtime when possible

And as it is an emitter, simple code to make it emit Creeper.

# Emit the saved amount of Creeper at the specified coordinates,
# but only emit so much so that the creeper level is at least as much as 'Amt', but no more
CurrentCoords <-Amt SetCreeperNoLower
# Wait the specified amount of ticks before doing anything
<-Delay Delay

You probably need a good popup text to make sure people think it's a normal emitter. Simply add these 2 lines and you're done.

"Amt: " <-Amt concat "
" concat "Interval: " <-Delay 30.00 div 2 Round concat concat SetPopuptext

Leaving stuff behind

The hardest part probably, but the most important for huge maps, is to prevent power zone (PZ) spam.
This should be something the map maker should take care of himself and not be a problem you have to worry about. Though doing things on the destruction of our custom emitter isn't that hard.

Set PZ creation on death

If you would like to force a PZ to appear or perhaps not to appear, that is done easily with the following snippet:


Explaining in-depth what it does:
self: Get the current unit (the emitter we're creating);
CONST_CREATEPZ: A constant each CRPL core has, defines whether or not to create a PZ on death;
FALSE: Set the above constant to false, meaning this emitter won't drop a PZ on death (obviously can also be TRUE);
SetUnitAttribute: Set the defined constant of the defined unit to the defined value.

It's best not to force this constant in your code and leave the decision of whether or not to leave a PZ to the map maker. A map maker can choose whether or not to leave a PZ in the options of a CRPL code.
Leaving something else behind

In case you're not satisfied with just a simple PZ, you can do whatever you'd like on the unit's death by defining a function called destroyed.
This function is automatically called the moment the unit is destroyed.
Since we declared a variable called DeathAmt, lets release that much creeper upon death!

	CurrentCoords <-DeathAmt AddCreeper
Functions should always be at the end of your code. Read more about functions at the CRPL tutorial.

Progressive output

Negative increment


Click to display ⇲

Click to hide ⇱

What exactly is supposed to be put here? Progressive how? And why explain what a negative increment value would do?

I would assume increasing the creeper emission amount e.g.
if(<-Amt <-AmtMax neq)
	<-AmtIncrease 30.00 <-Delay div div <-Amt add ->Amt

Digitalis support

Simply add this code to the file to add Digitalis support

if(CurrentCoords GetDigitalis eq0 CurrentCoords GetDigitalisGrowth 1 eq eq)
	CurrentCoords 1 SetDigitalis

If there is any DigitalisGrowth (The white Digitalis-like stuff that shows where it will grow) under the core, Digitalis will grow.

Phantom/slip emitter

Flip emitter

crpl/crpltutorial/interactive/advancedemitter.txt · Last modified: 2018/05/16 16:28 by CatMan33