Skip to main content

Wildfires

Overview

This component monitors environmental conditions (season, phase, temperature, and wetness) to determine when wildfires can spontaneously ignite. When active, it periodically attempts to start a fire at random valid locations near each active player. It only operates on the master simulation, enforcing server-side exclusivity.

Dependencies & Tags

Component Dependencies:

  • TheWorld (global world instance)
  • TheSim (global simulation accessor)
  • AllPlayers (global list of players)

Tags Used for Filtering:

  • _excludetags: "wildfireprotected", "fire", "burnt", "player", "companion", "NOCLICK", "INLIMBO"

Tags Checked During Validation:

  • "fireimmune", "wildfirepriority", "shadecanopy", "shadecanopysmall"
  • Pickable component: IsWildfireStarter() method
  • Witherable component: IsProtected(), IsWithered() methods
  • Workable component: GetWorkAction() == ACTIONS.CHOP

Events Registered:

  • "weathertick", "seasontick", "temperaturetick", "phasechanged"
  • "ms_lightwildfireforplayer", "ms_playerjoined", "ms_playerleft"

Properties

PropertyTypeDefault ValueDescription
instEntityReference to the entity this component is attached to (the world).
_activeplayerstable{}List of currently active player entities.
_scheduledtaskstable{}Maps player entities to their pending fire-ignition tasks.
_issummerbooleanfalseWhether the current season is Summer.
_isdaybooleantrueWhether the current world phase is "day".
_iswetbooleanfalseWhether current weather makes ignition difficult (wetness or snow > 0).
_ishotbooleanTUNING.STARTING_TEMP > TUNING.WILDFIRE_THRESHOLDWhether ambient temperature exceeds the wildfire ignition threshold.
_chancenumberTUNING.WILDFIRE_CHANCEBase probability per tick for ignition (if conditions are met).
_radiusnumber25Radius around players within which to search for ignition targets.
_updatingbooleanfalseWhether the component is actively scheduling ignition attempts.
_excludetagstable{ "wildfireprotected", "fire", "burnt", "player", "companion", "NOCLICK", "INLIMBO" }Tags that disqualify entities as fire starters.

Main Functions

CheckValidWildfireStarter(obj)

  • Description: Determines whether an entity is eligible to ignite a wildfire, based on tags, components, environmental protection, and temperature.
  • Parameters:
    • obj (Entity): The entity to evaluate.

LightFireForPlayer(player, rescheduleFn)

  • Description: Attempts to ignite a wildfire for a specific player. It performs a luck roll, checks for sandstorm interference, finds candidate fire-starting entities nearby, and selects one to ignite.
  • Parameters:
    • player (Entity): The player whose position is used as the origin for finding ignition targets.
    • rescheduleFn (function): Callback function used to reschedule the next ignition attempt for this player.

ScheduleSpawn(player)

  • Description: Schedules a fire-ignition task for a given player if no task is already pending.
  • Parameters:
    • player (Entity): The player for whom to schedule an ignition attempt.

CancelSpawn(player)

  • Description: Cancels any pending fire-ignition task for a given player and clears its schedule entry.
  • Parameters:
    • player (Entity): The player whose scheduled task should be cancelled.

ToggleUpdate()

  • Description: Enables or disables the wildfire engine based on current environmental conditions (summer, day, hot, dry). When activated, schedules ignition tasks for all active players; when deactivated, cancels all pending tasks.
  • Parameters: None.

ForceWildfireForPlayer(inst, player)

  • Description: Immediately attempts to ignite a wildfire for a given player, bypassing the normal scheduling logic. Only proceeds if environmental conditions are currently favorable.
  • Parameters:
    • inst (Entity): The world instance.
    • player (Entity): The player for whom to force a fire ignition.

GetDebugString()

  • Description: Returns a string indicating whether the wildfire system is currently active.
  • Parameters: None.

Events & Listeners

  • Listens to:
    • "weathertick" → updates _iswet and calls ToggleUpdate()
    • "seasontick" → updates _issummer and calls ToggleUpdate()
    • "temperaturetick" → updates _ishot and calls ToggleUpdate()
    • "phasechanged" → updates _isday and calls ToggleUpdate()
    • "ms_lightwildfireforplayer" → triggers ForceWildfireForPlayer()
    • "ms_playerjoined" → adds the new player and schedules ignition if active
    • "ms_playerleft" → removes the player and cancels pending tasks
  • Emits (via inst:PushEvent):
    • None directly. Uses internal state and external triggers.