making new units to use?

Started by Azraile, May 21, 2014, 01:57:02 AM

Previous topic - Next topic

Azraile

Can you add new units to be buit by the player besides the main ones?

or replace units that are there already with ones you make?


Just wondering because I was considering adding an arch-battery and ad an AC silo ...  so they could store exess power and AC.... and if needed used as a weapon (by letting them be destroyed).... though the batery would be kinda dangurious

Relli

I'll be honest, I'm working on this exact problem right now. There's no easy commands to have a unit be considered a player's unit, but if you're decent with code, you can make it work. One of the biggest parts of this is SetUnitAttribute. CRPLCores by default are assumed to be meanies, so they do things like Count for Victory, Support Digitalis, and can be Nullified. These can all be turned off, and a few useful ones turned on instead, like ability to connect to collectors/relays/CNs, being able to request packets, setting them to require being built before use, and so on.
From there, other features can be added on manually. I've set up my units so they take damage in Creeper like normal player units, which I could share here if you wanted. It's probably pretty rough, but it works. And then there's whatever you want the unit to actually do.

I hope some of this helps, and if you have any further questions, I'd love to assist.

Annonymus

Adding buttons on the GUI is impossible, but everything else is quite easy and it's even possible to add buttons on the left of the GUI.
To replace them automatically just scan the entire map for unit X, destroy all of them and place customunit Y where they were.
Interactivity might be a bit tricky but I think planetfall did a great job on that.
For what you want it's even easier, just add 2 buttons besides the GUI, when clicked place core (with script attached) on the location of the next click, make them request packets and register what gets sent to it, then add a button on the unit to "free" the energy/ore or place it in a siphon as soon as it arrives so you can free the button for making it stop requesting.
In the :destroyed function add the bomb.
If a topic started by me is in the wrong place feel free to move it at anytime.

Grayzzur


http://knucklecracker.com/forums/index.php?topic=14650.0

In an attempt to recreate some CW1 units, I've worked partially on some of those issues. The Drones I've made basically auto-replace any Strafers you try to build. Interactivity isn't too bad, as the pad is a stationary unit and you only need to give the air unit a target cell to bomb. Still, a lot of the code was just in doing the selected item and targetting animations.

For the map with the CW1 SAM Launchers, you'll see I've co-opted the Beams. All the interactivity there is just a Beam being hijacked. My custom unit saps energy from the Beam, and as there are no "real" spores on the map (those are custom CRPL units, too), the Beam never has anything to fire at by itself.

So, with a little creativity, you can work around the limitations. Those two maps and their code should help point you in the right direction.

As a reminder, if you want to pull the code and resources from any cool map you see, you can: http://knucklecracker.com/wiki/doku.php?id=crpl:examine_map_resources.
"Fate. It protects fools, little children, and ships named 'Enterprise.'" -William T. Riker

Clean0nion

Quote from: Annonymus on May 21, 2014, 10:20:27 AM
Adding buttons on the GUI is impossible.
:EnableAlternateControlMode

Annonymus

Quote from: Clean0nion on May 21, 2014, 01:28:04 PM
Quote from: Annonymus on May 21, 2014, 10:20:27 AM
Adding buttons on the GUI is impossible.
:EnableAlternateControlMode
true, but then you have to re-integrate as CRPL the existing GUI, which probaly isn't worth it.
If a topic started by me is in the wrong place feel free to move it at anytime.

stewbasic

Quote from: Annonymus on May 22, 2014, 02:10:20 PM
Quote from: Clean0nion on May 21, 2014, 01:28:04 PM
Quote from: Annonymus on May 21, 2014, 10:20:27 AM
Adding buttons on the GUI is impossible.
:EnableAlternateControlMode
true, but then you have to re-integrate as CRPL the existing GUI, which probaly isn't worth it.
It is impossible if you want both custom and regular units. If you use EnableAlternateControlMode and make your own GUI, you can't change things like pulse cannon targeting. If you keep the inbuilt GUI you can't detect clicks on it.

Annonymus

Quote from: stewbasic on May 22, 2014, 07:17:12 PM
It is impossible if you want both custom and regular units. If you use EnableAlternateControlMode and make your own GUI, you can't change things like pulse cannon targeting. If you keep the inbuilt GUI you can't detect clicks on it.
At least part of these problems could be solved by re-creating the basic units as CRPL, but, like I said, that's quite a bit of work to be done and probably there would still be some things that you couldn't make. (Guppies and command nodes, probably)
If a topic started by me is in the wrong place feel free to move it at anytime.