Update 4 id1, hipnotic, mg1, and rogue source

This commit is contained in:
Mike Rubits
2022-08-18 15:18:32 -05:00
parent bebf782915
commit 7bcbd29c99
14 changed files with 149 additions and 12 deletions

106
quakec_mg1/misc_model.qc Normal file
View File

@@ -0,0 +1,106 @@
const float MISC_MODEL_ANIMATED = 1;
const float MISC_MODEL_ANIMATED_ONCE = 2;
const float MISC_MODEL_ANIMATED_START_OFF = 4;
///////////////////////////////
// Behaviour for a looping animation
///////////////////////////////
void misc_model_think_loop()
{
self.frame += 1;
if(self.frame == self.cnt)
{
self.frame = self.count; // Back to start
}
self.nextthink = time + 0.1;
}
void misc_model_use_loop()
{
if(self.spawnflags & MISC_MODEL_ANIMATED_START_OFF)
{
self.spawnflags (-) MISC_MODEL_ANIMATED_START_OFF;
self.think = misc_model_think_loop;
misc_model_think_loop();
}
else
{
self.spawnflags (+) MISC_MODEL_ANIMATED_START_OFF;
self.think = SUB_Null;
self.nextthink = -1;
}
}
///////////////////////////////
// Behaviour for a single animation
///////////////////////////////
void misc_model_think_once()
{
self.frame += 1;
if(self.frame < self.cnt)
{
self.nextthink = time + 0.1;
}
}
void misc_model_use_once()
{
self.frame = self.count;
self.think = misc_model_think_once;
self.nextthink = time + 0.1;
}
///////////////////////////////
void misc_model()
{
if(self.model == "") { objerror("misc_model with no model specified"); }
precache_model(self.model);
setmodel(self, self.model);
setorigin(self, self.origin);
self.solid = SOLID_NOT;
if(self.spawnflags == 0)
{
makestatic(self);
return;
}
if(self.cnt < self.frame) { objerror("misc_model with invalid frame range (cnt < frame)"); }
if(self.targetname == "") { objerror("misc_model with no targetname"); }
self.count = self.frame;
if(self.spawnflags & MISC_MODEL_ANIMATED_ONCE)
{
self.use = misc_model_use_once;
}
else if(self.spawnflags & (MISC_MODEL_ANIMATED | MISC_MODEL_ANIMATED_START_OFF))
{
self.use = misc_model_use_loop;
// Stupid way to do it but just flip the bit flag and pretend we just used it.
self.spawnflags ^= MISC_MODEL_ANIMATED_START_OFF;
misc_model_use_loop();
}
}

View File

@@ -68,6 +68,7 @@ monsters/oldone.qc // registered
misc_corpses.qc //Corpses yay
misc_fx.qc // adds screenshake
misc_model.qc //generic static and animated model
//Map specific code? Why not..
map_specific/mge2m2.qc