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
02a56fce
Commit
02a56fce
authored
Jul 23, 2022
by
akatatsu27
Browse files
Major questing improvements
parent
89717f3c
Changes
35
Hide whitespace changes
Inline
Side-by-side
src/main/java/emu/grasscutter/game/quest/content/ContentQuestVarLess.java
0 → 100644
View file @
02a56fce
package
emu.grasscutter.game.quest.content
;
import
emu.grasscutter.Grasscutter
;
import
emu.grasscutter.data.excels.QuestData
;
import
emu.grasscutter.game.quest.GameQuest
;
import
emu.grasscutter.game.quest.QuestValue
;
import
emu.grasscutter.game.quest.enums.QuestTrigger
;
import
emu.grasscutter.game.quest.handlers.QuestBaseHandler
;
@QuestValue
(
QuestTrigger
.
QUEST_CONTENT_QUEST_VAR_LESS
)
public
class
ContentQuestVarLess
extends
QuestBaseHandler
{
@Override
public
boolean
execute
(
GameQuest
quest
,
QuestData
.
QuestCondition
condition
,
String
paramStr
,
int
...
params
)
{
int
questVarValue
=
quest
.
getMainQuest
().
getQuestVars
()[
params
[
0
]];
Grasscutter
.
getLogger
().
debug
(
"questVar {} : {}"
,
params
[
0
],
questVarValue
);
return
questVarValue
<
params
[
1
];
}
}
src/main/java/emu/grasscutter/game/quest/content/ContentTriggerFire.java
0 → 100644
View file @
02a56fce
package
emu.grasscutter.game.quest.content
;
import
emu.grasscutter.Grasscutter
;
import
emu.grasscutter.data.GameData
;
import
emu.grasscutter.data.excels.QuestData
;
import
emu.grasscutter.data.excels.TriggerExcelConfigData
;
import
emu.grasscutter.game.quest.GameQuest
;
import
emu.grasscutter.game.quest.QuestValue
;
import
emu.grasscutter.game.quest.enums.QuestTrigger
;
import
emu.grasscutter.game.quest.handlers.QuestBaseHandler
;
@QuestValue
(
QuestTrigger
.
QUEST_CONTENT_TRIGGER_FIRE
)
public
class
ContentTriggerFire
extends
QuestBaseHandler
{
@Override
public
boolean
execute
(
GameQuest
quest
,
QuestData
.
QuestCondition
condition
,
String
paramStr
,
int
...
params
)
{
if
(
quest
.
getTriggers
().
containsKey
(
quest
.
getTriggerNameById
(
params
[
0
])))
{
//We don't want to put a new key here
return
quest
.
getTriggers
().
get
(
quest
.
getTriggerNameById
(
params
[
0
]));
}
else
{
Grasscutter
.
getLogger
().
error
(
"quest {} doesn't have trigger {}"
,
quest
.
getSubQuestId
(),
params
[
0
]);
return
false
;
}
}
}
src/main/java/emu/grasscutter/game/quest/content/ContentUnlockTransPoint.java
0 → 100644
View file @
02a56fce
package
emu.grasscutter.game.quest.content
;
import
emu.grasscutter.data.excels.QuestData
;
import
emu.grasscutter.game.quest.GameQuest
;
import
emu.grasscutter.game.quest.QuestValue
;
import
emu.grasscutter.game.quest.enums.QuestTrigger
;
import
emu.grasscutter.game.quest.handlers.QuestBaseHandler
;
@QuestValue
(
QuestTrigger
.
QUEST_CONTENT_UNLOCK_TRANS_POINT
)
public
class
ContentUnlockTransPoint
extends
QuestBaseHandler
{
@Override
public
boolean
execute
(
GameQuest
quest
,
QuestData
.
QuestCondition
condition
,
String
paramStr
,
int
...
params
)
{
return
true
;
}
}
src/main/java/emu/grasscutter/game/quest/exec/ExecDecQuestGlobalVar.java
0 → 100644
View file @
02a56fce
package
emu.grasscutter.game.quest.exec
;
import
emu.grasscutter.data.excels.QuestData
;
import
emu.grasscutter.game.quest.GameQuest
;
import
emu.grasscutter.game.quest.QuestValue
;
import
emu.grasscutter.game.quest.enums.QuestTrigger
;
import
emu.grasscutter.game.quest.handlers.QuestExecHandler
;
@QuestValue
(
QuestTrigger
.
QUEST_EXEC_DEC_QUEST_GLOBAL_VAR
)
public
class
ExecDecQuestGlobalVar
extends
QuestExecHandler
{
@Override
public
boolean
execute
(
GameQuest
quest
,
QuestData
.
QuestExecParam
condition
,
String
...
paramStr
)
{
quest
.
getOwner
().
getQuestManager
().
decQuestGlobalVarValue
(
Integer
.
valueOf
(
paramStr
[
0
]),
Integer
.
valueOf
(
paramStr
[
1
]));
return
true
;
}
}
src/main/java/emu/grasscutter/game/quest/exec/ExecDecQuestVar.java
0 → 100644
View file @
02a56fce
package
emu.grasscutter.game.quest.exec
;
import
emu.grasscutter.data.excels.QuestData
;
import
emu.grasscutter.game.quest.GameQuest
;
import
emu.grasscutter.game.quest.QuestValue
;
import
emu.grasscutter.game.quest.enums.QuestTrigger
;
import
emu.grasscutter.game.quest.handlers.QuestExecHandler
;
@QuestValue
(
QuestTrigger
.
QUEST_EXEC_DEC_QUEST_VAR
)
public
class
ExecDecQuestVar
extends
QuestExecHandler
{
@Override
public
boolean
execute
(
GameQuest
quest
,
QuestData
.
QuestExecParam
condition
,
String
...
paramStr
)
{
quest
.
getMainQuest
().
decQuestVar
(
Integer
.
parseInt
(
paramStr
[
0
]),
Integer
.
parseInt
(
paramStr
[
1
]));
return
true
;
}
}
src/main/java/emu/grasscutter/game/quest/exec/ExecIncQuestGlobalVar.java
0 → 100644
View file @
02a56fce
package
emu.grasscutter.game.quest.exec
;
import
emu.grasscutter.data.excels.QuestData
;
import
emu.grasscutter.game.quest.GameQuest
;
import
emu.grasscutter.game.quest.QuestValue
;
import
emu.grasscutter.game.quest.enums.QuestTrigger
;
import
emu.grasscutter.game.quest.handlers.QuestExecHandler
;
@QuestValue
(
QuestTrigger
.
QUEST_EXEC_INC_QUEST_GLOBAL_VAR
)
public
class
ExecIncQuestGlobalVar
extends
QuestExecHandler
{
@Override
public
boolean
execute
(
GameQuest
quest
,
QuestData
.
QuestExecParam
condition
,
String
...
paramStr
)
{
quest
.
getOwner
().
getQuestManager
().
incQuestGlobalVarValue
(
Integer
.
valueOf
(
paramStr
[
0
]),
Integer
.
valueOf
(
paramStr
[
1
]));
return
true
;
}
}
\ No newline at end of file
src/main/java/emu/grasscutter/game/quest/exec/ExecIncQuestVar.java
0 → 100644
View file @
02a56fce
package
emu.grasscutter.game.quest.exec
;
import
emu.grasscutter.data.excels.QuestData
;
import
emu.grasscutter.game.quest.GameQuest
;
import
emu.grasscutter.game.quest.QuestValue
;
import
emu.grasscutter.game.quest.enums.QuestTrigger
;
import
emu.grasscutter.game.quest.handlers.QuestExecHandler
;
@QuestValue
(
QuestTrigger
.
QUEST_EXEC_INC_QUEST_VAR
)
public
class
ExecIncQuestVar
extends
QuestExecHandler
{
@Override
public
boolean
execute
(
GameQuest
quest
,
QuestData
.
QuestExecParam
condition
,
String
...
paramStr
)
{
quest
.
getMainQuest
().
incQuestVar
(
Integer
.
parseInt
(
paramStr
[
0
]),
Integer
.
parseInt
(
paramStr
[
1
]));
return
true
;
}
}
src/main/java/emu/grasscutter/game/quest/exec/ExecSetQuestGlobalVar.java
0 → 100644
View file @
02a56fce
package
emu.grasscutter.game.quest.exec
;
import
emu.grasscutter.data.excels.QuestData
;
import
emu.grasscutter.game.quest.GameQuest
;
import
emu.grasscutter.game.quest.QuestValue
;
import
emu.grasscutter.game.quest.enums.QuestTrigger
;
import
emu.grasscutter.game.quest.handlers.QuestExecHandler
;
@QuestValue
(
QuestTrigger
.
QUEST_EXEC_SET_QUEST_GLOBAL_VAR
)
public
class
ExecSetQuestGlobalVar
extends
QuestExecHandler
{
@Override
public
boolean
execute
(
GameQuest
quest
,
QuestData
.
QuestExecParam
condition
,
String
...
paramStr
)
{
quest
.
getOwner
().
getQuestManager
().
setQuestGlobalVarValue
(
Integer
.
valueOf
(
paramStr
[
0
]),
Integer
.
valueOf
(
paramStr
[
1
]));
return
true
;
}
}
src/main/java/emu/grasscutter/game/quest/exec/ExecSetQuestVar.java
0 → 100644
View file @
02a56fce
package
emu.grasscutter.game.quest.exec
;
import
emu.grasscutter.data.excels.QuestData
;
import
emu.grasscutter.game.quest.GameQuest
;
import
emu.grasscutter.game.quest.QuestValue
;
import
emu.grasscutter.game.quest.enums.QuestTrigger
;
import
emu.grasscutter.game.quest.handlers.QuestExecHandler
;
@QuestValue
(
QuestTrigger
.
QUEST_EXEC_SET_QUEST_VAR
)
public
class
ExecSetQuestVar
extends
QuestExecHandler
{
@Override
public
boolean
execute
(
GameQuest
quest
,
QuestData
.
QuestExecParam
condition
,
String
...
paramStr
)
{
quest
.
getMainQuest
().
setQuestVar
(
Integer
.
parseInt
(
paramStr
[
0
]),
Integer
.
parseInt
(
paramStr
[
1
]));
return
true
;
}
}
src/main/java/emu/grasscutter/game/world/Scene.java
View file @
02a56fce
...
...
@@ -627,8 +627,14 @@ public class Scene {
.
flatMap
(
Collection:
:
stream
)
.
toList
();
onLoadGroup
(
groups
);
Grasscutter
.
getLogger
().
info
(
"Scene {} Block {} loaded."
,
this
.
getId
(),
block
.
id
);
onLoadGroup
(
groups
);
Grasscutter
.
getLogger
().
info
(
"Scene {} Block {} loaded."
,
this
.
getId
(),
block
.
id
);
}
public
void
loadTriggerFromGroup
(
SceneGroup
group
,
String
triggerName
)
{
//Load triggers and regions
getScriptManager
().
registerTrigger
(
group
.
triggers
.
values
().
stream
().
filter
(
p
->
p
.
name
.
contains
(
triggerName
)).
toList
());
group
.
regions
.
values
().
stream
().
filter
(
q
->
q
.
config_id
==
Integer
.
parseInt
(
triggerName
.
substring
(
13
))).
map
(
region
->
new
EntityRegion
(
this
,
region
))
.
forEach
(
getScriptManager
()::
registerRegion
);
}
public
void
onLoadGroup
(
List
<
SceneGroup
>
groups
)
{
...
...
src/main/java/emu/grasscutter/server/packet/recv/HandlerPersonalLineAllDataReq.java
View file @
02a56fce
...
...
@@ -11,7 +11,7 @@ public class HandlerPersonalLineAllDataReq extends PacketHandler {
@Override
public
void
handle
(
GameSession
session
,
byte
[]
header
,
byte
[]
payload
)
throws
Exception
{
session
.
send
(
new
PacketPersonalLineAllDataRsp
(
session
.
getPlayer
().
getQuestManager
().
getQuests
().
values
()));
session
.
send
(
new
PacketPersonalLineAllDataRsp
(
session
.
getPlayer
().
getQuestManager
().
get
Main
Quests
().
values
()));
}
}
src/main/java/emu/grasscutter/server/packet/recv/HandlerQuestUpdateQuestVarReq.java
0 → 100644
View file @
02a56fce
package
emu.grasscutter.server.packet.recv
;
import
emu.grasscutter.game.quest.GameMainQuest
;
import
emu.grasscutter.net.packet.Opcodes
;
import
emu.grasscutter.net.packet.PacketHandler
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
import
emu.grasscutter.net.proto.PacketHeadOuterClass
;
import
emu.grasscutter.net.proto.PlayerSetPauseReqOuterClass
;
import
emu.grasscutter.net.proto.QuestUpdateQuestVarReqOuterClass
;
import
emu.grasscutter.net.proto.QuestVarOpOuterClass
;
import
emu.grasscutter.server.game.GameSession
;
import
emu.grasscutter.server.packet.send.PacketPlayerSetPauseRsp
;
import
emu.grasscutter.server.packet.send.PacketQuestUpdateQuestVarRsp
;
import
java.util.List
;
@Opcodes
(
PacketOpcodes
.
QuestUpdateQuestVarReq
)
public
class
HandlerQuestUpdateQuestVarReq
extends
PacketHandler
{
@Override
public
void
handle
(
GameSession
session
,
byte
[]
header
,
byte
[]
payload
)
throws
Exception
{
//Client sends packets. One with the value, and one with the index and the new value to set/inc/dec
var
req
=
QuestUpdateQuestVarReqOuterClass
.
QuestUpdateQuestVarReq
.
parseFrom
(
payload
);
GameMainQuest
mainQuest
=
session
.
getPlayer
().
getQuestManager
().
getMainQuestById
(
req
.
getQuestId
()/
100
);
List
<
QuestVarOpOuterClass
.
QuestVarOp
>
questVars
=
req
.
getQuestVarOpListList
();
if
(
mainQuest
.
getQuestVarsUpdate
().
size
()
==
0
)
{
for
(
QuestVarOpOuterClass
.
QuestVarOp
questVar
:
questVars
)
{
mainQuest
.
getQuestVarsUpdate
().
add
(
questVar
.
getValue
());
}
}
else
{
for
(
QuestVarOpOuterClass
.
QuestVarOp
questVar
:
questVars
)
{
if
(
questVar
.
getIsAdd
())
{
if
(
questVar
.
getValue
()
>=
0
)
{
mainQuest
.
incQuestVar
(
questVar
.
getIndex
(),
questVar
.
getValue
());
}
else
{
mainQuest
.
decQuestVar
(
questVar
.
getIndex
(),
questVar
.
getValue
());
}
}
else
{
mainQuest
.
setQuestVar
(
questVar
.
getIndex
(),
mainQuest
.
getQuestVarsUpdate
().
get
(
0
));
}
//remove the first element from the update list
mainQuest
.
getQuestVarsUpdate
().
remove
(
0
);
}
}
session
.
send
(
new
PacketQuestUpdateQuestVarRsp
(
req
.
getQuestId
()));
}
}
src/main/java/emu/grasscutter/server/packet/send/PacketQuestProgressUpdateNotify.java
View file @
02a56fce
...
...
@@ -7,24 +7,24 @@ import emu.grasscutter.net.packet.PacketOpcodes;
import
emu.grasscutter.net.proto.QuestProgressUpdateNotifyOuterClass.QuestProgressUpdateNotify
;
public
class
PacketQuestProgressUpdateNotify
extends
BasePacket
{
public
PacketQuestProgressUpdateNotify
(
GameQuest
quest
)
{
super
(
PacketOpcodes
.
QuestProgressUpdateNotify
);
QuestProgressUpdateNotify
.
Builder
proto
=
QuestProgressUpdateNotify
.
newBuilder
().
setQuestId
(
quest
.
getQuestId
());
QuestProgressUpdateNotify
.
Builder
proto
=
QuestProgressUpdateNotify
.
newBuilder
().
setQuestId
(
quest
.
get
Sub
QuestId
());
if
(
quest
.
getFinishProgressList
()
!=
null
)
{
for
(
int
i
:
quest
.
getFinishProgressList
())
{
proto
.
addFinishProgressList
(
i
);
}
}
if
(
quest
.
getFailProgressList
()
!=
null
)
{
for
(
int
i
:
quest
.
getFailProgressList
())
{
proto
.
addFailProgressList
(
i
);
}
}
this
.
setData
(
proto
);
}
}
src/main/java/emu/grasscutter/server/packet/send/PacketQuestUpdateQuestVarRsp.java
0 → 100644
View file @
02a56fce
package
emu.grasscutter.server.packet.send
;
import
emu.grasscutter.net.packet.BasePacket
;
import
emu.grasscutter.net.packet.Opcodes
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
import
emu.grasscutter.net.proto.QuestUpdateQuestVarReqOuterClass
;
import
emu.grasscutter.net.proto.QuestUpdateQuestVarRspOuterClass
;
@Opcodes
(
PacketOpcodes
.
QuestUpdateQuestVarReq
)
public
class
PacketQuestUpdateQuestVarRsp
extends
BasePacket
{
public
PacketQuestUpdateQuestVarRsp
(
int
questId
)
{
super
(
PacketOpcodes
.
QuestUpdateQuestVarRsp
);
var
rsp
=
QuestUpdateQuestVarRspOuterClass
.
QuestUpdateQuestVarRsp
.
newBuilder
()
.
setQuestId
(
questId
).
build
();
this
.
setData
(
rsp
);
}
}
src/main/java/emu/grasscutter/server/packet/send/PacketServerCondMeetQuestListUpdateNotify.java
View file @
02a56fce
...
...
@@ -6,8 +6,11 @@ import emu.grasscutter.net.packet.BasePacket;
import
emu.grasscutter.net.packet.PacketOpcodes
;
import
emu.grasscutter.net.proto.ServerCondMeetQuestListUpdateNotifyOuterClass.ServerCondMeetQuestListUpdateNotify
;
import
java.util.List
;
import
java.util.Set
;
public
class
PacketServerCondMeetQuestListUpdateNotify
extends
BasePacket
{
public
PacketServerCondMeetQuestListUpdateNotify
(
Player
player
)
{
super
(
PacketOpcodes
.
ServerCondMeetQuestListUpdateNotify
);
...
...
@@ -23,13 +26,24 @@ public class PacketServerCondMeetQuestListUpdateNotify extends BasePacket {
this
.
setData
(
proto
);
}
public
PacketServerCondMeetQuestListUpdateNotify
(
GameQuest
quest
)
{
public
PacketServerCondMeetQuestListUpdateNotify
(
List
<
GameQuest
>
quest
s
)
{
super
(
PacketOpcodes
.
ServerCondMeetQuestListUpdateNotify
);
ServerCondMeetQuestListUpdateNotify
proto
=
ServerCondMeetQuestListUpdateNotify
.
newBuilder
()
//.addAddQuestIdList(quest.getQuestId())
.
build
();
ServerCondMeetQuestListUpdateNotify
.
Builder
proto
=
ServerCondMeetQuestListUpdateNotify
.
newBuilder
();
for
(
GameQuest
quest
:
quests
)
{
proto
.
addAddQuestIdList
(
quest
.
getSubQuestId
());
}
proto
.
build
();
this
.
setData
(
proto
);
}
public
PacketServerCondMeetQuestListUpdateNotify
()
{
super
(
PacketOpcodes
.
ServerCondMeetQuestListUpdateNotify
);
ServerCondMeetQuestListUpdateNotify
.
Builder
proto
=
ServerCondMeetQuestListUpdateNotify
.
newBuilder
();
proto
.
build
();
this
.
setData
(
proto
);
}
...
...
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