Yotb Stager
Based on game build 714014 | Last updated: 2026-03-03
Overview
YOTB_Stager orchestrates the annual YOTB (Your Own Taste Beefs) contest event in DST. It handles the full lifecycle of a contest: verifying arena safety and conditions, spawning temporary contestants (trainers and beefalo), evaluating outfit combinations against randomized category targets, building suspense via voiceover dialogue, declaring winners, and distributing prizes. It relies on several supporting components (combat, hitcher, markable, named, skinner_beefalo, talker, timer, workable, yotb_stagemanager) to manage state and interactions, and consumes external data (yotb_costumes) for outfit scoring.
Usage example
-- Assume stage_entity is a valid entity prefabricated for contest hosting
stage_entity:AddComponent("yotb_stager")
-- To initiate a contest (e.g., after player interaction)
stage_entity.components.yotb_stager:StartContest(player_entity)
Dependencies & tags
Components used:
combat,hitcher,markable,markable_proxy,named,skinner_beefalo,talker,timer,workable,yotb_stagemanager
Tags added/removed:- Adds:
yotb_contestenabled,yotb_conteststartable,nomagic,NPC_contestant(temporarily on spawned entities) - Removes:
yotb_conteststartableduring active contest
Properties
| Property | Type | Default Value | Description |
|---|---|---|---|
inst | Entity | nil (set in constructor) | The entity this component is attached to (the contest host/stage). |
tasks | table | {} | List of pending delayed tasks (DoTaskInTime handles), used for cleanup on abort. |
choice | string | "far" | Evaluation strategy for comment selection: "random", "far", or "close". |
queue | table | {} | Ordered queue of callback functions for linear sequencing of phases. |
posts | table | nil | List of hitching posts found within range during contest start. |
temp_trainers | table | nil | List of temporary trainer NPCs spawned for the current contest. |
temp_beefalo | table | nil | List of temporary beefalo NPCs spawned for the current contest. |
victors | table | nil | List of winners (players or NPCs) after prize evaluation. |
others | table | nil | List of non-winners receiving consolation prizes. |
target_values | table | { FEARSOME=0, FESTIVE=0, FORMAL=0 } | Randomly generated target scores per category during contest start. |
doll_values | table | nil | Precomputed scores for doll appraisal (used in appraisedoll workflow). |
Main functions
cleartimers()
- Description: Stops any running timers (
prizedeadline,warndeadline) on the host entity. - Parameters: None.
- Returns: Nothing.
AdvanceQueue(data)
- Description: Executes the next callback in the
queuetable (used for ordered phase transitions). - Parameters:
data(table) — unused argument passed from event callbacks. - Returns: Nothing.
SpawnVoice(pos, comment, duration)
- Description: Spawns the
yotb_stage_voiceentity and makes it speak a comment at the given world position. - Parameters:
pos(Vector3) — World position for the voice entity.comment(string) — Localized string to speak.duration(number) — Approximate playback duration (subtracts0.5internally).
- Returns: Nothing.
AbortContest(data)
- Description: Immediately cancels the current contest, cleaning up spawned entities, clearing timers, and resetting tags. Often triggered by player/contestant attack or death. Pushes
yotb_onabortcontestevent. - Parameters:
data(table) — Containsreason(e.g.,"attack"). - Returns: Nothing.
EnableContest()
- Description: Enables the contest host to accept start requests by adding tags and pushing
contestenabledevent. - Parameters: None.
- Returns: Nothing.
DisableContest()
- Description: Disables the contest host by removing contest-specific tags and pushing
contestdisabledevent. - Parameters: None.
- Returns: Nothing.
TestStartContest(starter)
- Description: Checks game conditions (no hostiles nearby, sufficient time until night, minimum posts/contestants) to determine if a contest can start.
- Parameters:
starter(Entity, unused in function) — Player entity initiating the request. - Returns:
nilif safe to start."unsafe"(hostiles/players too close, combat active),"notime"(night approaching),"notenoughposts"(< 4 posts),"nocontestants"(no hitched beefalo).
Start_fail(result)
- Description: Handles failure messages and exits after a contest attempt fails
TestStartContest. - Parameters:
result(string) — One of the failure codes returned byTestStartContest. - Returns: Nothing.
StartContest(starter)
- Description: Begins the contest flow if
TestStartContestsucceeds. Spawnsyotb_stage_voice, locks posts, and queuesStart_phase2. - Parameters:
starter(Entity) — Player entity initiating the contest. - Returns: Nothing.
Start_phase2()
- Description: Initializes contest parameters (posts, target values per category) and pushes
onflourishstart. - Parameters: None.
- Returns: Nothing.
Start_phase3()
- Description: Announces the start, spawns extra beefalo if needed (for ≥ 4 posts), and schedules
StateParametersto set target scores. - Parameters: None.
- Returns: Nothing.
GetParameterLine(category)
- Description: Returns a localized string corresponding to how close the current
target_values[category]is to zero, based ontarget_thresholds. - Parameters:
category(string) — One of"FEARSOME","FESTIVE","FORMAL". - Returns: string — Localized speech line (from
target_lines).
StateParameters()
- Description: Begins announcing target score categories and schedules
StateParameters_Phase2. - Parameters: None.
- Returns: Nothing.
StateParameters_Phase2()
- Description: Sequentially announces each category's target (FORMAL → FESTIVE → FEARSOME) and kicks off
BuildSuspense. - Parameters: None.
- Returns: Nothing.
GetBeefScore(beefalo)
- Description: Sums costume part scores (FEARSOME/FESTIVE/FORMAL) for a beefalo using data from
yotb_costumes. - Parameters:
beefalo(Entity) — The beefalo to evaluate. - Returns: table
{ FEARSOME=n, FESTIVE=n, FORMAL=n }— Total scores.
GetClosest(values), GetFurthest(values), GetRandom()
- Description: Determines which category (FEARSOME/FESTIVE/FORMAL) best matches the evaluation strategy (
"close","far", or"random") betweenvalues(e.g.,beefalo.candidate_values) andself.target_values. - Parameters:
values(table) — Scores fromGetBeefScore. - Returns: string — Selected category key.
GetComment(post)
- Description: Generates a localized comment string describing how well a hitched beefalo's outfit matches the target.
- Parameters:
post(Entity) — The hitching post (must have a hitched beefalo). - Returns: table — Contains
duration(number) andstrs(localized strings) based onlinesandthresholds.
BuildSuspense()
- Description: Starts suspense period: enables markable on beefalo, plays music, triggers trainer panic timers, and waits for player marks via
yotb_post_markevents. - Parameters: None.
- Returns: Nothing.
CheckForMarks(post, doer)
- Description: Checks if
doerhas already marked the givenpost. - Parameters:
post(Entity) — Hitching post to check.doer(Entity) — Marking entity (usually player).
- Returns:
post(Entity) if already marked, elsefalse.
DeclareWinner()
- Description: Computes aggregate scores per beefalo, sorts by total deviation, and hosts podium ceremony with comments.
- Parameters: None.
- Returns: Nothing.
Tossprize(target, pattern, other)
- Description: Spawns and launches a prize item (red pouch with gold nuggets or a pattern fragment) toward
targetor into the air. - Parameters:
target(Entity ornil) — Entity to target (for NPC winners or players).pattern(boolean) — Iftrue, spawns a random pattern fragment instead of a pouch.other(boolean) — Iftrue, uses a fixed prize for non-winners.
- Returns: Nothing.
Tossprizes()
- Description: Distributes prizes to victors, consolation recipients, and pattern fragments.
- Parameters: None.
- Returns: Nothing.
AwardVictors()
- Description: Identifies winners based on marks on the winning post, sets
victors,notvictors,prizes, and triggersyotb_throwprizesevent. - Parameters: None.
- Returns: Nothing.
EndContest(reason)
- Description: Finalizes the contest: cleans up marks, unlocks posts, resets state, and begins shutdown sequence.
- Parameters:
reason(string ornil) —"attack","toolate", ornilfor normal end. - Returns: Nothing.
appraisedoll(doll)
- Description: Initiates doll appraisal workflow (distinct from full contest): computes
doll_values, shows feedback, and ends. - Parameters:
doll(Entity) — The doll being appraised (used to readcategoryfrom its data). - Returns: Nothing.
LoadPostPass(ents, data)
- Description: Hook called after map loading to reset timers (restores state from save).
- Parameters:
ents,data— Save/load arguments (unused). - Returns: Nothing.
Events & listeners
- Listens to:
yotb_contest_abort(viainst:ListenForEvent) → callsAbortContestyotb_advance_queue→ callsAdvanceQueuetimerdone→ callsEndContest("toolate")or encourages prize collectionattacked,death→ aborts contest on player/beefalo attack/death (viaonattacked)
- Pushes:
contestenabled,contestdisabledconteststarted,contestdisabledonflourishstart,onflourishendyotb_throwprizes,yotb_onabortcontest,yotb_oncontestfinshedtrader_arrives,trader_leaves