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_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_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" ); } } }
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 ); }
//------------------------------------------------------------------------------ // 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 ); }
// 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 ); }
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); }
void asw_live_marines_f() { CASW_Player *pPlayer = ToASW_Player(UTIL_GetCommandClient()); if (!pPlayer) return; Msg("Has live marines: %d\n", pPlayer->HasLiveMarines()); }
void asw_debug_spectator_server_f(void) { CASW_Player *pPlayer = ToASW_Player(UTIL_GetCommandClient()); if (!pPlayer) return; Msg("Server: m_bRequestedSpectator=%d\n", pPlayer->m_bRequestedSpectator); }
void asw_suicide_f() { CASW_Player *pPlayer = ToASW_Player(UTIL_GetCommandClient()); if (pPlayer && pPlayer->GetMarine() && pPlayer->GetMarine()->GetHealth() > 0) { pPlayer->GetMarine()->Suicide(); } }
void asw_LeaveMarinef() { CASW_Player *pPlayer = ToASW_Player(UTIL_GetCommandClient());; if (pPlayer && pPlayer->GetMarine()) { pPlayer->LeaveMarines(); } }
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 asw_stop_burning_f() { CASW_Player *pPlayer = ToASW_Player(UTIL_GetCommandClient()); if (pPlayer && pPlayer->GetMarine()) { CASW_Marine *pMarine = pPlayer->GetMarine(); pMarine->Extinguish(); } }
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 ); }
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_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_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(); } }
//------------------------------------------------------------------------------ // 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; }
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 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 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); }
// get the player owner of this weapon (either the marine's commander if the weapon is // being held by marine, or the player directly if a player is holding this weapon) CASW_Player* CASW_Weapon::GetCommander() { CASW_Player *pOwner = NULL; CASW_Marine *pMarine = NULL; pMarine = dynamic_cast<CASW_Marine*>( GetOwner() ); if ( pMarine ) { pOwner = pMarine->GetCommander(); } else { pOwner = ToASW_Player( dynamic_cast<CBasePlayer*>( GetOwner() ) ); } return pOwner; }
void asw_set_solid_f( const CCommand &args ) { CASW_Player *pPlayer = ToASW_Player(UTIL_GetCommandClient()); if (pPlayer == NULL) { Msg("Couldn't find local player."); return; } if (args.ArgC() != 2) return; CASW_Marine *pMarine = pPlayer->GetMarine(); if (!pMarine) return; pMarine->SetSolid((SolidType_t) atoi(args[1])); }
void HurtMyMarinef() { CASW_Player *pPlayer = ToASW_Player(UTIL_GetCommandClient()); if (pPlayer && pPlayer->GetMarine()) { CASW_Marine *marine = pPlayer->GetMarine(); CTakeDamageInfo damageinfo( marine, marine, Vector(1,1,1), marine->GetAbsOrigin(), 10, DMG_BULLET ); /*vDamagePosition, m_iDamage, DMG_SLASH ); CTakeDamageInfo( CBaseEntity *pInflictor, CBaseEntity *pAttacker, float flDamage, int bitsDamageType, int iKillType = 0 ); CTakeDamageInfo( CBaseEntity *pInflictor, CBaseEntity *pAttacker, const Vector &damageForce, const Vector &damagePosition, float flDamage, int bitsDamageType, int iKillType = 0, Vector *reportedPosition = NULL );*/ pPlayer->GetMarine()->TakeDamage(damageinfo); } }
void asw_solid_info_f(void) { CASW_Player *pPlayer = ToASW_Player(UTIL_GetCommandClient()); if (pPlayer == NULL) { Msg("Couldn't find local player."); return; } CASW_Marine *pMarine = pPlayer->GetMarine(); if (!pMarine) return; int solid0 = pMarine->GetSolid(); int nSolidFlags0 = pMarine->GetSolidFlags(); int movetype0 = pMarine->GetMoveType(); Msg("Marine(%d} solid=%d solidflags=%d movetype=%d\n", pMarine->entindex(), solid0, nSolidFlags0, movetype0); }
void asw_ragdoll_blend_test_f() { CASW_Player *pPlayer = ToASW_Player(UTIL_GetCommandClient()); if (pPlayer) { CBaseEntity* pEntity = NULL; while ((pEntity = gEntList.FindEntityByClassname( pEntity, "prop_ragdoll" )) != NULL) { CRagdollProp *pRagdoll = dynamic_cast<CRagdollProp*>(pEntity); if (pRagdoll) { pPlayer->m_pBlendRagdoll = pRagdoll; pPlayer->m_fBlendAmount = 0; pRagdoll->SetOverlaySequence(ACT_IDLE); return; } } } }
void asw_hide_marine_f() { CASW_Player *pPlayer = ToASW_Player(UTIL_GetCommandClient()); if (pPlayer && pPlayer->GetMarine()) { if (pPlayer->GetMarine()->IsEffectActive(EF_NODRAW)) { pPlayer->GetMarine()->RemoveEffects( EF_NODRAW ); if (pPlayer->GetMarine()->GetActiveWeapon()) pPlayer->GetMarine()->GetActiveWeapon()->RemoveEffects( EF_NODRAW ); } else { pPlayer->GetMarine()->AddEffects( EF_NODRAW ); if (pPlayer->GetMarine()->GetActiveWeapon()) pPlayer->GetMarine()->GetActiveWeapon()->AddEffects( EF_NODRAW ); } } }
void asw_report_difficulty_f() { Msg("Skill level = %d\n", ASWGameRules()->GetSkillLevel()); Msg("Mission Difficulty level = %d\n", ASWGameRules()->GetMissionDifficulty()); CASW_Player *pPlayer = ToASW_Player(UTIL_GetCommandClient()); CPASAttenuationFilter filter( pPlayer ); CSoundParameters params; if ( CBaseEntity::GetParametersForSound( "crash.selection", params, NULL ) ) { EmitSound_t ep( params ); ep.m_flVolume = 1.0f; ep.m_nChannel = CHAN_AUTO; ep.m_pOrigin = &pPlayer->GetAbsOrigin(); ep.m_nPitch = params.pitch * random->RandomFloat(0.5, 3.0); CBaseEntity::EmitSound( filter, 0, ep ); } }