flashlight: added support for cstrike, mp_flashlight, cleaned things up in /server

This commit is contained in:
Marco Cawthorne 2019-03-01 23:35:28 +01:00
parent 0fd206bc2f
commit afb78fd1ac
11 changed files with 116 additions and 88 deletions

View file

@ -78,6 +78,7 @@ cstrike/main.c
cstrike/player.c
cstrike/spawn.c
footsteps.c
flashlight.c
cstrike/input.c
cstrike/client.c
client.c

View file

@ -55,6 +55,10 @@ void Game_Input(void)
} else {
Weapon_Release();
}
if (self.impulse == 100) {
Flashlight_Toggle();
}
self.impulse = 0;
}

View file

@ -8,6 +8,8 @@
#define CLASSEXPORT(classname,classa) void classname ( void ) { spawnfunc_##classa(); }
var int autocvar_mp_flashlight = TRUE;
void Effect_Impact( int iType, vector vPos, vector vNormal );
void Effect_CreateExplosion( vector vPos );
void Footsteps_Update( void );

View file

@ -68,7 +68,7 @@ void SetChangeParms(void)
Game_SetChangeParms();
}
void SV_RunClientCommand( void )
void SV_RunClientCommand(void)
{
Game_RunClientCommand();
}
@ -88,103 +88,104 @@ void worldspawn(void)
g_initialized = TRUE;
// Let's load materials.txt because someone thought this was the best idea
filestream fileMaterial = fopen( "sound/materials.txt", FILE_READ );
hashMaterials = hash_createtab( 512, HASH_ADD );
filestream fileMaterial = fopen("sound/materials.txt", FILE_READ);
hashMaterials = hash_createtab(512, HASH_ADD);
if ( fileMaterial >= 0 ) {
while ( ( sTemp = fgets( fileMaterial ) ) ) {
if (fileMaterial >= 0) {
while ((sTemp = fgets(fileMaterial))) {
// Tokenize and just parse this stuff in
if ( tokenize_console( sTemp ) == 2 ) {
hash_add( hashMaterials, strtolower( argv( 1 ) ), str2chr( argv( 0 ), 0 ) );
if (tokenize_console(sTemp) == 2) {
hash_add(hashMaterials, strtolower(argv(1)), str2chr(argv(0), 0));
}
}
fclose( fileMaterial );
fclose(fileMaterial);
} else {
error( "Failed to load sound/materials.txt!\n" );
error("Failed to load sound/materials.txt!\n");
}
PMove_Init();
precache_sound( "weapons/explode3.wav" );
precache_sound( "weapons/explode4.wav" );
precache_sound( "weapons/explode5.wav" );
precache_sound("weapons/explode3.wav");
precache_sound("weapons/explode4.wav");
precache_sound("weapons/explode5.wav");
precache_sound( "debris/glass1.wav" );
precache_sound( "debris/glass2.wav" );
precache_sound( "debris/glass3.wav" );
precache_sound( "debris/wood1.wav" );
precache_sound( "debris/wood2.wav" );
precache_sound( "debris/wood3.wav" );
precache_sound( "debris/metal1.wav" );
precache_sound( "debris/metal2.wav" );
precache_sound( "debris/metal3.wav" );
precache_sound( "debris/flesh1.wav" );
precache_sound( "debris/flesh2.wav" );
precache_sound( "debris/flesh3.wav" );
precache_sound( "debris/flesh5.wav" );
precache_sound( "debris/flesh6.wav" );
precache_sound( "debris/flesh7.wav" );
precache_sound( "debris/concrete1.wav" );
precache_sound( "debris/concrete2.wav" );
precache_sound( "debris/concrete3.wav" );
precache_sound("debris/glass1.wav");
precache_sound("debris/glass2.wav");
precache_sound("debris/glass3.wav");
precache_sound("debris/wood1.wav");
precache_sound("debris/wood2.wav");
precache_sound("debris/wood3.wav");
precache_sound("debris/metal1.wav");
precache_sound("debris/metal2.wav");
precache_sound("debris/metal3.wav");
precache_sound("debris/flesh1.wav");
precache_sound("debris/flesh2.wav");
precache_sound("debris/flesh3.wav");
precache_sound("debris/flesh5.wav");
precache_sound("debris/flesh6.wav");
precache_sound("debris/flesh7.wav");
precache_sound("debris/concrete1.wav");
precache_sound("debris/concrete2.wav");
precache_sound("debris/concrete3.wav");
precache_sound( "player/pl_metal1.wav" );
precache_sound( "player/pl_metal2.wav" );
precache_sound( "player/pl_metal3.wav" );
precache_sound( "player/pl_metal4.wav" );
precache_sound("player/pl_metal1.wav");
precache_sound("player/pl_metal2.wav");
precache_sound("player/pl_metal3.wav");
precache_sound("player/pl_metal4.wav");
precache_sound( "player/pl_duct1.wav" );
precache_sound( "player/pl_duct2.wav" );
precache_sound( "player/pl_duct3.wav" );
precache_sound( "player/pl_duct4.wav" );
precache_sound("player/pl_duct1.wav");
precache_sound("player/pl_duct2.wav");
precache_sound("player/pl_duct3.wav");
precache_sound("player/pl_duct4.wav");
precache_sound( "player/pl_dirt1.wav" );
precache_sound( "player/pl_dirt2.wav" );
precache_sound( "player/pl_dirt3.wav" );
precache_sound( "player/pl_dirt4.wav" );
precache_sound("player/pl_dirt1.wav");
precache_sound("player/pl_dirt2.wav");
precache_sound("player/pl_dirt3.wav");
precache_sound("player/pl_dirt4.wav");
precache_sound( "player/pl_slosh1.wav" );
precache_sound( "player/pl_slosh2.wav" );
precache_sound( "player/pl_slosh3.wav" );
precache_sound( "player/pl_slosh4.wav" );
precache_sound("player/pl_slosh1.wav");
precache_sound("player/pl_slosh2.wav");
precache_sound("player/pl_slosh3.wav");
precache_sound("player/pl_slosh4.wav");
precache_sound( "player/pl_tile1.wav" );
precache_sound( "player/pl_tile2.wav" );
precache_sound( "player/pl_tile3.wav" );
precache_sound( "player/pl_tile4.wav" );
precache_sound("player/pl_tile1.wav");
precache_sound("player/pl_tile2.wav");
precache_sound("player/pl_tile3.wav");
precache_sound("player/pl_tile4.wav");
precache_sound( "player/pl_grate1.wav" );
precache_sound( "player/pl_grate2.wav" );
precache_sound( "player/pl_grate3.wav" );
precache_sound( "player/pl_grate4.wav" );
precache_sound("player/pl_grate1.wav");
precache_sound("player/pl_grate2.wav");
precache_sound("player/pl_grate3.wav");
precache_sound("player/pl_grate4.wav");
precache_sound( "player/pl_snow1.wav" );
precache_sound( "player/pl_snow2.wav" );
precache_sound( "player/pl_snow3.wav" );
precache_sound( "player/pl_snow4.wav" );
precache_sound("player/pl_snow1.wav");
precache_sound("player/pl_snow2.wav");
precache_sound("player/pl_snow3.wav");
precache_sound("player/pl_snow4.wav");
precache_sound( "player/pl_step1.wav" );
precache_sound( "player/pl_step2.wav" );
precache_sound( "player/pl_step3.wav" );
precache_sound( "player/pl_step4.wav" );
precache_sound("player/pl_step1.wav");
precache_sound("player/pl_step2.wav");
precache_sound("player/pl_step3.wav");
precache_sound("player/pl_step4.wav");
precache_sound( "items/9mmclip1.wav" );
precache_sound( "items/gunpickup2.wav" );
precache_sound( "common/wpn_select.wav" );
precache_sound( "common/wpn_denyselect.wav" );
precache_sound( "player/sprayer.wav" );
precache_sound("items/9mmclip1.wav");
precache_sound("items/gunpickup2.wav");
precache_sound("common/wpn_select.wav");
precache_sound("common/wpn_denyselect.wav");
precache_sound("player/sprayer.wav");
precache_sound("items/flashlight1.wav");
lightstyle( 0, "m" );
lightstyle( 1, "mmnmmommommnonmmonqnmmo" );
lightstyle( 2, "abcdefghijklmnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba" );
lightstyle( 3, "mmmmmaaaaammmmmaaaaaabcdefgabcdefg" );
lightstyle( 4, "mamamamamama" );
lightstyle( 5,"jklmnopqrstuvwxyzyxwvutsrqponmlkj" );
lightstyle( 6, "nmonqnmomnmomomno" );
lightstyle( 7, "mmmaaaabcdefgmmmmaaaammmaamm" );
lightstyle( 8, "mmmaaammmaaammmabcdefaaaammmmabcdefmmmaaaa" );
lightstyle( 9, "aaaaaaaazzzzzzzz" );
lightstyle( 10, "mmamammmmammamamaaamammma" );
lightstyle( 11, "abcdefghijklmnopqrrqponmlkjihgfedcba" );
lightstyle(0, "m");
lightstyle(1, "mmnmmommommnonmmonqnmmo");
lightstyle(2, "abcdefghijklmnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba");
lightstyle(3, "mmmmmaaaaammmmmaaaaaabcdefgabcdefg");
lightstyle(4, "mamamamamama");
lightstyle(5,"jklmnopqrstuvwxyzyxwvutsrqponmlkj");
lightstyle(6, "nmonqnmomnmomomno");
lightstyle(7, "mmmaaaabcdefgmmmmaaaammmaamm");
lightstyle(8, "mmmaaammmaaammmabcdefaaaammmmabcdefmmmaaaa");
lightstyle(9, "aaaaaaaazzzzzzzz");
lightstyle(10, "mmamammmmammamamaaamammma");
lightstyle(11, "abcdefghijklmnopqrrqponmlkjihgfedcba");
Game_Worldspawn();
Decals_Init();

View file

@ -0,0 +1,23 @@
/***
*
* Copyright (c) 2016-2019 Marco 'eukara' Hladik. All rights reserved.
*
* See the file LICENSE attached with the sources for usage details.
*
****/
void Flashlight_Toggle(void)
{
if (cvar("sv_clientslots") != 1) {
if (cvar("mp_flashlight") != 1) {
return;
}
}
if (self.flags & FL_FLASHLIGHT) {
self.flags &= ~FL_FLASHLIGHT;
} else {
self.flags |= FL_FLASHLIGHT;
}
sound(self, CHAN_ITEM, "items/flashlight1.wav", 1, ATTN_IDLE);
}

View file

@ -59,9 +59,10 @@ valve/damage.c
traceattack.c
vox.c
footsteps.c
flashlight.c
valve/input.c
valve/spawn.c
footsteps.c
entry.c
#endlist

View file

@ -57,9 +57,10 @@ valve/damage.c
traceattack.c
vox.c
footsteps.c
flashlight.c
valve/input.c
valve/spawn.c
footsteps.c
entry.c
#endlist

View file

@ -32,12 +32,7 @@ void Game_Input(void)
}
if (self.impulse == 100) {
if (self.flags & FL_FLASHLIGHT) {
self.flags &= ~FL_FLASHLIGHT;
} else {
self.flags |= FL_FLASHLIGHT;
}
sound (self, CHAN_ITEM, "items/flashlight1.wav", 1, ATTN_IDLE);
Flashlight_Toggle();
}
if (cvar("sv_cheats") == 1) {

Binary file not shown.

Binary file not shown.

Binary file not shown.