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
61e4491e
Commit
61e4491e
authored
Apr 18, 2022
by
Melledy
Browse files
Properly level up characters with the character exp virtual item
parent
ab343aeb
Changes
2
Show whitespace changes
Inline
Side-by-side
src/main/java/emu/grasscutter/game/inventory/Inventory.java
View file @
61e4491e
...
...
@@ -15,6 +15,7 @@ import emu.grasscutter.database.DatabaseHelper;
import
emu.grasscutter.game.GenshinPlayer
;
import
emu.grasscutter.game.avatar.AvatarStorage
;
import
emu.grasscutter.game.avatar.GenshinAvatar
;
import
emu.grasscutter.game.entity.EntityAvatar
;
import
emu.grasscutter.net.proto.ItemParamOuterClass.ItemParam
;
import
emu.grasscutter.server.packet.send.PacketAvatarEquipChangeNotify
;
import
emu.grasscutter.server.packet.send.PacketStoreItemChangeNotify
;
...
...
@@ -187,6 +188,8 @@ public class Inventory implements Iterable<GenshinItem> {
existingItem
.
save
();
return
existingItem
;
}
}
else
{
return
null
;
}
// Set ownership and save to db
...
...
@@ -207,6 +210,11 @@ public class Inventory implements Iterable<GenshinItem> {
private
void
addVirtualItem
(
int
itemId
,
int
count
)
{
switch
(
itemId
)
{
case
101
:
// Character exp
for
(
EntityAvatar
entity
:
getPlayer
().
getTeamManager
().
getActiveTeam
())
{
getPlayer
().
getServer
().
getInventoryManager
().
upgradeAvatar
(
player
,
entity
.
getAvatar
(),
count
);
}
break
;
case
102
:
// Adventure exp
getPlayer
().
addExpDirectly
(
count
);
break
;
...
...
src/main/java/emu/grasscutter/game/managers/InventoryManager.java
View file @
61e4491e
...
...
@@ -660,6 +660,19 @@ public class InventoryManager {
player
.
getInventory
().
removeItem
(
feedItem
,
count
);
// Level up
upgradeAvatar
(
player
,
avatar
,
promoteData
,
expGain
);
}
public
void
upgradeAvatar
(
GenshinPlayer
player
,
GenshinAvatar
avatar
,
int
expGain
)
{
AvatarPromoteData
promoteData
=
GenshinData
.
getAvatarPromoteData
(
avatar
.
getAvatarData
().
getAvatarPromoteId
(),
avatar
.
getPromoteLevel
());
if
(
promoteData
==
null
)
{
return
;
}
upgradeAvatar
(
player
,
avatar
,
promoteData
,
expGain
);
}
public
void
upgradeAvatar
(
GenshinPlayer
player
,
GenshinAvatar
avatar
,
AvatarPromoteData
promoteData
,
int
expGain
)
{
int
maxLevel
=
promoteData
.
getUnlockMaxLevel
();
int
level
=
avatar
.
getLevel
();
int
oldLevel
=
level
;
...
...
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