From 2ff7e8e6d03dc450e8b42c6ebeaa938023928c16 Mon Sep 17 00:00:00 2001 From: Denis Pauk Date: Thu, 24 Oct 2024 23:47:40 +0300 Subject: [PATCH] game: implement env_fire with TE_FLAME --- CMakeLists.txt | 1 + Makefile | 1 + src/client/cl_effects.c | 6 ++- src/game/g_light.c | 58 +++++++++++++++++++++++ src/game/savegame/tables/gamefunc_decs.h | 1 + src/game/savegame/tables/gamefunc_list.h | 1 + src/game/savegame/tables/spawnfunc_decs.h | 1 + src/game/savegame/tables/spawnfunc_list.h | 1 + 8 files changed, 68 insertions(+), 2 deletions(-) create mode 100644 src/game/g_light.c diff --git a/CMakeLists.txt b/CMakeLists.txt index c3fad167..ffa07bae 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -345,6 +345,7 @@ set(Game-Source ${GAME_SRC_DIR}/g_ctf.c ${GAME_SRC_DIR}/g_func.c ${GAME_SRC_DIR}/g_items.c + ${GAME_SRC_DIR}/g_light.c ${GAME_SRC_DIR}/g_main.c ${GAME_SRC_DIR}/g_misc.c ${GAME_SRC_DIR}/g_monster.c diff --git a/Makefile b/Makefile index 0d262716..df9d1566 100644 --- a/Makefile +++ b/Makefile @@ -955,6 +955,7 @@ GAME_OBJS_ = \ src/game/g_combat.o \ src/game/g_func.o \ src/game/g_items.o \ + src/game/g_light.o \ src/game/g_main.o \ src/game/g_misc.o \ src/game/g_monster.o \ diff --git a/src/client/cl_effects.c b/src/client/cl_effects.c index 7d0a94df..46a70500 100644 --- a/src/client/cl_effects.c +++ b/src/client/cl_effects.c @@ -2099,6 +2099,7 @@ CL_FlameEffects(vec3_t origin) count = rand() & 0xF; + /* Particles going down */ for(n = 0; n < count; n++) { cparticle_t *p; @@ -2119,7 +2120,7 @@ CL_FlameEffects(vec3_t origin) p->alpha = 1.0; p->alphavel = -1.0 / (1 + frandk() * 0.2); - p->color = CL_CombineColors(0xff0b0700, 0xff47477b, + p->color = CL_CombineColors(0xff007fef, 0xff003bb7, (float)(randk() & 15) / 15.0); for (j = 0; j < 3; j++) @@ -2134,6 +2135,7 @@ CL_FlameEffects(vec3_t origin) count = rand() & 0x7; + /* Particles go up */ for (n = 0; n < count; n++) { cparticle_t *p; @@ -2154,7 +2156,7 @@ CL_FlameEffects(vec3_t origin) p->alpha = 1.0; p->alphavel = -1.0 / (1 + frandk() * 0.5); - p->color = CL_CombineColors(0xff000000, 0xff2f2f2f, + p->color = CL_CombineColors(0xff0000ff, 0xff002f2f, (float)(randk() & 15) / 15.0); for (j=0 ; j<3 ; j++) { diff --git a/src/game/g_light.c b/src/game/g_light.c new file mode 100644 index 00000000..92d67cfb --- /dev/null +++ b/src/game/g_light.c @@ -0,0 +1,58 @@ +/* + * Copyright (C) 1997-2001 Id Software, Inc. + * Copyright (c) ZeniMax Media Inc. + * + * 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. + * + * ======================================================================= + * + * Custom light effects. + * + * ======================================================================= + */ + +#include "header/local.h" + +void +env_fire_think(edict_t *self) +{ + self->nextthink = level.time + FRAMETIME; + gi.WriteByte(svc_temp_entity); + gi.WriteByte(TE_FLAME); + gi.WritePosition(self->s.origin); + gi.multicast(self->s.origin, MULTICAST_PVS); +} + +/* + * QUAKED env_fire (.3 .3 1.0) (-8 -8 -8) (8 8 8) + * Flame effect. Does not emit light +*/ +void +SP_env_fire(edict_t *self) +{ + if (!self) + { + return; + } + + self->movetype = MOVETYPE_NONE; + self->solid = SOLID_NOT; + self->think = env_fire_think; + self->nextthink = level.time + FRAMETIME; + + gi.linkentity(self); +} diff --git a/src/game/savegame/tables/gamefunc_decs.h b/src/game/savegame/tables/gamefunc_decs.h index 82271f9b..7e526dc6 100644 --- a/src/game/savegame/tables/gamefunc_decs.h +++ b/src/game/savegame/tables/gamefunc_decs.h @@ -630,6 +630,7 @@ extern void enforcer_sight ( edict_t * self , edict_t * other ) ; extern void enforcer_sight ( edict_t * self , edict_t *other ); extern void enforcer_stand ( edict_t * self ) ; extern void enforcer_walk ( edict_t * self ) ; +extern void env_fire_think ( edict_t * self ) ; extern void fd_secret_done ( edict_t * self ) ; extern void fd_secret_killed ( edict_t * self , edict_t * inflictor , edict_t * attacker , int damage , vec3_t point ) ; extern void fd_secret_move1 ( edict_t * self ) ; diff --git a/src/game/savegame/tables/gamefunc_list.h b/src/game/savegame/tables/gamefunc_list.h index 9c61ef59..18fc4de0 100644 --- a/src/game/savegame/tables/gamefunc_list.h +++ b/src/game/savegame/tables/gamefunc_list.h @@ -589,6 +589,7 @@ {"enforcer_sight", (byte *)enforcer_sight}, {"enforcer_stand", (byte *)enforcer_stand}, {"enforcer_walk", (byte *)enforcer_walk}, +{"env_fire_think", (byte *)env_fire_think}, {"face_wall", (byte *)face_wall}, {"fd_secret_done", (byte *)fd_secret_done}, {"fd_secret_killed", (byte *)fd_secret_killed}, diff --git a/src/game/savegame/tables/spawnfunc_decs.h b/src/game/savegame/tables/spawnfunc_decs.h index a0915183..ae01c9aa 100644 --- a/src/game/savegame/tables/spawnfunc_decs.h +++ b/src/game/savegame/tables/spawnfunc_decs.h @@ -36,6 +36,7 @@ extern void SP_dm_dball_speed_change(edict_t * self); extern void SP_dm_dball_team1_start(edict_t * self); extern void SP_dm_dball_team2_start(edict_t * self); extern void SP_dm_tag_token(edict_t * self); +extern void SP_env_fire ( edict_t * ent ) ; extern void SP_func_areaportal ( edict_t * ent ) ; extern void SP_func_button ( edict_t * ent ) ; extern void SP_func_clock(edict_t * self); diff --git a/src/game/savegame/tables/spawnfunc_list.h b/src/game/savegame/tables/spawnfunc_list.h index 81cdaf0c..75a49ad9 100644 --- a/src/game/savegame/tables/spawnfunc_list.h +++ b/src/game/savegame/tables/spawnfunc_list.h @@ -35,6 +35,7 @@ {"dm_dball_team1_start", SP_dm_dball_team1_start}, {"dm_dball_team2_start", SP_dm_dball_team2_start}, {"dm_tag_token", SP_dm_tag_token}, +{"env_fire", SP_env_fire}, {"func_areaportal", SP_func_areaportal}, {"func_button", SP_func_button}, {"func_clock", SP_func_clock},