Completed Player Unit

Started by thetroll527, June 30, 2021, 12:11:11 PM

Previous topic - Next topic

thetroll527

How can you create a completed player unit for map?

I want a disserted base with some old stuff left around, but I want them completed. 

Thanks.

Karsten75

You can either scavenge another map with units similar to the ones you want, or you can start here:
https://knucklecracker.com/wiki/doku.php?id=cw4:custom_units

thetroll527

What I am trying to do is just have some completed miners, guns and factory. 

Karsten75

oh!. Click Ctrl-end while pointing (not selecting) a unit. it's in the Circled "I" popup on the editor pane.



thetroll527

Thanks a bunch, no idea why I didn't see that.


The Apocalyptic

What about filling a completed unit with ammo, if it uses any.

Karsten75

Quote from: The Apocalyptic on April 13, 2022, 04:53:51 PM
What about filling a completed unit with ammo, if it uses any.

Wow, way to necro a post! :D

Anyway, when you create the unit, in its "Settings" tab, choose "weapon" sub-tab and then set all options rea ammo:


Builder17

Quote from: Karsten75 on April 13, 2022, 07:12:10 PM
Quote from: The Apocalyptic on April 13, 2022, 04:53:51 PM
What about filling a completed unit with ammo, if it uses any.

When you create the unit, in its "Settings" tab, choose "weapon" sub-tab and then set all options rea ammo

I think they mean creating a vanilla unit, like Cannon or Mortar with ammo in map editor, pretty sure this requires 4rpl commands GetUnitMaxAmmo and SetUnitAmmo

The Apocalyptic

Right, Builder17!

Also, thank you. That helps a lot. I also meant doing the same with modded units, though. Would that work the same way?

Builder17

Quote from: The Apocalyptic on April 14, 2022, 01:00:35 PM
I also meant doing the same with modded units, though. Would that work the same way?

Yes, but for modded units also check K75's message above mine's. :)

Vertu

Create a new console script, copy and paste the code into said script, close what ever you are using to edit/create the console script and save the changes.
Have the console opened before selecting units.
Select all the units you wish to be built and have full ammo.
Click "Run Once", or if you want to build every unit you select at any moment, just have it keep running. It will work perfectly fine when left running.
Every unit you select when the script runs will be constructed and given it's maximum ammo.

GetSelectedUnits ->units
if(GetListCount(<-units) gt0)
do(GetListCount(<-units) 0)
ConstructUnit(<-units[I] 10000)
SetUnitAmmo(<-units[I] GetUnitMaxAmmo(<-units[I]))
SetUnitHealth(<-units[I] GetUnitMaxHealth(<-units[I]))
loop
ClearTraceLog
Trace3("Fully built " GetListCount(<-units) " selected units.")
else
if(GetUnitUpdateCount lt(2))
Trace("No units where selected for building.")
else
if(GetUnitUpdateCount 10 % eq0)
ClearTraceLog
if(<-count eq0)
Trace("Operating. |")
1 ->count
else
if(<-count eq(1))
Trace("Operating. /")
2 ->count
else
if(<-count eq(2))
Trace("Operating. -")
3 ->count
else
Trace("Operating. \")
0 ->count
endif
endif
endif
endif
endif
endif

Since .4rpl files are not in the exportable file type white-list, I could not just give you the script directly.
Life isn't fair because we say it isn't. Not because it is unfair. In fact, it is so fair we want to say it isn't and do.

The Apocalyptic

Thanks, Vertu!

I did wind up making a manual version, though, because I also needed to adjust the position of a specific ONE of the units in the affected area.

The Apocalyptic

#12
What if the units are prebuilt?

Edit: Never mind. It just fills the ammo. Thanks again, Vertu!