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
eedab792
Commit
eedab792
authored
Apr 22, 2022
by
Yazawazi
Committed by
GitHub
Apr 22, 2022
Browse files
fetter try
parent
b09d8a2a
Changes
5
Show whitespace changes
Inline
Side-by-side
src/main/java/emu/grasscutter/data/GenshinData.java
View file @
eedab792
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,7 @@ 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
<>();
public
static
Int2ObjectMap
<?>
getMapByResourceDef
(
Class
<?>
resourceDefinition
)
{
Int2ObjectMap
<?>
map
=
null
;
...
...
@@ -221,4 +224,16 @@ public class GenshinData {
public
static
Int2ObjectMap
<
SceneData
>
getSceneDataMap
()
{
return
sceneDataMap
;
}
public
static
Map
<
Integer
,
List
<
Integer
>>
getFetterDataEntries
()
{
// Can I do this?
Map
<
Integer
,
List
<
Integer
>>
fetters
=
new
HashMap
<>();
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 @
eedab792
...
...
@@ -56,6 +56,8 @@ public class AvatarData extends GenshinResource {
private
AvatarSkillDepotData
skillDepot
;
private
IntList
abilities
;
private
List
<
Integer
>
fetters
;
@Override
public
int
getId
(){
return
this
.
Id
;
...
...
@@ -193,10 +195,17 @@ 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
];
this
.
attackGrowthCurve
=
new
float
[
size
];
...
...
src/main/java/emu/grasscutter/data/def/FetterData.java
0 → 100644
View file @
eedab792
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 @
eedab792
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
<
Interget
>
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
.
fetterList
=
fetterList
;
}
public
List
<
Integer
>
getFetterList
()
{
return
fetterList
;
}
public
float
getCurrentHp
()
{
return
currentHp
;
}
...
...
@@ -386,6 +401,9 @@ public class GenshinAvatar {
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,18 @@ public class GenshinAvatar {
}
public
AvatarInfo
toProto
()
{
AvatarFetterInfo
.
Builder
avatarFetter
=
AvatarFetterInfo
.
newBuilder
()
.
setExpLevel
(
10
)
.
setExpNumber
(
6325
);
// Highest Level
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 +726,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 @
eedab792
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