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
c25e809f
Commit
c25e809f
authored
Apr 24, 2022
by
Benjamin Elsdon
Browse files
Merge remote-tracking branch 'upstream/development' into dev-mail
parents
9e7c9f46
b6d8dd0d
Changes
29
Hide whitespace changes
Inline
Side-by-side
src/main/java/emu/grasscutter/game/inventory/GenshinItem.java
View file @
c25e809f
...
@@ -90,7 +90,7 @@ public class GenshinItem {
...
@@ -90,7 +90,7 @@ public class GenshinItem {
// Equip data
// Equip data
if
(
getItemType
()
==
ItemType
.
ITEM_WEAPON
)
{
if
(
getItemType
()
==
ItemType
.
ITEM_WEAPON
)
{
this
.
level
=
1
;
this
.
level
=
this
.
count
>
1
?
this
.
count
:
1
;
this
.
affixes
=
new
ArrayList
<>(
2
);
this
.
affixes
=
new
ArrayList
<>(
2
);
if
(
getItemData
().
getSkillAffix
()
!=
null
)
{
if
(
getItemData
().
getSkillAffix
()
!=
null
)
{
for
(
int
skillAffix
:
getItemData
().
getSkillAffix
())
{
for
(
int
skillAffix
:
getItemData
().
getSkillAffix
())
{
...
...
src/main/java/emu/grasscutter/game/managers/InventoryManager.java
View file @
c25e809f
...
@@ -711,6 +711,31 @@ public class InventoryManager {
...
@@ -711,6 +711,31 @@ public class InventoryManager {
player
.
sendPacket
(
new
PacketAvatarUpgradeRsp
(
avatar
,
oldLevel
,
oldPropMap
));
player
.
sendPacket
(
new
PacketAvatarUpgradeRsp
(
avatar
,
oldLevel
,
oldPropMap
));
}
}
public
void
upgradeAvatarFetterLevel
(
GenshinPlayer
player
,
GenshinAvatar
avatar
,
int
expGain
)
{
// May work. Not test.
int
maxLevel
=
10
;
// Keep it until I think of a more "elegant" way
int
level
=
avatar
.
getFetterLevel
();
int
exp
=
avatar
.
getFetterExp
();
int
reqExp
=
GenshinData
.
getAvatarFetterLevelExpRequired
(
level
);
while
(
expGain
>
0
&&
reqExp
>
0
&&
level
<
maxLevel
)
{
int
toGain
=
Math
.
min
(
expGain
,
reqExp
-
exp
);
exp
+=
toGain
;
expGain
-=
toGain
;
if
(
exp
>=
reqExp
)
{
exp
=
0
;
level
+=
1
;
reqExp
=
GenshinData
.
getAvatarFetterLevelExpRequired
(
level
);
}
}
avatar
.
setFetterLevel
(
level
);
avatar
.
setFetterExp
(
exp
);
avatar
.
save
();
player
.
sendPacket
(
new
PacketAvatarPropNotify
(
avatar
));
}
public
void
upgradeAvatarSkill
(
GenshinPlayer
player
,
long
guid
,
int
skillId
)
{
public
void
upgradeAvatarSkill
(
GenshinPlayer
player
,
long
guid
,
int
skillId
)
{
// Sanity checks
// Sanity checks
GenshinAvatar
avatar
=
player
.
getAvatars
().
getAvatarByGuid
(
guid
);
GenshinAvatar
avatar
=
player
.
getAvatars
().
getAvatarByGuid
(
guid
);
...
...
src/main/java/emu/grasscutter/server/packet/recv/HandlerAvatarFetterLevelRewardReq.java
0 → 100644
View file @
c25e809f
package
emu.grasscutter.server.packet.recv
;
import
emu.grasscutter.data.GenshinData
;
import
emu.grasscutter.data.def.RewardData
;
import
emu.grasscutter.game.avatar.GenshinAvatar
;
import
emu.grasscutter.game.inventory.GenshinItem
;
import
emu.grasscutter.game.props.ActionReason
;
import
emu.grasscutter.net.packet.Opcodes
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
import
emu.grasscutter.net.proto.AvatarFetterLevelRewardReqOuterClass.AvatarFetterLevelRewardReq
;
import
emu.grasscutter.server.game.GameSession
;
import
emu.grasscutter.server.packet.send.PacketAvatarFetterDataNotify
;
import
emu.grasscutter.server.packet.send.PacketAvatarFetterLevelRewardRsp
;
import
emu.grasscutter.server.packet.send.PacketItemAddHintNotify
;
import
emu.grasscutter.server.packet.send.PacketUnlockNameCardNotify
;
import
emu.grasscutter.net.packet.PacketHandler
;
@Opcodes
(
PacketOpcodes
.
AvatarFetterLevelRewardReq
)
public
class
HandlerAvatarFetterLevelRewardReq
extends
PacketHandler
{
@Override
public
void
handle
(
GameSession
session
,
byte
[]
header
,
byte
[]
payload
)
throws
Exception
{
AvatarFetterLevelRewardReq
req
=
AvatarFetterLevelRewardReq
.
parseFrom
(
payload
);
if
(
req
.
getFetterLevel
()
<
10
)
{
// You don't have a full level of fetter level, why do you want to get a divorce certificate?
session
.
send
(
new
PacketAvatarFetterLevelRewardRsp
(
req
.
getAvatarGuid
(),
req
.
getFetterLevel
()));
}
else
{
long
avatarGuid
=
req
.
getAvatarGuid
();
GenshinAvatar
avatar
=
session
.
getPlayer
()
.
getAvatars
()
.
getAvatarByGuid
(
avatarGuid
);
int
rewardId
=
avatar
.
getNameCardRewardId
();
RewardData
card
=
GenshinData
.
getRewardDataMap
().
get
(
rewardId
);
int
cardId
=
card
.
getRewardItemList
().
get
(
0
).
getItemId
();
if
(
session
.
getPlayer
().
getNameCardList
().
contains
(
cardId
))
{
// Already got divorce certificate.
session
.
getPlayer
().
sendPacket
(
new
PacketAvatarFetterLevelRewardRsp
(
req
.
getAvatarGuid
(),
req
.
getFetterLevel
(),
rewardId
));
return
;
}
GenshinItem
item
=
new
GenshinItem
(
cardId
);
session
.
getPlayer
().
getInventory
().
addItem
(
item
);
session
.
getPlayer
().
sendPacket
(
new
PacketItemAddHintNotify
(
item
,
ActionReason
.
FetterLevelReward
));
session
.
getPlayer
().
sendPacket
(
new
PacketUnlockNameCardNotify
(
cardId
));
session
.
send
(
new
PacketAvatarFetterLevelRewardRsp
(
avatarGuid
,
req
.
getFetterLevel
(),
rewardId
));
session
.
send
(
new
PacketAvatarFetterDataNotify
(
avatar
));
}
}
}
src/main/java/emu/grasscutter/server/packet/recv/HandlerTakePlayerLevelRewardReq.java
0 → 100644
View file @
c25e809f
package
emu.grasscutter.server.packet.recv
;
import
java.util.LinkedList
;
import
java.util.List
;
import
java.util.Set
;
import
emu.grasscutter.Grasscutter
;
import
emu.grasscutter.data.GenshinData
;
import
emu.grasscutter.data.common.RewardItemData
;
import
emu.grasscutter.game.inventory.GenshinItem
;
import
emu.grasscutter.game.props.ActionReason
;
import
emu.grasscutter.net.packet.Opcodes
;
import
emu.grasscutter.net.packet.PacketHandler
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
import
emu.grasscutter.net.proto.TakePlayerLevelRewardReqOuterClass.TakePlayerLevelRewardReq
;
import
emu.grasscutter.server.game.GameSession
;
import
emu.grasscutter.server.packet.send.PacketItemAddHintNotify
;
import
emu.grasscutter.server.packet.send.PacketTakePlayerLevelRewardRsp
;
@Opcodes
(
PacketOpcodes
.
TakePlayerLevelRewardReq
)
public
class
HandlerTakePlayerLevelRewardReq
extends
PacketHandler
{
@Override
public
void
handle
(
GameSession
session
,
byte
[]
header
,
byte
[]
payload
)
throws
Exception
{
TakePlayerLevelRewardReq
req
=
TakePlayerLevelRewardReq
.
parseFrom
(
payload
);
int
level
=
req
.
getLevel
();
int
rewardId
=
GenshinData
.
getPlayerLevelDataMap
().
get
(
level
).
getRewardId
();
if
(
rewardId
!=
0
)
{
List
<
RewardItemData
>
rewardItems
=
GenshinData
.
getRewardDataMap
().
get
(
rewardId
).
getRewardItemList
();
List
<
GenshinItem
>
items
=
new
LinkedList
<>();
for
(
RewardItemData
rewardItem
:
rewardItems
)
{
if
(
rewardItem
!=
null
)
{
if
(
rewardItem
.
getItemId
()
!=
0
)
{
items
.
add
(
new
GenshinItem
(
rewardItem
.
getItemId
(),
rewardItem
.
getItemCount
()));
}
}
}
session
.
getPlayer
().
getInventory
().
addItems
(
items
);
session
.
getPlayer
().
sendPacket
(
new
PacketItemAddHintNotify
(
items
,
ActionReason
.
PlayerUpgradeReward
));
Set
<
Integer
>
rewardedLevels
=
session
.
getPlayer
().
getRewardedLevels
();
rewardedLevels
.
add
(
level
);
session
.
getPlayer
().
setRewardedLevels
(
rewardedLevels
);
}
session
.
send
(
new
PacketTakePlayerLevelRewardRsp
(
level
,
rewardId
));
}
}
src/main/java/emu/grasscutter/server/packet/send/PacketAvatarFetterDataNotify.java
0 → 100644
View file @
c25e809f
package
emu.grasscutter.server.packet.send
;
import
emu.grasscutter.game.avatar.GenshinAvatar
;
import
emu.grasscutter.game.props.FetterState
;
import
emu.grasscutter.net.packet.GenshinPacket
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
import
emu.grasscutter.net.proto.AvatarFetterDataNotifyOuterClass.AvatarFetterDataNotify
;
import
emu.grasscutter.net.proto.AvatarFetterInfoOuterClass.AvatarFetterInfo
;
import
emu.grasscutter.net.proto.FetterDataOuterClass.FetterData
;
public
class
PacketAvatarFetterDataNotify
extends
GenshinPacket
{
public
PacketAvatarFetterDataNotify
(
GenshinAvatar
avatar
)
{
super
(
PacketOpcodes
.
AvatarFetterDataNotify
);
AvatarFetterInfo
.
Builder
avatarFetter
=
AvatarFetterInfo
.
newBuilder
()
.
setExpLevel
(
avatar
.
getFetterLevel
())
.
setExpNumber
(
avatar
.
getFetterExp
());
if
(
avatar
.
getFetterList
()
!=
null
)
{
for
(
int
i
=
0
;
i
<
avatar
.
getFetterList
().
size
();
i
++)
{
avatarFetter
.
addFetterList
(
FetterData
.
newBuilder
()
.
setFetterId
(
avatar
.
getFetterList
().
get
(
i
))
.
setFetterState
(
FetterState
.
FINISH
.
getValue
())
);
}
}
int
rewardId
=
avatar
.
getNameCardRewardId
();
int
cardId
=
avatar
.
getNameCardId
();
if
(
avatar
.
getPlayer
().
getNameCardList
().
contains
(
cardId
))
{
avatarFetter
.
addRewardedFetterLevelList
(
rewardId
);
}
AvatarFetterInfo
avatarFetterInfo
=
avatarFetter
.
build
();
AvatarFetterDataNotify
proto
=
AvatarFetterDataNotify
.
newBuilder
()
.
putFetterInfoMap
(
avatar
.
getGuid
(),
avatarFetterInfo
)
.
build
();
this
.
setData
(
proto
);
}
}
src/main/java/emu/grasscutter/server/packet/send/PacketAvatarFetterLevelRewardRsp.java
0 → 100644
View file @
c25e809f
package
emu.grasscutter.server.packet.send
;
import
emu.grasscutter.net.packet.GenshinPacket
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
import
emu.grasscutter.net.proto.AvatarFetterLevelRewardRspOuterClass.AvatarFetterLevelRewardRsp
;
public
class
PacketAvatarFetterLevelRewardRsp
extends
GenshinPacket
{
public
PacketAvatarFetterLevelRewardRsp
(
long
guid
,
int
fetterLevel
,
int
rewardId
)
{
super
(
PacketOpcodes
.
AvatarFetterLevelRewardRsp
);
AvatarFetterLevelRewardRsp
proto
=
AvatarFetterLevelRewardRsp
.
newBuilder
()
.
setAvatarGuid
(
guid
)
.
setFetterLevel
(
fetterLevel
)
.
setRetcode
(
0
)
.
setRewardId
(
rewardId
)
.
build
();
this
.
setData
(
proto
);
}
public
PacketAvatarFetterLevelRewardRsp
(
long
guid
,
int
fetterLevel
)
{
super
(
PacketOpcodes
.
AvatarFetterLevelRewardRsp
);
AvatarFetterLevelRewardRsp
proto
=
AvatarFetterLevelRewardRsp
.
newBuilder
()
.
setAvatarGuid
(
guid
)
.
setFetterLevel
(
fetterLevel
)
.
setRetcode
(
1
)
.
setRewardId
(
0
)
.
build
();
this
.
setData
(
proto
);
}
}
src/main/java/emu/grasscutter/server/packet/send/PacketPlayerLevelRewardUpdateNotify.java
0 → 100644
View file @
c25e809f
package
emu.grasscutter.server.packet.send
;
import
java.util.Set
;
import
emu.grasscutter.net.packet.GenshinPacket
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
import
emu.grasscutter.net.proto.PlayerLevelRewardUpdateNotifyOuterClass.PlayerLevelRewardUpdateNotify
;
public
class
PacketPlayerLevelRewardUpdateNotify
extends
GenshinPacket
{
public
PacketPlayerLevelRewardUpdateNotify
(
Set
<
Integer
>
rewardedLevels
)
{
super
(
PacketOpcodes
.
PlayerLevelRewardUpdateNotify
);
PlayerLevelRewardUpdateNotify
.
Builder
proto
=
PlayerLevelRewardUpdateNotify
.
newBuilder
();
for
(
Integer
level
:
rewardedLevels
)
{
proto
.
addLevelList
(
level
);
}
this
.
setData
(
proto
.
build
());
}
}
src/main/java/emu/grasscutter/server/packet/send/PacketTakePlayerLevelRewardRsp.java
0 → 100644
View file @
c25e809f
package
emu.grasscutter.server.packet.send
;
import
emu.grasscutter.net.packet.GenshinPacket
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
import
emu.grasscutter.net.proto.TakePlayerLevelRewardRspOuterClass.TakePlayerLevelRewardRsp
;
public
class
PacketTakePlayerLevelRewardRsp
extends
GenshinPacket
{
public
PacketTakePlayerLevelRewardRsp
(
int
level
,
int
rewardId
)
{
super
(
PacketOpcodes
.
TakePlayerLevelRewardRsp
);
int
retcode
=
0
;
if
(
rewardId
==
0
)
{
retcode
=
1
;
}
TakePlayerLevelRewardRsp
proto
=
TakePlayerLevelRewardRsp
.
newBuilder
()
.
setLevel
(
level
)
.
setRewardId
(
rewardId
)
.
setRetcode
(
retcode
)
.
build
();
this
.
setData
(
proto
);
}
}
start.cmd
View file @
c25e809f
...
@@ -74,10 +74,11 @@ for /f "tokens=2*" %%a in ('reg query "HKCU\Software\Microsoft\Windows\CurrentVe
...
@@ -74,10 +74,11 @@ for /f "tokens=2*" %%a in ('reg query "HKCU\Software\Microsoft\Windows\CurrentVe
@rem TODO: External proxy when ORIG_PROXY_ENABLE == 0x1
@rem TODO: External proxy when ORIG_PROXY_ENABLE == 0x1
echo
set
ws
=
createobject
(
"wscript.shell"
)
>
"
%temp%
\proxy.vbs"
echo
set
ws
=
createobject
(
"wscript.shell"
)
>
"
%temp%
\proxy.vbs"
if
not
"
%MITMDUMP_PATH%
"
==
""
(
if
not
"
%MITMDUMP_PATH%
"
==
""
(
echo
ws
.currentdirectory
=
"
%MITMDUMP_PATH%
"
>>
"
%temp%
\proxy.vbs"
echo
ws
.currentdirectory
=
"
%MITMDUMP_PATH%
"
>>
"
%temp%
\proxy.vbs"
)
)
echo
ws
.run
"cmd /c mitmdump.exe -s "
^&
chr
(
34
)
^&
"
%CUR_PATH%%
PROXY_SCRIPT_NAME
%
"
^&
chr
(
34
)
^&
" -k
"
,
0
>>
"
%temp%
\proxy.vbs"
echo
ws
.run
"cmd /c mitmdump.exe -s "
^&
chr
(
34
)
^&
"
%CUR_PATH%%
PROXY_SCRIPT_NAME
%
"
^&
chr
(
34
)
^&
" -k
--allow-hosts "
^&
chr
(
34
)
^&
".*\.yuanshen\.com|.*\.mihoyo\.com|.*\.hoyoverse\.com"
^&
chr
(
34
)
,
0
>>
"
%temp%
\proxy.vbs"
"
%temp%
\proxy.vbs"
"
%temp%
\proxy.vbs"
del
/f /q
"
%temp%
\proxy.vbs"
>
nul
2
>
nul
del
/f /q
"
%temp%
\proxy.vbs"
>
nul
2
>
nul
...
@@ -161,4 +162,4 @@ call :LOG [INFO] See you again :)
...
@@ -161,4 +162,4 @@ call :LOG [INFO] See you again :)
goto
:EOF
goto
:EOF
:LOG
:LOG
echo
[
%time
:
~
0
,
8
%
]
%
*
echo
[
%time
:
~
0
,
8
%
]
%
*
\ No newline at end of file
Prev
1
2
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