How Does One Make Custom Units?

Started by SssirCreepersss, October 29, 2015, 07:51:42 PM

Previous topic - Next topic

SssirCreepersss

I have a WIP map that needs custom units for a NPC base holding out and needs to be reached in time.  I need NPC units that defend the base by default without the player able to adjust/move those units, of which those units should be damageable and repairable with a core that provides for them.  If the player reaches the core via connection in time, they will be rewarded resources and the characters will discuss a data disk placed under the core.  If the core is destroyed, those resources will be removed (only the disk of data will remain) and the characters will show disappointment, but the game won't end.  The units I have mentioned I want to have different skins than the units used by the player, if not simply recolored in some way.  As of now, I think I want to make these kinds of NPC units:

Reskinned NPC Sprayer
Reskinned NPC Mortar
Reskinned NPC Siphon
Reskinned NPC Beam
Reskinned NPC Relay
A type of bunker-base unit to gather and deploy provided resources to units listed above.

I have been given sources and advice from a few people, but I can't find out what I need to do to do this.  If you have a good step by step example I would love to know it.  Let me know if you need any more info about the units and what I want them to be like.  Thank you fellas.

Nicant

#1
That sounds like a huge project, i'll try a make some of the units for you!  :) But keep in mind that i have a life and im not a crpl genius so you won't get them all instantly! I will do the Relay! I'll try my best but if i can't, then i'll let you know!
I'm sorry, I am not that experienced with code, so unfortunately i wasn't able to make any of the units. What you are asking is beyond my limits.  :( but i hope one day i could.
CW4 hype!!

SssirCreepersss

I am very thankful that you tried.  I hope the community stays this friendly.   :)  (like most games with no PVP or server interaction at all)

warren

If you can live without reskins or recolors, this is actually a really easy project. You can create your mortars and blasters, then lock them. Then you can hide a couple guppies under a custom graphic of your base unit. You can use CRPL to control the supply of ammo and AC.

Creating even a single custom unit just for the reskin is harder than all of that. (you can of course put a semi-transparent image overtop each of your custom units.)

SssirCreepersss

#4
Sounds like a great idea.  However, I still am rusty with CRPL cores and I don't know how to "lock" units.

warren

#5
SetUnitSelectableOverride. I believe this persists across saves, so you only have to do it once, and you can even delete the core with the script afterwards.

A freezer can probably be written as follows:


CurrentCoords 0 TRUE GetAllUnitsInRange do
  FALSE SetUnitSelectableOverride
loop

awake:
  TRUE OperateWhilePaused


In order to use this, you would need to put this core on the unit(s) you want to freeze, exit editing mode, then reenter editing mode. Delete afterwards.

If it works, you will not be able to interact with the targeted units outside of editing mode. (so set them to target digitalis first if desired.)

Setting up guppies to act like a base will be harder. You can copy the script I used in the first Battle castle as a starting point.

  <-target CONST_AMMO dup2 GetUnitAttribute
  20 30.0 div add SetUnitAttribute

:awake
once
  CurrentCoords 0 TRUE GetAllUnitsInRange 0 do
    dup GetUnitType "GUPPYAIR" eq if
      ->target
    else
      pop
    endif
  loop
endonce

You will also need to freeze the guppies, but do so after moving them from their bases and setting them to store ac/ore if desired.
(once they are moved off their bases you can move them around in the editor if needed.)

If this script works, it adds ammo to the guppy over time.

Hubs

There are alot of corrupted units maps that you could probably pull from. I think all of those units have been re-created with crpl in various map. Search for "corrupted" in colonial space and you should get lots of examples.