Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
ziqian zhang
Grasscutter
Commits
58cb6029
Commit
58cb6029
authored
May 06, 2022
by
gentlespoon
Committed by
Melledy
May 06, 2022
Browse files
Fix #593: Accidental death of character
parent
3f91fdcb
Changes
1
Show whitespace changes
Inline
Side-by-side
src/main/java/emu/grasscutter/game/managers/MovementManager/MovementManager.java
View file @
58cb6029
...
@@ -60,6 +60,7 @@ public class MovementManager {
...
@@ -60,6 +60,7 @@ public class MovementManager {
private
final
Player
player
;
private
final
Player
player
;
private
float
landSpeed
=
0
;
private
float
landSpeed
=
0
;
private
long
landTimeMillisecond
=
0
;
private
Timer
movementManagerTickTimer
;
private
Timer
movementManagerTickTimer
;
private
GameSession
cachedSession
=
null
;
private
GameSession
cachedSession
=
null
;
private
GameEntity
cachedEntity
=
null
;
private
GameEntity
cachedEntity
=
null
;
...
@@ -192,12 +193,20 @@ public class MovementManager {
...
@@ -192,12 +193,20 @@ public class MovementManager {
// cache land speed
// cache land speed
if
(
state
==
MotionState
.
MOTION_LAND_SPEED
)
{
if
(
state
==
MotionState
.
MOTION_LAND_SPEED
)
{
landSpeed
=
motionInfo
.
getSpeed
().
getY
();
landSpeed
=
motionInfo
.
getSpeed
().
getY
();
landTimeMillisecond
=
System
.
currentTimeMillis
();
}
}
if
(
state
==
MotionState
.
MOTION_FALL_ON_GROUND
)
{
if
(
state
==
MotionState
.
MOTION_FALL_ON_GROUND
)
{
// if not received immediately after MOTION_LAND_SPEED, discard this packet.
// TODO: Test in high latency.
int
maxDelay
=
200
;
if
((
System
.
currentTimeMillis
()
-
landTimeMillisecond
)
>
maxDelay
)
{
Grasscutter
.
getLogger
().
debug
(
"MOTION_FALL_ON_GROUND received after "
+
maxDelay
+
"ms, discard."
);
return
;
}
float
currentHP
=
cachedEntity
.
getFightProperty
(
FightProperty
.
FIGHT_PROP_CUR_HP
);
float
currentHP
=
cachedEntity
.
getFightProperty
(
FightProperty
.
FIGHT_PROP_CUR_HP
);
float
maxHP
=
cachedEntity
.
getFightProperty
(
FightProperty
.
FIGHT_PROP_MAX_HP
);
float
maxHP
=
cachedEntity
.
getFightProperty
(
FightProperty
.
FIGHT_PROP_MAX_HP
);
float
damage
=
0
;
float
damage
=
0
;
//
Grasscutter.getLogger().debug("LandSpeed: " + landSpeed);
Grasscutter
.
getLogger
().
debug
(
"LandSpeed: "
+
landSpeed
);
if
(
landSpeed
<
-
23.5
)
{
if
(
landSpeed
<
-
23.5
)
{
damage
=
(
float
)(
maxHP
*
0.33
);
damage
=
(
float
)(
maxHP
*
0.33
);
}
}
...
@@ -214,7 +223,7 @@ public class MovementManager {
...
@@ -214,7 +223,7 @@ public class MovementManager {
if
(
newHP
<
0
)
{
if
(
newHP
<
0
)
{
newHP
=
0
;
newHP
=
0
;
}
}
//
Grasscutter.getLogger().debug("Max: " + maxHP + "\tCurr: " + currentHP + "\tDamage: " + damage + "\tnewHP: " + newHP);
Grasscutter
.
getLogger
().
debug
(
"Max: "
+
maxHP
+
"\tCurr: "
+
currentHP
+
"\tDamage: "
+
damage
+
"\tnewHP: "
+
newHP
);
cachedEntity
.
setFightProperty
(
FightProperty
.
FIGHT_PROP_CUR_HP
,
newHP
);
cachedEntity
.
setFightProperty
(
FightProperty
.
FIGHT_PROP_CUR_HP
,
newHP
);
cachedEntity
.
getWorld
().
broadcastPacket
(
new
PacketEntityFightPropUpdateNotify
(
cachedEntity
,
FightProperty
.
FIGHT_PROP_CUR_HP
));
cachedEntity
.
getWorld
().
broadcastPacket
(
new
PacketEntityFightPropUpdateNotify
(
cachedEntity
,
FightProperty
.
FIGHT_PROP_CUR_HP
));
if
(
newHP
==
0
)
{
if
(
newHP
==
0
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment