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
0bfa1fa0
Commit
0bfa1fa0
authored
May 09, 2022
by
Akka
Committed by
GitHub
May 09, 2022
Browse files
Merge pull request #8 from Grasscutters/development
Development
parents
65861c3c
056b5b80
Changes
51
Hide whitespace changes
Inline
Side-by-side
src/main/java/emu/grasscutter/game/player/TeamManager.java
View file @
0bfa1fa0
...
...
@@ -10,6 +10,7 @@ import emu.grasscutter.data.def.AvatarSkillDepotData;
import
emu.grasscutter.game.avatar.Avatar
;
import
emu.grasscutter.game.entity.EntityAvatar
;
import
emu.grasscutter.game.entity.EntityBaseGadget
;
import
emu.grasscutter.game.inventory.GameItem
;
import
emu.grasscutter.game.props.ElementType
;
import
emu.grasscutter.game.props.EnterReason
;
import
emu.grasscutter.game.props.FightProperty
;
...
...
@@ -579,6 +580,24 @@ public class TeamManager {
// Packets
getPlayer
().
sendPacket
(
new
BasePacket
(
PacketOpcodes
.
WorldPlayerReviveRsp
));
}
public
synchronized
void
addEnergyToTeam
(
GameItem
energyBall
)
{
// TODO
float
baseEnergy
=
2
;
for
(
int
i
=
0
;
i
<
getActiveTeam
().
size
();
i
++)
{
EntityAvatar
entity
=
getActiveTeam
().
get
(
i
);
float
energyGain
=
baseEnergy
;
// Active character gets full hp
if
(
getCurrentCharacterIndex
()
!=
i
)
{
energyGain
*=
Math
.
max
(
1.0
-
(
getActiveTeam
().
size
()
*
.
1
f
),
.
6
f
);
}
entity
.
addEnergy
(
energyGain
);
}
}
public
void
saveAvatars
()
{
// Save all avatars from active team
...
...
src/main/java/emu/grasscutter/game/props/ElementType.java
View file @
0bfa1fa0
...
...
@@ -9,21 +9,22 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import
it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap
;
public
enum
ElementType
{
None
(
0
,
FightProperty
.
FIGHT_PROP_MAX_FIRE_ENERGY
),
Fire
(
1
,
FightProperty
.
FIGHT_PROP_MAX_FIRE_ENERGY
,
10101
,
"TeamResonance_Fire_Lv2"
),
Water
(
2
,
FightProperty
.
FIGHT_PROP_MAX_WATER_ENERGY
,
10201
,
"TeamResonance_Water_Lv2"
),
Grass
(
3
,
FightProperty
.
FIGHT_PROP_MAX_GRASS_ENERGY
),
Electric
(
4
,
FightProperty
.
FIGHT_PROP_MAX_ELEC_ENERGY
,
10401
,
"TeamResonance_Electric_Lv2"
),
Ice
(
5
,
FightProperty
.
FIGHT_PROP_MAX_ICE_ENERGY
,
10601
,
"TeamResonance_Ice_Lv2"
),
Frozen
(
6
,
FightProperty
.
FIGHT_PROP_MAX_ICE_ENERGY
),
Wind
(
7
,
FightProperty
.
FIGHT_PROP_MAX_WIND_ENERGY
,
10301
,
"TeamResonance_Wind_Lv2"
),
Rock
(
8
,
FightProperty
.
FIGHT_PROP_MAX_ROCK_ENERGY
,
10701
,
"TeamResonance_Rock_Lv2"
),
AntiFire
(
9
,
FightProperty
.
FIGHT_PROP_MAX_FIRE_ENERGY
),
Default
(
255
,
FightProperty
.
FIGHT_PROP_MAX_FIRE_ENERGY
,
10801
,
"TeamResonance_AllDifferent"
);
None
(
0
,
FightProperty
.
FIGHT_PROP_CUR_FIRE_ENERGY
,
FightProperty
.
FIGHT_PROP_MAX_FIRE_ENERGY
),
Fire
(
1
,
FightProperty
.
FIGHT_PROP_CUR_FIRE_ENERGY
,
FightProperty
.
FIGHT_PROP_MAX_FIRE_ENERGY
,
10101
,
"TeamResonance_Fire_Lv2"
),
Water
(
2
,
FightProperty
.
FIGHT_PROP_CUR_WATER_ENERGY
,
FightProperty
.
FIGHT_PROP_MAX_WATER_ENERGY
,
10201
,
"TeamResonance_Water_Lv2"
),
Grass
(
3
,
FightProperty
.
FIGHT_PROP_CUR_GRASS_ENERGY
,
FightProperty
.
FIGHT_PROP_MAX_GRASS_ENERGY
),
Electric
(
4
,
FightProperty
.
FIGHT_PROP_CUR_ELEC_ENERGY
,
FightProperty
.
FIGHT_PROP_MAX_ELEC_ENERGY
,
10401
,
"TeamResonance_Electric_Lv2"
),
Ice
(
5
,
FightProperty
.
FIGHT_PROP_CUR_ICE_ENERGY
,
FightProperty
.
FIGHT_PROP_MAX_ICE_ENERGY
,
10601
,
"TeamResonance_Ice_Lv2"
),
Frozen
(
6
,
FightProperty
.
FIGHT_PROP_CUR_ICE_ENERGY
,
FightProperty
.
FIGHT_PROP_MAX_ICE_ENERGY
),
Wind
(
7
,
FightProperty
.
FIGHT_PROP_CUR_WIND_ENERGY
,
FightProperty
.
FIGHT_PROP_MAX_WIND_ENERGY
,
10301
,
"TeamResonance_Wind_Lv2"
),
Rock
(
8
,
FightProperty
.
FIGHT_PROP_CUR_ROCK_ENERGY
,
FightProperty
.
FIGHT_PROP_MAX_ROCK_ENERGY
,
10701
,
"TeamResonance_Rock_Lv2"
),
AntiFire
(
9
,
FightProperty
.
FIGHT_PROP_CUR_FIRE_ENERGY
,
FightProperty
.
FIGHT_PROP_MAX_FIRE_ENERGY
),
Default
(
255
,
FightProperty
.
FIGHT_PROP_CUR_FIRE_ENERGY
,
FightProperty
.
FIGHT_PROP_MAX_FIRE_ENERGY
,
10801
,
"TeamResonance_AllDifferent"
);
private
final
int
value
;
private
final
int
teamResonanceId
;
private
final
FightProperty
energyProperty
;
private
final
FightProperty
curEnergyProp
;
private
final
FightProperty
maxEnergyProp
;
private
final
int
configHash
;
private
static
final
Int2ObjectMap
<
ElementType
>
map
=
new
Int2ObjectOpenHashMap
<>();
private
static
final
Map
<
String
,
ElementType
>
stringMap
=
new
HashMap
<>();
...
...
@@ -35,13 +36,14 @@ public enum ElementType {
});
}
private
ElementType
(
int
value
,
FightProperty
e
nergyProp
erty
)
{
this
(
value
,
e
nergyProp
erty
,
0
,
null
);
private
ElementType
(
int
value
,
FightProperty
curE
nergyProp
,
FightProperty
maxEnergyProp
)
{
this
(
value
,
curE
nergyProp
,
maxEnergyProp
,
0
,
null
);
}
private
ElementType
(
int
value
,
FightProperty
e
nergyProp
erty
,
int
teamResonanceId
,
String
configName
)
{
private
ElementType
(
int
value
,
FightProperty
curE
nergyProp
,
FightProperty
maxEnergyProp
,
int
teamResonanceId
,
String
configName
)
{
this
.
value
=
value
;
this
.
energyProperty
=
energyProperty
;
this
.
curEnergyProp
=
curEnergyProp
;
this
.
maxEnergyProp
=
maxEnergyProp
;
this
.
teamResonanceId
=
teamResonanceId
;
if
(
configName
!=
null
)
{
this
.
configHash
=
Utils
.
abilityHash
(
configName
);
...
...
@@ -54,8 +56,12 @@ public enum ElementType {
return
value
;
}
public
FightProperty
getEnergyProperty
()
{
return
energyProperty
;
public
FightProperty
getCurEnergyProp
()
{
return
curEnergyProp
;
}
public
FightProperty
getMaxEnergyProp
()
{
return
maxEnergyProp
;
}
public
int
getTeamResonanceId
()
{
...
...
src/main/java/emu/grasscutter/game/tower/TowerLevelRecord.java
0 → 100644
View file @
0bfa1fa0
package
emu.grasscutter.game.tower
;
import
dev.morphia.annotations.Entity
;
import
java.util.HashMap
;
import
java.util.Map
;
@Entity
public
class
TowerLevelRecord
{
/**
* floorId in config
*/
private
int
floorId
;
/**
* LevelId - Stars
*/
private
Map
<
Integer
,
Integer
>
passedLevelMap
;
private
int
floorStarRewardProgress
;
public
TowerLevelRecord
setLevelStars
(
int
levelId
,
int
stars
){
passedLevelMap
.
put
(
levelId
,
stars
);
return
this
;
}
public
int
getStarCount
()
{
return
passedLevelMap
.
values
().
stream
().
mapToInt
(
Integer:
:
intValue
).
sum
();
}
public
TowerLevelRecord
(){
}
public
TowerLevelRecord
(
int
floorId
){
this
.
floorId
=
floorId
;
this
.
passedLevelMap
=
new
HashMap
<>();
this
.
floorStarRewardProgress
=
0
;
}
public
int
getFloorId
()
{
return
floorId
;
}
public
void
setFloorId
(
int
floorId
)
{
this
.
floorId
=
floorId
;
}
public
Map
<
Integer
,
Integer
>
getPassedLevelMap
()
{
return
passedLevelMap
;
}
public
void
setPassedLevelMap
(
Map
<
Integer
,
Integer
>
passedLevelMap
)
{
this
.
passedLevelMap
=
passedLevelMap
;
}
public
int
getFloorStarRewardProgress
()
{
return
floorStarRewardProgress
;
}
public
void
setFloorStarRewardProgress
(
int
floorStarRewardProgress
)
{
this
.
floorStarRewardProgress
=
floorStarRewardProgress
;
}
}
src/main/java/emu/grasscutter/game/tower/TowerManager.java
View file @
0bfa1fa0
...
...
@@ -9,10 +9,12 @@ import emu.grasscutter.game.dungeons.TowerDungeonSettleListener;
import
emu.grasscutter.game.player.Player
;
import
emu.grasscutter.server.packet.send.PacketCanUseSkillNotify
;
import
emu.grasscutter.server.packet.send.PacketTowerCurLevelRecordChangeNotify
;
import
emu.grasscutter.server.packet.send.PacketTowerEnterLevelRsp
;
import
emu.grasscutter.server.packet.send.PacketTowerLevelStarCondNotify
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
@Entity
public
class
TowerManager
{
...
...
@@ -26,11 +28,19 @@ public class TowerManager {
this
.
player
=
player
;
}
/**
* the floor players chose
*/
private
int
currentFloorId
;
private
int
currentLevel
;
@Transient
private
int
currentLevelId
;
/**
* floorId - Record
*/
private
Map
<
Integer
,
TowerLevelRecord
>
recordMap
;
@Transient
private
int
entryScene
;
...
...
@@ -38,7 +48,26 @@ public class TowerManager {
return
currentFloorId
;
}
public
int
getCurrentLevelId
(){
return
this
.
currentLevelId
+
currentLevel
;
}
/**
* form 1-3
*/
public
int
getCurrentLevel
(){
return
currentLevel
+
1
;
}
private
static
final
List
<
DungeonSettleListener
>
towerDungeonSettleListener
=
List
.
of
(
new
TowerDungeonSettleListener
());
public
Map
<
Integer
,
TowerLevelRecord
>
getRecordMap
()
{
if
(
recordMap
==
null
){
recordMap
=
new
HashMap
<>();
recordMap
.
put
(
1001
,
new
TowerLevelRecord
(
1001
));
}
return
recordMap
;
}
public
void
teamSelect
(
int
floor
,
List
<
List
<
Long
>>
towerTeams
)
{
var
floorData
=
GameData
.
getTowerFloorDataMap
().
get
(
floor
);
...
...
@@ -54,51 +83,73 @@ public class TowerManager {
entryScene
=
player
.
getSceneId
();
}
player
.
getTeamManager
().
setupTemporaryTeam
(
towerTeams
);
}
public
void
enterLevel
(
int
enterPointId
)
{
var
levelData
=
GameData
.
getTowerLevelDataMap
().
get
(
currentLevelId
+
c
urrentLevel
);
var
levelData
=
GameData
.
getTowerLevelDataMap
().
get
(
getC
urrentLevel
Id
()
);
this
.
currentLevel
++;
var
id
=
levelData
.
getDungeonId
();
var
dungeonId
=
levelData
.
getDungeonId
();
notifyCurLevelRecordChange
();
// use team user choose
player
.
getTeamManager
().
useTemporaryTeam
(
0
);
player
.
getServer
().
getDungeonManager
().
handoffDungeon
(
player
,
i
d
,
player
.
getServer
().
getDungeonManager
().
handoffDungeon
(
player
,
dungeonI
d
,
towerDungeonSettleListener
);
// make sure user can exit dungeon correctly
player
.
getScene
().
setPrevScene
(
entryScene
);
player
.
getScene
().
setPrevScenePoint
(
enterPointId
);
player
.
getSession
().
send
(
new
PacketTowerEnterLevelRsp
(
currentFloorId
,
c
urrentLevel
));
player
.
getSession
().
send
(
new
PacketTowerEnterLevelRsp
(
currentFloorId
,
getC
urrentLevel
()
));
// stop using skill
player
.
getSession
().
send
(
new
PacketCanUseSkillNotify
(
false
));
// notify the cond of stars
player
.
getSession
().
send
(
new
PacketTowerLevelStarCondNotify
(
currentFloorId
,
getCurrentLevel
()));
}
public
void
notifyCurLevelRecordChange
(){
player
.
getSession
().
send
(
new
PacketTowerCurLevelRecordChangeNotify
(
currentFloorId
,
c
urrentLevel
));
player
.
getSession
().
send
(
new
PacketTowerCurLevelRecordChangeNotify
(
currentFloorId
,
getC
urrentLevel
()
));
}
public
void
notifyCurLevelRecordChangeWhenDone
(){
player
.
getSession
().
send
(
new
PacketTowerCurLevelRecordChangeNotify
(
currentFloorId
,
currentLevel
+
1
));
public
void
notifyCurLevelRecordChangeWhenDone
(
int
stars
){
if
(!
recordMap
.
containsKey
(
currentFloorId
)){
recordMap
.
put
(
currentFloorId
,
new
TowerLevelRecord
(
currentFloorId
).
setLevelStars
(
getCurrentLevelId
(),
stars
));
}
else
{
recordMap
.
put
(
currentFloorId
,
recordMap
.
get
(
currentFloorId
).
setLevelStars
(
getCurrentLevelId
(),
stars
));
}
this
.
currentLevel
++;
if
(!
hasNextLevel
()){
// set up the next floor
recordMap
.
put
(
getNextFloorId
(),
new
TowerLevelRecord
(
getNextFloorId
()));
player
.
getSession
().
send
(
new
PacketTowerCurLevelRecordChangeNotify
(
getNextFloorId
(),
1
));
}
else
{
player
.
getSession
().
send
(
new
PacketTowerCurLevelRecordChangeNotify
(
currentFloorId
,
getCurrentLevel
()));
}
}
public
boolean
hasNextLevel
(){
return
this
.
currentLevel
<
3
;
}
public
int
getNextFloorId
()
{
if
(
hasNextLevel
()){
return
0
;
}
this
.
currentFloorId
++;
return
this
.
currentFloorId
;
return
player
.
getServer
().
getTowerScheduleManager
().
getNextFloorId
(
this
.
currentFloorId
);
}
public
boolean
hasNextFloor
(){
return
player
.
getServer
().
getTowerScheduleManager
().
getNextFloorId
(
this
.
currentFloorId
)
>
0
;
}
public
void
clearEntry
()
{
this
.
entryScene
=
0
;
}
public
boolean
canEnterScheduleFloor
(){
if
(!
recordMap
.
containsKey
(
player
.
getServer
().
getTowerScheduleManager
().
getLastEntranceFloor
())){
return
false
;
}
return
recordMap
.
get
(
player
.
getServer
().
getTowerScheduleManager
().
getLastEntranceFloor
())
.
getStarCount
()
>=
6
;
}
}
src/main/java/emu/grasscutter/game/tower/TowerScheduleConfig.java
0 → 100644
View file @
0bfa1fa0
package
emu.grasscutter.game.tower
;
import
java.util.Date
;
public
class
TowerScheduleConfig
{
private
int
scheduleId
;
private
Date
scheduleStartTime
;
private
Date
nextScheduleChangeTime
;
public
int
getScheduleId
()
{
return
scheduleId
;
}
public
void
setScheduleId
(
int
scheduleId
)
{
this
.
scheduleId
=
scheduleId
;
}
public
Date
getScheduleStartTime
()
{
return
scheduleStartTime
;
}
public
void
setScheduleStartTime
(
Date
scheduleStartTime
)
{
this
.
scheduleStartTime
=
scheduleStartTime
;
}
public
Date
getNextScheduleChangeTime
()
{
return
nextScheduleChangeTime
;
}
public
void
setNextScheduleChangeTime
(
Date
nextScheduleChangeTime
)
{
this
.
nextScheduleChangeTime
=
nextScheduleChangeTime
;
}
}
src/main/java/emu/grasscutter/game/tower/TowerScheduleManager.java
0 → 100644
View file @
0bfa1fa0
package
emu.grasscutter.game.tower
;
import
emu.grasscutter.Grasscutter
;
import
emu.grasscutter.data.GameData
;
import
emu.grasscutter.data.def.TowerScheduleData
;
import
emu.grasscutter.server.game.GameServer
;
import
java.io.FileReader
;
import
java.util.List
;
public
class
TowerScheduleManager
{
private
final
GameServer
gameServer
;
public
GameServer
getGameServer
()
{
return
gameServer
;
}
public
TowerScheduleManager
(
GameServer
gameServer
)
{
this
.
gameServer
=
gameServer
;
this
.
load
();
}
private
TowerScheduleConfig
towerScheduleConfig
;
public
synchronized
void
load
(){
try
(
FileReader
fileReader
=
new
FileReader
(
Grasscutter
.
getConfig
().
DATA_FOLDER
+
"TowerSchedule.json"
))
{
towerScheduleConfig
=
Grasscutter
.
getGsonFactory
().
fromJson
(
fileReader
,
TowerScheduleConfig
.
class
);
}
catch
(
Exception
e
)
{
Grasscutter
.
getLogger
().
error
(
"Unable to load tower schedule config."
,
e
);
}
}
public
TowerScheduleConfig
getTowerScheduleConfig
()
{
return
towerScheduleConfig
;
}
public
TowerScheduleData
getCurrentTowerScheduleData
(){
var
data
=
GameData
.
getTowerScheduleDataMap
().
get
(
towerScheduleConfig
.
getScheduleId
());
if
(
data
==
null
){
Grasscutter
.
getLogger
().
error
(
"Could not get current tower schedule data by config:{}"
,
towerScheduleConfig
);
}
return
data
;
}
public
List
<
Integer
>
getScheduleFloors
()
{
return
getCurrentTowerScheduleData
().
getSchedules
().
get
(
0
).
getFloorList
();
}
public
int
getNextFloorId
(
int
floorId
){
var
entranceFloors
=
getCurrentTowerScheduleData
().
getEntranceFloorId
();
var
nextId
=
0
;
// find in entrance floors first
for
(
int
i
=
0
;
i
<
entranceFloors
.
size
()-
1
;
i
++){
if
(
floorId
==
entranceFloors
.
get
(
i
)){
nextId
=
entranceFloors
.
get
(
i
+
1
);
}
}
if
(
nextId
!=
0
){
return
nextId
;
}
var
scheduleFloors
=
getScheduleFloors
();
// find in schedule floors
for
(
int
i
=
0
;
i
<
scheduleFloors
.
size
()-
1
;
i
++){
if
(
floorId
==
scheduleFloors
.
get
(
i
)){
nextId
=
scheduleFloors
.
get
(
i
+
1
);
}
}
return
nextId
;
}
public
Integer
getLastEntranceFloor
()
{
return
getCurrentTowerScheduleData
().
getEntranceFloorId
().
get
(
getCurrentTowerScheduleData
().
getEntranceFloorId
().
size
()-
1
);
}
}
src/main/java/emu/grasscutter/game/world/Scene.java
View file @
0bfa1fa0
...
...
@@ -385,27 +385,7 @@ public class Scene {
}
// Sanity check
if
(
target
.
getFightProperties
()
==
null
)
{
return
;
}
// Lose hp
target
.
addFightProperty
(
FightProperty
.
FIGHT_PROP_CUR_HP
,
-
result
.
getDamage
());
// Check if dead
boolean
isDead
=
false
;
if
(
target
.
getFightProperty
(
FightProperty
.
FIGHT_PROP_CUR_HP
)
<=
0
f
)
{
target
.
setFightProperty
(
FightProperty
.
FIGHT_PROP_CUR_HP
,
0
f
);
isDead
=
true
;
}
// Packets
this
.
broadcastPacket
(
new
PacketEntityFightPropUpdateNotify
(
target
,
FightProperty
.
FIGHT_PROP_CUR_HP
));
// Check if dead
if
(
isDead
)
{
this
.
killEntity
(
target
,
result
.
getAttackerId
());
}
target
.
damage
(
result
.
getDamage
(),
result
.
getAttackerId
());
}
public
void
killEntity
(
GameEntity
target
,
int
attackerId
)
{
...
...
src/main/java/emu/grasscutter/scripts/SceneScriptManager.java
View file @
0bfa1fa0
...
...
@@ -90,6 +90,10 @@ public class SceneScriptManager {
return
config
;
}
public
SceneGroup
getCurrentGroup
()
{
return
currentGroup
;
}
public
List
<
SceneBlock
>
getBlocks
()
{
return
blocks
;
}
...
...
@@ -237,16 +241,16 @@ public class SceneScriptManager {
for
(
SceneSuite
suite
:
group
.
suites
)
{
suite
.
sceneMonsters
=
new
ArrayList
<>(
suite
.
monsters
.
size
());
for
(
int
id
:
suite
.
monsters
)
{
try
{
SceneMonster
monster
=
(
SceneMonster
)
map
.
get
(
id
);
if
(
monster
!=
null
)
{
suite
.
sceneMonsters
.
add
(
monster
);
suite
.
monsters
.
forEach
(
id
->
{
Object
objEntry
=
map
.
get
(
id
.
intValue
());
if
(
objEntry
instanceof
Map
.
Entry
<?,?>
monsterEntry
)
{
Object
monster
=
monsterEntry
.
getValue
();
if
(
monster
instanceof
SceneMonster
sceneMonster
){
suite
.
sceneMonsters
.
add
(
sceneMonster
);
}
}
catch
(
Exception
e
)
{
continue
;
}
}
});
suite
.
sceneGadgets
=
new
ArrayList
<>(
suite
.
gadgets
.
size
());
for
(
int
id
:
suite
.
gadgets
)
{
try
{
...
...
@@ -320,13 +324,15 @@ public class SceneScriptManager {
}
public
void
spawnMonstersInGroup
(
SceneGroup
group
,
int
suiteIndex
)
{
this
.
currentGroup
=
group
;
this
.
monsterSceneLimit
=
0
;
var
suite
=
group
.
getSuiteByIndex
(
suiteIndex
);
if
(
suite
==
null
){
return
;
}
suite
.
sceneMonsters
.
forEach
(
mob
->
spawnMonstersInGroup
(
group
,
mob
));
if
(
suite
.
sceneMonsters
.
size
()
>
0
){
this
.
currentGroup
=
group
;
this
.
monsterSceneLimit
=
0
;
suite
.
sceneMonsters
.
forEach
(
mob
->
spawnMonstersInGroup
(
group
,
mob
));
}
}
public
void
spawnMonstersInGroup
(
SceneGroup
group
)
{
...
...
@@ -401,6 +407,7 @@ public class SceneScriptManager {
spawnMonstersInGroup
(
this
.
currentGroup
,
this
.
currentGroup
.
monsters
.
get
(
this
.
monsterOrders
.
poll
()));
}
else
if
(
this
.
monsterAlive
.
get
()
==
0
){
// spawn the last turn of monsters
//callEvent(EventType.EVENT_MONSTER_TIDE_DIE, new ScriptArgs());
while
(!
this
.
monsterOrders
.
isEmpty
()){
spawnMonstersInGroup
(
this
.
currentGroup
,
this
.
currentGroup
.
monsters
.
get
(
this
.
monsterOrders
.
poll
()));
}
...
...
src/main/java/emu/grasscutter/scripts/ScriptLib.java
View file @
0bfa1fa0
...
...
@@ -118,7 +118,7 @@ public class ScriptLib {
challengeIndex
,
groupId
,
ordersConfigId
,
tideCount
,
sceneLimit
,
param6
);
SceneGroup
group
=
getSceneScriptManager
().
getGroupById
(
groupId
);
if
(
group
==
null
||
group
.
monsters
==
null
)
{
return
1
;
}
...
...
@@ -136,8 +136,7 @@ public class ScriptLib {
if
(
group
==
null
||
group
.
monsters
==
null
)
{
return
1
;
}
// TODO just spawn all from group for now
this
.
getSceneScriptManager
().
spawnMonstersInGroup
(
group
,
suite
);
return
0
;
...
...
@@ -159,7 +158,13 @@ public class ScriptLib {
if
(
group
==
null
||
group
.
monsters
==
null
)
{
return
1
;
}
if
(
getSceneScriptManager
().
getScene
().
getChallenge
()
!=
null
&&
getSceneScriptManager
().
getScene
().
getChallenge
().
inProgress
())
{
return
0
;
}
DungeonChallenge
challenge
=
new
DungeonChallenge
(
getSceneScriptManager
().
getScene
(),
group
);
challenge
.
setChallengeId
(
challengeId
);
challenge
.
setChallengeIndex
(
challengeIndex
);
...
...
@@ -249,7 +254,7 @@ public class ScriptLib {
var1
);
return
(
int
)
getSceneScriptManager
().
getScene
().
getEntities
().
values
().
stream
()
.
filter
(
e
->
e
instanceof
EntityMonster
)
.
filter
(
e
->
e
instanceof
EntityMonster
&&
e
.
getGroupId
()
==
getSceneScriptManager
().
getCurrentGroup
().
id
)
.
count
();
}
public
int
SetMonsterBattleByGroup
(
int
var1
,
int
var2
,
int
var3
){
...
...
@@ -266,13 +271,11 @@ public class ScriptLib {
return
0
;
}
// 8-1
public
int
GetGroupVariableValueByGroup
(
int
var1
,
String
var2
,
int
var3
){
logger
.
debug
(
"[LUA] Call GetGroupVariableValueByGroup with {},{}
,{}
"
,
var1
,
var2
,
var3
);
public
int
GetGroupVariableValueByGroup
(
String
name
,
int
groupId
){
logger
.
debug
(
"[LUA] Call GetGroupVariableValueByGroup with {},{}"
,
name
,
groupId
);
//TODO
return
getSceneScriptManager
().
getVariables
().
getOrDefault
(
var2
,
0
);
return
getSceneScriptManager
().
getVariables
().
getOrDefault
(
name
,
0
);
}
public
int
SetIsAllowUseSkill
(
int
canUse
,
int
var2
){
...
...
@@ -299,4 +302,11 @@ public class ScriptLib {
return
0
;
}
public
int
SetGroupVariableValueByGroup
(
String
key
,
int
value
,
int
groupId
){
logger
.
debug
(
"[LUA] Call SetGroupVariableValueByGroup with {},{},{}"
,
key
,
value
,
groupId
);
return
0
;
}
}
src/main/java/emu/grasscutter/server/game/GameServer.java
View file @
0bfa1fa0
...
...
@@ -15,6 +15,7 @@ import emu.grasscutter.game.managers.InventoryManager;
import
emu.grasscutter.game.managers.MultiplayerManager
;
import
emu.grasscutter.game.player.Player
;
import
emu.grasscutter.game.shop.ShopManager
;
import
emu.grasscutter.game.tower.TowerScheduleManager
;
import
emu.grasscutter.game.world.World
;
import
emu.grasscutter.net.packet.PacketHandler
;
import
emu.grasscutter.net.proto.SocialDetailOuterClass.SocialDetail
;
...
...
@@ -54,6 +55,7 @@ public final class GameServer extends KcpServer {
private
final
DropManager
dropManager
;
private
final
CombineManger
combineManger
;
private
final
TowerScheduleManager
towerScheduleManager
;
public
GameServer
()
{
this
(
new
InetSocketAddress
(
...
...
@@ -82,7 +84,7 @@ public final class GameServer extends KcpServer {
this
.
dropManager
=
new
DropManager
(
this
);
this
.
expeditionManager
=
new
ExpeditionManager
(
this
);
this
.
combineManger
=
new
CombineManger
(
this
);
this
.
towerScheduleManager
=
new
TowerScheduleManager
(
this
);
// Hook into shutdown event.
Runtime
.
getRuntime
().
addShutdownHook
(
new
Thread
(
this
::
onServerShutdown
));
}
...
...
@@ -139,6 +141,10 @@ public final class GameServer extends KcpServer {
return
this
.
combineManger
;
}
public
TowerScheduleManager
getTowerScheduleManager
()
{
return
towerScheduleManager
;
}
public
TaskMap
getTaskMap
()
{
return
this
.
taskMap
;
}
...
...
src/main/java/emu/grasscutter/server/packet/recv/HandlerAbilityInvocationsNotify.java
View file @
0bfa1fa0
...
...
@@ -6,6 +6,7 @@ import emu.grasscutter.net.proto.AbilityInvocationsNotifyOuterClass.AbilityInvoc
import
emu.grasscutter.net.proto.AbilityInvokeEntryOuterClass.AbilityInvokeEntry
;
import
emu.grasscutter.net.packet.PacketHandler
;
import
emu.grasscutter.server.game.GameSession
;
import
emu.grasscutter.utils.Utils
;
@Opcodes
(
PacketOpcodes
.
AbilityInvocationsNotify
)
public
class
HandlerAbilityInvocationsNotify
extends
PacketHandler
{
...
...
@@ -15,13 +16,9 @@ public class HandlerAbilityInvocationsNotify extends PacketHandler {
AbilityInvocationsNotify
notif
=
AbilityInvocationsNotify
.
parseFrom
(
payload
);
for
(
AbilityInvokeEntry
entry
:
notif
.
getInvokesList
())
{
//System.out.println(entry.getArgumentType() + ": " + Utils.bytesToHex(entry.getAbilityData().toByteArray())
);
session
.
getPlayer
().
getAbilityManager
().
onAbilityInvoke
(
entry
);
session
.
getPlayer
().
getAbilityInvokeHandler
().
addEntry
(
entry
.
getForwardType
(),
entry
);
}
if
(
notif
.
getInvokesList
().
size
()
>
0
)
{
session
.
getPlayer
().
getAbilityInvokeHandler
().
update
(
session
.
getPlayer
());
}
}
}
src/main/java/emu/grasscutter/server/packet/recv/HandlerClientAbilityInitFinishNotify.java
View file @
0bfa1fa0
...
...
@@ -6,6 +6,7 @@ import emu.grasscutter.net.proto.AbilityInvokeEntryOuterClass.AbilityInvokeEntry
import
emu.grasscutter.net.proto.ClientAbilityInitFinishNotifyOuterClass.ClientAbilityInitFinishNotify
;
import
emu.grasscutter.net.packet.PacketHandler
;
import
emu.grasscutter.server.game.GameSession
;
import
emu.grasscutter.utils.Utils
;
@Opcodes
(
PacketOpcodes
.
ClientAbilityInitFinishNotify
)
public
class
HandlerClientAbilityInitFinishNotify
extends
PacketHandler
{
...
...
@@ -15,6 +16,7 @@ public class HandlerClientAbilityInitFinishNotify extends PacketHandler {
ClientAbilityInitFinishNotify
notif
=
ClientAbilityInitFinishNotify
.
parseFrom
(
payload
);
for
(
AbilityInvokeEntry
entry
:
notif
.
getInvokesList
())
{
session
.
getPlayer
().
getAbilityManager
().
onAbilityInvoke
(
entry
);
session
.
getPlayer
().
getClientAbilityInitFinishHandler
().
addEntry
(
entry
.
getForwardType
(),
entry
);
}
...
...
src/main/java/emu/grasscutter/server/packet/recv/HandlerCombatInvocationsNotify.java
View file @
0bfa1fa0
...
...
@@ -74,14 +74,6 @@ public class HandlerCombatInvocationsNotify extends PacketHandler {
session
.
getPlayer
().
getCombatInvokeHandler
().
addEntry
(
entry
.
getForwardType
(),
entry
);
}
if
(
notif
.
getInvokeListList
().
size
()
>
0
)
{
session
.
getPlayer
().
getCombatInvokeHandler
().
update
(
session
.
getPlayer
());
}
// Handle attack results last
while
(!
session
.
getPlayer
().
getAttackResults
().
isEmpty
())
{
session
.
getPlayer
().
getScene
().
handleAttack
(
session
.
getPlayer
().
getAttackResults
().
poll
());
}
}
private
void
handleFallOnGround
(
GameSession
session
,
GameEntity
entity
,
MotionState
motionState
)
{
...
...
src/main/java/emu/grasscutter/server/packet/recv/HandlerEvtCreateGadgetNotify.java
View file @
0bfa1fa0
...
...
@@ -14,11 +14,6 @@ public class HandlerEvtCreateGadgetNotify extends PacketHandler {
public
void
handle
(
GameSession
session
,
byte
[]
header
,
byte
[]
payload
)
throws
Exception
{
EvtCreateGadgetNotify
notify
=
EvtCreateGadgetNotify
.
parseFrom
(
payload
);
// Dont handle in singleplayer
if
(!
session
.
getPlayer
().
getWorld
().
isMultiplayer
())
{
return
;
}
// Sanity check - dont add duplicate entities
if
(
session
.
getPlayer
().
getScene
().
getEntityById
(
notify
.
getEntityId
())
!=
null
)
{
return
;
...
...
src/main/java/emu/grasscutter/server/packet/recv/HandlerEvtDestroyGadgetNotify.java
View file @
0bfa1fa0
...
...
@@ -12,11 +12,6 @@ public class HandlerEvtDestroyGadgetNotify extends PacketHandler {
@Override
public
void
handle
(
GameSession
session
,
byte
[]
header
,
byte
[]
payload
)
throws
Exception
{
EvtDestroyGadgetNotify
notify
=
EvtDestroyGadgetNotify
.
parseFrom
(
payload
);
// Dont handle in singleplayer
if
(!
session
.
getPlayer
().
getWorld
().
isMultiplayer
())
{
return
;
}
session
.
getPlayer
().
getScene
().
onPlayerDestroyGadget
(
notify
.
getEntityId
());
}
...
...
src/main/java/emu/grasscutter/server/packet/recv/HandlerSetEntityClientDataNotify.java
View file @
0bfa1fa0
...
...
@@ -23,7 +23,7 @@ public class HandlerSetEntityClientDataNotify extends PacketHandler {
BasePacket
packet
=
new
BasePacket
(
PacketOpcodes
.
SetEntityClientDataNotify
,
true
);
packet
.
setData
(
notif
);
session
.
getPlayer
().
getScene
().
broadcastPacket
ToOthers
(
session
.
getPlayer
(),
packet
);
session
.
getPlayer
().
getScene
().
broadcastPacket
(
packet
);
}
}
src/main/java/emu/grasscutter/server/packet/recv/HandlerSetPlayerBornDataReq.java
View file @
0bfa1fa0
...
...
@@ -62,7 +62,7 @@ public class HandlerSetPlayerBornDataReq extends PacketHandler {
// Create avatar
if
(
player
.
getAvatars
().
getAvatarCount
()
==
0
)
{
Avatar
mainCharacter
=
new
Avatar
(
avatarId
);
mainCharacter
.
setSkillDepot
(
GameData
.
getAvatarSkillDepotDataMap
().
get
(
startingSkillDepot
));
mainCharacter
.
setSkillDepot
Data
(
GameData
.
getAvatarSkillDepotDataMap
().
get
(
startingSkillDepot
));
player
.
addAvatar
(
mainCharacter
);
player
.
setMainCharacterId
(
avatarId
);
player
.
setHeadImage
(
avatarId
);
...
...
src/main/java/emu/grasscutter/server/packet/recv/HandlerTowerAllDataReq.java
View file @
0bfa1fa0
...
...
@@ -11,7 +11,10 @@ public class HandlerTowerAllDataReq extends PacketHandler {
@Override
public
void
handle
(
GameSession
session
,
byte
[]
header
,
byte
[]
payload
)
throws
Exception
{
session
.
send
(
new
PacketTowerAllDataRsp
());
session
.
send
(
new
PacketTowerAllDataRsp
(
session
.
getServer
().
getTowerScheduleManager
(),
session
.
getPlayer
().
getTowerManager
()
));
}
}
src/main/java/emu/grasscutter/server/packet/recv/HandlerUnionCmdNotify.java
View file @
0bfa1fa0
...
...
@@ -15,5 +15,14 @@ public class HandlerUnionCmdNotify extends PacketHandler {
for
(
UnionCmd
cmd
:
req
.
getCmdListList
())
{
session
.
getServer
().
getPacketHandler
().
handle
(
session
,
cmd
.
getMessageId
(),
EMPTY_BYTE_ARRAY
,
cmd
.
getBody
().
toByteArray
());
}
// Update
session
.
getPlayer
().
getCombatInvokeHandler
().
update
(
session
.
getPlayer
());
session
.
getPlayer
().
getAbilityInvokeHandler
().
update
(
session
.
getPlayer
());
// Handle attack results last
while
(!
session
.
getPlayer
().
getAttackResults
().
isEmpty
())
{
session
.
getPlayer
().
getScene
().
handleAttack
(
session
.
getPlayer
().
getAttackResults
().
poll
());
}
}
}
src/main/java/emu/grasscutter/server/packet/send/PacketDungeonSettleNotify.java
View file @
0bfa1fa0
...
...
@@ -46,7 +46,7 @@ public class PacketDungeonSettleNotify extends BasePacket {
.
setCount
(
1000
)
.
build
())
;
if
(
nextFloorId
>
0
){
if
(
nextFloorId
>
0
&&
canJump
){
towerLevelEndNotify
.
setNextFloorId
(
nextFloorId
);
}
...
...
Prev
1
2
3
Next
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