mirror of
https://github.com/FlourishingWorld/hk4e.git
synced 2026-02-04 14:22:26 +08:00
实现更多的触发器
This commit is contained in:
@@ -65,6 +65,7 @@ type GameDataConfig struct {
|
||||
ChestDropDataMap map[string]map[int32]*ChestDropData // 宝箱掉落
|
||||
DungeonDataMap map[int32]*DungeonData // 地牢
|
||||
GadgetDataMap map[int32]*GadgetData // 物件
|
||||
RefreshPolicyDataMap map[int32]*RefreshPolicyData // 刷新策略
|
||||
GCGCharDataMap map[int32]*GCGCharData // 七圣召唤角色卡牌
|
||||
GCGSkillDataMap map[int32]*GCGSkillData // 七圣召唤卡牌技能
|
||||
GachaDropGroupDataMap map[int32]*GachaDropGroupData // 卡池掉落组 临时的
|
||||
@@ -166,6 +167,7 @@ func (g *GameDataConfig) load() {
|
||||
g.loadChestDropData() // 宝箱掉落
|
||||
g.loadDungeonData() // 地牢
|
||||
g.loadGadgetData() // 物件
|
||||
g.loadRefreshPolicyData() // 刷新策略
|
||||
g.loadGCGCharData() // 七圣召唤角色卡牌
|
||||
g.loadGCGSkillData() // 七圣召唤卡牌技能
|
||||
g.loadGachaDropGroupData() // 卡池掉落组 临时的
|
||||
@@ -291,6 +293,9 @@ func initLuaState(luaState *lua.LState) {
|
||||
luaState.SetField(eventType, "EVENT_ANY_MONSTER_DIE", lua.LNumber(constant.LUA_EVENT_ANY_MONSTER_DIE))
|
||||
luaState.SetField(eventType, "EVENT_ANY_MONSTER_LIVE", lua.LNumber(constant.LUA_EVENT_ANY_MONSTER_LIVE))
|
||||
luaState.SetField(eventType, "EVENT_QUEST_START", lua.LNumber(constant.LUA_EVENT_QUEST_START))
|
||||
luaState.SetField(eventType, "EVENT_GADGET_CREATE", lua.LNumber(constant.LUA_EVENT_GADGET_CREATE))
|
||||
luaState.SetField(eventType, "EVENT_GADGET_STATE_CHANGE", lua.LNumber(constant.LUA_EVENT_GADGET_STATE_CHANGE))
|
||||
luaState.SetField(eventType, "EVENT_GROUP_LOAD", lua.LNumber(constant.LUA_EVENT_GROUP_LOAD))
|
||||
|
||||
entityType := luaState.NewTable()
|
||||
luaState.SetGlobal("EntityType", entityType)
|
||||
|
||||
@@ -20,7 +20,7 @@ func (g *GameDataConfig) loadPlayerLevelData() {
|
||||
logger.Info("PlayerLevelData count: %v", len(g.PlayerLevelDataMap))
|
||||
}
|
||||
|
||||
func GetPlayerLevelDataById(level int32) *PlayerLevelData {
|
||||
func GetPlayerLevelDataByLevel(level int32) *PlayerLevelData {
|
||||
return CONF.PlayerLevelDataMap[level]
|
||||
}
|
||||
|
||||
|
||||
73
gdconf/refresh_policy_data.go
Normal file
73
gdconf/refresh_policy_data.go
Normal file
@@ -0,0 +1,73 @@
|
||||
package gdconf
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"hk4e/pkg/logger"
|
||||
)
|
||||
|
||||
const (
|
||||
RefreshTypeNone = 0
|
||||
RefreshTypeAfterTime = 1
|
||||
RefreshTypeDayTime = 2
|
||||
RefreshTypeDayTimeRange = 3
|
||||
RefreshTypeDay = 4
|
||||
)
|
||||
|
||||
// RefreshPolicyData 刷新策略配置表
|
||||
type RefreshPolicyData struct {
|
||||
RefreshId int32 `csv:"刷新ID"`
|
||||
RefreshType int32 `csv:"刷新方式,omitempty"`
|
||||
RefreshTimeStr string `csv:"刷新时间,omitempty"`
|
||||
|
||||
RefreshTime int32
|
||||
RefreshTimeRange [2]int32
|
||||
}
|
||||
|
||||
func (g *GameDataConfig) loadRefreshPolicyData() {
|
||||
g.RefreshPolicyDataMap = make(map[int32]*RefreshPolicyData)
|
||||
refreshPolicyDataList := make([]*RefreshPolicyData, 0)
|
||||
readTable[RefreshPolicyData](g.txtPrefix+"RefreshPolicyData.txt", &refreshPolicyDataList)
|
||||
for _, refreshPolicyData := range refreshPolicyDataList {
|
||||
if refreshPolicyData.RefreshType < RefreshTypeNone || refreshPolicyData.RefreshType > RefreshTypeDay {
|
||||
info := fmt.Sprintf("invalid refresh type: %v", refreshPolicyData)
|
||||
panic(info)
|
||||
}
|
||||
if refreshPolicyData.RefreshType == RefreshTypeDayTimeRange {
|
||||
split := strings.Split(refreshPolicyData.RefreshTimeStr, ";")
|
||||
if len(split) != 2 {
|
||||
info := fmt.Sprintf("refresh time format error: %v", refreshPolicyData)
|
||||
panic(info)
|
||||
}
|
||||
startTime, err := strconv.Atoi(split[0])
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
endTime, err := strconv.Atoi(split[1])
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
refreshPolicyData.RefreshTimeRange = [2]int32{int32(startTime), int32(endTime)}
|
||||
} else if refreshPolicyData.RefreshType == RefreshTypeNone {
|
||||
refreshPolicyData.RefreshTime = 0
|
||||
} else {
|
||||
refreshTime, err := strconv.Atoi(refreshPolicyData.RefreshTimeStr)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
refreshPolicyData.RefreshTime = int32(refreshTime)
|
||||
}
|
||||
g.RefreshPolicyDataMap[refreshPolicyData.RefreshId] = refreshPolicyData
|
||||
}
|
||||
logger.Info("RefreshPolicyData count: %v", len(g.RefreshPolicyDataMap))
|
||||
}
|
||||
|
||||
func GetRefreshPolicyDataById(refreshId int32) *RefreshPolicyData {
|
||||
return CONF.RefreshPolicyDataMap[refreshId]
|
||||
}
|
||||
|
||||
func GetRefreshPolicyDataMap() map[int32]*RefreshPolicyData {
|
||||
return CONF.RefreshPolicyDataMap
|
||||
}
|
||||
@@ -54,21 +54,22 @@ type BlockRange struct {
|
||||
}
|
||||
|
||||
type Group struct {
|
||||
Id int32 `json:"id"`
|
||||
RefreshId int32 `json:"refresh_id"`
|
||||
Area int32 `json:"area"`
|
||||
Pos *Vector `json:"pos"`
|
||||
DynamicLoad bool `json:"dynamic_load"`
|
||||
IsReplaceable *Replaceable `json:"is_replaceable"`
|
||||
MonsterMap map[int32]*Monster `json:"-"` // 怪物
|
||||
NpcMap map[int32]*Npc `json:"-"` // NPC
|
||||
GadgetMap map[int32]*Gadget `json:"-"` // 物件
|
||||
RegionMap map[int32]*Region `json:"-"` // 区域
|
||||
TriggerMap map[string]*Trigger `json:"-"` // 触发器
|
||||
GroupInitConfig *GroupInitConfig `json:"-"` // 初始化配置
|
||||
SuiteMap map[int32]*Suite `json:"-"` // 小组配置
|
||||
LuaStr string `json:"-"` // LUA原始字符串缓存
|
||||
LuaState *lua.LState `json:"-"` // LUA虚拟机实例
|
||||
Id int32 `json:"id"`
|
||||
RefreshId int32 `json:"refresh_id"`
|
||||
Area int32 `json:"area"`
|
||||
Pos *Vector `json:"pos"`
|
||||
DynamicLoad bool `json:"dynamic_load"`
|
||||
IsReplaceable *Replaceable `json:"is_replaceable"`
|
||||
MonsterMap map[int32]*Monster `json:"-"` // 怪物
|
||||
NpcMap map[int32]*Npc `json:"-"` // NPC
|
||||
GadgetMap map[int32]*Gadget `json:"-"` // 物件
|
||||
RegionMap map[int32]*Region `json:"-"` // 区域
|
||||
TriggerMap map[string]*Trigger `json:"-"` // 触发器
|
||||
VariableMap map[string]*Variable `json:"-"` // 变量
|
||||
GroupInitConfig *GroupInitConfig `json:"-"` // 初始化配置
|
||||
SuiteMap map[int32]*Suite `json:"-"` // 小组配置
|
||||
LuaStr string `json:"-"` // LUA原始字符串缓存
|
||||
LuaState *lua.LState `json:"-"` // LUA虚拟机实例
|
||||
}
|
||||
|
||||
type GroupInitConfig struct {
|
||||
@@ -91,6 +92,7 @@ type Monster struct {
|
||||
Level int32 `json:"level"`
|
||||
AreaId int32 `json:"area_id"`
|
||||
DropTag string `json:"drop_tag"` // 关联MonsterDropData表
|
||||
IsOneOff bool `json:"isOneoff"`
|
||||
}
|
||||
|
||||
type Npc struct {
|
||||
@@ -112,6 +114,8 @@ type Gadget struct {
|
||||
State int32 `json:"state"`
|
||||
VisionLevel int32 `json:"vision_level"`
|
||||
DropTag string `json:"drop_tag"`
|
||||
IsOneOff bool `json:"isOneoff"`
|
||||
ChestDropId int32 `json:"chest_drop_id"`
|
||||
}
|
||||
|
||||
type Region struct {
|
||||
@@ -135,6 +139,13 @@ type Trigger struct {
|
||||
TriggerCount int32 `json:"trigger_count"`
|
||||
}
|
||||
|
||||
type Variable struct {
|
||||
ConfigId int32 `json:"config_id"`
|
||||
Name string `json:"name"`
|
||||
Value int32 `json:"value"`
|
||||
NoRefresh bool `json:"no_refresh"`
|
||||
}
|
||||
|
||||
type SuiteLuaTable struct {
|
||||
MonsterConfigIdList any `json:"monsters"` // 怪物
|
||||
GadgetConfigIdList any `json:"gadgets"` // 物件
|
||||
@@ -231,6 +242,18 @@ func (g *GameDataConfig) loadGroup(group *Group, block *Block, sceneId int32, bl
|
||||
for _, trigger := range triggerList {
|
||||
group.TriggerMap[trigger.Name] = trigger
|
||||
}
|
||||
// variables
|
||||
variableList := make([]*Variable, 0)
|
||||
ok = getSceneLuaConfigTable[*[]*Variable](luaState, "variables", &variableList)
|
||||
if !ok {
|
||||
logger.Error("get variables object error, sceneId: %v, blockId: %v, groupId: %v", sceneId, blockId, groupId)
|
||||
luaState.Close()
|
||||
return
|
||||
}
|
||||
group.VariableMap = make(map[string]*Variable)
|
||||
for _, variable := range variableList {
|
||||
group.VariableMap[variable.Name] = variable
|
||||
}
|
||||
// suites
|
||||
suiteLuaTableList := make([]*SuiteLuaTable, 0)
|
||||
ok = getSceneLuaConfigTable[*[]*SuiteLuaTable](luaState, "suites", &suiteLuaTableList)
|
||||
|
||||
Reference in New Issue
Block a user