Skip to content

Draft: Shield Refactor

Todo:

  • Fix fireflower not going away after being damaged. (FIXED)
  • lib_pRemoveShield needs to be deprecated.
  • Create an automatic compatibility layer for player.powers[pw_shield] in lua.
  • Make player->shield accessible
  • Remake fireflower detection, I realized that the fireflower cant be the only one accessible through SH_STACK
  • ShieldThink Hook.
  • expose more shield constants to lua.
  • Shield freeslots! SHIELD_...

Additions

  • Old shieldtype_t has renamed to legacyshieldtype_t and has been replaced with a brand new enum.
  • New Lua function P_KillShield.
  • player->shield [shieldtype_t] (C side only at the moment)
  • player->shieldorb [mobj_t] (Both C and Lua)
  • SHIELD_NONE exposed to lua
typedef enum 
{
	// Vanilla Shields
	SHIELD_NONE = 0,
	SHIELD_PITY,
	SHIELD_WHIRLWIND,
	SHIELD_ARMAGEDDON,
	SHIELD_PINK,
	SHIELD_ATTRACT,
	SHIELD_ELEMENTAL,
	SHIELD_FORCE,
    
	// Sonic 3 Shields
	SHIELD_FLAME, // SH_FLAMEAURA equivalent
	SHIELD_BUBBLE, // SH_BUBBLEWRAP equivalent
	SHIELD_LIGHTNING // SH_THUNDERCOIN equivalent
} shieldtype_t;

typedef enum
{
	SP_FIRE = 1<<0,
	SP_WATER = 1<<1,
	SP_ELECTRIC = 1<<2,
	SP_SPIKE = 1<<3,
} shieldprotection_t;

typedef struct
{
	shieldtype_t type;       // what shield it is SHIELD_...   (512 max shields for compatibility, can increase in 2.3 if player.powers[pw_shield] gets removed
	UINT8        hp;         // how many hits a shield has (used by force shield)
	UINT16       protection; // flags, similar to SH_PROTECTFIRE SH_PROTECTWATER SH_PROTECTELECTRIC SH_PROTECTSPIKE
	boolean      fireflower; // hardcoded fireflower stuff idk suggest something better
} shield_t;

typedef struct player_s
{
    // … existing fields …
    shield_t    shield;        // replaces powers[pw_shield]
    mobj_t      *shieldorb; // pointer to the active shield mobj (NULL if none)
    // …
} player_t;
Edited by Jisk

Merge request reports

Loading