From bc46399f8c03c2a9668c492060913228f6b3f2ab Mon Sep 17 00:00:00 2001 From: MotoLegacy Date: Sun, 14 Jan 2024 20:48:42 -0500 Subject: [PATCH] CLIENT/SERVER: Add new event for screen flashing, add delay to game start --- source/client/.DS_Store | Bin 0 -> 6148 bytes source/client/defs/custom.qc | 7 ++- source/client/hud.qc | 61 +++++++++++++++--------- source/client/main.qc | 17 +++++-- source/server/.DS_Store | Bin 0 -> 6148 bytes source/server/clientfuncs.qc | 34 +++++++------ source/server/damage.qc | 2 +- source/server/defs/standard.qc | 2 +- source/server/entities/powerups.qc | 37 ++++---------- source/server/main.qc | 38 +++++++++++---- source/server/player.qc | 14 ++---- source/server/utilities/game_restart.qc | 2 + source/shared/.DS_Store | Bin 0 -> 6148 bytes source/shared/defs/custom.qc | 54 ++++++++++++++------- 14 files changed, 158 insertions(+), 110 deletions(-) create mode 100644 source/client/.DS_Store create mode 100644 source/server/.DS_Store create mode 100644 source/shared/.DS_Store diff --git a/source/client/.DS_Store b/source/client/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..f443712f7f27e299936c842b47d2707426e7d784 GIT binary patch literal 6148 zcmeHK&5qMB5FU5KHf34S14w&8io~^Ac2~=yic2WVfh$39092Buun}oolC(Kgm2!r6 z;1#&?B)khJ_{R1^OVb-d2zjLO=bstd`D~A4A`*jHd`#3OA{WZ&Tt(6#+|IfoEmN}x z6snIg&1p;%XtrT(D=Y(+fq#twKD*Z`q!C?Ef^+-p{FYSEA-$*3<5Z5KR7SAmF!2C- z_+1HdL~Z38QrT$z`8R8aVvO>JiuGQ_t!;KuRZPw3U!rN66y?#;SJB#WuI#qmw!7!P z3NB<7lwmn524Vh!OHZXtqsx34Jxj*buzTa7%*rsy#<_Ax;xSBKK2Ne(Rs%W9;zIcb zy20(ZoniN2u{iA?_q>z4_m(|x(Ld?;ytA{@<+9`6ynW~Xli|B`lF1KD141BTppt!q zm+%pppWi(X@+_6vThy`rE_k1TlLn>*`>iuQ!Ad2FtxeY78mu`E&zh`TJpO9m*Jz5q zbF5;5^-Qrw+gJb7%Ifc<{{q%I4b{x1C~w~h>z;G9<0^PgNUD92HqBM-ja5%f-O3+e z!0cC-V}KRQfMviku*v|(2M@~V8>}^|(1Aof0e}vwl_1YQ3GCw;^bOV;(E<_L6{uZ> zd146dj(X47`37r^+MR@Xd 0.95) - alpha = 1; - - alpha = invertfloat(alpha); - - drawfill ([0, 0, 0], [g_width, g_height, 0], [0, 0, 0], alpha, 0); // background - oldfade_alpha = alpha; + vector color = '0 0 0'; + float flash_alpha = 0; + + // Obtain the flash color + switch(screenflash_color) { + case SCREENFLASH_COLOR_BLACK: color = '0 0 0'; break; + case SCREENFLASH_COLOR_WHITE: color = '1 1 1'; break; + default: color = '1 0 0'; break; } - else if (fade_type == 2) { - alpha = sin(((fade_time - time) * 2)); - if (oldfade_alpha > 0.95) - alpha = 1; - - drawfill ([0, 0, 0], [g_width, g_height, 0], [0, 0, 0], alpha, 0); // background - oldfade_alpha = alpha; + + float percentage_complete = screenflash_worktime / (screenflash_duration - screenflash_starttime); + + // Fade Out + if (screenflash_type == SCREENFLASH_FADE_OUT) { + flash_alpha = invertfloat(percentage_complete); } + // Fade In + else if (screenflash_type == SCREENFLASH_FADE_IN) { + flash_alpha = percentage_complete; + } + // Fade In + Fade Out + else { + // Fade In + if (percentage_complete < 0.5) { + flash_alpha = percentage_complete; + } + // Fade Out + else { + flash_alpha = invertfloat(percentage_complete); + } + } + + screenflash_worktime += frametime; + drawfill ([0, 0], [g_width, g_height, 0], color, flash_alpha, 0); } void(float width, float height) HUD_ScrollText = { @@ -1819,6 +1836,6 @@ void(float width, float height) HUD_Draw = HUD_Achievements(width, height); - if (fade_time > time) - HUD_Fade(); + if (screenflash_duration > time) + HUD_Screenflash(); } \ No newline at end of file diff --git a/source/client/main.qc b/source/client/main.qc index 60e51af..06b401a 100644 --- a/source/client/main.qc +++ b/source/client/main.qc @@ -625,7 +625,11 @@ noref void(float width, float height, float menushown) CSQC_UpdateView = } if(in_menu) { - //in menu.qc + // sorta-nasty hack: flashes should still draw if we're + // drawing the menu. + if (screenflash_duration > time) + HUD_Screenflash(); + Draw_Menu(); setlocaluserinfo(0, "in_menu", "1"); } @@ -907,6 +911,13 @@ noref void() CSQC_Parse_Event = case CSQC_EVENT_PLAYERNAME: character_name = readstring(); break; + case CSQC_EVENT_SCREENFLASH: + screenflash_color = readbyte(); + screenflash_duration = time + readbyte(); + screenflash_type = readbyte(); + screenflash_worktime = 0; + screenflash_starttime = time; + break; case EVENT_WEAPONRECOIL: local vector rec; rec_x = readcoord()/5; @@ -979,10 +990,6 @@ noref void() CSQC_Parse_Event = case EVENT_MAPTYPE: map_compatibility_mode = readbyte(); break; - case EVENT_BLACKOUT: - fade_time = readbyte(); - fade_type = readbyte(); - break; case EVENT_WORLDDATA: chaptertitle = readstring(); location = readstring(); diff --git a/source/server/.DS_Store b/source/server/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..3f4c639b5797cce4697996ac66ce0b3cdc29102f GIT binary patch literal 6148 zcmeHKISv9b477n_C7LZM^96noA$S2FKpX`Uf&%Eb;$1wA@lk*lI%v>Xawc&+i894{ zEh0L*Zl@xxh%|6Rx!KS++c)poAR`Kdj$ WYhoAZbi|zw MAX_POWERUPS - 1) @@ -98,7 +97,6 @@ PU_AddToStruct = // Populate the Struct at Index powerup_array[powerup_count].id = id; powerup_array[powerup_count].occupied = true; - powerup_array[powerup_count].flash_screen = flash_screen; powerup_array[powerup_count].model_path = model_path; powerup_array[powerup_count].voiceover_path = voiceover_path; powerup_array[powerup_count].function = function; @@ -175,22 +173,6 @@ float() PU_GetNextPowerUp = return id; }; -// -// PU_ShouldFlashScreen(id) -// Returns flash_screen from Power-Up struct. -// -float(float id) PU_ShouldFlashScreen = -{ - if (id == -1) - return false; - - for(float i = 0; i < MAX_POWERUPS - 1; i++) { - if (powerup_array[i].id == id) - return powerup_array[i].flash_screen; - } - return false; -}; - // // PU_ModelPath(id) // Returns model_path from Power-Up struct. @@ -339,6 +321,9 @@ void() PU_NukeKill = // void() PU_Nuke = { + // Flash the screen white + nzp_screenflash(world, SCREENFLASH_COLOR_WHITE, 1, SCREENFLASH_FADE_INANDOUT); + // if there's already one active, just increment the point multiplier if (nuke_powerup_active == true) { nuke_powerups_activated++; @@ -589,15 +574,15 @@ void() PU_Init = } // Just add all of them for now - PU_AddToStruct(PU_NUKE, true, "models/pu/nuke!.mdl", "sounds/pu/kaboom.wav", PU_Nuke, + PU_AddToStruct(PU_NUKE, "models/pu/nuke!.mdl", "sounds/pu/kaboom.wav", PU_Nuke, PU_NullRequirement ); - PU_AddToStruct(PU_INSTAKILL, false, "models/pu/instakill!.mdl", "sounds/pu/insta_kill.wav", PU_InstaKill, + PU_AddToStruct(PU_INSTAKILL, "models/pu/instakill!.mdl", "sounds/pu/insta_kill.wav", PU_InstaKill, PU_NullRequirement ); - PU_AddToStruct(PU_DOUBLEPTS, false, "models/pu/x2!.mdl", "sounds/pu/double_points.wav", PU_DoublePoints, + PU_AddToStruct(PU_DOUBLEPTS, "models/pu/x2!.mdl", "sounds/pu/double_points.wav", PU_DoublePoints, PU_NullRequirement ); - PU_AddToStruct(PU_CARPENTER, false, "models/pu/carpenter!.mdl", "sounds/pu/carpenter.wav", PU_Carpenter, + PU_AddToStruct(PU_CARPENTER, "models/pu/carpenter!.mdl", "sounds/pu/carpenter.wav", PU_Carpenter, PU_CarpenterRequirement ); - PU_AddToStruct(PU_MAXAMMO, false, "models/pu/maxammo!.mdl", "sounds/pu/maxammo.wav", PU_MaxAmmo, + PU_AddToStruct(PU_MAXAMMO, "models/pu/maxammo!.mdl", "sounds/pu/maxammo.wav", PU_MaxAmmo, PU_NullRequirement ); // Nuke requires an extra Precache @@ -678,10 +663,6 @@ void() PU_Touch = Light_None(self); self.touch = SUB_Null; - // Flash the Screen if permitted - if (PU_ShouldFlashScreen(self.walktype) == true) - stuffcmd(other, "bf\n"); - // Run Power-Up function PU_LogicFunction(self.walktype); } diff --git a/source/server/main.qc b/source/server/main.qc index 0276933..cba44be 100644 --- a/source/server/main.qc +++ b/source/server/main.qc @@ -39,6 +39,7 @@ void() main = } float ai_delay_time; +float time_before_gamestart; // // Way_SetBrushEntNonSolid(ent_name) @@ -90,6 +91,10 @@ void() StartFrame = return; } + // Start completely blacked out + //if (time < 5) + + if (roundinit) { Round_Core(); @@ -122,19 +127,32 @@ void() StartFrame = } } else { - entity SpawnedIn; - SpawnedIn = find(world, classname, "player"); - - if (SpawnedIn) { - entity getdog = find(world, classname, "spawn_dog"); - if (getdog) - gotdog = 1; - else - gotdog = 0; + if (!time_before_gamestart) { + entity SpawnedIn; + SpawnedIn = find(world, classname, "player"); + if (SpawnedIn) { + Compat_Init(); + time_before_gamestart = time + 3; + } + return; + } else if (time_before_gamestart < time) { updateDogRound(); InitRounds(); - Compat_Init(); + nzp_screenflash(world, SCREENFLASH_COLOR_BLACK, 1, SCREENFLASH_FADE_OUT); + sound(self, CHAN_AUTO, "sounds/rounds/splash.wav", 1, ATTN_NONE); + + entity players = find(world, classname, "player"); + + while(players != world) { + if (players.name != "") + nzp_setplayername(players, players.name); + + players = find(players, classname, "player"); + } + + } else { + nzp_screenflash(world, SCREENFLASH_COLOR_BLACK, 90, SCREENFLASH_FADE_OUT); } } } diff --git a/source/server/player.qc b/source/server/player.qc index ddc0ab3..9086924 100644 --- a/source/server/player.qc +++ b/source/server/player.qc @@ -561,9 +561,6 @@ void() PlayerPostThink = if(self.isspec) return; - if (time < 5 && self.name != "") - nzp_setplayername(self, self.name); - //landsound if((self.oldvelocity_z < -212) && (self.flags & FL_ONGROUND)) { @@ -890,12 +887,6 @@ void() PlayerSpawn = self.reviving = 0; self.perks = G_PERKS; - if (rounds < 1 && player_count == 0) { - sound(self, CHAN_AUTO, "sounds/rounds/splash.wav", 1, ATTN_NONE); - sound(self, CHAN_ITEM, "sounds/rounds/nround.wav", 0.75, ATTN_NONE); - } - - PromptLevelChange(self.nextthink + 3, 1, self); UpdatePlayerCount(player_count); #ifdef FTE @@ -921,6 +912,11 @@ void() PlayerSpawn = if (G_STARTROUND != 1) { rounds = G_STARTROUND - 1; } + + // Make sure players joining after game start are still allowed + // to see their name. + if (time >= 5 && self.name != "") + nzp_setplayername(self, self.name); }; void() SpectatorSpawn = diff --git a/source/server/utilities/game_restart.qc b/source/server/utilities/game_restart.qc index af7ee0c..2f0afcf 100644 --- a/source/server/utilities/game_restart.qc +++ b/source/server/utilities/game_restart.qc @@ -370,4 +370,6 @@ void() Soft_Restart = { InitRounds(); self.isspec = false; PutClientInServer(); + + nzp_screenflash(world, SCREENFLASH_COLOR_BLACK, 1, SCREENFLASH_FADE_OUT); } \ No newline at end of file diff --git a/source/shared/.DS_Store b/source/shared/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..77dcbcd7753126ff991d588c29b310d748dc4ba0 GIT binary patch literal 6148 zcmeHK!EO^V5FMu}-KauJC6IbST8V2^+Nu;qT$a!txONd70EOM`LRTzynoZb46lu@! zF}?C7{0@C%yAe&xu?WzNG=Agp%vgS2*=r(FgITsm)Fq+-%Gm0lxj}fG^_sN2XC0`x z#*5O7($b{pb3u{6p8?*xHf5C42dY-~?-|B+ep;~$S;nPxHTL`bJsp=tHQn9)p;~M0 z^*bBEMz9&Yi%(4*Pm}4a8YGi9+4<9`}8Gb51YxC7n zukc-3x$E%~zQI_o=Sw`%rO_YZ5co~8jO{bKg9l_3Mht6oU!qhpker0Nl zYQ!cqMjeeBj^6@yj@ma=P!CorperH_2m`{vtuf%w#$fZ-W{|?dfH3f{GQj6U2xW{s zHV*C4fyO=ofNi*~z_!2sz>pol$YbLW9*AUN(4~{IGoy~5 zS@{==@(&Lc+Hg{lLurKpVc;qQYp&bn`~Ud&@Bgbw(h~-Rf&YpD)jo=k23V56TdysS v@7fUh9?HUTjl*RM40{zLmapP%s1^7_Hh_`G#vwcq`4O-*NFxmVQ3fsmKFW3X literal 0 HcmV?d00001 diff --git a/source/shared/defs/custom.qc b/source/shared/defs/custom.qc index 63af388..0cd7726 100644 --- a/source/shared/defs/custom.qc +++ b/source/shared/defs/custom.qc @@ -73,20 +73,37 @@ #define CSQC_EVENT_PLAYERNAME 17 // player_name -#define EVENT_UPDATE 18 -#define EVENT_BLACKOUT 19 -#define EVENT_WORLDDATA 20 +#define CSQC_EVENT_SCREENFLASH 18 // screenflash_color + // screenflash_duration + // screenflash_type + +#define EVENT_UPDATE 19 +#define EVENT_BLACKOUT 20 +#define EVENT_WORLDDATA 21 #define EVENT_PLAYERUPDATE 22 -#define EVENT_REVIVEON 24 -#define EVENT_REVIVEOFF 25 -#define EVENT_REVIVECHANGE 26 -#define EVENT_WEAPONRECOIL 27 -#define EVENT_GRENADEPULSE 29 -#define EVENT_BETTYPROMPT 30 -#define EVENT_CHATMESSAGE 31 -#define EVENT_DOUBLETAPUPDATE 32 -#define EVENT_ENDGAME 33 -#define EVENT_MAPTYPE 34 +#define EVENT_REVIVEON 23 +#define EVENT_REVIVEOFF 24 +#define EVENT_REVIVECHANGE 25 +#define EVENT_WEAPONRECOIL 26 +#define EVENT_GRENADEPULSE 27 +#define EVENT_BETTYPROMPT 28 +#define EVENT_CHATMESSAGE 29 +#define EVENT_DOUBLETAPUPDATE 30 +#define EVENT_ENDGAME 31 +#define EVENT_MAPTYPE 32 + +// +// Types of screen-flashes, global. +// + +// Colors +#define SCREENFLASH_COLOR_WHITE 0 +#define SCREENFLASH_COLOR_BLACK 1 + +// Types +#define SCREENFLASH_FADE_INANDOUT 0 +#define SCREENFLASH_FADE_IN 1 +#define SCREENFLASH_FADE_OUT 2 // Define our FTE platform #ifndef STANDARD @@ -296,9 +313,10 @@ float game_over; // invert float takes in float value between 0 and 1, inverts position // eg: 0.1 returns 0.9, 0.34 returns 0.66 float invertfloat(float input) { - - if (input <= 0 || input >= 1) - return input; // out of boundaries - - return (1 - input); + if (input < 0) + return 0; // adjust to lower boundary + else if (input > 1) + return 1; // adjust to upper boundary + else + return (1 - input); }