mirror of
https://github.com/nzp-team/quakec.git
synced 2025-02-21 19:21:54 +00:00
Server: Have Power Switch toggle lightstyles
This commit is contained in:
parent
f2a80afd3b
commit
0553d33213
4 changed files with 92 additions and 87 deletions
|
@ -476,6 +476,13 @@ void (float achievement_id, float progress_value, optional entity who) UpdateAch
|
||||||
// Unrelated to engine, but custom functions
|
// Unrelated to engine, but custom functions
|
||||||
// *****************************************
|
// *****************************************
|
||||||
|
|
||||||
|
void(string modelname) Precache_Set = // Precache model, and set myself to it
|
||||||
|
{
|
||||||
|
precache_model(modelname);
|
||||||
|
setmodel(self, modelname);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
float(entity who, entity target) isFacing =
|
float(entity who, entity target) isFacing =
|
||||||
{
|
{
|
||||||
float who_angle = who.angles_y;
|
float who_angle = who.angles_y;
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
Spawns and handles Quake's lights and torches
|
Spawns and handles Quake's lights and torches
|
||||||
|
|
||||||
Copyright (C) 2021 NZ:P Team
|
Copyright (C) 2021-2022 NZ:P Team
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or
|
This program is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the GNU General Public License
|
modify it under the terms of the GNU General Public License
|
||||||
|
@ -25,94 +25,74 @@
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
float START_OFF = 1; // Light on/off spawnflag
|
#define LIGHT_SPAWNFLAG_STARTOFF 1 // Light starts turned off but can be triggered
|
||||||
void() Light_setup; // Definition from Lights.qc
|
// On via Power Switch.
|
||||||
|
|
||||||
void(string modelname) Precache_Set = // Precache model, and set myself to it
|
#define LIGHT_SPAWNFLAG_STARTON 2 // Opposite of STARTOFF, light turns Off when
|
||||||
|
// Power is On.
|
||||||
|
|
||||||
|
//
|
||||||
|
// LS_Setup()
|
||||||
|
// Defines all of the LightStyles in the Game.
|
||||||
|
//
|
||||||
|
void() LS_Setup =
|
||||||
{
|
{
|
||||||
precache_model(modelname);
|
// Lightstyles take alphebetical strings of input, from a-z.
|
||||||
setmodel(self, modelname);
|
// a = complete darkness.
|
||||||
};
|
// z = maximum brightness.
|
||||||
|
lightstyle(0, "m"); // 0 : Normal
|
||||||
|
lightstyle(1, "mmnmmommommnonmmonqnmmo"); // 1 : Flicker
|
||||||
|
lightstyle(2, "abcdefghijklmnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba"); // 2 : Slow Strong Pulse
|
||||||
|
lightstyle(3, "mmmmmaaaaammmmmaaaaaabcdefgabcdefg"); // 3 : Candle
|
||||||
|
lightstyle(4, "mamamamamama"); // 4 : Fast Strobe
|
||||||
|
lightstyle(5, "jklmnopqrstuvwxyzyxwvutsrqponmlkj"); // 5 : Gentle Pulse
|
||||||
|
lightstyle(6, "nmonqnmomnmomomno"); // 6 : Flicker 2
|
||||||
|
lightstyle(7, "mmmaaaabcdefgmmmmaaaammmaamm"); // 7 : Candle 2
|
||||||
|
lightstyle(8, "mmmaaammmaaammmabcdefaaaammmmabcdefmmmaaaa"); // 8 : Candle 3
|
||||||
|
lightstyle(9, "aaaaaaaazzzzzzzz"); // 9 : Slow Strobe
|
||||||
|
lightstyle(10, "mmamammmmammamamaaamammma"); // 10: Fluro
|
||||||
|
lightstyle(11, "abcdefghijklmnopqrrqponmlkjihgfedcba"); // 11: Slow Pulse (no black) // 64: Off.
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// L_Setup()
|
||||||
|
// Initialization for Lights.
|
||||||
|
//
|
||||||
|
void() L_Setup =
|
||||||
|
{
|
||||||
|
// If it's not vanilla ZHLT, cut it off.
|
||||||
|
if (self.style > 12)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Set the Light to be Off if the spawnflag is set.
|
||||||
|
if ((self.spawnflags & LIGHT_SPAWNFLAG_STARTOFF)) {
|
||||||
|
// Store the other value for later.
|
||||||
|
self.score = self.style;
|
||||||
|
lightstyle(self.style, "a");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// --------------------
|
||||||
|
// Generic Light Entities
|
||||||
|
// --------------------
|
||||||
|
//
|
||||||
|
|
||||||
void() light = // Basic Light
|
void() light = // Basic Light
|
||||||
{
|
{ L_Setup(); }
|
||||||
Light_setup(); // Setup Light
|
|
||||||
}
|
|
||||||
|
|
||||||
void() light_fluoro = // Light with hum ambient
|
void() light_fluoro = // Light with hum ambient
|
||||||
{
|
{ L_Setup(); }
|
||||||
Light_setup(); // Setup Light
|
void() light_environment = // Sun cast from Sky
|
||||||
};
|
{ makestatic(self); }
|
||||||
|
|
||||||
void() light_environment = // Basic Light
|
|
||||||
{
|
|
||||||
makestatic(self); // Static entity. Never changes.
|
|
||||||
}
|
|
||||||
|
|
||||||
void() light_fluorospark = // Light with buzz ambient
|
void() light_fluorospark = // Light with buzz ambient
|
||||||
{
|
{ L_Setup(); }
|
||||||
Light_setup(); // Setup Light
|
|
||||||
};
|
|
||||||
|
|
||||||
void() light_globe = // Light with visible globe
|
void() light_globe = // Light with visible globe
|
||||||
{
|
{ Precache_Set("progs/s_light.spr"); makestatic(self); }
|
||||||
Precache_Set("progs/s_light.spr"); // Set model
|
|
||||||
makestatic(self); // Static entity. Never changes.
|
|
||||||
}
|
|
||||||
|
|
||||||
void() light_torch_small_walltorch = // Light with visible wall torch
|
void() light_torch_small_walltorch = // Light with visible wall torch
|
||||||
{
|
{ Precache_Set("progs/flame.mdl"); makestatic(self); }
|
||||||
Precache_Set("progs/flame.mdl"); // Set model
|
void() light_torch_small_yellow = // Light with small flame & fire sound
|
||||||
makestatic(self); // Static entity. Never changes.
|
{ Precache_Set("progs/flame2.mdl"); makestatic(self); }
|
||||||
};
|
void() light_torch_large_yellow = // Light with larger flame & fire sound
|
||||||
|
{ Precache_Set("progs/flame2.mdl"); self.frame = 1; makestatic(self); }
|
||||||
void() light_flame_small_yellow = // Light with small flame & fire sound
|
|
||||||
{
|
|
||||||
Precache_Set("progs/flame2.mdl"); // Set model
|
|
||||||
makestatic(self); // Static entity. Never changes.
|
|
||||||
};
|
|
||||||
|
|
||||||
void() light_flame_large_yellow = // Light with larger flame & fire sound
|
|
||||||
{
|
|
||||||
Precache_Set("progs/flame2.mdl"); // Set model
|
|
||||||
self.frame = 1; // Switch to second frame (large)
|
|
||||||
makestatic(self); // Static entity. Never changes.
|
|
||||||
};
|
|
||||||
|
|
||||||
void() light_flame_small_white = // Light with small flame & fire sound
|
void() light_flame_small_white = // Light with small flame & fire sound
|
||||||
{
|
{ Precache_Set("progs/flame2.mdl"); makestatic(self); }
|
||||||
Precache_Set("progs/flame2.mdl"); // Set model
|
|
||||||
makestatic(self); // Static entity. Never changes.
|
|
||||||
};
|
|
||||||
|
|
||||||
void() Light_setup = // Set light on or off, as per spawnflags
|
|
||||||
{
|
|
||||||
if (self.style < 32) {
|
|
||||||
return;
|
|
||||||
} // Dont switch other styles.
|
|
||||||
|
|
||||||
if (self.spawnflags & START_OFF)
|
|
||||||
lightstyle(self.style, "a"); // If light starts off, set it off.
|
|
||||||
else
|
|
||||||
lightstyle(self.style, "m"); // If light starts ON, turn in ON. Simple :)
|
|
||||||
}
|
|
||||||
|
|
||||||
void() LightStyles_setup =
|
|
||||||
{
|
|
||||||
// Setup light animation tables. 'a' is total darkness, 'z' is maxbright.
|
|
||||||
|
|
||||||
lightstyle(0,"m"); // Style 0: Normal
|
|
||||||
lightstyle(1,"mmnmmommommnonmmonqnmmo"); // Style 1: Flicker
|
|
||||||
lightstyle(2,"abcdefghijklmnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba"); // Style 2: Slow Strong Pulse
|
|
||||||
lightstyle(3,"mmmmmaaaaammmmmaaaaaabcdefgabcdefg"); // Style 3: Candle
|
|
||||||
lightstyle(4,"mamamamamama"); // Style 4: Fast Strobe
|
|
||||||
lightstyle(5,"jklmnopqrstuvwxyzyxwvutsrqponmlkj"); // Style 5: Gentle Pulse
|
|
||||||
lightstyle(6,"nmonqnmomnmomomno"); // Style 6: Flicker 2
|
|
||||||
lightstyle(7,"mmmaaaabcdefgmmmmaaaammmaamm"); // Style 7: Candle 2
|
|
||||||
lightstyle(8,"mmmaaammmaaammmabcdefaaaammmmabcdefmmmaaaa"); // Style 8: Candle 3
|
|
||||||
lightstyle(9,"aaaaaaaazzzzzzzz"); // Style 9: Slow Strobe
|
|
||||||
lightstyle(10,"mmamammmmammamamaaamammma"); // Style 10: Fluro
|
|
||||||
lightstyle(11,"abcdefghijklmnopqrrqponmlkjihgfedcba"); // Style 11: Slow Pulse (no black)
|
|
||||||
};
|
|
||||||
|
|
|
@ -1049,16 +1049,32 @@ void() turnpower4 =[ 4, SUB_Null ] {self.frame = 4;};
|
||||||
|
|
||||||
//
|
//
|
||||||
// Turn_Lights()
|
// Turn_Lights()
|
||||||
// Activates Perk Light Effects
|
// Activates Perk Light Effects and LightStyles
|
||||||
//
|
//
|
||||||
void() Turn_Lights =
|
void() Turn_Lights =
|
||||||
{
|
{
|
||||||
local entity tempe = findfloat(world, requirespower, 1);
|
// Perk Lights
|
||||||
|
entity tempe = findfloat(world, requirespower, 1);
|
||||||
while (tempe)
|
while (tempe)
|
||||||
{
|
{
|
||||||
Turn_PerkLight_On(tempe);
|
Turn_PerkLight_On(tempe);
|
||||||
tempe = findfloat (tempe, requirespower, 1);
|
tempe = findfloat (tempe, requirespower, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Light Styles
|
||||||
|
tempe = find(world, classname, "light");
|
||||||
|
while(tempe)
|
||||||
|
{
|
||||||
|
if (tempe.spawnflags & LIGHT_SPAWNFLAG_STARTOFF) {
|
||||||
|
tempe.style = tempe.score;
|
||||||
|
LS_Setup();
|
||||||
|
}/* else if (tempe.spawnflags & LIGHT_SPAWNFLAG_STARTON) {
|
||||||
|
tempe.style = 64;
|
||||||
|
lightstyle(tempe.style, "a");
|
||||||
|
}*/
|
||||||
|
|
||||||
|
tempe = find(tempe, classname, "light");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void() LightStyles_setup;
|
void() LS_Setup;
|
||||||
void() SUB_Remove = {remove(self);}
|
void() SUB_Remove = {remove(self);}
|
||||||
|
|
||||||
//called when starting server/loading the map
|
//called when starting server/loading the map
|
||||||
|
@ -306,7 +306,9 @@ void() precaches =
|
||||||
void() worldspawn =
|
void() worldspawn =
|
||||||
{
|
{
|
||||||
precaches();
|
precaches();
|
||||||
LightStyles_setup();
|
|
||||||
|
// Define all of our Light Styles
|
||||||
|
LS_Setup();
|
||||||
|
|
||||||
#ifdef PC
|
#ifdef PC
|
||||||
clientstat(STAT_CURRENTMAG, EV_FLOAT, currentmag);
|
clientstat(STAT_CURRENTMAG, EV_FLOAT, currentmag);
|
||||||
|
|
Loading…
Reference in a new issue