question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Discussion] Shoot hook rework proposal/ideas

See original GitHub issue

Description

This issue is related to ModPlayer.Shoot and ModItem/GlobalItem.Shoot and their behavior. Ill outline some of the issues of its current implementation and some proposed fixes.

Application Scope

Currently, both hooks are called in

else if (PlayerHooks.Shoot(this, item, ref vector, ref num70, ref num71, ref shoot, ref Damage, ref KnockBack)
	&& ItemLoader.Shoot(item, this, ref vector, ref num70, ref num71, ref shoot, ref Damage, ref KnockBack)) {

which is at the very end of the chain relevant for all projectile spawning from item use. A big number of valid shooting items (I would say about 50%, other modders agree with this number) won’t ever enter this part of the code, making the hook useless if you want to detect projectiles being shot from items in a guaranteed manner. (Vanilla code is still inconsistent as to where it spawns projectiles sometimes, so it won’t be able to cover 100% of items anyway, but even 80% is better than 50%)

Possible fix would be to add another hook with no return value that simply executes when an item was used to shoot a projectile (Possible overlap with UseItem (which is also a bit inconsistent because of item.useStyle logic, but that’s another topic)).

General Use

The hooks return value (bool) indicates if the game should proceed spawning the projectile with the given parameters or not. Modders use this hook to change the way projectiles are spawned, or just spawn new ones entirely. In combination with how the hooks are called (ModPlayer ones being split from the Item ones), this can cause shortcircuiting due to the &&.

Possible fix would be to split up the logic into CanShoot and Shoot hooks. As for the shortcircuiting, change it to & or combine it into one Loader method.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
Mirsariocommented, Jul 13, 2020

Possible fix would be to split up the logic into CanShoot and Shoot hooks.

Seems like the best solution to me.

0reactions
Jofairdencommented, Jul 14, 2020

but I bet someone wants to add custom firing logic, or extra projectiles, or something. That’s very common (example: shotgun)

What happens when someone wants to cancel vanilla logic, because they're handling it themselves, but some mods haven't had a chance to modify the the damage values? I guess that’d need to become a diff hook

Read more comments on GitHub >

github_iconTop Results From Across the Web

Roadhog Hook Changes - General Discussion
I am once again here to propose Role Based Interactions with Hog's Hook. In other words, Hooking a Tank produces a different effect...
Read more >
500+ TikTok Hooks: Ultimate List For Every Business ...
This will be a massive list of TikTok hook ideas that you can use in your videos. I wanted to include a list...
Read more >
30 Amazing Customer Service Training Ideas, Exercises & ...
Uncover the highest potential of your customer service team with these ideas, exercises, and topics for your next training program.
Read more >
The promise: The families of Sandy Hook and the long ...
In asking these questions, the families of Sandy Hook Promise began their transformation from deeply sympathetic victim-advocates into a force ...
Read more >
Introducing Hooks
Hooks allow you to reuse stateful logic without changing your component hierarchy. This makes it easy to share Hooks among many components or...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found