A crpl request (possibly simple)

Started by MrJellyLiker, December 09, 2017, 06:05:38 AM

Previous topic - Next topic

MrJellyLiker

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?

kajacx

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 and this 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:

  • Find a way to test if the unit is connected. I don't know if that is possible, but I'm not an expert on CRPL.
  • Accept 1 energy packet and generate 11 energy in return. Not a perfect solution, but it would work.
  • Manually scan for nearby colletors, relays and command centers and compute the connection manually.

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. 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.
Why do work yourself, when you can write a program that will do the work for you.

MrJellyLiker


GoodMorning

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.
A narrative is a lightly-marked path to another reality.

Builder17

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.

MrJellyLiker

No worries, ill make void bordering them :D
And there will be no spores at all.

kajacx

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.
Why do work yourself, when you can write a program that will do the work for you.

Builder17

#7
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.