CRPL code goals

Started by Jallun, July 26, 2014, 06:11:04 PM

Previous topic - Next topic

Jallun

1) Where collecting a certain tech artifact will instantly complete the map, regardless of the status of any emitters/spore towers.
2) A CRPL Core that will fire a bolt like the Bertha that is countered by Snipers.

What code(s) will fill these?

ParkourPenguin

1) Where collecting a certain tech artifact will instantly complete the map, regardless of the status of any emitters/spore towers.
Try looking into the utility command DestroyAllEnemyUnits. Unfortunately, it doesn't have a wiki page, so I have no idea how it works or what it does, but it sounds like it'll destroy all units that count for victory. If it doesn't, just get all the UIDs on the map via GetAllUnitsInRange, filter out which ones have the attribute CONST_COUNTSFORVICTORY as true by using GetUnitAttribute, and destroy all of those with the Destroy command. I think that should cause you to win the map.

2) A CRPL Core that will fire a bolt like the Bertha that is countered by Snipers.
Virgil made a gun script a while back on his blog post Chimera. I've attached both of the scripts he used below. To get the projectiles to be targeted by snipers, just set CONST_SNIPERTARGET to true and mess around with CONST_HEALTH / CONST_MAXHEALTH in the bullet script.
"Only a life lived for others is a life worthwhile."
-Albert Einstein

knucracker

DestroyAllEnemyUnits looks like it will destroy all units that are set as something a Nullifier will fire at.

Jallun

#3
Quote from: ParkourPenguin on July 27, 2014, 12:25:39 PM2) A CRPL Core that will fire a bolt like the Bertha that is countered by Snipers.
Virgil made a gun script a while back on his blog post Chimera. I've attached both of the scripts he used below. To get the projectiles to be targeted by snipers, just set CONST_SNIPERTARGET to true and mess around with CONST_HEALTH / CONST_MAXHEALTH in the bullet script.

For this one in particular, I set the Sniper target thing against the CRBullet so the sniper will shoot down the shots?

ParkourPenguin

Quote from: Jallun on July 28, 2014, 05:31:31 PM
For this one in particular, I set the Sniper target thing against the CRBullet so the sniper will shoot down the shots?

Yup. You can do everything that I previously mentioned by adding the following lines of code into the once...endonce block of CRBullet.crpl:
SetUnitAttribute(Self CONST_SNIPERTARGET TRUE)
SetUnitAttribute(Self CONST_SNIPERIGNORELOS TRUE)
SetUnitAttribute(Self CONST_MAXHEALTH 20)
SetUnitAttribute(Self CONST_HEALTH 20)


Each shot from the sniper deals 20 damage, I believe (please correct me if I'm wrong).

I also added one thing: by setting CONST_SNIPERIGNORELOS to true, snipers don't care whether or not their target is in their line of sight. This is useful if their target is suppose to be flying through the air, like a bullet.
"Only a life lived for others is a life worthwhile."
-Albert Einstein

Jallun

#5
Quote from: ParkourPenguin on July 28, 2014, 06:31:37 PM
Quote from: Jallun on July 28, 2014, 05:31:31 PM
For this one in particular, I set the Sniper target thing against the CRBullet so the sniper will shoot down the shots?

Yup. You can do everything that I previously mentioned by adding the following lines of code into the once...endonce block of CRBullet.crpl:
SetUnitAttribute(Self CONST_SNIPERTARGET TRUE)
SetUnitAttribute(Self CONST_SNIPERIGNORELOS TRUE)
SetUnitAttribute(Self CONST_MAXHEALTH 20)
SetUnitAttribute(Self CONST_HEALTH 20)


Each shot from the sniper deals 20 damage, I believe (please correct me if I'm wrong).

I also added one thing: by setting CONST_SNIPERIGNORELOS to true, snipers don't care whether or not their target is in their line of sight. This is useful if their target is suppose to be flying through the air, like a bullet.

Alright, and another thing: how to modify the interval of the shots and their range?

Edit: How does a crpl file get imported?

ParkourPenguin

#6
Quote from: Jallun on July 28, 2014, 06:57:24 PM
Alright, and another thing: how to modify the interval of the shots and their range?

Edit: How does a crpl file get imported?

How to import CRPL files:
If you already have a CRPL file, all you need to do is to move it to the "scripts" folder where your world is saved in the world editor. For me on windows, it's located at C:\Users\ParkourPenguin\Documents\creeperworld3\WorldEditor. Here, all the maps in the world editor are saved, including all the scripts for these maps.

Locate which world you want to import the script(s) to, open that folder, then there should be a folder in there called "scripts". Just move the .crpl files into that folder.

After that, get back into the world editor in Creeper World 3. In edit mode, select the "Unit" tab, and click on the blue "Scripts" button near the right. Then, just click on "Compile All" near the bottom of the thing that pops up, and the scripts should be ready to be added to CRPL cores.

How to modify the interval of the shots and their range:
The range should be easy. Once you build a CRPL core and add the CRGun script to it, just select the script's name from the box directly below where you added it, and a second box labeled "Input Variables" should pop up right below it. Here, you can modify the range of it.

However, the interval of the shots is a bit harder, since I don't believe Virgil made that an input variable. However, it's possible to modify the script and make it an input variable. I've attached a slightly modified version of Virgil's script that does this to this post. I added an input variable called "interval" that dictates how many frames it should wait before firing again. 30 frames is 1 second, so by default (60 frames), it will wait 2 seconds.


I hope this helped! Please don't hesitate to ask if you have any more questions!
"Only a life lived for others is a life worthwhile."
-Albert Einstein

Jallun

#7
Quote from: ParkourPenguin on July 28, 2014, 07:50:28 PM
How to modify the interval of the shots and their range:
The range should be easy. Once you build a CRPL core and add the CRGun script to it, just select the script's name from the box directly below where you added it, and a second box labeled "Input Variables" should pop up right below it. Here, you can modify the range of it.

How is the range measured (Metres, Yards etc.)? Also, it appears I cannot type into that box.

Lost in Nowhere

The range is measured in tiles, which don't have any specific conversion to real-world sizes; if you need one, just choose one that works.
Don't die! :)

Asbestos

You have to select one of the scripts and then modify the variables below the box.

ParkourPenguin

Quote from: Jallun on July 28, 2014, 08:22:09 PM
How is the range measured (Metres, Yards etc.)? Also, it appears I cannot type into that box.

As Lost in Nowhere stated, the radius is measured in tiles. Tiles is probably the most common unit of distance in CW3; however, pixels is also used in some commands.

Also, which box are you talking about? I attached an image below detailing the process if it helps out at all.
"Only a life lived for others is a life worthwhile."
-Albert Einstein

Jallun

Quote from: ParkourPenguin on July 28, 2014, 10:53:01 PM
Quote from: Jallun on July 28, 2014, 08:22:09 PM
How is the range measured (Metres, Yards etc.)? Also, it appears I cannot type into that box.

As Lost in Nowhere stated, the radius is measured in tiles. Tiles is probably the most common unit of distance in CW3; however, pixels is also used in some commands.

Also, which box are you talking about? I attached an image below detailing the process if it helps out at all.

I got the gun to work after remembering to import the two CR scripts, though as separate CRPL cores. Now to make the gun effect do two things:
1) Refresh every 3 minutes
2) Only start firing upon building of at least 2 Snipers or a long wait of 10 minutes.

Since right now, it fires upon the map starting and a CN isn't even imprinted onto the map at that point.

ParkourPenguin

Quote from: Jallun on July 28, 2014, 11:19:16 PM
I got the gun to work after remembering to import the two CR scripts, though as separate CRPL cores. Now to make the gun effect do two things:
1) Refresh every 3 minutes
2) Only start firing upon building of at least 2 Snipers or a long wait of 10 minutes.

Since right now, it fires upon the map starting and a CN isn't even imprinted onto the map at that point.

Don't attach the CRBullet script to any CRPL core. The CRGun script will automatically make use of the CRBullet script itself. Just having the CRBullet script compiled is enough.

1) If you mean you want it to fire every 3 minutes, then set the interval to the equivalent number of frames. 3 minutes = 180 seconds = 5400 frames. Therefore, the input variable "interval" should be set to 5400.

2) I've updated the CRGun script with both of these features implemented. I wasn't able to test this, as it's pretty late where I'm at right now, so if there are any bugs, let us know, and someone will fix it. It's attached to the previous post with only CRGun.crpl attached; click here to download it.
"Only a life lived for others is a life worthwhile."
-Albert Einstein

Jallun

Quote from: ParkourPenguin on July 29, 2014, 12:05:45 AM
2) I've updated the CRGun script with both of these features implemented. I wasn't able to test this, as it's pretty late where I'm at right now, so if there are any bugs, let us know, and someone will fix it. It's attached to the previous post with only CRGun.crpl attached; click here to download it.

I've found that while the gun does aim correctly to the closest target, it does not fire regardless of what I do. I've built ~8 Snipers and 1.5 hours into the map and no shot whatsoever.

ParkourPenguin

Quote from: Jallun on July 29, 2014, 08:51:54 AM
I've found that while the gun does aim correctly to the closest target, it does not fire regardless of what I do. I've built ~8 Snipers and 1.5 hours into the map and no shot whatsoever.

I did some testing, and it seems to work perfectly as intended. I can't seem to replicate what happened to you. Could you list step-by-step everything you do, including the values of all the input variables? That would help me determine what's causing that problem.
"Only a life lived for others is a life worthwhile."
-Albert Einstein