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
14b6d3ce
Commit
14b6d3ce
authored
Apr 29, 2022
by
Melledy
Browse files
Fix monster levels in dungeons
parent
d690590e
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/main/java/emu/grasscutter/data/def/DungeonData.java
View file @
14b6d3ce
...
...
@@ -10,6 +10,7 @@ import emu.grasscutter.game.props.SceneType;
public
class
DungeonData
extends
GameResource
{
private
int
Id
;
private
int
SceneId
;
private
int
ShowLevel
;
private
String
InvolveType
;
// TODO enum
@Override
...
...
@@ -21,6 +22,10 @@ public class DungeonData extends GameResource {
return
SceneId
;
}
public
int
getShowLevel
()
{
return
ShowLevel
;
}
@Override
public
void
onLoad
()
{
...
...
src/main/java/emu/grasscutter/game/world/Scene.java
View file @
14b6d3ce
...
...
@@ -495,20 +495,7 @@ public class Scene {
}
for
(
SceneGroup
group
:
block
.
groups
)
{
for
(
SceneGadget
g
:
group
.
gadgets
)
{
EntityGadget
entity
=
new
EntityGadget
(
this
,
g
.
gadget_id
,
g
.
pos
);
if
(
entity
.
getGadgetData
()
==
null
)
continue
;
entity
.
setBlockId
(
block
.
id
);
entity
.
setConfigId
(
g
.
config_id
);
entity
.
setGroupId
(
group
.
id
);
entity
.
getRotation
().
set
(
g
.
rot
);
entity
.
setState
(
g
.
state
);
this
.
addEntity
(
entity
);
this
.
getScriptManager
().
callEvent
(
EventType
.
EVENT_GADGET_CREATE
,
new
ScriptArgs
(
entity
.
getConfigId
()));
}
this
.
getScriptManager
().
spawnGadgetsInGroup
(
block
,
group
);
}
}
...
...
src/main/java/emu/grasscutter/scripts/SceneScriptManager.java
View file @
14b6d3ce
package
emu.grasscutter.scripts
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.HashSet
;
import
java.util.List
;
...
...
@@ -14,6 +15,9 @@ import org.luaj.vm2.LuaValue;
import
org.luaj.vm2.lib.jse.CoerceJavaToLua
;
import
emu.grasscutter.Grasscutter
;
import
emu.grasscutter.data.GameData
;
import
emu.grasscutter.data.def.MonsterData
;
import
emu.grasscutter.data.def.WorldLevelData
;
import
emu.grasscutter.game.entity.EntityGadget
;
import
emu.grasscutter.game.entity.EntityMonster
;
import
emu.grasscutter.game.entity.GameEntity
;
...
...
@@ -207,6 +211,64 @@ public class SceneScriptManager {
}
public
void
spawnGadgetsInGroup
(
SceneBlock
block
,
SceneGroup
group
)
{
for
(
SceneGadget
g
:
group
.
gadgets
)
{
EntityGadget
entity
=
new
EntityGadget
(
getScene
(),
g
.
gadget_id
,
g
.
pos
);
if
(
entity
.
getGadgetData
()
==
null
)
continue
;
entity
.
setBlockId
(
block
.
id
);
entity
.
setConfigId
(
g
.
config_id
);
entity
.
setGroupId
(
group
.
id
);
entity
.
getRotation
().
set
(
g
.
rot
);
entity
.
setState
(
g
.
state
);
getScene
().
addEntity
(
entity
);
this
.
callEvent
(
EventType
.
EVENT_GADGET_CREATE
,
new
ScriptArgs
(
entity
.
getConfigId
()));
}
}
public
void
spawnMonstersInGroup
(
SceneGroup
group
)
{
List
<
GameEntity
>
toAdd
=
new
ArrayList
<>();
for
(
SceneMonster
monster
:
group
.
monsters
)
{
MonsterData
data
=
GameData
.
getMonsterDataMap
().
get
(
monster
.
monster_id
);
if
(
data
==
null
)
{
continue
;
}
// Calculate level
int
level
=
monster
.
level
;
if
(
getScene
().
getDungeonData
()
!=
null
)
{
level
=
getScene
().
getDungeonData
().
getShowLevel
();
}
else
if
(
getScene
().
getWorld
().
getWorldLevel
()
>
0
)
{
WorldLevelData
worldLevelData
=
GameData
.
getWorldLevelDataMap
().
get
(
getScene
().
getWorld
().
getWorldLevel
());
if
(
worldLevelData
!=
null
)
{
level
=
worldLevelData
.
getMonsterLevel
();
}
}
// Spawn mob
EntityMonster
entity
=
new
EntityMonster
(
getScene
(),
data
,
monster
.
pos
,
level
);
entity
.
getRotation
().
set
(
monster
.
rot
);
entity
.
setGroupId
(
group
.
id
);
entity
.
setConfigId
(
monster
.
config_id
);
toAdd
.
add
(
entity
);
}
if
(
toAdd
.
size
()
>
0
)
{
getScene
().
addEntities
(
toAdd
);
for
(
GameEntity
entity
:
toAdd
)
{
callEvent
(
EventType
.
EVENT_ANY_MONSTER_LIVE
,
new
ScriptArgs
(
entity
.
getConfigId
()));
}
}
}
// Events
public
void
callEvent
(
int
eventType
,
ScriptArgs
params
)
{
...
...
src/main/java/emu/grasscutter/scripts/ScriptLib.java
View file @
14b6d3ce
...
...
@@ -115,30 +115,7 @@ public class ScriptLib {
}
// TODO just spawn all from group for now
List
<
GameEntity
>
toAdd
=
new
ArrayList
<>();
for
(
SceneMonster
monster
:
group
.
monsters
)
{
MonsterData
data
=
GameData
.
getMonsterDataMap
().
get
(
monster
.
monster_id
);
if
(
data
==
null
)
{
continue
;
}
EntityMonster
entity
=
new
EntityMonster
(
getSceneScriptManager
().
getScene
(),
data
,
monster
.
pos
,
monster
.
level
);
entity
.
getRotation
().
set
(
monster
.
rot
);
entity
.
setGroupId
(
group
.
id
);
entity
.
setConfigId
(
monster
.
config_id
);
toAdd
.
add
(
entity
);
}
if
(
toAdd
.
size
()
>
0
)
{
getSceneScriptManager
().
getScene
().
addEntities
(
toAdd
);
for
(
GameEntity
entity
:
toAdd
)
{
this
.
getSceneScriptManager
().
callEvent
(
EventType
.
EVENT_ANY_MONSTER_LIVE
,
new
ScriptArgs
(
entity
.
getConfigId
()));
}
}
this
.
getSceneScriptManager
().
spawnMonstersInGroup
(
group
);
return
0
;
}
...
...
@@ -151,30 +128,7 @@ public class ScriptLib {
}
// TODO just spawn all from group for now
List
<
GameEntity
>
toAdd
=
new
ArrayList
<>();
for
(
SceneMonster
monster
:
group
.
monsters
)
{
MonsterData
data
=
GameData
.
getMonsterDataMap
().
get
(
monster
.
monster_id
);
if
(
data
==
null
)
{
continue
;
}
EntityMonster
entity
=
new
EntityMonster
(
getSceneScriptManager
().
getScene
(),
data
,
monster
.
pos
,
monster
.
level
);
entity
.
getRotation
().
set
(
monster
.
rot
);
entity
.
setGroupId
(
group
.
id
);
entity
.
setConfigId
(
monster
.
config_id
);
toAdd
.
add
(
entity
);
}
if
(
toAdd
.
size
()
>
0
)
{
getSceneScriptManager
().
getScene
().
addEntities
(
toAdd
);
for
(
GameEntity
entity
:
toAdd
)
{
this
.
getSceneScriptManager
().
callEvent
(
EventType
.
EVENT_ANY_MONSTER_LIVE
,
new
ScriptArgs
(
entity
.
getConfigId
()));
}
}
this
.
getSceneScriptManager
().
spawnMonstersInGroup
(
group
);
return
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