//------------------------------------------------------------------------------
// Purpose: Create an NPC of the given type
//------------------------------------------------------------------------------
void CC_ASW_Ent_Create( const CCommand& args )
{
	MDLCACHE_CRITICAL_SECTION();

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

	// Try to create entity
	CBaseEntity *entity = dynamic_cast< CBaseEntity * >( CreateEntityByName(args[1]) );
	if (entity)
	{
		entity->Precache();		

		// Now attempt to drop into the world
		CASW_Player* pPlayer = ToASW_Player( UTIL_GetCommandClient() );
		if (!pPlayer)
			return;

		trace_t tr;
		UTIL_TraceLine( pPlayer->GetCrosshairTracePos() + Vector( 0, 0, 30 ),
			pPlayer->GetCrosshairTracePos(), MASK_SOLID, 
			pPlayer, COLLISION_GROUP_NONE, &tr );

		if ( tr.fraction != 0.0 )
		{
			// Raise the end position a little up off the floor, place the npc and drop him down
			tr.endpos.z += 12;
			entity->Teleport( &tr.endpos, NULL, NULL );
			// this was causing aliens to spawn under ground 
			//UTIL_DropToFloor( entity, MASK_SOLID );
		}
		DispatchSpawn(entity);
	}
	CBaseEntity::SetAllowPrecache( allowPrecache );
}
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;
		}
	}
}
void asw_marine_spectate_f(const CCommand &args)
{
	CASW_Player *pPlayer = ToASW_Player(UTIL_GetCommandClient());
	if ( args.ArgC() < 2 )
	{
		Msg( "Usage: asw_marine_spectate [marine_num]\n" );
		return;
	}

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

	int iMarine = atof(args[1]);
	if (iMarine < 0 || iMarine >= pGameResource->GetMaxMarineResources())
		return;

	CASW_Marine_Resource* pMR = pGameResource->GetMarineResource(iMarine);
	if (!pMR)
	{
		Msg("No marine resource in that index\n");
		return;
	}

	CASW_Marine *pMarine = pMR->GetMarineEntity();
	if (!pMarine)
	{
		Msg("No live marine in that slot\n");
		return;
	}
		
	pPlayer->SetSpectatingMarine(pMarine);
}
// 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 );
}
Beispiel #5
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CASW_Prediction::SetupMove( C_BasePlayer *player, CUserCmd *ucmd, IMoveHelper *pHelper, 
	CMoveData *move )
{
	// Call the default SetupMove code.
	BaseClass::SetupMove( player, ucmd, pHelper, move );
	
	CASW_Player *pASWPlayer = static_cast<CASW_Player*>( player );
	if ( !asw_allow_detach.GetBool() )
	{		
		if ( pASWPlayer && pASWPlayer->GetMarine() )
		{
			// this forces horizontal movement
			move->m_vecAngles.x = 0;
			move->m_vecViewAngles.x = 0;
		}
	}

	CBaseEntity *pMoveParent = player->GetMoveParent();
	if (!pMoveParent)
	{
		move->m_vecAbsViewAngles = move->m_vecViewAngles;
	}
	else
	{
		matrix3x4_t viewToParent, viewToWorld;
		AngleMatrix( move->m_vecViewAngles, viewToParent );
		ConcatTransforms( pMoveParent->EntityToWorldTransform(), viewToParent, viewToWorld );
		MatrixAngles( viewToWorld, move->m_vecAbsViewAngles );
	}
	CASW_MoveData *pASWMove = static_cast<CASW_MoveData*>( move );
	pASWMove->m_iForcedAction = ucmd->forced_action;
	// setup trace optimization
	g_pGameMovement->SetupMovementBounds( move );
}
void asw_test_turret_f()
{
	CASW_Player *pPlayer = ToASW_Player(UTIL_GetCommandClient());
	
	if (pPlayer && pPlayer->GetMarine())
	{
		CASW_Marine *pMarine = pPlayer->GetMarine();
		if (pMarine->m_hRemoteTurret.Get())
		{
			pMarine->m_hRemoteTurret->StopUsingTurret();//m_hUser = NULL;
			pMarine->m_hRemoteTurret = NULL;
			return;
		}
		CBaseEntity* pEntity = NULL;
		while ((pEntity = gEntList.FindEntityByClassname( pEntity, "asw_remote_turret" )) != NULL)
		{
			CASW_Remote_Turret* pTurret = dynamic_cast<CASW_Remote_Turret*>(pEntity);			
			if (pTurret)
			{
				pTurret->StartedUsingTurret(pMarine);
				pMarine->m_hRemoteTurret = pTurret;
				Msg("Set turret\n");
				return;
			}
		}
	}	
	Msg("Failed to find a turret\n");
}
void asw_room_info_f()
{
	CASW_Player *pPlayer = ToASW_Player(UTIL_GetCommandClient());
	if ( pPlayer && pPlayer->GetMarine() && missionchooser && missionchooser->RandomMissions() )
	{
		IASW_Room_Details *pRoom = missionchooser->RandomMissions()->GetRoomDetails( pPlayer->GetMarine()->GetAbsOrigin() );
		if ( !pRoom )
		{
			Msg(" Couldn't find room\n" );
		}
		else
		{
			char buf[MAX_PATH];
			pRoom->GetFullRoomName( buf, MAX_PATH );
			Msg( " Room name: %s\n", buf );
			Msg( " Room tags: " );
			int nNumTags = pRoom->GetNumTags();
			for ( int i = 0; i < nNumTags; ++ i )
			{
				Msg( "%s    ", pRoom->GetTag( i ) );
			}
			Msg( "\n" );
		}
	}
}
Beispiel #8
0
void asw_path_end_f()
{
	CASW_Player *pPlayer = ToASW_Player(UTIL_GetCommandClient());
	if ( !pPlayer || !ASWPathUtils() )
		return;

	if ( !pPlayer->GetMarine() )
		return;

	Vector vecPathEnd = pPlayer->GetMarine()->GetAbsOrigin();
	debugoverlay->AddBoxOverlay( g_vecPathStart, Vector(-10, -10, -10 ), Vector(10, 10, 10) , vec3_angle, 255, 0, 0, 255, 30.0f );
	debugoverlay->AddBoxOverlay( vecPathEnd, Vector(-10, -10, -10 ), Vector(10, 10, 10) , vec3_angle, 255, 255, 0, 255, 30.0f );

	AI_Waypoint_t *pWaypoint = ASWPathUtils()->BuildRoute( g_vecPathStart, vecPathEnd, NULL, 100, NAV_NONE, bits_BUILD_GET_CLOSE );
	if ( !pWaypoint )
	{
		Msg( "Failed to find route\n" );
		return;
	}

	if ( UTIL_ASW_DoorBlockingRoute( pWaypoint, true ) )
	{
		Msg(" Route blocked by sealed/locked door\n" );
	}

	ASWPathUtils()->DebugDrawRoute( g_vecPathStart, pWaypoint );
}
void asw_live_marines_f()
{
	CASW_Player *pPlayer = ToASW_Player(UTIL_GetCommandClient());
	if (!pPlayer)
		return;

	Msg("Has live marines: %d\n", pPlayer->HasLiveMarines());
}
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;
}
void asw_suicide_f()
{
	CASW_Player *pPlayer = ToASW_Player(UTIL_GetCommandClient());
		
	if (pPlayer && pPlayer->GetMarine() && pPlayer->GetMarine()->GetHealth() > 0)
	{
		pPlayer->GetMarine()->Suicide();
	}
}
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_LeaveMarinef()
{
	CASW_Player *pPlayer = ToASW_Player(UTIL_GetCommandClient());;

	if (pPlayer && pPlayer->GetMarine())
	{
		pPlayer->LeaveMarines();
	}
}
void asw_stop_burning_f()
{
	CASW_Player *pPlayer = ToASW_Player(UTIL_GetCommandClient());
	
	if (pPlayer && pPlayer->GetMarine())
	{
		CASW_Marine *pMarine = pPlayer->GetMarine();
		pMarine->Extinguish();
	}
}
void asw_build_speech_durations_f()
{
	CASW_Player *pPlayer = ToASW_Player(UTIL_GetCommandClient());	
	
	if (!pPlayer || !MarineProfileList() || !pPlayer->GetMarine())
		return;
	Msg("Saving speech durations...");
	MarineProfileList()->SaveSpeechDurations(pPlayer->GetMarine());
	Msg("Done!\n");
}
void ShootMe()
{
	CASW_Player *pPlayer = ToASW_Player(UTIL_GetCommandClient());
	if ( pPlayer->GetMarine() )
	{
		CTakeDamageInfo dmgInfo( pPlayer, pPlayer, 3, DMG_BULLET );
		Vector vecDir = RandomVector(-1, 1);
		trace_t tr;
		pPlayer->GetMarine()->DispatchTraceAttack( dmgInfo, vecDir, &tr );
	}
}
void ASW_PhysicsShove_f()
{
	CASW_Player *pPlayer = ToASW_Player(UTIL_GetCommandClient());
	
	if (pPlayer && pPlayer->GetMarine())
	{
		if (pPlayer->GetMarine()->GetFlags() & FL_FROZEN)	// don't allow this if the marine is frozen
			return;
		pPlayer->GetMarine()->PhysicsShove();
	}
}
void CASW_Button_Area::ActivateUnlockedButton(CASW_Marine* pMarine)
{
	// don't use the button if we're in the delay between using
	if ( m_fLastButtonUseTime != 0 && gpGlobals->curtime < m_fLastButtonUseTime + m_flWait )
		return;
	if ( !pMarine )
		return;

	if( !RequirementsMet( pMarine ) )
		return;

	if ( m_bIsDoorButton )
	{
		// if the door isn't sealed (or greater than a certain amount of damage?)
		//  then make it open
		CASW_Door* pDoor = GetDoor();
		if ( pDoor )
		{
			if (pDoor->GetSealAmount() > 0)
			{
				//Msg("Door mechanism not responding.  Maintenance Division has been notified of the problem.\n");
			}
			else
			{				
				//Msg("Toggling door...\n");
				variant_t emptyVariant;
				pDoor->AcceptInput("Toggle", pMarine, this, emptyVariant, 0);
			}
		}
	}

	// send our 'activated' output
	m_OnButtonActivated.FireOutput(pMarine, this);

	// Fire event
	IGameEvent * event = gameeventmanager->CreateEvent( "button_area_used" );
	if ( event )
	{
		CASW_Player *pPlayer = pMarine->GetCommander();

		event->SetInt( "userid", ( pPlayer ? pPlayer->GetUserID() : 0 ) );
		event->SetInt( "entindex", entindex() );
		gameeventmanager->FireEvent( event );
	}

	m_fLastButtonUseTime = gpGlobals->curtime;

	UpdateWaitingForInput();

	if ( m_bDisableAfterUse )
	{
		UTIL_Remove(this);
	}
}
Beispiel #19
0
void asw_path_start_f()
{
	CASW_Player *pPlayer = ToASW_Player(UTIL_GetCommandClient());
	if ( !pPlayer || !ASWPathUtils() )
		return;

	if ( !pPlayer->GetMarine() )
		return;
	
	g_vecPathStart = pPlayer->GetMarine()->GetAbsOrigin();
}
void asw_debug_server_cursor_f( const CCommand& args )
{
	MDLCACHE_CRITICAL_SECTION();

	// Now attempt to drop into the world
	CASW_Player* pPlayer = ToASW_Player(UTIL_GetCommandClient());
	if (!pPlayer)
		return;

	NDebugOverlay::Cross3D( pPlayer->GetCrosshairTracePos(), 20.0f, 255, 128, 0, true, 1.0f );
}
Beispiel #21
0
int ASW_GiveAmmo( CASW_Marine *pMarine, float flCount, const char *pszAmmoName, CBaseEntity *pAmmoEntity, bool bSuppressSound = false )
{
	int iAmmoType = GetAmmoDef()->Index(pszAmmoName);
	if ( iAmmoType == -1 )
	{
		Msg("ERROR: Attempting to give unknown ammo type (%s)\n",pszAmmoName);
		return 0;
	}

	int amount = pMarine->GiveAmmo( flCount, iAmmoType, bSuppressSound );
	if ( amount == 0 )
		amount = pMarine->GiveAmmoToAmmoBag( flCount, iAmmoType, bSuppressSound );

	if ( amount > 0 )
	{
		pMarine->TookAmmoPickup( pAmmoEntity );

		// Check the ammo type... for some doing a spilling bullet effect isn't fictionally appropriate
		if ( iAmmoType != GetAmmoDef()->Index( "ASW_F" ) && iAmmoType != GetAmmoDef()->Index( "ASW_ML" ) && iAmmoType != GetAmmoDef()->Index( "ASW_TG" ) && iAmmoType != GetAmmoDef()->Index( "ASW_GL" ) )
		{
			// Do effects
			int iAmmoCost = CASW_Ammo_Drop_Shared::GetAmmoUnitCost( iAmmoType );

			if ( iAmmoCost < 20 )
			{
				pAmmoEntity->EmitSound( "ASW_Ammobag.Pickup_sml" );
				DispatchParticleEffect( "ammo_satchel_take_sml", pAmmoEntity->GetAbsOrigin() + Vector( 0, 0, 4 ), vec3_angle );
			}
			else if ( iAmmoCost < 75 )
			{
				pAmmoEntity->EmitSound( "ASW_Ammobag.Pickup_med" );
				DispatchParticleEffect( "ammo_satchel_take_med", pAmmoEntity->GetAbsOrigin() + Vector( 0, 0, 4 ), vec3_angle );
			}
			else
			{
				pAmmoEntity->EmitSound( "ASW_Ammobag.Pickup_lrg" );
				DispatchParticleEffect( "ammo_satchel_take_lrg", pAmmoEntity->GetAbsOrigin() + Vector( 0, 0, 4 ), vec3_angle );
			}
		}

		IGameEvent * event = gameeventmanager->CreateEvent( "ammo_pickup" );
		if ( event )
		{
			CASW_Player *pPlayer = pMarine->GetCommander();
			event->SetInt( "userid", ( pPlayer ? pPlayer->GetUserID() : 0 ) );
			event->SetInt( "entindex", pMarine->entindex() );

			gameeventmanager->FireEvent( event );
		}
	}

	return amount;
}
Beispiel #22
0
void CASW_Weapon::DiffPrint(  char const *fmt, ... )
{
	CASW_Player *pPlayer = GetCommander();
	if ( !pPlayer )
		return;

	va_list		argptr;
	char		string[1024];
	va_start (argptr,fmt);
	Q_vsnprintf(string, sizeof( string ), fmt,argptr);
	va_end (argptr);

	::DiffPrint( CBaseEntity::IsServer(), pPlayer->CurrentCommandNumber(), "%s", string );
}
//------------------------------------------------------------------------------
// Purpose: Teleport a specified entity to where the player is looking
//------------------------------------------------------------------------------
bool CC_ASW_GetCommandEnt( const CCommand& args, CBaseEntity **ent, Vector *vecTargetPoint, QAngle *vecPlayerAngle )
{
	// Find the entity
	*ent = NULL;
	// First try using it as an entindex
	int iEntIndex = atoi( args[1] );
	if ( iEntIndex )
	{
		*ent = CBaseEntity::Instance( iEntIndex );
	}
	else
	{
		// Try finding it by name
		*ent = gEntList.FindEntityByName( NULL, args[1] );

		if ( !*ent )
		{
			// Finally, try finding it by classname
			*ent = gEntList.FindEntityByClassname( NULL, args[1] );
		}
	}

	if ( !*ent )
	{
		Msg( "Couldn't find any entity named '%s'\n", args[1] );
		return false;
	}

	CASW_Player *pPlayer = ToASW_Player( UTIL_GetCommandClient() );
	if ( vecTargetPoint )
	{
		trace_t tr;
		UTIL_TraceLine( pPlayer->GetCrosshairTracePos() + Vector( 0, 0, 30 ),
			pPlayer->GetCrosshairTracePos() - Vector( 0, 0, 10 ), MASK_SOLID, 
			pPlayer, COLLISION_GROUP_NONE, &tr );

		if ( tr.fraction != 1.0 )
		{
			*vecTargetPoint = tr.endpos;
		}
	}

	if ( vecPlayerAngle )
	{
		*vecPlayerAngle = pPlayer->EyeAngles();
	}

	return true;
}
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_asw_inventory()
{
	CASW_Player *pPlayer = ToASW_Player(UTIL_GetCommandClient());
	if ( pPlayer->GetMarine() )
	{
		for (int i=0;i<pPlayer->GetMarine()->WeaponCount();i++)
		{
			CBaseEntity *pWeapon = pPlayer->GetMarine()->GetWeapon(i);
			if ( pWeapon )
			{
				Msg(" Inventory[%d] = %s (%d)\n", i, pWeapon->GetClassname(), pWeapon->entindex() );
			}
		}
	}
}
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 CASW_Campaign_Save::UpdateLastCommanders()
{
	// save which marines the players have selected
	// add which marines he has selected
	CASW_Game_Resource *pGameResource = ASWGameResource();
	if ( !pGameResource )
		return;

	// first check there were some marines selected (i.e. we're not in the campaign lobby map)
	int iNumMarineResources = 0;
	for (int i=0;i<pGameResource->GetMaxMarineResources();i++)
	{
		if (pGameResource->GetMarineResource(i))
			iNumMarineResources++;
	}
	if ( iNumMarineResources <= 0 )
		return;
	
	char buffer[256];
	for (int i=0;i<ASW_NUM_MARINE_PROFILES;i++)
	{
		// look for a marine info for this marine
		bool bFound = false;
		for (int k=0;k<pGameResource->GetMaxMarineResources();k++)
		{
			CASW_Marine_Resource *pMR = pGameResource->GetMarineResource(k);
			if (pMR && pMR->GetProfileIndex() == i && pMR->GetCommander())
			{
				CASW_Player *pPlayer = pMR->GetCommander();
				if (pPlayer)
				{
					// store the commander who has this marine
					Q_snprintf(buffer, sizeof(buffer), "%s%s",pPlayer->GetPlayerName(), pPlayer->GetASWNetworkID());
					m_LastCommanders[i] = AllocPooledString(buffer);
					m_LastMarineResourceSlot[i] = k;
					m_LastPrimaryMarines[i] = pPlayer->IsPrimaryMarine(i);
					bFound = true;
					break;
				}
			}
		}
		if (!bFound)
		{
			m_LastCommanders[i] = AllocPooledString("");
			m_LastMarineResourceSlot[i] = 0;
		}
	}
}
void asw_ragdoll_marine_f()
{
	CASW_Player *pPlayer = ToASW_Player(UTIL_GetCommandClient());
	static CRagdollProp * s_pRagdoll = NULL;

	if (pPlayer && pPlayer->GetMarine())
	{
		CASW_Marine* pMarine = pPlayer->GetMarine();
		pMarine->SetKnockedOut(!pMarine->m_bKnockedOut);

		return;
		
		if (pMarine->IsEffectActive(EF_NODRAW) && s_pRagdoll)
		{
			//Calcs the diff between ragdoll worldspace center and victim worldspace center, moves the victim by this diff.
			//Sets the victim's angles to 0, ragdoll yaw, 0
			QAngle newAngles( 0, s_pRagdoll->GetAbsAngles()[YAW], 0 );

			Vector centerDelta = s_pRagdoll->WorldSpaceCenter() - pMarine->WorldSpaceCenter();
			centerDelta.z = 0;	// don't put us in the floor
			Vector newOrigin = pMarine->GetAbsOrigin() + centerDelta;
			pMarine->SetAbsOrigin( newOrigin );
			pMarine->SetAbsAngles( newAngles );
			//DetachAttachedRagdoll( s_pRagdoll ); 	// unnecessary since we remove it next?
			UTIL_Remove( s_pRagdoll );
			pMarine->RemoveEffects( EF_NODRAW );
			pMarine->RemoveSolidFlags( FSOLID_NOT_SOLID );
		}
		else
		{
			pMarine->InvalidateBoneCache();
			pMarine->AddSolidFlags( FSOLID_NOT_SOLID );			
			CTakeDamageInfo	info;
			info.SetDamageType( DMG_GENERIC );
			info.SetDamageForce( vec3_origin );
			info.SetDamagePosition( pMarine->WorldSpaceCenter() );
			s_pRagdoll = (CRagdollProp*) CreateServerRagdoll( pMarine, 0, info, COLLISION_GROUP_NONE );
			if ( s_pRagdoll )
			{
				s_pRagdoll->DisableAutoFade();
				s_pRagdoll->SetThink( NULL );
				s_pRagdoll->SetUnragdoll( pMarine );
			}			
			pMarine->AddEffects( EF_NODRAW );
			//pMarine->SetupBones( m_pRagdollBones, BONE_USED_BY_ANYTHING );
		}
	}
}
void asw_conversation_f(const CCommand &args)
{
	CASW_Player *pPlayer = ToASW_Player(UTIL_GetCommandClient());
	if (!pPlayer)
		return;
	
	CASW_Marine *pMarine = pPlayer->GetMarine();
	if (!pMarine)
		return;

	if (args.ArgC() < 2)
	{
		Msg("Usage: asw_conversation [conversation number]\n");
	}
	int iConv = atoi(args[1]);
	CASW_MarineSpeech::StartConversation(iConv, pMarine);
}
void asw_test_marinenearby_f(const CCommand &args)
{
	Msg("0.5 as float = %f\n", 0.5f);
	Msg("0.5f as int = %d\n", (int) 0.5f);
	Msg("0.51f as int = %d\n", (int) 0.51f);
	Msg("0.52f as int = %d\n", (int) 0.52f);
	Msg("0.6f as int = %d\n", (int) 0.6f);
	Msg("0.56f as int = %d\n", (int) 0.56f);
	Msg("0.49f as int = %d\n", (int) 0.49f);
	Msg("1.99f as int = %d\n", (int) 1.99f);
	Msg("2.01f as int = %d\n", (int) 2.01f);
	CASW_Player *pPlayer = ToASW_Player(UTIL_GetCommandClient());	

	if (!ASWGameRules())
		return;
	if (!pPlayer || !pPlayer->GetMarine())
		return;
	
	if ( args.ArgC() < 4 )
	{
		Msg("Usage: asw_test_marinenearby [0|1] [grid step] [grid count]\n");
	}
	int iWide = atoi(args[1]);
	float fGridStep = atof(args[2]);
	int iGridCount = atoi(args[3]);
	//Msg("Wide = %d, step = %f, count = %d\n", iWide, fGridStep, iGridCount);

	Vector asw_default_camera_dir_2;
	QAngle test_angle(asw_marine_nearby_angle.GetFloat(), 90, 0);
	AngleVectors(test_angle, &asw_default_camera_dir_2);
	Vector asw_default_camera_offset_2 = asw_default_camera_dir_2 * -405.0f;

	for (int x=-iGridCount;x<iGridCount;x++)
	{
		for (int y=-iGridCount;y<iGridCount*3;y++)
		{
			Vector pos = pPlayer->GetMarine()->GetAbsOrigin() + Vector(x * fGridStep, y*fGridStep, 10);
			//Msg("Testing pos %f, %f, %f\n", pos.x, pos.y, pos.z);
			bool bCorpseCanSee = false;
			UTIL_ASW_AnyMarineCanSee(pos,
				iWide, bCorpseCanSee);
		}
	}	
	Vector pos = (pPlayer->GetMarine()->GetAbsOrigin() + asw_default_camera_offset_2);
	//NDebugOverlay::Line(pos, pos + asw_default_camera_dir_2 * 410, 0,0,255,true, 30);
}