|
|
@ -25,335 +25,301 @@ |
|
|
|
#include "gamerules.h" |
|
|
|
#include "gamerules.h" |
|
|
|
#include "decals.h" |
|
|
|
#include "decals.h" |
|
|
|
#include "sporegrenade.h" |
|
|
|
#include "sporegrenade.h" |
|
|
|
#include "gearbox_weapons.h" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LINK_ENTITY_TO_CLASS(spore, CSporeGrenade) |
|
|
|
LINK_ENTITY_TO_CLASS(spore, CSpore) |
|
|
|
|
|
|
|
|
|
|
|
TYPEDESCRIPTION CSporeGrenade::m_SaveData[] = |
|
|
|
TYPEDESCRIPTION CSpore::m_SaveData[] = |
|
|
|
{ |
|
|
|
{ |
|
|
|
DEFINE_FIELD(CSporeGrenade, m_pSporeGlow, FIELD_CLASSPTR), |
|
|
|
DEFINE_FIELD(CSpore, m_SporeType, FIELD_INTEGER), |
|
|
|
|
|
|
|
DEFINE_FIELD(CSpore, m_flIgniteTime, FIELD_TIME), |
|
|
|
|
|
|
|
DEFINE_FIELD(CSpore, m_bIsAI, FIELD_BOOLEAN), |
|
|
|
|
|
|
|
DEFINE_FIELD(CSpore, m_hSprite, FIELD_EHANDLE) |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
IMPLEMENT_SAVERESTORE(CSporeGrenade, CBaseMonster) |
|
|
|
IMPLEMENT_SAVERESTORE(CSpore, CGrenade) |
|
|
|
|
|
|
|
|
|
|
|
int gSporeExplode, gSporeExplodeC; |
|
|
|
int gSporeExplode, gSporeExplodeC; |
|
|
|
|
|
|
|
|
|
|
|
void CSporeGrenade::Precache(void) |
|
|
|
void CSpore::Precache(void) |
|
|
|
{ |
|
|
|
{ |
|
|
|
PRECACHE_MODEL("models/spore.mdl"); |
|
|
|
PRECACHE_MODEL("models/spore.mdl"); |
|
|
|
PRECACHE_MODEL("sprites/glow02.spr"); |
|
|
|
PRECACHE_MODEL("sprites/glow01.spr"); |
|
|
|
g_sModelIndexTinySpit = PRECACHE_MODEL("sprites/tinyspit.spr"); |
|
|
|
|
|
|
|
gSporeExplode = PRECACHE_MODEL ("sprites/spore_exp_01.spr"); |
|
|
|
m_iBlow = PRECACHE_MODEL("sprites/spore_exp_01.spr"); |
|
|
|
gSporeExplodeC = PRECACHE_MODEL ("sprites/spore_exp_c_01.spr"); |
|
|
|
m_iBlowSmall = PRECACHE_MODEL("sprites/spore_exp_c_01.spr"); |
|
|
|
|
|
|
|
m_iSpitSprite = m_iTrail = PRECACHE_MODEL("sprites/tinyspit.spr"); |
|
|
|
|
|
|
|
|
|
|
|
PRECACHE_SOUND("weapons/splauncher_bounce.wav"); |
|
|
|
PRECACHE_SOUND("weapons/splauncher_bounce.wav"); |
|
|
|
PRECACHE_SOUND("weapons/splauncher_impact.wav"); |
|
|
|
PRECACHE_SOUND("weapons/splauncher_impact.wav"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void CSporeGrenade::Explode(TraceResult *pTrace) |
|
|
|
void CSpore::Spawn() |
|
|
|
{ |
|
|
|
{ |
|
|
|
pev->solid = SOLID_NOT;// intangible
|
|
|
|
Precache(); |
|
|
|
pev->takedamage = DAMAGE_NO; |
|
|
|
|
|
|
|
|
|
|
|
if (m_SporeType == GRENADE) |
|
|
|
|
|
|
|
pev->movetype = MOVETYPE_BOUNCE; |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
pev->movetype = MOVETYPE_FLY; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pev->solid = SOLID_BBOX; |
|
|
|
|
|
|
|
|
|
|
|
// Pull out of the wall a bit
|
|
|
|
SET_MODEL(edict(), "models/spore.mdl"); |
|
|
|
if (pTrace->flFraction != 1.0) |
|
|
|
|
|
|
|
|
|
|
|
UTIL_SetSize(pev, g_vecZero, g_vecZero); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UTIL_SetOrigin(pev, pev->origin); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SetThink(&CSpore::FlyThink); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (m_SporeType == GRENADE) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
SetTouch(&CSpore::MyBounceTouch); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!m_bPuked) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
pev->angles.x -= RANDOM_LONG(-5, 5) + 30; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
pev->origin = pTrace->vecEndPos + (pTrace->vecPlaneNormal * (pev->dmg - 24) * 0.6); |
|
|
|
SetTouch(&CSpore::RocketTouch); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Vector vecSpraySpot = pTrace->vecEndPos; |
|
|
|
UTIL_MakeVectors(pev->angles); |
|
|
|
float flSpraySpeed = RANDOM_LONG(10, 15); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// If the trace is pointing up, then place
|
|
|
|
if (!m_bIsAI) |
|
|
|
// spawn position a few units higher.
|
|
|
|
{ |
|
|
|
if (pTrace->vecPlaneNormal.z > 0) |
|
|
|
if (m_SporeType != GRENADE) |
|
|
|
{ |
|
|
|
{ |
|
|
|
vecSpraySpot = vecSpraySpot + (pTrace->vecPlaneNormal * 8); |
|
|
|
pev->velocity = gpGlobals->v_forward * 1200; |
|
|
|
flSpraySpeed *= 2; // Double the speed to make them fly higher
|
|
|
|
|
|
|
|
// in the air.
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Spawn small particles at the explosion origin.
|
|
|
|
pev->gravity = 1; |
|
|
|
SpawnExplosionParticles( |
|
|
|
} |
|
|
|
vecSpraySpot, // position
|
|
|
|
|
|
|
|
pTrace->vecPlaneNormal, // direction
|
|
|
|
|
|
|
|
g_sModelIndexTinySpit, // modelindex
|
|
|
|
|
|
|
|
RANDOM_LONG(40, 50), // count
|
|
|
|
|
|
|
|
flSpraySpeed, // speed
|
|
|
|
|
|
|
|
RANDOM_FLOAT(600, 640)); // noise
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MESSAGE_BEGIN( MSG_PAS, SVC_TEMPENTITY, pev->origin ); |
|
|
|
|
|
|
|
WRITE_BYTE( TE_SPRITE ); |
|
|
|
|
|
|
|
WRITE_COORD( pev->origin.x ); |
|
|
|
|
|
|
|
WRITE_COORD( pev->origin.y ); |
|
|
|
|
|
|
|
WRITE_COORD( pev->origin.z ); |
|
|
|
|
|
|
|
WRITE_SHORT( RANDOM_LONG( 0, 1 ) ? gSporeExplode : gSporeExplodeC ); |
|
|
|
|
|
|
|
WRITE_BYTE( 25 ); // scale * 10
|
|
|
|
|
|
|
|
WRITE_BYTE( 155 ); // framerate
|
|
|
|
|
|
|
|
MESSAGE_END(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, pev->origin ); |
|
|
|
|
|
|
|
WRITE_BYTE(TE_DLIGHT); |
|
|
|
|
|
|
|
WRITE_COORD( pev->origin.x ); // X
|
|
|
|
|
|
|
|
WRITE_COORD( pev->origin.y ); // Y
|
|
|
|
|
|
|
|
WRITE_COORD( pev->origin.z ); // Z
|
|
|
|
|
|
|
|
WRITE_BYTE( 12 ); // radius * 0.1
|
|
|
|
|
|
|
|
WRITE_BYTE( 0 ); // r
|
|
|
|
|
|
|
|
WRITE_BYTE( 180 ); // g
|
|
|
|
|
|
|
|
WRITE_BYTE( 0 ); // b
|
|
|
|
|
|
|
|
WRITE_BYTE( 20 ); // time * 10
|
|
|
|
|
|
|
|
WRITE_BYTE( 20 ); // decay * 0.1
|
|
|
|
|
|
|
|
MESSAGE_END( ); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Play explode sound.
|
|
|
|
|
|
|
|
EMIT_SOUND(ENT(pev), CHAN_VOICE, "weapons/splauncher_impact.wav", 1, ATTN_NORM); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CSoundEnt::InsertSound(bits_SOUND_COMBAT, pev->origin, NORMAL_EXPLOSION_VOLUME, 3.0); |
|
|
|
|
|
|
|
entvars_t *pevOwner; |
|
|
|
|
|
|
|
if (pev->owner) |
|
|
|
|
|
|
|
pevOwner = VARS(pev->owner); |
|
|
|
|
|
|
|
else |
|
|
|
else |
|
|
|
pevOwner = NULL; |
|
|
|
{ |
|
|
|
|
|
|
|
pev->gravity = 0.5; |
|
|
|
|
|
|
|
pev->friction = 0.7; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
pev->owner = NULL; // can't traceline attack owner if this is set
|
|
|
|
pev->dmg = gSkillData.plrDmgSpore; |
|
|
|
|
|
|
|
|
|
|
|
RadiusDamage(pev, pevOwner, pev->dmg, CLASS_NONE, DMG_BLAST); |
|
|
|
m_flIgniteTime = gpGlobals->time; |
|
|
|
|
|
|
|
|
|
|
|
// Place a decal on the surface that was hit.
|
|
|
|
pev->nextthink = gpGlobals->time + 0.01; |
|
|
|
UTIL_DecalTrace(pTrace, DECAL_SPR_SPLT1 + RANDOM_LONG(0, 2)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UTIL_Remove(this); |
|
|
|
CSprite* sprite = CSprite::SpriteCreate("sprites/glow01.spr", pev->origin, false); |
|
|
|
} |
|
|
|
if (sprite) { |
|
|
|
|
|
|
|
sprite->SetTransparency(kRenderTransAdd, 180, 180, 40, 100, kRenderFxDistort); |
|
|
|
|
|
|
|
sprite->SetScale(0.8); |
|
|
|
|
|
|
|
sprite->SetAttachment(edict(), 0); |
|
|
|
|
|
|
|
m_hSprite = sprite; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void CSporeGrenade::Detonate(void) |
|
|
|
m_fRegisteredSound = false; |
|
|
|
{ |
|
|
|
|
|
|
|
TraceResult tr; |
|
|
|
|
|
|
|
Vector vecSpot = pev->origin + Vector(0, 0, 8); |
|
|
|
|
|
|
|
UTIL_TraceLine(vecSpot, vecSpot + Vector(0, 0, -40), ignore_monsters, ENT(pev), &tr); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Explode(&tr); |
|
|
|
m_flSoundDelay = gpGlobals->time; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void CSpore::BounceSound() |
|
|
|
void CSporeGrenade::BounceSound(void) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
DangerSound(); |
|
|
|
//Nothing
|
|
|
|
EMIT_SOUND(ENT(pev), CHAN_VOICE, "weapons/splauncher_bounce.wav", 0.25, ATTN_NORM); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void CSporeGrenade::DangerSound() |
|
|
|
void CSpore::IgniteThink() |
|
|
|
{ |
|
|
|
{ |
|
|
|
CSoundEnt::InsertSound(bits_SOUND_DANGER, pev->origin + pev->velocity * 0.5, pev->velocity.Length(), 0.2); |
|
|
|
SetThink(NULL); |
|
|
|
} |
|
|
|
SetTouch(NULL); |
|
|
|
|
|
|
|
|
|
|
|
void CSporeGrenade::TumbleThink(void) |
|
|
|
if (m_hSprite) |
|
|
|
{ |
|
|
|
|
|
|
|
if (!IsInWorld()) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
UTIL_Remove(this); |
|
|
|
UTIL_Remove(m_hSprite); |
|
|
|
return; |
|
|
|
m_hSprite = 0; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
pev->nextthink = gpGlobals->time + 0.1; |
|
|
|
EMIT_SOUND(edict(), CHAN_WEAPON, "weapons/splauncher_impact.wav", VOL_NORM, ATTN_NORM); |
|
|
|
|
|
|
|
|
|
|
|
if (pev->dmgtime - 1 < gpGlobals->time) |
|
|
|
const Vector vecDir = pev->velocity.Normalize(); |
|
|
|
{ |
|
|
|
|
|
|
|
CSoundEnt::InsertSound(bits_SOUND_DANGER, pev->origin + pev->velocity * (pev->dmgtime - gpGlobals->time), 400, 0.1); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (pev->dmgtime <= gpGlobals->time) |
|
|
|
TraceResult tr; |
|
|
|
{ |
|
|
|
|
|
|
|
SetThink(&CSporeGrenade::Detonate); |
|
|
|
UTIL_TraceLine( |
|
|
|
} |
|
|
|
pev->origin, pev->origin + vecDir * (m_SporeType == GRENADE ? 64 : 32), |
|
|
|
|
|
|
|
dont_ignore_monsters, edict(), &tr); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UTIL_DecalTrace(&tr, DECAL_SPR_SPLT1 + RANDOM_LONG(0, 2)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MESSAGE_BEGIN(MSG_PVS, SVC_TEMPENTITY, pev->origin); |
|
|
|
|
|
|
|
WRITE_BYTE(TE_SPRITE_SPRAY); |
|
|
|
|
|
|
|
WRITE_COORD( pev->origin.x ); |
|
|
|
|
|
|
|
WRITE_COORD( pev->origin.y ); |
|
|
|
|
|
|
|
WRITE_COORD( pev->origin.z ); |
|
|
|
|
|
|
|
WRITE_COORD( tr.vecPlaneNormal.x ); |
|
|
|
|
|
|
|
WRITE_COORD( tr.vecPlaneNormal.y ); |
|
|
|
|
|
|
|
WRITE_COORD( tr.vecPlaneNormal.z ); |
|
|
|
|
|
|
|
WRITE_SHORT(m_iSpitSprite); |
|
|
|
|
|
|
|
WRITE_BYTE(100); |
|
|
|
|
|
|
|
WRITE_BYTE(40); |
|
|
|
|
|
|
|
WRITE_BYTE(180); |
|
|
|
|
|
|
|
MESSAGE_END(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MESSAGE_BEGIN(MSG_PVS, SVC_TEMPENTITY, pev->origin); |
|
|
|
|
|
|
|
WRITE_BYTE(TE_DLIGHT); |
|
|
|
|
|
|
|
WRITE_COORD( pev->origin.x ); |
|
|
|
|
|
|
|
WRITE_COORD( pev->origin.y ); |
|
|
|
|
|
|
|
WRITE_COORD( pev->origin.z ); |
|
|
|
|
|
|
|
WRITE_BYTE(10); |
|
|
|
|
|
|
|
WRITE_BYTE(15); |
|
|
|
|
|
|
|
WRITE_BYTE(220); |
|
|
|
|
|
|
|
WRITE_BYTE(40); |
|
|
|
|
|
|
|
WRITE_BYTE(5); |
|
|
|
|
|
|
|
WRITE_BYTE(10); |
|
|
|
|
|
|
|
MESSAGE_END(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MESSAGE_BEGIN(MSG_PVS, SVC_TEMPENTITY, pev->origin); |
|
|
|
|
|
|
|
WRITE_BYTE(TE_SPRITE); |
|
|
|
|
|
|
|
WRITE_COORD( pev->origin.x ); |
|
|
|
|
|
|
|
WRITE_COORD( pev->origin.y ); |
|
|
|
|
|
|
|
WRITE_COORD( pev->origin.z ); |
|
|
|
|
|
|
|
WRITE_SHORT(RANDOM_LONG(0, 1) ? m_iBlow : m_iBlowSmall); |
|
|
|
|
|
|
|
WRITE_BYTE(20); |
|
|
|
|
|
|
|
WRITE_BYTE(128); |
|
|
|
|
|
|
|
MESSAGE_END(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MESSAGE_BEGIN(MSG_PVS, SVC_TEMPENTITY, pev->origin); |
|
|
|
|
|
|
|
WRITE_BYTE(TE_SPRITE_SPRAY); |
|
|
|
|
|
|
|
WRITE_COORD( pev->origin.x ); |
|
|
|
|
|
|
|
WRITE_COORD( pev->origin.y ); |
|
|
|
|
|
|
|
WRITE_COORD( pev->origin.z ); |
|
|
|
|
|
|
|
WRITE_COORD(RANDOM_FLOAT(-1, 1)); |
|
|
|
|
|
|
|
WRITE_COORD(1); |
|
|
|
|
|
|
|
WRITE_COORD(RANDOM_FLOAT(-1, 1)); |
|
|
|
|
|
|
|
WRITE_SHORT(m_iTrail); |
|
|
|
|
|
|
|
WRITE_BYTE(2); |
|
|
|
|
|
|
|
WRITE_BYTE(20); |
|
|
|
|
|
|
|
WRITE_BYTE(80); |
|
|
|
|
|
|
|
MESSAGE_END(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
::RadiusDamage(pev->origin, pev, VARS(pev->owner), pev->dmg, 200, CLASS_NONE, DMG_ALWAYSGIB | DMG_BLAST); |
|
|
|
|
|
|
|
|
|
|
|
// Spawn particles.
|
|
|
|
SetThink(&CSpore::SUB_Remove); |
|
|
|
SpawnTrailParticles( |
|
|
|
|
|
|
|
pev->origin, // position
|
|
|
|
pev->nextthink = gpGlobals->time; |
|
|
|
-pev->velocity.Normalize(), // dir
|
|
|
|
|
|
|
|
g_sModelIndexTinySpit, // modelindex
|
|
|
|
|
|
|
|
RANDOM_LONG( 2, 4 ), // count
|
|
|
|
|
|
|
|
RANDOM_FLOAT(10, 15), // speed
|
|
|
|
|
|
|
|
RANDOM_FLOAT(2, 3) * 100); // noise ( client will divide by 100 )
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
void CSpore::FlyThink() |
|
|
|
// Contact grenade, explode when it touches something
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
void CSporeGrenade::ExplodeTouch(CBaseEntity *pOther) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
TraceResult tr; |
|
|
|
const float flDelay = m_bIsAI ? 4.0 : 2.0; |
|
|
|
Vector vecSpot;// trace starts here!
|
|
|
|
|
|
|
|
|
|
|
|
if (m_SporeType != GRENADE || (gpGlobals->time <= m_flIgniteTime + flDelay)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
Vector velocity = pev->velocity.Normalize(); |
|
|
|
|
|
|
|
|
|
|
|
pev->enemy = pOther->edict(); |
|
|
|
MESSAGE_BEGIN(MSG_PVS, SVC_TEMPENTITY, pev->origin); |
|
|
|
|
|
|
|
WRITE_BYTE(TE_SPRITE_SPRAY); |
|
|
|
|
|
|
|
WRITE_COORD( pev->origin.x ); |
|
|
|
|
|
|
|
WRITE_COORD( pev->origin.y ); |
|
|
|
|
|
|
|
WRITE_COORD( pev->origin.z ); |
|
|
|
|
|
|
|
WRITE_COORD( velocity.x ); |
|
|
|
|
|
|
|
WRITE_COORD( velocity.y ); |
|
|
|
|
|
|
|
WRITE_COORD( velocity.z ); |
|
|
|
|
|
|
|
WRITE_SHORT(m_iTrail); |
|
|
|
|
|
|
|
WRITE_BYTE(2); |
|
|
|
|
|
|
|
WRITE_BYTE(20); |
|
|
|
|
|
|
|
WRITE_BYTE(80); |
|
|
|
|
|
|
|
MESSAGE_END(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
SetThink(&CSpore::IgniteThink); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
vecSpot = pev->origin - pev->velocity.Normalize() * 32; |
|
|
|
pev->nextthink = gpGlobals->time + 0.03; |
|
|
|
UTIL_TraceLine(vecSpot, vecSpot + pev->velocity.Normalize() * 64, ignore_monsters, ENT(pev), &tr); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Explode(&tr); |
|
|
|
void CSpore::GibThink() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
//Nothing
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void CSporeGrenade::DangerSoundThink(void) |
|
|
|
void CSpore::RocketTouch(CBaseEntity* pOther) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (!IsInWorld()) |
|
|
|
if (pOther->pev->takedamage != DAMAGE_NO) |
|
|
|
{ |
|
|
|
{ |
|
|
|
UTIL_Remove(this); |
|
|
|
pOther->TakeDamage(pev, VARS(pev->owner), gSkillData.plrDmgSpore, DMG_GENERIC); |
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
DangerSound(); |
|
|
|
IgniteThink(); |
|
|
|
pev->nextthink = gpGlobals->time + 0.2; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Spawn particles.
|
|
|
|
|
|
|
|
SpawnTrailParticles( |
|
|
|
|
|
|
|
pev->origin, // position
|
|
|
|
|
|
|
|
-pev->velocity.Normalize(), // dir
|
|
|
|
|
|
|
|
g_sModelIndexTinySpit, // modelindex
|
|
|
|
|
|
|
|
RANDOM_LONG( 5, 10), // count
|
|
|
|
|
|
|
|
RANDOM_FLOAT(10, 15), // speed
|
|
|
|
|
|
|
|
RANDOM_FLOAT(2, 3) * 100); // noise ( client will divide by 100 )
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void CSporeGrenade::BounceTouch(CBaseEntity *pOther) |
|
|
|
void CSpore::MyBounceTouch(CBaseEntity* pOther) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if ( !pOther->pev->takedamage ) |
|
|
|
if (pOther->pev->takedamage == DAMAGE_NO) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (!(pev->flags & FL_ONGROUND)) { |
|
|
|
if (pOther->edict() != pev->owner) |
|
|
|
if (pev->dmg_save < gpGlobals->time) { |
|
|
|
{ |
|
|
|
BounceSound(); |
|
|
|
if (gpGlobals->time > m_flSoundDelay) |
|
|
|
pev->dmg_save = gpGlobals->time + 0.1; |
|
|
|
{ |
|
|
|
} |
|
|
|
CSoundEnt::InsertSound(bits_SOUND_DANGER, pev->origin, (int)(pev->dmg * 2.5f), 0.3); |
|
|
|
} else { |
|
|
|
|
|
|
|
pev->velocity = pev->velocity * 0.9; |
|
|
|
m_flSoundDelay = gpGlobals->time + 1.0; |
|
|
|
} |
|
|
|
} |
|
|
|
if (pev->flags & FL_SWIM) |
|
|
|
|
|
|
|
|
|
|
|
if ((pev->flags & FL_ONGROUND) != 0) |
|
|
|
{ |
|
|
|
{ |
|
|
|
pev->velocity = pev->velocity * 0.5; |
|
|
|
pev->velocity = pev->velocity * 0.5; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
EMIT_SOUND_DYN(edict(), CHAN_VOICE, "weapons/splauncher_bounce.wav", 0.25, ATTN_NORM, 0, PITCH_NORM); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
TraceResult tr = UTIL_GetGlobalTrace(); |
|
|
|
pOther->TakeDamage(pev, VARS(pev->owner), gSkillData.plrDmgSpore, DMG_GENERIC); |
|
|
|
Explode(&tr); |
|
|
|
|
|
|
|
|
|
|
|
IgniteThink(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void CSporeGrenade::Spawn(void) |
|
|
|
CSpore* CSpore::CreateSpore(const Vector& vecOrigin, const Vector& vecAngles, CBaseEntity* pOwner, SporeType sporeType, bool bIsAI, bool bPuked) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Precache(); |
|
|
|
CSpore* pSpore = GetClassPtr<CSpore>(NULL); |
|
|
|
pev->classname = MAKE_STRING("spore"); |
|
|
|
|
|
|
|
pev->movetype = MOVETYPE_BOUNCE; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pev->solid = SOLID_BBOX; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SET_MODEL(ENT(pev), "models/spore.mdl"); |
|
|
|
UTIL_SetOrigin(pSpore->pev, vecOrigin); |
|
|
|
UTIL_SetSize(pev, Vector(0, 0, 0), Vector(0, 0, 0)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//pev->gravity = 0.5;
|
|
|
|
pSpore->m_SporeType = sporeType; |
|
|
|
|
|
|
|
|
|
|
|
pev->dmg = gSkillData.plrDmgSpore; |
|
|
|
if (bIsAI) |
|
|
|
|
|
|
|
|
|
|
|
m_pSporeGlow = CSprite::SpriteCreate("sprites/glow02.spr", pev->origin, FALSE); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (m_pSporeGlow) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
m_pSporeGlow->SetTransparency(kRenderGlow, 150, 158, 19, 155, kRenderFxNoDissipation); |
|
|
|
pSpore->pev->velocity = vecAngles; |
|
|
|
m_pSporeGlow->SetAttachment(edict(), 0); |
|
|
|
|
|
|
|
m_pSporeGlow->SetScale(.75f); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CBaseEntity* CSporeGrenade::ShootTimed(entvars_t *pevOwner, Vector vecStart, Vector vecVelocity, bool ai) |
|
|
|
pSpore->pev->angles = UTIL_VecToAngles(vecAngles); |
|
|
|
{ |
|
|
|
|
|
|
|
CSporeGrenade *pGrenade = GetClassPtr((CSporeGrenade *)NULL); |
|
|
|
|
|
|
|
UTIL_SetOrigin(pGrenade->pev, vecStart); |
|
|
|
|
|
|
|
pGrenade->Spawn(); |
|
|
|
|
|
|
|
pGrenade->pev->velocity = vecVelocity; |
|
|
|
|
|
|
|
pGrenade->pev->angles = UTIL_VecToAngles(pGrenade->pev->velocity); |
|
|
|
|
|
|
|
pGrenade->pev->owner = ENT(pevOwner); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pGrenade->SetTouch(&CSporeGrenade::BounceTouch); // Bounce if touched
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
float lifetime = 2.0; |
|
|
|
|
|
|
|
if (ai) { |
|
|
|
|
|
|
|
lifetime = 4.0; |
|
|
|
|
|
|
|
pGrenade->pev->gravity = 0.5; |
|
|
|
|
|
|
|
pGrenade->pev->friction = 0.9; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
pGrenade->pev->dmgtime = gpGlobals->time + lifetime; |
|
|
|
else |
|
|
|
pGrenade->SetThink(&CSporeGrenade::TumbleThink); |
|
|
|
|
|
|
|
pGrenade->pev->nextthink = gpGlobals->time + 0.1; |
|
|
|
|
|
|
|
if (lifetime < 0.1) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
pGrenade->pev->nextthink = gpGlobals->time; |
|
|
|
pSpore->pev->angles = vecAngles; |
|
|
|
pGrenade->pev->velocity = Vector(0, 0, 0); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return pGrenade; |
|
|
|
pSpore->m_bIsAI = bIsAI; |
|
|
|
} |
|
|
|
pSpore->m_bPuked = bPuked; |
|
|
|
|
|
|
|
|
|
|
|
CBaseEntity *CSporeGrenade::ShootContact(entvars_t *pevOwner, Vector vecStart, Vector vecVelocity) |
|
|
|
pSpore->Spawn(); |
|
|
|
{ |
|
|
|
|
|
|
|
CSporeGrenade *pGrenade = GetClassPtr((CSporeGrenade *)NULL); |
|
|
|
|
|
|
|
UTIL_SetOrigin(pGrenade->pev, vecStart); |
|
|
|
|
|
|
|
pGrenade->Spawn(); |
|
|
|
|
|
|
|
pGrenade->pev->movetype = MOVETYPE_FLY; |
|
|
|
|
|
|
|
pGrenade->pev->velocity = vecVelocity; |
|
|
|
|
|
|
|
pGrenade->pev->angles = UTIL_VecToAngles(pGrenade->pev->velocity); |
|
|
|
|
|
|
|
pGrenade->pev->owner = ENT(pevOwner); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// make monsters afraid of it while in the air
|
|
|
|
|
|
|
|
pGrenade->SetThink(&CSporeGrenade::DangerSoundThink); |
|
|
|
|
|
|
|
pGrenade->pev->nextthink = gpGlobals->time; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Explode on contact
|
|
|
|
|
|
|
|
pGrenade->SetTouch(&CSporeGrenade::ExplodeTouch); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pGrenade->pev->gravity = 0.5; |
|
|
|
|
|
|
|
pGrenade->pev->friction = 0.7; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return pGrenade; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void CSporeGrenade::SpawnTrailParticles(const Vector& origin, const Vector& direction, int modelindex, int count, float speed, float noise) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
MESSAGE_BEGIN(MSG_PVS, SVC_TEMPENTITY, origin); |
|
|
|
|
|
|
|
WRITE_BYTE(TE_SPRITE_SPRAY); |
|
|
|
|
|
|
|
WRITE_COORD(origin.x); // pos
|
|
|
|
|
|
|
|
WRITE_COORD(origin.y); |
|
|
|
|
|
|
|
WRITE_COORD(origin.z); |
|
|
|
|
|
|
|
WRITE_COORD(direction.x); // dir
|
|
|
|
|
|
|
|
WRITE_COORD(direction.y); |
|
|
|
|
|
|
|
WRITE_COORD(direction.z); |
|
|
|
|
|
|
|
WRITE_SHORT(modelindex); // model
|
|
|
|
|
|
|
|
WRITE_BYTE(count); // count
|
|
|
|
|
|
|
|
WRITE_BYTE(speed); // speed
|
|
|
|
|
|
|
|
WRITE_BYTE(noise); // noise ( client will divide by 100 )
|
|
|
|
|
|
|
|
MESSAGE_END(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void CSporeGrenade::SpawnExplosionParticles(const Vector& origin, const Vector& direction, int modelindex, int count, float speed, float noise) |
|
|
|
pSpore->pev->owner = pOwner->edict(); |
|
|
|
{ |
|
|
|
pSpore->pev->classname = MAKE_STRING("spore"); |
|
|
|
|
|
|
|
|
|
|
|
MESSAGE_BEGIN(MSG_PVS, SVC_TEMPENTITY, origin); |
|
|
|
return pSpore; |
|
|
|
WRITE_BYTE(TE_SPRITE_SPRAY); |
|
|
|
|
|
|
|
WRITE_COORD(origin.x); // pos
|
|
|
|
|
|
|
|
WRITE_COORD(origin.y); |
|
|
|
|
|
|
|
WRITE_COORD(origin.z); |
|
|
|
|
|
|
|
WRITE_COORD(direction.x); // dir
|
|
|
|
|
|
|
|
WRITE_COORD(direction.y); |
|
|
|
|
|
|
|
WRITE_COORD(direction.z); |
|
|
|
|
|
|
|
WRITE_SHORT(modelindex); // model
|
|
|
|
|
|
|
|
WRITE_BYTE(count); // count
|
|
|
|
|
|
|
|
WRITE_BYTE(speed); // speed
|
|
|
|
|
|
|
|
WRITE_BYTE(noise); // noise ( client will divide by 100 )
|
|
|
|
|
|
|
|
MESSAGE_END(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void CSporeGrenade::UpdateOnRemove() |
|
|
|
void CSpore::UpdateOnRemove() |
|
|
|
{ |
|
|
|
{ |
|
|
|
CBaseMonster::UpdateOnRemove(); |
|
|
|
CGrenade::UpdateOnRemove(); |
|
|
|
if (m_pSporeGlow) |
|
|
|
if (m_hSprite) |
|
|
|
{ |
|
|
|
{ |
|
|
|
UTIL_Remove(m_pSporeGlow); |
|
|
|
UTIL_Remove(m_hSprite); |
|
|
|
m_pSporeGlow = NULL; |
|
|
|
m_hSprite = 0; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|