Here is the armor code:
Code: Select all
class EnergyShield : BasicArmorPickup
{
Default
{
// PROPERTY
DamageFactor "LCaliber", 0.0; //Immune
DamageFactor "MCaliber", 0.0; //Immune
DamageFactor "HCaliber", 0.0; //Immune
DamageFactor "Explosive", 0.0; //Immune
DamageFactor "KExplosive", 0.0; //Immune
DamageFactor "Fire", 0.0; //Immune
DamageFactor "Laser", 1.0; //Vulnerable
Armor.SaveAmount 300; //300
Armor.SavePercent 100;
}
States
{
Spawn:
TNT1 A 1;
Loop;
}
override bool Use(bool pickup)
{
bool result = Super.Use(pickup);
// If pickup has succeeded, give the FX item too.
if (result)
{
Owner.GiveInventory('EnergyShieldFX', 1);
}
return result;
}
}
class EnergyShieldFX : Inventory
{
Default
{
// Prevent sudden removal of the item.
+INVENTORY.UNCLEARABLE;
}
override void AbsorbDamage(int damage, Name damageType, out int newdamage, Actor inflictor, Actor source, int flags)
{
// If the enemy is wearing the armor, play the special sound.
if (OwnerHasEnergyShield())
{
Owner.A_StartSound("Armor/Energy_Shield", CHAN_BODY);
}
}
override void Tick()
{
Super.Tick();
// If the enemy doesn't have the armor anymore, destroy the FX item.
If (!OwnerHasEnergyShield())
{
Destroy();
}
}
private bool OwnerHasEnergyShield()
{
// Check that the player still has the corresponding armor type
// and the amount is non-zero.
if (Owner != null)
{
let ba = BasicArmor(Owner.FindInventory('BasicArmor'));
if (ba != null)
{
return ba.Amount > 0 && ba.ArmorType == 'EnergyShield';
}
}
return false;
}
}
Code: Select all
CODE CODE CODE CODE CODE
CODE CODE CODE CODE CODE...
override void PostBeginPlay()
{
super.PostBeginPlay();
// Began already with armor whitout waiting for his first frame.
GiveInventory("EnergyShield", 1);
}
Override void Tick()
{
Super.Tick(); //Call original in case of another override
{
//Heal every fifteen tics
If (Level.Time%15 == 0 && FindInventory("EnergyShieldFX") && Health > 0)
{
GiveInventory("BasicArmorBonus", 5);
}
}
}
CODE CODE CODE CODE CODE
CODE CODE CODE CODE CODE...