Files
GaCy-GO/tools/cw_role_stars_export.lua
T

40 lines
2.2 KiB
Lua
Raw Normal View History

-- Existing handbook role configs; read four star rows per heartbeat. No role
-- creation, Star assignment, gameplay action or scene loader. Pauses in Battle.
do
local s=_G.__gacCwRoleStars1 or {family=0,variant=0,star=1,count=0};_G.__gacCwRoleStars1=s
if s.done then return end
local log=function(v)CS.UnityEngine.Debug.Log('[GAC_CW_ROLE_STARS] '..tostring(v))end
local ok,err=pcall(function()
local flags=CS.System.Enum.ToObject(typeof(CS.System.Reflection.BindingFlags),60)
local manager=CS.RPG.Client.GlobalVars.s_GamePhaseManager
local phase=manager and typeof(CS.RPG.Client.GamePhaseManager):GetField('_CurrentPhase',flags):GetValue(manager)
if not phase or typeof(CS.RPG.Client.BattleGamePhase):IsInstanceOfType(phase)then return end
if not s.families then
s.families=CS.RPG.Client.GlobalVars.s_ModuleManager.GridFightModule:GetHandBookAllRoleConfig()
if s.families.Count>1024 then error('role family bound exceeded')end
log('BEGIN families='..s.families.Count)
end
for batch=1,4 do
if s.family>=s.families.Count then s.done=true;log('END count='..s.count);return end
local family=s.families[s.family]
local role=s.variant==0 and family.DefaultRole or family.OtherRoles[s.variant-1]
local config=role.RoleConfig
if config.MaxStar>16 then error('role star bound exceeded')end
local star=config:GetStarConfig(s.star)
if star then
local row=star:GetType():GetField('_Row',flags):GetValue(star)
local servant=star:GetType():GetField('_ServantStarRow',flags):GetValue(star)
local text='{"ID":'..config.ID..',"Star":'..s.star..',"StarConfig":'..CS.Newtonsoft.Json.JsonConvert.SerializeObject(row)..',"ServantStarConfig":'..CS.Newtonsoft.Json.JsonConvert.SerializeObject(servant)..'}'
if #text>65536 then error('role star row exceeds bound')end
log('ROW '..text);s.count=s.count+1
else log('MISSING '..config.ID..' '..s.star)end
s.star=s.star+1
if s.star>config.MaxStar then
s.star=1;s.variant=s.variant+1
local otherCount=family.OtherRoles and family.OtherRoles.Count or 0
if s.variant>otherCount then s.variant=0;s.family=s.family+1 end
end
end
end)
if not ok then log('ERROR '..tostring(err));s.done=true end
end