From f116fb44ebe35dc60f9a8b7fdae3a43f27373f86 Mon Sep 17 00:00:00 2001 From: Denis Pauk Date: Sun, 20 Oct 2024 14:28:32 +0300 Subject: [PATCH] game: show description of dynamic spawn entities --- src/game/g_spawn.c | 20 +++++++++++++++++--- src/game/savegame/tables/gamefunc_decs.h | 1 + src/game/savegame/tables/gamefunc_list.h | 1 + 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/game/g_spawn.c b/src/game/g_spawn.c index 2e1e8e18..f2ae3fbf 100644 --- a/src/game/g_spawn.c +++ b/src/game/g_spawn.c @@ -123,12 +123,26 @@ DynamicSpawnUpdate(edict_t *self, dynamicentity_t *data) ) / 3; } +void +dynamicspawn_touch(edict_t *self, edict_t *other, cplane_t *plane /* unused */, + csurface_t *surf /* unused */) +{ + if (!self || !other || !self->message || !self->message[0]) + { + return; + } + + gi.centerprintf(other, "Entity description: %s", self->message); +} + static void -DynamicSpawn(edict_t *self) +DynamicSpawn(edict_t *self, dynamicentity_t *data) { /* All other properties could be updated in DynamicSpawnUpdate */ self->movetype = MOVETYPE_NONE; self->solid = SOLID_BBOX; + self->message = data->description; + self->touch = dynamicspawn_touch; gi.linkentity(self); } @@ -279,7 +293,7 @@ ED_CallSpawn(edict_t *ent) if (dyn_id >= 0 && dynamicentities[dyn_id].model_path[0]) { /* spawn only if know model */ - DynamicSpawn(ent); + DynamicSpawn(ent, &dynamicentities[dyn_id]); return; } @@ -299,7 +313,7 @@ ED_CallSpawn(edict_t *ent) if (gi.FS_LoadFile(self.model_path, NULL) > 4) { DynamicSpawnUpdate(ent, &self); - DynamicSpawn(ent); + DynamicSpawn(ent, &self); return; } } diff --git a/src/game/savegame/tables/gamefunc_decs.h b/src/game/savegame/tables/gamefunc_decs.h index d517df9a..fae0c468 100644 --- a/src/game/savegame/tables/gamefunc_decs.h +++ b/src/game/savegame/tables/gamefunc_decs.h @@ -617,6 +617,7 @@ extern void drawbbox ( edict_t * self ) ; extern void drop_make_touchable ( edict_t * ent ) ; extern void drop_temp_touch ( edict_t * ent , edict_t * other , cplane_t * plane , csurface_t * surf ) ; extern void droptofloor ( edict_t * ent ) ; +extern void dynamicspawn_touch(edict_t *self, edict_t *other, cplane_t *plane /* unused */, csurface_t *surf /* unused */); extern void enfbolt_touch ( edict_t * self , edict_t * other , cplane_t * plane, csurface_t *surf); extern void enforcer_attack ( edict_t * self ) ; extern void enforcer_die ( edict_t * self , edict_t * inflictor , edict_t * attacker , int damage , vec3_t point ) ; diff --git a/src/game/savegame/tables/gamefunc_list.h b/src/game/savegame/tables/gamefunc_list.h index 82d7a7bd..ca817f74 100644 --- a/src/game/savegame/tables/gamefunc_list.h +++ b/src/game/savegame/tables/gamefunc_list.h @@ -579,6 +579,7 @@ {"drop_make_touchable", (byte *)drop_make_touchable}, {"drop_temp_touch", (byte *)drop_temp_touch}, {"droptofloor", (byte *)droptofloor}, +{"dynamicspawn_touch", (byte *)dynamicspawn_touch}, {"enfbolt_touch", (byte *)enfbolt_touch}, {"enforcer_attack", (byte *)enforcer_attack}, {"enforcer_die", (byte *)enforcer_die},