From b976fc1d337d5348992f31807b25931920780860 Mon Sep 17 00:00:00 2001 From: Marco Hladik Date: Thu, 8 Dec 2016 21:24:09 +0100 Subject: [PATCH] Added as_* gamemode support CVAR mp_c4timer now affects the bomb Fixed a bug in which the rounds weren't reset properly when players left Max playerspeed can now be controlled serverside with sv_maxspeed --- Source/Client/Event.c | 4 +- Source/Client/HUD.c | 3 +- Source/Server/Defs.h | 1 + Source/Server/FuncEscapeZone.c | 4 +- Source/Server/FuncVIPSafetyZone.c | 61 +++++++++++++++++++++++++++++++ Source/Server/Main.c | 10 +++-- Source/Server/Player.c | 7 ++-- Source/Server/Rules.c | 33 +++++++++++++++-- Source/Server/Spawn.c | 14 ++++++- Source/Server/progs.src | 1 + Source/Shared/WeaponC4Bomb.c | 2 +- cstrike/default.cfg | 56 ++++++++++++++++++++++++++++ cstrike/ftesrv.cfg | 8 ++++ cstrike/particles/default.cfg | 55 ++++++++++++++++++++++++++++ 14 files changed, 240 insertions(+), 19 deletions(-) create mode 100644 Source/Server/FuncVIPSafetyZone.c create mode 100644 cstrike/default.cfg create mode 100644 cstrike/ftesrv.cfg create mode 100644 cstrike/particles/default.cfg diff --git a/Source/Client/Event.c b/Source/Client/Event.c index eebaf55d..eaf49614 100644 --- a/Source/Client/Event.c +++ b/Source/Client/Event.c @@ -49,9 +49,7 @@ float CSQC_ConsoleCommand( string sCMD ) { return TRUE; break; case "chooseteam": - if( getstatf( STAT_TEAM ) == 0 ) { - fVGUI_Display = VGUI_TEAMSELECT; - } + fVGUI_Display = VGUI_TEAMSELECT; return TRUE; break; case "use": diff --git a/Source/Client/HUD.c b/Source/Client/HUD.c index 1df26fce..1636117d 100644 --- a/Source/Client/HUD.c +++ b/Source/Client/HUD.c @@ -40,11 +40,12 @@ float vHUDNumPos[10] = { }; // Ditto -vector vHUDCalPos[10] = { +vector vHUDCalPos[11] = { '0 0 0', '0.09375 0.28125 0', // 50AE '0.28125 0.28125 0', // 762MM '0 0.375 0', // 556MM + '0 0.375 0', // 556MM '0.09375 0.375 0', // 338MAG '0.1875 0.28125 0', // 9MM '0 0.28125 0', // BUCKSHOT diff --git a/Source/Server/Defs.h b/Source/Server/Defs.h index e7e79356..3c864cf4 100644 --- a/Source/Server/Defs.h +++ b/Source/Server/Defs.h @@ -64,6 +64,7 @@ int iHostagesMax; int iBombZones; int iRescueZones; int iBuyZones; +int iVIPZones; int iBuyRestriction; // For info_map_parameters int iHostagesRescued; diff --git a/Source/Server/FuncEscapeZone.c b/Source/Server/FuncEscapeZone.c index 0b74d65c..0e4966e2 100644 --- a/Source/Server/FuncEscapeZone.c +++ b/Source/Server/FuncEscapeZone.c @@ -23,7 +23,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. func_escapezone_touch ================= */ -void func_escapezone_touch( void ) { +void func_vip_safetyzone( void ) { if ( ( other.classname == "player" ) && ( other.team == TEAM_T ) ) { } @@ -36,7 +36,7 @@ SPAWN: func_escapezone Entry function for the terrorist escape zone ================= */ -void func_escapezone( void ) { +void func_vip_safetyzone( void ) { self.angles = '0 0 0'; self.movetype = MOVETYPE_NONE; self.solid = SOLID_TRIGGER; diff --git a/Source/Server/FuncVIPSafetyZone.c b/Source/Server/FuncVIPSafetyZone.c new file mode 100644 index 00000000..ea8673ae --- /dev/null +++ b/Source/Server/FuncVIPSafetyZone.c @@ -0,0 +1,61 @@ +/* +OpenCS Project +Copyright (C) 2015 Marco "eukara" Hladik + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +/* +================= +func_vip_safetyzone_touch +================= +*/ +void func_vip_safetyzone_touch( void ) { + if ( ( other.classname == "player" ) && ( other.team == TEAM_VIP ) ) { + Rules_RoundOver( TEAM_CT ); + + entity eOld = self; + self = other; + self.team = TEAM_CT; + Spawn_MakeSpectator(); + self.classname = "player"; + + self = eOld; + } +} + +/* +================= +SPAWN: func_vip_safetyzone + +Entry function for the VIP escape zone +================= +*/ +void func_vip_safetyzone( void ) { + self.angles = '0 0 0'; + self.movetype = MOVETYPE_NONE; + self.solid = SOLID_TRIGGER; + + if ( self.model ) { + setmodel( self, self.model ); + } else { + setsize( self, self.mins, self.maxs ); + } + + self.model = 0; + self.touch = func_vip_safetyzone_touch; + iVIPZones++; +} diff --git a/Source/Server/Main.c b/Source/Server/Main.c index cc868a3d..caa16a23 100644 --- a/Source/Server/Main.c +++ b/Source/Server/Main.c @@ -22,12 +22,14 @@ void main( void ) {} void SetNewParms( void ) {} void SetChangeParms( void ) {} +void SV_PausedTic( float fDuration ) { + +} + // Run every frame... by world? void StartFrame( void ) { - - // We've got hostages, but no rescue zones, create some - if ( !iRescueZones && iHostagesMax > 0 ) { + if ( !iRescueZones && iHostagesMax > 0 ) { Game_CreateRescueZones(); } @@ -53,6 +55,7 @@ void StartFrame( void ) { if ( iInGamePlayers == 0 ) { fGameState = GAME_INACTIVE; fGameTime = 0; + fOldInGamePlayers = 0; } else { Timer_Update(); } @@ -69,6 +72,7 @@ void worldspawn( void ) { precache_model( sCSPlayers[6] ); precache_model( sCSPlayers[7] ); precache_model( sCSPlayers[8] ); + precache_model( "models/player/vip/vip.mdl" ); precache_model( "models/w_c4.mdl" ); EFFECT_GUNSHOT = particleeffectnum( "te_gunshot" ); diff --git a/Source/Server/Player.c b/Source/Server/Player.c index 6a95967d..87ab884f 100644 --- a/Source/Server/Player.c +++ b/Source/Server/Player.c @@ -50,15 +50,16 @@ void Player_Death( void ) { Rules_RoundOver( TEAM_T ); } } else if ( self.team == TEAM_VIP ) { - // TODO: Finish me + iAlivePlayers_CT--; // For consistency + Rules_RoundOver( TEAM_T ); } } float Player_GetMaxSpeed( float fWeapon ) { if ( self.iCrouching == TRUE ) { - return (cvar( "cl_forwardspeed" ) * wptTable[ fWeapon ].fSpeedM) * 0.5; + return (cvar( "sv_maxspeed" ) * wptTable[ fWeapon ].fSpeedM) * 0.5; } else { - return cvar( "cl_forwardspeed" ) * wptTable[ fWeapon ].fSpeedM; + return cvar( "sv_maxspeed" ) * wptTable[ fWeapon ].fSpeedM; } } diff --git a/Source/Server/Rules.c b/Source/Server/Rules.c index 1da948da..39160e44 100644 --- a/Source/Server/Rules.c +++ b/Source/Server/Rules.c @@ -79,15 +79,15 @@ void Rules_Restart( void ) { // Select a random Terrorist for the bomb thing if ( iBombZones > 0 ) { int iRandomT = ceil( random() * iAlivePlayers_T ); - int iPicked = 0; + int iPickT = 0; eFind = findchain( classname, "player" ); while ( eFind ) { if ( eFind.classname == "player" && eFind.team == TEAM_T ) { - iPicked++; + iPickT++; - if ( iPicked == iRandomT ) { + if ( iPickT == iRandomT ) { eOld = self; self = eFind; Weapon_AddItem( WEAPON_C4BOMB ); @@ -95,6 +95,29 @@ void Rules_Restart( void ) { } } + eFind = eFind.chain; + } + } + + // If there is a VIP, select a random CT to be it + if ( iVIPZones > 0 ) { + int iRandomCT = ceil( random() * iAlivePlayers_CT ); + int iPickCT = 0; + + eFind = findchain( classname, "player" ); + while ( eFind ) { + + if ( eFind.classname == "player" && eFind.team == TEAM_CT ) { + iPickCT++; + + if ( iPickCT == iRandomCT ) { + eOld = self; + self = eFind; + self.team = TEAM_VIP; + Spawn_RespawnClient( self.team ); + self = eOld; + } + } eFind = eFind.chain; } @@ -137,7 +160,9 @@ void Rules_RoundOver( int iTeamWon ) { // Whenever mp_roundtime was being counted down to 0 void Rules_TimeOver( void ) { - if ( iBombZones > 0 ) { + if ( iVIPZones > 0 ) { + Rules_RoundOver( TEAM_T ); + } else if ( iBombZones > 0 ) { Rules_RoundOver( TEAM_CT ); } else if ( iHostagesMax > 0 ) { // TODO: Broadcast_Print: Hostages have not been rescued! diff --git a/Source/Server/Spawn.c b/Source/Server/Spawn.c index 33a8f26f..0aa57eca 100644 --- a/Source/Server/Spawn.c +++ b/Source/Server/Spawn.c @@ -29,9 +29,11 @@ entity Spawn_FindSpawnPoint( float fTeam ) { if ( fTeam == TEAM_T ) { sClassname = "info_player_deathmatch"; eSpot = eLastSpawn = eLastTSpawn; - } else { + } else if ( fTeam == TEAM_CT ) { sClassname = "info_player_start"; eSpot = eLastSpawn = eLastCTSpawn; + } else if ( fTeam == TEAM_VIP ) { + return find( world, classname, "info_vip_start" ); } while (1) { @@ -95,7 +97,11 @@ void Spawn_RespawnClient( float fTeam ) { self.fixangle = TRUE; // Get the player-model from Defs.h's list - setmodel( self, sCSPlayers[ self.fCharModel ] ); + if ( self.team != TEAM_VIP ) { + setmodel( self, sCSPlayers[ self.fCharModel ] ); + } else { + setmodel( self, "models/player/vip/vip.mdl" ); + } setsize( self, VEC_HULL_MIN, VEC_HULL_MAX ); self.view_ofs = VEC_PLAYER_VIEWPOS; @@ -205,6 +211,10 @@ void info_player_start( void ) { void info_player_deathmatch( void ) { } +// VIP Spawnpoints +void info_vip_start( void ) { +} + void info_target( void ) { setorigin( self, self.origin ); } diff --git a/Source/Server/progs.src b/Source/Server/progs.src index ca2c542f..d98d59d5 100644 --- a/Source/Server/progs.src +++ b/Source/Server/progs.src @@ -50,6 +50,7 @@ EnvObjects.c FuncBreakable.c FuncLadder.c FuncHostageRescue.c +FuncVIPSafetyZone.c FuncBombTarget.c FuncBuyZone.c FuncButton.c diff --git a/Source/Shared/WeaponC4Bomb.c b/Source/Shared/WeaponC4Bomb.c index 9467f330..e1835ee0 100644 --- a/Source/Shared/WeaponC4Bomb.c +++ b/Source/Shared/WeaponC4Bomb.c @@ -87,7 +87,7 @@ void WeaponC4BOMB_Drop( vector vBombPos ) { setmodel( eBomb, "models/w_c4.mdl" ); eBomb.think = c4bomb_think; eBomb.nextthink = time + 1.5; - eBomb.fAttackFinished = time + 45; + eBomb.fAttackFinished = time + cvar( "mp_c4timer" ); sound( eBomb, CHAN_WEAPON, "weapons/c4_plant.wav", 1.0, ATTN_IDLE ); Radio_BroadcastMessage( RADIO_BOMBPL ); diff --git a/cstrike/default.cfg b/cstrike/default.cfg new file mode 100644 index 00000000..936e2bde --- /dev/null +++ b/cstrike/default.cfg @@ -0,0 +1,56 @@ +bind w +forward +bind s +back +bind a +moveleft +bind d +moveright +bind "UPARROW" "+forward" +bind "DOWNARROW" "+back" +bind "LEFTARROW" "+left" +bind "RIGHTARROW" "+right" +bind MOUSE1 +attack +bind MOUSE2 +button5 +bind r +button4 +bind e "use" + +bind 1 "impulse 1" +bind 2 "impulse 2" +bind 3 "impulse 3" +bind 4 "impulse 4" + +bind SPACE +jump +bind CTRL +button3 +bind SHIFT +speed + +bind b buy +bind m chooseteam +bind ESC togglemenu +bind v noclip + +// Movement Variables +sv_maxspeed 240 +cl_forwardspeed 240 +cl_sidespeed 240 +cl_backspeed 240 +cl_movespeedkey 0.2 +seta mp_startmoney "800" +seta mp_buytime 90 +seta mp_freezetime 6 +seta mp_c4timer 45 +seta mp_roundtime 5 +cl_bobcycle 0.8 +cl_bob 0.01 +cl_bobup 0.5 + +seta r_particledesc default + +hostname "Counter-Strike 1.5 Server" +seta vid_conautoscale "1" +seta snd_device "sdl" + +alias +attack2 +button5 +alias -attack2 -button5 +alias +reload +button4 +alias -reload -button4 +r_fullbrightSkins 0 +r_fb_models 0 + + diff --git a/cstrike/ftesrv.cfg b/cstrike/ftesrv.cfg new file mode 100644 index 00000000..ecace442 --- /dev/null +++ b/cstrike/ftesrv.cfg @@ -0,0 +1,8 @@ +sv_maxspeed 240 +seta mp_startmoney "800" +seta mp_buytime 90 +seta mp_freezetime 6 +seta mp_c4timer 45 +seta mp_roundtime 5 +hostname "Counter-Strike 1.5 Server" + diff --git a/cstrike/particles/default.cfg b/cstrike/particles/default.cfg new file mode 100644 index 00000000..471be568 --- /dev/null +++ b/cstrike/particles/default.cfg @@ -0,0 +1,55 @@ +r_part te_gunshot +{ + type texturedspark + texture ball + tcoords 1 65 31 95 256 8 32 + scale 1 + count 12 + scalefactor 1 + alpha 0.5 + die 0.8 + rgb 255 180 0 + blend add + spawnmode ball + spawnorg 1 + spawnvel 100 + veladd -100 + friction 0.3 + gravity 800 +} + +r_part +te_gunshot +{ + texture ball + tcoords 1 65 31 95 256 8 32 + count 3 + scale 25 + scalefactor 1 + die 1 + alpha 0.5 + rgb 10 10 10 + blend add + spawnmode ball + spawnorg 2 + spawnvel 20 + veladd -20 +} + +r_part te_blood +{ + type texturedspark + texture ball + tcoords 1 65 31 95 256 8 32 + scale 1 + count 12 + scalefactor 1 + alpha 0.2 + die 0.8 + rgb 200 0 0 + spawnmode ball + spawnorg 1 + spawnvel 100 + veladd -100 + friction 0.3 + gravity 800 +}