Sgwilson Gymstates
Based on game build 714014 | Last updated: 2026-03-08
Overview
SGwilson_gymstates extends the state graph for Wolfgang (and potentially other strongman characters) with states that govern gym-based workout interactions. It integrates closely with the strongman, mightiness, locomotor, and mightygym components to handle animation control, mightiness gain/loss, motion state, and exit logic upon workout completion or interruption. This script does not define a component itself but provides a reusable function to populate state definitions and action handlers into an existing state graph system.
Usage example
local GymStates = require "stategraphs/SGwilson_gymstates"
local states = {}
local actionhandlers = {}
local events = {}
GymStates.AddGymStates(states, actionhandlers, events)
-- Then pass states/actionhandlers to the stategraph builder
SGWilson.stategraph = SGStateGraph("SGWilson")
SGWilson.stategraph.states = states
SGWilson.stategraph.actionhandlers = actionhandlers
Dependencies & tags
Components used: locomotor, mightiness, mightygym, strongman
Tags added (per state):
"gym","busy","silentmorph"in"workout_gym""busy"in"mighty_gym_success_perfect","mighty_gym_success","mighty_gym_workout_fail"
Properties
No public properties are initialized by this file. It exports a single table GymStates with one method.
Main functions
GymStates.AddGymStates(states, actionhandlers, events)
- Description: Inserts gym-related state definitions and action handlers into the provided state and handler arrays. This function is called during stategraph construction to populate workout-related behavior for Wolfgang.
- Parameters:
states(table) – The array of state definitions to extend.actionhandlers(table) – The array of action handlers to extend.events(table) – Reserved for future use; not used in current implementation.
- Returns: Nothing (modifies arrays in-place).
getfull(inst) (local helper)
- Description: Returns
"_full"if the player’s mightiness percentage is at or above1.0, otherwise returns an empty string. Used to select appropriate animation suffixes. - Parameters:
inst(EntityInst) – The player entity instance. - Returns:
string– Either"_full"or"".
exitgym(inst) (local helper)
- Description: Triggers the gym exit sequence by calling
CharacterExitGymon the associated gym component, if one exists. - Parameters:
inst(EntityInst) – The player entity instance. - Returns: Nothing.
State: "workout_gym"
- Description: Initial transition state when entering the gym. Stops locomotion, plays the pickup animation, and waits briefly before triggering the buffered action.
onenter: Callslocomotor:Stop(), plays"pickup"animation, sets timeout to6 * FRAMES.ontimeout: Callsinst:PerformBufferedAction().- Tags:
"gym","busy","silentmorph".
State: "mighty_gym_active_pre"
- Description: Preparatory animation before beginning the workout loop. Plays based on mightiness level (via
getfull). onenter: Plays"mighty_gym_active_pre"+ suffix. Storesnorestartflag instatemem.events.animover: Switches to"mighty_gym_workout_loop"and setsdontleavegym = true.onexit: Conditionally callsResetBell(unlessnorestart) and callsexitgymifdontleavegymisfalse.
State: "mighty_gym_workout_loop"
- Description: Main continuous workout loop. Plays looping animation and workout sound. Verifies line of sight to the gym object.
onenter: Checks visibility to gym; if lost, callsexitgym. Otherwise plays"mighty_gym_active_loop"animation, starts"workout_LP"sound, and pushesgym_bell_startevent.events.animover: Re-enters"mighty_gym_workout_loop"and setsdontleavegym = true.onexit: Callsexitgymifdontleavegymisfalse.
State: "mighty_gym_success_perfect"
- Description: Handles a perfect gym lift, granting a larger mightiness gain. Plays success animation and sound, then decides whether to exit or resume workout.
onenter: Callsmightiness:DoDelta(..., true)with perfect calculation (CalculateMightiness(true)), plays"lift_pre"and"mighty_gym_success_big"animations with dynamic suffixes, plays"wolfgang2/common/gym/success"sound, then triggers buffered action.events.animqueueover: If mightiness is at full capacity (current >= max + overmax), callsexitgym; otherwise setsdontleavegym = trueand loops back to"mighty_gym_workout_loop".onexit: Callsexitgymifdontleavegymisfalse.- Tags:
"busy".
State: "mighty_gym_success"
- Description: Handles a standard (non-perfect) gym lift, granting a standard mightiness gain.
onenter: Same as"mighty_gym_success_perfect"but usesCalculateMightiness(false).events.animqueueoverandonexit: Same logic as the perfect state.- Tags:
"busy".
State: "mighty_gym_workout_fail"
- Description: Handles a failed gym lift attempt. Plays fail animation, stops workout sound, and returns to pre-loop state after delay.
onenter: Plays"lift_pre"and"mighty_gym_fail"animations, kills"workout_LP"sound, triggers buffered action.timeline: At5*FRAMES, plays"wolfgang2/common/gym/fail"sound.events.animqueueover: Setsdontleavegym = trueand returns to"mighty_gym_active_pre"withnorestart=true.onexit: Callsexitgymifdontleavegymisfalse.- Tags:
"busy".
Events & listeners
- Listens to:
"animover"(in"mighty_gym_active_pre"and"mighty_gym_workout_loop")"animqueueover"(in"mighty_gym_success_perfect","mighty_gym_success","mighty_gym_workout_fail")
- Pushes:
"gym_bell_start"(viaplayer_classified.gym_bell_start:push())"locomote"(indirectly, vialocomotor:Stop())"mightinessdelta"(indirectly, viamightiness:DoDelta())