items/mcl_bows: Let players shoot themselves with arrows #117
No reviewers
Labels
No Label
blocker
bug
code quality
confirmed
critical
discussion
high priority
incompatibility
incomplete feature
invalid
low priority
missing feauture
needs testing
packet spam
performance
project
regression
translations
unconfirmed
in review
ready for review
No Milestone
No project
No Assignees
3 Participants
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: Mineclonia/Mineclonia#117
Loading…
Reference in New Issue
No description provided.
Delete Branch "fix-arrow-selfshoot-3"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
TRACKING ISSUE: #113
Players can shoot themselves with bows in Minecraft and MineClone2.
Solution
6b1ce182d3
.Details
This PR right originally existed to figure out what the difference was between the solution that @cora made for players wanting to shooting themselves in PR #115 and the ones that @epCode made in MineClone2 commit
6b1ce182d3
. I have cherry-picked both of those and cleaned up the commits to remove unrelated changes and whitespace errors.I then fixed a bug inherited from MineClone that would cause a stack trace when the “Ding” hit sound was played for potion arrows. I also made it so that for both regular and potion arrows the game plays the hit sound only when hitting another player, and not oneself.
Testing Steps
World Preparation
9f086a9242
with mapgen v7 and seed “arrow”.Verify Bug (for future reference)
Verify Patch Part 1: Regular Arrows
Verify Patch Part 2: Enchanted Arrows
Verify Patch Part 3: Multiplayer
cf7a767958
to251fd414bc
251fd414bc
to330487fcc9
I think this code might be wrong in PR #112. After all,
self._in_player
is never set, so it will always benil
, so I would think PR #112 breaks the sound an arrow makes when it hits a player.330487fcc9
to6951ecdfc9
WIP: items/mcl_bows: Let players shoot themselves with regular arrowsto WIP: items/mcl_bows: Let players shoot themselves with arrowsAccording to https://yewtu.be/watch?v=F09qguaa41Y you do not get a hit sound when you hit yourself.
This is probably related to arrows sticking in player what @cora mentioned in PR #116.
I maintain that this code should be refactored as follows:
_time_in_air to
0 inon_activate
._time_in_air
usingdtime
inon_step
(so it represents seconds of flight).There is no reason for a variable representing elapsed time to start at 1.0 which makes code like
_time_in_air > 1.02
misleading._time_in_air
is not used anywhere else, fortunately:Assuming the ideal lag-free globalstep is 20 Hz, to get from 1 to 1.02 by adding 0.001 each globalstep takes about a second.
@ryvnf anything more? If not, I'll work on proper testing instructions.
That is almost certainly wrong, I think it needs to be
dtime_s
. Why should it be 0?I think one consequence of when
on_activate
sets_time_in_air
to 0 is that an arrow that was unloaded and later loaded would not hurt its shooter for about a second after being loaded.Like I wrote in the other PR. I think this can be ignored since it requires a sequence of events which is incredibly unlikely to happen within the time required to hit yourself.
One way would be to serialize the
_time_in_air
like I suggested here and set that value when the arrow is loaded again. But in practice I think that would be no different than usingdtime_s
.I think your solution of using
dtime_s
is good.Yeah, it works under the constraint that a map block with an arrow in it is always unloaded for more than a second.
This PR now also addresses issue #114 (“Can't blow up end crystals with harming arrows”).
WIP: items/mcl_bows: Let players shoot themselves with arrowsto items/mcl_bows: Let players shoot themselves with arrows@ryvnf can you please follow the testing steps and report back?
World Preparation
9f086a9242
with mapgen v7 and seed “arrow”.NB: First arrow went through head without colliding.
NB: Specifications request stone buttons
NB: My aim sucks.
Verify Patch Part 2: Enchanted Arrows
NB: My aim still sucks.
Verify Patch Part 3: Multiplayer
Yeah, that was an oversight, stone buttons can not be hit.