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
77f2bcf5
Commit
77f2bcf5
authored
Aug 21, 2022
by
akatatsu27
Committed by
GitHub
Aug 21, 2022
Browse files
small quest fixes (#1677)
* small quest fixes * uncomment hack
parent
abd1e756
Changes
8
Show whitespace changes
Inline
Side-by-side
src/main/java/emu/grasscutter/game/player/Player.java
View file @
77f2bcf5
...
...
@@ -225,6 +225,7 @@ public class Player {
this
.
unlockedFurnitureSuite
=
new
HashSet
<>();
this
.
activeForges
=
new
ArrayList
<>();
this
.
unlockedRecipies
=
new
HashMap
<>();
this
.
questGlobalVariables
=
new
HashMap
<>();
this
.
openStates
=
new
HashMap
<>();
this
.
unlockedSceneAreas
=
new
HashMap
<>();
this
.
unlockedScenePoints
=
new
HashMap
<>();
...
...
src/main/java/emu/grasscutter/game/player/PlayerProgressManager.java
View file @
77f2bcf5
...
...
@@ -46,6 +46,7 @@ public class PlayerProgressManager extends BasePlayerDataManager {
// that particular statue interactable.
this
.
player
.
getUnlockedScenePoints
(
3
).
add
(
7
);
this
.
player
.
getUnlockedSceneAreas
(
3
).
add
(
1
);
}
/******************************************************************************************************************
...
...
@@ -195,14 +196,13 @@ public class PlayerProgressManager extends BasePlayerDataManager {
}
}
public
void
unlockTransPoint
(
int
sceneId
,
int
pointId
,
boolean
isStatue
)
{
public
boolean
unlockTransPoint
(
int
sceneId
,
int
pointId
,
boolean
isStatue
)
{
// Check whether the unlocked point exists and whether it is still locked.
String
key
=
sceneId
+
"_"
+
pointId
;
ScenePointEntry
scenePointEntry
=
GameData
.
getScenePointEntries
().
get
(
key
);
if
(
scenePointEntry
==
null
||
this
.
player
.
getUnlockedScenePoints
(
sceneId
).
contains
(
pointId
))
{
this
.
player
.
sendPacket
(
new
PacketUnlockTransPointRsp
(
Retcode
.
RET_FAIL
));
return
;
return
false
;
}
// Add the point to the list of unlocked points for its scene.
...
...
@@ -222,7 +222,7 @@ public class PlayerProgressManager extends BasePlayerDataManager {
// Send packet.
this
.
player
.
sendPacket
(
new
PacketScenePointUnlockNotify
(
sceneId
,
pointId
));
this
.
player
.
sendPacket
(
new
PacketUnlockTransPointRsp
(
Retcode
.
RET_SUCC
))
;
return
true
;
}
public
void
unlockSceneArea
(
int
sceneId
,
int
areaId
)
{
...
...
src/main/java/emu/grasscutter/game/quest/GameMainQuest.java
View file @
77f2bcf5
...
...
@@ -194,8 +194,9 @@ public class GameMainQuest {
CompiledScript
cs
=
ScriptLoader
.
getScriptByPath
(
SCRIPT
(
"Quest/Share/Q"
+
getParentQuestId
()
+
"ShareConfig."
+
ScriptLoader
.
getScriptType
()));
//mainQuest 303 doesn't have a ShareConfig
if
(
cs
==
null
)
{
Grasscutter
.
getLogger
().
error
(
"Couldn't find Q"
+
getParentQuestId
()
+
"ShareConfig."
+
ScriptLoader
.
getScriptType
());
Grasscutter
.
getLogger
().
debug
(
"Couldn't find Q"
+
getParentQuestId
()
+
"ShareConfig."
+
ScriptLoader
.
getScriptType
());
return
;
}
...
...
@@ -283,15 +284,19 @@ public class GameMainQuest {
for
(
GameQuest
subQuestWithCond
:
subQuestsWithCond
)
{
List
<
QuestData
.
QuestCondition
>
failCond
=
subQuestWithCond
.
getQuestData
().
getFailCond
();
int
[]
fail
=
new
int
[
failCond
.
size
()];
for
(
int
i
=
0
;
i
<
subQuestWithCond
.
getQuestData
().
getFailCond
().
size
();
i
++)
{
QuestData
.
QuestCondition
condition
=
failCond
.
get
(
i
);
if
(
condition
.
getType
()
==
condType
)
{
boolean
result
=
this
.
getOwner
().
getServer
().
getQuestSystem
().
triggerContent
(
subQuestWithCond
,
condition
,
paramStr
,
params
);
fail
[
i
]
=
result
?
1
:
0
;
subQuestWithCond
.
getFailProgressList
()[
i
]
=
result
?
1
:
0
;
if
(
result
)
{
getOwner
().
getSession
().
send
(
new
PacketQuestProgressUpdateNotify
(
subQuestWithCond
));
}
}
}
boolean
shouldFail
=
LogicType
.
calculate
(
subQuestWithCond
.
getQuestData
().
getFailCondComb
(),
fail
);
boolean
shouldFail
=
LogicType
.
calculate
(
subQuestWithCond
.
getQuestData
().
getFailCondComb
(),
subQuestWithCond
.
getFailProgressList
()
);
if
(
shouldFail
)
{
subQuestWithCond
.
fail
();
...
...
@@ -314,15 +319,19 @@ public class GameMainQuest {
for
(
GameQuest
subQuestWithCond
:
subQuestsWithCond
)
{
List
<
QuestData
.
QuestCondition
>
finishCond
=
subQuestWithCond
.
getQuestData
().
getFinishCond
();
int
[]
finish
=
new
int
[
finishCond
.
size
()];
for
(
int
i
=
0
;
i
<
finishCond
.
size
();
i
++)
{
QuestData
.
QuestCondition
condition
=
finishCond
.
get
(
i
);
if
(
condition
.
getType
()
==
condType
)
{
boolean
result
=
this
.
getOwner
().
getServer
().
getQuestSystem
().
triggerContent
(
subQuestWithCond
,
condition
,
paramStr
,
params
);
finish
[
i
]
=
result
?
1
:
0
;
subQuestWithCond
.
getFinishProgressList
()[
i
]
=
result
?
1
:
0
;
if
(
result
)
{
getOwner
().
getSession
().
send
(
new
PacketQuestProgressUpdateNotify
(
subQuestWithCond
));
}
}
}
boolean
shouldFinish
=
LogicType
.
calculate
(
subQuestWithCond
.
getQuestData
().
getFinishCondComb
(),
finish
);
boolean
shouldFinish
=
LogicType
.
calculate
(
subQuestWithCond
.
getQuestData
().
getFinishCondComb
(),
subQuestWithCond
.
getFinishProgressList
()
);
if
(
shouldFinish
)
{
subQuestWithCond
.
finish
();
...
...
src/main/java/emu/grasscutter/game/quest/GameQuest.java
View file @
77f2bcf5
...
...
@@ -137,13 +137,6 @@ public class GameQuest {
this
.
state
=
QuestState
.
QUEST_STATE_FINISHED
;
this
.
finishTime
=
Utils
.
getCurrentSeconds
();
if
(
getFinishProgressList
()
!=
null
)
{
Arrays
.
fill
(
getFinishProgressList
(),
1
);
}
getOwner
().
getSession
().
send
(
new
PacketQuestProgressUpdateNotify
(
this
));
if
(
getQuestData
().
finishParent
())
{
// This quest finishes the questline - the main quest will also save the quest to db, so we don't have to call save() here
getMainQuest
().
finish
();
...
...
@@ -169,12 +162,6 @@ public class GameQuest {
this
.
state
=
QuestState
.
QUEST_STATE_FAILED
;
this
.
finishTime
=
Utils
.
getCurrentSeconds
();
if
(
getFailProgressList
()
!=
null
)
{
Arrays
.
fill
(
getFailProgressList
(),
1
);
}
getOwner
().
getSession
().
send
(
new
PacketQuestProgressUpdateNotify
(
this
));
getQuestData
().
getFailExec
().
forEach
(
e
->
getOwner
().
getServer
().
getQuestSystem
().
triggerExec
(
this
,
e
,
e
.
getParam
()));
//Some subQuests have conditions that subQuests fail (even from different MainQuests)
getOwner
().
getQuestManager
().
triggerEvent
(
QuestTrigger
.
QUEST_CONTENT_QUEST_STATE_EQUAL
,
this
.
subQuestId
,
this
.
state
.
getValue
(),
0
,
0
,
0
);
...
...
src/main/java/emu/grasscutter/game/quest/QuestManager.java
View file @
77f2bcf5
...
...
@@ -25,8 +25,6 @@ import lombok.Getter;
public
class
QuestManager
extends
BasePlayerManager
{
@Getter
private
final
Player
player
;
@Getter
private
Map
<
Integer
,
Integer
>
questGlobalVariables
;
@Getter
private
final
Int2ObjectMap
<
GameMainQuest
>
mainQuests
;
@Getter
private
List
<
GameQuest
>
addToQuestListUpdateNotify
;
/*
...
...
@@ -72,7 +70,6 @@ public class QuestManager extends BasePlayerManager {
super
(
player
);
this
.
player
=
player
;
this
.
questGlobalVariables
=
player
.
getQuestGlobalVariables
();
this
.
mainQuests
=
new
Int2ObjectOpenHashMap
<>();
this
.
addToQuestListUpdateNotify
=
new
ArrayList
<>();
}
...
...
@@ -81,7 +78,7 @@ public class QuestManager extends BasePlayerManager {
List
<
GameMainQuest
>
newQuests
=
this
.
addMultMainQuests
(
newPlayerMainQuests
);
//getPlayer().sendPacket(new PacketServerCondMeetQuestListUpdateNotify(newPlayerServerCondMeetQuestListUpdateNotify));
getPlayer
().
sendPacket
(
new
PacketFinishedParentQuestUpdateNotify
(
newQuests
));
//
getPlayer().sendPacket(new PacketFinishedParentQuestUpdateNotify(newQuests));
}
...
...
@@ -112,24 +109,24 @@ public class QuestManager extends BasePlayerManager {
Looking through mainQuests 72201-72208 and 72174, we can infer that a questGlobalVar's default value is 0
*/
public
Integer
getQuestGlobalVarValue
(
Integer
variable
)
{
return
this
.
q
uestGlobalVariables
.
getOrDefault
(
variable
,
0
);
return
getPlayer
().
getQ
uestGlobalVariables
()
.
getOrDefault
(
variable
,
0
);
}
public
void
setQuestGlobalVarValue
(
Integer
variable
,
Integer
value
)
{
Integer
previousValue
=
this
.
q
uestGlobalVariables
.
put
(
variable
,
value
);
Integer
previousValue
=
getPlayer
().
getQ
uestGlobalVariables
()
.
put
(
variable
,
value
);
Grasscutter
.
getLogger
().
debug
(
"Changed questGlobalVar {} value from {} to {}"
,
variable
,
previousValue
==
null
?
0
:
previousValue
,
value
);
}
public
void
incQuestGlobalVarValue
(
Integer
variable
,
Integer
inc
)
{
//
Integer
previousValue
=
this
.
q
uestGlobalVariables
.
getOrDefault
(
variable
,
0
);
this
.
q
uestGlobalVariables
.
put
(
variable
,
previousValue
+
inc
);
Integer
previousValue
=
getPlayer
().
getQ
uestGlobalVariables
()
.
getOrDefault
(
variable
,
0
);
getPlayer
().
getQ
uestGlobalVariables
()
.
put
(
variable
,
previousValue
+
inc
);
Grasscutter
.
getLogger
().
debug
(
"Incremented questGlobalVar {} value from {} to {}"
,
variable
,
previousValue
,
previousValue
+
inc
);
}
//In MainQuest 998, dec is passed as a positive integer
public
void
decQuestGlobalVarValue
(
Integer
variable
,
Integer
dec
)
{
//
Integer
previousValue
=
this
.
q
uestGlobalVariables
.
getOrDefault
(
variable
,
0
);
this
.
q
uestGlobalVariables
.
put
(
variable
,
previousValue
-
dec
);
Integer
previousValue
=
getPlayer
().
getQ
uestGlobalVariables
()
.
getOrDefault
(
variable
,
0
);
getPlayer
().
getQ
uestGlobalVariables
()
.
put
(
variable
,
previousValue
-
dec
);
Grasscutter
.
getLogger
().
debug
(
"Decremented questGlobalVar {} value from {} to {}"
,
variable
,
previousValue
,
previousValue
-
dec
);
}
...
...
src/main/java/emu/grasscutter/game/quest/content/ContentUnlockTransPoint.java
View file @
77f2bcf5
...
...
@@ -10,6 +10,6 @@ import emu.grasscutter.game.quest.handlers.QuestBaseHandler;
public
class
ContentUnlockTransPoint
extends
QuestBaseHandler
{
@Override
public
boolean
execute
(
GameQuest
quest
,
QuestData
.
QuestCondition
condition
,
String
paramStr
,
int
...
params
)
{
return
true
;
return
condition
.
getParam
()[
0
]
==
params
[
0
]
&&
condition
.
getParam
()[
1
]
==
params
[
1
]
;
}
}
src/main/java/emu/grasscutter/game/quest/exec/ExecUnlockPoint.java
View file @
77f2bcf5
...
...
@@ -13,7 +13,7 @@ public class ExecUnlockPoint extends QuestExecHandler {
// Unlock the trans point for the player.
int
sceneId
=
Integer
.
parseInt
(
paramStr
[
0
]);
int
pointId
=
Integer
.
parseInt
(
paramStr
[
1
]);
boolean
isStatue
=
quest
.
getMainQuestId
()
==
303
;
boolean
isStatue
=
quest
.
getMainQuestId
()
==
303
||
quest
.
getMainQuestId
()
==
352
;
quest
.
getOwner
().
getProgressManager
().
unlockTransPoint
(
sceneId
,
pointId
,
isStatue
);
...
...
src/main/java/emu/grasscutter/server/packet/recv/HandlerUnlockTransPointReq.java
View file @
77f2bcf5
...
...
@@ -2,15 +2,18 @@ package emu.grasscutter.server.packet.recv;
import
emu.grasscutter.net.packet.Opcodes
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
import
emu.grasscutter.net.proto.RetcodeOuterClass
;
import
emu.grasscutter.net.proto.UnlockTransPointReqOuterClass.UnlockTransPointReq
;
import
emu.grasscutter.net.packet.PacketHandler
;
import
emu.grasscutter.server.game.GameSession
;
import
emu.grasscutter.server.packet.send.PacketUnlockTransPointRsp
;
@Opcodes
(
PacketOpcodes
.
UnlockTransPointReq
)
public
class
HandlerUnlockTransPointReq
extends
PacketHandler
{
@Override
public
void
handle
(
GameSession
session
,
byte
[]
header
,
byte
[]
payload
)
throws
Exception
{
UnlockTransPointReq
req
=
UnlockTransPointReq
.
parseFrom
(
payload
);
session
.
getPlayer
().
getProgressManager
().
unlockTransPoint
(
req
.
getSceneId
(),
req
.
getPointId
(),
false
);
boolean
unlocked
=
session
.
getPlayer
().
getProgressManager
().
unlockTransPoint
(
req
.
getSceneId
(),
req
.
getPointId
(),
false
);
session
.
getPlayer
().
sendPacket
(
new
PacketUnlockTransPointRsp
(
unlocked
?
RetcodeOuterClass
.
Retcode
.
RET_SUCC
:
RetcodeOuterClass
.
Retcode
.
RET_FAIL
));
}
}
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