From b9acb98c8800060be37b5712ea8ba9a150cec4d7 Mon Sep 17 00:00:00 2001 From: Mr-Auto <36127424+Mr-Auto@users.noreply.github.com> Date: Thu, 12 Sep 2024 22:04:34 +0200 Subject: [PATCH] exposing more vitrual functions and hooks --- docs/game_data/lua_enums.txt | 10 ++ docs/game_data/spel2.lua | 99 ++++++++++++++----- docs/src/includes/_enums.md | 11 ++- docs/src/includes/_types.md | 89 ++++++++++++----- src/game_api/entity.hpp | 2 +- src/game_api/entity_db.hpp | 3 +- src/game_api/movable.hpp | 21 +--- src/game_api/script/usertypes/entity_lua.cpp | 60 +++++++---- src/game_api/script/usertypes/vtables_lua.cpp | 61 +++++++----- 9 files changed, 236 insertions(+), 120 deletions(-) diff --git a/docs/game_data/lua_enums.txt b/docs/game_data/lua_enums.txt index cd2ac1265..ca863618f 100644 --- a/docs/game_data/lua_enums.txt +++ b/docs/game_data/lua_enums.txt @@ -332,9 +332,14 @@ ENTITY_OVERRIDE = { ACTIVATE = 25, APPLY_FRICTION = 84, APPLY_METADATA = 28, + APPLY_MOVEMENT = 71, APPLY_VELOCITY = 42, + ATTACK = 46, + BREAK_BLOCK = 86, CALCULATE_JUMP_VELOCITY = 40, + CAN_BE_PICKED_UP_BY = 68, CAN_BE_PUSHED = 10, + CAN_BREAK_BLOCK = 85, CAN_ENTER = 46, CAN_JUMP = 37, CHECK_OUT_OF_BOUNDS = 58, @@ -353,6 +358,7 @@ ENTITY_OVERRIDE = { FLOOR_UPDATE = 38, FREEZE = 52, FRICTION = 19, + GENERATE_FALL_POOF_PARTICLES = 82, GENERATE_STOMP_DAMAGE_PARTICLES = 8, GET_COLLISION_INFO = 38, GET_DAMAGE = 43, @@ -362,8 +368,10 @@ ENTITY_OVERRIDE = { HIDE_HUD = 41, INIT = 36, INITIALIZE = 75, + INSTAKILL_DEATH = 92, IS_IN_LIQUID = 12, IS_ON_FIRE = 45, + IS_POWERUP_CAPABLE = 74, IS_UNLOCKED = 45, KILL = 3, LEDGE_GRAB = 31, @@ -377,6 +385,7 @@ ENTITY_OVERRIDE = { PICKED_UP_BY = 68, PICK_UP = 67, PROCESS_INPUT = 78, + RELEASE = 81, REMOVE_ITEM = 21, RESET_DRAW_DEPTH = 18, SET_AS_SOUND_SOURCE = 20, @@ -391,6 +400,7 @@ ENTITY_OVERRIDE = { STOOD_ON = 32, STUN = 51, THROWN_BY = 62, + THROWN_INTO = 47, TRIGGER_ACTION = 24, UPDATE_STATE_MACHINE = 2, WALKED_OFF = 30, diff --git a/docs/game_data/spel2.lua b/docs/game_data/spel2.lua index c89bf6b5a..b666426e2 100644 --- a/docs/game_data/spel2.lua +++ b/docs/game_data/spel2.lua @@ -2426,13 +2426,18 @@ function PRNG:random(min, max) end ---@field search_flags integer @MASK ---@field width number ---@field height number + ---@field draw_depth integer ---@field offsetx number ---@field offsety number ---@field hitboxx number ---@field hitboxy number - ---@field draw_depth integer + ---@field default_shape SHAPE + ---@field default_hitbox_enabled boolean ---@field collision2_mask integer @MASK, will only call collision2 when colliding with entities that match this mask. ---@field collision_mask integer @MASK used for collision with floors, walls etc. + ---@field default_flags integer + ---@field default_more_flags integer + ---@field properties_flags integer ---@field friction number ---@field elasticity number ---@field weight number @@ -2441,21 +2446,20 @@ function PRNG:random(min, max) end ---@field sprint_factor number ---@field jump number ---@field default_color Color + ---@field texture TEXTURE + ---@field tilex integer + ---@field tiley integer ---@field damage integer ---@field life integer ---@field sacrifice_value integer @Favor for sacrificing alive. Halved when dead (health == 0). ---@field blood_content integer - ---@field texture TEXTURE - ---@field animations table - ---@field properties_flags integer - ---@field default_flags integer - ---@field default_more_flags integer ---@field leaves_corpse_behind boolean + ---@field description STRINGID ---@field sound_killed_by_player integer ---@field sound_killed_by_other integer - ---@field description STRINGID - ---@field tilex integer - ---@field tiley integer + ---@field animations table + ---@field default_special_offsetx number + ---@field default_special_offsetx number ---@class RenderInfo ---@field x number @@ -2517,7 +2521,7 @@ function PRNG:random(min, max) end ---@field get_texture fun(self): TEXTURE ---@field set_texture fun(self, texture_id: TEXTURE): boolean @Changes the entity texture, check the [textures.txt](game_data/textures.txt) for available vanilla textures or use [define_texture](#define_texture) to make custom one ---@field set_draw_depth fun(self, draw_depth: integer, b3f: integer): nil - ---@field set_enable_turning fun(self, enabled: boolean): nil + ---@field reset_draw_depth fun(self): nil ---@field liberate_from_shop fun(self, clear_parrent: boolean): nil @`clear_parent` used only for CHAR_* entities, sets the `linked_companion_parent` to -1 ---@field get_held_entity fun(self): Entity ---@field set_layer fun(self, layer: LAYER): nil @Moves the entity to specified layer, nothing else happens, so this does not emulate a door transition @@ -2535,9 +2539,12 @@ function PRNG:random(min, max) end ---@field get_items fun(self): integer[] ---@field is_in_liquid fun(self): boolean @Returns true if entity is in water/lava ---@field is_cursed fun(self): boolean + ---@field is_movable fun(self): boolean + ---@field can_be_pushed fun(self): boolean ---@field update fun(self): nil ---@field flip fun(self, left: boolean): nil - ---@field can_be_pushed fun(self): boolean + ---@field remove_item fun(self, entity: Entity, autokill_check: boolean): nil + ---@field apply_db fun(self): nil @Applies changes made in `entity.type` ---@field set_pre_virtual fun(self, entry: ENTITY_OVERRIDE, fun: function): CallbackId @Hooks before the virtual function at index `entry`. ---@field set_post_virtual fun(self, entry: ENTITY_OVERRIDE, fun: function): CallbackId @Hooks after the virtual function at index `entry`. ---@field clear_virtual fun(self, callback_id: CallbackId): nil @Clears the hook given by `callback_id`, alternatively use `clear_callback()` inside the hook. @@ -2646,6 +2653,7 @@ function Entity:destroy_recursive() end ---@field buttons_previous BUTTON ---@field stand_counter integer ---@field jump_height_multiplier number @EntityDB.jump gets multiplied by this to get the jump + ---@field price integer ---@field owner_uid integer ---@field last_owner_uid integer ---@field current_animation Animation @@ -2669,7 +2677,6 @@ function Entity:destroy_recursive() end ---@field exit_invincibility_timer integer ---@field invincibility_frames_timer integer ---@field frozen_timer integer - ---@field price integer ---@field is_poisoned fun(self): boolean ---@field is_button_pressed fun(self, button: BUTTON): boolean ---@field is_button_held fun(self, button: BUTTON): boolean @@ -2677,7 +2684,7 @@ function Entity:destroy_recursive() end ---@field stun fun(self, framecount: integer): nil ---@field freeze fun(self, framecount: integer, ignore_lava: boolean): nil @Sets the `frozen_timer`, the param `ignore_lava` doesn't do much, just skips the liquid check, if in lava the game will set `frozen_timer` to 0 immediately most of the time ---@field light_on_fire fun(self, time: integer): nil @Does not damage entity - ---@field set_cursed fun(self, b: boolean, effect: boolean?): nil @effect = true - plays the sound and spawn particle above entity + ---@field set_cursed fun(self, b: boolean, effect: boolean): nil ---@field drop fun(self): nil @Called when dropping or throwing ---@field pick_up fun(self, entity_to_pick_up: Entity): nil ---@field standing_on fun(self): Entity @@ -2685,6 +2692,9 @@ function Entity:destroy_recursive() end ---@field can_jump fun(self): boolean @Return true if the entity is allowed to jump, even midair. Return false and can't jump, except from ladders apparently. ---@field is_on_fire fun(self): boolean ---@field is_powerup_capable fun(self): boolean + ---@field can_be_picked_up_by fun(self, entity_picking_up: Entity, boolean: ): boolean + ---@field can_break_block fun(self, horizontal: boolean, block: Entity): boolean + ---@field break_block fun(self, camera_shake: boolean, block: Entity): nil ---@field damage fun(self, damage_dealer: Entity, damage_amount: integer, damage_flags: DAMAGE_TYPE, velocity: Vec2, unknown_damage_phase: integer, stun_amount: integer, iframes: integer, unknown_is_final: boolean): boolean @Damage the movable by the specified amount, stuns and gives it invincibility for the specified amount of frames and applies the velocities. `damage_dealer` can be set to nil.
Returns: true if entity was affected (for stuff like pot that should break after hit etc.), false if the event should be ignored by damage_dealer ---@field get_all_behaviors fun(self): integer[] @Get all available behavior ids ---@field set_behavior fun(self, behavior_id: integer): boolean @Set behavior, this is more than just state as it's an active function, for example climbing ladder is a behavior and it doesn't actually need ladder/rope entity
Returns false if entity doesn't have this behavior id @@ -2693,6 +2703,13 @@ function Entity:destroy_recursive() end ---@field reset_gravity fun(self): nil @Remove the gravity hook and reset to defaults ---@field set_position fun(self, to_x: number, to_y: number): nil @Set the absolute position of an entity and offset all rendering related things accordingly to teleport without any interpolation or graphical glitches. If the camera is focused on the entity, it is also moved. ---@field process_input fun(self): nil + ---@field calculate_jump_velocity fun(self, dont_ignore_liquid: boolean): number + ---@field apply_velocity fun(self, velocities: Vec2, ignore_weight: boolean): nil + ---@field get_damage fun(self): integer @Returns the damage that the entity deals + ---@field attack fun(self, victim: Entity): boolean @Runs on contact damage, returns false if there wasn't any interaction (called from on_collision2, will be called as long as the hitboxes overlap) + ---@field thrown_into fun(self, victim: Entity): boolean @Same as above, but for being thrown into something and potentially dealing damage that way + ---@field get_damage_sound fun(self, damage: DAMAGE_TYPE): integer @returns sound id for the damage taken, return 0 to make it silence + ---@field copy_extra_info fun(self, clone: Entity, some_entity_uid: integer): nil @Entities must be of the same type! ---@field cutscene CutsceneBehavior ---@field clear_cutscene fun(self): nil ---@field get_base_behavior fun(self, state_id: integer): VanillaMovableBehavior @Gets a vanilla behavior from this movable, needs to be called before `clear_behaviors`
but the returned values are still valid after a call to `clear_behaviors` @@ -2718,6 +2735,10 @@ function Entity:destroy_recursive() end ---@field set_post_get_damage fun(self, fun: fun(self: Movable): integer?): CallbackId @Hooks after the virtual function.
The callback signature is `nil get_damage(Movable self)`
Virtual function docs:
Returns the damage that the entity deals ---@field set_pre_is_on_fire fun(self, fun: fun(self: Movable): boolean?): CallbackId @Hooks before the virtual function.
The callback signature is `optional is_on_fire(Movable self)` ---@field set_post_is_on_fire fun(self, fun: fun(self: Movable): boolean?): CallbackId @Hooks after the virtual function.
The callback signature is `nil is_on_fire(Movable self)` + ---@field set_pre_attack fun(self, fun: fun(self: Movable, victim: Entity): boolean?): CallbackId @Hooks before the virtual function.
The callback signature is `optional attack(Movable self, Entity victim)`
Virtual function docs:
Runs on contact damage, returns false if there wasn't any interaction (called from on_collision2, will be called as long as the hitboxes overlap) + ---@field set_post_attack fun(self, fun: fun(self: Movable, victim: Entity): boolean?): CallbackId @Hooks after the virtual function.
The callback signature is `nil attack(Movable self, Entity victim)`
Virtual function docs:
Runs on contact damage, returns false if there wasn't any interaction (called from on_collision2, will be called as long as the hitboxes overlap) + ---@field set_pre_thrown_into fun(self, fun: fun(self: Movable, victim: Entity): boolean?): CallbackId @Hooks before the virtual function.
The callback signature is `optional thrown_into(Movable self, Entity victim)`
Virtual function docs:
Same as above, but for being thrown into something and potentially dealing damage that way + ---@field set_post_thrown_into fun(self, fun: fun(self: Movable, victim: Entity): boolean?): CallbackId @Hooks after the virtual function.
The callback signature is `nil thrown_into(Movable self, Entity victim)`
Virtual function docs:
Same as above, but for being thrown into something and potentially dealing damage that way ---@field set_pre_damage fun(self, fun: fun(self: Movable, damage_dealer: Entity, damage_amount: integer, damage_flags: DAMAGE_TYPE, velocity: Vec2, unknown_damage_phase: integer, stun_amount: integer, iframes: integer, unknown_is_final: boolean): boolean?): CallbackId @Hooks before the virtual function.
The callback signature is `optional damage(Movable self, Entity damage_dealer, integer damage_amount, DAMAGE_TYPE damage_flags, Vec2 velocity, integer unknown_damage_phase, integer stun_amount, integer iframes, boolean unknown_is_final)`
Virtual function docs:
Damage the movable by the specified amount, stuns and gives it invincibility for the specified amount of frames and applies the velocities. `damage_dealer` can be set to nil.
Returns: true if entity was affected (for stuff like pot that should break after hit etc.), false if the event should be ignored by damage_dealer ---@field set_post_damage fun(self, fun: fun(self: Movable, damage_dealer: Entity, damage_amount: integer, damage_flags: DAMAGE_TYPE, velocity: Vec2, unknown_damage_phase: integer, stun_amount: integer, iframes: integer, unknown_is_final: boolean): boolean?): CallbackId @Hooks after the virtual function.
The callback signature is `nil damage(Movable self, Entity damage_dealer, integer damage_amount, DAMAGE_TYPE damage_flags, Vec2 velocity, integer unknown_damage_phase, integer stun_amount, integer iframes, boolean unknown_is_final)`
Virtual function docs:
Damage the movable by the specified amount, stuns and gives it invincibility for the specified amount of frames and applies the velocities. `damage_dealer` can be set to nil.
Returns: true if entity was affected (for stuff like pot that should break after hit etc.), false if the event should be ignored by damage_dealer ---@field set_pre_on_hit fun(self, fun: fun(self: Movable, damage_dealer: Entity): boolean): CallbackId @Hooks before the virtual function.
The callback signature is `bool on_hit(Movable self, Entity damage_dealer)`
Virtual function docs:
Hit by broken arrows etc that don't deal damage, calls damage with 0 damage. @@ -2732,40 +2753,54 @@ function Entity:destroy_recursive() end ---@field set_post_light_on_fire fun(self, fun: fun(self: Movable, time: integer): boolean): CallbackId @Hooks after the virtual function.
The callback signature is `nil light_on_fire(Movable self, integer time)`
Virtual function docs:
Does not damage entity ---@field set_pre_set_cursed fun(self, fun: fun(self: Movable, b: boolean, effect: boolean): boolean): CallbackId @Hooks before the virtual function.
The callback signature is `bool set_cursed(Movable self, boolean b, boolean effect)` ---@field set_post_set_cursed fun(self, fun: fun(self: Movable, b: boolean, effect: boolean): boolean): CallbackId @Hooks after the virtual function.
The callback signature is `nil set_cursed(Movable self, boolean b, boolean effect)` - ---@field set_pre_web_collision fun(self, fun: fun(self: Movable): boolean): CallbackId @Hooks before the virtual function.
The callback signature is `bool web_collision(Movable self)` - ---@field set_post_web_collision fun(self, fun: fun(self: Movable): boolean): CallbackId @Hooks after the virtual function.
The callback signature is `nil web_collision(Movable self)` + ---@field set_pre_web_collision fun(self, fun: fun(self: Movable, boolean: boolean): boolean): CallbackId @Hooks before the virtual function.
The callback signature is `bool web_collision(Movable self, boolean boolean)` + ---@field set_post_web_collision fun(self, fun: fun(self: Movable, boolean: boolean): boolean): CallbackId @Hooks after the virtual function.
The callback signature is `nil web_collision(Movable self, boolean boolean)` ---@field set_pre_check_out_of_bounds fun(self, fun: fun(self: Movable): boolean): CallbackId @Hooks before the virtual function.
The callback signature is `bool check_out_of_bounds(Movable self)`
Virtual function docs:
Disable to not get killed outside level bounds. ---@field set_post_check_out_of_bounds fun(self, fun: fun(self: Movable): boolean): CallbackId @Hooks after the virtual function.
The callback signature is `nil check_out_of_bounds(Movable self)`
Virtual function docs:
Disable to not get killed outside level bounds. ---@field set_pre_set_standing_on fun(self, fun: fun(self: Movable, entity_uid: integer): boolean): CallbackId @Hooks before the virtual function.
The callback signature is `bool set_standing_on(Movable self, integer entity_uid)` ---@field set_post_set_standing_on fun(self, fun: fun(self: Movable, entity_uid: integer): boolean): CallbackId @Hooks after the virtual function.
The callback signature is `nil set_standing_on(Movable self, integer entity_uid)` ---@field set_pre_standing_on fun(self, fun: fun(self: Movable): Entity?): CallbackId @Hooks before the virtual function.
The callback signature is `optional standing_on(Movable self)` ---@field set_post_standing_on fun(self, fun: fun(self: Movable): Entity?): CallbackId @Hooks after the virtual function.
The callback signature is `nil standing_on(Movable self)` - ---@field set_pre_stomped_by fun(self, fun: fun(self: Movable, Entity: ): boolean): CallbackId @Hooks before the virtual function.
The callback signature is `bool stomped_by(Movable self, Entity)` - ---@field set_post_stomped_by fun(self, fun: fun(self: Movable, Entity: ): boolean): CallbackId @Hooks after the virtual function.
The callback signature is `nil stomped_by(Movable self, Entity)` - ---@field set_pre_thrown_by fun(self, fun: fun(self: Movable, Entity: ): boolean): CallbackId @Hooks before the virtual function.
The callback signature is `bool thrown_by(Movable self, Entity)` - ---@field set_post_thrown_by fun(self, fun: fun(self: Movable, Entity: ): boolean): CallbackId @Hooks after the virtual function.
The callback signature is `nil thrown_by(Movable self, Entity)` - ---@field set_pre_cloned_to fun(self, fun: fun(self: Movable, Entity: ): boolean): CallbackId @Hooks before the virtual function.
The callback signature is `bool cloned_to(Movable self, Entity)` - ---@field set_post_cloned_to fun(self, fun: fun(self: Movable, Entity: ): boolean): CallbackId @Hooks after the virtual function.
The callback signature is `nil cloned_to(Movable self, Entity)` + ---@field set_pre_stomped_by fun(self, fun: fun(self: Movable, stomper: Entity): boolean?): CallbackId @Hooks before the virtual function.
The callback signature is `optional stomped_by(Movable self, Entity stomper)` + ---@field set_post_stomped_by fun(self, fun: fun(self: Movable, stomper: Entity): boolean?): CallbackId @Hooks after the virtual function.
The callback signature is `nil stomped_by(Movable self, Entity stomper)` + ---@field set_pre_thrown_by fun(self, fun: fun(self: Movable, thrower: Entity): boolean): CallbackId @Hooks before the virtual function.
The callback signature is `bool thrown_by(Movable self, Entity thrower)` + ---@field set_post_thrown_by fun(self, fun: fun(self: Movable, thrower: Entity): boolean): CallbackId @Hooks after the virtual function.
The callback signature is `nil thrown_by(Movable self, Entity thrower)` + ---@field set_pre_cloned_to fun(self, fun: fun(self: Movable, some_entity_uid: Entity clone integer): boolean): CallbackId @Hooks before the virtual function.
The callback signature is `bool cloned_to(Movable self, Entity clone integer some_entity_uid)` + ---@field set_post_cloned_to fun(self, fun: fun(self: Movable, some_entity_uid: Entity clone integer): boolean): CallbackId @Hooks after the virtual function.
The callback signature is `nil cloned_to(Movable self, Entity clone integer some_entity_uid)` ---@field set_pre_pick_up fun(self, fun: fun(self: Movable, entity_to_pick_up: Entity): boolean): CallbackId @Hooks before the virtual function.
The callback signature is `bool pick_up(Movable self, Entity entity_to_pick_up)` ---@field set_post_pick_up fun(self, fun: fun(self: Movable, entity_to_pick_up: Entity): boolean): CallbackId @Hooks after the virtual function.
The callback signature is `nil pick_up(Movable self, Entity entity_to_pick_up)` - ---@field set_pre_picked_up_by fun(self, fun: fun(self: Movable, Entity: ): boolean): CallbackId @Hooks before the virtual function.
The callback signature is `bool picked_up_by(Movable self, Entity)` - ---@field set_post_picked_up_by fun(self, fun: fun(self: Movable, Entity: ): boolean): CallbackId @Hooks after the virtual function.
The callback signature is `nil picked_up_by(Movable self, Entity)` + ---@field set_pre_can_be_picked_up_by fun(self, fun: fun(self: Movable, entity_picking_up: Entity, boolean: ): boolean?): CallbackId @Hooks before the virtual function.
The callback signature is `optional can_be_picked_up_by(Movable self, Entity entity_picking_up, boolean)` + ---@field set_post_can_be_picked_up_by fun(self, fun: fun(self: Movable, entity_picking_up: Entity, boolean: ): boolean?): CallbackId @Hooks after the virtual function.
The callback signature is `nil can_be_picked_up_by(Movable self, Entity entity_picking_up, boolean)` ---@field set_pre_drop fun(self, fun: fun(self: Movable): boolean): CallbackId @Hooks before the virtual function.
The callback signature is `bool drop(Movable self)`
Virtual function docs:
Called when dropping or throwing ---@field set_post_drop fun(self, fun: fun(self: Movable): boolean): CallbackId @Hooks after the virtual function.
The callback signature is `nil drop(Movable self)`
Virtual function docs:
Called when dropping or throwing ---@field set_pre_collect_treasure fun(self, fun: fun(self: Movable, value: integer, treasure: ENT_TYPE): boolean?): CallbackId @Hooks before the virtual function.
The callback signature is `optional collect_treasure(Movable self, integer value, ENT_TYPE treasure)`
Virtual function docs:
Adds or subtracts the specified amount of money to the movable's (player's) inventory. Shows the calculation animation in the HUD. Adds treasure to the inventory list shown on transition. Use the global add_money to add money without adding specific treasure. ---@field set_post_collect_treasure fun(self, fun: fun(self: Movable, value: integer, treasure: ENT_TYPE): boolean?): CallbackId @Hooks after the virtual function.
The callback signature is `nil collect_treasure(Movable self, integer value, ENT_TYPE treasure)`
Virtual function docs:
Adds or subtracts the specified amount of money to the movable's (player's) inventory. Shows the calculation animation in the HUD. Adds treasure to the inventory list shown on transition. Use the global add_money to add money without adding specific treasure. + ---@field set_pre_apply_movement fun(self, fun: fun(self: Movable, integer: , integer: , integer: ): boolean?): CallbackId @Hooks before the virtual function.
The callback signature is `optional apply_movement(Movable self, integer, integer, integer)` + ---@field set_post_apply_movement fun(self, fun: fun(self: Movable, integer: , integer: , integer: ): boolean?): CallbackId @Hooks after the virtual function.
The callback signature is `nil apply_movement(Movable self, integer, integer, integer)` + ---@field set_pre_is_powerup_capable fun(self, fun: fun(self: Movable): boolean?): CallbackId @Hooks before the virtual function.
The callback signature is `optional is_powerup_capable(Movable self)` + ---@field set_post_is_powerup_capable fun(self, fun: fun(self: Movable): boolean?): CallbackId @Hooks after the virtual function.
The callback signature is `nil is_powerup_capable(Movable self)` ---@field set_pre_initialize fun(self, fun: fun(self: Movable): boolean): CallbackId @Hooks before the virtual function.
The callback signature is `bool initialize(Movable self)` ---@field set_post_initialize fun(self, fun: fun(self: Movable): boolean): CallbackId @Hooks after the virtual function.
The callback signature is `nil initialize(Movable self)` ---@field set_pre_process_input fun(self, fun: fun(self: Movable): boolean): CallbackId @Hooks before the virtual function.
The callback signature is `bool process_input(Movable self)` ---@field set_post_process_input fun(self, fun: fun(self: Movable): boolean): CallbackId @Hooks after the virtual function.
The callback signature is `nil process_input(Movable self)` ---@field set_pre_picked_up fun(self, fun: fun(self: Movable): boolean): CallbackId @Hooks before the virtual function.
The callback signature is `bool picked_up(Movable self)` ---@field set_post_picked_up fun(self, fun: fun(self: Movable): boolean): CallbackId @Hooks after the virtual function.
The callback signature is `nil picked_up(Movable self)` - ---@field set_pre_fall fun(self, fun: fun(self: Movable): boolean): CallbackId @Hooks before the virtual function.
The callback signature is `bool fall(Movable self)` - ---@field set_post_fall fun(self, fun: fun(self: Movable): boolean): CallbackId @Hooks after the virtual function.
The callback signature is `nil fall(Movable self)` + ---@field set_pre_release fun(self, fun: fun(self: Movable): boolean): CallbackId @Hooks before the virtual function.
The callback signature is `bool release(Movable self)` + ---@field set_post_release fun(self, fun: fun(self: Movable): boolean): CallbackId @Hooks after the virtual function.
The callback signature is `nil release(Movable self)` + ---@field set_pre_generate_fall_poof_particles fun(self, fun: fun(self: Movable): boolean): CallbackId @Hooks before the virtual function.
The callback signature is `bool generate_fall_poof_particles(Movable self)` + ---@field set_post_generate_fall_poof_particles fun(self, fun: fun(self: Movable): boolean): CallbackId @Hooks after the virtual function.
The callback signature is `nil generate_fall_poof_particles(Movable self)` + ---@field set_pre_fall fun(self, fun: fun(self: Movable, number: number): boolean): CallbackId @Hooks before the virtual function.
The callback signature is `bool fall(Movable self, number number)` + ---@field set_post_fall fun(self, fun: fun(self: Movable, number: number): boolean): CallbackId @Hooks after the virtual function.
The callback signature is `nil fall(Movable self, number number)` ---@field set_pre_apply_friction fun(self, fun: fun(self: Movable, number: , vertical: boolean, number: ): boolean): CallbackId @Hooks before the virtual function.
The callback signature is `bool apply_friction(Movable self, number, boolean vertical, number)` ---@field set_post_apply_friction fun(self, fun: fun(self: Movable, number: , vertical: boolean, number: ): boolean): CallbackId @Hooks after the virtual function.
The callback signature is `nil apply_friction(Movable self, number, boolean vertical, number)` - ---@field set_pre_crush fun(self, fun: fun(self: Movable, Entity: ): boolean): CallbackId @Hooks before the virtual function.
The callback signature is `bool crush(Movable self, Entity)` - ---@field set_post_crush fun(self, fun: fun(self: Movable, Entity: ): boolean): CallbackId @Hooks after the virtual function.
The callback signature is `nil crush(Movable self, Entity)` + ---@field set_pre_can_break_block fun(self, fun: fun(self: Movable, horizontal: boolean, block: Entity): boolean?): CallbackId @Hooks before the virtual function.
The callback signature is `optional can_break_block(Movable self, boolean horizontal, Entity block)` + ---@field set_post_can_break_block fun(self, fun: fun(self: Movable, horizontal: boolean, block: Entity): boolean?): CallbackId @Hooks after the virtual function.
The callback signature is `nil can_break_block(Movable self, boolean horizontal, Entity block)` + ---@field set_pre_break_block fun(self, fun: fun(self: Movable, camera_shake: boolean, block: Entity): boolean): CallbackId @Hooks before the virtual function.
The callback signature is `bool break_block(Movable self, boolean camera_shake, Entity block)` + ---@field set_post_break_block fun(self, fun: fun(self: Movable, camera_shake: boolean, block: Entity): boolean): CallbackId @Hooks after the virtual function.
The callback signature is `nil break_block(Movable self, boolean camera_shake, Entity block)` + ---@field set_pre_crush fun(self, fun: fun(self: Movable, entity: Entity): boolean): CallbackId @Hooks before the virtual function.
The callback signature is `bool crush(Movable self, Entity entity)` + ---@field set_post_crush fun(self, fun: fun(self: Movable, entity: Entity): boolean): CallbackId @Hooks after the virtual function.
The callback signature is `nil crush(Movable self, Entity entity)` + ---@field set_pre_instakill_death fun(self, fun: fun(self: Movable): boolean): CallbackId @Hooks before the virtual function.
The callback signature is `bool instakill_death(Movable self)` + ---@field set_post_instakill_death fun(self, fun: fun(self: Movable): boolean): CallbackId @Hooks after the virtual function.
The callback signature is `nil instakill_death(Movable self)` local Movable = nil ---Move a movable according to its velocity, can disable gravity ---Will also update `movable.animation_frame` and various timers and counters @@ -7122,9 +7157,14 @@ ENTITY_OVERRIDE = { ACTIVATE = 25, APPLY_FRICTION = 84, APPLY_METADATA = 28, + APPLY_MOVEMENT = 71, APPLY_VELOCITY = 42, + ATTACK = 46, + BREAK_BLOCK = 86, CALCULATE_JUMP_VELOCITY = 40, + CAN_BE_PICKED_UP_BY = 68, CAN_BE_PUSHED = 10, + CAN_BREAK_BLOCK = 85, CAN_ENTER = 46, CAN_JUMP = 37, CHECK_OUT_OF_BOUNDS = 58, @@ -7143,6 +7183,7 @@ ENTITY_OVERRIDE = { FLOOR_UPDATE = 38, FREEZE = 52, FRICTION = 19, + GENERATE_FALL_POOF_PARTICLES = 82, GENERATE_STOMP_DAMAGE_PARTICLES = 8, GET_COLLISION_INFO = 38, GET_DAMAGE = 43, @@ -7152,8 +7193,10 @@ ENTITY_OVERRIDE = { HIDE_HUD = 41, INIT = 36, INITIALIZE = 75, + INSTAKILL_DEATH = 92, IS_IN_LIQUID = 12, IS_ON_FIRE = 45, + IS_POWERUP_CAPABLE = 74, IS_UNLOCKED = 45, KILL = 3, LEDGE_GRAB = 31, @@ -7167,6 +7210,7 @@ ENTITY_OVERRIDE = { PICKED_UP_BY = 68, PICK_UP = 67, PROCESS_INPUT = 78, + RELEASE = 81, REMOVE_ITEM = 21, RESET_DRAW_DEPTH = 18, SET_AS_SOUND_SOURCE = 20, @@ -7181,6 +7225,7 @@ ENTITY_OVERRIDE = { STOOD_ON = 32, STUN = 51, THROWN_BY = 62, + THROWN_INTO = 47, TRIGGER_ACTION = 24, UPDATE_STATE_MACHINE = 2, WALKED_OFF = 30, diff --git a/docs/src/includes/_enums.md b/docs/src/includes/_enums.md index 5dd0d4144..4065f64a7 100644 --- a/docs/src/includes/_enums.md +++ b/docs/src/includes/_enums.md @@ -262,6 +262,8 @@ Name | Data | Description [APPLY_VELOCITY](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=ENTITY_OVERRIDE.APPLY_VELOCITY) | 42 | [GET_DAMAGE](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=ENTITY_OVERRIDE.GET_DAMAGE) | 43 | [IS_ON_FIRE](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=ENTITY_OVERRIDE.IS_ON_FIRE) | 45 | +[ATTACK](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=ENTITY_OVERRIDE.ATTACK) | 46 | +[THROWN_INTO](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=ENTITY_OVERRIDE.THROWN_INTO) | 47 | [DAMAGE](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=ENTITY_OVERRIDE.DAMAGE) | 48 | [ON_HIT](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=ENTITY_OVERRIDE.ON_HIT) | 49 | [GET_DAMAGE_SOUND](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=ENTITY_OVERRIDE.GET_DAMAGE_SOUND) | 50 | @@ -277,15 +279,22 @@ Name | Data | Description [THROWN_BY](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=ENTITY_OVERRIDE.THROWN_BY) | 62 | [CLONED_TO](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=ENTITY_OVERRIDE.CLONED_TO) | 63 | [PICK_UP](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=ENTITY_OVERRIDE.PICK_UP) | 67 | -[PICKED_UP_BY](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=ENTITY_OVERRIDE.PICKED_UP_BY) | 68 | +[CAN_BE_PICKED_UP_BY](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=ENTITY_OVERRIDE.CAN_BE_PICKED_UP_BY) | 68 | [DROP](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=ENTITY_OVERRIDE.DROP) | 69 | [COLLECT_TREASURE](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=ENTITY_OVERRIDE.COLLECT_TREASURE) | 70 | +[APPLY_MOVEMENT](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=ENTITY_OVERRIDE.APPLY_MOVEMENT) | 71 | +[IS_POWERUP_CAPABLE](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=ENTITY_OVERRIDE.IS_POWERUP_CAPABLE) | 74 | [INITIALIZE](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=ENTITY_OVERRIDE.INITIALIZE) | 75 | [PROCESS_INPUT](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=ENTITY_OVERRIDE.PROCESS_INPUT) | 78 | [PICKED_UP](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=ENTITY_OVERRIDE.PICKED_UP) | 80 | +[RELEASE](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=ENTITY_OVERRIDE.RELEASE) | 81 | +[GENERATE_FALL_POOF_PARTICLES](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=ENTITY_OVERRIDE.GENERATE_FALL_POOF_PARTICLES) | 82 | [FALL](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=ENTITY_OVERRIDE.FALL) | 83 | [APPLY_FRICTION](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=ENTITY_OVERRIDE.APPLY_FRICTION) | 84 | +[CAN_BREAK_BLOCK](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=ENTITY_OVERRIDE.CAN_BREAK_BLOCK) | 85 | +[BREAK_BLOCK](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=ENTITY_OVERRIDE.BREAK_BLOCK) | 86 | [CRUSH](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=ENTITY_OVERRIDE.CRUSH) | 90 | +[INSTAKILL_DEATH](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=ENTITY_OVERRIDE.INSTAKILL_DEATH) | 92 | [FLOOR_UPDATE](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=ENTITY_OVERRIDE.FLOOR_UPDATE) | 38 | [ENTER_ATTEMPT](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=ENTITY_OVERRIDE.ENTER_ATTEMPT) | 40 | [HIDE_HUD](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=ENTITY_OVERRIDE.HIDE_HUD) | 41 | diff --git a/docs/src/includes/_types.md b/docs/src/includes/_types.md index 13db5465c..00f0a1de2 100644 --- a/docs/src/includes/_types.md +++ b/docs/src/includes/_types.md @@ -456,13 +456,18 @@ Type | Name | Description int | [search_flags](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=search_flags) | [MASK](#MASK) float | [width](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=width) | float | [height](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=height) | +int | [draw_depth](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=draw_depth) | float | [offsetx](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=offsetx) | float | [offsety](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=offsety) | float | [hitboxx](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=hitboxx) | float | [hitboxy](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=hitboxy) | -int | [draw_depth](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=draw_depth) | +[SHAPE](#SHAPE) | [default_shape](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=default_shape) | +bool | [default_hitbox_enabled](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=default_hitbox_enabled) | int | [collision2_mask](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=collision2_mask) | [MASK](#MASK), will only call collision2 when colliding with entities that match this mask. int | [collision_mask](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=collision_mask) | [MASK](#MASK) used for collision with floors, walls etc. +int | [default_flags](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=default_flags) | +int | [default_more_flags](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=default_more_flags) | +int | [properties_flags](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=properties_flags) | float | [friction](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=friction) | float | [elasticity](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=elasticity) | float | [weight](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=weight) | @@ -471,21 +476,20 @@ float | [max_speed](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=max float | [sprint_factor](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=sprint_factor) | float | [jump](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=jump) | [Color](#Color) | [default_color](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=default_color) | +[TEXTURE](#TEXTURE) | [texture](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=texture) | +int | [tilex](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=tilex) | +int | [tiley](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=tiley) | int | [damage](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=damage) | int | [life](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=life) | int | [sacrifice_value](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=sacrifice_value) | Favor for sacrificing alive. Halved when dead (health == 0). int | [blood_content](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=blood_content) | -[TEXTURE](#TEXTURE) | [texture](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=texture) | -map<int, [Animation](#Animation)> | [animations](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=animations) | -int | [properties_flags](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=properties_flags) | -int | [default_flags](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=default_flags) | -int | [default_more_flags](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=default_more_flags) | bool | [leaves_corpse_behind](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=leaves_corpse_behind) | +[STRINGID](#Aliases) | [description](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=description) | int | [sound_killed_by_player](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=sound_killed_by_player) | int | [sound_killed_by_other](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=sound_killed_by_other) | -[STRINGID](#Aliases) | [description](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=description) | -int | [tilex](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=tilex) | -int | [tiley](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=tiley) | +map<int, [Animation](#Animation)> | [animations](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=animations) | +float | [default_special_offsetx](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=default_special_offsetx) | +float | [default_special_offsetx](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=default_special_offsetx) | ### HudInventory @@ -4233,7 +4237,7 @@ bool | [overlaps_with(Entity other)](https://github.com/spelunky-fyi/overlunky/s [TEXTURE](#TEXTURE) | [get_texture()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=get_texture) | bool | [set_texture(TEXTURE texture_id)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_texture) | Changes the entity texture, check the [textures.txt](game_data/textures.txt) for available vanilla textures or use [define_texture](#define_texture) to make custom one nil | [set_draw_depth(int draw_depth, int b3f)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_draw_depth) | -nil | [set_enable_turning(bool enabled)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_enable_turning) | +nil | [reset_draw_depth()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=reset_draw_depth) | nil | [liberate_from_shop(bool clear_parrent)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=liberate_from_shop) | `clear_parent` used only for CHAR_* entities, sets the `linked_companion_parent` to -1 [Entity](#Entity) | [get_held_entity()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=get_held_entity) | nil | [set_layer(LAYER layer)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_layer) | Moves the entity to specified layer, nothing else happens, so this does not emulate a door transition @@ -4251,13 +4255,16 @@ nil | [set_invisible(bool value)](https://github.com/spelunky-fyi/overlunky/sear vector<int> | [get_items()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=get_items) | bool | [is_in_liquid()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=is_in_liquid) | Returns true if entity is in water/lava bool | [is_cursed()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=is_cursed) | +bool | [is_movable()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=is_movable) | +bool | [can_be_pushed()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=can_be_pushed) | nil | [kill_recursive(bool destroy_corpse, Entity responsible, optional mask, array ent_types, RECURSIVE_MODE rec_mode)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=kill_recursive) | Kill entity along with all entities attached to it. Be aware that for example killing push block with this function will also kill anything on top of it, any items, players, monsters etc.
To avoid that, you can inclusively or exclusively limit certain [MASK](#MASK) and [ENT_TYPE](#ENT_TYPE). Note: the function will first check mask, if the entity doesn't match, it will look in the provided [ENT_TYPE](#ENT_TYPE)'s
destroy_corpse and responsible are the standard parameters for the kill function nil | [kill_recursive(bool destroy_corpse, Entity responsible)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=kill_recursive) | Short for using [RECURSIVE_MODE](#RECURSIVE_MODE).NONE nil | [destroy_recursive(optional mask, array ent_types, RECURSIVE_MODE rec_mode)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=destroy_recursive) | Destroy entity along with all entities attached to it. Be aware that for example destroying push block with this function will also destroy anything on top of it, any items, players, monsters etc.
To avoid that, you can inclusively or exclusively limit certain [MASK](#MASK) and [ENT_TYPE](#ENT_TYPE). Note: the function will first check the mask, if the entity doesn't match, it will look in the provided [ENT_TYPE](#ENT_TYPE)'s nil | [destroy_recursive()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=destroy_recursive) | Short for using [RECURSIVE_MODE](#RECURSIVE_MODE).NONE nil | [update()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=update) | nil | [flip(bool left)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=flip) | -bool | [can_be_pushed()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=can_be_pushed) | +nil | [remove_item(Entity entity, bool autokill_check)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=remove_item) | +nil | [apply_db()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=apply_db) | Applies changes made in `entity.type` [CallbackId](#Aliases) | [set_pre_virtual(ENTITY_OVERRIDE entry, function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_pre_virtual) | Hooks before the virtual function at index `entry`. [CallbackId](#Aliases) | [set_post_virtual(ENTITY_OVERRIDE entry, function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_post_virtual) | Hooks after the virtual function at index `entry`. nil | [clear_virtual(CallbackId callback_id)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=clear_virtual) | Clears the hook given by `callback_id`, alternatively use `clear_callback()` inside the hook. @@ -6886,6 +6893,7 @@ float | [movey](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=movey) [BUTTON](#BUTTON) | [buttons_previous](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=buttons_previous) | int | [stand_counter](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=stand_counter) | float | [jump_height_multiplier](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=jump_height_multiplier) | [EntityDB](#EntityDB).jump gets multiplied by this to get the jump +int | [price](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=price) | int | [owner_uid](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=owner_uid) | int | [last_owner_uid](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=last_owner_uid) | [Animation](#Animation) | [current_animation](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=current_animation) | @@ -6909,7 +6917,6 @@ int | [onfire_effect_timer](https://github.com/spelunky-fyi/overlunky/search?l=L int | [exit_invincibility_timer](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=exit_invincibility_timer) | int | [invincibility_frames_timer](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=invincibility_frames_timer) | int | [frozen_timer](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=frozen_timer) | -int | [price](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=price) | bool | [is_poisoned()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=is_poisoned) | bool | [is_button_pressed(BUTTON button)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=is_button_pressed) | bool | [is_button_held(BUTTON button)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=is_button_held) | @@ -6917,7 +6924,7 @@ bool | [is_button_released(BUTTON button)](https://github.com/spelunky-fyi/overl nil | [stun(int framecount)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=stun) | nil | [freeze(int framecount, bool ignore_lava)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=freeze) | Sets the `frozen_timer`, the param `ignore_lava` doesn't do much, just skips the liquid check, if in lava the game will set `frozen_timer` to 0 immediately most of the time nil | [light_on_fire(int time)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=light_on_fire) | Does not damage entity -nil | [set_cursed(bool b, optional effect)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_cursed) | effect = true - plays the sound and spawn particle above entity +nil | [set_cursed(bool b, bool effect)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_cursed) | nil | [drop()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=drop) | Called when dropping or throwing nil | [pick_up(Entity entity_to_pick_up)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=pick_up) | [Entity](#Entity) | [standing_on()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=standing_on) | @@ -6925,6 +6932,9 @@ bool | [collect_treasure(int value, ENT_TYPE treasure)](https://github.com/spelu bool | [can_jump()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=can_jump) | Return true if the entity is allowed to jump, even midair. Return false and can't jump, except from ladders apparently. bool | [is_on_fire()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=is_on_fire) | bool | [is_powerup_capable()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=is_powerup_capable) | +bool | [can_be_picked_up_by(Entity entity_picking_up, bool)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=can_be_picked_up_by) | +bool | [can_break_block(bool horizontal, Entity block)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=can_break_block) | +nil | [break_block(bool camera_shake, Entity block)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=break_block) | bool | [damage(Entity damage_dealer, int damage_amount, DAMAGE_TYPE damage_flags, Vec2 velocity, int unknown_damage_phase, int stun_amount, int iframes, bool unknown_is_final)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=damage) | Damage the movable by the specified amount, stuns and gives it invincibility for the specified amount of frames and applies the velocities. `damage_dealer` can be set to nil.
Returns: true if entity was affected (for stuff like pot that should break after hit etc.), false if the event should be ignored by damage_dealer vector<int> | [get_all_behaviors()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=get_all_behaviors) | Get all available behavior ids bool | [set_behavior(int behavior_id)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_behavior) | Set behavior, this is more than just state as it's an active function, for example climbing ladder is a behavior and it doesn't actually need ladder/rope entity
Returns false if entity doesn't have this behavior id @@ -6933,6 +6943,13 @@ nil | [set_gravity(float gravity)](https://github.com/spelunky-fyi/overlunky/sea nil | [reset_gravity()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=reset_gravity) | Remove the gravity hook and reset to defaults nil | [set_position(float to_x, float to_y)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_position) | Set the absolute position of an entity and offset all rendering related things accordingly to teleport without any interpolation or graphical glitches. If the camera is focused on the entity, it is also moved. nil | [process_input()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=process_input) | +float | [calculate_jump_velocity(bool dont_ignore_liquid)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=calculate_jump_velocity) | +nil | [apply_velocity(Vec2 velocities, bool ignore_weight)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=apply_velocity) | +int | [get_damage()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=get_damage) | Returns the damage that the entity deals +bool | [attack(Entity victim)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=attack) | Runs on contact damage, returns false if there wasn't any interaction (called from on_collision2, will be called as long as the hitboxes overlap) +bool | [thrown_into(Entity victim)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=thrown_into) | Same as above, but for being thrown into something and potentially dealing damage that way +int | [get_damage_sound(DAMAGE_TYPE damage)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=get_damage_sound) | returns sound id for the damage taken, return 0 to make it silence +nil | [copy_extra_info(Entity clone, int some_entity_uid)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=copy_extra_info) | Entities must be of the same type! [CutsceneBehavior](#CutsceneBehavior) | [cutscene](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=cutscene) | nil | [clear_cutscene()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=clear_cutscene) | [VanillaMovableBehavior](#VanillaMovableBehavior) | [get_base_behavior(int state_id)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=get_base_behavior) | Gets a vanilla behavior from this movable, needs to be called before `clear_behaviors`
but the returned values are still valid after a call to `clear_behaviors` @@ -6961,6 +6978,10 @@ nil | [clear_virtual(CallbackId callback_id)](https://github.com/spelunky-fyi/ov [CallbackId](#Aliases) | [set_post_get_damage(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_post_get_damage) | Hooks after the virtual function.
The callback signature is `nil get_damage(Movable self)`
Virtual function docs:
Returns the damage that the entity deals [CallbackId](#Aliases) | [set_pre_is_on_fire(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_pre_is_on_fire) | Hooks before the virtual function.
The callback signature is `optional is_on_fire(Movable self)` [CallbackId](#Aliases) | [set_post_is_on_fire(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_post_is_on_fire) | Hooks after the virtual function.
The callback signature is `nil is_on_fire(Movable self)` +[CallbackId](#Aliases) | [set_pre_attack(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_pre_attack) | Hooks before the virtual function.
The callback signature is `optional attack(Movable self, Entity victim)`
Virtual function docs:
Runs on contact damage, returns false if there wasn't any interaction (called from on_collision2, will be called as long as the hitboxes overlap) +[CallbackId](#Aliases) | [set_post_attack(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_post_attack) | Hooks after the virtual function.
The callback signature is `nil attack(Movable self, Entity victim)`
Virtual function docs:
Runs on contact damage, returns false if there wasn't any interaction (called from on_collision2, will be called as long as the hitboxes overlap) +[CallbackId](#Aliases) | [set_pre_thrown_into(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_pre_thrown_into) | Hooks before the virtual function.
The callback signature is `optional thrown_into(Movable self, Entity victim)`
Virtual function docs:
Same as above, but for being thrown into something and potentially dealing damage that way +[CallbackId](#Aliases) | [set_post_thrown_into(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_post_thrown_into) | Hooks after the virtual function.
The callback signature is `nil thrown_into(Movable self, Entity victim)`
Virtual function docs:
Same as above, but for being thrown into something and potentially dealing damage that way [CallbackId](#Aliases) | [set_pre_damage(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_pre_damage) | Hooks before the virtual function.
The callback signature is `optional damage(Movable self, Entity damage_dealer, int damage_amount, DAMAGE_TYPE damage_flags, Vec2 velocity, int unknown_damage_phase, int stun_amount, int iframes, bool unknown_is_final)`
Virtual function docs:
Damage the movable by the specified amount, stuns and gives it invincibility for the specified amount of frames and applies the velocities. `damage_dealer` can be set to nil.
Returns: true if entity was affected (for stuff like pot that should break after hit etc.), false if the event should be ignored by damage_dealer [CallbackId](#Aliases) | [set_post_damage(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_post_damage) | Hooks after the virtual function.
The callback signature is `nil damage(Movable self, Entity damage_dealer, int damage_amount, DAMAGE_TYPE damage_flags, Vec2 velocity, int unknown_damage_phase, int stun_amount, int iframes, bool unknown_is_final)`
Virtual function docs:
Damage the movable by the specified amount, stuns and gives it invincibility for the specified amount of frames and applies the velocities. `damage_dealer` can be set to nil.
Returns: true if entity was affected (for stuff like pot that should break after hit etc.), false if the event should be ignored by damage_dealer [CallbackId](#Aliases) | [set_pre_on_hit(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_pre_on_hit) | Hooks before the virtual function.
The callback signature is `bool on_hit(Movable self, Entity damage_dealer)`
Virtual function docs:
Hit by broken arrows etc that don't deal damage, calls damage with 0 damage. @@ -6975,40 +6996,54 @@ nil | [clear_virtual(CallbackId callback_id)](https://github.com/spelunky-fyi/ov [CallbackId](#Aliases) | [set_post_light_on_fire(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_post_light_on_fire) | Hooks after the virtual function.
The callback signature is `nil light_on_fire(Movable self, int time)`
Virtual function docs:
Does not damage entity [CallbackId](#Aliases) | [set_pre_set_cursed(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_pre_set_cursed) | Hooks before the virtual function.
The callback signature is `bool set_cursed(Movable self, bool b, bool effect)` [CallbackId](#Aliases) | [set_post_set_cursed(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_post_set_cursed) | Hooks after the virtual function.
The callback signature is `nil set_cursed(Movable self, bool b, bool effect)` -[CallbackId](#Aliases) | [set_pre_web_collision(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_pre_web_collision) | Hooks before the virtual function.
The callback signature is `bool web_collision(Movable self)` -[CallbackId](#Aliases) | [set_post_web_collision(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_post_web_collision) | Hooks after the virtual function.
The callback signature is `nil web_collision(Movable self)` +[CallbackId](#Aliases) | [set_pre_web_collision(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_pre_web_collision) | Hooks before the virtual function.
The callback signature is `bool web_collision(Movable self, bool bool)` +[CallbackId](#Aliases) | [set_post_web_collision(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_post_web_collision) | Hooks after the virtual function.
The callback signature is `nil web_collision(Movable self, bool bool)` [CallbackId](#Aliases) | [set_pre_check_out_of_bounds(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_pre_check_out_of_bounds) | Hooks before the virtual function.
The callback signature is `bool check_out_of_bounds(Movable self)`
Virtual function docs:
Disable to not get killed outside level bounds. [CallbackId](#Aliases) | [set_post_check_out_of_bounds(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_post_check_out_of_bounds) | Hooks after the virtual function.
The callback signature is `nil check_out_of_bounds(Movable self)`
Virtual function docs:
Disable to not get killed outside level bounds. [CallbackId](#Aliases) | [set_pre_set_standing_on(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_pre_set_standing_on) | Hooks before the virtual function.
The callback signature is `bool set_standing_on(Movable self, int entity_uid)` [CallbackId](#Aliases) | [set_post_set_standing_on(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_post_set_standing_on) | Hooks after the virtual function.
The callback signature is `nil set_standing_on(Movable self, int entity_uid)` [CallbackId](#Aliases) | [set_pre_standing_on(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_pre_standing_on) | Hooks before the virtual function.
The callback signature is `optional standing_on(Movable self)` [CallbackId](#Aliases) | [set_post_standing_on(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_post_standing_on) | Hooks after the virtual function.
The callback signature is `nil standing_on(Movable self)` -[CallbackId](#Aliases) | [set_pre_stomped_by(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_pre_stomped_by) | Hooks before the virtual function.
The callback signature is `bool stomped_by(Movable self, Entity)` -[CallbackId](#Aliases) | [set_post_stomped_by(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_post_stomped_by) | Hooks after the virtual function.
The callback signature is `nil stomped_by(Movable self, Entity)` -[CallbackId](#Aliases) | [set_pre_thrown_by(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_pre_thrown_by) | Hooks before the virtual function.
The callback signature is `bool thrown_by(Movable self, Entity)` -[CallbackId](#Aliases) | [set_post_thrown_by(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_post_thrown_by) | Hooks after the virtual function.
The callback signature is `nil thrown_by(Movable self, Entity)` -[CallbackId](#Aliases) | [set_pre_cloned_to(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_pre_cloned_to) | Hooks before the virtual function.
The callback signature is `bool cloned_to(Movable self, Entity)` -[CallbackId](#Aliases) | [set_post_cloned_to(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_post_cloned_to) | Hooks after the virtual function.
The callback signature is `nil cloned_to(Movable self, Entity)` +[CallbackId](#Aliases) | [set_pre_stomped_by(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_pre_stomped_by) | Hooks before the virtual function.
The callback signature is `optional stomped_by(Movable self, Entity stomper)` +[CallbackId](#Aliases) | [set_post_stomped_by(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_post_stomped_by) | Hooks after the virtual function.
The callback signature is `nil stomped_by(Movable self, Entity stomper)` +[CallbackId](#Aliases) | [set_pre_thrown_by(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_pre_thrown_by) | Hooks before the virtual function.
The callback signature is `bool thrown_by(Movable self, Entity thrower)` +[CallbackId](#Aliases) | [set_post_thrown_by(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_post_thrown_by) | Hooks after the virtual function.
The callback signature is `nil thrown_by(Movable self, Entity thrower)` +[CallbackId](#Aliases) | [set_pre_cloned_to(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_pre_cloned_to) | Hooks before the virtual function.
The callback signature is `bool cloned_to(Movable self, Entity clone int some_entity_uid)` +[CallbackId](#Aliases) | [set_post_cloned_to(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_post_cloned_to) | Hooks after the virtual function.
The callback signature is `nil cloned_to(Movable self, Entity clone int some_entity_uid)` [CallbackId](#Aliases) | [set_pre_pick_up(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_pre_pick_up) | Hooks before the virtual function.
The callback signature is `bool pick_up(Movable self, Entity entity_to_pick_up)` [CallbackId](#Aliases) | [set_post_pick_up(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_post_pick_up) | Hooks after the virtual function.
The callback signature is `nil pick_up(Movable self, Entity entity_to_pick_up)` -[CallbackId](#Aliases) | [set_pre_picked_up_by(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_pre_picked_up_by) | Hooks before the virtual function.
The callback signature is `bool picked_up_by(Movable self, Entity)` -[CallbackId](#Aliases) | [set_post_picked_up_by(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_post_picked_up_by) | Hooks after the virtual function.
The callback signature is `nil picked_up_by(Movable self, Entity)` +[CallbackId](#Aliases) | [set_pre_can_be_picked_up_by(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_pre_can_be_picked_up_by) | Hooks before the virtual function.
The callback signature is `optional can_be_picked_up_by(Movable self, Entity entity_picking_up, bool)` +[CallbackId](#Aliases) | [set_post_can_be_picked_up_by(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_post_can_be_picked_up_by) | Hooks after the virtual function.
The callback signature is `nil can_be_picked_up_by(Movable self, Entity entity_picking_up, bool)` [CallbackId](#Aliases) | [set_pre_drop(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_pre_drop) | Hooks before the virtual function.
The callback signature is `bool drop(Movable self)`
Virtual function docs:
Called when dropping or throwing [CallbackId](#Aliases) | [set_post_drop(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_post_drop) | Hooks after the virtual function.
The callback signature is `nil drop(Movable self)`
Virtual function docs:
Called when dropping or throwing [CallbackId](#Aliases) | [set_pre_collect_treasure(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_pre_collect_treasure) | Hooks before the virtual function.
The callback signature is `optional collect_treasure(Movable self, int value, ENT_TYPE treasure)`
Virtual function docs:
Adds or subtracts the specified amount of money to the movable's (player's) inventory. Shows the calculation animation in the HUD. Adds treasure to the inventory list shown on transition. Use the global add_money to add money without adding specific treasure. [CallbackId](#Aliases) | [set_post_collect_treasure(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_post_collect_treasure) | Hooks after the virtual function.
The callback signature is `nil collect_treasure(Movable self, int value, ENT_TYPE treasure)`
Virtual function docs:
Adds or subtracts the specified amount of money to the movable's (player's) inventory. Shows the calculation animation in the HUD. Adds treasure to the inventory list shown on transition. Use the global add_money to add money without adding specific treasure. +[CallbackId](#Aliases) | [set_pre_apply_movement(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_pre_apply_movement) | Hooks before the virtual function.
The callback signature is `optional apply_movement(Movable self, int, int, int)` +[CallbackId](#Aliases) | [set_post_apply_movement(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_post_apply_movement) | Hooks after the virtual function.
The callback signature is `nil apply_movement(Movable self, int, int, int)` +[CallbackId](#Aliases) | [set_pre_is_powerup_capable(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_pre_is_powerup_capable) | Hooks before the virtual function.
The callback signature is `optional is_powerup_capable(Movable self)` +[CallbackId](#Aliases) | [set_post_is_powerup_capable(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_post_is_powerup_capable) | Hooks after the virtual function.
The callback signature is `nil is_powerup_capable(Movable self)` [CallbackId](#Aliases) | [set_pre_initialize(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_pre_initialize) | Hooks before the virtual function.
The callback signature is `bool initialize(Movable self)` [CallbackId](#Aliases) | [set_post_initialize(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_post_initialize) | Hooks after the virtual function.
The callback signature is `nil initialize(Movable self)` [CallbackId](#Aliases) | [set_pre_process_input(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_pre_process_input) | Hooks before the virtual function.
The callback signature is `bool process_input(Movable self)` [CallbackId](#Aliases) | [set_post_process_input(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_post_process_input) | Hooks after the virtual function.
The callback signature is `nil process_input(Movable self)` [CallbackId](#Aliases) | [set_pre_picked_up(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_pre_picked_up) | Hooks before the virtual function.
The callback signature is `bool picked_up(Movable self)` [CallbackId](#Aliases) | [set_post_picked_up(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_post_picked_up) | Hooks after the virtual function.
The callback signature is `nil picked_up(Movable self)` -[CallbackId](#Aliases) | [set_pre_fall(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_pre_fall) | Hooks before the virtual function.
The callback signature is `bool fall(Movable self)` -[CallbackId](#Aliases) | [set_post_fall(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_post_fall) | Hooks after the virtual function.
The callback signature is `nil fall(Movable self)` +[CallbackId](#Aliases) | [set_pre_release(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_pre_release) | Hooks before the virtual function.
The callback signature is `bool release(Movable self)` +[CallbackId](#Aliases) | [set_post_release(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_post_release) | Hooks after the virtual function.
The callback signature is `nil release(Movable self)` +[CallbackId](#Aliases) | [set_pre_generate_fall_poof_particles(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_pre_generate_fall_poof_particles) | Hooks before the virtual function.
The callback signature is `bool generate_fall_poof_particles(Movable self)` +[CallbackId](#Aliases) | [set_post_generate_fall_poof_particles(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_post_generate_fall_poof_particles) | Hooks after the virtual function.
The callback signature is `nil generate_fall_poof_particles(Movable self)` +[CallbackId](#Aliases) | [set_pre_fall(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_pre_fall) | Hooks before the virtual function.
The callback signature is `bool fall(Movable self, float float)` +[CallbackId](#Aliases) | [set_post_fall(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_post_fall) | Hooks after the virtual function.
The callback signature is `nil fall(Movable self, float float)` [CallbackId](#Aliases) | [set_pre_apply_friction(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_pre_apply_friction) | Hooks before the virtual function.
The callback signature is `bool apply_friction(Movable self, float, bool vertical, float)` [CallbackId](#Aliases) | [set_post_apply_friction(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_post_apply_friction) | Hooks after the virtual function.
The callback signature is `nil apply_friction(Movable self, float, bool vertical, float)` -[CallbackId](#Aliases) | [set_pre_crush(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_pre_crush) | Hooks before the virtual function.
The callback signature is `bool crush(Movable self, Entity)` -[CallbackId](#Aliases) | [set_post_crush(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_post_crush) | Hooks after the virtual function.
The callback signature is `nil crush(Movable self, Entity)` +[CallbackId](#Aliases) | [set_pre_can_break_block(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_pre_can_break_block) | Hooks before the virtual function.
The callback signature is `optional can_break_block(Movable self, bool horizontal, Entity block)` +[CallbackId](#Aliases) | [set_post_can_break_block(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_post_can_break_block) | Hooks after the virtual function.
The callback signature is `nil can_break_block(Movable self, bool horizontal, Entity block)` +[CallbackId](#Aliases) | [set_pre_break_block(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_pre_break_block) | Hooks before the virtual function.
The callback signature is `bool break_block(Movable self, bool camera_shake, Entity block)` +[CallbackId](#Aliases) | [set_post_break_block(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_post_break_block) | Hooks after the virtual function.
The callback signature is `nil break_block(Movable self, bool camera_shake, Entity block)` +[CallbackId](#Aliases) | [set_pre_crush(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_pre_crush) | Hooks before the virtual function.
The callback signature is `bool crush(Movable self, Entity entity)` +[CallbackId](#Aliases) | [set_post_crush(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_post_crush) | Hooks after the virtual function.
The callback signature is `nil crush(Movable self, Entity entity)` +[CallbackId](#Aliases) | [set_pre_instakill_death(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_pre_instakill_death) | Hooks before the virtual function.
The callback signature is `bool instakill_death(Movable self)` +[CallbackId](#Aliases) | [set_post_instakill_death(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_post_instakill_death) | Hooks after the virtual function.
The callback signature is `nil instakill_death(Movable self)` ### MovingIcon diff --git a/src/game_api/entity.hpp b/src/game_api/entity.hpp index ab21a4815..268e3624f 100644 --- a/src/game_api/entity.hpp +++ b/src/game_api/entity.hpp @@ -222,7 +222,7 @@ class Entity { clear_dtor_impl(this, dtor_cb_id); } - + /// NoDoc void set_enable_turning(bool enabled); std::vector get_items(); diff --git a/src/game_api/entity_db.hpp b/src/game_api/entity_db.hpp index cb1c47202..0b2f2b848 100644 --- a/src/game_api/entity_db.hpp +++ b/src/game_api/entity_db.hpp @@ -40,7 +40,7 @@ struct EntityDB float width; float height; uint8_t draw_depth; - uint8_t default_b3f; // value gets copied into entity.b3f along with draw_depth etc (RVA 0x21F30CC4) + uint8_t default_b3f; // value gets copied into entity.b3f along with draw_depth etc int16_t field_26; union { @@ -148,7 +148,6 @@ struct EntityFactory bool type_set[0x395]; std::unordered_map> entity_instance_map; // game_unorderedmap probably EntityMap entity_map; // game_unorderedmap probably - void* _ptr_7; }; EntityDB* get_type(uint32_t id); diff --git a/src/game_api/movable.hpp b/src/game_api/movable.hpp index 312420b81..b6e1b86bf 100644 --- a/src/game_api/movable.hpp +++ b/src/game_api/movable.hpp @@ -127,11 +127,6 @@ class Movable : public Entity /// Remove the gravity hook and reset to defaults void reset_gravity(); - // don't use this, it's only to not break backwards compatibility - void light_on_fire_broken() - { - this->light_on_fire(0x64); // kind of standard value that the game uses - } /// Get all available behavior ids std::vector get_all_behaviors(); /// Set behavior, this is more than just state as it's an active function, for example climbing ladder is a behavior and it doesn't actually need ladder/rope entity @@ -143,20 +138,6 @@ class Movable : public Entity /// Set the absolute position of an entity and offset all rendering related things accordingly to teleport without any interpolation or graphical glitches. If the camera is focused on the entity, it is also moved. void set_position(float to_x, float to_y); - // for backwards compatibility - // adds a coin to the table cause the collected_money_count is expected to increase - void add_money_broken(int amount) - { - static const auto coin = to_id("ENT_TYPE_ITEM_GOLDCOIN"); - this->collect_treasure(amount, coin); - } - - /// effect = true - plays the sound and spawn particle above entity - void set_cursed_fix(bool b, std::optional effect) - { - set_cursed(b, effect.value_or(true)); - } - /// Return true if the entity is allowed to jump, even midair. Return false and can't jump, except from ladders apparently. virtual bool can_jump() = 0; // 37 virtual void get_collision_info(CollisionInfo& dest) = 0; // 38, from entityDB @@ -194,7 +175,7 @@ class Movable : public Entity /// Disable to not get killed outside level bounds. virtual void check_out_of_bounds() = 0; // 58, kills with the 'still falling' death cause, is called for any item/fx/mount/monster/player virtual void set_standing_on(int32_t entity_uid) = 0; // 59 - virtual Entity* standing_on() = 0; // 60, looks up movable.standing_on_uid in state.instance_id_to_pointer + virtual Entity* standing_on() = 0; // 60 virtual bool on_stomped_on_by(Entity* stomper) = 0; // 61 virtual void on_thrown_by(Entity* thrower) = 0; // 62, implemented for special cases like hired hand (player with ai_func), horned lizard... /// Entities must be of the same type! diff --git a/src/game_api/script/usertypes/entity_lua.cpp b/src/game_api/script/usertypes/entity_lua.cpp index e82f75b94..9c71924ad 100644 --- a/src/game_api/script/usertypes/entity_lua.cpp +++ b/src/game_api/script/usertypes/entity_lua.cpp @@ -49,13 +49,18 @@ void register_usertypes(sol::state& lua) entitydb_type["search_flags"] = &EntityDB::search_flags; entitydb_type["width"] = &EntityDB::width; entitydb_type["height"] = &EntityDB::height; + entitydb_type["draw_depth"] = &EntityDB::draw_depth; entitydb_type["offsetx"] = &EntityDB::default_offsetx; entitydb_type["offsety"] = &EntityDB::default_offsety; entitydb_type["hitboxx"] = &EntityDB::default_hitboxx; entitydb_type["hitboxy"] = &EntityDB::default_hitboxy; - entitydb_type["draw_depth"] = &EntityDB::draw_depth; + entitydb_type["default_shape"] = &EntityDB::default_shape; + entitydb_type["default_hitbox_enabled"] = &EntityDB::default_hitbox_enabled; entitydb_type["collision2_mask"] = &EntityDB::collision2_mask; entitydb_type["collision_mask"] = &EntityDB::collision_mask; + entitydb_type["default_flags"] = &EntityDB::default_flags; + entitydb_type["default_more_flags"] = &EntityDB::default_more_flags; + entitydb_type["properties_flags"] = &EntityDB::properties_flags; entitydb_type["friction"] = &EntityDB::friction; entitydb_type["elasticity"] = &EntityDB::elasticity; entitydb_type["weight"] = &EntityDB::weight; @@ -68,21 +73,20 @@ void register_usertypes(sol::state& lua) entitydb_type["glow_green"] = &EntityDB::glow_green; entitydb_type["glow_blue"] = &EntityDB::glow_blue; entitydb_type["glow_alpha"] = &EntityDB::glow_alpha; + entitydb_type["texture"] = &EntityDB::texture_id; + entitydb_type["tilex"] = &EntityDB::tile_x; + entitydb_type["tiley"] = &EntityDB::tile_y; entitydb_type["damage"] = &EntityDB::damage; entitydb_type["life"] = &EntityDB::life; entitydb_type["sacrifice_value"] = &EntityDB::sacrifice_value; entitydb_type["blood_content"] = &EntityDB::blood_content; - entitydb_type["texture"] = &EntityDB::texture_id; - entitydb_type["animations"] = &EntityDB::animations; - entitydb_type["properties_flags"] = &EntityDB::properties_flags; - entitydb_type["default_flags"] = &EntityDB::default_flags; - entitydb_type["default_more_flags"] = &EntityDB::default_more_flags; entitydb_type["leaves_corpse_behind"] = &EntityDB::leaves_corpse_behind; + entitydb_type["description"] = &EntityDB::description; entitydb_type["sound_killed_by_player"] = &EntityDB::sound_killed_by_player; entitydb_type["sound_killed_by_other"] = &EntityDB::sound_killed_by_other; - entitydb_type["description"] = &EntityDB::description; - entitydb_type["tilex"] = &EntityDB::tile_x; - entitydb_type["tiley"] = &EntityDB::tile_y; + entitydb_type["animations"] = &EntityDB::animations; + entitydb_type["default_special_offsetx"] = &EntityDB::default_special_offsetx; + entitydb_type["default_special_offsetx"] = &EntityDB::default_special_offsety; /// Some information used to render the entity, can not be changed, used in Entity lua.new_usertype( @@ -244,6 +248,7 @@ void register_usertypes(sol::state& lua) { ent.set_draw_depth(depth, 0); }); entity_type["set_draw_depth"] = set_draw_depth; + entity_type["reset_draw_depth"] = &Entity::reset_draw_depth; entity_type["set_enable_turning"] = &Entity::set_enable_turning; auto liberate_from_shop = sol::overload(&Entity::liberate_from_shop, [](Entity& ent) // for backward compatibility) @@ -266,11 +271,15 @@ void register_usertypes(sol::state& lua) entity_type["get_items"] = &Entity::get_items; entity_type["is_in_liquid"] = &Entity::is_in_liquid; entity_type["is_cursed"] = &Entity::is_cursed; + entity_type["is_movable"] = &Entity::is_movable; + entity_type["can_be_pushed"] = &Entity::can_be_pushed; entity_type["kill_recursive"] = kill_recursive; entity_type["destroy_recursive"] = destroy_recursive; entity_type["update"] = &Entity::update_state_machine; entity_type["flip"] = &Entity::flip; - entity_type["can_be_pushed"] = &Entity::can_be_pushed; + entity_type["remove_item"] = &Entity::remove_item; + entity_type["apply_db"] = &Entity::apply_db; + /* Entity // user_data // You can put any arbitrary lua object here for custom entities or player stats, which is then saved across level transitions for players and carried items, mounts etc... This field is local to the script and multiple scripts can write different things in the same entity. The data is saved right before ON.PRE_LOAD_SCREEN from a level and loaded right before ON.POST_LOAD_SCREEN to a level or transition. It is not available yet in post_entity_spawn, but that is a good place to initialize it for new custom entities. See example for more. @@ -280,11 +289,15 @@ void register_usertypes(sol::state& lua) &Movable::broken_damage, &Movable::damage); auto light_on_fire = sol::overload( - static_cast(&Movable::light_on_fire_broken), - static_cast(&Movable::light_on_fire)); + [](Movable& ent) // for backwards compatibility + { ent.light_on_fire(0x64); }, // kind of standard value that the game uses + &Movable::light_on_fire); auto add_money = sol::overload( - static_cast(&Movable::add_money_broken), - static_cast(&Movable::collect_treasure)); + [](Movable& ent, int amount) // for backwards compatibility + {static const auto coin = to_id("ENT_TYPE_ITEM_GOLDCOIN"); + ent.collect_treasure(amount, coin); }, // adds a coin to the table cause the collected_money_count is expected to increase + &Movable::collect_treasure); + auto movable_type = lua.new_usertype("Movable", sol::base_classes, sol::bases()); movable_type["move"] = &Movable::move; movable_type["movex"] = &Movable::movex; @@ -293,6 +306,7 @@ void register_usertypes(sol::state& lua) movable_type["buttons_previous"] = &Movable::buttons_previous; movable_type["stand_counter"] = &Movable::stand_counter; movable_type["jump_height_multiplier"] = &Movable::jump_height_multiplier; + movable_type["price"] = &Movable::price; movable_type["owner_uid"] = &Movable::owner_uid; movable_type["last_owner_uid"] = &Movable::last_owner_uid; movable_type["current_animation"] = &Movable::current_animation; @@ -319,7 +333,6 @@ void register_usertypes(sol::state& lua) movable_type["exit_invincibility_timer"] = &Movable::exit_invincibility_timer; movable_type["invincibility_frames_timer"] = &Movable::invincibility_frames_timer; movable_type["frozen_timer"] = &Movable::frozen_timer; - movable_type["price"] = &Movable::price; movable_type["is_poisoned"] = &Movable::is_poisoned; movable_type["poison"] = &Movable::poison; movable_type["is_button_pressed"] = &Movable::is_button_pressed; @@ -327,12 +340,15 @@ void register_usertypes(sol::state& lua) movable_type["is_button_released"] = &Movable::is_button_released; movable_type["stun"] = &Movable::stun; - auto freeze = sol::overload(&Movable::freeze, [](Movable& ent, uint8_t frame_count) // for backward compatibility + auto freeze = sol::overload(&Movable::freeze, [](Movable& ent, uint8_t frame_count) // for backwards compatibility { ent.freeze(frame_count, false); }); + auto set_cursed = sol::overload(&Movable::set_cursed, [](Movable& ent, bool b) // for backwards compatibility + { ent.set_cursed(b, true); }); + movable_type["freeze"] = freeze; movable_type["light_on_fire"] = light_on_fire; - movable_type["set_cursed"] = &Movable::set_cursed_fix; + movable_type["set_cursed"] = set_cursed; movable_type["drop"] = &Movable::drop; movable_type["pick_up"] = &Movable::pick_up; movable_type["standing_on"] = &Movable::standing_on; @@ -342,6 +358,9 @@ void register_usertypes(sol::state& lua) movable_type["can_jump"] = &Movable::can_jump; movable_type["is_on_fire"] = &Movable::is_on_fire; movable_type["is_powerup_capable"] = &Movable::is_powerup_capable; + movable_type["can_be_picked_up_by"] = &Movable::can_be_picked_up_by; + movable_type["can_break_block"] = &Movable::can_break_block; + movable_type["break_block"] = &Movable::break_block; movable_type["damage"] = damage; movable_type["get_all_behaviors"] = &Movable::get_all_behaviors; movable_type["set_behavior"] = &Movable::set_behavior; @@ -350,6 +369,13 @@ void register_usertypes(sol::state& lua) movable_type["reset_gravity"] = &Movable::reset_gravity; movable_type["set_position"] = &Movable::set_position; movable_type["process_input"] = &Movable::process_input; + movable_type["calculate_jump_velocity"] = &Movable::calculate_jump_velocity; + movable_type["apply_velocity"] = &Movable::apply_velocity; + movable_type["get_damage"] = &Movable::get_damage; + movable_type["attack"] = &Movable::attack; + movable_type["thrown_into"] = &Movable::thrown_into; + movable_type["get_damage_sound"] = &Movable::get_damage_sound; + movable_type["copy_extra_info"] = &Movable::copy_extra_info; movable_type["cutscene"] = sol::readonly(&Movable::cutscene_behavior); movable_type["clear_cutscene"] = [](Movable& movable) -> void { diff --git a/src/game_api/script/usertypes/vtables_lua.cpp b/src/game_api/script/usertypes/vtables_lua.cpp index f83daa5ce..a775883ce 100644 --- a/src/game_api/script/usertypes/vtables_lua.cpp +++ b/src/game_api/script/usertypes/vtables_lua.cpp @@ -67,31 +67,42 @@ void register_usertypes(sol::state& lua) /// NoDoc VTableEntry<"stomp_damage", 43, MemFun<&Movable::get_damage>>, VTableEntry<"get_damage", 43, MemFun<&Movable::get_damage>>, - VTableEntry<"is_on_fire", 45, bool()>, - VTableEntry<"damage", 48, bool(Entity*, int8_t, uint16_t, Vec2*, uint8_t, uint16_t, uint8_t, bool)>, - VTableEntry<"on_hit", 49, void(Entity*)>, - VTableEntry<"get_damage_sound", 50, uint32_t(DAMAGE_TYPE)>, - VTableEntry<"stun", 51, void(uint16_t)>, - VTableEntry<"freeze", 52, void(uint8_t)>, - VTableEntry<"light_on_fire", 53, void(uint8_t)>, - VTableEntry<"set_cursed", 54, void(bool)>, - VTableEntry<"web_collision", 55, void()>, - VTableEntry<"check_out_of_bounds", 58, void()>, - VTableEntry<"set_standing_on", 59, void(int32_t)>, - VTableEntry<"standing_on", 60, Entity*()>, - VTableEntry<"stomped_by", 61, void(Entity*)>, - VTableEntry<"thrown_by", 62, void(Entity*)>, - VTableEntry<"cloned_to", 63, void(Entity*)>, - VTableEntry<"pick_up", 67, void(Entity*)>, - VTableEntry<"picked_up_by", 68, void(Entity*)>, - VTableEntry<"drop", 69, void(Entity*)>, - VTableEntry<"collect_treasure", 70, void(int32_t, uint32_t)>, - VTableEntry<"initialize", 75, void()>, - VTableEntry<"process_input", 78, void()>, - VTableEntry<"picked_up", 80, void()>, - VTableEntry<"fall", 83, void()>, - VTableEntry<"apply_friction", 84, void()>, - VTableEntry<"crush", 90, void(Entity*)>>; + VTableEntry<"is_on_fire", 45, MemFun<&Movable::is_on_fire>>, + VTableEntry<"attack", 46, MemFun<&Movable::attack>>, + VTableEntry<"thrown_into", 47, MemFun<&Movable::thrown_into>>, + VTableEntry<"damage", 48, MemFun<&Movable::damage>>, + VTableEntry<"on_hit", 49, MemFun<&Movable::on_hit>>, + VTableEntry<"get_damage_sound", 50, MemFun<&Movable::get_damage_sound>>, + VTableEntry<"stun", 51, MemFun<&Movable::stun>>, + VTableEntry<"freeze", 52, MemFun<&Movable::freeze>>, + VTableEntry<"light_on_fire", 53, MemFun<&Movable::light_on_fire>>, + VTableEntry<"set_cursed", 54, MemFun<&Movable::set_cursed>>, + VTableEntry<"web_collision", 55, MemFun<&Movable::on_spiderweb_collision>>, + VTableEntry<"check_out_of_bounds", 58, MemFun<&Movable::check_out_of_bounds>>, + VTableEntry<"set_standing_on", 59, MemFun<&Movable::set_standing_on>>, + VTableEntry<"standing_on", 60, MemFun<&Movable::standing_on>>, + VTableEntry<"stomped_by", 61, MemFun<&Movable::on_stomped_on_by>>, + VTableEntry<"thrown_by", 62, MemFun<&Movable::on_thrown_by>>, + VTableEntry<"cloned_to", 63, MemFun<&Movable::copy_extra_info>>, + VTableEntry<"pick_up", 67, MemFun<&Movable::pick_up>>, + /// NoDoc + VTableEntry<"picked_up_by", 68, MemFun<&Movable::can_be_picked_up_by>>, + VTableEntry<"can_be_picked_up_by", 68, MemFun<&Movable::can_be_picked_up_by>>, + VTableEntry<"drop", 69, MemFun<&Movable::drop>>, + VTableEntry<"collect_treasure", 70, MemFun<&Movable::collect_treasure>>, + VTableEntry<"apply_movement", 71, MemFun<&Movable::apply_movement>>, + VTableEntry<"is_powerup_capable", 74, MemFun<&Movable::is_powerup_capable>>, + VTableEntry<"initialize", 75, MemFun<&Movable::initialize>>, + VTableEntry<"process_input", 78, MemFun<&Movable::process_input>>, + VTableEntry<"picked_up", 80, MemFun<&Movable::on_picked_up>>, + VTableEntry<"release", 81, MemFun<&Movable::on_release>>, + VTableEntry<"generate_fall_poof_particles", 82, MemFun<&Movable::generate_fall_poof_particles>>, + VTableEntry<"fall", 83, MemFun<&Movable::handle_fall_logic>>, + VTableEntry<"apply_friction", 84, MemFun<&Movable::apply_friction>>, + VTableEntry<"can_break_block", 85, MemFun<&Movable::can_break_block>>, + VTableEntry<"break_block", 86, MemFun<&Movable::break_block>>, + VTableEntry<"crush", 90, MemFun<&Movable::on_crushed_by>>, + VTableEntry<"instakill_death", 92, MemFun<&Movable::on_instakill_death>>>; static MovableVTable movable_vtable(lua, lua["Movable"], "ENTITY_OVERRIDE"); using FloorVTable = HookableVTable<