Skip to content

Commit

Permalink
game: use vec3_t as scale
Browse files Browse the repository at this point in the history
  • Loading branch information
0lvin committed Nov 22, 2024
1 parent fec4bca commit 99c7418
Show file tree
Hide file tree
Showing 51 changed files with 648 additions and 430 deletions.
10 changes: 2 additions & 8 deletions src/common/header/shared.h
Original file line number Diff line number Diff line change
Expand Up @@ -1436,24 +1436,20 @@ typedef struct entity_state_s
int event; /* impulse events -- muzzle flashes, footsteps, etc */
/* events only go out for a single frame, they */
/* are automatically cleared each frame */
vec3_t scale;

short clientnum; // In Quake 2, the client num was passed in skinnum. We need this value, however.

// For specific path to skin.

char skinname[MAX_QPATH];

// Model scale.

float scale;

// EF_XXX.

// What's this exactly?

byte color[4];

// For looping sounds, so we can set volume and attenuation.

byte sound_data;

// required so we can place sounds for bmodels correctly in 3d space
Expand All @@ -1467,14 +1463,12 @@ typedef struct entity_state_s
fmnodeinfo_t fmnodeinfo[MAX_FM_MESH_NODES];

// Skeletal info. Only relevant for player models (i.e. have U_JOINTED).

short skeletalType;
short rootJoint;

short swapFrame;

// Used by the client to verify is this still the same entity it last had.

byte usageCount;
} entity_state_t;

Expand Down
15 changes: 11 additions & 4 deletions src/game/character/ai.c
Original file line number Diff line number Diff line change
Expand Up @@ -203,12 +203,15 @@ void c_corvus_init(edict_t *self,int classId)
VectorCopy(c_maxs, self->maxs);
VectorCopy(c_mins, self->intentMins);
VectorCopy(c_maxs, self->intentMaxs);
self->viewheight = self->maxs[2]*0.8;

self->viewheight = self->maxs[2] * 0.8;

if (!self->monsterinfo.scale)
{
self->s.scale = self->monsterinfo.scale = 1;
self->monsterinfo.scale = 1;
VectorSet(self->s.scale,
self->monsterinfo.scale,
self->monsterinfo.scale,
self->monsterinfo.scale);
}

self->materialtype = MAT_FLESH;
Expand Down Expand Up @@ -261,7 +264,11 @@ void c_character_init(edict_t *self,int classId)

if (!self->monsterinfo.scale)
{
self->s.scale = self->monsterinfo.scale = 1;
self->monsterinfo.scale = 1;
VectorSet(self->s.scale,
self->monsterinfo.scale,
self->monsterinfo.scale,
self->monsterinfo.scale);
}

self->count = self->s.modelindex;
Expand Down
9 changes: 6 additions & 3 deletions src/game/character/elflord/elflord.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ float mist_yaw;
void Elflord_c_gib(edict_t *self, G_Message_t *msg)
{
gi.CreateEffect(&self->s, FX_WEAPON_SPHEREEXPLODE, CEF_OWNERS_ORIGIN , NULL,
"db", self->movedir, (byte)(self->s.scale * 7.5));
"db", self->movedir, (byte)(AVG_VEC3T(self->s.scale) * 7.5));

gi.sound(self,CHAN_WEAPON,gi.soundindex("weapons/SphereImpact.wav"),2,ATTN_NORM,0);

Expand Down Expand Up @@ -193,6 +193,9 @@ void SP_character_elflord (edict_t *self)

c_character_init(self,CID_C_ELFLORD);

self->s.scale = self->monsterinfo.scale = 2.0;

self->monsterinfo.scale = 2.0;
VectorSet(self->s.scale,
self->monsterinfo.scale,
self->monsterinfo.scale,
self->monsterinfo.scale);
}
6 changes: 5 additions & 1 deletion src/game/character/siernan/siernan1.c
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,11 @@ void SP_character_siernan1 (edict_t *self)
VectorSet(self->mins, -10, -10, -20);
VectorSet(self->maxs, 10, 10, 20);

self->s.scale = self->monsterinfo.scale = 1.2;
self->monsterinfo.scale = 1.2;
VectorSet(self->s.scale,
self->monsterinfo.scale,
self->monsterinfo.scale,
self->monsterinfo.scale);

c_character_init(self,CID_C_SIERNAN1);

Expand Down
6 changes: 5 additions & 1 deletion src/game/character/siernan/siernan2.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,11 @@ void SP_character_siernan2 (edict_t *self)
VectorSet(self->mins, -17, -25, 0);
VectorSet(self->maxs, 22, 12, 16);

self->s.scale = self->monsterinfo.scale = 1;
self->monsterinfo.scale = 1;
VectorSet(self->s.scale,
self->monsterinfo.scale,
self->monsterinfo.scale,
self->monsterinfo.scale);

c_character_init(self,CID_C_SIERNAN2);
}
18 changes: 13 additions & 5 deletions src/game/effects/fx_sphereofannihlation.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,11 @@ static qboolean FXSphereOfAnnihilationSphereThink(struct client_entity_s *Self,
else
detail_scale = 1.0;

Self->r.scale=Owner->current.scale * detail_scale;
Self->r.scale = (
Owner->current.scale[0] +
Owner->current.scale[1] +
Owner->current.scale[2]
) / 3 * detail_scale;

return true;
}
Expand Down Expand Up @@ -191,7 +195,11 @@ void FXSphereOfAnnihilation(centity_t *Owner,int Type,int Flags,vec3_t Origin)

SphereThinker->r.model = sphere_models[1];
SphereThinker->r.flags |= RF_TRANSLUCENT;
SphereThinker->r.scale = Owner->current.scale;
SphereThinker->r.scale = (
Owner->current.scale[0] +
Owner->current.scale[1] +
Owner->current.scale[2]
) / 3;
SphereThinker->radius = 70.0;
SphereThinker->Update = FXSphereOfAnnihilationSphereThink;
SphereThinker->AddToView = LinkedEntityUpdatePlacement;
Expand Down Expand Up @@ -537,7 +545,7 @@ void FXSphereOfAnnihilationExplode(centity_t *Owner, int Type, int Flags, vec3_t
ce->velocity[0]+=flrand(-SMOKE_SPEED,SMOKE_SPEED);
ce->velocity[1]+=flrand(-SMOKE_SPEED,SMOKE_SPEED);
ce->velocity[2]+=flrand(-SMOKE_SPEED,SMOKE_SPEED);
AddParticleToList(Explosion, ce);
AddParticleToList(Explosion, ce);

}
}
Expand Down Expand Up @@ -595,7 +603,7 @@ void FXSphereOfAnnihilationPower(centity_t *Owner,int Type,int Flags,vec3_t Orig
//make the line beam down the side
beam = ClientEntity_new(-1, CEF_DONT_LINK, spot1, NULL, 200);
beam->r.model = sphere_models[5];
beam->r.spriteType = SPRITE_LINE;
beam->r.spriteType = SPRITE_LINE;
beam->r.flags |= RF_TRANS_ADD | RF_TRANS_ADD_ALPHA;
beam->r.scale = (size-3) * 6;
beam->radius = 256;
Expand Down Expand Up @@ -631,7 +639,7 @@ void FXSphereOfAnnihilationPower(centity_t *Owner,int Type,int Flags,vec3_t Orig
VectorMA(ce->velocity, flrand(-15, 15), up, ce->velocity);
VectorMA(ce->origin, flrand(-size*.4, size*.4), right, ce->origin);
VectorMA(ce->origin, flrand(-size*.4, size*.4), up, ce->origin);
AddParticleToList(exp1, ce);
AddParticleToList(exp1, ce);
}
if (Flags & CEF_FLAG6)
{
Expand Down
2 changes: 1 addition & 1 deletion src/game/effects/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,7 @@ AddServerEntities(frame_t *frame)
ent->skin = NULL; // No custom skin.
}

ent->scale = s1->scale;
ent->scale = (s1->scale[0] + s1->scale[1] + s1->scale[2]) / 3;

if(s1->color[0] ||
s1->color[1] ||
Expand Down
2 changes: 1 addition & 1 deletion src/game/g_ai.c
Original file line number Diff line number Diff line change
Expand Up @@ -2193,7 +2193,7 @@ old_ai_run(edict_t *self, float dist)
if(trace.ent->takedamage && self->monsterinfo.aiflags & AI_SHOVE && trace.fraction <= 0.5)
{//hurt them some too?
if(self->classID == CID_GORGON &&
self->s.scale >1.5 &&
(AVG_VEC3T(self->s.scale) > 1.5) &&
trace.ent->classID!=self->classID &&
trace.ent->health <= 200&&
infront(self, self->enemy))//chomp!
Expand Down
15 changes: 10 additions & 5 deletions src/game/g_env.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ void smoke_use (edict_t *self, edict_t *other, edict_t *activator)
byte scale,speed,wait,maxrange;
if (self->spawnflags & START_OFF)
{
scale = (byte)(self->s.scale * 32.0);
scale = (byte)(AVG_VEC3T(self->s.scale) * 32.0);
AngleVectors(self->s.angles, dir, NULL, NULL);

speed = Q_ftol(self->speed);
Expand Down Expand Up @@ -119,16 +119,21 @@ void SP_env_smoke (edict_t *self)
byte scale,speed,wait,maxrange;

// set scale
if (!self->s.scale)
self->s.scale = 1;
scale = (byte)(self->s.scale * 32.0);
if (!self->s.scale[0] ||
!self->s.scale[1] ||
!self->s.scale[2])
{
VectorSet(self->s.scale, 1.0, 1.0, 1.0);
}

scale = (byte)(AVG_VEC3T(self->s.scale) * 32.0);

// allow us to use this stuff
if (self->targetname)
self->use = smoke_use;

// set the wait between puffs
if (!self->wait)
if (!self->wait)
self->wait = 5;

// set the distance
Expand Down
16 changes: 10 additions & 6 deletions src/game/g_func.c
Original file line number Diff line number Diff line change
Expand Up @@ -2171,7 +2171,7 @@ SP_func_button(edict_t *ent)
G_SetMovedir(ent->s.angles, ent->movedir);
ent->movetype = MOVETYPE_STOP;
ent->solid = SOLID_BSP;
ent->takedamage = DAMAGE_NO;
ent->takedamage = DAMAGE_NO;
gi.setmodel(ent, ent->model);

button_sounds(ent);
Expand Down Expand Up @@ -4776,10 +4776,10 @@ void monsterspawner_go(edict_t *self)
monster->jump_chance = self->jump_chance;
monster->wakeup_distance = self->wakeup_distance;

monster->s.scale = self->s.scale;
VectorCopy(self->s.scale, monster->s.scale);

VectorScale(STDMinsForClass[monster->classID], monster->s.scale, monster->mins);
VectorScale(STDMaxsForClass[monster->classID], monster->s.scale, monster->maxs);
VectorScale(STDMinsForClass[monster->classID], AVG_VEC3T(monster->s.scale), monster->mins);
VectorScale(STDMaxsForClass[monster->classID], AVG_VEC3T(monster->s.scale), monster->maxs);

if (self->attenuation)
{
Expand Down Expand Up @@ -4997,8 +4997,12 @@ void SP_func_monsterspawner (edict_t *self)
if (!self->wait)
self->wait = 10;

if(!self->s.scale)
self->s.scale = 1.0f;
if (!self->s.scale[0] ||
!self->s.scale[1] ||
!self->s.scale[2])
{
VectorSet(self->s.scale, 1.0, 1.0, 1.0);
}

if (self->targetname)
self->use = monsterspawner_use;
Expand Down
58 changes: 42 additions & 16 deletions src/game/g_light.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ void create_fire_touch (edict_t *owner,vec3_t origin)

VectorCopy(origin,flame->s.origin);

flame->s.scale = owner->s.scale;
flame->dmg = 3 * owner->s.scale;
VectorCopy(owner->s.scale, flame->s.scale);
flame->dmg = 3 * AVG_VEC3T(owner->s.scale);

VectorSet(flame->mins, -8, -8, -2);
VectorSet(flame->maxs, 8, 8, 14);
Expand All @@ -127,10 +127,14 @@ void SpawnFlame(edict_t *self,vec3_t origin)

// NOTE - LIMIT ON SCALE is x 8.

if (self->s.scale >= 8.0)
if (AVG_VEC3T(self->s.scale) >= 8.0)
{
scale = 255;
}
else
scale = self->s.scale * 32;
{
scale = AVG_VEC3T(self->s.scale) * 32;
}

self->PersistantCFX = gi.CreatePersistantEffect(&self->s,
FX_FIRE,
Expand Down Expand Up @@ -196,23 +200,32 @@ void fire_use (edict_t *self, edict_t *other, edict_t *activator)
if (self->spawnflags & FIRE_OFF)
{
// NOTE - LIMIT ON SCALE is x 8
if (self->s.scale >= 8.0)
if (AVG_VEC3T(self->s.scale) >= 8.0)
{
scale = 255;
}
else
scale = self->s.scale * 32;
{
scale = AVG_VEC3T(self->s.scale) * 32;
}

self->PersistantCFX = gi.CreatePersistantEffect(&self->s,
FX_FIRE,
CEF_BROADCAST,
self->s.origin,
"b",scale);
"b", scale);

create_fire_touch (self,self->s.origin);
create_fire_touch(self,self->s.origin);

if (self->s.scale < 1)
if (AVG_VEC3T(self->s.scale) < 1)
{
self->s.sound = gi.soundindex("ambient/smallfire.wav");
}
else
{
self->s.sound = gi.soundindex("ambient/fireplace.wav");
}

self->s.sound_data = (127 & ENT_VOL_MASK) | ATTN_STATIC;
self->spawnflags &= ~FIRE_OFF;
}
Expand All @@ -236,7 +249,7 @@ void firemove_think(edict_t *self)
{
byte scale;

scale = self->s.scale * 8;
scale = AVG_VEC3T(self->s.scale) * 8;

self->PersistantCFX = gi.CreatePersistantEffect(&self->s,
FX_FIRE_ON_ENTITY,
Expand Down Expand Up @@ -272,8 +285,12 @@ SP_env_fire(edict_t *self)
return;
}

if (!self->s.scale)
self->s.scale = 1;
if (!self->s.scale[0] ||
!self->s.scale[1] ||
!self->s.scale[2])
{
VectorSet(self->s.scale, 1.0, 1.0, 1.0);
}

if (self->targetname)
{
Expand Down Expand Up @@ -317,17 +334,26 @@ SP_env_fire(edict_t *self)
if (self->spawnflags & FIRE_OFF)
return;

if (self->s.scale < 1)
if (AVG_VEC3T(self->s.scale) < 1)
{
self->s.sound = gi.soundindex("ambient/smallfire.wav");
}
else
{
self->s.sound = gi.soundindex("ambient/fireplace.wav");
}

self->s.sound_data = (127 & ENT_VOL_MASK) | ATTN_STATIC;

// NOTE - LIMIT ON SCALE is x 8
if (self->s.scale >= 8.0)
scale = 255;
if (AVG_VEC3T(self->s.scale) >= 8.0)
{
scale = 255;
}
else
scale = self->s.scale * 32;
{
scale = AVG_VEC3T(self->s.scale) * 32;
}

if (self->spawnflags & FIRE_MOVEABLE)
{
Expand Down
Loading

0 comments on commit 99c7418

Please sign in to comment.