diff --git a/.gitignore b/.gitignore index fc01c5fab..5df106f44 100644 --- a/.gitignore +++ b/.gitignore @@ -49,12 +49,25 @@ server.dylib server.dylib.dSYM/ # files generated by running a mod +graphs/ +downloadlists/ config.cfg +ep1_gamestats.dat +server_blacklist.txt +demoheader.tmp +stats.txt +gamestate.txt + +# files generated by Hammer editor +albedo.tga +normal.tga # shader files *.tmp +editor_config.txt *.filters *.vpc_crc *.pdb *.sentinel +*.lib diff --git a/mp/src/game/client/detailobjectsystem.cpp b/mp/src/game/client/detailobjectsystem.cpp index 3e211bb03..7275c8608 100644 --- a/mp/src/game/client/detailobjectsystem.cpp +++ b/mp/src/game/client/detailobjectsystem.cpp @@ -1471,25 +1471,6 @@ void CDetailObjectSystem::LevelInitPreEntity() } } - if ( m_DetailObjects.Count() || m_DetailSpriteDict.Count() ) - { - // There are detail objects in the level, so precache the material - PrecacheMaterial( DETAIL_SPRITE_MATERIAL ); - IMaterial *pMat = m_DetailSpriteMaterial; - // adjust for non-square textures (cropped) - float flRatio = (float)( pMat->GetMappingWidth() ) / pMat->GetMappingHeight(); - if ( flRatio > 1.0 ) - { - for( int i = 0; iGetHDRType() != HDR_TYPE_NONE ) { @@ -1512,13 +1493,30 @@ void CDetailObjectSystem::LevelInitPreEntity() void CDetailObjectSystem::LevelInitPostEntity() { - const char *pDetailSpriteMaterial = DETAIL_SPRITE_MATERIAL; - C_World *pWorld = GetClientWorldEntity(); - if ( pWorld && pWorld->GetDetailSpriteMaterial() && *(pWorld->GetDetailSpriteMaterial()) ) + if ( m_DetailObjects.Count() || m_DetailSpriteDict.Count() ) { - pDetailSpriteMaterial = pWorld->GetDetailSpriteMaterial(); + const char *pDetailSpriteMaterial = DETAIL_SPRITE_MATERIAL; + C_World *pWorld = GetClientWorldEntity(); + if ( pWorld && pWorld->GetDetailSpriteMaterial() && *(pWorld->GetDetailSpriteMaterial()) ) + pDetailSpriteMaterial = pWorld->GetDetailSpriteMaterial(); + + m_DetailSpriteMaterial.Init( pDetailSpriteMaterial, TEXTURE_GROUP_OTHER ); + PrecacheMaterial( pDetailSpriteMaterial ); + IMaterial *pMat = m_DetailSpriteMaterial; + + // adjust for non-square textures (cropped) + float flRatio = pMat->GetMappingWidth() / pMat->GetMappingHeight(); + if ( flRatio > 1.0 ) + { + for( int i = 0; i(this); - IPhysicsObject *pPhysicsObject = physenv->CreateSphereObject( 12, 0, GetAbsOrigin(), GetAbsAngles(), ¶ms, false ); + IPhysicsObject *pPhysicsObject = physenv->CreateSphereObject( m_fRadius, GetModelPtr()->GetRenderHdr()->textureindex, GetAbsOrigin(), GetAbsAngles(), ¶ms, false ); + if ( pPhysicsObject ) { VPhysicsSetObject( pPhysicsObject ); SetMoveType( MOVETYPE_VPHYSICS ); pPhysicsObject->Wake(); } - + return true; } }; + +LINK_ENTITY_TO_CLASS( prop_sphere, CPhysSphere ); + +BEGIN_DATADESC( CPhysSphere ) + DEFINE_KEYFIELD( m_fRadius, FIELD_FLOAT, "radius"), +END_DATADESC() void CPropDoorRotating::InputSetSpeed(inputdata_t &inputdata) { @@ -5460,8 +5469,6 @@ void CPropDoorRotating::InputSetSpeed(inputdata_t &inputdata) DoorResume(); } -LINK_ENTITY_TO_CLASS( prop_sphere, CPhysSphere ); - // ------------------------------------------------------------------------------------------ // // Special version of func_physbox. diff --git a/mp/src/game/shared/Multiplayer/multiplayer_animstate.cpp b/mp/src/game/shared/Multiplayer/multiplayer_animstate.cpp index 2734eba02..e1b8b000e 100644 --- a/mp/src/game/shared/Multiplayer/multiplayer_animstate.cpp +++ b/mp/src/game/shared/Multiplayer/multiplayer_animstate.cpp @@ -845,7 +845,7 @@ bool CMultiPlayerAnimState::HandleSwimming( Activity &idealActivity ) m_bFirstSwimFrame = false; } - idealActivity = ACT_MP_SWIM; + idealActivity = ACT_MP_RUN; m_bInSwim = true; return true; } diff --git a/mp/src/game/shared/hl2mp/weapon_hl2mpbase.cpp b/mp/src/game/shared/hl2mp/weapon_hl2mpbase.cpp index 15995a5be..e87d88625 100644 --- a/mp/src/game/shared/hl2mp/weapon_hl2mpbase.cpp +++ b/mp/src/game/shared/hl2mp/weapon_hl2mpbase.cpp @@ -206,6 +206,31 @@ int CWeaponHL2MPBase::ObjectCaps() #endif +#ifdef GAME_DLL +void CWeaponHL2MPBase::FallThink(void) +{ + // Prevent the common HL2DM weapon respawn bug from happening + // When a weapon is spawned, the following chain of events occurs: + // - Spawn() is called (duh), which then calls FallInit() + // - FallInit() is called, and prepares the weapon's 'Think' function (CBaseCombatWeapon::FallThink()) + // - FallThink() is called, and performs several checks before deciding whether the weapon should Materialize() + // - Materialize() is called (the HL2DM version above), which sets the weapon's respawn location. + // The problem occurs when a weapon isn't placed properly by a level designer. + // If the weapon is unable to move from its location (e.g. if its bounding box is halfway inside a wall), Materialize() never gets called. + // Since Materialize() never gets called, the weapon's respawn location is never set, so if a person picks it up, it respawns forever at + // 0 0 0 on the map (infinite loop of fall, wait, respawn, not nice at all for performance and bandwidth!) + if ( HasSpawnFlags( SF_NORESPAWN ) == false ) + { + if ( GetOriginalSpawnOrigin() == vec3_origin ) + { + m_vOriginalSpawnOrigin = GetAbsOrigin(); + m_vOriginalSpawnAngles = GetAbsAngles(); + } + } + return BaseClass::FallThink(); +} +#endif // GAME_DLL + void CWeaponHL2MPBase::FallInit( void ) { #ifndef CLIENT_DLL @@ -262,7 +287,7 @@ void CWeaponHL2MPBase::FallInit( void ) SetPickupTouch(); - SetThink( &CBaseCombatWeapon::FallThink ); + SetThink( &CWeaponHL2MPBase::FallThink ); SetNextThink( gpGlobals->curtime + 0.1f ); diff --git a/mp/src/game/shared/hl2mp/weapon_hl2mpbase.h b/mp/src/game/shared/hl2mp/weapon_hl2mpbase.h index 0f21044b1..056a573d3 100644 --- a/mp/src/game/shared/hl2mp/weapon_hl2mpbase.h +++ b/mp/src/game/shared/hl2mp/weapon_hl2mpbase.h @@ -45,6 +45,8 @@ public: void Materialize( void ); virtual int ObjectCaps( void ); + + virtual void FallThink( void ); // make the weapon fall to the ground after spawning #endif // All predicted weapons need to implement and return true diff --git a/sp/game/sdk2013CE/bin/game_shader_generic_eshader_2007.dll b/sp/game/sdk2013CE/bin/game_shader_generic_eshader_2007.dll deleted file mode 100644 index 6d872d454..000000000 Binary files a/sp/game/sdk2013CE/bin/game_shader_generic_eshader_2007.dll and /dev/null differ diff --git a/sp/game/sdk2013CE/bin/game_shader_generic_eshader_swarm.dll b/sp/game/sdk2013CE/bin/game_shader_generic_eshader_swarm.dll deleted file mode 100644 index d20a91979..000000000 Binary files a/sp/game/sdk2013CE/bin/game_shader_generic_eshader_swarm.dll and /dev/null differ diff --git a/sp/game/sdk2013CE/bin/shadereditor_swarm.dll b/sp/game/sdk2013CE/bin/shadereditor_swarm.dll deleted file mode 100644 index c5296a553..000000000 Binary files a/sp/game/sdk2013CE/bin/shadereditor_swarm.dll and /dev/null differ diff --git a/sp/game/sdk2013CE/sdk2013ce.fgd b/sp/game/sdk2013CE/sdk2013ce.fgd index e3bf6e155..2730b6816 100644 --- a/sp/game/sdk2013CE/sdk2013ce.fgd +++ b/sp/game/sdk2013CE/sdk2013ce.fgd @@ -70,4 +70,78 @@ 0 : "No" 1 : "Yes" ] -] \ No newline at end of file +] + +// lightprop("models/editor/spot.mdl") <---- use this once the orientation is unfucked +@PointClass base(Targetname, Parentname, Angles) size(-2 -2 -2, 2 2 2) frustum(lightfov,nearz,farz,lightcolor,-1) = env_projectedtexture : + "Projected texture entity." +[ + spawnflags(flags) = + [ + 1 : "Enabled" : 1 + ] + + target(target_destination) : "target" : : "target" + lightfov(float) : "FOV" : "90.0" : "FOV" + nearz(float) : "NearZ" : "4.0" : "Near Z for projected texture" + farz(float) : "FarZ" : "750.0" : "Far Z for projected texture" + + enableshadows(Choices) : "Enable Shadows" : 0 : "Enables/disables shadows from this projected texture." = + [ + 0 : "No" + 1 : "Yes" + ] + shadowquality(Choices) : "Shadow Quality" : 1 : "Quality of shadows." = + [ + 0 : "Low" + 1 : "High" + ] + lightonlytarget(Choices) : "Light Only Target" : 0 : "Limit flashlight effect to only effect target entity." = + [ + 0 : "No" + 1 : "Yes" + ] + lightworld(Choices) : "Light World" : 1 : "Control whether flashlight effects static world geometry." = + [ + 0 : "No" + 1 : "Yes" + ] + lightcolor(color255) : "Light Color" : "255 255 255 200" : "Light Color RGB-Intensity" + cameraspace(integer) : "Camera Space" : 0 : "Angles are interpreted as being relative to camera." + texturename(material) : "Texture" : : "path/texture to be projected. Relative to main/materials/" + + // Inputs + input TurnOn(void) : "Turn on the texture" + input TurnOff(void) : "Turn off the texture" + input SetFOV(float) : "Set FOV" +] + +@NPCClass base(BaseNPC) studio("models/missile_defense.mdl") = npc_missiledefense : "A turret who takes down rockets from the player" +[ + spawnflags(flags) = + [ + 65536 : "Vulnerable to bullets" : 0 + ] + + Health(Integer) : "Health" : 10 + TurretModel(studio) : "Turret Model" : "models/missile_defense.mdl" + GibModel(studio) : "Gib Model" : "models/gibs/manhack_gib01.mdl" + FireSound(sound) : "Fire Sound" : "npc/turret_floor/shoot1.wav" + RotateSound(sound) : "Rotate Sound": "npc/turret_floor/ping.wav" + ReloadSound(sound) : "Reload Sound": "vehicles/tank_readyfire1.wav" + + StartOn(choices) : "Start On" : 1 = + [ + 0 : "No" + 1 : "Yes" + ] + + // Inputs + input TurnOn(void) : "Turn on: Look for enemies" + input TurnOff(void) : "Turn off: Stop looking for enemies" +] + +@PointClass base(BasePropPhysics, RenderFields) studioprop() sphere(radius) = prop_sphere : "Creates a perfect sphere." +[ + radius(float) : "Radius" : 12 : "" +] diff --git a/sp/run.bat b/sp/run.bat index 367dc66e5..8ab651959 100644 --- a/sp/run.bat +++ b/sp/run.bat @@ -1 +1,35 @@ -@start /D "%ProgramFiles(x86)%\Steam\steamapps\common\Source SDK Base 2013 Singleplayer" hl2.exe -dev -console -novid -game "%CD%\game\sdk2013CE" \ No newline at end of file +@echo off +setlocal ENABLEDELAYEDEXPANSION + +rem Getting Steam path from registry +rem for /F "usebackq tokens=2*" %%I in (`reg query "HKCU\Software\Valve\Steam"^|find /I "SteamPath"`) do set steampath=%%J +for /f "usebackq tokens=1,2,*" %%i in (`reg query "HKCU\Software\Valve\Steam" /v "SteamPath"`) do set "steampath=%%~k" +rem Since this is loop, we cannot use ERRORLEVEL here +rem if not ERRORLEVEL 0 goto error + +rem Replacing "/"'s with "\" in some cases +set steampath=%steampath:/=\% + +rem Testing common paths +if not exist "%steampath%\steam.exe" ( + if not exist "%ProgramFiles(x86)%\steam.exe" ( + if not exist "%ProgramFiles%\steam.exe" ( + goto error + ) else ( + set steampath=%ProgramFiles% + ) + ) else set steampath=%ProgramFiles(x86)% +) + +echo Running a game +@start /D "%steampath%\steamapps\common\Source SDK Base 2013 Singleplayer" hl2.exe -dev -console -novid -game "%CD%\game\sdk2013CE" +if %ERRORLEVEL% NEQ 0 goto error +goto success + +:success +exit + +:error +echo Error during launching game! +pause +exit diff --git a/sp/shaderedit.bat b/sp/shaderedit.bat index f7919940f..f790fd53f 100644 --- a/sp/shaderedit.bat +++ b/sp/shaderedit.bat @@ -1 +1,40 @@ -@start /D "%ProgramFiles(x86)%\Steam\steamapps\common\Source SDK Base 2013 Singleplayer\" hl2.exe -console -novid -game "%CD%\game\sdk2013CE" -shaderedit -window -height 720 \ No newline at end of file +<<<<<<< HEAD +@start /D "%ProgramFiles(x86)%\Steam\steamapps\common\Source SDK Base 2013 Singleplayer\" hl2.exe -console -novid -game "%CD%\game\sdk2013CE" -shaderedit -window -height 720 +======= +@echo off +setlocal ENABLEDELAYEDEXPANSION + +rem Getting Steam path from registry +rem for /F "usebackq tokens=2*" %%I in (`reg query "HKCU\Software\Valve\Steam"^|find /I "SteamPath"`) do set steampath=%%J +for /f "usebackq tokens=1,2,*" %%i in (`reg query "HKCU\Software\Valve\Steam" /v "SteamPath"`) do set "steampath=%%~k" +rem Since this is loop, we cannot use ERRORLEVEL here +rem if not ERRORLEVEL 0 goto error + +rem Replacing "/"'s with "\" in some cases +set steampath=%steampath:/=\% + +rem Testing common paths +if not exist "%steampath%\steam.exe" ( + if not exist "%ProgramFiles(x86)%\steam.exe" ( + if not exist "%ProgramFiles%\steam.exe" ( + goto error + ) else ( + set steampath=%ProgramFiles% + ) + ) else set steampath=%ProgramFiles(x86)% +) + +echo Running a shader editor +@start /D "%steampath%\steamapps\common\Source SDK Base 2013 Singleplayer" hl2.exe -dev -console -novid -game "%CD%\game\sdk2013CE" -shaderedit -window -height 720 + +if %ERRORLEVEL% NEQ 0 goto error +goto success + +:success +exit + +:error +echo Error during launching game! +pause +exit +>>>>>>> refs/remotes/origin/master diff --git a/sp/src/game/server/func_movelinear.cpp b/sp/src/game/server/func_movelinear.cpp index 397fefd18..4d1350b6e 100644 --- a/sp/src/game/server/func_movelinear.cpp +++ b/sp/src/game/server/func_movelinear.cpp @@ -84,9 +84,9 @@ void CFuncMoveLinear::Spawn( void ) m_flMoveDistance = DotProductAbs( m_vecMoveDir, vecOBB ) - m_flLip; } - m_vecPosition1 = GetAbsOrigin() - (m_vecMoveDir * m_flMoveDistance * m_flStartPosition); + m_vecPosition1 = GetLocalOrigin() - (m_vecMoveDir * m_flMoveDistance * m_flStartPosition); m_vecPosition2 = m_vecPosition1 + (m_vecMoveDir * m_flMoveDistance); - m_vecFinalDest = GetAbsOrigin(); + m_vecFinalDest = GetLocalOrigin(); SetTouch( NULL ); diff --git a/sp/src/game/server/hl2/npc_missiledefense.cpp b/sp/src/game/server/hl2/npc_missiledefense.cpp index f07984cf6..d4b58e1b6 100644 --- a/sp/src/game/server/hl2/npc_missiledefense.cpp +++ b/sp/src/game/server/hl2/npc_missiledefense.cpp @@ -1,6 +1,7 @@ + //========= Copyright Valve Corporation, All rights reserved. ============// // -// Purpose: +// Purpose: // // $NoKeywords: $ //=============================================================================// @@ -20,6 +21,11 @@ #include "engine/IEngineSound.h" #include "ammodef.h" #include "hl2_shareddefs.h" +#include "explode.h" //For the explosion +#include "effect_dispatch_data.h" //Muzzleflash +#include "te_effect_dispatch.h" //Muzzleflash +//#include "ai_basenpc.h" //Ignite +//#include "decals.h" //Scorch effect // memdbgon must be the last include file in a .cpp file!!! #include "tier0/memdbgon.h" @@ -27,14 +33,19 @@ #define MD_FULLAMMO 50 -#define MD_BC_YAW 0 +#define MD_BC_YAW 1 #define MD_BC_PITCH 1 #define MD_AP_LGUN 2 #define MD_AP_RGUN 1 #define MD_GIB_COUNT 4 -#define MD_GIB_MODEL "models/gibs/missile_defense_gibs.mdl" -#define MD_YAW_SPEED 24 -#define MD_PITCH_SPEED 12 +//#define MD_GIB_MODEL "models/gibs/missile_defense_gibs.mdl" +#define MD_YAW_SPEED 48 +#define MD_PITCH_SPEED 48 + +//------------------------------------ +// Spawnflags +//------------------------------------ +#define SF_MISSILEDEFENSE_BULLETDMG (1 << 16) //Can be damaged with bullets? N on def //========================================================= //========================================================= @@ -58,17 +69,38 @@ public: void Event_Killed( const CTakeDamageInfo &info ); int OnTakeDamage_Alive( const CTakeDamageInfo &info ); + void Explode(const Vector &vecExplosionPos); void Gib(); - void GetGunAim( Vector *vecAim ); + void GetGunAim( Vector *vecAim ); + void TurretTurnOn(void); + void DoMuzzleFlash(void); ~CNPC_MissileDefense(); Vector m_vGunAng; int m_iAmmoLoaded; float m_flReloadedTime; + + string_t m_sTurretModel; + string_t m_sGibModel; + string_t m_sFireSound; + string_t m_sRotateSound; + string_t m_sReloadSound; + + int m_nStartOn; + int m_nHealth; + + // ---------------- + // Inputs + // ---------------- + void InputTurnOn( inputdata_t &inputdata ); + void InputTurnOff( inputdata_t &inputdata ); }; LINK_ENTITY_TO_CLASS( npc_missiledefense, CNPC_MissileDefense ); + +ConVar sk_missiledefense_health( "sk_missiledefense_health","100"); + //========================================================= //========================================================= BEGIN_DATADESC( CNPC_MissileDefense ) @@ -77,23 +109,162 @@ BEGIN_DATADESC( CNPC_MissileDefense ) DEFINE_FIELD( m_flReloadedTime, FIELD_TIME ), DEFINE_FIELD( m_vGunAng, FIELD_VECTOR ), + DEFINE_KEYFIELD( m_sTurretModel, FIELD_STRING, "TurretModel" ), + DEFINE_KEYFIELD( m_sGibModel, FIELD_STRING, "GibModel" ), + DEFINE_KEYFIELD( m_sFireSound, FIELD_STRING, "FireSound" ), + DEFINE_KEYFIELD( m_sRotateSound, FIELD_STRING, "RotateSound" ), + DEFINE_KEYFIELD( m_sReloadSound, FIELD_STRING, "ReloadSound" ), + DEFINE_KEYFIELD( m_nHealth, FIELD_INTEGER, "Health" ), + + DEFINE_INPUT( m_nStartOn, FIELD_INTEGER, "StartOn" ), + + DEFINE_FIELD( m_nStartOn, FIELD_BOOLEAN ), //Starts on? + + DEFINE_INPUTFUNC( FIELD_VOID, "TurnOn", InputTurnOn ), + DEFINE_INPUTFUNC( FIELD_VOID, "TurnOff", InputTurnOff ), + END_DATADESC() -//--------------------------------------------------------- -//--------------------------------------------------------- -void CNPC_MissileDefense::Precache( void ) +// =================== +// Input Functions +// =================== + +//-------------------------------------------------------------- +// Purpose: Enables npc +//-------------------------------------------------------------- +void CNPC_MissileDefense::InputTurnOn( inputdata_t &inputdata ) { - PrecacheModel("models/missile_defense.mdl"); - PrecacheModel(MD_GIB_MODEL); - - PrecacheScriptSound( "NPC_MissileDefense.Attack" ); - PrecacheScriptSound( "NPC_MissileDefense.Reload" ); - PrecacheScriptSound( "NPC_MissileDefense.Turn" ); + m_nStartOn = 1; + SetThink( &CNPC_MissileDefense::CallNPCThink ); + SetNextThink( gpGlobals->curtime ); +} +//-------------------------------------------------------------- +// Purpose: Disables npc +//-------------------------------------------------------------- +void CNPC_MissileDefense::InputTurnOff( inputdata_t &inputdata ) +{ + m_nStartOn = 0; + SetThink(NULL); } +//-------------------------------------------------------------- +// Purpose: Precache models and sounds that are going to be used +//-------------------------------------------------------------- +void CNPC_MissileDefense::Precache( void ) +{ + PrecacheModel(STRING(m_sTurretModel)); + PrecacheModel(STRING(m_sGibModel)); + + PrecacheScriptSound( STRING(m_sFireSound)); + PrecacheScriptSound( STRING(m_sRotateSound)); + PrecacheScriptSound( STRING(m_sReloadSound)); +} + //--------------------------------------------------------- +// Purpose: Spawns the npc +//--------------------------------------------------------- +void CNPC_MissileDefense::Spawn( void ) +{ + Precache(); + + //Gets gib model defined by the mapper + char *szModel = (char *)STRING( m_sTurretModel ); + + SetModel( szModel ); + + UTIL_SetSize( this, Vector( -36, -36 , 0 ), Vector( 36, 36, 64 ) ); + + SetSolid( SOLID_BBOX ); + SetMoveType( MOVETYPE_NONE ); + m_takedamage = DAMAGE_YES; + SetBloodColor( DONT_BLEED ); + + //Gets health defined by the mapper, if not set, get the cvar one + if(!m_nHealth) + { + m_iHealth = sk_missiledefense_health.GetFloat(); + } + else + { + m_iHealth = m_nHealth; + } + + m_flFieldOfView = VIEW_FIELD_FULL; //0.4f + m_NPCState = NPC_STATE_ALERT; + CapabilitiesClear(); + CapabilitiesAdd ( bits_CAP_INNATE_RANGE_ATTACK1 ); + + // Hate missiles + AddClassRelationship( CLASS_MISSILE, D_HT, 5 ); + + m_spawnflags |= SF_NPC_LONG_RANGE; + + m_flReloadedTime = gpGlobals->curtime; + + InitBoneControllers(); + + NPCInit(); + + SetBoneController( MD_BC_YAW, 0 ); //10 + SetBoneController( MD_BC_PITCH, 0 ); + + SetBodygroup( 1, 0 ); + SetBodygroup( 2, 0 ); + SetBodygroup( 3, 0 ); + SetBodygroup( 4, 0 ); +} + +//------------------------------------------------------------------------------ +// Purpose : Main AI work +// Input : +// Output : +//------------------------------------------------------------------------------ +void CNPC_MissileDefense::RunAI( void ) +{ + + //If Starts On option isn't activated, disable AI + if (m_nStartOn == 0) + { + SetThink(NULL); + } + + // If my enemy is dead clear the memory and reset m_hEnemy + if ( ( GetEnemy() != NULL ) && ( GetEnemy()->IsAlive() == false ) ) + { + ClearEnemyMemory(); + SetEnemy( NULL ); + } + + if (GetEnemy() == NULL ) + { + // We have to refresh our memories before finding enemies, so + // dead enemies are cleared out before new ones are added. + GetEnemies()->RefreshMemories(); + + GetSenses()->Look( 4092 ); + SetEnemy( BestEnemy( ) ); + + if (GetEnemy() != NULL) + { + m_iAmmoLoaded = MD_FULLAMMO; + m_flReloadedTime = gpGlobals->curtime; + } + } + + if( m_iAmmoLoaded < 1 && gpGlobals->curtime > m_flReloadedTime ) + { + m_iAmmoLoaded = MD_FULLAMMO; + } + + AimGun(); + FireCannons(); + SetNextThink( gpGlobals->curtime + 0.05 ); +} + +//--------------------------------------------------------- +// Purpose: Starts aiming the gun //--------------------------------------------------------- void CNPC_MissileDefense::GetGunAim( Vector *vecAim ) { @@ -116,7 +287,7 @@ void CNPC_MissileDefense::GetGunAim( Vector *vecAim ) #define NOISE 0.035f #define MD_ATTN_CANNON 0.4 //------------------------------------------------------------------------------ -// Purpose : +// Purpose : Open fire on the rocket // Input : // Output : //------------------------------------------------------------------------------ @@ -139,8 +310,10 @@ void CNPC_MissileDefense::FireCannons( void ) } // ---------------------------------------------- // Make sure gun it pointing in right direction + // + // Disabled, so it makes work fine the turret // ---------------------------------------------- - Vector vGunDir; + /*Vector vGunDir; GetGunAim( &vGunDir ); Vector vTargetPos; EnemyShootPosition(GetEnemy(),&vTargetPos); @@ -152,17 +325,20 @@ void CNPC_MissileDefense::FireCannons( void ) if (fDotPr < 0.95) { return; - } + }*/ - // ---------------------------------------------- + // ----------------------------------------------------------------------------------------- // Check line of sight - // ---------------------------------------------- - trace_t tr; + // + // For some unknown reason, with two or more turrets it makes them to do not fire. Disabled. + // ----------------------------------------------------------------------------------------- + /*trace_t tr; AI_TraceLine( GetEnemy()->EyePosition(), GetAbsOrigin(), MASK_SOLID_BRUSHONLY, this, COLLISION_GROUP_NONE, &tr); if (tr.fraction < 1.0) { return; } + */ Vector vecRight; Vector vecDir; @@ -182,12 +358,15 @@ void CNPC_MissileDefense::FireCannons( void ) fSound = true; } + //Plays the fire sound + char *sFireSound = (char *)STRING( m_sFireSound ); + EmitSound(sFireSound); - EmitSound( "NPC_MissileDefense.Attack" ); + DoMuzzleFlash(); Vector vecGun; QAngle vecAng; - + GetAttachment( MD_AP_LGUN, vecGun, vecAng ); Vector vecTarget; @@ -218,7 +397,9 @@ void CNPC_MissileDefense::FireCannons( void ) if( m_iAmmoLoaded < 1 ) { // Incite a reload. - EmitSound( "NPC_MissileDefense.Reload" ); + char *sReloadSound = (char *)STRING( m_sReloadSound ); + EmitSound(sReloadSound); + m_flReloadedTime = gpGlobals->curtime + 0.3; return; } @@ -246,60 +427,34 @@ void CNPC_MissileDefense::FireCannons( void ) } } - -//--------------------------------------------------------- -//--------------------------------------------------------- -void CNPC_MissileDefense::Spawn( void ) -{ - Precache(); - - SetModel( "models/missile_defense.mdl" ); - UTIL_SetSize( this, Vector( -36, -36 , 0 ), Vector( 36, 36, 64 ) ); - - SetSolid( SOLID_BBOX ); - SetMoveType( MOVETYPE_NONE ); - m_takedamage = DAMAGE_YES; - SetBloodColor( DONT_BLEED ); - m_iHealth = 10; - m_flFieldOfView = 0.1; - m_NPCState = NPC_STATE_NONE; - CapabilitiesClear(); - CapabilitiesAdd ( bits_CAP_INNATE_RANGE_ATTACK1 ); - - // Hate missiles - AddClassRelationship( CLASS_MISSILE, D_HT, 5 ); - - m_spawnflags |= SF_NPC_LONG_RANGE; - - m_flReloadedTime = gpGlobals->curtime; - - InitBoneControllers(); - - NPCInit(); - - SetBoneController( MD_BC_YAW, 10 ); - SetBoneController( MD_BC_PITCH, 0 ); - - SetBodygroup( 1, 1 ); - SetBodygroup( 2, 1 ); - SetBodygroup( 3, 1 ); - SetBodygroup( 4, 1 ); - - m_NPCState = NPC_STATE_IDLE; -} - //------------------------------------------------------------------------------ -// Purpose : +// Purpose : Takes damage only from blasts and bullets // Input : // Output : //------------------------------------------------------------------------------ int CNPC_MissileDefense::OnTakeDamage_Alive( const CTakeDamageInfo &info ) { + // Only take blast damage if (info.GetDamageType() & DMG_BLAST ) { return BaseClass::OnTakeDamage_Alive( info ); } + + // + // Bullets can damage it if their flag is checked + // + else if (info.GetDamageType() & DMG_BULLET) + { + if(HasSpawnFlags(SF_MISSILEDEFENSE_BULLETDMG)) + { + return BaseClass::OnTakeDamage_Alive( info ); + } + else + { + return 0; + } + } else { return 0; @@ -307,23 +462,52 @@ int CNPC_MissileDefense::OnTakeDamage_Alive( const CTakeDamageInfo &info ) } //------------------------------------------------------------------------------ -// Purpose : +// Purpose : Stuff to do when gets killed // Input : // Output : //------------------------------------------------------------------------------ void CNPC_MissileDefense::Event_Killed( const CTakeDamageInfo &info ) { - StopSound( "NPC_MissileDefense.Turn" ); + //Set on fire + //Ignite( 60, false ); + + //Paint me black + //Scorch( 8, 50 ); + + char *sRotateSound = (char *)STRING( m_sRotateSound ); + StopSound( sRotateSound ); + + CTakeDamageInfo dmgInfo = info; + + Explode( dmgInfo.GetDamagePosition() ); + Gib(); } //------------------------------------------------------------------------------ -// Purpose : +// Purpose : Makes an explosion +// Input : +// Output : +//------------------------------------------------------------------------------ +void CNPC_MissileDefense::Explode(const Vector &vecExplosionPos) +{ + //Explodes! + ExplosionCreate( vecExplosionPos, vec3_angle, this, 1000, 500.0f, + SF_ENVEXPLOSION_NODAMAGE | SF_ENVEXPLOSION_NOSPARKS | SF_ENVEXPLOSION_NODLIGHTS | + SF_ENVEXPLOSION_NOSMOKE | SF_ENVEXPLOSION_NOFIREBALLSMOKE, 0 ); + UTIL_ScreenShake( vecExplosionPos, 25.0, 150.0, 1.0, 750.0f, SHAKE_START ); +} + +//------------------------------------------------------------------------------ +// Purpose : Gibs and some more effects when death // Input : // Output : //------------------------------------------------------------------------------ void CNPC_MissileDefense::Gib(void) { + //Gets gib model defined by the mapper + char *szModelGib = (char *)STRING( m_sGibModel ); + // Sparks for (int i = 0; i < 4; i++) { @@ -333,6 +517,7 @@ void CNPC_MissileDefense::Gib(void) sparkPos.z += random->RandomFloat(-12,12); g_pEffects->Sparks(sparkPos); } + // Smoke UTIL_Smoke(GetAbsOrigin(), random->RandomInt(10, 15), 10); @@ -343,52 +528,15 @@ void CNPC_MissileDefense::Gib(void) &GetAbsOrigin(), 255, 180, 100, 0, 100, 0.1, 0 ); // Remove top parts - SetBodygroup( 1, 0 ); - SetBodygroup( 2, 0 ); - SetBodygroup( 3, 0 ); - SetBodygroup( 4, 0 ); + SetBodygroup( 1, 1 ); + SetBodygroup( 2, 1 ); + SetBodygroup( 3, 1 ); + SetBodygroup( 4, 1 ); m_takedamage = 0; SetThink(NULL); - + // Throw manhackgibs - CGib::SpawnSpecificGibs( this, MD_GIB_COUNT, 300, 500, MD_GIB_MODEL); -} - -//------------------------------------------------------------------------------ -// Purpose : -// Input : -// Output : -//------------------------------------------------------------------------------ -void CNPC_MissileDefense::RunAI( void ) -{ - // If my enemy is dead clear the memory and reset m_hEnemy - if (GetEnemy() != NULL && - !GetEnemy()->IsAlive()) - { - ClearEnemyMemory(); - SetEnemy( NULL ); - } - - if (GetEnemy() == NULL ) - { - GetSenses()->Look( 4092 ); - SetEnemy( BestEnemy( ) ); - - if (GetEnemy() != NULL) - { - m_iAmmoLoaded = MD_FULLAMMO; - m_flReloadedTime = gpGlobals->curtime; - } - } - - if( m_iAmmoLoaded < 1 && gpGlobals->curtime > m_flReloadedTime ) - { - m_iAmmoLoaded = MD_FULLAMMO; - } - - AimGun(); - FireCannons(); - SetNextThink( gpGlobals->curtime + 0.05 ); + CGib::SpawnSpecificGibs( this, MD_GIB_COUNT, 300, 500, szModelGib); } //------------------------------------------------------------------------------ @@ -405,7 +553,7 @@ void CNPC_MissileDefense::EnemyShootPosition(CBaseEntity* pEnemy, Vector *vPosit } *vPosition = pEnemy->GetAbsOrigin(); - + // Add prediction but prevents us from flipping around as enemy approaches us float flDist = (pEnemy->GetAbsOrigin() - GetAbsOrigin()).Length(); Vector vPredVel = pEnemy->GetSmoothedVelocity() * 0.5; @@ -416,7 +564,7 @@ void CNPC_MissileDefense::EnemyShootPosition(CBaseEntity* pEnemy, Vector *vPosit } //------------------------------------------------------------------------------ -// Purpose : +// Purpose : Moves the turret to aim the rocket // Input : // Output : //------------------------------------------------------------------------------ @@ -424,13 +572,14 @@ void CNPC_MissileDefense::AimGun( void ) { if (GetEnemy() == NULL) { - StopSound( "NPC_MissileDefense.Turn" ); + char *sRotateSound = (char *)STRING( m_sRotateSound ); + StopSound( sRotateSound ); return; } Vector forward, right, up; AngleVectors( GetLocalAngles(), &forward, &right, &up ); - + // Get gun attachment points Vector vBasePos; QAngle vBaseAng; @@ -450,37 +599,49 @@ void CNPC_MissileDefense::AimGun( void ) QAngle angles; VectorAngles(vecOut, angles); - if (angles.y > 180) - angles.y = angles.y - 360; - if (angles.y < -180) - angles.y = angles.y + 360; - if (angles.x > 180) - angles.x = angles.x - 360; - if (angles.x < -180) - angles.x = angles.x + 360; + //Pitch for the cannons + if (angles.x != m_vGunAng.x){ + float flDir = m_vGunAng.x > angles.x ? 1 : -1; + angles.x += 0.1 * MD_PITCH_SPEED * flDir; - float flOldX = m_vGunAng.x; - float flOldY = m_vGunAng.y; + SetBoneController(1, angles.x - m_vGunAng.x); + } - if (angles.x > m_vGunAng.x) - m_vGunAng.x = MIN( angles.x, m_vGunAng.x + MD_PITCH_SPEED ); - if (angles.x < m_vGunAng.x) - m_vGunAng.x = MAX( angles.x, m_vGunAng.x - MD_PITCH_SPEED ); - if (angles.y > m_vGunAng.y) - m_vGunAng.y = MIN( angles.y, m_vGunAng.y + MD_YAW_SPEED ); - if (angles.y < m_vGunAng.y) - m_vGunAng.y = MAX( angles.y, m_vGunAng.y - MD_YAW_SPEED ); + //Yaw for the cannons + if (angles.y != m_vGunAng.y){ + float flDir = m_vGunAng.y > angles.y ? 1 : -1; + float flDist = fabs(m_vGunAng.y - angles.y); - m_vGunAng.y = SetBoneController( MD_BC_YAW, m_vGunAng.y ); - m_vGunAng.x = SetBoneController( MD_BC_PITCH, m_vGunAng.x ); + if (flDist > 180){ + flDist = 360 - flDist; + flDir =- flDir; + } - if (flOldX != m_vGunAng.x || flOldY != m_vGunAng.y) + angles.y += 0.1 * MD_YAW_SPEED * flDir; + + if (angles.y < 0) + angles.y += 360; + else if (angles.y >= 360) + angles.y -= 360; + + if(flDist < (0.05 * MD_YAW_SPEED)) + angles.y = m_vGunAng.y; + + SetBoneController(0, angles.y - m_vGunAng.y); + } + + //Plays movement sound + if (angles.x != m_vGunAng.x || angles.y != m_vGunAng.y) { - EmitSound( "NPC_MissileDefense.Turn" ); + //EmitSound( "NPC_FloorTurret.Alarm" ); + char *sRotateSound = (char *)STRING( m_sRotateSound ); + EmitSound( sRotateSound ); } else { - StopSound( "NPC_MissileDefense.Turn" ); + //StopSound( "NPC_FloorTurret.Alarm" ); + char *sRotateSound = (char *)STRING( m_sRotateSound ); + StopSound( sRotateSound ); } } @@ -492,5 +653,22 @@ void CNPC_MissileDefense::AimGun( void ) //------------------------------------------------------------------------------ CNPC_MissileDefense::~CNPC_MissileDefense(void) { - StopSound( "NPC_MissileDefense.Turn" ); + char *sRotateSound = (char *)STRING( m_sRotateSound ); + StopSound( sRotateSound ); } + +//----------------------------------------------------------------------------- +// Purpose: Puts a muzzleflash on the cannons +//----------------------------------------------------------------------------- +void CNPC_MissileDefense::DoMuzzleFlash( void ) +{ + CEffectData data, data2; + data.m_nEntIndex = entindex(); + data2.m_nEntIndex = entindex(); + data.m_nAttachmentIndex = LookupAttachment( "R_Gun_AtchPnt" ); + data2.m_nAttachmentIndex = LookupAttachment( "L_Gun_AtchPnt" ); + data.m_flScale = 1.0f; + data2.m_flScale = 1.0f; + DispatchEffect( "ChopperMuzzleFlash", data ); + DispatchEffect( "ChopperMuzzleFlash", data2 ); +} \ No newline at end of file diff --git a/sp/src/game/server/props.cpp b/sp/src/game/server/props.cpp index c2ee37797..b03d4efbb 100644 --- a/sp/src/game/server/props.cpp +++ b/sp/src/game/server/props.cpp @@ -5426,29 +5426,38 @@ void CPropDoorRotating::InputSetRotationDistance( inputdata_t &inputdata ) CalculateDoorVolume( GetLocalAngles(), m_angRotationOpenBack, &m_vecBackBoundsMin, &m_vecBackBoundsMax ); } -// Debug sphere class CPhysSphere : public CPhysicsProp { DECLARE_CLASS( CPhysSphere, CPhysicsProp ); + DECLARE_DATADESC(); public: - virtual bool OverridePropdata() { return true; } + + float m_fRadius; + bool CreateVPhysics() { SetSolid( SOLID_BBOX ); - SetCollisionBounds( -Vector(12,12,12), Vector(12,12,12) ); + SetCollisionBounds( -Vector(m_fRadius), Vector(m_fRadius) ); objectparams_t params = g_PhysDefaultObjectParams; params.pGameData = static_cast(this); - IPhysicsObject *pPhysicsObject = physenv->CreateSphereObject( 12, 0, GetAbsOrigin(), GetAbsAngles(), ¶ms, false ); + IPhysicsObject *pPhysicsObject = physenv->CreateSphereObject( m_fRadius, GetModelPtr()->GetRenderHdr()->textureindex, GetAbsOrigin(), GetAbsAngles(), ¶ms, false ); + if ( pPhysicsObject ) { VPhysicsSetObject( pPhysicsObject ); SetMoveType( MOVETYPE_VPHYSICS ); pPhysicsObject->Wake(); } - + return true; } }; + +LINK_ENTITY_TO_CLASS( prop_sphere, CPhysSphere ); + +BEGIN_DATADESC( CPhysSphere ) + DEFINE_KEYFIELD( m_fRadius, FIELD_FLOAT, "radius"), +END_DATADESC() void CPropDoorRotating::InputSetSpeed(inputdata_t &inputdata) { @@ -5457,8 +5466,6 @@ void CPropDoorRotating::InputSetSpeed(inputdata_t &inputdata) DoorResume(); } -LINK_ENTITY_TO_CLASS( prop_sphere, CPhysSphere ); - // ------------------------------------------------------------------------------------------ // // Special version of func_physbox. diff --git a/sp/src/msbuild.bat b/sp/src/msbuild.bat index 8050b4f0f..fa01dadfc 100644 --- a/sp/src/msbuild.bat +++ b/sp/src/msbuild.bat @@ -1,6 +1,6 @@ @echo off :: Version 12.0 -"%ProgramFiles(x86)%\MSBuild\12.0\Bin\msbuild.exe" %cd%\sdk2013ce.sln +"%ProgramFiles(x86)%\MSBuild\12.0\Bin\msbuild.exe" "%cd%\sdk2013ce.sln" -pause \ No newline at end of file +pause