Skip to content

Commit 276e7c0

Browse files
committed
Merge origin/develop into loading
2 parents 8812354 + 82c2bb2 commit 276e7c0

10 files changed

Lines changed: 814 additions & 334 deletions

File tree

external/script/main.lua

Lines changed: 48 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1276,6 +1276,34 @@ function main.f_charParam(t, c)
12761276
end
12771277
end
12781278

1279+
-- Converts character order params to a roster order-table key:
1280+
local function orderParamMode(param)
1281+
if param == 'order' then
1282+
return 'default'
1283+
end
1284+
local mode = tostring(param or ''):match('^order(.+)$')
1285+
if mode ~= nil and mode ~= '' then
1286+
return mode
1287+
end
1288+
return nil
1289+
end
1290+
1291+
-- Add char ref to unified per-mode order table.
1292+
local function addOrderChar(mode, order, ref)
1293+
mode = mode or 'default'
1294+
order = tonumber(order)
1295+
if order == nil or ref == nil then
1296+
return
1297+
end
1298+
if main.t_orderChars[mode] == nil then
1299+
main.t_orderChars[mode] = {}
1300+
end
1301+
if main.t_orderChars[mode][order] == nil then
1302+
main.t_orderChars[mode][order] = {}
1303+
end
1304+
table.insert(main.t_orderChars[mode][order], ref)
1305+
end
1306+
12791307
function main.f_addChar(line, playable, loading, slot)
12801308
table.insert(main.t_selChars, {})
12811309
local row = #main.t_selChars
@@ -1339,17 +1367,21 @@ function main.f_addChar(line, playable, loading, slot)
13391367
main.t_selChars[row].char_ref = main.t_charDef[main.t_selChars[row].char:lower()]
13401368
end
13411369
if playable then
1342-
--order param
1343-
if main.t_orderChars[main.t_selChars[row].order] == nil then
1344-
main.t_orderChars[main.t_selChars[row].order] = {}
1370+
-- order / order<gamemode> params
1371+
local hasSurvivalOrder = false
1372+
for k, v in pairs(main.t_selChars[row]) do
1373+
local mode = orderParamMode(k)
1374+
if mode ~= nil then
1375+
if mode == 'survival' then
1376+
hasSurvivalOrder = true
1377+
end
1378+
addOrderChar(mode, v, row - 1)
1379+
end
13451380
end
1346-
table.insert(main.t_orderChars[main.t_selChars[row].order], row - 1)
1347-
--ordersurvival param
1348-
local num = main.t_selChars[row].ordersurvival or 1
1349-
if main.t_orderSurvival[num] == nil then
1350-
main.t_orderSurvival[num] = {}
1381+
-- Preserve legacy Survival behavior: chars without ordersurvival still belong to survival order 1.
1382+
if not hasSurvivalOrder then
1383+
addOrderChar('survival', 1, row - 1)
13511384
end
1352-
table.insert(main.t_orderSurvival[num], row - 1)
13531385
--bonus games mode
13541386
if main.t_selChars[row].bonus ~= nil and main.t_selChars[row].bonus == 1 then
13551387
table.insert(main.t_bonusChars, row - 1)
@@ -1438,9 +1470,8 @@ function main.f_addStage(file, hidden, line)
14381470
end
14391471

14401472
main.t_includeStage = {{}, {}} --includestage = 1, includestage = -1
1441-
main.t_orderChars = {}
1473+
main.t_orderChars = {default = {}}
14421474
main.t_orderStages = {}
1443-
main.t_orderSurvival = {}
14441475
main.t_bonusChars = {}
14451476
main.t_selGrid = {}
14461477
main.t_selOptions = {}
@@ -3137,13 +3168,12 @@ function main.f_unlockChar(num, bool, reset)
31373168
if main.t_selChars[num].hidden ~= 0 then
31383169
main.t_selChars[num].hidden_default = main.t_selChars[num].hidden
31393170
main.t_selChars[num].hidden = 0
3140-
for k, t in pairs({order = main.t_orderChars, ordersurvival = main.t_orderSurvival}) do
3141-
if main.t_selChars[num][k] ~= nil and main.t_selChars[num][k] < 0 then
3142-
main.t_selChars[num][k] = 0 - main.t_selChars[num][k]
3143-
if t[main.t_selChars[num][k]] == nil then
3144-
t[main.t_selChars[num][k]] = {}
3145-
end
3146-
table.insert(t[main.t_selChars[num][k]], main.t_selChars[num].char_ref)
3171+
for k, v in pairs(main.t_selChars[num]) do
3172+
local mode = orderParamMode(k)
3173+
local order = tonumber(v)
3174+
if mode ~= nil and order ~= nil and order < 0 then
3175+
main.t_selChars[num][k] = 0 - order
3176+
addOrderChar(mode, main.t_selChars[num][k], main.t_selChars[num].char_ref)
31473177
end
31483178
end
31493179
start.t_grid[main.t_selChars[num].row][main.t_selChars[num].col].hidden = main.t_selChars[num].hidden
@@ -3930,7 +3960,6 @@ if gameOption('Debug.DumpLuaTables') then
39303960
main.f_printTable(main.t_selStoryMode, "debug/t_selStoryMode.txt")
39313961
main.f_printTable(main.t_orderChars, "debug/t_orderChars.txt")
39323962
main.f_printTable(main.t_orderStages, "debug/t_orderStages.txt")
3933-
main.f_printTable(main.t_orderSurvival, "debug/t_orderSurvival.txt")
39343963
main.f_printTable(main.t_randomChars, "debug/t_randomChars.txt")
39353964
main.f_printTable(main.t_bonusChars, "debug/t_bonusChars.txt")
39363965
main.f_printTable(main.t_stageDef, "debug/t_stageDef.txt")

external/script/start.lua

Lines changed: 70 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,22 @@ local cursorDone = {}
2525
--;===========================================================
2626
--; COMMON FUNCTIONS
2727
--;===========================================================
28+
-- Returns the unified order table used by the active mode.
29+
-- Priority: order<gameMode>, order<baseMode>, order
30+
function start.f_getOrderChars(baseMode)
31+
local mode = gameMode() or ''
32+
local checked = {}
33+
for _, key in ipairs({mode, baseMode, 'default'}) do
34+
if key ~= nil and key ~= '' and not checked[key] then
35+
checked[key] = true
36+
if type(main.t_orderChars[key]) == 'table' then
37+
return main.t_orderChars[key]
38+
end
39+
end
40+
end
41+
return {}
42+
end
43+
2844
--; ROSTER
2945
--converts '.maxmatches' style table (key = order, value = max matches) to key = match number, value = subtable with char num and order data
3046
function start.f_unifySettings(t, t_chars)
@@ -38,17 +54,6 @@ function start.f_unifySettings(t, t_chars)
3854
infinite = true
3955
end
4056
for j = 1, num do --iterate up to max amount of matches versus characters with this order
41-
--[[if j * start.p[2].numChars > #t_chars[i] and #ret > 0 then --if there are not enough characters to fill all slots and at least 1 fight is already assigned
42-
local stop = true
43-
for k = (j - 1) * start.p[2].numChars + 1, #t_chars[i] do --loop through characters left for this match
44-
if start.f_getCharData(t_chars[i][k]).single == 1 then --and allow appending if any of the remaining characters has 'single' flag set
45-
stop = false
46-
end
47-
end
48-
if stop then
49-
break
50-
end
51-
end]]
5257
table.insert(ret, {['rmin'] = start.p[2].numChars, ['rmax'] = start.p[2].numChars, ['order'] = i})
5358
end
5459
if infinite then
@@ -64,30 +69,56 @@ end
6469
-- by start.f_makeRoster function, depending on game mode. Can be appended via
6570
-- external module, without conflicting with default scripts.
6671
start.t_makeRoster = {}
67-
start.t_makeRoster.arcade = function()
68-
if start.p[2].teamMode == 0 then --Single
69-
if start.f_getCharData(start.p[1].t_selected[1].ref).maxmatches ~= nil and main.t_selOptions[start.f_getCharData(start.p[1].t_selected[1].ref).maxmatches .. '_arcademaxmatches'] ~= nil then --custom settings exists as char param
70-
return start.f_unifySettings(main.t_selOptions[start.f_getCharData(start.p[1].t_selected[1].ref).maxmatches .. '_arcademaxmatches'], main.t_orderChars), main.t_orderChars
71-
else --default settings
72-
return start.f_unifySettings(main.t_selOptions.arcademaxmatches, main.t_orderChars), main.t_orderChars
72+
function start.f_rosterMaxMatches(baseMode)
73+
local charData = start.f_getCharData(start.p[1].t_selected[1].ref)
74+
local mode = gameMode() or ''
75+
local t_chars = start.f_getOrderChars(baseMode)
76+
local fallback = start.p[2].teamMode == 0 and 'arcade' or 'team'
77+
local useMode = mode ~= '' and mode ~= 'arcade' and mode ~= 'team'
78+
local candidates = {}
79+
local function add(prefix, name)
80+
if name == nil or name == '' then
81+
return
82+
end
83+
if prefix ~= nil and prefix ~= '' then
84+
table.insert(candidates, prefix .. '_' .. name .. 'maxmatches')
85+
else
86+
table.insert(candidates, name .. 'maxmatches')
7387
end
74-
else --Simul / Turns / Tag
75-
if start.f_getCharData(start.p[1].t_selected[1].ref).maxmatches ~= nil and main.t_selOptions[start.f_getCharData(start.p[1].t_selected[1].ref).maxmatches .. '_teammaxmatches'] ~= nil then --custom settings exists as char param
76-
return start.f_unifySettings(main.t_selOptions[start.f_getCharData(start.p[1].t_selected[1].ref).maxmatches .. '_teammaxmatches'], main.t_orderChars), main.t_orderChars
77-
else --default settings
78-
return start.f_unifySettings(main.t_selOptions.teammaxmatches, main.t_orderChars), main.t_orderChars
88+
end
89+
if charData.maxmatches ~= nil then
90+
if useMode then
91+
add(charData.maxmatches, mode)
92+
end
93+
if baseMode ~= nil and baseMode ~= mode then
94+
add(charData.maxmatches, baseMode)
95+
end
96+
add(charData.maxmatches, fallback)
97+
end
98+
if useMode then
99+
add(nil, mode)
100+
end
101+
if baseMode ~= nil and baseMode ~= mode then
102+
add(nil, baseMode)
103+
end
104+
add(nil, fallback)
105+
for _, key in ipairs(candidates) do
106+
if main.t_selOptions[key] ~= nil then
107+
return start.f_unifySettings(main.t_selOptions[key], t_chars), t_chars
79108
end
80109
end
110+
return start.f_unifySettings(main.t_selOptions[fallback .. 'maxmatches'], t_chars), t_chars
111+
end
112+
113+
start.t_makeRoster.arcade = function()
114+
return start.f_rosterMaxMatches('arcade')
81115
end
82116
start.t_makeRoster.teamcoop = start.t_makeRoster.arcade
83117
start.t_makeRoster.netplayteamcoop = start.t_makeRoster.arcade
84118
start.t_makeRoster.timeattack = start.t_makeRoster.arcade
119+
85120
start.t_makeRoster.survival = function()
86-
if start.f_getCharData(start.p[1].t_selected[1].ref).maxmatches ~= nil and main.t_selOptions[start.f_getCharData(start.p[1].t_selected[1].ref).maxmatches .. '_survivalmaxmatches'] ~= nil then --custom settings exists as char param
87-
return start.f_unifySettings(main.t_selOptions[start.f_getCharData(start.p[1].t_selected[1].ref).maxmatches .. '_survivalmaxmatches'], main.t_orderSurvival), main.t_orderSurvival
88-
else --default settings
89-
return start.f_unifySettings(main.t_selOptions.survivalmaxmatches, main.t_orderSurvival), main.t_orderSurvival
90-
end
121+
return start.f_rosterMaxMatches('survival')
91122
end
92123
start.t_makeRoster.survivalcoop = start.t_makeRoster.survival
93124
start.t_makeRoster.netplaysurvivalcoop = start.t_makeRoster.survival
@@ -1342,16 +1373,13 @@ end
13421373

13431374
--removes char with particular ref from table
13441375
function start.f_excludeChar(t, ref)
1345-
for _, sel in ipairs(main.t_selChars) do
1346-
if sel.char_ref == ref then
1347-
if t[sel.order] ~= nil then
1348-
for k, v in ipairs(t[sel.order]) do
1349-
if v == ref then
1350-
table.remove(t[sel.order], k)
1351-
end
1376+
for _, list in pairs(t) do
1377+
if type(list) == 'table' then
1378+
for i = #list, 1, -1 do
1379+
if list[i] == ref then
1380+
table.remove(list, i)
13521381
end
13531382
end
1354-
break
13551383
end
13561384
end
13571385
return t
@@ -1686,7 +1714,7 @@ function start.f_selectMode()
16861714
if start.reset then
16871715
-- Save current remap state. main.f_restoreInput() should restore to this.
16881716
main.f_saveBaseRemapInput()
1689-
main.t_availableChars = main.f_tableCopy(main.t_orderChars)
1717+
main.t_availableChars = main.f_tableCopy(start.f_getOrderChars())
16901718
--generate default roster
16911719
if main.makeRoster then
16921720
start.t_roster = start.f_makeRoster()
@@ -3192,9 +3220,10 @@ function start.f_palMenu(side, cmd, player, member, selectState)
31923220

31933221
-- done anim after pal confirmation - primary face
31943222
local done_anim = pCfg.face.done.anim
3223+
local done_spr = pCfg.face.done.spr
31953224
local preview_anim = pCfg.palmenu.preview.anim
3196-
if done_anim ~= preview_anim then
3197-
if st.face_anim ~= done_anim and (main.coop or motif.select_info['p' .. side].face.num > 1 or main.f_tableLength(start.p[side].t_selected) + 1 == start.p[side].numChars) then
3225+
if done_anim ~= preview_anim or done_spr[1] ~= -1 then
3226+
if (st.face_anim ~= done_anim or done_spr[1] ~= -1) and (main.coop or motif.select_info['p' .. side].face.num > 1 or main.f_tableLength(start.p[side].t_selected) + 1 == start.p[side].numChars) then
31983227
local a = start.f_animGet(start.c[player].selRef, side, member, pCfg.face.done, pCfg.face, false, st.face_data)
31993228
if a then
32003229
st.face_data = start.loadPalettes(a, charRef, pal)
@@ -3450,14 +3479,15 @@ function start.f_selectMenu(side, cmd, player, member, selectState)
34503479
-- if select anim differs from done anim and coop or pX.face.num allows to display more than 1 portrait or it's the last team member
34513480
local done_anim = pCfg.face.done.anim
34523481
local done_anim2 = pCfg.face2.done.anim
3482+
local done_spr = pCfg.face.done.spr
34533483
local palmenu_preview_anim = pCfg.palmenu.preview.anim
34543484
local face_anim = start.p[side].t_selTemp[member].face_anim
34553485
local face2_anim = start.p[side].t_selTemp[member].face2_anim
34563486
local canShow = main.coop or motif.select_info['p' .. side].face.num > 1 or main.f_tableLength(start.p[side].t_selected) + 1 == start.p[side].numChars
34573487
local canShow2 = main.coop or motif.select_info['p' .. side].face2.num > 1 or main.f_tableLength(start.p[side].t_selected) + 1 == start.p[side].numChars
34583488
-- primary face "done" / preview
3459-
if face_anim ~= done_anim and canShow then
3460-
if motif.select_info.paletteselect == 0 and done_anim ~= -1 then
3489+
if (face_anim ~= done_anim or done_spr[1] ~= -1) and canShow then
3490+
if motif.select_info.paletteselect == 0 and (done_anim ~= -1 or done_spr[1] ~= -1) then
34613491
setDoneAnim(start.c[player].selRef, side, member, pCfg.face.done, pCfg.face, 'face_data')
34623492
elseif palmenu_preview_anim ~= -1 and motif.select_info.paletteselect ~= 0 then
34633493
start.f_playWave(start.c[player].selRef, 'cursor', motif.select_info['p' .. side].palmenu.preview.snd[1], motif.select_info['p' .. side].palmenu.preview.snd[2])

0 commit comments

Comments
 (0)