Knuckle Cracker

Creeper World 3 => The Coder's Corner => Topic started by: MrJellyLiker on December 09, 2017, 06:05:38 AM

Title: A crpl request (possibly simple)
Post by: MrJellyLiker on December 09, 2017, 06:05:38 AM
Hello guys, i wanna have a unit which generates you 10 energy when connected to a CC(just like 2 reactors in power zones)

Here is what it must do
-cant be destroyed by any method
-connects to other buildings
-generates 10 energy for you when connected to a building which is connected to a CC (through buildings or directly)

Can you guys do it?
Title: Re: A crpl request (possibly simple)
Post by: kajacx on December 09, 2017, 08:30:12 AM
Quote from: MrJellyLiker on December 09, 2017, 06:05:38 AM
Can you guys do it?

No, the question is can you do it? You already started well by subdividing the problem into 3 easier subproblems, so let's take a look at them individually. I must warn you though, It was a long time sice I used CRPL, I am making scripts for PF in PRPL now only, so take what I say with a grain of salt.

this (https://knucklecracker.com/wiki/doku.php?id=crpl:docs:setunitattribute) and this (https://knucklecracker.com/wiki/doku.php?id=crpl:docs:getunitattribute#unit_constants) will be your best friends.

1) cant be destroyed by any method
This should be easy, set CONST_NULLIFIERDAMAGES to 0 so it isn't destroyable by nullifier, CONST_COUNTSFORVICTORY to 0 so that you can actually win the game and CONST_SUPPORTSDIGITALIS to 0 so it doesn't grow digitalis. Other settings should be fine with default value.

2)connects to other buildings
You can set CONST_CONNECTABLE to 1, but I don't if there is a way to test if the connection exist, this is probably ment for units that consume packets to be able to receive them. I can see 3 possible options:

Both 2nd and 3rd option have their pros and cons, I would probably choose the 2nd option with a acceptiong energy packets and producing more energy in return.

3)
I must say, I can't find a way to add energy. Not saying it's impossible, just I don't see anything on the wiki (https://knucklecracker.com/wiki/doku.php?id=crpl:crplreference). I would try creating a symphon over an energy crysal underneatch the unit, and chaning the neregy left in the cristal or wheter on not the syphon is active. You could then use SetUnitSelectableOverride on the symphon to make it unselectable by the player. Not an optimal solution but hey, better than nothing.
Title: Re: A crpl request (possibly simple)
Post by: MrJellyLiker on December 09, 2017, 10:13:50 AM
Thanks for the help :)
Title: Re: A crpl request (possibly simple)
Post by: GoodMorning on December 09, 2017, 05:44:39 PM
You can use that, or use SetUnitSelectableOverride Reactors.

Reactors are 0.4 energy, or 4 with a PZ. So 25 Reactors will do it. Leave the Reactors under the unit, and the game will take care of connecting for you.
Title: Re: A crpl request (possibly simple)
Post by: Builder17 on December 10, 2017, 12:10:36 AM
Quote from: GoodMorning on December 09, 2017, 05:44:39 PM
You can use that, or use SetUnitSelectableOverride Reactors.

Reactors are 0.4 energy, or 4 with a PZ. So 25 Reactors will do it. Leave the Reactors under the unit, and the game will take care of connecting for you.

There is only one problem in this. :)

-Cannot be destroyed by any method.
Title: Re: A crpl request (possibly simple)
Post by: MrJellyLiker on December 11, 2017, 11:35:38 AM
No worries, ill make void bordering them :D
And there will be no spores at all.
Title: Re: A crpl request (possibly simple)
Post by: kajacx on December 11, 2017, 11:40:00 AM
Quote from: MrJellyLiker on December 11, 2017, 11:35:38 AM
No worries, ill make void bordering them :D
And there will be no spores at all.

Good idea, however I would recommend puting the void directly underneath the reactors, you could even mask the fact that there is void by the custom unit's image. Aslo I'm pretty sure you could scan for nearby spores and destroy them if they get too close, or just explode them pre-maturely or something like that if you would like to have spores.
Title: Re: A crpl request (possibly simple)
Post by: Builder17 on December 11, 2017, 01:30:36 PM
Quote from: kajacx on December 11, 2017, 11:40:00 AM

Also I'm pretty sure you could scan for nearby spores and destroy them if they get too close, or just explode them pre-maturely or something like that if you would like to have spores.
Vanilla spores don't have unit ID. That's probably not possible. :(

Quote from: kajacx on December 11, 2017, 11:40:00 AM
Quote from: MrJellyLiker on December 11, 2017, 11:35:38 AM
No worries, ill make void bordering them :D
And there will be no spores at all.
Good idea, however I would recommend putting the void directly underneath the reactors

This sounds good plan.