Knuckle Cracker

Creeper World 3 => The Coder's Corner => Topic started by: Sorrontis on July 25, 2015, 12:37:36 AM

Title: RPL newbie needs help
Post by: Sorrontis on July 25, 2015, 12:37:36 AM
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!
Title: Re: RPL newbie needs help
Post by: 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 (http://knucklecracker.com/wiki/doku.php?id=crpl:crplreference) 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.
Title: Re: RPL newbie needs help
Post by: Sorrontis on July 25, 2015, 08:48:51 AM
thank you! I'll look into the references to go from what you give me.
Title: Re: RPL newbie needs help
Post by: Sorrontis on July 27, 2015, 02:40:47 PM
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 (http://knucklecracker.com/wiki/doku.php?id=crpl:crplreference) 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
Title: Re: RPL newbie needs help
Post by: Lost in Nowhere on July 27, 2015, 02:43:13 PM
In order for a script to run, it needs to be attached to a CRPL core.
Title: Re: RPL newbie needs help
Post by: Sorrontis on July 27, 2015, 02:46:52 PM
thank you. I know I was missing something! Can cores be destroyed to stop the effects?
Title: Re: RPL newbie needs help
Post by: warren on July 27, 2015, 05:42:49 PM
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.
Title: Re: RPL newbie needs help
Post by: Sorrontis on July 30, 2015, 01:32:47 PM
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!
Title: Re: RPL newbie needs help
Post by: warren on July 30, 2015, 03:39:09 PM
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.
Title: Re: RPL newbie needs help
Post by: Sorrontis on July 30, 2015, 03:42:41 PM
thanks warren... stupid question, but how do you extract stuff from missions?
Title: Re: RPL newbie needs help
Post by: warren on July 30, 2015, 03:47:47 PM
http://knucklecracker.com/wiki/doku.php?id=crpl:examine_map_resources (http://knucklecracker.com/wiki/doku.php?id=crpl:examine_map_resources).

The profile of this information should probably be raised on the wiki.
Title: Re: RPL newbie needs help
Post by: Sorrontis on July 30, 2015, 04:11:02 PM
thanks! that will make my life easier!
Title: Re: RPL newbie needs help
Post by: Grayzzur on July 31, 2015, 09:57:14 AM
Quote from: warren on July 30, 2015, 03:47:47 PM
http://knucklecracker.com/wiki/doku.php?id=crpl:examine_map_resources (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!
Title: Re: RPL newbie needs help
Post by: Sorrontis on July 31, 2015, 10:26:02 AM
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 (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.