Skip to content

Commit

Permalink
fix: add missing const, stagevar, projvar; refactor
Browse files Browse the repository at this point in the history
fix: add missing const, stagevar, projvar
const: data.volume, size.weight, size.pushfactor
stagevar: camera.tensionvel, camera.cuthigh, camera.cutlow
projvar: vel.z, velmul.z, remvelocity.z, accel.z, projlayerno, supermovetime

script.go changes related to upcoming script rewriting:
charChangeAnim => changeAnim
charChangeState => changeState
charMapSet, entityMapSet => mapSet
charSndPlay => playSnd
charSndStop => stopSnd, stopAllSound
animGetPreloadedData => animGetPreloadedCharData, animGetPreloadedStageData
  • Loading branch information
K4thos committed Dec 31, 2024
1 parent 43ea092 commit 310c462
Show file tree
Hide file tree
Showing 7 changed files with 402 additions and 335 deletions.
4 changes: 2 additions & 2 deletions external/script/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1894,7 +1894,7 @@ function main.f_addChar(line, playable, loading, slot)
--cell data
for _, v in pairs({{motif.select_info.portrait_anim, -1}, motif.select_info.portrait_spr}) do
if v[1] ~= -1 then
main.t_selChars[row].cell_data = animGetPreloadedData('char', main.t_selChars[row].char_ref, v[1], v[2])
main.t_selChars[row].cell_data = animGetPreloadedCharData(main.t_selChars[row].char_ref, v[1], v[2])
if main.t_selChars[row].cell_data ~= nil then
animSetScale(
main.t_selChars[row].cell_data,
Expand Down Expand Up @@ -1992,7 +1992,7 @@ function main.f_addStage(file, hidden)
--anim data
for _, v in pairs({{motif.select_info.stage_portrait_anim, -1}, motif.select_info.stage_portrait_spr}) do
if #v > 0 and v[1] ~= -1 then
main.t_selStages[stageNo].anim_data = animGetPreloadedData('stage', stageNo, v[1], v[2])
main.t_selStages[stageNo].anim_data = animGetPreloadedStageData(stageNo, v[1], v[2])
if main.t_selStages[stageNo].anim_data ~= nil then
animSetScale(
main.t_selStages[stageNo].anim_data,
Expand Down
30 changes: 18 additions & 12 deletions external/script/menu.lua
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@ menu.t_itemname = {
player(2)
setAILevel(menu.ailevel)
end
charMapSet(2, '_iksys_trainingDummyControl', menu.dummycontrol - 1)
player(2)
mapSet('_iksys_trainingDummyControl', menu.dummycontrol - 1)
end
return true
end,
Expand All @@ -137,35 +138,40 @@ menu.t_itemname = {
--Dummy Mode
['dummymode'] = function(t, item, cursorPosY, moveTxt, section)
if menu.f_valueChanged(t.items[item], motif[section]) then
charMapSet(2, '_iksys_trainingDummyMode', menu.dummymode - 1)
player(2)
mapSet('_iksys_trainingDummyMode', menu.dummymode - 1)
end
return true
end,
--Guard Mode
['guardmode'] = function(t, item, cursorPosY, moveTxt, section)
if menu.f_valueChanged(t.items[item], motif[section]) then
charMapSet(2, '_iksys_trainingGuardMode', menu.guardmode - 1)
player(2)
mapSet('_iksys_trainingGuardMode', menu.guardmode - 1)
end
return true
end,
--Fall Recovery
['fallrecovery'] = function(t, item, cursorPosY, moveTxt, section)
if menu.f_valueChanged(t.items[item], motif[section]) then
charMapSet(2, '_iksys_trainingFallRecovery', menu.fallrecovery - 1)
player(2)
mapSet('_iksys_trainingFallRecovery', menu.fallrecovery - 1)
end
return true
end,
--Distance
['distance'] = function(t, item, cursorPosY, moveTxt, section)
if menu.f_valueChanged(t.items[item], motif[section]) then
charMapSet(2, '_iksys_trainingDistance', menu.distance - 1)
player(2)
mapSet('_iksys_trainingDistance', menu.distance - 1)
end
return true
end,
--Button Jam
['buttonjam'] = function(t, item, cursorPosY, moveTxt, section)
if menu.f_valueChanged(t.items[item], motif[section]) then
charMapSet(2, '_iksys_trainingButtonJam', menu.buttonjam - 1)
player(2)
mapSet('_iksys_trainingButtonJam', menu.buttonjam - 1)
end
return true
end,
Expand Down Expand Up @@ -467,12 +473,12 @@ function menu.f_trainingReset()
end
player(2)
setAILevel(0)
charMapSet(2, '_iksys_trainingDummyControl', 0)
charMapSet(2, '_iksys_trainingDummyMode', 0)
charMapSet(2, '_iksys_trainingGuardMode', 0)
charMapSet(2, '_iksys_trainingFallRecovery', 0)
charMapSet(2, '_iksys_trainingDistance', 0)
charMapSet(2, '_iksys_trainingButtonJam', 0)
mapSet('_iksys_trainingDummyControl', 0)
mapSet('_iksys_trainingDummyMode', 0)
mapSet('_iksys_trainingGuardMode', 0)
mapSet('_iksys_trainingFallRecovery', 0)
mapSet('_iksys_trainingDistance', 0)
mapSet('_iksys_trainingButtonJam', 0)
end

menu.movelistChar = 1
Expand Down
48 changes: 26 additions & 22 deletions external/script/start.lua
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,7 @@ function start.f_animGet(ref, side, member, t, subname, prefix, loop, default)
default
}) do
if v[1] ~= nil and v[1] ~= -1 then
local a = animGetPreloadedData('char', ref, v[1], v[2], loop)
local a = animGetPreloadedCharData(ref, v[1], v[2], loop)
if a ~= nil then
local xscale = start.f_getCharData(ref).portrait_scale / (main.SP_Viewport43[3] / main.SP_Localcoord[1])
local yscale = xscale
Expand Down Expand Up @@ -3143,14 +3143,14 @@ function start.f_resultInit()
end
for i = 1, 2 do
for k, v in ipairs(t['p' .. i .. start.t_result.stateType .. '_state']) do
if charChangeState(i, v) then
if player(i) and changeState(v) then
break
end
end
player(i) --assign sys.debugWC to player i
for j = 1, numpartner() do
for _, v in ipairs(t['p' .. i .. '_teammate' .. start.t_result.stateType .. '_state']) do
if charChangeState(j * 2 + i, v) then
if player(j * 2 + i) and changeState(v) then
break
end
end
Expand Down Expand Up @@ -3332,14 +3332,14 @@ function start.f_victoryInit()
end
for i = 1, 2 do
for k, v in ipairs(motif.victory_screen['p' .. i .. '_state']) do
if charChangeState(i, v) then
if player(i) and changeState(v) then
break
end
end
player(i) --assign sys.debugWC to player i
for j = 1, numpartner() do
for _, v in ipairs(motif.victory_screen['p' .. i .. '_teammate_state']) do
if charChangeState(j * 2 + i, v) then
if player(j * 2 + i) and changeState(j * 2 + i, v) then
break
end
end
Expand Down Expand Up @@ -3491,14 +3491,14 @@ function start.f_continueInit()
v.selectState = 0
end
for _, v in ipairs(motif.continue_screen['p' .. i .. '_state']) do
if charChangeState(i, v) then
if player(i) and changeState(v) then
break
end
end
player(i) --assign sys.debugWC to player i
for j = 1, numpartner() do
for _, v in ipairs(motif.continue_screen['p' .. i .. '_teammate_state']) do
if charChangeState(j * 2 + i, v) then
if player(j * 2 + i) and changeState(v) then
break
end
end
Expand All @@ -3525,14 +3525,14 @@ function start.f_continue()
sndPlay(motif.files.snd_data, motif.continue_screen.done_snd[1], motif.continue_screen.done_snd[2])
for i = 1, 2 do
for _, v in ipairs(motif.continue_screen['p' .. i .. '_yes_state']) do
if charChangeState(i, v) then
if player(i) and changeState(v) then
break
end
end
player(i) --assign sys.debugWC to player i
for j = 1, numpartner() do
for _, v in ipairs(motif.continue_screen['p' .. i .. '_teammate_yes_state']) do
if charChangeState(j * 2 + i, v) then
if player(j * 2 + i) and changeState(v) then
break
end
end
Expand Down Expand Up @@ -3568,14 +3568,14 @@ function start.f_continue()
sndPlay(motif.files.snd_data, motif.continue_screen.counter_end_snd[1], motif.continue_screen.counter_end_snd[2])
for i = 1, 2 do
for _, v in ipairs(motif.continue_screen['p' .. i .. '_no_state']) do
if charChangeState(i, v) then
if player(i) and changeState(v) then
break
end
end
player(i) --assign sys.debugWC to player i
for j = 1, numpartner() do
for _, v in ipairs(motif.continue_screen['p' .. i .. '_teammate_no_state']) do
if charChangeState(j * 2 + i, v) then
if player(j * 2 + i) and changeState(v) then
break
end
end
Expand Down Expand Up @@ -3606,14 +3606,14 @@ function start.f_continue()
sndPlay(motif.files.snd_data, motif.continue_screen.done_snd[1], motif.continue_screen.done_snd[2])
for i = 1, 2 do
for _, v in ipairs(motif.continue_screen['p' .. i .. '_yes_state']) do
if charChangeState(i, v) then
if player(i) and changeState(v) then
break
end
end
player(i) --assign sys.debugWC to player i
for j = 1, numpartner() do
for _, v in ipairs(motif.continue_screen['p' .. i .. '_teammate_yes_state']) do
if charChangeState(j * 2 + i, v) then
if player(j * 2 + i) and changeState(v) then
break
end
end
Expand All @@ -3625,14 +3625,14 @@ function start.f_continue()
sndPlay(motif.files.snd_data, motif.continue_screen.cancel_snd[1], motif.continue_screen.cancel_snd[2])
for i = 1, 2 do
for _, v in ipairs(motif.continue_screen['p' .. i .. '_no_state']) do
if charChangeState(i, v) then
if player(i) and changeState(v) then
break
end
end
player(i) --assign sys.debugWC to player i
for j = 1, numpartner() do
for _, v in ipairs(motif.continue_screen['p' .. i .. '_teammate_no_state']) do
if charChangeState(j * 2 + i, v) then
if player(j * 2 + i) and changeState(v) then
break
end
end
Expand Down Expand Up @@ -3762,7 +3762,7 @@ function start.f_hiscoreInit(gameMode, playMusic, input)
motif.hiscore_info.item_face_spr,
}) do
if v[1] ~= -1 then
local a = animGetPreloadedData('char', main.t_charDef[def], v[1], v[2], true)
local a = animGetPreloadedCharData(main.t_charDef[def], v[1], v[2], true)
if a ~= nil then
animSetScale(
a,
Expand Down Expand Up @@ -4317,16 +4317,20 @@ function start.f_dialogueTokens(key, t)
end
--play sound
elseif v.param == 'sound' then --pn, group_no, sound_no, volumescale
charSndPlay(v.pn, v.value[1] or -1, v.value[2] or 0, v.value[3] or 100)
player(v.pn)
sndPlay(v.value[1] or -1, v.value[2] or 0, v.value[3] or 100)
--change anim
elseif v.param == 'anim' then --pn, anim_no, anim_elem
charChangeAnim(v.pn, v.value[1] or 0, v.value[2] or 0)
player(v.pn)
changeAnim(v.value[1] or 0, v.value[2] or 0)
--change state
elseif v.param == 'state' then --pn, state_no
charChangeState(v.pn, v.value[1] or 0)
player(v.pn)
changeState(v.value[1] or 0)
--map operation
elseif v.param == 'map' then --pn, map_name, value, map_type
charMapSet(v.pn, v.value[1] or 'dummy', v.value[2] or 0, v.value[3] or 'set')
player(v.pn)
mapSet(v.pn, v.value[1] or 'dummy', v.value[2] or 0, v.value[3] or 'set')
end
end
end
Expand Down Expand Up @@ -4425,7 +4429,7 @@ function start.f_dialogue()
end
end
if main.f_input(main.t_players, main.f_extractKeys(motif.dialogue_info.skip_key)) then
charSndStop()
stopAllSound()
t.parsed[t.textNum].cnt = 9999
t.parsed[t.textNum].tokens = {}
t.wait = 0
Expand All @@ -4448,7 +4452,7 @@ function start.f_dialogue()
local key_cancel = main.f_input(main.t_players, main.f_extractKeys(motif.dialogue_info.cancel_key))
if (t.endtime ~= -1 and t.counter > t.endtime) or (t.counter > motif.dialogue_info.skiptime and key_cancel) then
if key_cancel then
charSndStop()
stopAllSound()
end
dialogueReset()
start.dialogueInit = false
Expand Down
15 changes: 15 additions & 0 deletions src/bytecode.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ const (
OC_const_data_hitsound_channel
OC_const_data_guardsound_channel
OC_const_data_ko_echo
OC_const_data_volume
OC_const_data_intpersistindex
OC_const_data_floatpersistindex
OC_const_size_xscale
Expand Down Expand Up @@ -289,6 +290,8 @@ const (
OC_const_size_draw_offset_x
OC_const_size_draw_offset_y
OC_const_size_depth
OC_const_size_weight
OC_const_size_pushfactor
OC_const_velocity_walk_fwd_x
OC_const_velocity_walk_back_x
OC_const_velocity_walk_up_x
Expand Down Expand Up @@ -1942,6 +1945,8 @@ func (be BytecodeExp) run_const(c *Char, i *int, oc *Char) {
sys.bcStack.PushI(c.gi().data.guardsound_channel)
case OC_const_data_ko_echo:
sys.bcStack.PushI(c.gi().data.ko.echo)
case OC_const_data_volume:
sys.bcStack.PushI(c.gi().data.volume)
case OC_const_data_intpersistindex:
sys.bcStack.PushI(c.gi().data.intpersistindex)
case OC_const_data_floatpersistindex:
Expand Down Expand Up @@ -2014,6 +2019,10 @@ func (be BytecodeExp) run_const(c *Char, i *int, oc *Char) {
sys.bcStack.PushF(c.size.draw.offset[1] * ((320 / c.localcoord) / oc.localscl))
case OC_const_size_depth:
sys.bcStack.PushF(c.size.depth * ((320 / c.localcoord) / oc.localscl))
case OC_const_size_weight:
sys.bcStack.PushI(c.size.weight)
case OC_const_size_pushfactor:
sys.bcStack.PushF(c.size.pushfactor)
case OC_const_velocity_walk_fwd_x:
sys.bcStack.PushF(c.gi().velocity.walk.fwd * ((320 / c.localcoord) / oc.localscl))
case OC_const_velocity_walk_back_x:
Expand Down Expand Up @@ -2240,6 +2249,12 @@ func (be BytecodeExp) run_const(c *Char, i *int, oc *Char) {
sys.bcStack.PushB(sys.stage.stageCamera.lowestcap)
case OC_const_stagevar_camera_tension:
sys.bcStack.PushI(int32(float32(sys.stage.stageCamera.tension) * sys.stage.localscl / oc.localscl))
case OC_const_stagevar_camera_tensionvel:
sys.bcStack.PushF(sys.stage.stageCamera.tensionvel)
case OC_const_stagevar_camera_cuthigh:
sys.bcStack.PushI(sys.stage.stageCamera.cuthigh)
case OC_const_stagevar_camera_cutlow:
sys.bcStack.PushI(sys.stage.stageCamera.cutlow)
case OC_const_stagevar_camera_tensionhigh:
sys.bcStack.PushI(int32(float32(sys.stage.stageCamera.tensionhigh) * sys.stage.localscl / oc.localscl))
case OC_const_stagevar_camera_tensionlow:
Expand Down
10 changes: 9 additions & 1 deletion src/char.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ const (
GSF_nokodisplay
GSF_norounddisplay
GSF_nowindisplay
GSF_roundnotskip
GSF_roundfreeze
GSF_roundnotskip
)

type PosType int32
Expand Down Expand Up @@ -4006,18 +4006,26 @@ func (c *Char) projVar(pid BytecodeValue, idx BytecodeValue, flag BytecodeValue,
v = BytecodeFloat(p.velocity[0] * p.localscl / oc.localscl)
case OC_ex2_projvar_vel_y:
v = BytecodeFloat(p.velocity[1] * p.localscl / oc.localscl)
case OC_ex2_projvar_vel_z:
v = BytecodeFloat(p.velocity[2] * p.localscl / oc.localscl)
case OC_ex2_projvar_velmul_x:
v = BytecodeFloat(p.velmul[0])
case OC_ex2_projvar_velmul_y:
v = BytecodeFloat(p.velmul[1])
case OC_ex2_projvar_velmul_z:
v = BytecodeFloat(p.velmul[2])
case OC_ex2_projvar_remvelocity_x:
v = BytecodeFloat(p.remvelocity[0] * p.localscl / oc.localscl)
case OC_ex2_projvar_remvelocity_y:
v = BytecodeFloat(p.remvelocity[1] * p.localscl / oc.localscl)
case OC_ex2_projvar_remvelocity_z:
v = BytecodeFloat(p.remvelocity[2] * p.localscl / oc.localscl)
case OC_ex2_projvar_accel_x:
v = BytecodeFloat(p.accel[0] * p.localscl)
case OC_ex2_projvar_accel_y:
v = BytecodeFloat(p.accel[1] * p.localscl)
case OC_ex2_projvar_accel_z:
v = BytecodeFloat(p.accel[2] * p.localscl)
case OC_ex2_projvar_projscale_x:
v = BytecodeFloat(p.scale[0])
case OC_ex2_projvar_projscale_y:
Expand Down
Loading

0 comments on commit 310c462

Please sign in to comment.