swwmgz_m/zscript/swwm_player_items.zsc

132 lines
3.4 KiB
Text

// player-specific item stuff
// tokens for custom maps
Class SWWMStoreDisabler : Inventory
{
Default
{
+INVENTORY.UNCLEARABLE;
+INVENTORY.UNDROPPABLE;
+INVENTORY.UNTOSSABLE;
}
}
Class SWWMReviveDisabler : Inventory
{
Default
{
+INVENTORY.UNCLEARABLE;
+INVENTORY.UNDROPPABLE;
+INVENTORY.UNTOSSABLE;
}
}
// lucky collar
// made by Ashley Knox, given to you and Ibuki by Saya
Class SayaCollar : SWWMArmor
{
Default
{
Inventory.Amount 1;
Inventory.MaxAmount 1;
Inventory.InterHubAmount 1;
SWWMArmor.ArmorPriority 1;
+INVENTORY.UNCLEARABLE;
// SWWMArmor flags are not needed as this overrides AbsorbDamage directly
}
override void AbsorbDamage( int damage, Name damageType, out int newdamage, Actor inflictor, Actor source, int flags )
{
if ( (damage <= 0) || (flags&(DMG_FORCED|DMG_NO_ARMOR)) ) return;
newdamage = damage;
// oopsies are halved
if ( source == Owner ) newdamage = max(1,newdamage/2);
// in danger? reduce to a quarter
if ( (Owner.Health-newdamage < 25) )
{
int splitdmg[2];
splitdmg[0] = max(0,Owner.Health-25); // non-reduced part (>=25% health)
splitdmg[1] = max(1,(newdamage-splitdmg[0])/4); // reduced part (<25% health)
newdamage = splitdmg[0]+splitdmg[1];
}
}
// for friendly fire handling, jammed into here
override void ModifyDamage( int damage, Name damageType, out int newdamage, bool passive, Actor inflictor, Actor source, int flags )
{
int ff = swwm_friendlyfire;
if ( !source || (source == Owner) || (source.player == Owner.player) || !source.IsFriend(Owner) || !ff ) return;
// 1: block incoming friendly damage
// 2: also block outgoing friendly damage
if ( (passive && ff) || (!passive && (ff == 2)) )
newdamage = 0;
}
}
// high-resonant almasteel plating
// EXTRA THICC as Saya requested
Class AlmasteelPlating : SWWMArmor
{
Default
{
Inventory.Amount 1;
Inventory.MaxAmount 1;
Inventory.InterHubAmount 1;
Inventory.RestrictedTo "Demolitionist";
SWWMArmor.ArmorPriority 2;
+INVENTORY.UNCLEARABLE;
+SWWMARMOR.NOHITFLASH;
+SWWMARMOR.NOHITSOUND;
+SWWMARMOR.NODRAIN;
}
override int HandleDamage( int damage, Name damageType, int flags )
{
// 80% reduction for explosions
double factor = (flags&DMG_EXPLOSION)?.2:1.;
// 50% reduction for crushing
if ( damageType == 'Crush' ) factor /= 2.;
return damage-int(damage*factor);
}
override bool HandlePickup( Inventory item )
{
// disallow vanilla armors
if ( (item is 'BasicArmor') || (item is 'BasicArmorBonus') || (item is 'BasicArmorPickup') || (item is 'HexenArmor') )
{
item.bPickupGood = true; // but act as if we picked them up
return true;
}
return false;
}
}
Class ReviveCooldown : Powerup
{
Default
{
Inventory.Icon "graphics/HUD/Icons/I_Revive.png";
Powerup.Duration -60;
}
override void Tick()
{
if ( !Owner ) Destroy();
if ( Owner.Health <= 0 ) return; // timer does not go down when dead
if ( (EffectTics == 0) || ((EffectTics > 0) && (--EffectTics == 0)) )
Destroy ();
}
override void InitEffect()
{
Super.InitEffect();
// adjust the duration
EffectTics = max(0,swwm_revivecooldown)*GameTicRate;
}
override void EndEffect()
{
Super.EndEffect();
if ( !Owner ) return;
Owner.A_StartSound("demolitionist/revive",CHAN_ITEMEXTRA);
if ( (EffectTics <= 0) && Owner && Owner.CheckLocalView() ) Console.Printf(StringTable.Localize("$D_REFAIL"));
}
override void OwnerDied()
{
// do nothing, this "powerup" is preserved on death
}
}