--Ghost Trainer v.2 by Dafe --[[v.2.1 - Fixed loading game settings for first round - in a pinch, use a flag ]]-- --[[v.2 - Added support for grips - Added option to display ghost source - Added option to load related game settings and mods - Loading game settings is ineffective in the first round, but works as expected thereafter - dev note: imported entire header string and frame numbers for semi future-proofing ]]-- --Options: --Announce source of the move sequence at the start of the match announceSource = true --Load relevant game settings (i.e. dojo size, engage distance, turnframes, etc.) loadSettings = true math.randomseed(get_world_state().frame_tick) firstRound = true; Uke = {} Uke.moveSet = {
} Uke.metaFormat = {"matchframes", "turnframes", "", "", "", "flags", "engagedistance", "damage", "sumo", "mod", "", "dojosize", "dismemberthreshold", "fracturethreshold", "engageheight", "", "", "", ""} function split(str) local ret = {} for w in string.gmatch(str, "[%w,._]+") do table.insert(ret, w) end return ret end function rollUke() Uke.randIndex = math.random(1, #Uke.moveSet) end function initUke() Uke.cursor = 1 if Uke.randIndex == nil then rollUke() end for i=0, 19 do set_joint_state(1, i, 4) end --Reference move for current round activeMove = Uke.moveSet[Uke.randIndex] --Set up next round rollUke() if loadSettings then local settings = split(Uke.moveSet[Uke.randIndex].meta) for i=1, #Uke.metaFormat do if Uke.metaFormat[i] ~= "" then run_cmd("set " .. Uke.metaFormat[i] .. " " .. settings[i]) end end if firstRound then firstRound = false run_cmd("lm " .. settings[10]) end run_cmd("clear") end if announceSource then run_cmd("echo Loaded ghost - " .. activeMove.replay .. " - " .. activeMove.player) end end function randomMove() local activeStep = activeMove.sequence[Uke.cursor] if activeStep then if activeStep.move then for k, v in pairs(activeStep.move) do set_joint_state(1, v[1], v[2]) end end if activeStep.grip then set_grip_info(1, BODYPARTS.L_HAND, activeStep.grip[1]) set_grip_info(1, BODYPARTS.R_HAND, activeStep.grip[2]) end Uke.cursor = Uke.cursor + 1 end end add_hook("new_game", "initUke", initUke) add_hook("exit_freeze", "moveUke", randomMove)