Esempio n. 1
0
bool CASW_Use_Area::RequirementsMet( CBaseEntity *pUser )
{
	int nPlayersRequired = MIN( m_nPlayersRequired, ASWGameResource()->CountAllAliveMarines() );

	if ( nPlayersRequired <= 1 )
	{
		return true;
	}

	int nTouchingMarines = 0;

	for ( int nEnt = 0; nEnt < m_hTouchingEntities.Count(); ++nEnt )
	{
		CASW_Marine *pMarine = dynamic_cast<CASW_Marine *>( m_hTouchingEntities[ nEnt ].Get() );

		if ( pMarine && pMarine->IsAlive() && !pMarine->m_bKnockedOut )
		{
			nTouchingMarines++;
		}
	}

	if ( nTouchingMarines >= nPlayersRequired )
	{
		return true;
	}

	m_OnRequirementFailed.FireOutput( pUser, this );

	return false;
}
bool CASWTraceFilterShot::ShouldHitEntity( IHandleEntity *pHandleEntity, int contentsMask )
{
	Assert( pHandleEntity );
	if ( !PassServerEntityFilter( pHandleEntity, m_pPassEnt2 ) )
		return false;
	
	CBaseEntity *pEntity = EntityFromEntityHandle( pHandleEntity );

	// don't collide with other projectiles
	if ( dynamic_cast<CASW_Flamer_Projectile*>( pEntity ) != NULL )
		return false;

	if ( dynamic_cast<CASW_Extinguisher_Projectile*>( pEntity ) != NULL )
		return false;

	if ( pEntity && pEntity->Classify() == CLASS_ASW_MARINE )
	{
		if ( m_bSkipMarines )
			return false;

		CASW_Marine *pMarine = assert_cast<CASW_Marine*>( pEntity );
		if ( m_bSkipRollingMarines && pMarine->GetCurrentMeleeAttack() && pMarine->GetCurrentMeleeAttack()->m_nAttackID == CASW_Melee_System::s_nRollAttackID )
			return false;

		if ( m_bSkipMarinesReflectingProjectiles && pMarine->IsReflectingProjectiles() )
			return false;
	}

	if ( m_bSkipAliens && pEntity && IsAlienClass( pEntity->Classify() ) )
		return false;

	return BaseClass::ShouldHitEntity( pHandleEntity, contentsMask );
}
void CASW_Weapon_Hornet_Barrage::FireRocket()
{
	CASW_Player *pPlayer = GetCommander();
	CASW_Marine *pMarine = GetMarine();
	if ( !pPlayer || !pMarine || pMarine->GetHealth() <= 0 )
	{
		m_iRocketsToFire = 0;
		return;
	}

	WeaponSound(SINGLE);

	// tell the marine to tell its weapon to draw the muzzle flash
	pMarine->DoMuzzleFlash();

	pMarine->DoAnimationEvent( PLAYERANIMEVENT_FIRE_GUN_PRIMARY );

	Vector vecSrc	 = GetRocketFiringPosition();
	m_iRocketsToFire = m_iRocketsToFire.Get() - 1;
	m_flNextLaunchTime = gpGlobals->curtime + m_flFireInterval.Get();

#ifndef CLIENT_DLL
	float fGrenadeDamage = MarineSkills()->GetSkillBasedValueByMarine(pMarine, ASW_MARINE_SKILL_GRENADES, ASW_MARINE_SUBSKILL_GRENADE_HORNET_DMG );

	CASW_Rocket::Create( fGrenadeDamage, vecSrc, GetRocketAngle(), pMarine, this );

	if ( ASWGameRules() )
	{
		ASWGameRules()->m_fLastFireTime = gpGlobals->curtime;
	}

	pMarine->OnWeaponFired( this, 1 );

#endif
}
Esempio n. 4
0
// creates a batch of aliens at the mouse cursor
void asw_alien_batch_f( const CCommand& args )
{
    MDLCACHE_CRITICAL_SECTION();

    bool allowPrecache = CBaseEntity::IsPrecacheAllowed();
    CBaseEntity::SetAllowPrecache( true );

    // find spawn point
    CASW_Player* pPlayer = ToASW_Player(UTIL_GetCommandClient());
    if (!pPlayer)
        return;
    CASW_Marine *pMarine = pPlayer->GetMarine();
    if (!pMarine)
        return;
    trace_t tr;
    Vector forward;

    AngleVectors( pMarine->EyeAngles(), &forward );
    UTIL_TraceLine(pMarine->EyePosition(),
                   pMarine->EyePosition() + forward * 300.0f,MASK_SOLID,
                   pMarine, COLLISION_GROUP_NONE, &tr );
    if ( tr.fraction != 0.0 )
    {
        // trace to the floor from this spot
        Vector vecSrc = tr.endpos;
        tr.endpos.z += 12;
        UTIL_TraceLine( vecSrc + Vector(0, 0, 12),
                        vecSrc - Vector( 0, 0, 512 ) ,MASK_SOLID,
                        pMarine, COLLISION_GROUP_NONE, &tr );

        ASWSpawnManager()->SpawnAlienBatch( "asw_parasite", 25, tr.endpos, vec3_angle );
    }

    CBaseEntity::SetAllowPrecache( allowPrecache );
}
Esempio n. 5
0
//-----------------------------------------------------------------------------
// Purpose: Input handler for showing the message and/or playing the sound.
//-----------------------------------------------------------------------------
void CPointEventProxy::InputGenerateEvent( inputdata_t &inputdata )
{
	IGameEvent * event = gameeventmanager->CreateEvent( m_iszEventName.ToCStr() );
	if ( event )
	{
		CBasePlayer *pActivator = NULL;

#ifdef INFESTED_DLL
		CASW_Marine *pMarine = dynamic_cast< CASW_Marine* >( inputdata.pActivator );
		if ( pMarine )
		{
			pActivator = pMarine->GetCommander();
		}
#else
		pActivator = dynamic_cast< CBasePlayer* >( inputdata.pActivator );
#endif

		if ( m_bActivatorAsUserID )
		{
			event->SetInt( "userid", ( pActivator ? pActivator->GetUserID() : 0 ) );
		}

		gameeventmanager->FireEvent( event );
	}
}
float	CASW_Weapon_Pistol::GetFireRate( void )
{
	CASW_Marine *pMarine = GetMarine();

	float flRate = GetWeaponInfo()->m_flFireRate;

	// player firing rate
	if (!pMarine || pMarine->IsInhabited())
	{
		return flRate;
	}

#ifdef CLIENT_DLL
	return flRate;

#else
	float randomness = 0.1f * random->RandomFloat() - 0.05f;

	// AI firing rate: depends on distance to enemy
	if (!pMarine->GetEnemy())
		return 0.3f + randomness;

	float dist = pMarine->GetAbsOrigin().DistTo(pMarine->GetEnemy()->GetAbsOrigin());
	if (dist > 500)
		return 0.3f + randomness;

	if (dist < 100)
		return 0.14f + randomness;

	float factor = (dist - 100) / 400.0f;
	return 0.14f + factor * 0.16f + randomness;
#endif
}
const QAngle& CASW_Weapon_Smart_Bomb::GetRocketAngle()
{
	static QAngle angRocket = vec3_angle;
	CASW_Player *pPlayer = GetCommander();
	CASW_Marine *pMarine = GetMarine();
	if ( !pPlayer || !pMarine || pMarine->GetHealth() <= 0 )
	{
		return angRocket;
	}

	//Vector vecDir = pPlayer->GetAutoaimVectorForMarine(pMarine, GetAutoAimAmount(), GetVerticalAdjustOnlyAutoAimAmount());	// 45 degrees = 0.707106781187
	//VectorAngles( vecDir, angRocket );
	//angRocket[ YAW ] += random->RandomFloat( -35, 35 );
	angRocket[ PITCH ] = -60.0f;	// aim up to help avoid FF
	if ( GetRocketsToFire() % 2 )
	{
		angRocket[ YAW ] = m_iRocketsToFire * 15.0f;	// 15 degrees between each rocket
	}
	else
	{
		angRocket[ YAW ] = RandomFloat( 0.0f, 360.0f );
	}
	angRocket[ ROLL ] = 0;
	return angRocket;
}
void asw_gimme_ammo_f(void)
{
	CASW_Game_Resource *pGameResource = ASWGameResource();
	if ( !pGameResource )
		return;

	for (int i=0;i<pGameResource->GetMaxMarineResources();i++)
	{
		if (pGameResource->GetMarineResource(i) != NULL && pGameResource->GetMarineResource(i)->GetMarineEntity())
		{
			CASW_Marine *pMarine = pGameResource->GetMarineResource(i)->GetMarineEntity();
			for (int k=0;k<ASW_MAX_MARINE_WEAPONS;k++)
			{
				CASW_Weapon *pWeapon = pMarine->GetASWWeapon(k);
				if (!pWeapon)
					continue;

				// refill bullets in the gun
				pWeapon->m_iClip1 = pWeapon->GetMaxClip1();
				pWeapon->m_iClip2 = pWeapon->GetMaxClip2();

				// give the marine a load of ammo of that type
				pMarine->GiveAmmo(10000, pWeapon->GetPrimaryAmmoType());
				pMarine->GiveAmmo(10000, pWeapon->GetSecondaryAmmoType());
			}
		}
	}
}
void CASW_Parasite::InfestThink( void )
{	
	SetNextThink( gpGlobals->curtime + 0.1f );

	if ( !GetModelPtr() )
		return;
	
	StudioFrameAdvance();

	DispatchAnimEvents( this );

	CASW_Marine *pMarine = dynamic_cast<CASW_Marine*>(GetParent());
	CASW_Colonist *pColonist = dynamic_cast<CASW_Colonist*>(GetParent());

	if (!pColonist) {
	if ( !pMarine || !pMarine->IsInfested() || pMarine->IsEffectActive( EF_NODRAW ) )
	{
		FinishedInfesting();
	}
	}

	if (!pMarine) {
		if ( !pColonist || !pColonist->IsInfested() || pColonist->IsEffectActive( EF_NODRAW ) )
		{
			FinishedInfesting();
		}
	}
}
Esempio n. 10
0
bool CASW_Spawn_Manager::AddHorde( int iHordeSize )
{
    m_iHordeToSpawn = iHordeSize;

    if ( m_vecHordePosition == vec3_origin )
    {
        if ( !FindHordePosition() )
        {
            Msg("Error: Failed to find horde position\n");
            return false;
        }
        else
        {
            if ( asw_director_debug.GetBool() )
            {
                NDebugOverlay::Cross3D( m_vecHordePosition, 50.0f, 255, 128, 0, true, 60.0f );
                float flDist;
                CASW_Marine *pMarine = UTIL_ASW_NearestMarine( m_vecHordePosition, flDist );
                if ( pMarine )
                {
                    NDebugOverlay::Line( pMarine->GetAbsOrigin(), m_vecHordePosition, 255, 128, 0, true, 60.0f );
                }
            }
        }
    }
    return true;
}
Esempio n. 11
0
void CASW_Weapon_Blink::DoBlink()
{
	CASW_Marine *pMarine = GetMarine();
	if ( !pMarine )
		return;

	pMarine->m_iJumpJetting = JJ_BLINK;
	pMarine->m_vecJumpJetStart = pMarine->GetAbsOrigin();
	pMarine->m_vecJumpJetEnd = m_vecAbilityDestination;
	pMarine->m_flJumpJetStartTime = gpGlobals->curtime;
	pMarine->m_flJumpJetEndTime = gpGlobals->curtime + asw_blink_time.GetFloat();

	ASWMeleeSystem()->StartMeleeAttack( ASWMeleeSystem()->GetMeleeAttackByName( "Blink" ), pMarine, ASWGameMovement()->GetMoveData() );

	// TODO:
	/*
#ifdef GAME_DLL
	// create a small stun volume at the start
	CASW_Weapon_EffectVolume *pEffect = (CASW_Weapon_EffectVolume*) CreateEntityByName("asw_weapon_effect_volume");
	if ( pEffect )
	{
		pEffect->SetAbsOrigin( pMarine->GetAbsOrigin() );
		pEffect->SetOwnerEntity( pMarine );
		pEffect->SetOwnerWeapon( NULL );
		pEffect->SetEffectFlag( ASW_WEV_ELECTRIC_BIG );
		pEffect->SetDuration( pSkill->GetValue( CASW_Skill_Details::Duration, GetSkillPoints() ) );
		pEffect->Spawn();
	}
#endif
	*/

	m_flPower = 0.0f;

	// TODO: Check for charges being zero
}
void CASW_Weapon_Sniper_Rifle::ItemPostFrame( void )
{
	BaseClass::ItemPostFrame();

	CASW_Marine *pMarine = GetMarine();
	if ( !pMarine )
		return;

	// AIs switch out of zoom mode
	if ( !pMarine->IsInhabited() && IsZoomed() )
	{
		m_bZoomed = false;
	}

	bool bAttack1, bAttack2, bReload, bOldReload, bOldAttack1;
	GetButtons( bAttack1, bAttack2, bReload, bOldReload, bOldAttack1 );

	bool bOldAttack2 = false;
	if ( pMarine->IsInhabited() && pMarine->GetCommander() )
	{
		bOldAttack2 = !!(pMarine->m_nOldButtons & IN_ATTACK2);
	}

	if ( bAttack2 && !bOldAttack2 )
	{
		m_bZoomed = !IsZoomed();
	}
}
void asw_drop_ammo_f(const CCommand &args)
{
	CASW_Player *pPlayer = ToASW_Player(UTIL_GetCommandClient());
	if (!pPlayer)
		return;
	
	CASW_Marine *pMarine = pPlayer->GetMarine();
	if (!pMarine)
		return;

	int iBagSlot = atoi(args[1]);

	CASW_Weapon_Ammo_Bag *pBag = dynamic_cast<CASW_Weapon_Ammo_Bag*>(pMarine->GetWeapon(0));
	if (pBag)
	{
		if (pBag->DropAmmoPickup(iBagSlot))
		{
			return;
		}
	}

	pBag = dynamic_cast<CASW_Weapon_Ammo_Bag*>(pMarine->GetWeapon(1));
	if (pBag)
	{
		if (pBag->DropAmmoPickup(iBagSlot))
		{
			return;
		}
	}
}
bool CASW_Weapon::ShouldAlienFlinch(CBaseEntity *pAlien, const CTakeDamageInfo &info)
{
	if (!GetWeaponInfo())
		return false;
	float fFlinchChance = GetWeaponInfo()->m_fFlinchChance;
	CASW_Marine *pMarine = dynamic_cast<CASW_Marine*>(GetOwner());
	if (asw_debug_alien_damage.GetBool())
		Msg("BaseFlinch chance %f ", fFlinchChance);
	if (pMarine && pMarine->GetMarineProfile() && pMarine->GetMarineProfile()->GetMarineClass() == MARINE_CLASS_SPECIAL_WEAPONS)
	{
		// this is a special weapons marine, so we need to add our flinch bonus onto it
		fFlinchChance += GetWeaponInfo()->m_fStoppingPowerFlinchBonus * MarineSkills()->GetSkillBasedValueByMarine(pMarine, ASW_MARINE_SKILL_STOPPING_POWER);
		if (asw_debug_alien_damage.GetBool())
			Msg("Boosted by specialweaps to %f ", fFlinchChance);
	}

	//CALL_ATTRIB_HOOK_FLOAT( fFlinchChance, mod_stopping );

	if (pAlien)
	{
		int iHealth = pAlien->GetHealth();
		int iDamage = info.GetDamage();
		float fAlienHealth = float(iHealth + iDamage) / float(pAlien->GetMaxHealth());
		fFlinchChance *= fAlienHealth;
		if (asw_debug_alien_damage.GetBool())
			Msg("adjusted by alien health (%f) to %f ", fAlienHealth, fFlinchChance);
	}

	float f = random->RandomFloat();
	bool bResult = ( f < fFlinchChance);
	if (asw_debug_alien_damage.GetBool())
		Msg("random float is %f shouldflinch = %d\n", f, bResult);
	return bResult;
}
Esempio n. 15
0
int CASW_Barrel_Explosive::OnTakeDamage( const CTakeDamageInfo &info )
{
	int saveFlags = m_takedamage;

	// don't be destroyed by buzzers
	if ( info.GetAttacker() && info.GetAttacker()->Classify() == CLASS_ASW_BUZZER )
	{
		return 0;
	}

	// prevent barrel exploding when knocked around
	if ( info.GetDamageType() & DMG_CRUSH )
		return 0;
	
	CASW_Marine* pMarine = NULL;
	if ( info.GetAttacker() && info.GetAttacker()->Classify() == CLASS_ASW_MARINE )
	{
		m_hAttacker = info.GetAttacker();

		pMarine = assert_cast< CASW_Marine* >( info.GetAttacker() );
		// prevent AI marines blowing up barrels as it makes the player ANGRY ANGRY
		if ( pMarine && !pMarine->IsInhabited() )
			return 0;
	}

	// don't burst open if melee'd
	if ( info.GetDamageType() & ( DMG_CLUB | DMG_SLASH ) )
	{
		m_takedamage = DAMAGE_EVENTS_ONLY;

		if( !m_bMeleeHit )
		{
			if ( pMarine )
			{
				IGameEvent * event = gameeventmanager->CreateEvent( "physics_melee" );
				if ( event )
				{
					CASW_Player *pCommander = pMarine->GetCommander();
					event->SetInt( "attacker", pCommander ? pCommander->GetUserID() : 0 );
					event->SetInt( "entindex", entindex() );
					gameeventmanager->FireEvent( event );
				}
			}
			m_bMeleeHit = true;
		}
	}

	if ( pMarine )
	{
		pMarine->HurtJunkItem(this, info);
	}

	// skip the breakable prop's complex damage handling and just hurt us
	int iResult = CBaseEntity::OnTakeDamage(info);
	m_takedamage = saveFlags;

	return iResult;
}
Esempio n. 16
0
// function unused (done by CASW_Marine::Weapon_Switch instead?)
void CASW_Weapon::SendWeaponSwitchEvents()
{
	CASW_Marine *marine = dynamic_cast<CASW_Marine*>(GetOwner());
	if (!marine)
		return;

	// Make the player play his reload animation. (and send to clients)
	marine->DoAnimationEvent( PLAYERANIMEVENT_WEAPON_SWITCH );
}
void CASW_Weapon_Freeze_Grenades::DelayedAttack( void )
{
	m_bShotDelayed = false;
	
	CASW_Player *pPlayer = GetCommander();
	if ( !pPlayer )
		return;

	CASW_Marine *pMarine = GetMarine();
	if ( !pMarine || pMarine->GetWaterLevel() == 3 )
		return;
	
#ifndef CLIENT_DLL		
	Vector vecSrc = pMarine->GetOffhandThrowSource();

	Vector vecDest = pPlayer->GetCrosshairTracePos();
	Vector newVel = UTIL_LaunchVector( vecSrc, vecDest, GetThrowGravity() ) * 28.0f;
	
	float fGrenadeRadius = GetBoomRadius( pMarine );
	if (asw_debug_marine_damage.GetBool())
	{
		Msg( "Freeze grenade radius = %f \n", fGrenadeRadius );
	}
	pMarine->GetMarineSpeech()->Chatter( CHATTER_GRENADE );

	// freeze aliens completely, plus the freeze duration
	float flFreezeAmount = 1.0f + MarineSkills()->GetSkillBasedValueByMarine(pMarine, ASW_MARINE_SKILL_GRENADES, ASW_MARINE_SUBSKILL_GRENADE_FREEZE_DURATION);

	if (ASWGameRules())
		ASWGameRules()->m_fLastFireTime = gpGlobals->curtime;

	CASW_Grenade_Freeze *pGrenade = CASW_Grenade_Freeze::Freeze_Grenade_Create( 
		1.0f,
		flFreezeAmount,
		fGrenadeRadius,
		0,
		vecSrc, pMarine->EyeAngles(), newVel, AngularImpulse(0,0,0), pMarine, this );
	if ( pGrenade )
	{
		pGrenade->SetGravity( GetThrowGravity() );
		pGrenade->SetExplodeOnWorldContact( true );
	}
	
#endif
		// decrement ammo
	m_iClip1 -= 1;

#ifndef CLIENT_DLL
	DestroyIfEmpty( true );
#endif

	m_flSoonestPrimaryAttack = gpGlobals->curtime + ASW_FLARES_FASTEST_REFIRE_TIME;
	if (m_iClip1 > 0)		// only force the fire wait time if we have ammo for another shot
		m_flNextPrimaryAttack = gpGlobals->curtime + GetFireRate();
	else
		m_flNextPrimaryAttack = gpGlobals->curtime;
}
void asw_stop_burning_f()
{
	CASW_Player *pPlayer = ToASW_Player(UTIL_GetCommandClient());
	
	if (pPlayer && pPlayer->GetMarine())
	{
		CASW_Marine *pMarine = pPlayer->GetMarine();
		pMarine->Extinguish();
	}
}
//-----------------------------------------------------------------------------
bool CASW_Weapon::IsCarriedByLocalPlayer()
{
	if ( gpGlobals->maxClients <= 1 && !engine->IsDedicatedServer() )
	{
		CASW_Marine *pMarine = dynamic_cast<CASW_Marine*>( GetOwner() );
		return ( pMarine && pMarine->IsInhabited() && pMarine->GetCommander() == UTIL_GetListenServerHost() );
	}

	return false;
}
const Vector& CASW_Weapon_Hornet_Barrage::GetRocketFiringPosition()
{
	CASW_Marine *pMarine = GetMarine();
	if ( !pMarine )
		return vec3_origin;

	static Vector vecSrc;
	vecSrc = pMarine->Weapon_ShootPosition();

	return vecSrc;
}
void MarineHealths()
{
	CBaseEntity* pEntity = NULL;
	while ((pEntity = gEntList.FindEntityByClassname( pEntity, "asw_marine" )) != NULL)
	{
		CASW_Marine* marine = CASW_Marine::AsMarine( pEntity );
		if (marine)
		{
			Msg("Marine health is %d\n", marine->GetHealth());
		}
	}
}
Esempio n. 22
0
int CASW_Item_Crate::OnTakeDamage( const CTakeDamageInfo &info )
{
	if (info.GetAttacker() && info.GetAttacker()->Classify() == CLASS_PLAYER_ALLY_VITAL)
	{
		CASW_Marine* pMarine = dynamic_cast<CASW_Marine*>(info.GetAttacker());
		if (pMarine)
			pMarine->HurtJunkItem(this, info);
	}
		
	int iResult = BaseClass::OnTakeDamage(info);

	return iResult;
}
int CASW_Weapon_Medkit::GetHealAmount()
{
	CASW_Marine *pMarine = GetMarine();
	if ( !pMarine )
		return 0;

	// medics adjust heal amount by their skills
	if ( pMarine->GetMarineProfile() && pMarine->GetMarineProfile()->CanUseFirstAid() )
	{
		return MarineSkills()->GetSkillBasedValueByMarine(pMarine, ASW_MARINE_SKILL_HEALING, ASW_MARINE_SUBSKILL_HEALING_MEDKIT_HPS);
	}

	return MEDKIT_HEAL_AMOUNT.GetInt();
}
Esempio n. 24
0
// increase intensity as aliens are killed (particularly if they're close to the marines)
void CASW_Director::Event_AlienKilled( CBaseEntity *pAlien, const CTakeDamageInfo &info )
{
	if ( !pAlien )
		return;

	CASW_Game_Resource *pGameResource = ASWGameResource();
	if ( !pGameResource )
		return;

	bool bDangerous = pAlien->Classify() == CLASS_ASW_SHIELDBUG;       // shieldbug
	bool bVeryDangerous = pAlien->Classify() == CLASS_ASW_QUEEN;		// queen

	for ( int i=0;i<pGameResource->GetMaxMarineResources();i++ )
	{
		CASW_Marine_Resource *pMR = pGameResource->GetMarineResource(i);
		if ( !pMR )
			continue;

		CASW_Marine *pMarine = pMR->GetMarineEntity();
		if ( !pMarine || pMarine->GetHealth() <= 0 )
			continue;

		CASW_Intensity::IntensityType stress = CASW_Intensity::MILD;

		if ( bVeryDangerous )
		{
			stress = CASW_Intensity::EXTREME;
		}
		else if ( bDangerous )
		{
			stress = CASW_Intensity::HIGH;
		}
		else
		{
			float distance = pMarine->GetAbsOrigin().DistTo( pAlien->GetAbsOrigin() );
			if ( distance > asw_intensity_far_range.GetFloat() )
			{
				stress = CASW_Intensity::MILD;
			}
			else
			{
				stress = CASW_Intensity::MODERATE;
			}
		}

		pMR->GetIntensity()->Increase( stress );
	}

	ASWArena()->Event_AlienKilled( pAlien, info );
}
const Vector& CASW_Weapon_Smart_Bomb::GetRocketFiringPosition()
{
	CASW_Marine *pMarine = GetMarine();
	if ( !pMarine )
		return vec3_origin;

	static Vector vecSrc;
	QAngle ang;

	int nAttachment = pMarine->LookupAttachment( "backpack" );
	pMarine->GetAttachment( nAttachment, vecSrc, ang );

	return vecSrc;
}
const QAngle& CASW_Weapon_Hornet_Barrage::GetRocketAngle()
{
	static QAngle angRocket = vec3_angle;
	CASW_Player *pPlayer = GetCommander();
	CASW_Marine *pMarine = GetMarine();
	if ( !pPlayer || !pMarine || pMarine->GetHealth() <= 0 )
	{
		return angRocket;
	}

	Vector vecDir = pPlayer->GetAutoaimVectorForMarine(pMarine, GetAutoAimAmount(), GetVerticalAdjustOnlyAutoAimAmount());	// 45 degrees = 0.707106781187
	VectorAngles( vecDir, angRocket );
	angRocket[ YAW ] += random->RandomFloat( -35, 35 );
	return angRocket;
}
void cc_stuck( const CCommand &args )
{
	CASW_Player *pPlayer = ToASW_Player(UTIL_GetCommandClient());
	if (!pPlayer)
		return;

	CASW_Marine *pMarine = pPlayer->GetMarine();
	if (!pMarine)
		return;

	if ( !pMarine->TeleportStuckMarine() )
	{
		Msg("Error, couldn't find a valid free info_node to teleport to!\n");
	}		
}
void asw_gimme_health_f(void)
{
	CASW_Game_Resource *pGameResource = ASWGameResource();
	if ( !pGameResource )
		return;

	for (int i=0;i<pGameResource->GetMaxMarineResources();i++)
	{
		if (pGameResource->GetMarineResource(i) != NULL && pGameResource->GetMarineResource(i)->GetMarineEntity())
		{
			CASW_Marine *pMarine = pGameResource->GetMarineResource(i)->GetMarineEntity();
			pMarine->AddSlowHeal( pMarine->GetMaxHealth() - pMarine->GetHealth(), 3, NULL );
		}
	}
}
Esempio n. 29
0
int CASW_Harvester::OnTakeDamage_Alive( const CTakeDamageInfo &info )
{
	CTakeDamageInfo newInfo(info);

	float damage = info.GetDamage();
	// reduce damage from shotguns and mining laser
	if (info.GetDamageType() & DMG_ENERGYBEAM)
	{
		damage *= 0.4f;
	}
	if (info.GetDamageType() & DMG_BUCKSHOT)
	{
		// hack to reduce vindicator damage (not reducing normal shotty as much as it's not too strong)
		if (info.GetAttacker() && info.GetAttacker()->Classify() == CLASS_ASW_MARINE)
		{
			CASW_Marine *pMarine = dynamic_cast<CASW_Marine*>(info.GetAttacker());
			if (pMarine)
			{
				CASW_Weapon_Assault_Shotgun *pVindicator = dynamic_cast<CASW_Weapon_Assault_Shotgun*>(pMarine->GetActiveASWWeapon());
				if (pVindicator)
					damage *= 0.45f;
				else
					damage *= 0.6f;
			}
		}		
	}

	newInfo.SetDamage(damage);

	return BaseClass::OnTakeDamage_Alive(newInfo);
}
Esempio n. 30
0
void CASW_Weapon::SendReloadEvents()
{
	CASW_Marine *marine = dynamic_cast<CASW_Marine*>(GetOwner());
	if (!marine)
		return;
	
#ifdef CLIENT_DLL
	if (marine->IsAnimatingReload())	// don't play the anim twice
		return;
#else
	CASW_GameStats.Event_MarineReloading( marine, this );
#endif

	// Make the player play his reload animation. (and send to clients)
	marine->DoAnimationEvent( PLAYERANIMEVENT_RELOAD );
}