Knuckle Cracker

Creeper World 4 => Making Maps, Units, and Scripts => Topic started by: thetroll527 on June 30, 2021, 12:11:11 PM

Title: Completed Player Unit
Post by: thetroll527 on June 30, 2021, 12:11:11 PM
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.
Title: Re: Completed Player Unit
Post by: Karsten75 on June 30, 2021, 12:37:10 PM
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
Title: Re: Completed Player Unit
Post by: thetroll527 on June 30, 2021, 12:54:47 PM
What I am trying to do is just have some completed miners, guns and factory. 
Title: Re: Completed Player Unit
Post by: Karsten75 on June 30, 2021, 02:06:41 PM
oh!. Click Ctrl-end while pointing (not selecting) a unit. it's in the Circled "I" popup on the editor pane.

(https://i.imgur.com/TDhmTf6.png)
Title: Re: Completed Player Unit
Post by: thetroll527 on June 30, 2021, 02:52:07 PM
Thanks a bunch, no idea why I didn't see that.

Title: Re: Completed Player Unit
Post by: The Apocalyptic on April 13, 2022, 04:53:51 PM
What about filling a completed unit with ammo, if it uses any.
Title: Re: Completed Player Unit
Post by: 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.

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:

(https://i.imgur.com/rAWkolH.png)
Title: Re: Completed Player Unit
Post by: Builder17 on April 14, 2022, 10:01:27 AM
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
Title: Re: Completed Player Unit
Post by: The Apocalyptic on April 14, 2022, 01:00:35 PM
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?
Title: Re: Completed Player Unit
Post by: Builder17 on April 14, 2022, 02:13:01 PM
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. :)
Title: Re: Completed Player Unit
Post by: Vertu on April 14, 2022, 02:58:23 PM
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.
Title: Re: Completed Player Unit
Post by: The Apocalyptic on April 15, 2022, 03:17:09 PM
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.
Title: Re: Completed Player Unit
Post by: The Apocalyptic on April 15, 2022, 03:33:20 PM
What if the units are prebuilt?

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