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
ed98ab15
Commit
ed98ab15
authored
Apr 28, 2022
by
Kengxxiao
Committed by
Melledy
Apr 28, 2022
Browse files
fix exp drop issue
parent
a5601e84
Changes
3
Show whitespace changes
Inline
Side-by-side
src/main/java/emu/grasscutter/game/drop/DropData.java
View file @
ed98ab15
...
...
@@ -7,6 +7,15 @@ public class DropData {
private
int
minCount
;
private
int
maxCount
;
private
boolean
share
=
false
;
private
boolean
give
=
false
;
public
boolean
isGive
()
{
return
give
;
}
public
void
setGive
(
boolean
give
)
{
this
.
give
=
give
;
}
public
int
getItemId
()
{
return
itemId
;
...
...
@@ -43,15 +52,4 @@ public class DropData {
this
.
share
=
share
;
}
public
boolean
isGive
()
{
return
give
;
}
private
boolean
give
=
false
;
public
boolean
isExp
()
{
return
exp
;
}
private
boolean
exp
=
false
;
}
src/main/java/emu/grasscutter/game/drop/DropManager.java
View file @
ed98ab15
...
...
@@ -6,7 +6,11 @@ import emu.grasscutter.data.GameData;
import
emu.grasscutter.data.def.ItemData
;
import
emu.grasscutter.game.entity.EntityItem
;
import
emu.grasscutter.game.entity.EntityMonster
;
import
emu.grasscutter.game.inventory.GameItem
;
import
emu.grasscutter.game.inventory.ItemType
;
import
emu.grasscutter.game.player.Player
;
import
emu.grasscutter.game.props.ActionReason
;
import
emu.grasscutter.game.world.Scene
;
import
emu.grasscutter.server.game.GameServer
;
import
emu.grasscutter.utils.Position
;
import
emu.grasscutter.utils.Utils
;
...
...
@@ -53,31 +57,41 @@ public class DropManager {
e
.
printStackTrace
();
}
}
private
void
addDropEntity
(
DropData
dd
,
Scene
dropScene
,
ItemData
itemData
,
Position
pos
,
int
num
,
Player
target
)
{
if
(!
dd
.
isGive
()
&&
(
itemData
.
getItemType
()
!=
ItemType
.
ITEM_VIRTUAL
||
itemData
.
getGadgetId
()
!=
0
))
{
EntityItem
entity
=
new
EntityItem
(
dropScene
,
target
,
itemData
,
pos
,
num
,
dd
.
isShare
());
if
(!
dd
.
isShare
())
dropScene
.
addEntityToSingleClient
(
target
,
entity
);
else
dropScene
.
addEntity
(
entity
);
}
else
{
if
(
target
!=
null
)
{
target
.
getInventory
().
addItem
(
new
GameItem
(
itemData
,
num
),
ActionReason
.
SubfieldDrop
,
true
);
}
else
{
// target is null if items will be added are shared. no one could pick it up because of the combination(give + shared)
// so it will be sent to all players' inventories directly.
dropScene
.
getPlayers
().
forEach
(
x
->
{
x
.
getInventory
().
addItem
(
new
GameItem
(
itemData
,
num
),
ActionReason
.
SubfieldDrop
,
true
);
});
}
}
}
private
void
processDrop
(
DropData
dd
,
EntityMonster
em
,
Player
gp
)
{
int
target
=
Utils
.
randomRange
(
1
,
10000
);
if
(
target
>=
dd
.
getMinWeight
()
&&
target
<
dd
.
getMaxWeight
())
{
ItemData
itemData
=
GameData
.
getItemDataMap
().
get
(
dd
.
getItemId
());
int
num
=
Utils
.
randomRange
(
dd
.
getMinCount
(),
dd
.
getMaxCount
());
if
(!
dd
.
isGive
())
{
if
(
itemData
.
isEquip
())
{
for
(
int
i
=
0
;
i
<
num
;
i
++)
{
float
range
=
(
5
f
+
(.
1
f
*
num
));
Position
pos
=
em
.
getPosition
().
clone
().
addX
((
float
)
(
Math
.
random
()
*
range
)
-
(
range
/
2
)).
addY
(
3
f
).
addZ
((
float
)
(
Math
.
random
()
*
range
)
-
(
range
/
2
));
EntityItem
entity
=
new
EntityItem
(
em
.
getScene
(),
gp
,
itemData
,
pos
,
num
,
dd
.
isShare
());
if
(!
dd
.
isShare
())
em
.
getScene
().
addEntityToSingleClient
(
gp
,
entity
);
else
em
.
getScene
().
addEntity
(
entity
);
addDropEntity
(
dd
,
em
.
getScene
(),
itemData
,
pos
,
num
,
gp
);
}
}
else
{
Position
pos
=
em
.
getPosition
().
clone
().
addY
(
3
f
);
EntityItem
entity
=
new
EntityItem
(
em
.
getScene
(),
gp
,
itemData
,
pos
,
num
,
dd
.
isShare
());
if
(!
dd
.
isShare
())
em
.
getScene
().
addEntityToSingleClient
(
gp
,
entity
);
else
em
.
getScene
().
addEntity
(
entity
);
}
addDropEntity
(
dd
,
em
.
getScene
(),
itemData
,
pos
,
num
,
gp
);
}
}
}
...
...
src/main/java/emu/grasscutter/game/inventory/Inventory.java
View file @
ed98ab15
...
...
@@ -168,7 +168,7 @@ public class Inventory implements Iterable<GameItem> {
}
else
if
(
type
==
ItemType
.
ITEM_VIRTUAL
)
{
// Handle
this
.
addVirtualItem
(
item
.
getItemId
(),
item
.
getCount
());
return
null
;
return
item
;
}
else
if
(
item
.
getItemData
().
getMaterialType
()
==
MaterialType
.
MATERIAL_AVATAR
)
{
// Get avatar id
int
avatarId
=
(
item
.
getItemId
()
%
1000
)
+
10000000
;
...
...
@@ -236,9 +236,7 @@ public class Inventory implements Iterable<GameItem> {
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
);
}
getPlayer
().
getServer
().
getInventoryManager
().
upgradeAvatar
(
player
,
getPlayer
().
getTeamManager
().
getCurrentAvatarEntity
().
getAvatar
(),
count
);
break
;
case
102
:
// Adventure exp
getPlayer
().
addExpDirectly
(
count
);
...
...
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