<-CW3 Home <-CRPL Home <-Interacive tutorials
Here I'll show you how to create your custom emitter. What will it have:
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):
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.
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.
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
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.
If you would like to force a PZ to appear or perhaps not to appear, that is done easily with the following snippet:
Self CONST_CREATEPZ FALSE SetUnitAttribute
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.
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!
:destroyed CurrentCoords <-DeathAmt AddCreeper
Simply add this code to the file to add Digitalis support
if(CurrentCoords GetDigitalis eq0 CurrentCoords GetDigitalisGrowth 1 eq eq) CurrentCoords 1 SetDigitalis endif
If there is any DigitalisGrowth (The white Digitalis-like stuff that shows where it will grow) under the core, Digitalis will grow.