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
9a0a15a4
Commit
9a0a15a4
authored
May 08, 2022
by
HotaruYS
Committed by
GitHub
May 08, 2022
Browse files
Merge branch 'development' into patch-3
parents
beea95fd
5d1f4957
Changes
46
Hide whitespace changes
Inline
Side-by-side
build.gradle
View file @
9a0a15a4
...
@@ -70,7 +70,7 @@ dependencies {
...
@@ -70,7 +70,7 @@ dependencies {
implementation
group:
'io.netty'
,
name:
'netty-all'
,
version:
'4.1.71.Final'
implementation
group:
'io.netty'
,
name:
'netty-all'
,
version:
'4.1.71.Final'
implementation
group:
'com.google.code.gson'
,
name:
'gson'
,
version:
'2.
8.8
'
implementation
group:
'com.google.code.gson'
,
name:
'gson'
,
version:
'2.
9.0
'
implementation
group:
'com.google.protobuf'
,
name:
'protobuf-java'
,
version:
'3.18.2'
implementation
group:
'com.google.protobuf'
,
name:
'protobuf-java'
,
version:
'3.18.2'
implementation
group:
'org.reflections'
,
name:
'reflections'
,
version:
'0.10.2'
implementation
group:
'org.reflections'
,
name:
'reflections'
,
version:
'0.10.2'
...
...
data/TowerSchedule.json
0 → 100644
View file @
9a0a15a4
{
"scheduleId"
:
1
,
"scheduleStartTime"
:
"2022-05-01T00:00:00+08:00"
,
"nextScheduleChangeTime"
:
"2022-05-30T00:00:00+08:00"
}
\ No newline at end of file
src/main/java/emu/grasscutter/command/commands/UnlockTowerCommand.java
0 → 100644
View file @
9a0a15a4
package
emu.grasscutter.command.commands
;
import
emu.grasscutter.command.Command
;
import
emu.grasscutter.command.CommandHandler
;
import
emu.grasscutter.game.player.Player
;
import
emu.grasscutter.game.tower.TowerLevelRecord
;
import
java.util.List
;
import
static
emu
.
grasscutter
.
utils
.
Language
.
translate
;
@Command
(
label
=
"unlocktower"
,
usage
=
"unlocktower"
,
aliases
=
{
"ut"
},
description
=
"Unlock all levels of tower"
,
permission
=
"player.tower"
)
public
class
UnlockTowerCommand
implements
CommandHandler
{
@Override
public
void
execute
(
Player
sender
,
Player
targetPlayer
,
List
<
String
>
args
)
{
unlockFloor
(
sender
,
sender
.
getServer
().
getTowerScheduleManager
()
.
getCurrentTowerScheduleData
().
getEntranceFloorId
());
unlockFloor
(
sender
,
sender
.
getServer
().
getTowerScheduleManager
()
.
getScheduleFloors
());
CommandHandler
.
sendMessage
(
sender
,
translate
(
"commands.tower.unlock_done"
));
}
public
void
unlockFloor
(
Player
player
,
List
<
Integer
>
floors
){
floors
.
stream
()
.
filter
(
id
->
!
player
.
getTowerManager
().
getRecordMap
().
containsKey
(
id
))
.
forEach
(
id
->
player
.
getTowerManager
().
getRecordMap
().
put
(
id
,
new
TowerLevelRecord
(
id
)));
}
}
src/main/java/emu/grasscutter/data/GameData.java
View file @
9a0a15a4
...
@@ -9,6 +9,8 @@ import java.util.Map;
...
@@ -9,6 +9,8 @@ import java.util.Map;
import
emu.grasscutter.Grasscutter
;
import
emu.grasscutter.Grasscutter
;
import
emu.grasscutter.utils.Utils
;
import
emu.grasscutter.utils.Utils
;
import
emu.grasscutter.data.custom.AbilityEmbryoEntry
;
import
emu.grasscutter.data.custom.AbilityEmbryoEntry
;
import
emu.grasscutter.data.custom.AbilityModifier
;
import
emu.grasscutter.data.custom.AbilityModifierEntry
;
import
emu.grasscutter.data.custom.OpenConfigEntry
;
import
emu.grasscutter.data.custom.OpenConfigEntry
;
import
emu.grasscutter.data.custom.ScenePointEntry
;
import
emu.grasscutter.data.custom.ScenePointEntry
;
import
emu.grasscutter.data.def.*
;
import
emu.grasscutter.data.def.*
;
...
@@ -22,6 +24,7 @@ public class GameData {
...
@@ -22,6 +24,7 @@ public class GameData {
// BinOutputs
// BinOutputs
private
static
final
Int2ObjectMap
<
String
>
abilityHashes
=
new
Int2ObjectOpenHashMap
<>();
private
static
final
Int2ObjectMap
<
String
>
abilityHashes
=
new
Int2ObjectOpenHashMap
<>();
private
static
final
Map
<
String
,
AbilityEmbryoEntry
>
abilityEmbryos
=
new
HashMap
<>();
private
static
final
Map
<
String
,
AbilityEmbryoEntry
>
abilityEmbryos
=
new
HashMap
<>();
private
static
final
Map
<
String
,
AbilityModifierEntry
>
abilityModifiers
=
new
HashMap
<>();
private
static
final
Map
<
String
,
OpenConfigEntry
>
openConfigEntries
=
new
HashMap
<>();
private
static
final
Map
<
String
,
OpenConfigEntry
>
openConfigEntries
=
new
HashMap
<>();
private
static
final
Map
<
String
,
ScenePointEntry
>
scenePointEntries
=
new
HashMap
<>();
private
static
final
Map
<
String
,
ScenePointEntry
>
scenePointEntries
=
new
HashMap
<>();
...
@@ -70,6 +73,7 @@ public class GameData {
...
@@ -70,6 +73,7 @@ public class GameData {
private
static
final
Int2ObjectMap
<
RewardPreviewData
>
rewardPreviewDataMap
=
new
Int2ObjectOpenHashMap
<>();
private
static
final
Int2ObjectMap
<
RewardPreviewData
>
rewardPreviewDataMap
=
new
Int2ObjectOpenHashMap
<>();
private
static
final
Int2ObjectMap
<
TowerFloorData
>
towerFloorDataMap
=
new
Int2ObjectOpenHashMap
<>();
private
static
final
Int2ObjectMap
<
TowerFloorData
>
towerFloorDataMap
=
new
Int2ObjectOpenHashMap
<>();
private
static
final
Int2ObjectMap
<
TowerLevelData
>
towerLevelDataMap
=
new
Int2ObjectOpenHashMap
<>();
private
static
final
Int2ObjectMap
<
TowerLevelData
>
towerLevelDataMap
=
new
Int2ObjectOpenHashMap
<>();
private
static
final
Int2ObjectMap
<
TowerScheduleData
>
towerScheduleDataMap
=
new
Int2ObjectOpenHashMap
<>();
// Cache
// Cache
private
static
Map
<
Integer
,
List
<
Integer
>>
fetters
=
new
HashMap
<>();
private
static
Map
<
Integer
,
List
<
Integer
>>
fetters
=
new
HashMap
<>();
...
@@ -101,6 +105,10 @@ public class GameData {
...
@@ -101,6 +105,10 @@ public class GameData {
return
abilityEmbryos
;
return
abilityEmbryos
;
}
}
public
static
Map
<
String
,
AbilityModifierEntry
>
getAbilityModifiers
()
{
return
abilityModifiers
;
}
public
static
Map
<
String
,
OpenConfigEntry
>
getOpenConfigEntries
()
{
public
static
Map
<
String
,
OpenConfigEntry
>
getOpenConfigEntries
()
{
return
openConfigEntries
;
return
openConfigEntries
;
}
}
...
@@ -320,4 +328,7 @@ public class GameData {
...
@@ -320,4 +328,7 @@ public class GameData {
public
static
Int2ObjectMap
<
TowerLevelData
>
getTowerLevelDataMap
(){
public
static
Int2ObjectMap
<
TowerLevelData
>
getTowerLevelDataMap
(){
return
towerLevelDataMap
;
return
towerLevelDataMap
;
}
}
public
static
Int2ObjectMap
<
TowerScheduleData
>
getTowerScheduleDataMap
(){
return
towerScheduleDataMap
;
}
}
}
src/main/java/emu/grasscutter/data/ResourceLoader.java
View file @
9a0a15a4
...
@@ -18,6 +18,11 @@ import emu.grasscutter.Grasscutter;
...
@@ -18,6 +18,11 @@ import emu.grasscutter.Grasscutter;
import
emu.grasscutter.data.common.PointData
;
import
emu.grasscutter.data.common.PointData
;
import
emu.grasscutter.data.common.ScenePointConfig
;
import
emu.grasscutter.data.common.ScenePointConfig
;
import
emu.grasscutter.data.custom.AbilityEmbryoEntry
;
import
emu.grasscutter.data.custom.AbilityEmbryoEntry
;
import
emu.grasscutter.data.custom.AbilityModifier
;
import
emu.grasscutter.data.custom.AbilityModifier.AbilityConfigData
;
import
emu.grasscutter.data.custom.AbilityModifier.AbilityModifierAction
;
import
emu.grasscutter.data.custom.AbilityModifier.AbilityModifierActionType
;
import
emu.grasscutter.data.custom.AbilityModifierEntry
;
import
emu.grasscutter.data.custom.OpenConfigEntry
;
import
emu.grasscutter.data.custom.OpenConfigEntry
;
import
emu.grasscutter.data.custom.ScenePointEntry
;
import
emu.grasscutter.data.custom.ScenePointEntry
;
import
emu.grasscutter.game.world.SpawnDataEntry
;
import
emu.grasscutter.game.world.SpawnDataEntry
;
...
@@ -47,6 +52,7 @@ public class ResourceLoader {
...
@@ -47,6 +52,7 @@ public class ResourceLoader {
// Load ability lists
// Load ability lists
loadAbilityEmbryos
();
loadAbilityEmbryos
();
loadOpenConfig
();
loadOpenConfig
();
loadAbilityModifiers
();
// Load resources
// Load resources
loadResources
();
loadResources
();
// Process into depots
// Process into depots
...
@@ -244,6 +250,69 @@ public class ResourceLoader {
...
@@ -244,6 +250,69 @@ public class ResourceLoader {
}
}
}
}
private
static
void
loadAbilityModifiers
()
{
// Load from BinOutput
File
folder
=
new
File
(
Utils
.
toFilePath
(
Grasscutter
.
getConfig
().
RESOURCE_FOLDER
+
"BinOutput/Ability/Temp/AvatarAbilities/"
));
File
[]
files
=
folder
.
listFiles
();
if
(
files
==
null
)
{
Grasscutter
.
getLogger
().
error
(
"Error loading ability modifiers: no files found in "
+
folder
.
getAbsolutePath
());
return
;
}
for
(
File
file
:
files
)
{
List
<
AbilityConfigData
>
abilityConfigList
=
null
;
try
(
FileReader
fileReader
=
new
FileReader
(
file
))
{
abilityConfigList
=
Grasscutter
.
getGsonFactory
().
fromJson
(
fileReader
,
TypeToken
.
getParameterized
(
Collection
.
class
,
AbilityConfigData
.
class
).
getType
());
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
continue
;
}
for
(
AbilityConfigData
data
:
abilityConfigList
)
{
if
(
data
.
Default
.
modifiers
==
null
||
data
.
Default
.
modifiers
.
size
()
==
0
)
{
continue
;
}
AbilityModifierEntry
modifierEntry
=
new
AbilityModifierEntry
(
data
.
Default
.
abilityName
);
for
(
Entry
<
String
,
AbilityModifier
>
entry
:
data
.
Default
.
modifiers
.
entrySet
())
{
AbilityModifier
modifier
=
entry
.
getValue
();
// Stare.
if
(
modifier
.
onAdded
!=
null
)
{
for
(
AbilityModifierAction
action
:
modifier
.
onAdded
)
{
if
(
action
.
$type
.
contains
(
"HealHP"
))
{
action
.
type
=
AbilityModifierActionType
.
HealHP
;
modifierEntry
.
getOnAdded
().
add
(
action
);
}
}
}
if
(
modifier
.
onThinkInterval
!=
null
)
{
for
(
AbilityModifierAction
action
:
modifier
.
onThinkInterval
)
{
if
(
action
.
$type
.
contains
(
"HealHP"
))
{
action
.
type
=
AbilityModifierActionType
.
HealHP
;
modifierEntry
.
getOnThinkInterval
().
add
(
action
);
}
}
}
if
(
modifier
.
onRemoved
!=
null
)
{
for
(
AbilityModifierAction
action
:
modifier
.
onRemoved
)
{
if
(
action
.
$type
.
contains
(
"HealHP"
))
{
action
.
type
=
AbilityModifierActionType
.
HealHP
;
modifierEntry
.
getOnRemoved
().
add
(
action
);
}
}
}
}
GameData
.
getAbilityModifiers
().
put
(
modifierEntry
.
getName
(),
modifierEntry
);
}
}
}
private
static
void
loadSpawnData
()
{
private
static
void
loadSpawnData
()
{
// Read from cached file if exists
// Read from cached file if exists
File
spawnDataEntries
=
new
File
(
Grasscutter
.
getConfig
().
DATA_FOLDER
+
"Spawns.json"
);
File
spawnDataEntries
=
new
File
(
Grasscutter
.
getConfig
().
DATA_FOLDER
+
"Spawns.json"
);
...
...
src/main/java/emu/grasscutter/data/custom/AbilityModifier.java
0 → 100644
View file @
9a0a15a4
package
emu.grasscutter.data.custom
;
import
java.util.Map
;
public
class
AbilityModifier
{
public
AbilityModifierAction
[]
onAdded
;
public
AbilityModifierAction
[]
onThinkInterval
;
public
AbilityModifierAction
[]
onRemoved
;
public
static
class
AbilityConfigData
{
public
AbilityData
Default
;
}
public
static
class
AbilityData
{
public
String
abilityName
;
public
Map
<
String
,
AbilityModifier
>
modifiers
;
}
public
static
class
AbilityModifierAction
{
public
String
$type
;
public
AbilityModifierActionType
type
;
public
String
target
;
public
AbilityModifierValue
amount
;
public
AbilityModifierValue
amountByTargetCurrentHPRatio
;
}
public
static
class
AbilityModifierValue
{
public
boolean
isFormula
;
public
boolean
isDynamic
;
public
String
dynamicKey
;
}
public
enum
AbilityModifierActionType
{
HealHP
,
ApplyModifier
,
LoseHP
;
}
}
src/main/java/emu/grasscutter/data/custom/AbilityModifierEntry.java
0 → 100644
View file @
9a0a15a4
package
emu.grasscutter.data.custom
;
import
java.util.ArrayList
;
import
java.util.List
;
import
emu.grasscutter.data.custom.AbilityModifier.AbilityModifierAction
;
public
class
AbilityModifierEntry
{
private
String
name
;
// Custom value
public
List
<
AbilityModifierAction
>
onModifierAdded
;
public
List
<
AbilityModifierAction
>
onThinkInterval
;
public
List
<
AbilityModifierAction
>
onRemoved
;
public
AbilityModifierEntry
(
String
name
)
{
this
.
name
=
name
;
this
.
onModifierAdded
=
new
ArrayList
<>();
this
.
onThinkInterval
=
new
ArrayList
<>();
this
.
onRemoved
=
new
ArrayList
<>();
}
public
String
getName
()
{
return
name
;
}
public
List
<
AbilityModifierAction
>
getOnAdded
()
{
return
onModifierAdded
;
}
public
List
<
AbilityModifierAction
>
getOnThinkInterval
()
{
return
onThinkInterval
;
}
public
List
<
AbilityModifierAction
>
getOnRemoved
()
{
return
onRemoved
;
}
}
src/main/java/emu/grasscutter/data/def/TowerScheduleData.java
0 → 100644
View file @
9a0a15a4
package
emu.grasscutter.data.def
;
import
emu.grasscutter.data.GameResource
;
import
emu.grasscutter.data.ResourceType
;
import
java.util.List
;
@ResourceType
(
name
=
"TowerScheduleExcelConfigData.json"
)
public
class
TowerScheduleData
extends
GameResource
{
private
int
ScheduleId
;
private
List
<
Integer
>
EntranceFloorId
;
private
List
<
ScheduleDetail
>
Schedules
;
private
int
MonthlyLevelConfigId
;
@Override
public
int
getId
()
{
return
ScheduleId
;
}
@Override
public
void
onLoad
()
{
super
.
onLoad
();
this
.
Schedules
=
this
.
Schedules
.
stream
()
.
filter
(
item
->
item
.
getFloorList
().
size
()
>
0
)
.
toList
();
}
public
int
getScheduleId
()
{
return
ScheduleId
;
}
public
void
setScheduleId
(
int
scheduleId
)
{
ScheduleId
=
scheduleId
;
}
public
List
<
Integer
>
getEntranceFloorId
()
{
return
EntranceFloorId
;
}
public
void
setEntranceFloorId
(
List
<
Integer
>
entranceFloorId
)
{
EntranceFloorId
=
entranceFloorId
;
}
public
List
<
ScheduleDetail
>
getSchedules
()
{
return
Schedules
;
}
public
void
setSchedules
(
List
<
ScheduleDetail
>
schedules
)
{
Schedules
=
schedules
;
}
public
int
getMonthlyLevelConfigId
()
{
return
MonthlyLevelConfigId
;
}
public
void
setMonthlyLevelConfigId
(
int
monthlyLevelConfigId
)
{
MonthlyLevelConfigId
=
monthlyLevelConfigId
;
}
public
static
class
ScheduleDetail
{
private
List
<
Integer
>
FloorList
;
public
List
<
Integer
>
getFloorList
()
{
return
FloorList
;
}
public
void
setFloorList
(
List
<
Integer
>
floorList
)
{
FloorList
=
floorList
;
}
}
}
src/main/java/emu/grasscutter/game/ability/AbilityManager.java
0 → 100644
View file @
9a0a15a4
package
emu.grasscutter.game.ability
;
import
com.google.protobuf.InvalidProtocolBufferException
;
import
emu.grasscutter.Grasscutter
;
import
emu.grasscutter.data.GameData
;
import
emu.grasscutter.data.custom.AbilityModifier
;
import
emu.grasscutter.data.custom.AbilityModifier.AbilityModifierAction
;
import
emu.grasscutter.data.custom.AbilityModifier.AbilityModifierActionType
;
import
emu.grasscutter.data.def.ItemData
;
import
emu.grasscutter.data.custom.AbilityModifierEntry
;
import
emu.grasscutter.game.entity.EntityItem
;
import
emu.grasscutter.game.entity.GameEntity
;
import
emu.grasscutter.game.player.Player
;
import
emu.grasscutter.net.proto.AbilityActionGenerateElemBallOuterClass.AbilityActionGenerateElemBall
;
import
emu.grasscutter.net.proto.AbilityInvokeArgumentOuterClass.AbilityInvokeArgument
;
import
emu.grasscutter.net.proto.AbilityInvokeEntryHeadOuterClass.AbilityInvokeEntryHead
;
import
emu.grasscutter.net.proto.AbilityInvokeEntryOuterClass.AbilityInvokeEntry
;
import
emu.grasscutter.net.proto.AbilityMetaModifierChangeOuterClass.AbilityMetaModifierChange
;
import
emu.grasscutter.net.proto.AbilityMetaReInitOverrideMapOuterClass.AbilityMetaReInitOverrideMap
;
import
emu.grasscutter.net.proto.AbilityScalarTypeOuterClass.AbilityScalarType
;
import
emu.grasscutter.net.proto.AbilityScalarValueEntryOuterClass.AbilityScalarValueEntry
;
import
emu.grasscutter.net.proto.ModifierActionOuterClass.ModifierAction
;
import
emu.grasscutter.utils.Position
;
import
emu.grasscutter.utils.Utils
;
public
class
AbilityManager
{
private
Player
player
;
public
AbilityManager
(
Player
player
)
{
this
.
player
=
player
;
}
public
Player
getPlayer
()
{
return
this
.
player
;
}
public
void
onAbilityInvoke
(
AbilityInvokeEntry
invoke
)
throws
Exception
{
//System.out.println(invoke.getArgumentType() + " (" + invoke.getArgumentTypeValue() + "): " + Utils.bytesToHex(invoke.toByteArray()));
switch
(
invoke
.
getArgumentType
())
{
case
ABILITY_META_OVERRIDE_PARAM:
handleOverrideParam
(
invoke
);
break
;
case
ABILITY_META_REINIT_OVERRIDEMAP:
handleReinitOverrideMap
(
invoke
);
break
;
case
ABILITY_META_MODIFIER_CHANGE:
handleModifierChange
(
invoke
);
break
;
case
ABILITY_MIXIN_COST_STAMINA:
handleMixinCostStamina
(
invoke
);
break
;
case
ABILITY_ACTION_GENERATE_ELEM_BALL:
handleGenerateElemBall
(
invoke
);
break
;
default
:
break
;
}
}
private
void
handleOverrideParam
(
AbilityInvokeEntry
invoke
)
throws
Exception
{
GameEntity
entity
=
player
.
getScene
().
getEntityById
(
invoke
.
getEntityId
());
if
(
entity
==
null
)
{
return
;
}
AbilityScalarValueEntry
entry
=
AbilityScalarValueEntry
.
parseFrom
(
invoke
.
getAbilityData
());
entity
.
getMetaOverrideMap
().
put
(
entry
.
getKey
().
getStr
(),
entry
.
getFloatValue
());
}
private
void
handleReinitOverrideMap
(
AbilityInvokeEntry
invoke
)
throws
Exception
{
GameEntity
entity
=
player
.
getScene
().
getEntityById
(
invoke
.
getEntityId
());
if
(
entity
==
null
)
{
return
;
}
AbilityMetaReInitOverrideMap
map
=
AbilityMetaReInitOverrideMap
.
parseFrom
(
invoke
.
getAbilityData
());
for
(
AbilityScalarValueEntry
entry
:
map
.
getOverrideMapList
())
{
entity
.
getMetaOverrideMap
().
put
(
entry
.
getKey
().
getStr
(),
entry
.
getFloatValue
());
}
}
private
void
handleModifierChange
(
AbilityInvokeEntry
invoke
)
throws
Exception
{
GameEntity
target
=
player
.
getScene
().
getEntityById
(
invoke
.
getEntityId
());
if
(
target
==
null
)
{
return
;
}
AbilityInvokeEntryHead
head
=
invoke
.
getHead
();
if
(
head
==
null
)
{
return
;
}
AbilityMetaModifierChange
data
=
AbilityMetaModifierChange
.
parseFrom
(
invoke
.
getAbilityData
());
if
(
data
==
null
)
{
return
;
}
GameEntity
sourceEntity
=
player
.
getScene
().
getEntityById
(
data
.
getApplyEntityId
());
if
(
sourceEntity
==
null
)
{
return
;
}
// This is not how it works but we will keep it for now since healing abilities dont work properly anyways
if
(
data
.
getAction
()
==
ModifierAction
.
ADDED
&&
data
.
getParentAbilityName
()
!=
null
)
{
// Handle add modifier here
String
modifierString
=
data
.
getParentAbilityName
().
getStr
();
AbilityModifierEntry
modifier
=
GameData
.
getAbilityModifiers
().
get
(
modifierString
);
if
(
modifier
!=
null
&&
modifier
.
getOnAdded
().
size
()
>
0
)
{
for
(
AbilityModifierAction
action
:
modifier
.
getOnAdded
())
{
invokeAction
(
action
,
target
,
sourceEntity
);
}
}
// Add to meta modifier list
target
.
getMetaModifiers
().
put
(
head
.
getInstancedModifierId
(),
modifierString
);
}
else
if
(
data
.
getAction
()
==
ModifierAction
.
REMOVED
)
{
String
modifierString
=
target
.
getMetaModifiers
().
get
(
head
.
getInstancedModifierId
());
if
(
modifierString
!=
null
)
{
// Get modifier and call on remove event
AbilityModifierEntry
modifier
=
GameData
.
getAbilityModifiers
().
get
(
modifierString
);
if
(
modifier
!=
null
&&
modifier
.
getOnRemoved
().
size
()
>
0
)
{
for
(
AbilityModifierAction
action
:
modifier
.
getOnRemoved
())
{
invokeAction
(
action
,
target
,
sourceEntity
);
}
}
// Remove from meta modifiers
target
.
getMetaModifiers
().
remove
(
head
.
getInstancedModifierId
());
}
}
}
private
void
handleMixinCostStamina
(
AbilityInvokeEntry
invoke
)
{
// Not the right way of doing this
if
(
Grasscutter
.
getConfig
().
OpenStamina
)
{
// getPlayer().getStaminaManager().updateStamina(getPlayer().getSession(), -450);
// TODO
// set flag in stamina/movement manager that specifies the player is currently using an alternate sprint
}
}
private
void
handleGenerateElemBall
(
AbilityInvokeEntry
invoke
)
throws
InvalidProtocolBufferException
{
AbilityActionGenerateElemBall
action
=
AbilityActionGenerateElemBall
.
parseFrom
(
invoke
.
getAbilityData
());
if
(
action
==
null
)
{
return
;
}
ItemData
itemData
=
GameData
.
getItemDataMap
().
get
(
2024
);
if
(
itemData
==
null
)
{
return
;
// Should never happen
}
EntityItem
energyBall
=
new
EntityItem
(
getPlayer
().
getScene
(),
getPlayer
(),
itemData
,
new
Position
(
action
.
getPos
()),
1
);
energyBall
.
getRotation
().
set
(
action
.
getRot
());
getPlayer
().
getScene
().
addEntity
(
energyBall
);
}
private
void
invokeAction
(
AbilityModifierAction
action
,
GameEntity
target
,
GameEntity
sourceEntity
)
{
switch
(
action
.
type
)
{
case
HealHP
->
{
if
(
action
.
amount
==
null
)
{
return
;
}
float
healAmount
=
0
;
if
(
action
.
amount
.
isDynamic
&&
action
.
amount
.
dynamicKey
!=
null
)
{
healAmount
=
sourceEntity
.
getMetaOverrideMap
().
getOrDefault
(
action
.
amount
.
dynamicKey
,
0
f
);
}
if
(
healAmount
>
0
)
{
target
.
heal
(
healAmount
);
}
}
case
LoseHP
->
{
if
(
action
.
amountByTargetCurrentHPRatio
==
null
)
{
return
;
}
float
damageAmount
=
0
;
if
(
action
.
amount
.
isDynamic
&&
action
.
amount
.
dynamicKey
!=
null
)
{
damageAmount
=
sourceEntity
.
getMetaOverrideMap
().
getOrDefault
(
action
.
amount
.
dynamicKey
,
0
f
);
}
if
(
damageAmount
>
0
)
{
target
.
damage
(
damageAmount
);
}
}
}
}
}
src/main/java/emu/grasscutter/game/avatar/Avatar.java
View file @
9a0a15a4
...
@@ -69,6 +69,7 @@ public class Avatar {
...
@@ -69,6 +69,7 @@ public class Avatar {
@Transient
private
Player
owner
;
@Transient
private
Player
owner
;
@Transient
private
AvatarData
data
;
@Transient
private
AvatarData
data
;
@Transient
private
AvatarSkillDepotData
skillDepot
;
@Transient
private
long
guid
;
// Player unique id
@Transient
private
long
guid
;
// Player unique id
private
int
avatarId
;
// Id of avatar
private
int
avatarId
;
// Id of avatar
...
@@ -103,8 +104,8 @@ public class Avatar {
...
@@ -103,8 +104,8 @@ public class Avatar {
private
int
nameCardRewardId
;
private
int
nameCardRewardId
;
private
int
nameCardId
;
private
int
nameCardId
;
@Deprecated
// Do not use. Morhpia only!
public
Avatar
()
{
public
Avatar
()
{
// Morhpia only!
this
.
equips
=
new
Int2ObjectOpenHashMap
<>();
this
.
equips
=
new
Int2ObjectOpenHashMap
<>();
this
.
fightProp
=
new
Int2FloatOpenHashMap
();
this
.
fightProp
=
new
Int2FloatOpenHashMap
();
this
.
extraAbilityEmbryos
=
new
HashSet
<>();
this
.
extraAbilityEmbryos
=
new
HashSet
<>();
...
@@ -140,7 +141,7 @@ public class Avatar {
...
@@ -140,7 +141,7 @@ public class Avatar {
}
}
// Skill depot
// Skill depot
this
.
setSkillDepot
(
getAvatarData
().
getSkillDepot
());
this
.
setSkillDepot
Data
(
getAvatarData
().
getSkillDepot
());
// Set stats
// Set stats
this
.
recalcStats
();
this
.
recalcStats
();
...
@@ -164,7 +165,8 @@ public class Avatar {
...
@@ -164,7 +165,8 @@ public class Avatar {
}
}
protected
void
setAvatarData
(
AvatarData
data
)
{
protected
void
setAvatarData
(
AvatarData
data
)
{
this
.
data
=
data
;
if
(
this
.
data
!=
null
)
return
;
this
.
data
=
data
;
// Used while loading this from the database
}
}
public
int
getOwnerId
()
{
public
int
getOwnerId
()
{
...
@@ -257,9 +259,19 @@ public class Avatar {
...
@@ -257,9 +259,19 @@ public class Avatar {
return
skillDepotId
;
return
skillDepotId
;
}
}
public
void
setSkillDepot
(
AvatarSkillDepotData
skillDepot
)
{
public
AvatarSkillDepotData
getSkillDepot
()
{
// Set id
return
skillDepot
;
}
protected
void
setSkillDepot
(
AvatarSkillDepotData
skillDepot
)
{
if
(
this
.
skillDepot
!=
null
)
return
;
this
.
skillDepot
=
skillDepot
;
// Used while loading this from the database
}
public
void
setSkillDepotData
(
AvatarSkillDepotData
skillDepot
)
{
// Set id and depot
this
.
skillDepotId
=
skillDepot
.
getId
();
this
.
skillDepotId
=
skillDepot
.
getId
();
this
.
skillDepot
=
skillDepot
;
// Clear, then add skills
// Clear, then add skills
getSkillLevelMap
().
clear
();
getSkillLevelMap
().
clear
();
if
(
skillDepot
.
getEnergySkill
()
>
0
)
{
if
(
skillDepot
.
getEnergySkill
()
>
0
)
{
...
@@ -501,8 +513,8 @@ public class Avatar {
...
@@ -501,8 +513,8 @@ public class Avatar {
// Set energy usage
// Set energy usage
if
(
data
.
getSkillDepot
()
!=
null
&&
data
.
getSkillDepot
().
getEnergySkillData
()
!=
null
)
{
if
(
data
.
getSkillDepot
()
!=
null
&&
data
.
getSkillDepot
().
getEnergySkillData
()
!=
null
)
{
ElementType
element
=
data
.
getSkillDepot
().
getElementType
();
ElementType
element
=
data
.
getSkillDepot
().
getElementType
();
this
.
setFightProperty
(
element
.
getEnergyProp
erty
(),
data
.
getSkillDepot
().
getEnergySkillData
().
getCostElemVal
());
this
.
setFightProperty
(
element
.
get
Max
EnergyProp
(),
data
.
getSkillDepot
().
getEnergySkillData
().
getCostElemVal
());
this
.
setFightProperty
((
element
.
getEnergyProp
erty
().
getId
()
%
70
)
+
1000
,
data
.
getSkillDepot
().
getEnergySkillData
().
getCostElemVal
());
this
.
setFightProperty
((
element
.
get
Max
EnergyProp
().
getId
()
%
70
)
+
1000
,
data
.
getSkillDepot
().
getEnergySkillData
().
getCostElemVal
());
}
}
// Artifacts
// Artifacts
...
...
src/main/java/emu/grasscutter/game/avatar/AvatarStorage.java
View file @
9a0a15a4
...
@@ -5,6 +5,7 @@ import java.util.List;
...
@@ -5,6 +5,7 @@ import java.util.List;
import
emu.grasscutter.data.GameData
;
import
emu.grasscutter.data.GameData
;
import
emu.grasscutter.data.def.AvatarData
;
import
emu.grasscutter.data.def.AvatarData
;
import
emu.grasscutter.data.def.AvatarSkillDepotData
;
import
emu.grasscutter.database.DatabaseHelper
;
import
emu.grasscutter.database.DatabaseHelper
;
import
emu.grasscutter.game.entity.EntityAvatar
;
import
emu.grasscutter.game.entity.EntityAvatar
;
import
emu.grasscutter.game.inventory.GameItem
;
import
emu.grasscutter.game.inventory.GameItem
;
...
@@ -139,12 +140,14 @@ public class AvatarStorage implements Iterable<Avatar> {
...
@@ -139,12 +140,14 @@ public class AvatarStorage implements Iterable<Avatar> {
}
}
AvatarData
avatarData
=
GameData
.
getAvatarDataMap
().
get
(
avatar
.
getAvatarId
());
AvatarData
avatarData
=
GameData
.
getAvatarDataMap
().
get
(
avatar
.
getAvatarId
());
if
(
avatarData
==
null
)
{
AvatarSkillDepotData
skillDepot
=
GameData
.
getAvatarSkillDepotDataMap
().
get
(
avatar
.
getSkillDepotId
());
if
(
avatarData
==
null
||
skillDepot
==
null
)
{
continue
;
continue
;
}
}
// Set ownerships
// Set ownerships
avatar
.
setAvatarData
(
avatarData
);
avatar
.
setAvatarData
(
avatarData
);
avatar
.
setSkillDepot
(
skillDepot
);
avatar
.
setOwner
(
getPlayer
());
avatar
.
setOwner
(
getPlayer
());
// Force recalc of const boosted skills
// Force recalc of const boosted skills
...
...
src/main/java/emu/grasscutter/game/dungeons/TowerDungeonSettleListener.java
View file @
9a0a15a4
...
@@ -12,12 +12,18 @@ public class TowerDungeonSettleListener implements DungeonSettleListener {
...
@@ -12,12 +12,18 @@ public class TowerDungeonSettleListener implements DungeonSettleListener {
scene
.
setAutoCloseTime
(
Utils
.
getCurrentSeconds
()
+
1000
);
scene
.
setAutoCloseTime
(
Utils
.
getCurrentSeconds
()
+
1000
);
var
towerManager
=
scene
.
getPlayers
().
get
(
0
).
getTowerManager
();
var
towerManager
=
scene
.
getPlayers
().
get
(
0
).
getTowerManager
();
towerManager
.
notifyCurLevelRecordChangeWhenDone
();
towerManager
.
notifyCurLevelRecordChangeWhenDone
(
3
);
scene
.
broadcastPacket
(
new
PacketTowerFloorRecordChangeNotify
(
towerManager
.
getCurrentFloorId
()));
scene
.
broadcastPacket
(
new
PacketTowerFloorRecordChangeNotify
(
scene
.
broadcastPacket
(
new
PacketDungeonSettleNotify
(
scene
.
getChallenge
(),
towerManager
.
getCurrentFloorId
(),
true
,
3
,
towerManager
.
canEnterScheduleFloor
()
));
scene
.
broadcastPacket
(
new
PacketDungeonSettleNotify
(
scene
.
getChallenge
(),
towerManager
.
hasNextFloor
(),
towerManager
.
hasNextLevel
(),
towerManager
.
hasNextLevel
(),
towerManager
.
getNextFloorId
()
towerManager
.
hasNextLevel
()
?
0
:
towerManager
.
getNextFloorId
()
));
));
}
}
...
...
src/main/java/emu/grasscutter/game/entity/EntityAvatar.java
View file @
9a0a15a4
...
@@ -17,17 +17,22 @@ import emu.grasscutter.net.proto.AbilityControlBlockOuterClass.AbilityControlBlo
...
@@ -17,17 +17,22 @@ import emu.grasscutter.net.proto.AbilityControlBlockOuterClass.AbilityControlBlo
import
emu.grasscutter.net.proto.AbilityEmbryoOuterClass.AbilityEmbryo
;
import
emu.grasscutter.net.proto.AbilityEmbryoOuterClass.AbilityEmbryo
;
import
emu.grasscutter.net.proto.AbilitySyncStateInfoOuterClass.AbilitySyncStateInfo
;
import
emu.grasscutter.net.proto.AbilitySyncStateInfoOuterClass.AbilitySyncStateInfo
;
import
emu.grasscutter.net.proto.AnimatorParameterValueInfoPairOuterClass.AnimatorParameterValueInfoPair
;
import
emu.grasscutter.net.proto.AnimatorParameterValueInfoPairOuterClass.AnimatorParameterValueInfoPair
;
import
emu.grasscutter.net.proto.ChangeHpReasonOuterClass.ChangeHpReason
;
import
emu.grasscutter.net.proto.EntityAuthorityInfoOuterClass.EntityAuthorityInfo
;
import
emu.grasscutter.net.proto.EntityAuthorityInfoOuterClass.EntityAuthorityInfo
;
import
emu.grasscutter.net.proto.EntityClientDataOuterClass.EntityClientData
;
import
emu.grasscutter.net.proto.EntityClientDataOuterClass.EntityClientData
;
import
emu.grasscutter.net.proto.EntityRendererChangedInfoOuterClass.EntityRendererChangedInfo
;
import
emu.grasscutter.net.proto.EntityRendererChangedInfoOuterClass.EntityRendererChangedInfo
;
import
emu.grasscutter.net.proto.FightPropPairOuterClass.FightPropPair
;
import
emu.grasscutter.net.proto.FightPropPairOuterClass.FightPropPair
;
import
emu.grasscutter.net.proto.PlayerDieTypeOuterClass.PlayerDieType
;
import
emu.grasscutter.net.proto.PlayerDieTypeOuterClass.PlayerDieType
;
import
emu.grasscutter.net.proto.PropChangeReasonOuterClass.PropChangeReason
;
import
emu.grasscutter.net.proto.PropPairOuterClass.PropPair
;
import
emu.grasscutter.net.proto.PropPairOuterClass.PropPair
;
import
emu.grasscutter.net.proto.ProtEntityTypeOuterClass.ProtEntityType
;
import
emu.grasscutter.net.proto.ProtEntityTypeOuterClass.ProtEntityType
;
import
emu.grasscutter.net.proto.SceneAvatarInfoOuterClass.SceneAvatarInfo
;
import
emu.grasscutter.net.proto.SceneAvatarInfoOuterClass.SceneAvatarInfo
;
import
emu.grasscutter.net.proto.SceneEntityAiInfoOuterClass.SceneEntityAiInfo
;
import
emu.grasscutter.net.proto.SceneEntityAiInfoOuterClass.SceneEntityAiInfo
;
import
emu.grasscutter.net.proto.SceneEntityInfoOuterClass.SceneEntityInfo
;
import
emu.grasscutter.net.proto.SceneEntityInfoOuterClass.SceneEntityInfo
;
import
emu.grasscutter.net.proto.VectorOuterClass.Vector
;
import
emu.grasscutter.net.proto.VectorOuterClass.Vector
;
import
emu.grasscutter.server.packet.send.PacketAvatarFightPropUpdateNotify
;
import
emu.grasscutter.server.packet.send.PacketEntityFightPropChangeReasonNotify
;
import
emu.grasscutter.server.packet.send.PacketEntityFightPropUpdateNotify
;
import
emu.grasscutter.utils.Position
;
import
emu.grasscutter.utils.Position
;
import
emu.grasscutter.utils.ProtoHelper
;
import
emu.grasscutter.utils.ProtoHelper
;
import
emu.grasscutter.utils.Utils
;
import
emu.grasscutter.utils.Utils
;
...
@@ -110,6 +115,35 @@ public class EntityAvatar extends GameEntity {
...
@@ -110,6 +115,35 @@ public class EntityAvatar extends GameEntity {
this
.
killedBy
=
killerId
;
this
.
killedBy
=
killerId
;
}
}
@Override
public
float
heal
(
float
amount
)
{
float
healed
=
super
.
heal
(
amount
);
if
(
healed
>
0
f
)
{
getScene
().
broadcastPacket
(
new
PacketEntityFightPropChangeReasonNotify
(
this
,
FightProperty
.
FIGHT_PROP_CUR_HP
,
healed
,
PropChangeReason
.
PROP_CHANGE_ABILITY
,
ChangeHpReason
.
ChangeHpAddAbility
)
);
}
return
healed
;
}
public
void
addEnergy
(
float
amount
)
{
FightProperty
curEnergyProp
=
getAvatar
().
getSkillDepot
().
getElementType
().
getCurEnergyProp
();
FightProperty
maxEnergyProp
=
getAvatar
().
getSkillDepot
().
getElementType
().
getMaxEnergyProp
();
float
curEnergy
=
this
.
getFightProperty
(
curEnergyProp
);
float
maxEnergy
=
this
.
getFightProperty
(
maxEnergyProp
);
float
newEnergy
=
Math
.
min
(
curEnergy
+
amount
,
maxEnergy
);
if
(
newEnergy
!=
curEnergy
)
{
setFightProperty
(
curEnergyProp
,
newEnergy
);
getScene
().
broadcastPacket
(
new
PacketAvatarFightPropUpdateNotify
(
getAvatar
(),
curEnergyProp
));
getScene
().
broadcastPacket
(
new
PacketEntityFightPropChangeReasonNotify
(
this
,
curEnergyProp
,
newEnergy
,
PropChangeReason
.
PROP_CHANGE_ENERGY_BALL
));
}
}
public
SceneAvatarInfo
getSceneAvatarInfo
()
{
public
SceneAvatarInfo
getSceneAvatarInfo
()
{
SceneAvatarInfo
.
Builder
avatarInfo
=
SceneAvatarInfo
.
newBuilder
()
SceneAvatarInfo
.
Builder
avatarInfo
=
SceneAvatarInfo
.
newBuilder
()
.
setUid
(
this
.
getPlayer
().
getUid
())
.
setUid
(
this
.
getPlayer
().
getUid
())
...
@@ -241,5 +275,5 @@ public class EntityAvatar extends GameEntity {
...
@@ -241,5 +275,5 @@ public class EntityAvatar extends GameEntity {
//
//
return
abilityControlBlock
.
build
();
return
abilityControlBlock
.
build
();
}
}
}
}
src/main/java/emu/grasscutter/game/entity/GameEntity.java
View file @
9a0a15a4
package
emu.grasscutter.game.entity
;
package
emu.grasscutter.game.entity
;
import
java.util.HashMap
;
import
java.util.Map
;
import
emu.grasscutter.game.props.FightProperty
;
import
emu.grasscutter.game.props.FightProperty
;
import
emu.grasscutter.game.props.LifeState
;
import
emu.grasscutter.game.props.LifeState
;
import
emu.grasscutter.game.world.Scene
;
import
emu.grasscutter.game.world.Scene
;
...
@@ -9,8 +12,11 @@ import emu.grasscutter.net.proto.MotionInfoOuterClass.MotionInfo;
...
@@ -9,8 +12,11 @@ import emu.grasscutter.net.proto.MotionInfoOuterClass.MotionInfo;
import
emu.grasscutter.net.proto.MotionStateOuterClass.MotionState
;
import
emu.grasscutter.net.proto.MotionStateOuterClass.MotionState
;
import
emu.grasscutter.net.proto.SceneEntityInfoOuterClass.SceneEntityInfo
;
import
emu.grasscutter.net.proto.SceneEntityInfoOuterClass.SceneEntityInfo
;
import
emu.grasscutter.net.proto.VectorOuterClass.Vector
;
import
emu.grasscutter.net.proto.VectorOuterClass.Vector
;
import
emu.grasscutter.server.packet.send.PacketEntityFightPropUpdateNotify
;
import
emu.grasscutter.utils.Position
;
import
emu.grasscutter.utils.Position
;
import
it.unimi.dsi.fastutil.ints.Int2FloatOpenHashMap
;
import
it.unimi.dsi.fastutil.ints.Int2FloatOpenHashMap
;
import
it.unimi.dsi.fastutil.ints.Int2ObjectMap
;
import
it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap
;
public
abstract
class
GameEntity
{
public
abstract
class
GameEntity
{
protected
int
id
;
protected
int
id
;
...
@@ -25,6 +31,10 @@ public abstract class GameEntity {
...
@@ -25,6 +31,10 @@ public abstract class GameEntity {
private
int
lastMoveSceneTimeMs
;
private
int
lastMoveSceneTimeMs
;
private
int
lastMoveReliableSeq
;
private
int
lastMoveReliableSeq
;
// Abilities
private
Map
<
String
,
Float
>
metaOverrideMap
;
private
Int2ObjectMap
<
String
>
metaModifiers
;
public
GameEntity
(
Scene
scene
)
{
public
GameEntity
(
Scene
scene
)
{
this
.
scene
=
scene
;
this
.
scene
=
scene
;
this
.
moveState
=
MotionState
.
MOTION_NONE
;
this
.
moveState
=
MotionState
.
MOTION_NONE
;
...
@@ -54,6 +64,20 @@ public abstract class GameEntity {
...
@@ -54,6 +64,20 @@ public abstract class GameEntity {
return
isAlive
()
?
LifeState
.
LIFE_ALIVE
:
LifeState
.
LIFE_DEAD
;
return
isAlive
()
?
LifeState
.
LIFE_ALIVE
:
LifeState
.
LIFE_DEAD
;
}
}
public
Map
<
String
,
Float
>
getMetaOverrideMap
()
{
if
(
this
.
metaOverrideMap
==
null
)
{
this
.
metaOverrideMap
=
new
HashMap
<>();
}
return
this
.
metaOverrideMap
;
}
public
Int2ObjectMap
<
String
>
getMetaModifiers
()
{
if
(
this
.
metaModifiers
==
null
)
{
this
.
metaModifiers
=
new
Int2ObjectOpenHashMap
<>();
}
return
this
.
metaModifiers
;
}
public
abstract
Int2FloatOpenHashMap
getFightProperties
();
public
abstract
Int2FloatOpenHashMap
getFightProperties
();
public
abstract
Position
getPosition
();
public
abstract
Position
getPosition
();
...
@@ -146,4 +170,53 @@ public abstract class GameEntity {
...
@@ -146,4 +170,53 @@ public abstract class GameEntity {
public
void
setSpawnEntry
(
SpawnDataEntry
spawnEntry
)
{
public
void
setSpawnEntry
(
SpawnDataEntry
spawnEntry
)
{
this
.
spawnEntry
=
spawnEntry
;
this
.
spawnEntry
=
spawnEntry
;
}
}
public
float
heal
(
float
amount
)
{
if
(
this
.
getFightProperties
()
==
null
)
{
return
0
f
;
}
float
curHp
=
getFightProperty
(
FightProperty
.
FIGHT_PROP_CUR_HP
);
float
maxHp
=
getFightProperty
(
FightProperty
.
FIGHT_PROP_MAX_HP
);
if
(
curHp
>=
maxHp
)
{
return
0
f
;
}
float
healed
=
Math
.
min
(
maxHp
-
curHp
,
amount
);
this
.
addFightProperty
(
FightProperty
.
FIGHT_PROP_CUR_HP
,
healed
);
getScene
().
broadcastPacket
(
new
PacketEntityFightPropUpdateNotify
(
this
,
FightProperty
.
FIGHT_PROP_CUR_HP
));
return
healed
;
}
public
void
damage
(
float
amount
)
{
damage
(
amount
,
0
);
}
public
void
damage
(
float
amount
,
int
killerId
)
{
// Sanity check
if
(
getFightProperties
()
==
null
)
{
return
;
}
// Lose hp
addFightProperty
(
FightProperty
.
FIGHT_PROP_CUR_HP
,
-
amount
);
// Check if dead
boolean
isDead
=
false
;
if
(
getFightProperty
(
FightProperty
.
FIGHT_PROP_CUR_HP
)
<=
0
f
)
{
setFightProperty
(
FightProperty
.
FIGHT_PROP_CUR_HP
,
0
f
);
isDead
=
true
;
}
// Packets
this
.
getScene
().
broadcastPacket
(
new
PacketEntityFightPropUpdateNotify
(
this
,
FightProperty
.
FIGHT_PROP_CUR_HP
));
// Check if dead
if
(
isDead
)
{
getScene
().
killEntity
(
this
,
0
);
}
}
}
}
src/main/java/emu/grasscutter/game/inventory/Inventory.java
View file @
9a0a15a4
...
@@ -172,6 +172,9 @@ public class Inventory implements Iterable<GameItem> {
...
@@ -172,6 +172,9 @@ public class Inventory implements Iterable<GameItem> {
// Handle
// Handle
this
.
addVirtualItem
(
item
.
getItemId
(),
item
.
getCount
());
this
.
addVirtualItem
(
item
.
getItemId
(),
item
.
getCount
());
return
item
;
return
item
;
}
else
if
(
item
.
getItemData
().
getMaterialType
()
==
MaterialType
.
MATERIAL_ADSORBATE
)
{
player
.
getTeamManager
().
addEnergyToTeam
(
item
);
return
null
;
}
else
if
(
item
.
getItemData
().
getMaterialType
()
==
MaterialType
.
MATERIAL_AVATAR
)
{
}
else
if
(
item
.
getItemData
().
getMaterialType
()
==
MaterialType
.
MATERIAL_AVATAR
)
{
// Get avatar id
// Get avatar id
int
avatarId
=
(
item
.
getItemId
()
%
1000
)
+
10000000
;
int
avatarId
=
(
item
.
getItemId
()
%
1000
)
+
10000000
;
...
...
src/main/java/emu/grasscutter/game/player/InvokeHandler.java
View file @
9a0a15a4
...
@@ -30,7 +30,7 @@ public class InvokeHandler<T> {
...
@@ -30,7 +30,7 @@ public class InvokeHandler<T> {
}
}
public
synchronized
void
update
(
Player
player
)
{
public
synchronized
void
update
(
Player
player
)
{
if
(
player
.
getWorld
()
==
null
)
{
if
(
player
.
getWorld
()
==
null
||
player
.
getScene
()
==
null
)
{
this
.
entryListForwardAll
.
clear
();
this
.
entryListForwardAll
.
clear
();
this
.
entryListForwardAllExceptCur
.
clear
();
this
.
entryListForwardAllExceptCur
.
clear
();
this
.
entryListForwardHost
.
clear
();
this
.
entryListForwardHost
.
clear
();
...
...
src/main/java/emu/grasscutter/game/player/Player.java
View file @
9a0a15a4
...
@@ -8,6 +8,7 @@ import emu.grasscutter.data.def.PlayerLevelData;
...
@@ -8,6 +8,7 @@ import emu.grasscutter.data.def.PlayerLevelData;
import
emu.grasscutter.database.DatabaseHelper
;
import
emu.grasscutter.database.DatabaseHelper
;
import
emu.grasscutter.game.Account
;
import
emu.grasscutter.game.Account
;
import
emu.grasscutter.game.CoopRequest
;
import
emu.grasscutter.game.CoopRequest
;
import
emu.grasscutter.game.ability.AbilityManager
;
import
emu.grasscutter.game.avatar.Avatar
;
import
emu.grasscutter.game.avatar.Avatar
;
import
emu.grasscutter.game.avatar.AvatarProfileData
;
import
emu.grasscutter.game.avatar.AvatarProfileData
;
import
emu.grasscutter.game.avatar.AvatarStorage
;
import
emu.grasscutter.game.avatar.AvatarStorage
;
...
@@ -89,7 +90,8 @@ public class Player {
...
@@ -89,7 +90,8 @@ public class Player {
@Transient
private
FriendsList
friendsList
;
@Transient
private
FriendsList
friendsList
;
@Transient
private
MailHandler
mailHandler
;
@Transient
private
MailHandler
mailHandler
;
@Transient
private
MessageHandler
messageHandler
;
@Transient
private
MessageHandler
messageHandler
;
@Transient
private
AbilityManager
abilityManager
;
@Transient
private
SotSManager
sotsManager
;
@Transient
private
SotSManager
sotsManager
;
private
TeamManager
teamManager
;
private
TeamManager
teamManager
;
...
@@ -142,6 +144,7 @@ public class Player {
...
@@ -142,6 +144,7 @@ public class Player {
this
.
friendsList
=
new
FriendsList
(
this
);
this
.
friendsList
=
new
FriendsList
(
this
);
this
.
mailHandler
=
new
MailHandler
(
this
);
this
.
mailHandler
=
new
MailHandler
(
this
);
this
.
towerManager
=
new
TowerManager
(
this
);
this
.
towerManager
=
new
TowerManager
(
this
);
this
.
abilityManager
=
new
AbilityManager
(
this
);
this
.
pos
=
new
Position
();
this
.
pos
=
new
Position
();
this
.
rotation
=
new
Position
();
this
.
rotation
=
new
Position
();
this
.
properties
=
new
HashMap
<>();
this
.
properties
=
new
HashMap
<>();
...
@@ -1025,6 +1028,10 @@ public class Player {
...
@@ -1025,6 +1028,10 @@ public class Player {
public
SotSManager
getSotSManager
()
{
return
sotsManager
;
}
public
SotSManager
getSotSManager
()
{
return
sotsManager
;
}
public
AbilityManager
getAbilityManager
()
{
return
abilityManager
;
}
public
synchronized
void
onTick
()
{
public
synchronized
void
onTick
()
{
// Check ping
// Check ping
if
(
this
.
getLastPingTime
()
>
System
.
currentTimeMillis
()
+
60000
)
{
if
(
this
.
getLastPingTime
()
>
System
.
currentTimeMillis
()
+
60000
)
{
...
...
src/main/java/emu/grasscutter/game/player/TeamManager.java
View file @
9a0a15a4
...
@@ -10,6 +10,7 @@ import emu.grasscutter.data.def.AvatarSkillDepotData;
...
@@ -10,6 +10,7 @@ import emu.grasscutter.data.def.AvatarSkillDepotData;
import
emu.grasscutter.game.avatar.Avatar
;
import
emu.grasscutter.game.avatar.Avatar
;
import
emu.grasscutter.game.entity.EntityAvatar
;
import
emu.grasscutter.game.entity.EntityAvatar
;
import
emu.grasscutter.game.entity.EntityBaseGadget
;
import
emu.grasscutter.game.entity.EntityBaseGadget
;
import
emu.grasscutter.game.inventory.GameItem
;
import
emu.grasscutter.game.props.ElementType
;
import
emu.grasscutter.game.props.ElementType
;
import
emu.grasscutter.game.props.EnterReason
;
import
emu.grasscutter.game.props.EnterReason
;
import
emu.grasscutter.game.props.FightProperty
;
import
emu.grasscutter.game.props.FightProperty
;
...
@@ -579,6 +580,24 @@ public class TeamManager {
...
@@ -579,6 +580,24 @@ public class TeamManager {
// Packets
// Packets
getPlayer
().
sendPacket
(
new
BasePacket
(
PacketOpcodes
.
WorldPlayerReviveRsp
));
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
()
{
public
void
saveAvatars
()
{
// Save all avatars from active team
// Save all avatars from active team
...
...
src/main/java/emu/grasscutter/game/props/ElementType.java
View file @
9a0a15a4
...
@@ -9,21 +9,22 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
...
@@ -9,21 +9,22 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import
it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap
;
import
it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap
;
public
enum
ElementType
{
public
enum
ElementType
{
None
(
0
,
FightProperty
.
FIGHT_PROP_MAX_FIRE_ENERGY
),
None
(
0
,
FightProperty
.
FIGHT_PROP_CUR_FIRE_ENERGY
,
FightProperty
.
FIGHT_PROP_MAX_FIRE_ENERGY
),
Fire
(
1
,
FightProperty
.
FIGHT_PROP_MAX_FIRE_ENERGY
,
10101
,
"TeamResonance_Fire_Lv2"
),
Fire
(
1
,
FightProperty
.
FIGHT_PROP_CUR_FIRE_ENERGY
,
FightProperty
.
FIGHT_PROP_MAX_FIRE_ENERGY
,
10101
,
"TeamResonance_Fire_Lv2"
),
Water
(
2
,
FightProperty
.
FIGHT_PROP_MAX_WATER_ENERGY
,
10201
,
"TeamResonance_Water_Lv2"
),
Water
(
2
,
FightProperty
.
FIGHT_PROP_CUR_WATER_ENERGY
,
FightProperty
.
FIGHT_PROP_MAX_WATER_ENERGY
,
10201
,
"TeamResonance_Water_Lv2"
),
Grass
(
3
,
FightProperty
.
FIGHT_PROP_MAX_GRASS_ENERGY
),
Grass
(
3
,
FightProperty
.
FIGHT_PROP_CUR_GRASS_ENERGY
,
FightProperty
.
FIGHT_PROP_MAX_GRASS_ENERGY
),
Electric
(
4
,
FightProperty
.
FIGHT_PROP_MAX_ELEC_ENERGY
,
10401
,
"TeamResonance_Electric_Lv2"
),
Electric
(
4
,
FightProperty
.
FIGHT_PROP_CUR_ELEC_ENERGY
,
FightProperty
.
FIGHT_PROP_MAX_ELEC_ENERGY
,
10401
,
"TeamResonance_Electric_Lv2"
),
Ice
(
5
,
FightProperty
.
FIGHT_PROP_MAX_ICE_ENERGY
,
10601
,
"TeamResonance_Ice_Lv2"
),
Ice
(
5
,
FightProperty
.
FIGHT_PROP_CUR_ICE_ENERGY
,
FightProperty
.
FIGHT_PROP_MAX_ICE_ENERGY
,
10601
,
"TeamResonance_Ice_Lv2"
),
Frozen
(
6
,
FightProperty
.
FIGHT_PROP_MAX_ICE_ENERGY
),
Frozen
(
6
,
FightProperty
.
FIGHT_PROP_CUR_ICE_ENERGY
,
FightProperty
.
FIGHT_PROP_MAX_ICE_ENERGY
),
Wind
(
7
,
FightProperty
.
FIGHT_PROP_MAX_WIND_ENERGY
,
10301
,
"TeamResonance_Wind_Lv2"
),
Wind
(
7
,
FightProperty
.
FIGHT_PROP_CUR_WIND_ENERGY
,
FightProperty
.
FIGHT_PROP_MAX_WIND_ENERGY
,
10301
,
"TeamResonance_Wind_Lv2"
),
Rock
(
8
,
FightProperty
.
FIGHT_PROP_MAX_ROCK_ENERGY
,
10701
,
"TeamResonance_Rock_Lv2"
),
Rock
(
8
,
FightProperty
.
FIGHT_PROP_CUR_ROCK_ENERGY
,
FightProperty
.
FIGHT_PROP_MAX_ROCK_ENERGY
,
10701
,
"TeamResonance_Rock_Lv2"
),
AntiFire
(
9
,
FightProperty
.
FIGHT_PROP_MAX_FIRE_ENERGY
),
AntiFire
(
9
,
FightProperty
.
FIGHT_PROP_CUR_FIRE_ENERGY
,
FightProperty
.
FIGHT_PROP_MAX_FIRE_ENERGY
),
Default
(
255
,
FightProperty
.
FIGHT_PROP_MAX_FIRE_ENERGY
,
10801
,
"TeamResonance_AllDifferent"
);
Default
(
255
,
FightProperty
.
FIGHT_PROP_CUR_FIRE_ENERGY
,
FightProperty
.
FIGHT_PROP_MAX_FIRE_ENERGY
,
10801
,
"TeamResonance_AllDifferent"
);
private
final
int
value
;
private
final
int
value
;
private
final
int
teamResonanceId
;
private
final
int
teamResonanceId
;
private
final
FightProperty
energyProperty
;
private
final
FightProperty
curEnergyProp
;
private
final
FightProperty
maxEnergyProp
;
private
final
int
configHash
;
private
final
int
configHash
;
private
static
final
Int2ObjectMap
<
ElementType
>
map
=
new
Int2ObjectOpenHashMap
<>();
private
static
final
Int2ObjectMap
<
ElementType
>
map
=
new
Int2ObjectOpenHashMap
<>();
private
static
final
Map
<
String
,
ElementType
>
stringMap
=
new
HashMap
<>();
private
static
final
Map
<
String
,
ElementType
>
stringMap
=
new
HashMap
<>();
...
@@ -35,13 +36,14 @@ public enum ElementType {
...
@@ -35,13 +36,14 @@ public enum ElementType {
});
});
}
}
private
ElementType
(
int
value
,
FightProperty
e
nergyProp
erty
)
{
private
ElementType
(
int
value
,
FightProperty
curE
nergyProp
,
FightProperty
maxEnergyProp
)
{
this
(
value
,
e
nergyProp
erty
,
0
,
null
);
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
.
value
=
value
;
this
.
energyProperty
=
energyProperty
;
this
.
curEnergyProp
=
curEnergyProp
;
this
.
maxEnergyProp
=
maxEnergyProp
;
this
.
teamResonanceId
=
teamResonanceId
;
this
.
teamResonanceId
=
teamResonanceId
;
if
(
configName
!=
null
)
{
if
(
configName
!=
null
)
{
this
.
configHash
=
Utils
.
abilityHash
(
configName
);
this
.
configHash
=
Utils
.
abilityHash
(
configName
);
...
@@ -54,8 +56,12 @@ public enum ElementType {
...
@@ -54,8 +56,12 @@ public enum ElementType {
return
value
;
return
value
;
}
}
public
FightProperty
getEnergyProperty
()
{
public
FightProperty
getCurEnergyProp
()
{
return
energyProperty
;
return
curEnergyProp
;
}
public
FightProperty
getMaxEnergyProp
()
{
return
maxEnergyProp
;
}
}
public
int
getTeamResonanceId
()
{
public
int
getTeamResonanceId
()
{
...
...
src/main/java/emu/grasscutter/game/tower/TowerLevelRecord.java
0 → 100644
View file @
9a0a15a4
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
;
}
}
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