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
2531ae36
Commit
2531ae36
authored
May 11, 2022
by
gentlespoon
Committed by
Melledy
May 11, 2022
Browse files
Feature: vehicle stamina
1. Remove references. 2. Handle vehicle stamina.
parent
ba5635bf
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
src/main/java/emu/grasscutter/game/managers/StaminaManager/AfterUpdateStaminaListener.java
View file @
2531ae36
...
@@ -8,5 +8,5 @@ public interface AfterUpdateStaminaListener {
...
@@ -8,5 +8,5 @@ public interface AfterUpdateStaminaListener {
* @param reason Why updating stamina.
* @param reason Why updating stamina.
* @param newStamina New Stamina value.
* @param newStamina New Stamina value.
*/
*/
void
onAfterUpdateStamina
(
String
reason
,
int
newStamina
);
void
onAfterUpdateStamina
(
String
reason
,
int
newStamina
,
boolean
isCharacterStamina
);
}
}
src/main/java/emu/grasscutter/game/managers/StaminaManager/BeforeUpdateStaminaListener.java
View file @
2531ae36
...
@@ -8,7 +8,7 @@ public interface BeforeUpdateStaminaListener {
...
@@ -8,7 +8,7 @@ public interface BeforeUpdateStaminaListener {
* @param newStamina New ABSOLUTE stamina value.
* @param newStamina New ABSOLUTE stamina value.
* @return true if you want to cancel this update, otherwise false.
* @return true if you want to cancel this update, otherwise false.
*/
*/
int
onBeforeUpdateStamina
(
String
reason
,
int
newStamina
);
int
onBeforeUpdateStamina
(
String
reason
,
int
newStamina
,
boolean
isCharacterStamina
);
/**
/**
* onBeforeUpdateStamina() will be called before StaminaManager attempt to update the player's current stamina.
* onBeforeUpdateStamina() will be called before StaminaManager attempt to update the player's current stamina.
* This gives listeners a chance to intercept this update.
* This gives listeners a chance to intercept this update.
...
@@ -16,5 +16,5 @@ public interface BeforeUpdateStaminaListener {
...
@@ -16,5 +16,5 @@ public interface BeforeUpdateStaminaListener {
* @param consumption ConsumptionType and RELATIVE stamina change amount.
* @param consumption ConsumptionType and RELATIVE stamina change amount.
* @return true if you want to cancel this update, otherwise false.
* @return true if you want to cancel this update, otherwise false.
*/
*/
Consumption
onBeforeUpdateStamina
(
String
reason
,
Consumption
consumption
);
Consumption
onBeforeUpdateStamina
(
String
reason
,
Consumption
consumption
,
boolean
isCharacterStamina
);
}
}
\ No newline at end of file
src/main/java/emu/grasscutter/game/managers/StaminaManager/ConsumptionType.java
View file @
2531ae36
...
@@ -13,18 +13,19 @@ public enum ConsumptionType {
...
@@ -13,18 +13,19 @@ public enum ConsumptionType {
// Slow swimming is handled per movement, not per second.
// Slow swimming is handled per movement, not per second.
// Arm movement frequency depends on gender/age/height.
// Arm movement frequency depends on gender/age/height.
// TODO: Instead of cost -80 per tick, find a proper way to calculate cost.
// TODO: Instead of cost -80 per tick, find a proper way to calculate cost.
SKIFF
(-
300
),
// TODO: Get real value
SKIFF
_DASH
(-
204
),
SPRINT
(-
1800
),
SPRINT
(-
1800
),
SWIM_DASH_START
(-
20
),
SWIM_DASH_START
(-
20
00
),
SWIM_DASH
(-
204
),
// -10.2 per second, 5Hz = -204 each tick
SWIM_DASH
(-
204
),
// -10.2 per second, 5Hz = -204 each tick
SWIMMING
(-
80
),
SWIMMING
(-
80
),
TALENT_DASH
(-
300
),
// -1500 per second, 5Hz = -300 each tick
TALENT_DASH
(-
300
),
// -1500 per second, 5Hz = -300 each tick
TALENT_DASH_START
(-
1000
),
TALENT_DASH_START
(-
1000
),
// restore
// restore
POWERED_FLY
(
500
),
// TODO: Get real value
POWERED_FLY
(
500
),
POWERED_SKIFF
(
20
00
),
// TODO: Get real value
POWERED_SKIFF
(
5
00
),
RUN
(
500
),
RUN
(
500
),
SKIFF
(
500
),
STANDBY
(
500
),
STANDBY
(
500
),
WALK
(
500
);
WALK
(
500
);
...
...
src/main/java/emu/grasscutter/game/managers/StaminaManager/StaminaManager.java
View file @
2531ae36
This diff is collapsed.
Click to expand it.
src/main/java/emu/grasscutter/game/player/Player.java
View file @
2531ae36
...
@@ -1237,7 +1237,7 @@ public class Player {
...
@@ -1237,7 +1237,7 @@ public class Player {
}
else
if
(
prop
==
PlayerProperty
.
PROP_IS_TRANSFERABLE
)
{
// 10009
}
else
if
(
prop
==
PlayerProperty
.
PROP_IS_TRANSFERABLE
)
{
// 10009
if
(!(
0
<=
value
&&
value
<=
1
))
{
return
false
;
}
if
(!(
0
<=
value
&&
value
<=
1
))
{
return
false
;
}
}
else
if
(
prop
==
PlayerProperty
.
PROP_MAX_STAMINA
)
{
// 10010
}
else
if
(
prop
==
PlayerProperty
.
PROP_MAX_STAMINA
)
{
// 10010
if
(!(
value
>=
0
&&
value
<=
StaminaManager
.
GlobalMaximumStamina
))
{
return
false
;
}
if
(!(
value
>=
0
&&
value
<=
StaminaManager
.
Global
Character
MaximumStamina
))
{
return
false
;
}
}
else
if
(
prop
==
PlayerProperty
.
PROP_CUR_PERSIST_STAMINA
)
{
// 10011
}
else
if
(
prop
==
PlayerProperty
.
PROP_CUR_PERSIST_STAMINA
)
{
// 10011
int
playerMaximumStamina
=
getProperty
(
PlayerProperty
.
PROP_MAX_STAMINA
);
int
playerMaximumStamina
=
getProperty
(
PlayerProperty
.
PROP_MAX_STAMINA
);
if
(!(
value
>=
0
&&
value
<=
playerMaximumStamina
))
{
return
false
;
}
if
(!(
value
>=
0
&&
value
<=
playerMaximumStamina
))
{
return
false
;
}
...
...
src/main/java/emu/grasscutter/server/packet/recv/HandlerVehicleInteractReq.java
View file @
2531ae36
...
@@ -14,6 +14,7 @@ public class HandlerVehicleInteractReq extends PacketHandler {
...
@@ -14,6 +14,7 @@ public class HandlerVehicleInteractReq extends PacketHandler {
@Override
@Override
public
void
handle
(
GameSession
session
,
byte
[]
header
,
byte
[]
payload
)
throws
Exception
{
public
void
handle
(
GameSession
session
,
byte
[]
header
,
byte
[]
payload
)
throws
Exception
{
VehicleInteractReqOuterClass
.
VehicleInteractReq
req
=
VehicleInteractReqOuterClass
.
VehicleInteractReq
.
parseFrom
(
payload
);
VehicleInteractReqOuterClass
.
VehicleInteractReq
req
=
VehicleInteractReqOuterClass
.
VehicleInteractReq
.
parseFrom
(
payload
);
session
.
getPlayer
().
getStaminaManager
().
handleVehicleInteractReq
(
session
,
req
.
getEntityId
(),
req
.
getInteractType
());
session
.
send
(
new
PacketVehicleInteractRsp
(
session
.
getPlayer
(),
req
.
getEntityId
(),
req
.
getInteractType
()));
session
.
send
(
new
PacketVehicleInteractRsp
(
session
.
getPlayer
(),
req
.
getEntityId
(),
req
.
getInteractType
()));
}
}
}
}
src/main/java/emu/grasscutter/server/packet/send/PacketVehicleStaminaNotify.java
View file @
2531ae36
package
emu.grasscutter.server.packet.send
;
package
emu.grasscutter.server.packet.send
;
import
emu.grasscutter.game.entity.GameEntity
;
import
emu.grasscutter.net.packet.BasePacket
;
import
emu.grasscutter.net.packet.BasePacket
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
import
emu.grasscutter.net.proto.VehicleStaminaNotifyOuterClass.VehicleStaminaNotify
;
import
emu.grasscutter.net.proto.VehicleStaminaNotifyOuterClass.VehicleStaminaNotify
;
public
class
PacketVehicleStaminaNotify
extends
BasePacket
{
public
class
PacketVehicleStaminaNotify
extends
BasePacket
{
public
PacketVehicleStaminaNotify
(
GameEntity
entity
,
in
t
newStamina
)
{
public
PacketVehicleStaminaNotify
(
int
vehicleId
,
floa
t
newStamina
)
{
super
(
PacketOpcodes
.
VehicleStaminaNotify
);
super
(
PacketOpcodes
.
VehicleStaminaNotify
);
VehicleStaminaNotify
.
Builder
proto
=
VehicleStaminaNotify
.
newBuilder
();
VehicleStaminaNotify
.
Builder
proto
=
VehicleStaminaNotify
.
newBuilder
();
proto
.
setEntityId
(
entity
.
getId
()
);
proto
.
setEntityId
(
vehicleId
);
proto
.
setCurStamina
(
newStamina
);
proto
.
setCurStamina
(
newStamina
);
this
.
setData
(
proto
.
build
());
this
.
setData
(
proto
.
build
());
...
...
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