Projectile::Projectile(float px, float py, float pDirection, float pVelocity, float pDamage, sf::Texture mSpriteTexture) { CalculateVelocities(pDirection, pVelocity); SetDamage(pDamage); SetTexture(mSpriteTexture); SetDirection(pDirection); SetPosX(px); SetPosY(py); }
bool Dash::Initialize() { SetDamage(0.0f); SetTime(0.0); SetStatusEffect(&StatusEffect()); SetCooldown(0.0f); m_totalCooldown = DASH_COOLDOWN; m_stacks = -1; return true; }
Bullet::Bullet(Vector3 position, Mtx44 rotationOrientation, int damage, const char* textureFile) : GameObject("Bullet", "OBJ//Bullet//Bullet.obj", textureFile, MaterialList::GetInstance()->material[MaterialList::PLASTIC]) { SetPosition(position); SetRotation(rotationMatrix); SetDamage(damage); SetSpeed(200.0f); }
Bullet::Bullet(Vector3 position, Mtx44 rotationMatrix, int damage, const char* textureFile, float speed) : GameObject("Bullet", "OBJ//Bullet//Bullet.obj", textureFile, MaterialList::GetInstance()->material[MaterialList::PLASTIC]) { SetPosition(position); SetRotation(rotationMatrix); SetDamage(damage); SetSpeed(speed); timeToDespawn = 5.0; }
CBullet::CBullet(float fRotation,CBase* pOwner) { SetOwner(pOwner); SetWidth(16); SetHeight(16); SetDamage(5); SetType(OBJ_BULLET); ES->RegisterClient("enemydestroyed",this); ES->RegisterClient("camerachange",this); ES->RegisterClient("playerhit",this); m_fTimer = 0.0f; }
void ShootType::ShootMissile(const b2Vec2& initPos) { auto missile = new Missile(); missile->SetDynamicBody(m_Owner, m_MissileType, initPos, m_MissileScale); missile->SetTargetPos(m_TargetPos); missile->SetSpeed(m_MissileSpeed); missile->SetDamage(m_Damage); missile->SetRange(m_Range); missile->SetMaxHp(m_MissileHp); missile->SetHp(m_MissileHp); missile->MissileShoot(); }
void Monster::MeleeDamage(Game_Manager* gm_, Unit* target_) { int damage_ = target_->SetDamage(gm_, GetPos(), DT_MELEE, GetDamage()*GetAtkApply(), GetTeam()); GiveDamage(gm_, target_, DT_MELEE, damage_); target_->SetSlow(20); if(target_->GetMirrorDamage()) { SetDamage(gm_, target_->GetPos(), DT_MIRROR, target_->GetMirrorDamage(), target_->GetTeam()); } if(target_->GetMirrorKnockback()) { SetKnockback(target_->GetMirrorKnockback(), target_->GetMirrorKnockback()*2, GetAngleToTarget(target_->GetPos(),GetPos())); } }
void Dash::Cast(ObjectRef user, ObjectRef enemy) { r_cooldown = cooldown; auto dComp = user->GetComponent<DashComponent>(); if (dComp == NULL) { dComp = user->AddComponent<DashComponent>(); } user->GetComponent<CharacterComponent>()->GetCharacter()->SetCanMove(false); dComp->SetStun(stun_duration); dComp->SetDashSpeed(speed); dComp->SetDuration(duration); dComp->SetEnabled(true); dComp->SetDamage(damage); }
void CSnark::Spawn( void ) { Precache(); SetSolid( SOLID_BBOX ); AddSolidFlags( FSOLID_NOT_STANDABLE ); SetMoveType( MOVETYPE_FLYGRAVITY, MOVECOLLIDE_FLY_BOUNCE ); SetModel( "models/w_squeak.mdl" ); UTIL_SetSize( this, Vector( -4, -4, 0 ), Vector( 4, 4, 8 ) ); SetBloodColor( BLOOD_COLOR_YELLOW ); SetTouch( &CSnark::SuperBounceTouch ); SetThink( &CSnark::HuntThink ); SetNextThink( gpGlobals->curtime + 0.1f ); m_flNextHit = gpGlobals->curtime; m_flNextHunt = gpGlobals->curtime + 1E6; m_flNextBounceSoundTime = gpGlobals->curtime; AddFlag( FL_AIMTARGET | FL_NPC ); m_takedamage = DAMAGE_YES; m_iHealth = sk_snark_health.GetFloat(); m_iMaxHealth = m_iHealth; SetGravity( 0.5 ); SetFriction( 0.5 ); SetDamage( sk_snark_dmg_pop.GetFloat() ); m_flDie = gpGlobals->curtime + SQUEEK_DETONATE_DELAY; m_flFieldOfView = 0; // 180 degrees if ( GetOwnerEntity() ) m_hOwner = GetOwnerEntity(); m_flNextBounceSoundTime = gpGlobals->curtime;// reset each time a snark is spawned. SetSequence( WSQUEAK_RUN ); ResetSequenceInfo( ); m_iMyClass = CLASS_NONE; m_posPrev = Vector( 0, 0, 0 ); }
/////////////////////////////////////////////// // CONSTRUCTOR / DECONSTRUCT / OP OVERLOADS /////////////////////////////////////////////// CBullet::CBullet() { m_pOwner = NULL; SetWidth(16); SetHeight(16); SetDamage(5); SetType(OBJ_BULLET); ES->RegisterClient("enemyhit",this); ES->RegisterClient("camerachange",this); m_fTimer = 0.0f; m_fRotation = 0.0f; // Screw specifics m_bScrew = false; m_bPuke = false; };
BOOL CEffectManager::SetTargetArray(HEFFPROC handle,CTargetList* pTList,MAINTARGET* pMainTarget) { CTargetListIterator iter(pTList); TARGETSET tset[MAX_TARGET_NUM]; int nTargetNum = 0; while(iter.GetNextTarget()) { tset[nTargetNum].pTarget = OBJECTMGR->GetObject(iter.GetTargetID()); iter.GetTargetData(&tset[nTargetNum].ResultInfo); if(tset[nTargetNum].pTarget) ++nTargetNum; } iter.Release(); return SetDamage(handle,tset,nTargetNum,pMainTarget); }
void CIonFlare::SetUp(int shotowner, CGameObject * projectileowner, float damage, float damageradius, float velocity) { // Save the type of object that shot this weapon SetOwner(shotowner); // Damage of the projectile SetDamage((int)damage); m_PlasmaExplode = g_AudioManager.CreateSound(g_AudioManager.samples[SFX_PLAYER_IONCANNON], 10); m_Active = true; m_Velocity = velocity; m_DamageRadius = damageradius; m_CreationTime = g_time; m_LifeTime = 3.0f; }
void CTrackingMissile::SetUp(int shotOwner, int damage, bool left, float damageradius, float accuracy, CGameObject * projectileowner) { // Save the type of object that shot this weapon SetOwner(shotOwner); m_Tracking = false; m_UpdatePeriod = accuracy; m_SlerpScale = 1.0f / m_UpdatePeriod; m_DamageRadius = damageradius; // Damage of the projectile SetDamage(damage); m_Velocity = 40.0f; // Pointer to the game object that owns this shot m_ProjectileOwner = projectileowner; if(shotOwner == PLAYER_SHOT) { m_MissileExplode = g_AudioManager.CreateSound(g_AudioManager.samples[SFX_EXP_TINY], 9); m_MissileInAir = g_AudioManager.CreateSound(g_AudioManager.samples[SFX_MISSILEINAIR], 7); } else if(shotOwner == ENEMY_SHOT) { m_MissileExplode = g_AudioManager.CreateSound(g_AudioManager.samples[SFX_EXP_TINY], 7); m_MissileInAir = g_AudioManager.CreateSound(g_AudioManager.samples[SFX_MISSILEINAIR], 6); } m_MissileInAir->Play3DAudio(10.0f, 10000.0f, 75); m_Active = true; m_CreationTime = g_time; m_LifeTime = 10.0f; CObjFrame temp = *m_RenderObj.GetFrame(0); temp.GetOrientation(&m_Q0); m_Q2 = m_Q0; temp.RotateLocalX(-PI / 6.0f); temp.GetOrientation(&m_Q1); // Get the position of the object GetPosition(&m_CurPosition, 0); m_LastPosition = m_CurPosition; }
void CTripmineGrenade::Spawn( void ) { Precache( ); // motor SetMoveType( MOVETYPE_FLY ); SetSolid( SOLID_BBOX ); SetModel( "models/Weapons/w_slam.mdl" ); IPhysicsObject *pObject = VPhysicsInitNormal( SOLID_BBOX, GetSolidFlags() | FSOLID_TRIGGER, true ); pObject->EnableMotion( false ); SetCollisionGroup( COLLISION_GROUP_WEAPON ); SetCycle( 0.0f ); m_nBody = 3; m_flDamage = sk_plr_dmg_tripmine.GetFloat(); m_DmgRadius = sk_tripmine_radius.GetFloat(); ResetSequenceInfo( ); m_flPlaybackRate = 0; UTIL_SetSize(this, Vector( -4, -4, -2), Vector(4, 4, 2)); m_flPowerUp = gpGlobals->curtime + 2.0; SetThink( &CTripmineGrenade::PowerupThink ); SetNextThink( gpGlobals->curtime + 0.2 ); m_takedamage = DAMAGE_YES; m_iHealth = 1; EmitSound( "TripmineGrenade.Place" ); SetDamage ( 200 ); // Tripmine sits at 90 on wall so rotate back to get m_vecDir QAngle angles = GetAbsAngles(); angles.x -= 90; AngleVectors( angles, &m_vecDir ); m_vecEnd = GetAbsOrigin() + m_vecDir * 2048; AddEffects( EF_NOSHADOW ); }
void CShockBeam::Explode() { const Contents contents = UTIL_PointContents( GetAbsOrigin() ); if( m_pSprite ) { UTIL_Remove( m_pSprite ); m_pSprite = nullptr; } if( m_pBeam1 ) { UTIL_Remove( m_pBeam1 ); m_pBeam1 = nullptr; } if( m_pBeam2 ) { UTIL_Remove( m_pBeam2 ); m_pBeam2 = nullptr; } SetDamage( 40 ); MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, GetAbsOrigin() ); WRITE_BYTE( TE_DLIGHT ); WRITE_COORD_VECTOR( GetAbsOrigin() ); WRITE_BYTE( 8 ); WRITE_BYTE( 0 ); WRITE_BYTE( 253 ); WRITE_BYTE( 253 ); WRITE_BYTE( 5 ); WRITE_BYTE( 10 ); MESSAGE_END(); SetOwner( nullptr ); EMIT_SOUND_DYN( this, CHAN_WEAPON, "weapons/shock_impact.wav", UTIL_RandomFloat( 0.8, 0.9 ), ATTN_NORM, 0, PITCH_NORM ); }
void CAirtank::Spawn() { Precache( ); // motor SetMoveType( MOVETYPE_FLY ); SetSolidType( SOLID_BBOX ); SetModel( "models/w_oxygen.mdl"); SetSize( Vector( -16, -16, 0), Vector(16, 16, 36) ); SetAbsOrigin( GetAbsOrigin() ); SetTouch( &CAirtank::TankTouch ); SetThink( &CAirtank::TankThink ); GetFlags() |= FL_MONSTER; SetTakeDamageMode( DAMAGE_YES ); SetHealth( 20 ); SetDamage( 50 ); m_bState = true; }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CGrenadeRocket::Spawn( void ) { Precache(); SetMoveType( MOVETYPE_FLY ); SetSolid( SOLID_BBOX ); SetModel( "models/weapons/w_missile.mdl" ); UTIL_SetSize( this, vec3_origin, vec3_origin ); SetCollisionGroup( TFCOLLISION_GROUP_WEAPON ); SetTouch( MissileTouch ); SetDamage( 50 ); // Forward! Vector forward; AngleVectors( GetLocalAngles(), &forward, NULL, NULL ); SetAbsVelocity( forward * ROCKET_VELOCITY ); EmitSound( "GrenadeRocket.FlyLoop" ); }
void CGERocket::Spawn( void ) { Precache(); BaseClass::Spawn(); m_takedamage = DAMAGE_YES; m_iHealth = 1; m_bHitPlayer = false; // Default Damages they should be modified by the thrower SetDamage( 512 ); SetDamageRadius( 125 ); SetModel( "models/weapons/rocket_launcher/w_rocket.mdl" ); // Init our physics definition SetSolid( SOLID_VPHYSICS ); SetMoveType( MOVETYPE_FLY ); // So NPC's can "see" us AddFlag( FL_OBJECT ); // UTIL_SetSize( this, Vector(-10,-5,-5), Vector(10,5,5) ); SetCollisionGroup( COLLISION_GROUP_GRENADE ); SetThink( &CGERocket::IgniteThink ); SetNextThink( gpGlobals->curtime ); m_flSpawnTime = gpGlobals->curtime; // Explode if we hit anything solid SetTouch( &CGERocket::ExplodeTouch ); AddSolidFlags( FSOLID_NOT_STANDABLE ); }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CTFWeaponBaseGrenadeProj::InitGrenade( const Vector &velocity, const AngularImpulse &angVelocity, CBaseCombatCharacter *pOwner, const CTFWeaponInfo &weaponInfo ) { // We can't use OwnerEntity for grenades, because then the owner can't shoot them with his hitscan weapons (due to collide rules) // Thrower is used to store the person who threw the grenade, for damage purposes. SetOwnerEntity( NULL ); SetThrower( pOwner ); SetupInitialTransmittedGrenadeVelocity( velocity ); SetGravity( 0.4f/*BaseClass::GetGrenadeGravity()*/ ); SetFriction( 0.2f/*BaseClass::GetGrenadeFriction()*/ ); SetElasticity( 0.45f/*BaseClass::GetGrenadeElasticity()*/ ); SetDamage( weaponInfo.GetWeaponData( TF_WEAPON_PRIMARY_MODE ).m_nDamage ); SetDamageRadius( weaponInfo.m_flDamageRadius ); ChangeTeam( pOwner->GetTeamNumber() ); IPhysicsObject *pPhysicsObject = VPhysicsGetObject(); if ( pPhysicsObject ) { pPhysicsObject->AddVelocity( &velocity, &angVelocity ); } }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CGrenadeObjectSapper::Spawn( void ) { SetMoveType( MOVETYPE_NONE ); SetSolid( SOLID_BBOX ); AddSolidFlags( FSOLID_NOT_SOLID ); SetGravity( 0.0 ); SetFriction( 1.0 ); SetModel( "models/sapper.mdl"); UTIL_SetSize(this, Vector( -8, -8, -8), Vector(8, 8, 8)); SetCollisionGroup( TFCOLLISION_GROUP_WEAPON ); m_takedamage = DAMAGE_NO; m_iHealth = 50.0; m_bSapping = false; // Set my damages to the cvar values SetDamage( weapon_objectsapper_damage.GetFloat() * 0.1 ); SetDamageRadius( 0 ); SetTouch( NULL ); SetThink( &CGrenadeObjectSapper::SapperThink ); SetNextThink( gpGlobals->curtime + 0.1f ); m_bArmed = true; }
/* =========== WaterMove ============ */ void CBasePlayer::WaterMove() { if( GetMoveType() == MOVETYPE_NOCLIP ) return; if( GetHealth() < 0 ) return; if( GetWaterLevel() != WATERLEVEL_HEAD ) { // not underwater // play 'up for air' sound if( pev->air_finished < gpGlobals->time ) EMIT_SOUND( this, CHAN_VOICE, "player/pl_wade1.wav", 1, ATTN_NORM ); else if( pev->air_finished < gpGlobals->time + 9 ) EMIT_SOUND( this, CHAN_VOICE, "player/pl_wade2.wav", 1, ATTN_NORM ); pev->air_finished = gpGlobals->time + PLAYER_SWIM_AIRTIME; SetDamage( 2 ); // if we took drowning damage, give it back slowly if( m_idrowndmg > m_idrownrestored ) { // set drowning damage bit. hack - dmg_drownrecover actually // makes the time based damage code 'give back' health over time. // make sure counter is cleared so we start count correctly. // NOTE: this actually causes the count to continue restarting // until all drowning damage is healed. m_bitsDamageType |= DMG_DROWNRECOVER; m_bitsDamageType &= ~DMG_DROWN; m_rgbTimeBasedDamage[ itbd_DrownRecover ] = 0; } } else { // fully under water // stop restoring damage while underwater m_bitsDamageType &= ~DMG_DROWNRECOVER; m_rgbTimeBasedDamage[ itbd_DrownRecover ] = 0; if( pev->air_finished < gpGlobals->time ) // drown! { if( pev->pain_finished < gpGlobals->time ) { // take drowning damage SetDamage( GetDamage() + 1 ); if( GetDamage() > 5 ) SetDamage( 5 ); TakeDamage( CWorld::GetInstance(), CWorld::GetInstance(), GetDamage(), DMG_DROWN ); pev->pain_finished = gpGlobals->time + 1; // track drowning damage, give it back when // player finally takes a breath m_idrowndmg += GetDamage(); } } else { m_bitsDamageType &= ~DMG_DROWN; } } if( !GetWaterLevel() ) { if( GetFlags().Any( FL_INWATER ) ) { GetFlags().ClearFlags( FL_INWATER ); } return; } // make bubbles const int air = ( int ) ( pev->air_finished - gpGlobals->time ); if( !RANDOM_LONG( 0, 0x1f ) && RANDOM_LONG( 0, PLAYER_SWIM_AIRTIME - 1 ) >= air ) { switch( RANDOM_LONG( 0, 3 ) ) { case 0: EMIT_SOUND( this, CHAN_BODY, "player/pl_swim1.wav", 0.8, ATTN_NORM ); break; case 1: EMIT_SOUND( this, CHAN_BODY, "player/pl_swim2.wav", 0.8, ATTN_NORM ); break; case 2: EMIT_SOUND( this, CHAN_BODY, "player/pl_swim3.wav", 0.8, ATTN_NORM ); break; case 3: EMIT_SOUND( this, CHAN_BODY, "player/pl_swim4.wav", 0.8, ATTN_NORM ); break; } } if( GetWaterType() == CONTENTS_LAVA ) // do damage { if( GetDamageTime() < gpGlobals->time ) TakeDamage( CWorld::GetInstance(), CWorld::GetInstance(), 10 * GetWaterLevel(), DMG_BURN ); } else if( GetWaterType() == CONTENTS_SLIME ) // do damage { SetDamageTime( gpGlobals->time + 1 ); TakeDamage( CWorld::GetInstance(), CWorld::GetInstance(), 4 * GetWaterLevel(), DMG_ACID ); } if( !GetFlags().Any( FL_INWATER ) ) { GetFlags() |= FL_INWATER; SetDamageTime( 0 ); } }
void CSnark::SuperBounceTouch( CBaseEntity *pOther ) { float flpitch; trace_t tr = CBaseEntity::GetTouchTrace( ); // don't hit the guy that launched this grenade if ( m_hOwner && ( pOther == m_hOwner ) ) return; // at least until we've bounced once m_hOwner = NULL; QAngle angles = GetAbsAngles(); angles.x = 0; angles.z = 0; SetAbsAngles( angles ); // avoid bouncing too much if ( m_flNextHit > gpGlobals->curtime) return; // higher pitch as squeeker gets closer to detonation time flpitch = 155.0 - 60.0 * ( ( m_flDie - gpGlobals->curtime ) / SQUEEK_DETONATE_DELAY ); if ( pOther->m_takedamage && m_flNextAttack < gpGlobals->curtime ) { // attack! // make sure it's me who has touched them if ( tr.m_pEnt == pOther ) { // and it's not another squeakgrenade if ( tr.m_pEnt->GetModelIndex() != GetModelIndex() ) { // ALERT( at_console, "hit enemy\n"); ClearMultiDamage(); Vector vecForward; AngleVectors( GetAbsAngles(), &vecForward ); if ( m_hOwner != NULL ) { CTakeDamageInfo info( this, m_hOwner, sk_snark_dmg_bite.GetFloat(), DMG_SLASH ); CalculateMeleeDamageForce( &info, vecForward, tr.endpos ); pOther->DispatchTraceAttack( info, vecForward, &tr ); } else { CTakeDamageInfo info( this, this, sk_snark_dmg_bite.GetFloat(), DMG_SLASH ); CalculateMeleeDamageForce( &info, vecForward, tr.endpos ); pOther->DispatchTraceAttack( info, vecForward, &tr ); } ApplyMultiDamage(); SetDamage( GetDamage() + sk_snark_dmg_pop.GetFloat() ); // add more explosion damage // m_flDie += 2.0; // add more life // make bite sound CPASAttenuationFilter filter( this ); enginesound->EmitSound( filter, entindex(), CHAN_WEAPON, "squeek/sqk_deploy1.wav", 1, ATTN_NORM, 0, (int)flpitch ); m_flNextAttack = gpGlobals->curtime + 0.5; } } else { // ALERT( at_console, "been hit\n"); } } m_flNextHit = gpGlobals->curtime + 0.1; m_flNextHunt = gpGlobals->curtime; if ( g_pGameRules->IsMultiplayer() ) { // in multiplayer, we limit how often snarks can make their bounce sounds to prevent overflows. if ( gpGlobals->curtime < m_flNextBounceSoundTime ) { // too soon! return; } } if ( !( GetFlags() & FL_ONGROUND ) ) { // play bounce sound CPASAttenuationFilter filter2( this ); switch ( random->RandomInt( 0, 2 ) ) { case 0: enginesound->EmitSound( filter2, entindex(), CHAN_VOICE, "squeek/sqk_hunt1.wav", 1, ATTN_NORM, 0, (int)flpitch ); break; case 1: enginesound->EmitSound( filter2, entindex(), CHAN_VOICE, "squeek/sqk_hunt2.wav", 1, ATTN_NORM, 0, (int)flpitch ); break; case 2: enginesound->EmitSound( filter2, entindex(), CHAN_VOICE, "squeek/sqk_hunt3.wav", 1, ATTN_NORM, 0, (int)flpitch ); break; } CSoundEnt::InsertSound( SOUND_COMBAT, GetAbsOrigin(), 256, 0.25 ); } else { // skittering sound CSoundEnt::InsertSound( SOUND_COMBAT, GetAbsOrigin(), 100, 0.1 ); } m_flNextBounceSoundTime = gpGlobals->curtime + 0.5;// half second. }