Lunarplant Tentacle Weapon
Based on game build 714014 | Last updated: 2026-03-03
Overview
LunarPlant_Tentacle_Weapon is a passive weapon component that triggers the spawning of lunar tentacles upon the owner's successful attacks. It listens for equipped/unequipped events to attach/detach event callbacks to its owner, and responds to onattackother to attempt tentacle spawns. A conditional function (should_do_tentacles_fn) controls whether tentacle spawns occur — by default, it checks for the "wormwood_allegiance_lunar_plant_gear_2" skill activation via the skilltreeupdater component.
Usage example
local inst = CreateEntity()
inst:AddComponent("inventoryitem")
inst:AddComponent("combatweapon")
inst:AddComponent("lunarplant_tentacle_weapon")
inst.components.lunarplant_tentacle_weapon.spawn_chance = 0.25
inst.components.lunarplant_tentacle_weapon.tentacle_prefab = "lunarplanttentacle"
Dependencies & tags
Components used: combat, skilltreeupdater (via owner.components.skilltreeupdater in condition)
Tags: None identified.
Properties
| Property | Type | Default Value | Description |
|---|---|---|---|
spawn_chance | number | 0.2 | Probability (0.0–1.0) that a tentacle spawns per qualifying attack. |
tentacle_prefab | string | "lunarplanttentacle" | Prefab name to spawn for tentacles. |
should_do_tentacles_fn | function | DefaultLunarPlantTentacleCondition | Callback (weapon, owner, attack_data) -> boolean determining if tentacles should spawn. |
owner | EntityInstance or nil | nil | Entity currently equipped with this weapon; set automatically via equipped/unequipped events. |
Main functions
SetOwner(owner)
- Description: Assigns the weapon's owner and registers/deregisters event listeners for
onattackotherandonremoveon the owner. - Parameters:
owner(EntityInstance ornil) — the entity wielding the weapon. - Returns: Nothing.
- Error states: No direct error states; safely handles
nilowner.
OnAttack(owner, attack_data)
- Description: Attempts to spawn a lunar tentacle near the target of an attack, provided attack conditions are met and the luck roll succeeds.
- Parameters:
owner(EntityInstance) — the entity performing the attack.
attack_data(table) — attack event payload, must includeweapon(entity) andtarget(entity). - Returns: Nothing.
- Error states:
- Returns early if
attack_dataisnilorattack_data.weapon ~= self.inst. - Returns early if
should_do_tentacles_fnreturnsfalse. - Tentacle spawn may silently fail if
FindWalkableOffsetorSpawnPrefabreturnsnil.
- Returns early if
Events & listeners
- Listens to (on
self.inst):equipped— triggers_equipped_callback, which callsSetOwner(data.owner).unequipped— triggers_unequipped_callback, which callsSetOwner(nil).
- Listens to (on
owner):onattackother— triggers_on_attack, which callsOnAttack.onremove— triggers_erase_owner, which setsself.owner = nil.
- Pushes: None.