2022-02-08 18:42:28 +00:00
|
|
|
/*
|
|
|
|
server/entities/lights.qc
|
|
|
|
|
|
|
|
Spawns and handles Quake's lights and torches
|
|
|
|
|
2024-01-07 23:24:48 +00:00
|
|
|
Copyright (C) 2021-2024 NZ:P Team
|
2022-02-08 18:42:28 +00:00
|
|
|
|
|
|
|
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:
|
|
|
|
|
|
|
|
Free Software Foundation, Inc.
|
|
|
|
59 Temple Place - Suite 330
|
|
|
|
Boston, MA 02111-1307, USA
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2022-04-06 13:59:54 +00:00
|
|
|
#define LIGHT_SPAWNFLAG_STARTOFF 1 // Light starts turned off but can be triggered
|
|
|
|
// On via Power Switch.
|
2022-02-08 18:42:28 +00:00
|
|
|
|
2022-04-06 13:59:54 +00:00
|
|
|
#define LIGHT_SPAWNFLAG_STARTON 2 // Opposite of STARTOFF, light turns Off when
|
|
|
|
// Power is On.
|
2022-02-08 18:42:28 +00:00
|
|
|
|
2022-04-06 13:59:54 +00:00
|
|
|
//
|
|
|
|
// LS_Setup()
|
|
|
|
// Defines all of the LightStyles in the Game.
|
|
|
|
//
|
|
|
|
void() LS_Setup =
|
2022-02-08 18:42:28 +00:00
|
|
|
{
|
2022-04-06 13:59:54 +00:00
|
|
|
// Lightstyles take alphebetical strings of input, from a-z.
|
|
|
|
// 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.
|
2022-02-08 18:42:28 +00:00
|
|
|
}
|
|
|
|
|
2022-04-06 13:59:54 +00:00
|
|
|
//
|
|
|
|
// L_Setup()
|
|
|
|
// Initialization for Lights.
|
|
|
|
//
|
|
|
|
void() L_Setup =
|
2022-02-08 18:42:28 +00:00
|
|
|
{
|
2022-04-06 13:59:54 +00:00
|
|
|
// If it's not vanilla ZHLT, cut it off.
|
2024-06-29 17:08:03 +00:00
|
|
|
if (self.style > 12 || !self.targetname) {
|
|
|
|
remove(self);
|
|
|
|
return;
|
|
|
|
}
|
2022-04-06 13:59:54 +00:00
|
|
|
|
|
|
|
// Set the Light to be Off if the spawnflag is set.
|
2022-04-06 14:25:24 +00:00
|
|
|
/*if ((self.spawnflags & LIGHT_SPAWNFLAG_STARTOFF)) {
|
2022-04-06 13:59:54 +00:00
|
|
|
// Store the other value for later.
|
2022-04-06 14:25:24 +00:00
|
|
|
//self.score = self.style;
|
2022-04-06 13:59:54 +00:00
|
|
|
lightstyle(self.style, "a");
|
2022-04-06 14:25:24 +00:00
|
|
|
}*/
|
2022-02-08 18:42:28 +00:00
|
|
|
}
|
|
|
|
|
2022-04-06 13:59:54 +00:00
|
|
|
//
|
|
|
|
// --------------------
|
|
|
|
// Generic Light Entities
|
|
|
|
// --------------------
|
|
|
|
//
|
|
|
|
|
|
|
|
void() light = // Basic Light
|
|
|
|
{ L_Setup(); }
|
|
|
|
void() light_fluoro = // Light with hum ambient
|
|
|
|
{ L_Setup(); }
|
|
|
|
void() light_environment = // Sun cast from Sky
|
|
|
|
{ makestatic(self); }
|
|
|
|
void() light_fluorospark = // Light with buzz ambient
|
|
|
|
{ L_Setup(); }
|
|
|
|
void() light_globe = // Light with visible globe
|
2023-10-31 17:33:43 +00:00
|
|
|
{ L_Setup(); makestatic(self); }
|
2022-04-06 13:59:54 +00:00
|
|
|
void() light_torch_small_walltorch = // Light with visible wall torch
|
2023-10-31 17:33:43 +00:00
|
|
|
{ L_Setup(); makestatic(self); }
|
|
|
|
void() light_flame_large_yellow =
|
|
|
|
{ L_Setup(); makestatic(self); }
|
2022-04-06 13:59:54 +00:00
|
|
|
void() light_torch_small_yellow = // Light with small flame & fire sound
|
2023-10-31 17:33:43 +00:00
|
|
|
{ L_Setup(); makestatic(self); }
|
2022-04-06 13:59:54 +00:00
|
|
|
void() light_torch_large_yellow = // Light with larger flame & fire sound
|
2023-10-31 17:33:43 +00:00
|
|
|
{ L_Setup(); self.frame = 1; makestatic(self); }
|
2022-04-06 13:59:54 +00:00
|
|
|
void() light_flame_small_white = // Light with small flame & fire sound
|
2023-10-31 17:33:43 +00:00
|
|
|
{ L_Setup(); makestatic(self); }
|
2023-09-22 18:39:10 +00:00
|
|
|
void() light_spot = // Spotlight
|
2023-10-31 17:33:43 +00:00
|
|
|
{ L_Setup(); }
|
2023-01-16 04:13:06 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// --------------------
|
|
|
|
// Spawnable Dynamic Lights
|
|
|
|
// --------------------
|
|
|
|
//
|
2023-02-05 21:03:57 +00:00
|
|
|
|
2023-03-05 16:54:09 +00:00
|
|
|
//
|
|
|
|
// Light_Red(e)
|
|
|
|
// RGB: 255, 56, 56
|
|
|
|
//
|
2023-09-02 15:12:24 +00:00
|
|
|
void(entity e, optional float fullbright) Light_Red =
|
2023-03-05 16:54:09 +00:00
|
|
|
{
|
2023-09-02 15:12:24 +00:00
|
|
|
if (fullbright)
|
|
|
|
e.effects = EF_FULLBRIGHT;
|
2023-03-05 16:54:09 +00:00
|
|
|
|
|
|
|
#ifndef FTE
|
|
|
|
|
|
|
|
e.effects = e.effects | EF_REDLIGHT;
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
{
|
|
|
|
e.pflags = PFLAGS_FULLDYNAMIC;
|
|
|
|
e.light_lev = 100;
|
|
|
|
e.color_x = 2;
|
|
|
|
e.color_y = 0.25;
|
|
|
|
e.color_z = 0.25;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // FTE
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Light_Green(e)
|
|
|
|
// RGB: 56, 255, 56
|
|
|
|
//
|
2023-09-02 15:12:24 +00:00
|
|
|
void(entity e, optional float fullbright) Light_Green =
|
2023-03-05 16:54:09 +00:00
|
|
|
{
|
2023-09-02 15:12:24 +00:00
|
|
|
if (fullbright)
|
|
|
|
e.effects = EF_FULLBRIGHT;
|
2023-03-05 16:54:09 +00:00
|
|
|
|
|
|
|
#ifndef FTE
|
|
|
|
|
|
|
|
e.effects = e.effects | EF_GREENLIGHT;
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
{
|
|
|
|
e.pflags = PFLAGS_FULLDYNAMIC;
|
|
|
|
e.light_lev = 100;
|
|
|
|
e.color_x = 0.25;
|
|
|
|
e.color_y = 2;
|
|
|
|
e.color_z = 0.25;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // FTE
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Light_Blue(e)
|
|
|
|
// RGB: 56, 56, 255
|
|
|
|
//
|
2023-09-02 15:12:24 +00:00
|
|
|
void(entity e, optional float fullbright) Light_Blue =
|
2023-03-05 16:54:09 +00:00
|
|
|
{
|
2023-09-02 15:12:24 +00:00
|
|
|
if (fullbright)
|
|
|
|
e.effects = EF_FULLBRIGHT;
|
2023-03-05 16:54:09 +00:00
|
|
|
|
|
|
|
#ifndef FTE
|
|
|
|
|
|
|
|
e.effects = e.effects | EF_BLUELIGHT;
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
{
|
|
|
|
e.pflags = PFLAGS_FULLDYNAMIC;
|
|
|
|
e.light_lev = 100;
|
|
|
|
e.color_x = 0.25;
|
|
|
|
e.color_y = 0.25;
|
|
|
|
e.color_z = 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // FTE
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Light_Orange(e)
|
|
|
|
// RGB: 255, 128, 0
|
|
|
|
//
|
2023-09-02 15:12:24 +00:00
|
|
|
void(entity e, optional float fullbright) Light_Orange =
|
2023-03-05 16:54:09 +00:00
|
|
|
{
|
2023-09-02 15:12:24 +00:00
|
|
|
if (fullbright)
|
|
|
|
e.effects = EF_FULLBRIGHT;
|
2023-03-05 16:54:09 +00:00
|
|
|
|
|
|
|
#ifndef FTE
|
|
|
|
|
|
|
|
e.effects = e.effects | EF_ORANGELIGHT;
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
{
|
|
|
|
e.pflags = PFLAGS_FULLDYNAMIC;
|
|
|
|
e.light_lev = 100;
|
|
|
|
e.color_x = 2;
|
|
|
|
e.color_y = 1;
|
|
|
|
e.color_z = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // FTE
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Light_Purple(e)
|
|
|
|
// RGB: 255, 28, 255
|
|
|
|
//
|
2023-09-02 15:12:24 +00:00
|
|
|
void(entity e, optional float fullbright) Light_Purple =
|
2023-03-05 16:54:09 +00:00
|
|
|
{
|
2023-09-02 15:12:24 +00:00
|
|
|
if (fullbright)
|
|
|
|
e.effects = EF_FULLBRIGHT;
|
2023-03-05 16:54:09 +00:00
|
|
|
|
|
|
|
#ifndef FTE
|
|
|
|
|
|
|
|
e.effects = e.effects | EF_PURPLELIGHT;
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
{
|
|
|
|
e.pflags = PFLAGS_FULLDYNAMIC;
|
|
|
|
e.light_lev = 100;
|
|
|
|
e.color_x = 2;
|
|
|
|
e.color_y = 0.25;
|
|
|
|
e.color_z = 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // FTE
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Light_Cyan(e)
|
|
|
|
// RGB: 97, 178, 248
|
|
|
|
//
|
2023-09-02 15:12:24 +00:00
|
|
|
void(entity e, optional float fullbright) Light_Cyan =
|
2023-03-05 16:54:09 +00:00
|
|
|
{
|
2023-09-02 15:12:24 +00:00
|
|
|
if (fullbright)
|
|
|
|
e.effects = EF_FULLBRIGHT;
|
2023-03-05 16:54:09 +00:00
|
|
|
|
|
|
|
#ifndef FTE
|
|
|
|
|
|
|
|
e.effects = e.effects | EF_CYANLIGHT;
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
{
|
|
|
|
e.pflags = PFLAGS_FULLDYNAMIC;
|
|
|
|
e.light_lev = 100;
|
|
|
|
e.color_x = 0.765;
|
|
|
|
e.color_y = 1.4;
|
|
|
|
e.color_z = 1.95;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // FTE
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Light_Pink(e)
|
|
|
|
// RGB: 255, 180, 180
|
|
|
|
//
|
2023-09-02 15:12:24 +00:00
|
|
|
void(entity e, optional float fullbright) Light_Pink =
|
2023-03-05 16:54:09 +00:00
|
|
|
{
|
2023-09-02 15:12:24 +00:00
|
|
|
if (fullbright)
|
|
|
|
e.effects = EF_FULLBRIGHT;
|
2023-03-05 16:54:09 +00:00
|
|
|
|
|
|
|
#ifndef FTE
|
|
|
|
|
|
|
|
e.effects = e.effects | EF_PINKLIGHT;
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
{
|
|
|
|
e.pflags = PFLAGS_FULLDYNAMIC;
|
|
|
|
e.light_lev = 100;
|
|
|
|
e.color_x = 2.37;
|
|
|
|
e.color_y = 1.35;
|
|
|
|
e.color_z = 1.35;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // FTE
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Light_Lime(e)
|
|
|
|
// RGB: 128, 255, 128
|
|
|
|
//
|
2023-09-02 15:12:24 +00:00
|
|
|
void(entity e, optional float fullbright) Light_Lime =
|
2023-03-05 16:54:09 +00:00
|
|
|
{
|
2023-09-02 15:12:24 +00:00
|
|
|
if (fullbright)
|
|
|
|
e.effects = EF_FULLBRIGHT;
|
2023-03-05 16:54:09 +00:00
|
|
|
|
|
|
|
#ifndef FTE
|
|
|
|
|
|
|
|
e.effects = e.effects | EF_LIMELIGHT;
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
{
|
|
|
|
e.pflags = PFLAGS_FULLDYNAMIC;
|
|
|
|
e.light_lev = 100;
|
|
|
|
e.color_x = 1;
|
|
|
|
e.color_y = 2;
|
|
|
|
e.color_z = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // FTE
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Light_Yellow(e)
|
|
|
|
// RGB: 255, 255, 128
|
|
|
|
//
|
2023-09-02 15:12:24 +00:00
|
|
|
void(entity e, optional float fullbright) Light_Yellow =
|
2023-03-05 16:54:09 +00:00
|
|
|
{
|
2023-09-02 15:12:24 +00:00
|
|
|
if (fullbright)
|
|
|
|
e.effects = EF_FULLBRIGHT;
|
2023-03-05 16:54:09 +00:00
|
|
|
|
|
|
|
#ifndef FTE
|
|
|
|
|
|
|
|
e.effects = e.effects | EF_YELLOWLIGHT;
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
{
|
|
|
|
e.pflags = PFLAGS_FULLDYNAMIC;
|
|
|
|
e.light_lev = 100;
|
|
|
|
e.color_x = 2;
|
|
|
|
e.color_y = 2;
|
|
|
|
e.color_z = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // FTE
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Light_None(e)
|
|
|
|
// Resets all Perk Light Effects.
|
|
|
|
//
|
|
|
|
void(entity e) Light_None =
|
|
|
|
{
|
|
|
|
e.effects = 0;
|
|
|
|
|
|
|
|
#ifdef FTE
|
|
|
|
|
|
|
|
{
|
|
|
|
e.pflags = 0;
|
|
|
|
e.light_lev = 0;
|
|
|
|
e.color_x = 0;
|
|
|
|
e.color_y = 0;
|
|
|
|
e.color_z = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // FTE
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2023-02-05 21:03:57 +00:00
|
|
|
#ifdef FTE
|
|
|
|
|
2023-01-16 04:13:06 +00:00
|
|
|
void(entity what, float fullbright, float light_level,
|
|
|
|
float red, float green, float blue) Light_Custom =
|
|
|
|
{
|
|
|
|
if (fullbright)
|
|
|
|
what.effects = what.effects | EF_FULLBRIGHT;
|
|
|
|
|
|
|
|
{
|
|
|
|
what.pflags = PFLAGS_FULLDYNAMIC;
|
|
|
|
what.light_lev = light_level;
|
|
|
|
what.color_x = red;
|
|
|
|
what.color_y = green;
|
|
|
|
what.color_z = blue;
|
|
|
|
}
|
|
|
|
}
|
2023-02-05 21:03:57 +00:00
|
|
|
|
|
|
|
#endif // FTE
|