Flaregun: Working in game with new ammo type and placeholder custom assets. WIP flare collision behavior

This commit is contained in:
1upD 2018-11-07 22:54:48 -05:00
parent d9b256fe8f
commit 83dfddfb13
7 changed files with 1622 additions and 39 deletions

View File

@ -0,0 +1,11 @@
//=============================================================================
//
// Purpose: Half-Life 2 mod game definition file (.fgd)
// Defines new entities for the flaregun weapon
//
//=============================================================================
@include "halflife2.fgd"
@PointClass base(Item) studio("models/items/boxflares.mdl")= item_box_flare_rounds : "Box of Flare Rounds" []
@PointClass base(Weapon) studio("models/weapons/w_pistol.mdl") = weapon_flaregun : "Flaregun" []

File diff suppressed because it is too large Load Diff

View File

@ -3,9 +3,9 @@
WeaponData
{
// Weapon data is loaded by both the Game and Client DLLs.
"printname" "#HL2_Pistol"
"viewmodel" "models/weapons/v_pistol.mdl"
"playermodel" "models/weapons/w_pistol.mdl"
"printname" "#HL2_Flaregun"
"viewmodel" "models/weapons/v_flaregun.mdl"
"playermodel" "models/weapons/w_flaregun.mdl"
"anim_prefix" "pistol"
"bucket" "1"
"bucket_position" "2"
@ -13,7 +13,7 @@ WeaponData
"bucket_position_360" "0"
"clip_size" "1"
"primary_ammo" "Pistol"
"primary_ammo" "FlareRound"
"secondary_ammo" "None"
"weight" "2"
@ -24,14 +24,14 @@ WeaponData
SoundData
{
"reload" "Weapon_Pistol.Reload"
"reload_npc" "Weapon_Pistol.NPC_Reload"
"empty" "Weapon_Pistol.Empty"
"single_shot" "Weapon_Pistol.Single"
"single_shot_npc" "Weapon_Pistol.NPC_Single"
"special1" "Weapon_Pistol.Special1"
"special2" "Weapon_Pistol.Special2"
"burst" "Weapon_Pistol.Burst"
"reload" "Weapon_FlareGun.Reload"
"reload_npc" "Weapon_FlareGun.Reload"
"empty" "Weapon_Pistol.Empty"
"single_shot" "Weapon_FlareGun.Single"
"single_shot_npc" "Weapon_FlareGun.Single"
"special1" "Weapon_Pistol.Special1"
"special2" "Weapon_Pistol.Special2"
"burst" "Weapon_Pistol.Burst"
}
// Weapon Sprite data is loaded by the Client DLL.

View File

@ -606,6 +606,7 @@ enum
AMMOCRATE_CROSSBOW,
AMMOCRATE_AR2_ALTFIRE,
AMMOCRATE_SMG_ALTFIRE,
AMMOCRATE_FLAREROUND,
NUM_AMMO_CRATE_TYPES,
};
@ -693,6 +694,7 @@ const char *CItem_AmmoCrate::m_lpzModelNames[NUM_AMMO_CRATE_TYPES] =
//FIXME: This model is incorrect!
"models/items/ammocrate_ar2.mdl", // Combine Ball
"models/items/ammocrate_smg2.mdl", // smg grenade
"models/items/ammocrate_pistol.mdl", // Flareround
};
// Ammo type names
@ -708,6 +710,7 @@ const char *CItem_AmmoCrate::m_lpzAmmoNames[NUM_AMMO_CRATE_TYPES] =
"XBowBolt",
"AR2AltFire",
"SMG1_Grenade",
"FlareRound",
};
// Ammo amount given per +use
@ -723,6 +726,7 @@ int CItem_AmmoCrate::m_nAmmoAmounts[NUM_AMMO_CRATE_TYPES] =
50, // Crossbow
3, // AR2 alt-fire
5,
3
};
const char *CItem_AmmoCrate::m_pGiveWeapon[NUM_AMMO_CRATE_TYPES] =
@ -737,6 +741,7 @@ const char *CItem_AmmoCrate::m_pGiveWeapon[NUM_AMMO_CRATE_TYPES] =
NULL, // Crossbow
NULL, // AR2 alt-fire
NULL, // SMG alt-fire
NULL
};
#define AMMO_CRATE_CLOSE_DELAY 1.5f

View File

@ -26,7 +26,17 @@ class CFlareGunProjectile : public CFlare
public:
DECLARE_CLASS(CFlareGunProjectile, CFlare);
static CFlareGunProjectile *Create(Vector vecOrigin, QAngle vecAngles, CBaseEntity *pOwner, float lifetime);
void FlareGunProjectileTouch(CBaseEntity *pOther);
void IgniteOtherIfAllowed(CBaseEntity *pOther);
void FlareGunProjectileTouch(CBaseEntity *pOther);
void FlareGunProjectileBurnTouch(CBaseEntity *pOther);
};
class CFlaregunCustom : public CFlaregun
{
public:
DECLARE_CLASS(CFlaregunCustom, CFlaregun);
virtual bool Reload(void);
};
@ -55,7 +65,7 @@ public:
IMPLEMENT_SERVERCLASS_ST(CFlaregun, DT_Flaregun)
END_SEND_TABLE()
LINK_ENTITY_TO_CLASS( weapon_flaregun, CFlaregun );
LINK_ENTITY_TO_CLASS( weapon_flaregun, CFlaregunCustom);
PRECACHE_WEAPON_REGISTER( weapon_flaregun );
//-----------------------------------------------------------------------------
@ -149,6 +159,18 @@ void CFlaregun::SecondaryAttack( void )
WeaponSound( SINGLE );
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
bool CFlaregunCustom::Reload(void)
{
bool fRet = DefaultReload(GetMaxClip1(), GetMaxClip2(), ACT_VM_RELOAD);
if (fRet)
{
WeaponSound(RELOAD);
}
return fRet;
}
//-----------------------------------------------------------------------------
// Purpose: Create function for Flare Gun projectile
// Input : vecOrigin -
@ -179,6 +201,10 @@ CFlareGunProjectile *CFlareGunProjectile::Create(Vector vecOrigin, QAngle vecAng
//Burn out time
pFlare->m_flTimeBurnOut = gpGlobals->curtime + lifetime;
// Time to next burn damage
pFlare->m_flNextDamage = gpGlobals->curtime;
pFlare->RemoveSolidFlags(FSOLID_NOT_SOLID);
pFlare->AddSolidFlags(FSOLID_NOT_STANDABLE);
@ -212,29 +238,11 @@ void CFlareGunProjectile::FlareGunProjectileTouch(CBaseEntity *pOther)
Vector vecNewVelocity = GetAbsVelocity();
vecNewVelocity *= 0.1f;
SetAbsVelocity(vecNewVelocity);
SetMoveType(MOVETYPE_FLYGRAVITY, MOVECOLLIDE_FLY_BOUNCE);
SetGravity(1.0f);
Die(0.5);
// Don't burn the player
if (pOther->IsPlayer())
return;
// Don't burn friendly NPCs
CAI_BaseNPC *pNPC;
pNPC = dynamic_cast<CAI_BaseNPC*>(pOther);
if (pNPC && pNPC->IsPlayerAlly())
return;
// If this is an ignitable entity that isn't the player or an ally, ignite it!
CBaseAnimating *pAnim;
pAnim = dynamic_cast<CBaseAnimating*>(pOther);
if (pAnim)
pAnim->IgniteLifetime(30.0f);
IgniteOtherIfAllowed(pOther);
m_nBounces++;
return;
}
else
@ -267,7 +275,7 @@ void CFlareGunProjectile::FlareGunProjectileTouch(CBaseEntity *pOther)
SetAbsVelocity(vec3_origin);
SetMoveType(MOVETYPE_NONE);
SetTouch(&CFlare::FlareBurnTouch);
SetTouch(&CFlareGunProjectile::FlareGunProjectileBurnTouch);
int index = decalsystem->GetDecalIndexForName("SmallScorch");
if (index >= 0)
@ -318,6 +326,40 @@ void CFlareGunProjectile::FlareGunProjectileTouch(CBaseEntity *pOther)
SetMoveType(MOVETYPE_NONE);
RemoveSolidFlags(FSOLID_NOT_SOLID);
AddSolidFlags(FSOLID_TRIGGER);
SetTouch(&CFlareGunProjectile::FlareGunProjectileBurnTouch);
}
}
}
//-----------------------------------------------------------------------------
// Purpose:
// Input : *pOther -
//-----------------------------------------------------------------------------
void CFlareGunProjectile::FlareGunProjectileBurnTouch(CBaseEntity *pOther)
{
if (pOther && pOther->m_takedamage && (m_flNextDamage < gpGlobals->curtime))
{
IgniteOtherIfAllowed(pOther);
pOther->TakeDamage(CTakeDamageInfo(this, m_pOwner, 1, (DMG_BULLET | DMG_BURN)));
m_flNextDamage = gpGlobals->curtime + 1.0f;
}
}
void CFlareGunProjectile::IgniteOtherIfAllowed(CBaseEntity * pOther)
{
// Don't burn the player
if (pOther->IsPlayer())
return;
// Don't burn friendly NPCs
CAI_BaseNPC *pNPC;
pNPC = dynamic_cast<CAI_BaseNPC*>(pOther);
if (pNPC && pNPC->IsPlayerAlly())
return;
// If this is an ignitable entity that isn't the player or an ally, ignite it!
CBaseAnimating *pAnim;
pAnim = dynamic_cast<CBaseAnimating*>(pOther);
if (pAnim)
pAnim->IgniteLifetime(30.0f);
}

View File

@ -119,10 +119,9 @@ ConVar sk_plr_dmg_smg1 ( "sk_plr_dmg_smg1","0", FCVAR_REPLICATED );
ConVar sk_npc_dmg_smg1 ( "sk_npc_dmg_smg1","0", FCVAR_REPLICATED);
ConVar sk_max_smg1 ( "sk_max_smg1","0", FCVAR_REPLICATED);
// FIXME: remove these
//ConVar sk_plr_dmg_flare_round ( "sk_plr_dmg_flare_round","0", FCVAR_REPLICATED);
//ConVar sk_npc_dmg_flare_round ( "sk_npc_dmg_flare_round","0", FCVAR_REPLICATED);
//ConVar sk_max_flare_round ( "sk_max_flare_round","0", FCVAR_REPLICATED);
ConVar sk_plr_dmg_flare_round ( "sk_plr_dmg_flare_round","0", FCVAR_REPLICATED);
ConVar sk_npc_dmg_flare_round ( "sk_npc_dmg_flare_round","0", FCVAR_REPLICATED);
ConVar sk_max_flare_round ( "sk_max_flare_round","15", FCVAR_REPLICATED);
ConVar sk_plr_dmg_buckshot ( "sk_plr_dmg_buckshot","0", FCVAR_REPLICATED);
ConVar sk_npc_dmg_buckshot ( "sk_npc_dmg_buckshot","0", FCVAR_REPLICATED);
@ -1819,6 +1818,9 @@ CAmmoDef *GetAmmoDef()
def.AddAmmoType("CombineCannon", DMG_BULLET, TRACER_LINE, "sk_npc_dmg_gunship_to_plr", "sk_npc_dmg_gunship", NULL, 1.5 * 750 * 12, 0 ); // hit like a 1.5kg weight at 750 ft/s
def.AddAmmoType("AirboatGun", DMG_AIRBOAT, TRACER_LINE, "sk_plr_dmg_airboat", "sk_npc_dmg_airboat", NULL, BULLET_IMPULSE(10, 600), 0 );
// Custom
def.AddAmmoType("FlareRound", DMG_BURN, TRACER_NONE, "sk_plr_dmg_flare_round", "sk_npc_dmg_flare_round", "sk_max_flare_round", 0, 0);
//=====================================================================
// STRIDER MINIGUN DAMAGE - Pull up a chair and I'll tell you a tale.
//