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: allow remote deployment of place_monster items, throwable manhacks #4174

Merged
merged 2 commits into from Feb 7, 2024

Conversation

chaosvolt
Copy link
Member

@chaosvolt chaosvolt commented Jan 28, 2024

Purpose of change

This is a thing that @Lorith had requested support for way back in 2018 (CleverRaven/Cataclysm-DDA#26418). The issue got closed for "DDA doesn't care about fixing janky behavior if only mods will benefit from it" reasons, but it's not that hard to envision a perfectly vanilla use case for this.

Describe the solution

C++ changes:

  1. In iuse_actor.cpp, set place_monster_iuse::use so that place_monster items with place_randomly set to true will use the item's position instead of the players. This allows for monster-spawning items that activate when thrown, instant monster spawns using drop_action, etc without them instead automatically spawning next to the player. Failure to place also unsets the item as active to prevent !!FUN!! involving explosively infinite spawns of a manhack that tried and failed to spawn after being thrown (as ACT_ON_RANGED_HIT sets the item in question to count as active). Lastly, thanks to Shard/Lorith deployment by being thrown doesn't consume additional moves.

JSON changes:

  1. Gave all inactive manhacks/bombhacks the ACT_ON_RANGED_HIT flags, allowing you to yeet them for remote deployment (useful for tossing from behind cover as a distraction, for example).
  2. Audited the weights of all inactive hacks to be not much higher than the weight of all components. This increases throwing range a bit for most, for example a strength-8 character can now toss a standard manhack 3 tiles instead of 2.
  3. Additionally added flags to eyebots and set their action to place randomly, and reduced their size a bit. Weight now includes the weight of original components plus a security camera and 1 sheet metal, while volume reduced down to 20 liters (slightly above the audited volume of a mininuke hack). It's still a lot more than most characters could reasonably throw, but does put it more in reach for mutant characters.
  4. Accordingly, updated recipe and uncraft for eyebots to use/yield a security camera and 24 small metal sheets.
  5. Updated weights and volumes for broken hacks/eyebots accordingly.

Describe alternatives you've considered

Not adding throwable manhacks and only adding the code support.

Testing

  1. Checked affected JSON files for syntax and lint errors.
  2. Compiled and load-tested.
  3. Chucked a manhack 3 tiles away from me, it correctly deploys on the tile it was thrown to and not next to me (though it's still close enough that it immediately moved over to me due to spawning hostile).
  4. Chucked it even farther away with more strength to confirm it still spawns away from me and not next to me.
  5. Chucked a manhack at a debug monster, it spawns next to the monster as expected.
  6. Chucked it while surrounded by debug monsters, confirmed that it prints the relevant message and drops the manhack as an item on the tile next to me.
  7. Debug-killed the debug monsters, confirmed no infinite death swarm of manhacks appears like what happened in my very first test of this.
  8. Checked affected C++ file for syntax and lint errors.

Additional context

55chrizgbe661

I'd like to also allow it to support having ALLOWS_REMOTE_USE too, but right now that causes an error if activated from within inventory. If we can figure out how to fix that then we can allow for not requiring you to pick up the heavier bots when deploying them.

Checklist

@github-actions github-actions bot added src PR changes related to source code. data PRs related to datas. Won't crash game (probably) labels Jan 28, 2024
@chaosvolt
Copy link
Member Author

Hmm. Getting a problem when activating from within inventory:

 DEBUG    : Tried to find where of an item without a location

 FUNCTION : where
 FILE     : C:\Users\Vincent\Documents\GitHub\Cataclysm-BN\src\item.cpp
 LINE     : 10273
 VERSION  : BN d9ebeade9d4d-dirty

@chaosvolt
Copy link
Member Author

Found it, cause was from giving the manhacks the ALLOWS_REMOTE_USE flag.

Copy link
Member

@scarf005 scarf005 left a comment

Choose a reason for hiding this comment

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

commenting code good

@chaosvolt chaosvolt merged commit f8261df into cataclysmbnteam:main Feb 7, 2024
12 checks passed
@chaosvolt chaosvolt deleted the yeet-the-child branch February 7, 2024 04:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
data PRs related to datas. Won't crash game (probably) src PR changes related to source code.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants