game: show description of dynamic spawn entities

This commit is contained in:
Denis Pauk 2024-10-20 14:28:32 +03:00
parent db110ddc7e
commit f116fb44eb
3 changed files with 19 additions and 3 deletions

View file

@ -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;
}
}

View file

@ -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 ) ;

View file

@ -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},