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
1cf1a951
Commit
1cf1a951
authored
Apr 21, 2022
by
Magix
Committed by
GitHub
Apr 21, 2022
Browse files
Merge pull request #94 from Yazawazi/development
Try to show characters' stories and voices
parents
fc45d081
123fc263
Changes
5
Hide whitespace changes
Inline
Side-by-side
src/main/java/emu/grasscutter/data/GenshinData.java
View file @
1cf1a951
package
emu.grasscutter.data
;
import
java.lang.reflect.Field
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
emu.grasscutter.Grasscutter
;
...
...
@@ -54,6 +56,10 @@ public class GenshinData {
private
static
final
Int2ObjectMap
<
AvatarCostumeData
>
avatarCostumeDataItemIdMap
=
new
Int2ObjectLinkedOpenHashMap
<>();
private
static
final
Int2ObjectMap
<
SceneData
>
sceneDataMap
=
new
Int2ObjectLinkedOpenHashMap
<>();
private
static
final
Int2ObjectMap
<
FetterData
>
fetterDataMap
=
new
Int2ObjectOpenHashMap
<>();
// Cache
private
static
Map
<
Integer
,
List
<
Integer
>>
fetters
=
new
HashMap
<>();
public
static
Int2ObjectMap
<?>
getMapByResourceDef
(
Class
<?>
resourceDefinition
)
{
Int2ObjectMap
<?>
map
=
null
;
...
...
@@ -221,4 +227,17 @@ public class GenshinData {
public
static
Int2ObjectMap
<
SceneData
>
getSceneDataMap
()
{
return
sceneDataMap
;
}
public
static
Map
<
Integer
,
List
<
Integer
>>
getFetterDataEntries
()
{
if
(
fetters
.
isEmpty
())
{
fetterDataMap
.
forEach
((
k
,
v
)
->
{
if
(!
fetters
.
containsKey
(
v
.
getAvatarId
()))
{
fetters
.
put
(
v
.
getAvatarId
(),
new
ArrayList
<>());
}
fetters
.
get
(
v
.
getAvatarId
()).
add
(
k
);
});
}
return
fetters
;
}
}
src/main/java/emu/grasscutter/data/def/AvatarData.java
View file @
1cf1a951
...
...
@@ -55,6 +55,8 @@ public class AvatarData extends GenshinResource {
private
float
[]
defenseGrowthCurve
;
private
AvatarSkillDepotData
skillDepot
;
private
IntList
abilities
;
private
List
<
Integer
>
fetters
;
@Override
public
int
getId
(){
...
...
@@ -193,9 +195,16 @@ public class AvatarData extends GenshinResource {
return
abilities
;
}
public
List
<
Integer
>
getFetters
()
{
return
fetters
;
}
@Override
public
void
onLoad
()
{
this
.
skillDepot
=
GenshinData
.
getAvatarSkillDepotDataMap
().
get
(
this
.
SkillDepotId
);
// Get fetters from GenshinData
this
.
fetters
=
GenshinData
.
getFetterDataEntries
().
get
(
this
.
Id
);
int
size
=
GenshinData
.
getAvatarCurveDataMap
().
size
();
this
.
hpGrowthCurve
=
new
float
[
size
];
...
...
src/main/java/emu/grasscutter/data/def/FetterData.java
0 → 100644
View file @
1cf1a951
package
emu.grasscutter.data.def
;
import
emu.grasscutter.data.GenshinResource
;
import
emu.grasscutter.data.ResourceType
;
import
emu.grasscutter.data.ResourceType.LoadPriority
;
@ResourceType
(
name
=
{
"FetterInfoExcelConfigData.json"
,
"FettersExcelConfigData.json"
,
"FetterStoryExcelConfigData.json"
},
loadPriority
=
LoadPriority
.
HIGHEST
)
public
class
FetterData
extends
GenshinResource
{
private
int
AvatarId
;
private
int
FetterId
;
@Override
public
int
getId
()
{
return
FetterId
;
}
public
int
getAvatarId
()
{
return
AvatarId
;
}
@Override
public
void
onLoad
()
{
}
}
src/main/java/emu/grasscutter/game/avatar/GenshinAvatar.java
View file @
1cf1a951
package
emu.grasscutter.game.avatar
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
...
...
@@ -39,9 +41,11 @@ import emu.grasscutter.game.inventory.EquipType;
import
emu.grasscutter.game.inventory.GenshinItem
;
import
emu.grasscutter.game.props.ElementType
;
import
emu.grasscutter.game.props.EntityIdType
;
import
emu.grasscutter.game.props.FetterState
;
import
emu.grasscutter.game.props.FightProperty
;
import
emu.grasscutter.game.props.PlayerProperty
;
import
emu.grasscutter.net.proto.AvatarFetterInfoOuterClass.AvatarFetterInfo
;
import
emu.grasscutter.net.proto.FetterDataOuterClass.FetterData
;
import
emu.grasscutter.net.proto.AvatarInfoOuterClass.AvatarInfo
;
import
emu.grasscutter.server.packet.send.PacketAbilityChangeNotify
;
import
emu.grasscutter.server.packet.send.PacketAvatarEquipChangeNotify
;
...
...
@@ -73,6 +77,8 @@ public class GenshinAvatar {
@Transient
private
final
Int2FloatOpenHashMap
fightProp
;
@Transient
private
Set
<
String
>
extraAbilityEmbryos
;
private
List
<
Integer
>
fetters
;
private
Map
<
Integer
,
Integer
>
skillLevelMap
;
// Talent levels
private
Map
<
Integer
,
Integer
>
proudSkillBonusMap
;
// Talent bonus levels (from const)
private
int
skillDepotId
;
...
...
@@ -89,7 +95,8 @@ public class GenshinAvatar {
this
.
equips
=
new
Int2ObjectOpenHashMap
<>();
this
.
fightProp
=
new
Int2FloatOpenHashMap
();
this
.
extraAbilityEmbryos
=
new
HashSet
<>();
this
.
proudSkillBonusMap
=
new
HashMap
<>();
// TODO Move to genshin avatar
this
.
proudSkillBonusMap
=
new
HashMap
<>();
this
.
fetters
=
new
ArrayList
<>();
// TODO Move to genshin avatar
}
// On creation
...
...
@@ -266,6 +273,14 @@ public class GenshinAvatar {
return
extraAbilityEmbryos
;
}
public
void
setFetterList
(
List
<
Integer
>
fetterList
)
{
this
.
fetters
=
fetterList
;
}
public
List
<
Integer
>
getFetterList
()
{
return
fetters
;
}
public
float
getCurrentHp
()
{
return
currentHp
;
}
...
...
@@ -385,6 +400,9 @@ public class GenshinAvatar {
// Extra ability embryos
Set
<
String
>
prevExtraAbilityEmbryos
=
this
.
getExtraAbilityEmbryos
();
this
.
extraAbilityEmbryos
=
new
HashSet
<>();
// Fetters
this
.
setFetterList
(
data
.
getFetters
());
// Get hp percent, set to 100% if none
float
hpPercent
=
this
.
getFightProperty
(
FightProperty
.
FIGHT_PROP_MAX_HP
)
<=
0
?
1
f
:
this
.
getFightProperty
(
FightProperty
.
FIGHT_PROP_CUR_HP
)
/
this
.
getFightProperty
(
FightProperty
.
FIGHT_PROP_MAX_HP
);
...
...
@@ -683,6 +701,20 @@ public class GenshinAvatar {
}
public
AvatarInfo
toProto
()
{
AvatarFetterInfo
.
Builder
avatarFetter
=
AvatarFetterInfo
.
newBuilder
()
.
setExpLevel
(
10
)
.
setExpNumber
(
6325
);
// Highest Level
if
(
this
.
getFetterList
()
!=
null
)
{
for
(
int
i
=
0
;
i
<
this
.
getFetterList
().
size
();
i
++)
{
avatarFetter
.
addFetterList
(
FetterData
.
newBuilder
()
.
setFetterId
(
this
.
getFetterList
().
get
(
i
))
.
setFetterState
(
FetterState
.
FINISH
.
getValue
())
);
}
}
AvatarInfo
.
Builder
avatarInfo
=
AvatarInfo
.
newBuilder
()
.
setAvatarId
(
this
.
getAvatarId
())
.
setGuid
(
this
.
getGuid
())
...
...
@@ -696,7 +728,7 @@ public class GenshinAvatar {
.
putAllProudSkillExtraLevel
(
getProudSkillBonusMap
())
.
setAvatarType
(
1
)
.
setBornTime
(
this
.
getBornTime
())
.
setFetterInfo
(
A
vatarFetter
Info
.
newBuilder
().
setExpLevel
(
1
)
)
.
setFetterInfo
(
a
vatarFetter
)
.
setWearingFlycloakId
(
this
.
getFlyCloak
())
.
setCostumeId
(
this
.
getCostume
());
...
...
src/main/java/emu/grasscutter/game/props/FetterState.java
0 → 100644
View file @
1cf1a951
package
emu.grasscutter.game.props
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.stream.Stream
;
import
it.unimi.dsi.fastutil.ints.Int2ObjectMap
;
import
it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap
;
public
enum
FetterState
{
NONE
(
0
),
NOT_OPEN
(
1
),
OPEN
(
1
),
FINISH
(
3
);
private
final
int
value
;
private
static
final
Int2ObjectMap
<
FetterState
>
map
=
new
Int2ObjectOpenHashMap
<>();
private
static
final
Map
<
String
,
FetterState
>
stringMap
=
new
HashMap
<>();
static
{
Stream
.
of
(
values
()).
forEach
(
e
->
{
map
.
put
(
e
.
getValue
(),
e
);
stringMap
.
put
(
e
.
name
(),
e
);
});
}
private
FetterState
(
int
value
)
{
this
.
value
=
value
;
}
public
int
getValue
()
{
return
value
;
}
public
static
FetterState
getTypeByValue
(
int
value
)
{
return
map
.
getOrDefault
(
value
,
NONE
);
}
public
static
FetterState
getTypeByName
(
String
name
)
{
return
stringMap
.
getOrDefault
(
name
,
NONE
);
}
}
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