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
b253e779
Commit
b253e779
authored
May 03, 2022
by
xtaodada
Committed by
Melledy
May 02, 2022
Browse files
Implement food heal function
Co-authored-by:
pris
<
lilch1022@hotmail.com
>
parent
765f569e
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/main/java/emu/grasscutter/game/managers/InventoryManager.java
View file @
b253e779
...
@@ -937,10 +937,20 @@ public class InventoryManager {
...
@@ -937,10 +937,20 @@ public class InventoryManager {
if
(
target
==
null
)
{
if
(
target
==
null
)
{
break
;
break
;
}
}
used
=
player
.
getTeamManager
().
reviveAvatar
(
target
)
?
1
:
0
;
used
=
player
.
getTeamManager
().
reviveAvatar
(
target
)
?
1
:
0
;
}
}
break
;
break
;
case
MATERIAL_NOTICE_ADD_HP:
if
(
useItem
.
getItemData
().
getUseTarget
().
equals
(
"ITEM_USE_TARGET_SPECIFY_ALIVE_AVATAR"
))
{
if
(
target
==
null
)
{
break
;
}
int
[]
SatiationParams
=
useItem
.
getItemData
().
getSatiationParams
();
used
=
player
.
getTeamManager
().
healAvatar
(
target
,
SatiationParams
[
0
],
SatiationParams
[
1
])
?
1
:
0
;
}
break
;
case
MATERIAL_CHEST:
case
MATERIAL_CHEST:
if
(
useItem
.
getRewardBoxId
()
>
0
)
{
if
(
useItem
.
getRewardBoxId
()
>
0
)
{
used
=
handleRewardBox
(
player
,
useItem
)
?
1
:
0
;
used
=
handleRewardBox
(
player
,
useItem
)
?
1
:
0
;
...
...
src/main/java/emu/grasscutter/game/player/TeamManager.java
View file @
b253e779
...
@@ -457,7 +457,31 @@ public class TeamManager {
...
@@ -457,7 +457,31 @@ public class TeamManager {
return
false
;
return
false
;
}
}
public
boolean
healAvatar
(
Avatar
avatar
,
int
healRate
,
int
healAmount
)
{
for
(
EntityAvatar
entity
:
getActiveTeam
())
{
if
(
entity
.
getAvatar
()
==
avatar
)
{
if
(!
entity
.
isAlive
())
{
return
false
;
}
entity
.
setFightProperty
(
FightProperty
.
FIGHT_PROP_CUR_HP
,
(
float
)
Math
.
min
(
(
entity
.
getFightProperty
(
FightProperty
.
FIGHT_PROP_CUR_HP
)
+
entity
.
getFightProperty
(
FightProperty
.
FIGHT_PROP_MAX_HP
)
*
(
float
)
healRate
/
100.0
+
(
float
)
healAmount
/
100.0
),
entity
.
getFightProperty
(
FightProperty
.
FIGHT_PROP_MAX_HP
)
)
);
getPlayer
().
sendPacket
(
new
PacketAvatarFightPropUpdateNotify
(
entity
.
getAvatar
(),
FightProperty
.
FIGHT_PROP_CUR_HP
));
getPlayer
().
sendPacket
(
new
PacketAvatarLifeStateChangeNotify
(
entity
.
getAvatar
()));
return
true
;
}
}
return
false
;
}
public
void
respawnTeam
()
{
public
void
respawnTeam
()
{
// Make sure all team members are dead
// Make sure all team members are dead
for
(
EntityAvatar
entity
:
getActiveTeam
())
{
for
(
EntityAvatar
entity
:
getActiveTeam
())
{
...
...
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