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
631a5303
Commit
631a5303
authored
May 13, 2022
by
Melledy
Browse files
Switch to using quest excels
parent
9b26426e
Changes
20
Show whitespace changes
Inline
Side-by-side
src/main/java/emu/grasscutter/data/GameData.java
View file @
631a5303
...
...
@@ -12,7 +12,7 @@ import emu.grasscutter.data.custom.AbilityEmbryoEntry;
import
emu.grasscutter.data.custom.AbilityModifier
;
import
emu.grasscutter.data.custom.AbilityModifierEntry
;
import
emu.grasscutter.data.custom.OpenConfigEntry
;
import
emu.grasscutter.data.custom.Quest
Config
;
import
emu.grasscutter.data.custom.
Main
Quest
Data
;
import
emu.grasscutter.data.custom.ScenePointEntry
;
import
emu.grasscutter.data.def.*
;
import
it.unimi.dsi.fastutil.ints.Int2ObjectLinkedOpenHashMap
;
...
...
@@ -28,7 +28,7 @@ public class GameData {
private
static
final
Map
<
String
,
AbilityModifierEntry
>
abilityModifiers
=
new
HashMap
<>();
private
static
final
Map
<
String
,
OpenConfigEntry
>
openConfigEntries
=
new
HashMap
<>();
private
static
final
Map
<
String
,
ScenePointEntry
>
scenePointEntries
=
new
HashMap
<>();
private
static
final
Int2ObjectMap
<
Quest
Config
>
questConfigs
=
new
Int2ObjectOpenHashMap
<>();
private
static
final
Int2ObjectMap
<
Main
Quest
Data
>
mainQuestData
=
new
Int2ObjectOpenHashMap
<>();
// ExcelConfigs
private
static
final
Int2ObjectMap
<
PlayerLevelData
>
playerLevelDataMap
=
new
Int2ObjectOpenHashMap
<>();
...
...
@@ -70,6 +70,7 @@ public class GameData {
private
static
final
Int2ObjectMap
<
WorldLevelData
>
worldLevelDataMap
=
new
Int2ObjectOpenHashMap
<>();
private
static
final
Int2ObjectMap
<
DailyDungeonData
>
dailyDungeonDataMap
=
new
Int2ObjectOpenHashMap
<>();
private
static
final
Int2ObjectMap
<
DungeonData
>
dungeonDataMap
=
new
Int2ObjectOpenHashMap
<>();
private
static
final
Int2ObjectMap
<
QuestData
>
questDataMap
=
new
Int2ObjectOpenHashMap
<>();
private
static
final
Int2ObjectMap
<
ShopGoodsData
>
shopGoodsDataMap
=
new
Int2ObjectOpenHashMap
<>();
private
static
final
Int2ObjectMap
<
CombineData
>
combineDataMap
=
new
Int2ObjectOpenHashMap
<>();
private
static
final
Int2ObjectMap
<
RewardPreviewData
>
rewardPreviewDataMap
=
new
Int2ObjectOpenHashMap
<>();
...
...
@@ -124,8 +125,8 @@ public class GameData {
return
getScenePointEntries
().
get
(
sceneId
+
"_"
+
pointId
);
}
public
static
Int2ObjectMap
<
Quest
Config
>
getQuest
Configs
()
{
return
questConfigs
;
public
static
Int2ObjectMap
<
Main
Quest
Data
>
get
Main
Quest
DataMap
()
{
return
mainQuestData
;
}
public
static
Int2ObjectMap
<
AvatarData
>
getAvatarDataMap
()
{
...
...
@@ -337,4 +338,8 @@ public class GameData {
public
static
Int2ObjectMap
<
TowerScheduleData
>
getTowerScheduleDataMap
(){
return
towerScheduleDataMap
;
}
public
static
Int2ObjectMap
<
QuestData
>
getQuestDataMap
()
{
return
questDataMap
;
}
}
src/main/java/emu/grasscutter/data/ResourceLoader.java
View file @
631a5303
...
...
@@ -24,9 +24,7 @@ import emu.grasscutter.data.custom.AbilityModifier.AbilityModifierAction;
import
emu.grasscutter.data.custom.AbilityModifier.AbilityModifierActionType
;
import
emu.grasscutter.data.custom.AbilityModifierEntry
;
import
emu.grasscutter.data.custom.OpenConfigEntry
;
import
emu.grasscutter.data.custom.QuestConfig
;
import
emu.grasscutter.data.custom.QuestConfigData
;
import
emu.grasscutter.data.custom.QuestConfigData.SubQuestConfigData
;
import
emu.grasscutter.data.custom.MainQuestData
;
import
emu.grasscutter.data.custom.ScenePointEntry
;
import
emu.grasscutter.game.world.SpawnDataEntry.*
;
import
it.unimi.dsi.fastutil.ints.Int2ObjectMap
;
...
...
@@ -407,24 +405,19 @@ public class ResourceLoader {
}
for
(
File
file
:
folder
.
listFiles
())
{
Quest
Config
Data
mainQuest
=
null
;
Main
QuestData
mainQuest
=
null
;
try
(
FileReader
fileReader
=
new
FileReader
(
file
))
{
mainQuest
=
Grasscutter
.
getGsonFactory
().
fromJson
(
fileReader
,
Quest
Config
Data
.
class
);
mainQuest
=
Grasscutter
.
getGsonFactory
().
fromJson
(
fileReader
,
Main
QuestData
.
class
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
continue
;
}
if
(
mainQuest
.
getSubQuests
()
!=
null
)
{
for
(
SubQuestConfigData
subQuest
:
mainQuest
.
getSubQuests
())
{
QuestConfig
quest
=
new
QuestConfig
(
mainQuest
,
subQuest
);
GameData
.
getQuestConfigs
().
put
(
quest
.
getId
(),
quest
);
}
}
GameData
.
getMainQuestDataMap
().
put
(
mainQuest
.
getId
(),
mainQuest
);
}
Grasscutter
.
getLogger
().
info
(
"Loaded "
+
GameData
.
getQuest
Configs
().
size
()
+
" Quest
Configs
"
);
Grasscutter
.
getLogger
().
info
(
"Loaded "
+
GameData
.
get
Main
Quest
DataMap
().
size
()
+
"
Main
Quest
Datas.
"
);
}
// BinOutput configs
...
...
src/main/java/emu/grasscutter/data/custom/Quest
Config
Data.java
→
src/main/java/emu/grasscutter/data/custom/
Main
QuestData.java
View file @
631a5303
package
emu.grasscutter.data.custom
;
import
emu.grasscutter.game.quest.enums.LogicType
;
import
emu.grasscutter.game.quest.enums.QuestTrigger
Type
;
import
emu.grasscutter.game.quest.enums.QuestTrigger
;
import
emu.grasscutter.game.quest.enums.QuestType
;
public
class
Quest
Config
Data
{
public
class
Main
QuestData
{
private
int
id
;
private
int
series
;
private
QuestType
type
;
...
...
@@ -13,7 +13,7 @@ public class QuestConfigData {
private
int
[]
suggestTrackMainQuestList
;
private
int
[]
rewardIdList
;
private
SubQuest
Config
Data
[]
subQuests
;
private
SubQuestData
[]
subQuests
;
public
int
getId
()
{
return
id
;
...
...
@@ -39,66 +39,15 @@ public class QuestConfigData {
return
rewardIdList
;
}
public
SubQuest
Config
Data
[]
getSubQuests
()
{
public
SubQuestData
[]
getSubQuests
()
{
return
subQuests
;
}
public
class
SubQuest
Config
Data
{
public
static
class
SubQuestData
{
private
int
subId
;
private
int
mainId
;
private
LogicType
acceptCondComb
;
private
QuestCondition
[]
acceptCond
;
private
LogicType
finishCondComb
;
private
QuestCondition
[]
finishCond
;
private
LogicType
failCondComb
;
private
QuestCondition
[]
failCond
;
public
int
getSubId
()
{
return
subId
;
}
public
int
getMainId
()
{
return
mainId
;
}
public
LogicType
getAcceptCondComb
()
{
return
acceptCondComb
;
}
public
QuestCondition
[]
getAcceptCond
()
{
return
acceptCond
;
}
public
LogicType
getFinishCondComb
()
{
return
finishCondComb
;
}
public
QuestCondition
[]
getFinishCond
()
{
return
finishCond
;
}
public
LogicType
getFailCondComb
()
{
return
failCondComb
;
}
public
QuestCondition
[]
getFailCond
()
{
return
failCond
;
}
}
public
class
QuestCondition
{
private
QuestTriggerType
type
;
private
int
[]
param
;
public
QuestTriggerType
getType
()
{
return
type
;
}
public
int
[]
getParam
()
{
return
param
;
}
}
}
src/main/java/emu/grasscutter/data/custom/QuestConfig.java
deleted
100644 → 0
View file @
9b26426e
package
emu.grasscutter.data.custom
;
import
emu.grasscutter.data.custom.QuestConfigData.SubQuestConfigData
;
public
class
QuestConfig
{
private
final
QuestConfigData
mainQuest
;
private
final
SubQuestConfigData
subQuest
;
public
QuestConfig
(
QuestConfigData
mainQuest
,
SubQuestConfigData
subQuest
)
{
this
.
mainQuest
=
mainQuest
;
this
.
subQuest
=
subQuest
;
}
public
int
getId
()
{
return
subQuest
.
getSubId
();
}
public
QuestConfigData
getMainQuest
()
{
return
mainQuest
;
}
public
SubQuestConfigData
getSubQuest
()
{
return
subQuest
;
}
}
src/main/java/emu/grasscutter/data/def/QuestData.java
0 → 100644
View file @
631a5303
package
emu.grasscutter.data.def
;
import
java.util.Arrays
;
import
java.util.List
;
import
emu.grasscutter.data.GameResource
;
import
emu.grasscutter.data.ResourceType
;
import
emu.grasscutter.game.quest.enums.LogicType
;
import
emu.grasscutter.game.quest.enums.QuestTrigger
;
@ResourceType
(
name
=
"QuestExcelConfigData.json"
)
public
class
QuestData
extends
GameResource
{
private
int
SubId
;
private
int
MainId
;
private
int
Order
;
private
long
DescTextMapHash
;
private
LogicType
AcceptCondComb
;
private
QuestCondition
[]
acceptConditons
;
private
LogicType
FinishCondComb
;
private
QuestCondition
[]
finishConditons
;
private
LogicType
FailCondComb
;
private
QuestCondition
[]
failConditons
;
private
List
<
QuestParam
>
AcceptCond
;
private
List
<
QuestParam
>
FinishCond
;
private
List
<
QuestParam
>
FailCond
;
private
List
<
QuestExecParam
>
BeginExec
;
private
List
<
QuestExecParam
>
FinishExec
;
private
List
<
QuestExecParam
>
FailExec
;
public
int
getId
()
{
return
SubId
;
}
public
int
getMainId
()
{
return
MainId
;
}
public
int
getOrder
()
{
return
Order
;
}
public
long
getDescTextMapHash
()
{
return
DescTextMapHash
;
}
public
LogicType
getAcceptCondComb
()
{
return
AcceptCondComb
;
}
public
QuestCondition
[]
getAcceptCond
()
{
return
acceptConditons
;
}
public
LogicType
getFinishCondComb
()
{
return
FinishCondComb
;
}
public
QuestCondition
[]
getFinishCond
()
{
return
finishConditons
;
}
public
LogicType
getFailCondComb
()
{
return
FailCondComb
;
}
public
QuestCondition
[]
getFailCond
()
{
return
failConditons
;
}
public
void
onLoad
()
{
this
.
acceptConditons
=
AcceptCond
.
stream
().
filter
(
p
->
p
.
Type
!=
null
).
map
(
QuestCondition:
:
new
).
toArray
(
QuestCondition
[]::
new
);
AcceptCond
=
null
;
this
.
finishConditons
=
FinishCond
.
stream
().
filter
(
p
->
p
.
Type
!=
null
).
map
(
QuestCondition:
:
new
).
toArray
(
QuestCondition
[]::
new
);
FinishCond
=
null
;
this
.
failConditons
=
FailCond
.
stream
().
filter
(
p
->
p
.
Type
!=
null
).
map
(
QuestCondition:
:
new
).
toArray
(
QuestCondition
[]::
new
);
FailCond
=
null
;
}
public
class
QuestParam
{
QuestTrigger
Type
;
int
[]
Param
;
String
count
;
}
public
class
QuestExecParam
{
QuestTrigger
Type
;
String
[]
Param
;
String
count
;
}
public
static
class
QuestCondition
{
private
QuestTrigger
type
;
private
int
[]
param
;
private
String
count
;
public
QuestCondition
(
QuestParam
param
)
{
this
.
type
=
param
.
Type
;
this
.
param
=
param
.
Param
;
}
public
QuestTrigger
getType
()
{
return
type
;
}
public
int
[]
getParam
()
{
return
param
;
}
public
String
getCount
()
{
return
count
;
}
}
}
src/main/java/emu/grasscutter/game/quest/GameMainQuest.java
View file @
631a5303
...
...
@@ -10,7 +10,6 @@ import dev.morphia.annotations.Id;
import
dev.morphia.annotations.Indexed
;
import
dev.morphia.annotations.Transient
;
import
emu.grasscutter.data.GameData
;
import
emu.grasscutter.data.custom.QuestConfig
;
import
emu.grasscutter.database.DatabaseHelper
;
import
emu.grasscutter.game.player.Player
;
import
emu.grasscutter.game.quest.enums.ParentQuestState
;
...
...
src/main/java/emu/grasscutter/game/quest/GameQuest.java
View file @
631a5303
...
...
@@ -2,9 +2,11 @@ package emu.grasscutter.game.quest;
import
dev.morphia.annotations.Entity
;
import
dev.morphia.annotations.Transient
;
import
emu.grasscutter.data.custom.QuestConfig
;
import
emu.grasscutter.data.custom.QuestConfigData.QuestCondition
;
import
emu.grasscutter.data.custom.QuestConfigData.SubQuestConfigData
;
import
emu.grasscutter.data.GameData
;
import
emu.grasscutter.data.custom.MainQuestData
;
import
emu.grasscutter.data.custom.MainQuestData.SubQuestData
;
import
emu.grasscutter.data.def.QuestData
;
import
emu.grasscutter.data.def.QuestData.QuestCondition
;
import
emu.grasscutter.game.player.Player
;
import
emu.grasscutter.game.quest.enums.LogicType
;
import
emu.grasscutter.game.quest.enums.QuestState
;
...
...
@@ -16,7 +18,7 @@ import emu.grasscutter.utils.Utils;
@Entity
public
class
GameQuest
{
@Transient
private
GameMainQuest
mainQuest
;
@Transient
private
Quest
Config
config
;
@Transient
private
Quest
Data
questData
;
private
int
questId
;
private
int
mainQuestId
;
...
...
@@ -32,21 +34,21 @@ public class GameQuest {
@Deprecated
// Morphia only. Do not use.
public
GameQuest
()
{}
public
GameQuest
(
GameMainQuest
mainQuest
,
Quest
Config
config
)
{
public
GameQuest
(
GameMainQuest
mainQuest
,
Quest
Data
questData
)
{
this
.
mainQuest
=
mainQuest
;
this
.
questId
=
config
.
getId
();
this
.
mainQuestId
=
config
.
getMainQuest
().
get
Id
();
this
.
config
=
config
;
this
.
questId
=
questData
.
getId
();
this
.
mainQuestId
=
questData
.
getMain
Id
();
this
.
questData
=
questData
;
this
.
acceptTime
=
Utils
.
getCurrentSeconds
();
this
.
startTime
=
this
.
acceptTime
;
this
.
state
=
QuestState
.
QUEST_STATE_UNFINISHED
;
if
(
config
.
getSubQuest
()
.
getFinishCond
()
!=
null
)
{
this
.
finishProgressList
=
new
int
[
config
.
getSubQuest
()
.
getFinishCond
().
length
];
if
(
questData
.
getFinishCond
()!=
null
)
{
this
.
finishProgressList
=
new
int
[
questData
.
getFinishCond
().
length
];
}
if
(
config
.
getSubQuest
()
.
getFailCond
()
!=
null
)
{
this
.
failProgressList
=
new
int
[
config
.
getSubQuest
()
.
getFailCond
().
length
];
if
(
questData
.
getFailCond
()
!=
null
)
{
this
.
failProgressList
=
new
int
[
questData
.
getFailCond
().
length
];
}
this
.
mainQuest
.
getChildQuests
().
put
(
this
.
questId
,
this
);
...
...
@@ -72,13 +74,13 @@ public class GameQuest {
return
mainQuestId
;
}
public
Quest
Config
getConfig
()
{
return
config
;
public
Quest
Data
getData
()
{
return
questData
;
}
public
void
setConfig
(
Quest
Config
config
)
{
public
void
setConfig
(
Quest
Data
config
)
{
if
(
this
.
getQuestId
()
!=
config
.
getId
())
return
;
this
.
config
=
config
;
this
.
questData
=
config
;
}
public
QuestState
getState
()
{
...
...
@@ -148,16 +150,23 @@ public class GameQuest {
public
boolean
tryAcceptQuestLine
()
{
try
{
for
(
SubQuestConfigData
questData
:
getConfig
().
getMainQuest
().
getSubQuests
())
{
GameQuest
quest
=
getMainQuest
().
getChildQuestById
(
questData
.
getSubId
());
MainQuestData
questConfig
=
GameData
.
getMainQuestDataMap
().
get
(
this
.
getMainQuestId
());
for
(
SubQuestData
subQuest
:
questConfig
.
getSubQuests
())
{
GameQuest
quest
=
getMainQuest
().
getChildQuestById
(
subQuest
.
getSubId
());
if
(
quest
==
null
)
{
QuestData
questData
=
GameData
.
getQuestDataMap
().
get
(
subQuest
.
getSubId
());
if
(
questData
==
null
)
{
continue
;
}
int
[]
accept
=
new
int
[
questData
.
getAcceptCond
().
length
];
// TODO
for
(
int
i
=
0
;
i
<
questData
.
getAcceptCond
().
length
;
i
++)
{
QuestCondition
condition
=
questData
.
getAcceptCond
()[
i
];
boolean
result
=
getOwner
().
getServer
().
getQuestHandler
().
triggerCondition
(
this
,
condition
);
boolean
result
=
getOwner
().
getServer
().
getQuestHandler
().
triggerCondition
(
this
,
condition
,
condition
.
getParam
()
);
accept
[
i
]
=
result
?
1
:
0
;
}
...
...
@@ -165,7 +174,7 @@ public class GameQuest {
boolean
shouldAccept
=
LogicType
.
calculate
(
questData
.
getAcceptCondComb
(),
accept
);
if
(
shouldAccept
)
{
this
.
getOwner
().
getQuestManager
().
addQuest
(
questData
.
get
Sub
Id
());
this
.
getOwner
().
getQuestManager
().
addQuest
(
questData
.
getId
());
}
}
}
...
...
src/main/java/emu/grasscutter/game/quest/QuestManager.java
View file @
631a5303
...
...
@@ -9,12 +9,11 @@ import java.util.function.Consumer;
import
java.util.function.Function
;
import
emu.grasscutter.data.GameData
;
import
emu.grasscutter.data.custom.QuestConfig
;
import
emu.grasscutter.data.custom.QuestConfigData.QuestCondition
;
import
emu.grasscutter.data.custom.QuestConfigData.SubQuestConfigData
;
import
emu.grasscutter.data.def.QuestData
;
import
emu.grasscutter.data.def.QuestData.QuestCondition
;
import
emu.grasscutter.database.DatabaseHelper
;
import
emu.grasscutter.game.player.Player
;
import
emu.grasscutter.game.quest.enums.QuestTrigger
Type
;
import
emu.grasscutter.game.quest.enums.QuestTrigger
;
import
emu.grasscutter.game.quest.enums.LogicType
;
import
emu.grasscutter.game.quest.enums.QuestState
;
import
emu.grasscutter.server.packet.send.PacketFinishedParentQuestUpdateNotify
;
...
...
@@ -46,12 +45,12 @@ public class QuestManager {
}
public
GameQuest
getQuestById
(
int
questId
)
{
Quest
Config
questConfig
=
GameData
.
getQuest
Configs
().
get
(
questId
);
Quest
Data
questConfig
=
GameData
.
getQuest
DataMap
().
get
(
questId
);
if
(
questConfig
==
null
)
{
return
null
;
}
GameMainQuest
mainQuest
=
getQuests
().
get
(
questConfig
.
getMain
Quest
().
get
Id
());
GameMainQuest
mainQuest
=
getQuests
().
get
(
questConfig
.
getMainId
());
if
(
mainQuest
==
null
)
{
return
null
;
...
...
@@ -79,8 +78,8 @@ public class QuestManager {
}
}
public
GameMainQuest
addMainQuest
(
Quest
Config
questConfig
)
{
GameMainQuest
mainQuest
=
new
GameMainQuest
(
getPlayer
(),
questConfig
.
getMain
Quest
().
get
Id
());
public
GameMainQuest
addMainQuest
(
Quest
Data
questConfig
)
{
GameMainQuest
mainQuest
=
new
GameMainQuest
(
getPlayer
(),
questConfig
.
getMainId
());
getQuests
().
put
(
mainQuest
.
getParentQuestId
(),
mainQuest
);
getPlayer
().
sendPacket
(
new
PacketFinishedParentQuestUpdateNotify
(
mainQuest
));
...
...
@@ -89,13 +88,13 @@ public class QuestManager {
}
public
GameQuest
addQuest
(
int
questId
)
{
Quest
Config
questConfig
=
GameData
.
getQuest
Configs
().
get
(
questId
);
Quest
Data
questConfig
=
GameData
.
getQuest
DataMap
().
get
(
questId
);
if
(
questConfig
==
null
)
{
return
null
;
}
// Main quest
GameMainQuest
mainQuest
=
this
.
getMainQuestById
(
questConfig
.
getMain
Quest
().
get
Id
());
GameMainQuest
mainQuest
=
this
.
getMainQuestById
(
questConfig
.
getMainId
());
// Create main quest if it doesnt exist
if
(
mainQuest
==
null
)
{
...
...
@@ -122,11 +121,11 @@ public class QuestManager {
return
quest
;
}
public
void
triggerEvent
(
QuestTrigger
Type
condType
,
int
...
params
)
{
public
void
triggerEvent
(
QuestTrigger
condType
,
int
...
params
)
{
Set
<
GameQuest
>
changedQuests
=
new
HashSet
<>();
this
.
forEachActiveQuest
(
quest
->
{
Sub
Quest
Config
Data
data
=
quest
.
get
Config
().
getSubQuest
();
QuestData
data
=
quest
.
get
Data
();
for
(
int
i
=
0
;
i
<
data
.
getFinishCond
().
length
;
i
++)
{
if
(
quest
.
getFinishProgressList
()[
i
]
==
1
)
{
...
...
@@ -150,7 +149,7 @@ public class QuestManager {
});
for
(
GameQuest
quest
:
changedQuests
)
{
LogicType
logicType
=
quest
.
get
Config
().
getSubQuest
().
getFailCondComb
();
LogicType
logicType
=
quest
.
get
Data
().
getFailCondComb
();
int
[]
progress
=
quest
.
getFinishProgressList
();
// Handle logical comb
...
...
@@ -174,7 +173,7 @@ public class QuestManager {
for
(
GameQuest
quest
:
mainQuest
.
getChildQuests
().
values
())
{
quest
.
setMainQuest
(
mainQuest
);
quest
.
setConfig
(
GameData
.
getQuest
Configs
().
get
(
quest
.
getQuestId
()));
quest
.
setConfig
(
GameData
.
getQuest
DataMap
().
get
(
quest
.
getQuestId
()));
}
this
.
getQuests
().
put
(
mainQuest
.
getParentQuestId
(),
mainQuest
);
...
...
src/main/java/emu/grasscutter/game/quest/QuestValue.java
View file @
631a5303
...
...
@@ -3,9 +3,9 @@ package emu.grasscutter.game.quest;
import
java.lang.annotation.Retention
;
import
java.lang.annotation.RetentionPolicy
;
import
emu.grasscutter.game.quest.enums.QuestTrigger
Type
;
import
emu.grasscutter.game.quest.enums.QuestTrigger
;
@Retention
(
RetentionPolicy
.
RUNTIME
)
public
@interface
QuestValue
{
QuestTrigger
Type
value
();
QuestTrigger
value
();
}
src/main/java/emu/grasscutter/game/quest/ServerQuestHandler.java
View file @
631a5303
...
...
@@ -4,11 +4,9 @@ import java.util.Set;
import
org.reflections.Reflections
;
import
emu.grasscutter.
data.custom.QuestConfigData.QuestCondition
;
import
emu.grasscutter.
game.quest.enums.QuestTriggerType
;
import
emu.grasscutter.
Grasscutter
;
import
emu.grasscutter.
data.def.QuestData.QuestCondition
;
import
emu.grasscutter.game.quest.handlers.QuestBaseHandler
;
import
emu.grasscutter.net.packet.Opcodes
;
import
emu.grasscutter.server.game.GameServer
;
import
it.unimi.dsi.fastutil.ints.Int2ObjectMap
;
import
it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap
;
...
...
@@ -62,7 +60,7 @@ public class ServerQuestHandler {
public
boolean
triggerCondition
(
GameQuest
quest
,
QuestCondition
condition
,
int
...
params
)
{
QuestBaseHandler
handler
=
condHandlers
.
get
(
condition
.
getType
().
getValue
());
if
(
handler
==
null
||
quest
.
get
Config
()
==
null
)
{
if
(
handler
==
null
||
quest
.
get
Data
()
==
null
)
{
return
false
;
}
...
...
@@ -72,7 +70,7 @@ public class ServerQuestHandler {
public
boolean
triggerContent
(
GameQuest
quest
,
QuestCondition
condition
,
int
...
params
)
{
QuestBaseHandler
handler
=
contHandlers
.
get
(
condition
.
getType
().
getValue
());
if
(
handler
==
null
||
quest
.
get
Config
()
==
null
)
{
if
(
handler
==
null
||
quest
.
get
Data
()
==
null
)
{
return
false
;
}
...
...
@@ -82,7 +80,7 @@ public class ServerQuestHandler {
public
boolean
triggerExec
(
GameQuest
quest
,
QuestCondition
condition
,
int
...
params
)
{
QuestBaseHandler
handler
=
execHandlers
.
get
(
condition
.
getType
().
getValue
());
if
(
handler
==
null
||
quest
.
get
Config
()
==
null
)
{
if
(
handler
==
null
||
quest
.
get
Data
()
==
null
)
{
return
false
;
}
...
...
src/main/java/emu/grasscutter/game/quest/conditions/BaseCondition.java
View file @
631a5303
package
emu.grasscutter.game.quest.conditions
;
import
emu.grasscutter.data.
custom.QuestConfig
Data.QuestCondition
;
import
emu.grasscutter.data.
def.Quest
Data.QuestCondition
;
import
emu.grasscutter.game.quest.QuestValue
;
import
emu.grasscutter.game.quest.GameQuest
;
import
emu.grasscutter.game.quest.enums.QuestTrigger
Type
;
import
emu.grasscutter.game.quest.enums.QuestTrigger
;
import
emu.grasscutter.game.quest.handlers.QuestBaseHandler
;
@QuestValue
(
QuestTrigger
Type
.
QUEST_CONTENT_NONE
)
@QuestValue
(
QuestTrigger
.
QUEST_CONTENT_NONE
)
public
class
BaseCondition
extends
QuestBaseHandler
{
@Override
...
...
src/main/java/emu/grasscutter/game/quest/conditions/ConditionPlayerLevelEqualGreater.java
View file @
631a5303
package
emu.grasscutter.game.quest.conditions
;
import
emu.grasscutter.data.
custom.QuestConfig
Data.QuestCondition
;
import
emu.grasscutter.data.
def.Quest
Data.QuestCondition
;
import
emu.grasscutter.game.quest.QuestValue
;
import
emu.grasscutter.game.quest.GameQuest
;
import
emu.grasscutter.game.quest.enums.QuestTrigger
Type
;
import
emu.grasscutter.game.quest.enums.QuestTrigger
;
import
emu.grasscutter.game.quest.handlers.QuestBaseHandler
;
@QuestValue
(
QuestTrigger
Type
.
QUEST_COND_PLAYER_LEVEL_EQUAL_GREATER
)
@QuestValue
(
QuestTrigger
.
QUEST_COND_PLAYER_LEVEL_EQUAL_GREATER
)
public
class
ConditionPlayerLevelEqualGreater
extends
QuestBaseHandler
{
@Override
public
boolean
execute
(
GameQuest
quest
,
QuestCondition
condition
,
int
...
params
)
{
return
quest
.
getOwner
().
getLevel
()
>=
condition
.
getP
aram
()
[
0
];
return
quest
.
getOwner
().
getLevel
()
>=
p
aram
s
[
0
];
}
}
src/main/java/emu/grasscutter/game/quest/conditions/ConditionStateEqual.java
View file @
631a5303
package
emu.grasscutter.game.quest.conditions
;
import
emu.grasscutter.data.
custom.QuestConfig
Data.QuestCondition
;
import
emu.grasscutter.data.
def.Quest
Data.QuestCondition
;
import
emu.grasscutter.game.quest.QuestValue
;
import
emu.grasscutter.game.quest.GameQuest
;
import
emu.grasscutter.game.quest.enums.QuestTrigger
Type
;
import
emu.grasscutter.game.quest.enums.QuestTrigger
;
import
emu.grasscutter.game.quest.handlers.QuestBaseHandler
;
@QuestValue
(
QuestTrigger
Type
.
QUEST_COND_STATE_EQUAL
)
@QuestValue
(
QuestTrigger
.
QUEST_COND_STATE_EQUAL
)
public
class
ConditionStateEqual
extends
QuestBaseHandler
{
@Override
public
boolean
execute
(
GameQuest
quest
,
QuestCondition
condition
,
int
...
params
)
{
GameQuest
checkQuest
=
quest
.
getOwner
().
getQuestManager
().
getQuestById
(
condition
.
getP
aram
()
[
0
]);
GameQuest
checkQuest
=
quest
.
getOwner
().
getQuestManager
().
getQuestById
(
p
aram
s
[
0
]);
if
(
checkQuest
!=
null
)
{
return
checkQuest
.
getState
().
getValue
()
==
condition
.
getP
aram
()
[
1
];
return
checkQuest
.
getState
().
getValue
()
==
p
aram
s
[
1
];
}
return
false
;
...
...
src/main/java/emu/grasscutter/game/quest/content/BaseContent.java
View file @
631a5303
package
emu.grasscutter.game.quest.content
;
import
emu.grasscutter.data.
custom.QuestConfig
Data.QuestCondition
;
import
emu.grasscutter.data.
def.Quest
Data.QuestCondition
;
import
emu.grasscutter.game.quest.QuestValue
;
import
emu.grasscutter.game.quest.GameQuest
;
import
emu.grasscutter.game.quest.enums.QuestTrigger
Type
;
import
emu.grasscutter.game.quest.enums.QuestTrigger
;
import
emu.grasscutter.game.quest.handlers.QuestBaseHandler
;
@QuestValue
(
QuestTrigger
Type
.
QUEST_CONTENT_NONE
)
@QuestValue
(
QuestTrigger
.
QUEST_CONTENT_NONE
)
public
class
BaseContent
extends
QuestBaseHandler
{
@Override
...
...
src/main/java/emu/grasscutter/game/quest/content/ContentCompleteTalk.java
View file @
631a5303
package
emu.grasscutter.game.quest.content
;
import
emu.grasscutter.data.
custom.QuestConfig
Data.QuestCondition
;
import
emu.grasscutter.data.
def.Quest
Data.QuestCondition
;
import
emu.grasscutter.game.quest.QuestValue
;
import
emu.grasscutter.game.quest.GameQuest
;
import
emu.grasscutter.game.quest.enums.QuestTrigger
Type
;
import
emu.grasscutter.game.quest.enums.QuestTrigger
;
import
emu.grasscutter.game.quest.handlers.QuestBaseHandler
;
@QuestValue
(
QuestTrigger
Type
.
QUEST_CONTENT_COMPLETE_TALK
)
@QuestValue
(
QuestTrigger
.
QUEST_CONTENT_COMPLETE_TALK
)
public
class
ContentCompleteTalk
extends
QuestBaseHandler
{
@Override
...
...
src/main/java/emu/grasscutter/game/quest/enums/QuestTrigger
Type
.java
→
src/main/java/emu/grasscutter/game/quest/enums/QuestTrigger.java
View file @
631a5303
package
emu.grasscutter.game.quest.enums
;
public
enum
QuestTrigger
Type
{
public
enum
QuestTrigger
{
QUEST_COND_NONE
(
0
),
QUEST_COND_STATE_EQUAL
(
1
),
QUEST_COND_STATE_NOT_EQUAL
(
2
),
...
...
@@ -225,7 +225,7 @@ public enum QuestTriggerType {
private
final
int
value
;
QuestTrigger
Type
(
int
id
)
{
QuestTrigger
(
int
id
)
{
this
.
value
=
id
;
}
...
...
src/main/java/emu/grasscutter/game/quest/handlers/QuestBaseHandler.java
View file @
631a5303
package
emu.grasscutter.game.quest.handlers
;
import
emu.grasscutter.data.
custom.QuestConfig
Data.QuestCondition
;
import
emu.grasscutter.data.
def.Quest
Data.QuestCondition
;
import
emu.grasscutter.game.quest.GameQuest
;
public
abstract
class
QuestBaseHandler
{
...
...
src/main/java/emu/grasscutter/server/packet/recv/HandlerNpcTalkReq.java
View file @
631a5303
package
emu.grasscutter.server.packet.recv
;
import
emu.grasscutter.game.inventory.GameItem
;
import
emu.grasscutter.game.quest.enums.QuestTrigger
Type
;
import
emu.grasscutter.game.quest.enums.QuestTrigger
;
import
emu.grasscutter.net.packet.Opcodes
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
import
emu.grasscutter.net.proto.NpcTalkReqOuterClass.NpcTalkReq
;
...
...
@@ -16,7 +16,7 @@ public class HandlerNpcTalkReq extends PacketHandler {
public
void
handle
(
GameSession
session
,
byte
[]
header
,
byte
[]
payload
)
throws
Exception
{
NpcTalkReq
req
=
NpcTalkReq
.
parseFrom
(
payload
);
session
.
getPlayer
().
getQuestManager
().
triggerEvent
(
QuestTrigger
Type
.
QUEST_CONTENT_COMPLETE_TALK
,
req
.
getTalkId
());
session
.
getPlayer
().
getQuestManager
().
triggerEvent
(
QuestTrigger
.
QUEST_CONTENT_COMPLETE_TALK
,
req
.
getTalkId
());
session
.
send
(
new
PacketNpcTalkRsp
(
req
.
getNpcEntityId
(),
req
.
getTalkId
(),
req
.
getEntityId
()));
}
...
...
src/main/java/emu/grasscutter/server/packet/send/PacketServerCondMeetQuestListUpdateNotify.java
View file @
631a5303
package
emu.grasscutter.server.packet.send
;
import
emu.grasscutter.data.GameData
;
import
emu.grasscutter.data.custom.QuestConfig
;
import
emu.grasscutter.game.player.Player
;
import
emu.grasscutter.game.quest.GameMainQuest
;
import
emu.grasscutter.game.quest.GameQuest
;
import
emu.grasscutter.net.packet.BasePacket
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
...
...
src/main/java/emu/grasscutter/tools/Tools.java
View file @
631a5303
...
...
@@ -19,10 +19,11 @@ import emu.grasscutter.command.Command;
import
emu.grasscutter.command.CommandMap
;
import
emu.grasscutter.data.GameData
;
import
emu.grasscutter.data.ResourceLoader
;
import
emu.grasscutter.data.custom.Quest
Config
;
import
emu.grasscutter.data.custom.
Main
Quest
Data
;
import
emu.grasscutter.data.def.AvatarData
;
import
emu.grasscutter.data.def.ItemData
;
import
emu.grasscutter.data.def.MonsterData
;
import
emu.grasscutter.data.def.QuestData
;
import
emu.grasscutter.data.def.SceneData
;
import
emu.grasscutter.utils.Utils
;
...
...
@@ -149,13 +150,16 @@ final class ToolsWithLanguageOption {
writer
.
println
(
data
.
getId
()
+
" : "
+
data
.
getScriptData
());
}
writer
.
println
();
writer
.
println
(
"// Quests"
);
list
=
new
ArrayList
<>(
GameData
.
getQuest
Configs
().
keySet
());
list
=
new
ArrayList
<>(
GameData
.
getQuest
DataMap
().
keySet
());
Collections
.
sort
(
list
);
for
(
Integer
id
:
list
)
{
QuestConfig
data
=
GameData
.
getQuestConfigs
().
get
(
id
);
writer
.
println
(
data
.
getId
()
+
" : "
+
map
.
get
(
data
.
getMainQuest
().
getTitleTextMapHash
()));
QuestData
data
=
GameData
.
getQuestDataMap
().
get
(
id
);
MainQuestData
mainQuest
=
GameData
.
getMainQuestDataMap
().
get
(
data
.
getMainId
());
writer
.
println
(
data
.
getId
()
+
" : "
+
map
.
get
(
mainQuest
.
getTitleTextMapHash
())
+
" - "
+
map
.
get
(
data
.
getDescTextMapHash
()));
}
writer
.
println
();
...
...
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