大世界ability相关交互完善第二弹
This commit is contained in:
1 parent
0750f2a984
commit
7f2fa99a82
25 files changed
+323
-342
No files matched your search
@@ -206,21 +206,25 @@ func (g *GameDataConfig) loadAbilityJsonConfigLoop(path string) {
|
||||
}
|
||||
for _, file := range fileList {
|
||||
fileName := file.Name()
|
||||
filePath := path + "/" + fileName
|
||||
if file.IsDir() {
|
||||
g.loadAbilityJsonConfigLoop(path + "/" + fileName)
|
||||
g.loadAbilityJsonConfigLoop(filePath)
|
||||
}
|
||||
if split := strings.Split(fileName, "."); split[len(split)-1] != "json" {
|
||||
continue
|
||||
}
|
||||
fileData, err := os.ReadFile(path + "/" + fileName)
|
||||
fileData, err := os.ReadFile(filePath)
|
||||
if err != nil {
|
||||
info := fmt.Sprintf("open file error: %v, path: %v", err, path+"/"+fileName)
|
||||
info := fmt.Sprintf("open file error: %v", err)
|
||||
panic(info)
|
||||
}
|
||||
if fileData[0] == 0xEF && fileData[1] == 0xBB && fileData[2] == 0xBF {
|
||||
fileData = fileData[3:]
|
||||
}
|
||||
var abilityJsonConfigList []*AbilityJsonConfig = nil
|
||||
err = hjson.Unmarshal(fileData, &abilityJsonConfigList)
|
||||
if err != nil {
|
||||
logger.Info("parse file error: %v, path: %v", err, path+"/"+fileName)
|
||||
logger.Info("parse file error: %v, path: %v", err, filePath)
|
||||
continue
|
||||
}
|
||||
for _, abilityJsonConfig := range abilityJsonConfigList {
|
||||
|
||||
@@ -78,9 +78,12 @@ func (g *GameDataConfig) loadAvatarData() {
|
||||
for _, avatarData := range avatarDataList {
|
||||
fileData, err := os.ReadFile(g.jsonPrefix + "avatar/" + avatarData.ConfigJson + ".json")
|
||||
if err != nil {
|
||||
info := fmt.Sprintf("open file error: %v, avatarId: %v", err, avatarData.AvatarId)
|
||||
info := fmt.Sprintf("open file error: %v", err)
|
||||
panic(info)
|
||||
}
|
||||
if fileData[0] == 0xEF && fileData[1] == 0xBB && fileData[2] == 0xBF {
|
||||
fileData = fileData[3:]
|
||||
}
|
||||
configAbilityJson := new(ConfigAbilityJson)
|
||||
err = hjson.Unmarshal(fileData, configAbilityJson)
|
||||
if err != nil {
|
||||
|
||||
@@ -54,20 +54,22 @@ func (g *GameDataConfig) loadAvatarSkillDepotData() {
|
||||
g.AvatarSkillDepotDataMap = make(map[int32]*AvatarSkillDepotData)
|
||||
avatarSkillDepotDataList := make([]*AvatarSkillDepotData, 0)
|
||||
readTable[AvatarSkillDepotData](g.txtPrefix+"AvatarSkillDepotData.txt", &avatarSkillDepotDataList)
|
||||
playerElementsFilePath := g.jsonPrefix + "ability_group/AbilityGroup_Other_PlayerElementAbility.json"
|
||||
playerElementsFile, err := os.ReadFile(playerElementsFilePath)
|
||||
filePath := g.jsonPrefix + "ability_group/AbilityGroup_Other_PlayerElementAbility.json"
|
||||
fileData, err := os.ReadFile(filePath)
|
||||
if err != nil {
|
||||
info := fmt.Sprintf("open file error: %v", err)
|
||||
panic(info)
|
||||
}
|
||||
if fileData[0] == 0xEF && fileData[1] == 0xBB && fileData[2] == 0xBF {
|
||||
fileData = fileData[3:]
|
||||
}
|
||||
playerAbilities := make(map[string]*ConfigAbilityJson)
|
||||
err = hjson.Unmarshal(playerElementsFile, &playerAbilities)
|
||||
err = hjson.Unmarshal(fileData, &playerAbilities)
|
||||
if err != nil {
|
||||
info := fmt.Sprintf("parse file error: %v", err)
|
||||
panic(info)
|
||||
}
|
||||
logger.Info("load %v PlayerAbilities", len(playerAbilities))
|
||||
|
||||
for _, avatarSkillDepotData := range avatarSkillDepotDataList {
|
||||
// 把全部技能数据放进一个列表里 以后要是没用到或者不需要的话就可以删了
|
||||
avatarSkillDepotData.Skills = make([]int32, 0)
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
package gdconf
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"hk4e/pkg/logger"
|
||||
"os"
|
||||
|
||||
"github.com/hjson/hjson-go/v4"
|
||||
)
|
||||
|
||||
type ConfigGlobalCombat struct {
|
||||
DefaultAbilities struct {
|
||||
DefaultAvatarAbilities []string `json:"defaultAvatarAbilities"`
|
||||
} `json:"defaultAbilities"`
|
||||
}
|
||||
|
||||
func (g *GameDataConfig) loadDefaultAbilityJsonConfig() {
|
||||
CONF.DefaultAbilityNameList = make([]string, 0)
|
||||
filePath := g.jsonPrefix + "common/ConfigGlobalCombat.json"
|
||||
fileData, err := os.ReadFile(filePath)
|
||||
if err != nil {
|
||||
info := fmt.Sprintf("open file error: %v", err)
|
||||
panic(info)
|
||||
}
|
||||
if fileData[0] == 0xEF && fileData[1] == 0xBB && fileData[2] == 0xBF {
|
||||
fileData = fileData[3:]
|
||||
}
|
||||
configGlobalCombat := new(ConfigGlobalCombat)
|
||||
err = hjson.Unmarshal(fileData, configGlobalCombat)
|
||||
if err != nil {
|
||||
logger.Info("parse file error: %v, path: %v", err, filePath)
|
||||
panic(err)
|
||||
}
|
||||
for _, defaultAbilityName := range configGlobalCombat.DefaultAbilities.DefaultAvatarAbilities {
|
||||
CONF.DefaultAbilityNameList = append(CONF.DefaultAbilityNameList, defaultAbilityName)
|
||||
}
|
||||
}
|
||||
|
||||
func GetDefaultAbilityNameList() []string {
|
||||
return CONF.DefaultAbilityNameList
|
||||
}
|
||||
@@ -9,8 +9,46 @@ import (
|
||||
"github.com/hjson/hjson-go/v4"
|
||||
)
|
||||
|
||||
type ConfigGadget struct {
|
||||
Type string `json:"$type"`
|
||||
ConfigGadgetVehicle
|
||||
ConfigAbilityJson
|
||||
}
|
||||
|
||||
type ConfigGadgetVehicle struct {
|
||||
Vehicle *ConfigVehicle `json:"vehicle"` // 载具
|
||||
Combat *ConfigVehicleCombat `json:"combat"` // 战斗
|
||||
}
|
||||
|
||||
type ConfigVehicle struct {
|
||||
VehicleType string `json:"vehicleType"` // 载具类型
|
||||
DefaultLevel int32 `json:"defaultLevel"` // 默认等级
|
||||
MaxSeatCount int32 `json:"maxSeatCount"` // 最大座位数
|
||||
Stamina *ConfigVehicleStamina `json:"stamina"` // 耐力
|
||||
}
|
||||
|
||||
type ConfigVehicleStamina struct {
|
||||
StaminaUpperLimit float32 `json:"staminaUpperLimit"` // 耐力上限
|
||||
StaminaRecoverSpeed float32 `json:"staminaRecoverSpeed"` // 耐力回复速度
|
||||
StaminaRecoverWaitTime float32 `json:"staminaRecoverWaitTime"` // 耐力回复等待时间
|
||||
ExtraStaminaUpperLimit float32 `json:"extraStaminaUpperLimit"` // 额外耐力上限
|
||||
SprintStaminaCost float32 `json:"sprintStaminaCost"` // 冲刺时耐力消耗
|
||||
DashStaminaCost float32 `json:"dashStaminaCost"` // 猛冲时耐力消耗
|
||||
}
|
||||
|
||||
type ConfigVehicleCombat struct {
|
||||
Property *ConfigVehicleCombatProperty `json:"property"` // 属性
|
||||
}
|
||||
|
||||
type ConfigVehicleCombatProperty struct {
|
||||
HP float32 `json:"HP"` // 血量
|
||||
Attack float32 `json:"attack"` // 攻击力
|
||||
DefenseBase float32 `json:"defenseBase"` // 防御力
|
||||
Weight float32 `json:"weight"` // 重量
|
||||
}
|
||||
|
||||
func (g *GameDataConfig) loadGadgetJsonConfig() {
|
||||
g.GadgetJsonConfigMap = make(map[string]*ConfigAbilityJson)
|
||||
g.GadgetJsonConfigMap = make(map[string]*ConfigGadget)
|
||||
g.loadGadgetJsonConfigLoop(g.jsonPrefix + "gadget")
|
||||
logger.Info("GadgetJsonConfig Count: %v", len(g.GadgetJsonConfigMap))
|
||||
}
|
||||
@@ -23,21 +61,25 @@ func (g *GameDataConfig) loadGadgetJsonConfigLoop(path string) {
|
||||
}
|
||||
for _, file := range fileList {
|
||||
fileName := file.Name()
|
||||
filePath := path + "/" + fileName
|
||||
if file.IsDir() {
|
||||
g.loadGadgetJsonConfigLoop(path + "/" + fileName)
|
||||
g.loadGadgetJsonConfigLoop(filePath)
|
||||
}
|
||||
if split := strings.Split(fileName, "."); split[len(split)-1] != "json" {
|
||||
continue
|
||||
}
|
||||
fileData, err := os.ReadFile(path + "/" + fileName)
|
||||
fileData, err := os.ReadFile(filePath)
|
||||
if err != nil {
|
||||
info := fmt.Sprintf("open file error: %v, path: %v", err, path+"/"+fileName)
|
||||
info := fmt.Sprintf("open file error: %v", err)
|
||||
panic(info)
|
||||
}
|
||||
var gadgetJsonConfigMap map[string]*ConfigAbilityJson = nil
|
||||
if fileData[0] == 0xEF && fileData[1] == 0xBB && fileData[2] == 0xBF {
|
||||
fileData = fileData[3:]
|
||||
}
|
||||
var gadgetJsonConfigMap map[string]*ConfigGadget = nil
|
||||
err = hjson.Unmarshal(fileData, &gadgetJsonConfigMap)
|
||||
if err != nil {
|
||||
logger.Info("parse file error: %v, path: %v", err, path+"/"+fileName)
|
||||
logger.Info("parse file error: %v, path: %v", err, filePath)
|
||||
continue
|
||||
}
|
||||
for k, v := range gadgetJsonConfigMap {
|
||||
@@ -46,6 +88,6 @@ func (g *GameDataConfig) loadGadgetJsonConfigLoop(path string) {
|
||||
}
|
||||
}
|
||||
|
||||
func GetGadgetJsonConfigByName(name string) *ConfigAbilityJson {
|
||||
func GetGadgetJsonConfigByName(name string) *ConfigGadget {
|
||||
return CONF.GadgetJsonConfigMap[name]
|
||||
}
|
||||
@@ -28,8 +28,9 @@ func (g *GameDataConfig) loadGadgetLuaConfigLoop(path string) {
|
||||
}
|
||||
for _, file := range fileList {
|
||||
fileName := file.Name()
|
||||
filePath := path + "/" + fileName
|
||||
if file.IsDir() {
|
||||
g.loadGadgetLuaConfigLoop(path + "/" + fileName)
|
||||
g.loadGadgetLuaConfigLoop(filePath)
|
||||
}
|
||||
split := strings.Split(fileName, ".")
|
||||
if split[len(split)-1] != "lua" {
|
||||
@@ -39,9 +40,9 @@ func (g *GameDataConfig) loadGadgetLuaConfigLoop(path string) {
|
||||
continue
|
||||
}
|
||||
gadgetLuaName := split[0]
|
||||
fileData, err := os.ReadFile(path + "/" + fileName)
|
||||
fileData, err := os.ReadFile(filePath)
|
||||
if err != nil {
|
||||
info := fmt.Sprintf("open file error: %v, path: %v", err, path+"/"+fileName)
|
||||
info := fmt.Sprintf("open file error: %v", err)
|
||||
panic(info)
|
||||
}
|
||||
if fileData[0] == 0xEF && fileData[1] == 0xBB && fileData[2] == 0xBF {
|
||||
@@ -59,7 +60,10 @@ func GetGadgetLuaConfigByName(name string) *GadgetLuaConfig {
|
||||
return nil
|
||||
}
|
||||
if gadgetLuaConfig.LuaState == nil {
|
||||
luaState := newLuaState(gadgetLuaConfig.LuaStr)
|
||||
luaState, err := newLuaState(gadgetLuaConfig.LuaStr)
|
||||
if err != nil {
|
||||
logger.Error("lua parse error: %v, name: %v", err, name)
|
||||
}
|
||||
scriptLib := luaState.NewTable()
|
||||
luaState.SetGlobal("ScriptLib", scriptLib)
|
||||
for _, scriptLibFunc := range SCRIPT_LIB_FUNC_LIST {
|
||||
|
||||
+12
-12
@@ -38,6 +38,11 @@ type GameDataConfig struct {
|
||||
SceneLuaStateLruMap map[int32]*LuaStateLru // 场景LUA虚拟机LRU内存淘汰
|
||||
TriggerDataMap map[int32]*TriggerData // 场景区域触发器
|
||||
ScenePointJsonConfigMap map[int32]*ScenePointJsonConfig // 场景传送点JSON配置
|
||||
AbilityDataMap map[string]*AbilityData // 能力
|
||||
AbilityDataHashMap map[uint32]*AbilityData // 能力哈希
|
||||
DefaultAbilityNameList []string // 默认能力
|
||||
GadgetJsonConfigMap map[string]*ConfigGadget // 物件JSON配置
|
||||
GadgetLuaConfigMap map[string]*GadgetLuaConfig // 物件LUA配置
|
||||
SceneTagDataMap map[int32]*SceneTagData // 场景标签
|
||||
GatherDataMap map[int32]*GatherData // 采集物
|
||||
GatherDataPointTypeMap map[int32]*GatherData // 采集物场景节点索引
|
||||
@@ -69,7 +74,6 @@ type GameDataConfig struct {
|
||||
GCGCharDataMap map[int32]*GCGCharData // 七圣召唤角色卡牌
|
||||
GCGSkillDataMap map[int32]*GCGSkillData // 七圣召唤卡牌技能
|
||||
GachaDropGroupDataMap map[int32]*GachaDropGroupData // 卡池掉落组 临时的
|
||||
VehicleDataMap map[int32]*VehicleData // 载具
|
||||
OpenStateDataMap map[int32]*OpenStateData // 开放状态
|
||||
WeatherDataMap map[int32]*WeatherData // 天气
|
||||
WeatherDataJsonMap map[int32]map[int32]*WeatherData // 天气 json的天气区域id格式
|
||||
@@ -83,10 +87,6 @@ type GameDataConfig struct {
|
||||
WeaponCurveDataMap map[int32]*WeaponCurveData // 武器曲线
|
||||
ReliquaryLevelDataMap map[int32]map[int32]*ReliquaryLevelData // 圣遗物等级
|
||||
MonsterCurveDataMap map[int32]*MonsterCurveData // 怪物曲线
|
||||
AbilityDataMap map[string]*AbilityData // 能力
|
||||
AbilityDataHashMap map[uint32]*AbilityData // 能力哈希
|
||||
GadgetJsonConfigMap map[string]*ConfigAbilityJson // 物件JSON配置
|
||||
GadgetLuaConfigMap map[string]*GadgetLuaConfig // 物件LUA配置
|
||||
}
|
||||
|
||||
func InitGameDataConfig() {
|
||||
@@ -160,6 +160,10 @@ func (g *GameDataConfig) load(loadSceneLua bool) {
|
||||
g.loadSceneLuaConfig(loadSceneLua) // 场景LUA配置
|
||||
g.loadTriggerData() // 场景区域触发器
|
||||
g.loadScenePointJsonConfig() // 场景传送点JSON配置
|
||||
g.loadAbilityJsonConfig() // 能力JSON配置
|
||||
g.loadDefaultAbilityJsonConfig() // 默认能力
|
||||
g.loadGadgetJsonConfig() // 物件JSON配置
|
||||
g.loadGadgetLuaConfig() // 物件LUA配置
|
||||
g.loadSceneTagData() // 场景标签
|
||||
g.loadGatherData() // 采集物
|
||||
g.loadWorldAreaData() // 世界区域
|
||||
@@ -188,7 +192,6 @@ func (g *GameDataConfig) load(loadSceneLua bool) {
|
||||
g.loadGCGCharData() // 七圣召唤角色卡牌
|
||||
g.loadGCGSkillData() // 七圣召唤卡牌技能
|
||||
g.loadGachaDropGroupData() // 卡池掉落组 临时的
|
||||
g.loadVehicleData() // 载具
|
||||
g.loadOpenStateData() // 开放状态
|
||||
g.loadWeatherData() // 天气
|
||||
g.loadWeatherTemplateData() // 天气模版
|
||||
@@ -201,9 +204,6 @@ func (g *GameDataConfig) load(loadSceneLua bool) {
|
||||
g.loadWeaponCurveData() // 武器曲线
|
||||
g.loadReliquaryLevelData() // 圣遗物等级
|
||||
g.loadMonsterCurveData() // 怪物曲线
|
||||
g.loadAbilityJsonConfig() // 能力JSON配置
|
||||
g.loadGadgetJsonConfig() // 物件JSON配置
|
||||
g.loadGadgetLuaConfig() // 物件LUA配置
|
||||
}
|
||||
|
||||
// CSV相关
|
||||
@@ -395,7 +395,7 @@ func initLuaState(luaState *lua.LState) {
|
||||
luaState.SetField(elementType, "Rock", lua.LNumber(constant.ELEMENT_TYPE_ROCK))
|
||||
}
|
||||
|
||||
func newLuaState(luaStr string) *lua.LState {
|
||||
func newLuaState(luaStr string) (*lua.LState, error) {
|
||||
luaState := lua.NewState(lua.Options{
|
||||
IncludeGoStackTrace: true,
|
||||
})
|
||||
@@ -413,10 +413,10 @@ func newLuaState(luaStr string) *lua.LState {
|
||||
err = luaState.DoString(luaStr)
|
||||
}
|
||||
if err != nil {
|
||||
logger.Error("lua parse error: %v", err)
|
||||
return luaState, err
|
||||
}
|
||||
}
|
||||
return luaState
|
||||
return luaState, nil
|
||||
}
|
||||
|
||||
func getSceneLuaConfigTable[T any](luaState *lua.LState, tableName string, object T) bool {
|
||||
|
||||
@@ -47,6 +47,9 @@ func CheckJsonLoop(path string, errorJsonFileList *[]string, totalJsonFileCount
|
||||
logger.Error("open file error: %v", err)
|
||||
continue
|
||||
}
|
||||
if fileData[0] == 0xEF && fileData[1] == 0xBB && fileData[2] == 0xBF {
|
||||
fileData = fileData[3:]
|
||||
}
|
||||
var obj any
|
||||
err = hjson.Unmarshal(fileData, &obj)
|
||||
if err != nil {
|
||||
|
||||
@@ -51,9 +51,12 @@ func (g *GameDataConfig) loadGCGSkillData() {
|
||||
// 技能效果Config
|
||||
fileData, err := os.ReadFile(g.jsonPrefix + "gcg_card_skill/" + gcgSkillData.ConfigJson + ".json")
|
||||
if err != nil {
|
||||
info := fmt.Sprintf("open file error: %v, SkillId: %v", err, gcgSkillData.SkillId)
|
||||
info := fmt.Sprintf("open file error: %v", err)
|
||||
panic(info)
|
||||
}
|
||||
if fileData[0] == 0xEF && fileData[1] == 0xBB && fileData[2] == 0xBF {
|
||||
fileData = fileData[3:]
|
||||
}
|
||||
configSkillEffect := new(ConfigSkillEffect)
|
||||
err = hjson.Unmarshal(fileData, configSkillEffect)
|
||||
if err != nil {
|
||||
|
||||
@@ -72,9 +72,12 @@ func (g *GameDataConfig) loadMonsterData() {
|
||||
for _, monsterData := range monsterDataList {
|
||||
fileData, err := os.ReadFile(g.jsonPrefix + "monster/" + monsterData.ConfigJson + ".json")
|
||||
if err != nil {
|
||||
info := fmt.Sprintf("open file error: %v, monsterId: %v", err, monsterData.MonsterId)
|
||||
info := fmt.Sprintf("open file error: %v", err)
|
||||
panic(info)
|
||||
}
|
||||
if fileData[0] == 0xEF && fileData[1] == 0xBB && fileData[2] == 0xBF {
|
||||
fileData = fileData[3:]
|
||||
}
|
||||
configAbilityJson := new(ConfigAbilityJson)
|
||||
err = hjson.Unmarshal(fileData, configAbilityJson)
|
||||
if err != nil {
|
||||
|
||||
+27
-11
@@ -169,13 +169,19 @@ func (g *GameDataConfig) loadGroup(group *Group, block *Block, sceneId int32, bl
|
||||
sceneIdStr := strconv.Itoa(int(sceneId))
|
||||
groupId := group.Id
|
||||
groupIdStr := strconv.Itoa(int(groupId))
|
||||
groupLuaData, err := os.ReadFile(sceneLuaPrefix + sceneIdStr + "/scene" + sceneIdStr + "_group" + groupIdStr + ".lua")
|
||||
fileData, err := os.ReadFile(sceneLuaPrefix + sceneIdStr + "/scene" + sceneIdStr + "_group" + groupIdStr + ".lua")
|
||||
if err != nil {
|
||||
logger.Error("open file error: %v, sceneId: %v, blockId: %v, groupId: %v", err, sceneId, blockId, groupId)
|
||||
logger.Error("open file error: %v", err)
|
||||
return
|
||||
}
|
||||
group.LuaStr = string(groupLuaData)
|
||||
luaState := newLuaState(group.LuaStr)
|
||||
if fileData[0] == 0xEF && fileData[1] == 0xBB && fileData[2] == 0xBF {
|
||||
fileData = fileData[3:]
|
||||
}
|
||||
group.LuaStr = string(fileData)
|
||||
luaState, err := newLuaState(group.LuaStr)
|
||||
if err != nil {
|
||||
logger.Error("lua parse error: %v, groupId: %v", err, groupId)
|
||||
}
|
||||
// init_config
|
||||
group.GroupInitConfig = new(GroupInitConfig)
|
||||
ok := getSceneLuaConfigTable[*GroupInitConfig](luaState, "init_config", group.GroupInitConfig)
|
||||
@@ -320,12 +326,15 @@ func (g *GameDataConfig) loadSceneLuaConfig(loadSceneLua bool) {
|
||||
for _, sceneData := range g.SceneDataMap {
|
||||
sceneId := sceneData.SceneId
|
||||
sceneIdStr := strconv.Itoa(int(sceneId))
|
||||
mainLuaData, err := os.ReadFile(sceneLuaPrefix + sceneIdStr + "/scene" + sceneIdStr + ".lua")
|
||||
filePath := sceneLuaPrefix + sceneIdStr + "/scene" + sceneIdStr + ".lua"
|
||||
mainLuaData, err := os.ReadFile(filePath)
|
||||
if err != nil {
|
||||
logger.Info("open file error: %v, sceneId: %v", err, sceneId)
|
||||
continue
|
||||
}
|
||||
luaState := newLuaState(string(mainLuaData))
|
||||
luaState, err := newLuaState(string(mainLuaData))
|
||||
if err != nil {
|
||||
logger.Error("lua parse error: %v, path: %v", err, filePath)
|
||||
}
|
||||
sceneLuaConfig := new(SceneLuaConfig)
|
||||
sceneLuaConfig.Id = sceneId
|
||||
// scene_config
|
||||
@@ -361,12 +370,16 @@ func (g *GameDataConfig) loadSceneLuaConfig(loadSceneLua bool) {
|
||||
}
|
||||
block.BlockRange = blockRectList[index]
|
||||
blockIdStr := strconv.Itoa(int(block.Id))
|
||||
blockLuaData, err := os.ReadFile(sceneLuaPrefix + sceneIdStr + "/scene" + sceneIdStr + "_block" + blockIdStr + ".lua")
|
||||
filePath := sceneLuaPrefix + sceneIdStr + "/scene" + sceneIdStr + "_block" + blockIdStr + ".lua"
|
||||
blockLuaData, err := os.ReadFile(filePath)
|
||||
if err != nil {
|
||||
logger.Error("open file error: %v, sceneId: %v, blockId: %v", err, sceneId, blockId)
|
||||
logger.Error("open file error: %v", err)
|
||||
continue
|
||||
}
|
||||
luaState = newLuaState(string(blockLuaData))
|
||||
luaState, err := newLuaState(string(blockLuaData))
|
||||
if err != nil {
|
||||
logger.Error("lua parse error: %v, path: %v", err, filePath)
|
||||
}
|
||||
// groups
|
||||
block.GroupMap = make(map[int32]*Group)
|
||||
groupList := make([]*Group, 0)
|
||||
@@ -477,7 +490,10 @@ func (g *Group) GetLuaState() *lua.LState {
|
||||
AccessTime: time.Now().UnixMilli(),
|
||||
}
|
||||
if g.LuaState == nil {
|
||||
luaState := newLuaState(g.LuaStr)
|
||||
luaState, err := newLuaState(g.LuaStr)
|
||||
if err != nil {
|
||||
logger.Error("lua parse error: %v, groupId: %v", err, g.Id)
|
||||
}
|
||||
scriptLib := luaState.NewTable()
|
||||
luaState.SetGlobal("ScriptLib", scriptLib)
|
||||
for _, scriptLibFunc := range SCRIPT_LIB_FUNC_LIST {
|
||||
|
||||
@@ -12,33 +12,18 @@ import (
|
||||
|
||||
// 传送点类型
|
||||
const (
|
||||
PointTypeStrTransPointNormal = "TransPointNormal"
|
||||
PointTypeStrTransPointPortal = "TransPointPortal"
|
||||
PointTypeStrTransPointStatue = "TransPointStatue"
|
||||
PointTypeStrDungeonEntry = "DungeonEntry"
|
||||
PointTypeStrDungeonExit = "DungeonExit"
|
||||
PointTypeStrDungeonQuitPoint = "DungeonQuitPoint"
|
||||
PointTypeStrDungeonWayPoint = "DungeonWayPoint"
|
||||
PointTypeStrDungeonSlipRevivePoint = "DungeonSlipRevivePoint"
|
||||
PointTypeStrSceneBuildingPoint = "SceneBuildingPoint"
|
||||
PointTypeStrPersonalSceneJumpPoint = "PersonalSceneJumpPoint"
|
||||
PointTypeStrVehicleSummonPoint = "VehicleSummonPoint"
|
||||
PointTypeStrOther = "Other"
|
||||
)
|
||||
|
||||
const (
|
||||
PointTypeTransPointNormal = iota // X
|
||||
PointTypeTransPointPortal
|
||||
PointTypeTransPointStatue // X
|
||||
PointTypeDungeonEntry // X
|
||||
PointTypeDungeonExit
|
||||
PointTypeDungeonQuitPoint
|
||||
PointTypeDungeonWayPoint
|
||||
PointTypeDungeonSlipRevivePoint
|
||||
PointTypeSceneBuildingPoint // X
|
||||
PointTypePersonalSceneJumpPoint // X
|
||||
PointTypeVehicleSummonPoint // X
|
||||
PointTypeOther
|
||||
PointTypeTransPointNormal = "TransPointNormal"
|
||||
PointTypeTransPointPortal = "TransPointPortal"
|
||||
PointTypeTransPointStatue = "TransPointStatue"
|
||||
PointTypeDungeonEntry = "DungeonEntry"
|
||||
PointTypeDungeonExit = "DungeonExit"
|
||||
PointTypeDungeonQuitPoint = "DungeonQuitPoint"
|
||||
PointTypeDungeonWayPoint = "DungeonWayPoint"
|
||||
PointTypeDungeonSlipRevivePoint = "DungeonSlipRevivePoint"
|
||||
PointTypeSceneBuildingPoint = "SceneBuildingPoint"
|
||||
PointTypePersonalSceneJumpPoint = "PersonalSceneJumpPoint"
|
||||
PointTypeVehicleSummonPoint = "VehicleSummonPoint"
|
||||
PointTypeOther = "Other"
|
||||
)
|
||||
|
||||
type ScenePointJsonConfig struct {
|
||||
@@ -48,8 +33,7 @@ type ScenePointJsonConfig struct {
|
||||
|
||||
type PointData struct {
|
||||
Id int32 `json:"-"`
|
||||
PointType int `json:"-"`
|
||||
PointTypeStr string `json:"pointType"` // 传送点类型
|
||||
PointType string `json:"pointType"` // 传送点类型
|
||||
TranPos *Position `json:"tranPos"` // 传送后位置
|
||||
TranRot *Position `json:"tranRot"` // 传送后朝向
|
||||
DungeonIds []int32 `json:"dungeonIds"` // 地牢id列表
|
||||
@@ -72,9 +56,11 @@ func (g *GameDataConfig) loadScenePointJsonConfig() {
|
||||
sceneIdStr := strconv.Itoa(int(sceneId))
|
||||
fileData, err := os.ReadFile(sceneLuaPrefix + sceneIdStr + "/scene" + sceneIdStr + "_point.json")
|
||||
if err != nil {
|
||||
logger.Info("open file error: %v, sceneId: %v", err, sceneId)
|
||||
continue
|
||||
}
|
||||
if fileData[0] == 0xEF && fileData[1] == 0xBB && fileData[2] == 0xBF {
|
||||
fileData = fileData[3:]
|
||||
}
|
||||
scenePointJsonConfig := new(ScenePointJsonConfig)
|
||||
err = json.Unmarshal(fileData, scenePointJsonConfig)
|
||||
if err != nil {
|
||||
@@ -89,35 +75,6 @@ func (g *GameDataConfig) loadScenePointJsonConfig() {
|
||||
continue
|
||||
}
|
||||
pointData.Id = int32(pointId)
|
||||
switch pointData.PointTypeStr {
|
||||
case PointTypeStrTransPointNormal:
|
||||
pointData.PointType = PointTypeTransPointNormal
|
||||
case PointTypeStrTransPointPortal:
|
||||
pointData.PointType = PointTypeTransPointPortal
|
||||
case PointTypeStrTransPointStatue:
|
||||
pointData.PointType = PointTypeTransPointStatue
|
||||
case PointTypeStrDungeonEntry:
|
||||
pointData.PointType = PointTypeDungeonEntry
|
||||
case PointTypeStrDungeonExit:
|
||||
pointData.PointType = PointTypeDungeonExit
|
||||
case PointTypeStrDungeonQuitPoint:
|
||||
pointData.PointType = PointTypeDungeonQuitPoint
|
||||
case PointTypeStrDungeonWayPoint:
|
||||
pointData.PointType = PointTypeDungeonWayPoint
|
||||
case PointTypeStrDungeonSlipRevivePoint:
|
||||
pointData.PointType = PointTypeDungeonSlipRevivePoint
|
||||
case PointTypeStrSceneBuildingPoint:
|
||||
pointData.PointType = PointTypeSceneBuildingPoint
|
||||
case PointTypeStrPersonalSceneJumpPoint:
|
||||
pointData.PointType = PointTypePersonalSceneJumpPoint
|
||||
case PointTypeStrVehicleSummonPoint:
|
||||
pointData.PointType = PointTypeVehicleSummonPoint
|
||||
case PointTypeStrOther:
|
||||
pointData.PointType = PointTypeOther
|
||||
default:
|
||||
logger.Info("unknown scene point type: %v", pointData.PointTypeStr)
|
||||
pointData.PointType = PointTypeOther
|
||||
}
|
||||
scenePointJsonConfig.PointMap[int32(pointId)] = pointData
|
||||
}
|
||||
g.ScenePointJsonConfigMap[sceneId] = scenePointJsonConfig
|
||||
|
||||
@@ -1,100 +0,0 @@
|
||||
package gdconf
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"hk4e/pkg/logger"
|
||||
|
||||
"github.com/hjson/hjson-go/v4"
|
||||
)
|
||||
|
||||
// VehicleData 载具配置表
|
||||
type VehicleData struct {
|
||||
VehicleId int32 `csv:"ID"`
|
||||
TextName string `csv:"名称$text_name_Name,omitempty"`
|
||||
|
||||
ConfigGadgetVehicle *ConfigGadgetVehicle
|
||||
}
|
||||
|
||||
type ConfigGadgetVehicle struct {
|
||||
Vehicle *ConfigVehicle `json:"vehicle"` // 载具
|
||||
Combat *ConfigVehicleCombat `json:"combat"` // 战斗
|
||||
}
|
||||
|
||||
type ConfigVehicle struct {
|
||||
VehicleType string `json:"vehicleType"` // 载具类型
|
||||
DefaultLevel int32 `json:"defaultLevel"` // 默认等级
|
||||
MaxSeatCount int32 `json:"maxSeatCount"` // 最大座位数
|
||||
Stamina *ConfigVehicleStamina `json:"stamina"` // 耐力
|
||||
}
|
||||
|
||||
type ConfigVehicleStamina struct {
|
||||
StaminaUpperLimit float32 `json:"staminaUpperLimit"` // 耐力上限
|
||||
StaminaRecoverSpeed float32 `json:"staminaRecoverSpeed"` // 耐力回复速度
|
||||
StaminaRecoverWaitTime float32 `json:"staminaRecoverWaitTime"` // 耐力回复等待时间
|
||||
ExtraStaminaUpperLimit float32 `json:"extraStaminaUpperLimit"` // 额外耐力上限
|
||||
SprintStaminaCost float32 `json:"sprintStaminaCost"` // 冲刺时耐力消耗
|
||||
DashStaminaCost float32 `json:"dashStaminaCost"` // 猛冲时耐力消耗
|
||||
}
|
||||
|
||||
type ConfigVehicleCombat struct {
|
||||
Property *ConfigVehicleCombatProperty // 属性
|
||||
}
|
||||
|
||||
type ConfigVehicleCombatProperty struct {
|
||||
HP float32 `json:"HP"` // 血量
|
||||
Attack float32 `json:"attack"` // 攻击力
|
||||
DefenseBase float32 `json:"defenseBase"` // 防御力
|
||||
Weight float32 `json:"weight"` // 重量
|
||||
}
|
||||
|
||||
func (g *GameDataConfig) loadVehicleData() {
|
||||
g.VehicleDataMap = make(map[int32]*VehicleData)
|
||||
configGadgetVehiclesMap := make(map[string]map[string]*ConfigGadgetVehicle)
|
||||
vehicleDataList := make([]*VehicleData, 0)
|
||||
readTable[VehicleData](g.txtPrefix+"GadgetData_Vehicle.txt", &vehicleDataList)
|
||||
for _, vehicleData := range vehicleDataList {
|
||||
vehicleNameSplit := strings.Split(vehicleData.TextName, "_")
|
||||
if len(vehicleNameSplit) < 3 {
|
||||
info := fmt.Sprintf("vehicle text name split len less 3, TextName: %v", vehicleData.TextName)
|
||||
panic(info)
|
||||
}
|
||||
// 载具类型
|
||||
vehicleType := vehicleNameSplit[0]
|
||||
// 先判断一下是否已读取过同类型的载具配置
|
||||
configGadgetVehicles, ok := configGadgetVehiclesMap[vehicleType]
|
||||
if !ok {
|
||||
// 读取载具config
|
||||
fileData, err := os.ReadFile(g.jsonPrefix + "gadget/ConfigGadget_Vehicle_" + vehicleType + ".json")
|
||||
if err != nil {
|
||||
info := fmt.Sprintf("open file error: %v, vehicleType: %v", err, vehicleType)
|
||||
panic(info)
|
||||
}
|
||||
err = hjson.Unmarshal(fileData, &configGadgetVehicles)
|
||||
if err != nil {
|
||||
info := fmt.Sprintf("parse file error: %v, vehicleType: %v", err, vehicleType)
|
||||
panic(info)
|
||||
}
|
||||
configGadgetVehiclesMap[vehicleType] = configGadgetVehicles
|
||||
}
|
||||
// 载具config配置是否存在
|
||||
configVehicle, ok := configGadgetVehicles[vehicleData.TextName]
|
||||
if !ok {
|
||||
logger.Info("can not find any config of vehicle, vehicleId: %v", vehicleData.VehicleId)
|
||||
}
|
||||
vehicleData.ConfigGadgetVehicle = configVehicle
|
||||
|
||||
g.VehicleDataMap[vehicleData.VehicleId] = vehicleData
|
||||
}
|
||||
logger.Info("VehicleData Count: %v", len(g.VehicleDataMap))
|
||||
}
|
||||
|
||||
func GetVehicleDataById(vehicleId int32) *VehicleData {
|
||||
return CONF.VehicleDataMap[vehicleId]
|
||||
}
|
||||
|
||||
func GetVehicleDataMap() map[int32]*VehicleData {
|
||||
return CONF.VehicleDataMap
|
||||
}
|
||||
@@ -32,10 +32,11 @@ func (g *GameDataConfig) loadWeatherAreaJsonConfig() {
|
||||
// 读取场景天气区域
|
||||
fileData, err := os.ReadFile(sceneLuaPrefix + sceneIdStr + "/scene" + sceneIdStr + "_weather_areas.json")
|
||||
if err != nil {
|
||||
// 有些场景没有天气区域是正常情况
|
||||
// logger.Error("open file error: %v, sceneId: %v", err, sceneId)
|
||||
continue
|
||||
}
|
||||
if fileData[0] == 0xEF && fileData[1] == 0xBB && fileData[2] == 0xBF {
|
||||
fileData = fileData[3:]
|
||||
}
|
||||
weatherAreaJsonConfigList := make([]*WeatherAreaJsonConfig, 0)
|
||||
err = hjson.Unmarshal(fileData, &weatherAreaJsonConfigList)
|
||||
if err != nil {
|
||||
|
||||
Reference in new issue
Block a user