Skip to main content

Ruins Bat

Based on game build 714014 | Last updated: 2026-03-07

Overview

The ruins_bat prefab is a one-time-use equippable weapon that spawns shadow tentacles on successful attacks. It integrates with the weapon, equippable, finiteuses, inventoryitem, shadowlevel, and inspectable components. When equipped, it overrides the player's arm animation and hides normal arms; unequipping restores default visuals. On each attack, it attempts a luck-based roll to spawn a shadowtentacle at a nearby walkable location, excluding holes.

Usage example

local bat = SpawnPrefab("ruins_bat")
if bat ~= nil then
player:PushEvent("equipskinneditem", bat:GetSkinName())
bat.components.equippable:Equip(player)
-- Attack logic handled via weapon component's SetOnAttack callback
end

Dependencies & tags

Components used: weapon, finiteuses, inspectable, inventoryitem, equippable, shadowlevel, combat (via spawned shadowtentacle)
Tags: Adds sharp and weapon and shadowlevel to the bat instance; spawned tentacles use combat and are assigned an owner.

Properties

PropertyTypeDefault ValueDescription
inst.components.weapon.damagenumberTUNING.RUINS_BAT_DAMAGEDamage dealt by the weapon on attack.
inst.components.weapon.onattackfunctiononattack (defined locally)Callback fired on attack to conditionally spawn shadow tentacles.
inst.components.finiteuses.totalnumberTUNING.RUINS_BAT_USESMaximum number of attacks allowed.
inst.components.finiteuses.currentnumberTUNING.RUINS_BAT_USESCurrent remaining uses. Decrements on each attack.
inst.components.equippable.walkspeedmultnumberTUNING.RUINS_BAT_SPEED_MULTMovement speed multiplier when the bat is equipped.
inst.components.shadowlevel.levelnumberTUNING.RUINS_BAT_SHADOW_LEVELShadow level applied to the entity (used for visibility in shadow realms).

Main functions

onequip(inst, owner)

  • Description: Executed when the bat is equipped. Applies skin overrides (if any), sets carry animation, and hides normal arms.
  • Parameters: inst (Entity) – the bat instance; owner (Entity) – the entity equipping the item.
  • Returns: Nothing.

onunequip(inst, owner)

  • Description: Executed when unequipped. Restores normal arm animation and clears skin overrides.
  • Parameters: inst (Entity); owner (Entity).
  • Returns: Nothing.

onattack(inst, owner, target)

  • Description: Attack callback for the weapon component. Attempts to spawn a shadow tentacle using a luck roll. If successful, spawns a tentacle at a nearby valid position, assigns the original target or nil, and plays attack sounds.
  • Parameters: inst (Entity) – the bat; owner (Entity) – attacker; target (Entity or nil) – target of the attack.
  • Returns: Nothing.
  • Error states: Fails silently if FindWalkableOffset returns nil or tentacle spawn fails.

Events & listeners

  • Listens to: None directly; event handlers (onequip, onunequip, onattack) are invoked via component callbacks (SetOnEquip, SetOnUnequip, SetOnAttack).
  • Pushes: equipskinneditem, unequipskinneditem (via owner:PushEvent(...)) when equipping/unequipping skinned variants.