From d8b8a78d37f717a25df526b774ac6107789f5708 Mon Sep 17 00:00:00 2001 From: Denis Pauk Date: Mon, 23 Oct 2023 00:18:30 +0300 Subject: [PATCH] game: Add target_sky and target_music Based on code https://github.com/id-Software/quake2-rerelease-dll.git Required to stop sky rotation. --- src/game/g_spawn.c | 4 ++ src/game/g_target.c | 67 ++++++++++++++++++++++++ src/game/savegame/tables/gamefunc_decs.h | 4 ++ src/game/savegame/tables/gamefunc_list.h | 4 ++ 4 files changed, 79 insertions(+) diff --git a/src/game/g_spawn.c b/src/game/g_spawn.c index 105b3a18..bc6d47e1 100644 --- a/src/game/g_spawn.c +++ b/src/game/g_spawn.c @@ -93,6 +93,8 @@ void SP_target_laser(edict_t *self); void SP_target_help(edict_t *ent); void SP_target_lightramp(edict_t *self); void SP_target_earthquake(edict_t *ent); +void SP_target_music(edict_t *ent); +void SP_target_sky(edict_t *ent); void SP_target_character(edict_t *ent); void SP_target_string(edict_t *ent); @@ -269,6 +271,8 @@ static spawn_t spawns[] = { {"target_help", SP_target_help}, {"target_lightramp", SP_target_lightramp}, {"target_earthquake", SP_target_earthquake}, + {"target_music", SP_target_music}, + {"target_sky", SP_target_sky}, {"target_character", SP_target_character}, {"target_string", SP_target_string}, {"target_mal_laser", SP_target_mal_laser}, diff --git a/src/game/g_target.c b/src/game/g_target.c index 17127d1d..ed0c8d84 100644 --- a/src/game/g_target.c +++ b/src/game/g_target.c @@ -1423,3 +1423,70 @@ SP_target_earthquake(edict_t *self) self->noise_index = gi.soundindex("world/quake.wav"); } } + +void +target_music_use(edict_t *self, edict_t *other, edict_t *activator) +{ + if (!self) + { + return; + } + + gi.configstring(CS_CDTRACK, va("%i", self->sounds)); +} + +void +SP_target_music(edict_t* self) +{ + if (!self) + { + return; + } + + self->use = target_music_use; +} + +void +target_sky_use(edict_t *self, edict_t *other, edict_t *activator) +{ + float rotate; + int32_t autorotate; + + + if (!self) + { + return; + } + + if (self->map && self->map[0]) + { + gi.configstring(CS_SKY, self->map); + } + + rotate = self->accel; + autorotate = self->style; + gi.configstring(CS_SKYROTATE, va("%f %d", rotate, autorotate)); + + gi.configstring(CS_SKYAXIS, va("%f %f %f", + self->movedir[0], self->movedir[1], self->movedir[2])); +} + +void +SP_target_sky(edict_t* self) +{ + if (!self) + { + return; + } + + self->use = target_sky_use; + + if (st.sky && st.sky[0]) + { + self->map = st.sky; + } + + VectorCopy(st.skyaxis, self->movedir); + self->accel = st.skyrotate; + self->style = st.skyautorotate; +} diff --git a/src/game/savegame/tables/gamefunc_decs.h b/src/game/savegame/tables/gamefunc_decs.h index 0422c405..9f5d51a4 100644 --- a/src/game/savegame/tables/gamefunc_decs.h +++ b/src/game/savegame/tables/gamefunc_decs.h @@ -1120,6 +1120,10 @@ extern void InitTrigger ( edict_t * self ) ; extern void SP_target_earthquake ( edict_t * self ) ; extern void target_earthquake_use ( edict_t * self , edict_t * other , edict_t * activator ) ; extern void target_earthquake_think ( edict_t * self ) ; +extern void SP_target_sky ( edict_t * self ) ; +extern void target_sky_use ( edict_t * self , edict_t * other , edict_t * activator ) ; +extern void SP_target_music ( edict_t * self ) ; +extern void target_music_use ( edict_t * self , edict_t * other , edict_t * activator ) ; extern void SP_target_lightramp ( edict_t * self ) ; extern void target_lightramp_use ( edict_t * self , edict_t * other , edict_t * activator ) ; extern void target_lightramp_think ( edict_t * self ) ; diff --git a/src/game/savegame/tables/gamefunc_list.h b/src/game/savegame/tables/gamefunc_list.h index aeda1ba5..eef7c473 100644 --- a/src/game/savegame/tables/gamefunc_list.h +++ b/src/game/savegame/tables/gamefunc_list.h @@ -1122,6 +1122,10 @@ {"SP_target_earthquake", (byte *)SP_target_earthquake}, {"target_earthquake_use", (byte *)target_earthquake_use}, {"target_earthquake_think", (byte *)target_earthquake_think}, +{"SP_target_music", (byte *)SP_target_music}, +{"target_music_use", (byte *)target_music_use}, +{"SP_target_sky", (byte *)SP_target_sky}, +{"target_sky_use", (byte *)target_sky_use}, {"SP_target_lightramp", (byte *)SP_target_lightramp}, {"target_lightramp_use", (byte *)target_lightramp_use}, {"target_lightramp_think", (byte *)target_lightramp_think},