RPL newbie needs help

Started by Sorrontis, July 25, 2015, 12:37:36 AM

Previous topic - Next topic

Sorrontis

Hello everyone!

I've been making my own maps for a bit, and I'd like to incorporate some code. I just don't know RPL. This is what I'm looking to do. It's really simple really (in Python anyways).

After 5 minutes of game time, a random spot on the map (200 x 200) is targeted by a mass driver.
At the impact site, some (50 units) anti creeper is spawned.
This repeats every minute until victory is achieved or defeat is accepted.

I would be grateful for the help with the code above.

If you're really not busy :) this would be nice too, but I'm not going to push my luck.
Optional: a target 5 seconds before impact
Optional: count down timer.


Thanks!
"If you want others to be happy, practice compassion. If you want to be happy, practice compassion."

warren

#1
This is probably a ten line script. The commands needed for everything but the timing are: RandCoords, FireAOO, SetImage, AddCreeper, SetText.

some math would be needed for the timer, and some math to format the count down clock. The crpl reference contains details on each command.

edit:
The timer. Scripts execute once every game frame. (1\30 of a second) But variables persist. A normal timer is probably a bad idea given that we wish a complicated time related behaviour. but we can make one:
<-time 1 add ->time
then test against it:
<-time 50 gt if ... endif

For formatting the time remaining, use concat to join your strings together.

Sorrontis

thank you! I'll look into the references to go from what you give me.
"If you want others to be happy, practice compassion. If you want to be happy, practice compassion."

Sorrontis

Spoiler
Quote from: warren on July 25, 2015, 05:43:17 AM
This is probably a ten line script. The commands needed for everything but the timing are: RandCoords, FireAOO, SetImage, AddCreeper, SetText.

some math would be needed for the timer, and some math to format the count down clock. The crpl reference contains details on each command.

edit:
The timer. Scripts execute once every game frame. (1\30 of a second) But variables persist. A normal timer is probably a bad idea given that we wish a complicated time related behaviour. but we can make one:
<-time 1 add ->time
then test against it:
<-time 50 gt if ... endif

For formatting the time remaining, use concat to join your strings together.
[close]

okay, so I've tried to follow sometime like your code as a start, it compiles properly, but when I initialize the game, nothing happens. I wait up to one minute (should only be 10 secs).


once
0 ->time
endonce

<-time 1 add ->time

<-time 300 gt if
"MASS" 10 10 FireAoo
0 ->time
endif
"If you want others to be happy, practice compassion. If you want to be happy, practice compassion."

Lost in Nowhere

In order for a script to run, it needs to be attached to a CRPL core.
Don't die! :)

Sorrontis

thank you. I know I was missing something! Can cores be destroyed to stop the effects?
"If you want others to be happy, practice compassion. If you want to be happy, practice compassion."

warren

A core that is destroyed does not run any scripts anymore. however: If you destroy the core in its own script, a virtual return is added. This will interrupt the script, but only from the main function. It will merely return from a subfunction. If you destroy the core from another script, the scripts on that core will either all run that frame or not run at all that frame depending on the run order of the cores. Cores run scripts in series as this is a single threaded game.

Sorrontis

thanks for the help everyone, I got it to work. However, now I'm looking at making a target (like Bertha's) to appear 3 seconds before the hit. Where would I find that image (is there a command for it), or do I have to make a custom image?

Thanks!
"If you want others to be happy, practice compassion. If you want to be happy, practice compassion."

warren

There is already several suitable reticle images floating around, you can extract one from another mission, or download one from the internet. The only limitation is that it has to be 64x64, 128x128, or 256x256. You have to set it to a custom image slot, then use the setImage, setImageColor, setImageScale, and setImageRotation commands to get it to look how you want. It is probably easier to position the core where you want the image rather than to use setImagePosition.

Sorrontis

thanks warren... stupid question, but how do you extract stuff from missions?
"If you want others to be happy, practice compassion. If you want to be happy, practice compassion."

warren


Sorrontis

thanks! that will make my life easier!
"If you want others to be happy, practice compassion. If you want to be happy, practice compassion."

Grayzzur

Quote from: warren on July 30, 2015, 03:47:47 PM
http://knucklecracker.com/wiki/doku.php?id=crpl:examine_map_resources.

The profile of this information should probably be raised on the wiki.
I added links to that document on the Overview and Tutorial pages as well (it was already hiding on the Reference page). Hopefully that will cut down on that question a bit. If not, it may be time for an FAQ page!
"Fate. It protects fools, little children, and ships named 'Enterprise.'" -William T. Riker

Sorrontis

Quote from: Grayzzur on July 31, 2015, 09:57:14 AM
Spoiler
Quote from: warren on July 30, 2015, 03:47:47 PM
http://knucklecracker.com/wiki/doku.php?id=crpl:examine_map_resources.

The profile of this information should probably be raised on the wiki.
I added links to that document on the Overview and Tutorial pages as well (it was already hiding on the Reference page). Hopefully that will cut down on that question a bit. If not, it may be time for an
[close]
FAQ page!

Oh, that would be beautiful. Especially for those (like me) just starting to learn RPL.
"If you want others to be happy, practice compassion. If you want to be happy, practice compassion."