Skip to content

Lua: new hooks and some additions

JugadorXEI requested to merge JugadorXEI/Kart-Public:lua-hooks-jug into next

Additions:

  • "KartHyudoro", prototype function(player_t player, player_t target [may be nil], boolean sink). return values int (player ID), boolean (force sink).
    • Allows coders to change Hyudoro's stealing and sink behaviours.
    • Usage examples: return -1 to prevent stealing. return -1, true to force a sink. return #target to steal from target.
  • "KartStealBumper", prototype function(player_t player, player_t target, boolean force). return values boolean (override behavior), boolean (set force).
    • Allows coders to change K_StealBumper's behaviour in Battle, namely how bumper stealing should behave by Sneakers, Karma Bombs and the like.
    • Usage examples: return true to prevent stealing. return false, true to force bumpers to be stolen despite of player's bumper count being zero.
  • "KartSneaker", prototype function(player_t player, int type), return value boolean (override behavior).
    • Allows coders to change K_DoSneaker's behaviour. Can be used to prevent certain types of Sneaker usage, or be used as a way to make Sneakers stronger, weaker, etc., without the need of elaborate hacks.
    • Usage example: return true to prevent Sneaker usage.
  • "PlayerItemUse", prototype function(player_t player, kartitems_t itemType, boolean wasHoldingItem), return values boolean (override behaviour), boolean (force item use).
    • Allows coders to know which item was used by which player, and if it's being dragged/orbited vs. being thrown or used (through checking wasHoldingItem). Also allows coders to override item behavior.
    • Usage examples: return false, true to allow items such as Springs to be used in mid-air.
  • "MobjScaleChange", prototype function(mobj_t mobj, fixed_t newscale, fixed_t oldscale), return value boolean (override behavior)
    • Allows coders to override P_SetScale by letting them stop scaling effects or do things according to scaling differences. This hook acts on a per-frame basis and fires every frame mobj's size changes.

Changes:

  • "MobjCollide" and "MobjMoveCollide" now include fixed_t desx, fixed_t desy, thus their prototypes now are function(thing, tmthing, desx, desy).
    • This was done because the results of collision calculations does not always reflect the mobj's current position + momentum. This allows for better handling of collisions without having the coder doing the blunt of calculations themself.

Build: srb2kart_morehooksjug.exe (32-bit)

Lua example: newhookstest.lua (remove the comment in the Mobj(Move)Collide hooks to see the prints).

Let me know if anything could be changed.

Edited by JugadorXEI

Merge request reports