-
Notifications
You must be signed in to change notification settings - Fork 454
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
Projectiles deal damage to breakable blocks #2357
Conversation
@niamu I think there is a better way to handle this, projectiles used to damage breakable blocks before the collision update so there should be a fix that doesn't use the new collision system. |
Merged your commit @CalebJohn, but after trying this branch with only your changes not on top of mine, the collisions aren't as reliable. I don't think this should be merged with both of our commits on this branch. I admit your change is cleaner, it just has reliability problems. It should only take 3 throwing knives to destroy the breakable block in the forest level. It takes several for me with your change alone. |
@niamu I think this can be improved by shrinking the size of the projectile when used for hitting walls, I can try writing up a better fix tomorrow. I'm just not a huge fan of using the collision tile to work backwards to find the node. |
Totally get your objection to working backwards to finding the node that we are colliding with. It is very ugly. I like it only because it's proven to be reliable in my tests. I'd welcome any cleaner fix you can come up with that matches reliability. |
Thanks to @CalebJohn, this is now much cleaner and reliable now. LGTM. |
@@ -222,7 +223,7 @@ function module.move_x(map, player, x, y, width, height, dx, dy) | |||
|
|||
if new_x <= tile_x and tile_x <= x then | |||
if player.wall_pushback then | |||
player:wall_pushback() | |||
player:wall_pushback(tile) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only reason we pass tile
as an argument here is to return on the function before it runs. I think it's cleaner to move that condition up here before we even call that function. Thoughts?
@niamu We only ignore the function call in projectile.lua, this is because we want projectiles to ignore breakable blocks but anything else (e.g. the player) should not be ignoring the block so those specific functions wouldn't quit. |
@CalebJohn, thanks for clarifying that. This is as clean as it gets then. |
Projectiles deal damage to breakable blocks
One thing I noticed from watching some YouTubers play (thanks to @edisonout for providing a link to get me started down this path) is that one of the first things players do is craft throwing knives in the forest and then accidentally shoot them at the breakable blocks and realize that they don't do any damage.
After investigating the code, I realize that this wasn't intentional and have spent the last several hours working out a fix. Yes, it's stupid ugly. If you can come up with a cleaner fix, I'd love to see it.
This gets the job done and makes breakable blocks feel a bit better to interact with.