AvHBite.cpp

 include "AvHAlienWeapons.h"
include "AvHPlayer.h"
ifdef AVH_CLIENT
include "cl_dll/eventscripts.h"
include "cl_dll/in_defs.h"
include "cl_dll/wrect.h"
include "cl_dll/cl_dll.h"
endif
include "../common/hldm.h"
include "../common/event_api.h"
include "../common/event_args.h"
include "../common/vector_util.h"
include "AvHAlienWeaponConstants.h"
include "AvHPlayerUpgrade.h"
ifdef AVH_SERVER
include "AvHGamerules.h"
include "AvHServerUtil.h"
endif
include "AvHSharedUtil.h"
LINK_ENTITY_TO_CLASS(kwBiteGun, AvHBite);
void V_PunchAxis( int axis, float punch );
void AvHBite::Init()
{
this->mRange = BALANCE_VAR(kBiteRange);
this->mDamage = BALANCE_VAR(kBiteDamage);
}
int AvHBite::GetBarrelLength() const
{
return kBiteBarrelLength;
}
bool AvHBite::GetIsGunPositionValid() const
{
return true;
}
float AvHBite::GetRateOfFire() const
{
return BALANCE_VAR(kBiteROF);
}
char* AvHBite::GetBiteSound() const
{
return kBiteSound;
}
int AvHBite::GetDeployAnimation() const
{
// Only play deploy anim when changing to skulk
int theDeployAnimation = 5;
AvHWeaponID thePreviousID = this->GetPreviousWeaponID(); switch(thePreviousID) { case AVH_WEAPON_BITE: case AVH_WEAPON_PARASITE: case AVH_ABILITY_LEAP: case AVH_WEAPON_DIVINEWIND: theDeployAnimation = -1; break; } return theDeployAnimation;
}
int AvHBite::GetIdleAnimation() const
{
//int theBaseOffset = this->GetIsPlayerMoving() ? 5 : 2;
//int theAnimation = theBaseOffset + UTIL_SharedRandomFloat(this->m_pPlayer->random_seed, 0, 1);
// Must be odd int theAnimation = 0; const int kMax = 41; int theRandomNumber = UTIL_SharedRandomLong(this->m_pPlayer->random_seed, 0, kMax); if(theRandomNumber == kMax) { // Return flavor anim theAnimation = 2; } else if(theRandomNumber < (kMax-1)/2) { theAnimation = 0; } else { theAnimation = 1; } return theAnimation;
}
int AvHBite::GetShootAnimation() const
{
return 4;
}
char* AvHBite::GetViewModel() const
{
return kLevel1ViewModel;
}
void AvHBite::Precache()
{
AvHAlienWeapon::Precache();
char* theBiteSound = this->GetBiteSound(); if(theBiteSound) { PRECACHE_UNMODIFIED_SOUND(theBiteSound); } PRECACHE_UNMODIFIED_SOUND(kBiteHitSound1); PRECACHE_UNMODIFIED_SOUND(kBiteHitSound2); PRECACHE_UNMODIFIED_SOUND(kBiteKillSound); this->mEvent = PRECACHE_EVENT(1, kBiteEventName);
}
void AvHBite::Spawn()
{
AvHAlienWeapon::Spawn();
this->Precache(); this->m_iId = AVH_WEAPON_BITE; // Set our class name this->pev->classname = MAKE_STRING(kwsBiteGun); SET_MODEL(ENT(this->pev), kNullModel); FallInit();// get ready to fall down.
}
void AvHBite::FireProjectiles(void)
{
ifdef AVH_SERVER
// TODO: Check team float theDamage = this->mDamage*AvHPlayerUpgrade::GetAlienMeleeDamageUpgrade(this->m_pPlayer->pev->iuser4, AvHSHUGetIsWeaponFocusable(AvHWeaponID(this->m_iId))); // Do trace hull here Vector theTestAiming = this->m_pPlayer->GetAutoaimVector( AUTOAIM_5DEGREES ); CBaseEntity* pHurt = this->m_pPlayer->CheckTraceHullAttack(this->mRange, theDamage, this->GetDamageType()); if(pHurt) { if(pHurt->pev->flags & (FL_MONSTER | FL_CLIENT)) { AvHSUKnockPlayerAbout(CBaseEntity::Instance(this->m_pPlayer->edict()), pHurt, 225); int theSoundIndex = RANDOM_LONG(0, 1); char* theSoundToPlay = ""; switch(theSoundIndex) { case 0: theSoundToPlay = kBiteHitSound1; break; case 1: theSoundToPlay = kBiteHitSound2; break; } if(pHurt->pev->health <= 0) { theSoundToPlay = kBiteKillSound; } EMIT_SOUND(ENT(pev), CHAN_WEAPON, theSoundToPlay, 1.0, ATTN_NORM); } }
endif
}
bool AvHBite::GetFiresUnderwater() const
{
return true;
}
bool AvHBite::GetIsDroppable() const
{
return false;
}
bool AvHBite::UsesAmmo(void) const
{
return false;
}
BOOL AvHBite::UseDecrement(void)
{
return true;
}