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

feat: flag for items NPCs will use in combat. #1704

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

KheirFerrum
Copy link
Collaborator

@KheirFerrum KheirFerrum commented Jul 7, 2022

Summary

SUMMARY: Features "Adds flag for items that NPCs will activate in combat."

Purpose of change

As a follow up #1505, make power armour and similar items usable by NPCs during combat.

Describe the solution

Modifies 52259 to function for most simple iuse actions, mainly transform and set_transform. The inclusion of chainsaws and chainsaw lajatangs will need a follow up PR that converts their iuse into iuse_actors for ease of use.

Canning the port, it's not going to do what I need it to do. New plan follows:

  • Make iuse_transform::can_use actually account for all pre-requisites, if it returns true, then it can be used, no ifs, no buts, no niche requirements or bullshit.
  • Make NPC weapon compare code account for transformed versions of wielded/unwielded items. Exclude guns for now, since things like the compound bow get weird due to cycling and strength requirements.
  • Have NPCs transform worn armour if it has a target flag (there is no function that compares the value of an armour, and I'm not going to code one for this PR, since it'll likely get complicated as we factor in encumbrance and coverage.
  • Have NPCs deactivate worn armour/weapons if they consume power when combat ends.

Describe alternatives you've considered

  • Set up a modular system to allow players to dynamically designate what items to use.
    Not the worst idea, but this current system suffices. In the future we will need somewhat more intelligent usage of items by NPCs so that NPC enemies will be more threatening with equipment. (Optically cloaked bandits anyone?)

Testing

  • Give an NPC the extendable baton, a power armour exoskeleton and helmet. Gave the NPC a UPS. Spawned a Debug Monster. Checked that NPC activated their equipment. Let it wail on the creature for a bit, then killed the Debug Monster, checked that all items returned to inactivated form.

Additional context

Unactivated Power Armour is encumbering, very heavy, and very warm, fortunately, NPCs do not suffer from stamina issues, heat issues, and encumbrance disappears when it's activated in combat.

I will need to make 2 follow up PRs to this.

  • Chainsaw iuse_actor creation. To allow for Combat Chainsaws and similar to function with this code.
  • NPC Bionics Update, to allow NPCs to use Bionic UPS and Bionic Armor Interfaces.

@KheirFerrum
Copy link
Collaborator Author

I'm trying to think of further things to develop here and coming up blank. None of the things I'd like are strictly a part of this PR and would be better served with follow up PRs (like the chainsaw and Bionic UPS/Interface)

@KheirFerrum KheirFerrum marked this pull request as ready for review July 8, 2022 06:26
src/npcmove.cpp Outdated Show resolved Hide resolved
@Coolthulhu Coolthulhu self-assigned this Jul 9, 2022
"id": "NPC_COMBAT_ITEM",
"type": "json_flag",
"context": [ ],
"info": "A <good>follower</good> will attempt to <info>use</info> this item in combat."
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure if it needs an info block like this.

Copy link
Member

Choose a reason for hiding this comment

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

I assume info block would make more sense if that were to more clearly imply activating it.

Copy link
Collaborator Author

@KheirFerrum KheirFerrum Jul 11, 2022

Choose a reason for hiding this comment

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

That makes sense, I can change it. Due to the way the flags are this is being slowly rolled out, so marking items that NPC's will activate and will not activate is important in my view

@@ -116,7 +116,7 @@
"symbol": "/",
"material": [ "aluminum" ],
"techniques": [ "WBLOCK_1", "RAPID" ],
"flags": [ "DURABLE_MELEE", "BELT_CLIP" ],
"flags": [ "DURABLE_MELEE", "BELT_CLIP", "NPC_COMBAT_ITEM" ],
Copy link
Member

Choose a reason for hiding this comment

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

I don't like how it's on both active and inactive variants. If I give a NPC an extended baton, I want them to use an extended baton. In fact, it may be hard to get the NPC to equip a collapsed one.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

So a problem with making them check for the active variant is that the iuse can_use for transforms doesn't cover all requirements, so for some requirements like need_charges the NPC will not know it can't be used until they actually use them, and if an NPC fails it's silent because of the way the messages are printed.

@Coolthulhu
Copy link
Member

My NPC started flipping the baton on and off during the fight when given the extended variant.

src/npc.h Outdated
/*
* Perform any cleanup upon no more present danger, such as disabling combat CBMs or items.
*/
void cleanup_on_no_danger();
Copy link
Member

Choose a reason for hiding this comment

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

I know the whole block above is full of methods, but they'd be better off as separate functions.
Consider a distant future when a player can let the AI control the character. If all the functionality is in npc methods, it will be harder and more hacky, but if it's all separate functions, it could be as easy as changing the npc argument to player (or even Character) one.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm not sure what protocol is for this, would I need to move the functions or shift them around in npc.h?

@KheirFerrum
Copy link
Collaborator Author

KheirFerrum commented Jul 10, 2022

My NPC started flipping the baton on and off during the fight when given the extended variant.

Gah, of course, I forgot it only counts active. If I want to make the baton work I'll need two flags, one to activate and one to deactivate.

@Coolthulhu
Copy link
Member

If I want to make the baton work I'll need two flags, one to activate and one to deactivate.

Or to compare their stats rather than using flags.
Or to remove the flag from batons and only keep it on active stuff.

@Coolthulhu Coolthulhu removed their assignment Jul 23, 2022
@KheirFerrum KheirFerrum marked this pull request as draft July 28, 2022 18:13
@KheirFerrum
Copy link
Collaborator Author

Here is the point I'm restarting it from scratch, old version just doesn't work for what I need it to do.

@KheirFerrum KheirFerrum reopened this Mar 26, 2023
@github-actions github-actions bot added the src changes related to source code. label Mar 26, 2023
Move all iuse_transform can use checks into iuse_transform::can_use
@scarf005 scarf005 changed the title Adds flag for items NPCs will use in combat. feat: flag for items NPCs will use in combat. Nov 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
src changes related to source code.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants