Wagdrone Flying
Based on game build 714014 | Last updated: 2026-03-07
Overview
The wagdrone_flying prefab implements a flying enemy entity equipped with lighting, a dedicated targeting system, and stategraph-controlled behavior. It depends heavily on shared logic via wagdrone_common.lua and integrates with the locomotor, inspectable, and updatelooper components. Targeting visuals are rendered using a non-networked FX entity (wagdrone_projectile_fx) that synchronizes animation with the parent during aiming phases.
Usage example
This prefab is not intended for direct manual instantiation by mods. It is used as a core game entity defined by the Prefab("wagdrone_flying", fn, assets, prefabs) call. Modders may interact with it indirectly—e.g., by spawning it via world generation or custom prefabs.
Dependencies & tags
Components used:
inspectable— provides status viaGetStatuslocomotor— controls flight speed (runspeed), setsdirectdrive, applies speed multiplierupdatelooper— adds post-update and on-update callbacks for FX syncing and lighting offset
Tags added:
can_offset_sort_pos— special flag for render sortingmech,electricdamageimmune,soulless,lunar_aligned,wagdrone— gameplay classification tags
External dependencies:
easing.lua— used for fade-out animation (outQuad)wagdrone_common.lua— shared logic (MakeHackable,PreventTeleportFromArena,ChangeToLoot,HackableLoadPostPass)wagdrone_projectile_fx,wagdrone_parts,gears,transistor,wagpunk_bits— prefabs spawned on death/damage
Properties
| Property | Type | Default Value | Description |
|---|---|---|---|
targeting | net_tinybyte | nil initially | Networked value (0, 1, or 2) representing targeting state: 0 = cancel, 1 = commit, 2 = show |
targetingfx | entity reference | nil | Reference to the targeting FX entity when active |
ShowTargeting(show, commit) | function | ShowTargeting | Public method to trigger targeting visual state changes |
OnSave(inst, data) | function | OnSave | Callback for persistence, records power state and loot status |
OnLoad(inst, data, ents) | function | OnLoad | Callback for restoration, handles state recovery and loot conversion |
Main functions
ShowTargeting(show, commit)
- Description: Controls the targeting visual state by setting the
targetingnet value and triggering FX updates on the client. - Parameters:
show(boolean ornil) — iftrue, sets targeting state to2(show).commit(boolean) — iftrueandshowisfalse, sets targeting state to1(commit/finalize). Otherwise, sets to0(cancel).
- Returns: Nothing.
- Error states: No-op if the server is dedicated (
TheNet:IsDedicated()is true), or if the new value matches the currenttargetingvalue.
GetStatus(inst, viewer)
- Description: Returns the status string shown when inspecting the entity.
- Parameters:
inst(entity) — the entity instance.viewer(player/entity) — the inspecting viewer (unused).
- Returns:
"DAMAGED"if theworkablecomponent exists (i.e., entity is being looted)."INACTIVE"if the entity’s stategraph has the"off"tag.nilotherwise (standard visible state).
CreateTargetingFx()
- Description: Helper that constructs the client-only targeting FX entity (
wagdrone_projectile_fx). - Parameters: None.
- Returns:
fx(entity) — a non-persistent entity withupdatelooper,animstate,transform, andsoundemitter. - Details: Sets up animations ("marker_pre", "marker_loop"), multicolor blending, bloom, light override, and background layering. Adds
FXandNOCLICKtags.
Target_OnPostUpdate(fx)
- Description: Post-update callback that positions the targeting FX at
y=0and syncs animation with the parent during targeting. - Parameters:
fx(entity) — the targeting FX entity.
- Returns: Nothing.
- Details: Adjusts world position to avoid vertical offset artifacts, and triggers
Target_SyncMarkerAnimto mirror the parent’s attack pre-animation frames.
Target_OnUpdateCancel(fx, dt)
- Description: Updates the FX’s fade-out when canceling targeting.
- Parameters:
fx(entity) — the targeting FX entity.dt(number) — delta time in seconds.
- Returns: Nothing.
- Details: Uses
easing.outQuadover0.2seconds to fade alpha from1to0; removes the FX when complete.
Events & listeners
- Listens to:
"targetingdirty"— triggersOnTargetingDirtyon clients to sync targeting visuals when thetargetingnet value changes."animover"— on targeting commit (state == 1), removes the FX after animation completes.
- Pushes: None.