Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Power Armor Overhaul #1505

Merged
merged 62 commits into from
Jul 6, 2022

Conversation

KheirFerrum
Copy link
Collaborator

@KheirFerrum KheirFerrum commented May 2, 2022

Summary

SUMMARY: Infrastructure? "Full overhaul of Power Armour system"

Purpose of change

Power Armour effects are all currently hardcoded, and the way it works right now is fairly undeveloped. This PR is essentially a full overhaul of how Power Armour is stored, transforms, and it's effects. There will also be content additions along with this.

As a side effect optical cloaks which also use the ups_based_armor activation have also been changed to function using transforms.

Describe the solution

The goal is a gradual deprecation of the power_armor bool in the json, and rewrite the system so that modular attachments can be applied to power armour. It will also attempt to convert most of the effects of the power_armor bool (like climate control, power armour interface, etc) into JSON flags, as many of these effects can already be replicated with little effort.

Some effects will be added to Power Armour as well, mainly a carry weight modification so that the average joe isn't overburdened by basic power armour.

List of current plans and completed ideas follow.

  • Turn Power Armour and Helmets from it's current weird active state into a transformable item. Apply separate tags to transformed items, like encumbrance, climate control, etc.
  • Deprecate the ups_based_armor activation effect and the power_armour bool. Side effect, will also update all other items that use ups_based_armor effects.
  • Make new flags that will help differentiate the exoskeleton, helmet, and other activatable peripherals.
  • Write new code to allow Activation of the main exoskeleton to transform both the exoskeleton and specific activatable peripherals worn. As externals do not use power, code for them to deactivate when not carried/worn.
  • Code so that Power Armor Interfaces cause power armor exoskeletons, externals and mods to draw directly from Bionic power, multiplying the power draw and charges per use by a factor inherent to the Bionic Power Interface.
  • Integrate holsters and sheaths from PA_Utilities mod by @darktoes and @DanteTorn (pending permission).
  • Add those peripherals to itemgroups and the like.
  • Code so that peripherals have a max number per body part (Went with 2, 3 on the torso to accommodate the hauling frame.)
  • Bugtest/Bugfix (As you may/may not imagine this is going to break shit, my hope is that when it is merged it won't)
  • Finish the mod updates for Kenan's modpack and various other popular mods that use the PA system.

Describe alternatives you've considered

Removal of the Power Armour Interface and rigging it so that it just draws from UPS instead (at rebalanced rate).

  • Could be done, but I have some plans for how the Power Armour Interface will work with modular additions. Also, it somewhat gatekeeps the practical use of Power Armour (to little gain, for now, this is part of the rework) Still, it's an idea.

Testing

  • Spawn in power armour, test that it can be worn and draws power appropriately.
  • Test that the on version can be turned on, taken off, and dropped without segfaults
    Apparently I didn't consider that carrier could be null, fixed.
  • Test that peripherals cannot be stacked to insane amounts, check that peripherals can be worn with all power armour, etc.

Additional context

Oh, I also reordered the power_armor.json because finding where everything was placed gave me a headache.

Currently completed implementations are:

  • Power draw, it will either draw from UPS, or be charged by the PA Interface Bionic.
  • Encumbrance for activated variants has been altered to be similar to original hardcode, with some caveats (Hauling Frames have 5 Encumbrance.)
  • Flags POWERARMOR_EXO, POWERARMOR_EXTERNAL and POWERARMOR_MOD applied to appropriate items. EXTERNALS cannot be worn on parts with EXO, this is to allow ease of conversion for mods like Secronom, which has biological power armour exoskeletons that cover the entire body. This will also allow us to easily split the Exoskeleton into arms/legs later if it's deemed appropriate (though I'm not personally fond of the idea).
  • Modify Carry Weight effects were added to activated variants of power armour, so now when activated PA will carry it's own weight.
  • ups_based_armor action torn out, replaced with set_transform and set_transformed. Meant to be an extensible iuse action for use with more than just power armour, but currently only applies to worn items.
  • Rewrote the wear code, so now you can wear rings while wearing power armour instead of having to take off PA, wear the ring, then wear PA again. This applies to all 0 coverage items.

Future things to do. [Note: Remember to link the PRs of future fixes to this so that this set of PRs is easy to follow.]

  • Update exoskeletons and hauling frames to have holsters/sheaths of their own. Add relic data to PA so that it will provide bonuses to stats when activated.
  • Add more peripherals, including night-vision/infrared, motors to improve strength and/or speed, wrist mounted minilaunchers, and whatever else I can think of, is allowed, and don't die coding.
  • Overhaul process_tool to use energy units instead of integers. Will need to untangle from other use_charge functions as those need to be in integers, which probably means new functions but could also mean that templates are needed.
  • Update the itemgroups so that power armour, high tech gear, and power armour mods aren't almost impossible to find.

@KheirFerrum KheirFerrum changed the title Power Armor Overhaul pt.1 Power Armor Overhaul May 2, 2022
@KheirFerrum KheirFerrum force-pushed the Power-Armour-Overhaul branch from 2dcd51b to b49bc65 Compare May 3, 2022 04:48
@KheirFerrum KheirFerrum force-pushed the Power-Armour-Overhaul branch from b49bc65 to 2bca562 Compare May 3, 2022 04:48
Basic helmets didn't transform, Heavy Helmet transformed into Heavy Exoskeleton, crashing the game.
Changed some of the text and flavour.

Introduced new power armour flags and integrated UPS drain into them. power_armor tag deprecated.

Removed the final vestiges of ups_based_armor.

Rewrote the power armour can_wear process.
return true;
if( elem.has_flag( flag_POWERARMOR_EXO ) ) {
result = true;
if( hasHelmet == nullptr ) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated to the PR itself, but this bool *hasHelmet is a terrible practice. Nowadays we'd return a struct or pair and not bother early exiting a loop over worn items because worn items vector is small.

Copy link
Collaborator Author

@KheirFerrum KheirFerrum May 15, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure how this should be fixed to be honest, C++ is still fairly arcane to me.

src/item.cpp Outdated Show resolved Hide resolved
src/item.cpp Outdated
@@ -9203,16 +9284,46 @@ bool item::process_tool( player *carrier, const tripoint &pos )
energy -= ammo_consume( energy, pos );

// for items in player possession if insufficient charges within tool try UPS
if( carrier && has_flag( flag_USE_UPS ) ) {
if( carrier && ( has_flag( flag_USE_UPS ) || ( is_power_armor() ) ) ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we just make power armor use UPS and make it processed like any other UPS tool here? Switching off doesn't seem to be something specific for power armor.

Copy link
Collaborator Author

@KheirFerrum KheirFerrum Jun 13, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand your meaning, this is my method of having the power armour use ups charges without having the (UPS) suffix and an incorrect description that the device has been "modified to run off a universal power supply" since that is it's default state.

It is thus processed exactly like a UPS tool assuming the power armour interface is not installed/activated.

Copy link
Member

@Coolthulhu Coolthulhu Jul 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather have the incorrect description, since many items have it as well. It looks like we may need to change the description, but for power armors, it should be consistent with other UPS items, even if the description is currently not perfect.

Copy link
Collaborator Author

@KheirFerrum KheirFerrum Jul 3, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just think it's really ugly, and I already folded the UPS description/function into the POWERARMOR_EXO/EXTERNAL/MOD flags alongside the Bionic Armour Interface. But if this is considered necessary I guess I can change that.

I'd also have to rewrite the use_charges and has_enough_charges function, which will be a bit of a pain due to how they are. It's hard to see a situation where we'd want power armour to run off the interface but not UPS.

It does make sense that only active tools are processed here.
src/visitable.cpp Outdated Show resolved Hide resolved
@KheirFerrum KheirFerrum force-pushed the Power-Armour-Overhaul branch from f83576e to a2b2c9d Compare July 3, 2022 04:27
I don't actually know if this is the appropriate way to add a description line.
@KheirFerrum
Copy link
Collaborator Author

KheirFerrum commented Jul 3, 2022

There's a check to make power armour with the USE_UPS flag not have (UPS) appended to it. This is mainly a taste issue. I just don't like it to appear as "power armor basic (active) (UPS)". If you would prefer such a thing, then I can remove the check.

All the groundwork was already laid by previous contributors, just needed to remove the hardcode check.
Turns out I don't really need to make new functions to make set_transform(ed) work.
To silence (UPS) suffix
So that the description outright tells players it's more efficient than using UPS.
Also . , just irks me
@KheirFerrum KheirFerrum force-pushed the Power-Armour-Overhaul branch from 6b373a6 to 8e32ba6 Compare July 5, 2022 05:59
@Coolthulhu Coolthulhu merged commit 707ae43 into cataclysmbnteam:upload Jul 6, 2022
@Coolthulhu
Copy link
Member

Pre-existing and very minor bug: if you destroy worn power armor, you can keep the helmet on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants