Git Repos / fte_dogmode / qc / func / bob.qc
Last update to this file was on 2024-06-15 at 19:50.
Show bob.qc
//==============================================================================
// func_bob -- code attributed to RennyC
//==============================================================================
//======================================================================
// Constants
//======================================================================
#ifdef SSQC
const float BOB_STYLE_START_OFF = 1; // start off
const float BOB_COLLISION = 2; // Collision for misc_bob
const float BOB_NONSOLID = 4; // Non solid for func_bob
#endif
//======================================================================
// fields
//======================================================================
#ifdef SSQC
.float bsporigin; // bmodel origins are 0,0,0; check first
.float waitmin2;
#endif
//======================================================================
// forward declarations
//======================================================================
// base_func_bob
#ifdef SSQC
void() base_func_bob_on;
void() base_func_bob_off;
void() base_func_bob_think_timer;
void(entity e) base_func_bob_init;
strip void() base_func_bob;
#endif
// func_bob
#ifdef SSQC
void(entity e) func_bob_init;
void() func_bob;
#endif
// misc_bob
#ifdef SSQC
void(entity e) misc_bob_init;
void() misc_bob;
#endif
//------------------------------------------------------------------------------
//----------------------------------------------------------------------
// class base_func_bob: base_func
// {
#ifdef SSQC
//--------------------------------------------------------------
void() base_func_bob_on =
{
// This may have been called by a "use" function, so don't
// allow it to be called repeatedly -- iw
self.use = sub_null;
if (self.bsporigin)
{
self.movetype = MOVETYPE_PUSH;
self.solid = SOLID_BSP;
}
else
{
self.movetype = MOVETYPE_FLY;
self.solid = SOLID_BBOX;
// Reset any onground flags
self.flags = 0;
}
if (self.spawnflags & BOB_NONSOLID)
self.solid = SOLID_NOT;
setmodel (self, self.mdl);
setsize (self, self.mins , self.maxs);
self.think = base_func_bob_think_timer;
if (self.bsporigin)
self.nextthink = self.ltime + 0.1 + self.delay;
else
self.nextthink = time + 0.1 + self.delay;
};
//--------------------------------------------------------------
void() base_func_bob_off =
{
if (self.bsporigin)
{
self.movetype = MOVETYPE_PUSH;
self.solid = SOLID_BSP;
}
else
{
self.movetype = MOVETYPE_FLY;
self.solid = SOLID_BBOX;
}
if (self.spawnflags & BOB_NONSOLID)
self.solid = SOLID_NOT;
setmodel (self, self.mdl);
setsize (self, self.mins , self.maxs);
self.velocity = '0 0 0';
if (self.style & BOB_STYLE_START_OFF)
self.use = base_func_bob_on;
};
//--------------------------------------------------------------
// was bob_timer -- CEV
//--------------------------------------------------------------
void() base_func_bob_think_timer =
{
self.think = base_func_bob_think_timer;
if (self.bsporigin)
self.nextthink = self.ltime + 0.1;
else
self.nextthink = time + 0.1;
// Has the cycle completed?
// changed from self.attack_timer to .attack_finished -- CEV
if (self.attack_finished < time)
{
// Setup bob cycle and half way point for slowdown
self.attack_finished = time + self.count;
self.distance = time + (self.count * 0.5);
// Flip direction of bmodel bob
self.lefty = 1 - self.lefty;
if (self.lefty < 1)
self.t_length = self.height;
else
self.t_length = -self.height;
// Always reset velocity and flags
self.velocity = '0 0 0';
self.flags = 0;
}
// Is the direction set?
// This is a block condition to prevent the bmodel moving
if (self.lefty != -1)
{
// Slow down velocity (gradually)
if (self.distance < time)
{
self.velocity = self.velocity * self.waitmin2;
}
else
{
// Speed up velocity (linear/exponentially)
self.t_length = self.t_length * self.waitmin;
self.velocity += self.movedir * self.t_length;
}
}
};
//--------------------------------------------------------------
void(entity e) base_func_bob_init =
{
base_func_init (e);
e.spawnflags |= BOB_COLLISION;
if (e.spawnflags & BOB_NONSOLID)
e.spawnflags &= ~BOB_COLLISION;
// Using a custom model?
if (e.mdl == "")
{
e.bsporigin = TRUE;
e.mdl = e.model;
}
else
{
e.bsporigin = FALSE;
e.modelindex = 0;
e.model = "";
}
sub_setmovedir (e);
e.movedir = normalize (e.movedir);
if (e.height <= 0)
// Direction intensity
e.height = 8;
if (e.count < 1)
// Direction switch timer
e.count = 2;
if (e.waitmin <= 0)
// Speed up
e.waitmin = 1;
if (e.waitmin2 <= 0)
// Slow down
e.waitmin2 = 0.75;
if (e.delay < 0)
e.delay = random() + random() + random();
// added style key 1 for start off -- dumptruck_ds
if (e.style & BOB_STYLE_START_OFF)
sub_runvoidas (e, base_func_bob_off);
else
sub_runvoidas (e, base_func_bob_on);
};
//--------------------------------------------------------------
strip void() base_func_bob =
{
base_func_bob_init (self);
};
#endif
// };
/*QUAKED func_bob (0 .5 .8) X X X X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
A SOLID bmodel that gently moves back and forth
-------- KEYS --------
targetname : trigger entity (works with entity state system)
angle : direction movement, use "360" for angle 0
height : direction intensity (def=8)
count : direction cycle timer (def=2s, minimum=1s)
waitmin : Speed up scale (def=1) 1+=non linear
waitmin2 : Slow down scale (def=0.75)
delay : Starting time delay (def=0, -1=random)
style : If set to 1, starts off and waits for trigger
_dirt : -1 = will be excluded from dirtmapping
_minlight : Minimum light level for any surface of the brush model
_mincolor : Minimum light color for any surface (def='1 1 1' RGB)
_shadow : Will cast shadows on other models and itself
_shadowself : Will cast shadows on itself
-------- SPAWNFLAGS --------
STARTOFF : Starts off and waits for trigger - DISABLED, Ripped out ESTATE System (RennyC)
-------- NOTES --------
A SOLID bmodel that gently moves back and forth
*/
//----------------------------------------------------------------------
// class func_bob: base_func_bob
// {
#ifdef SSQC
//--------------------------------------------------------------
void(entity e) func_bob_init =
{
e.classname = "func_bob";
e.classtype = CT_FUNC_BOB;
base_func_bob_init (e);
};
//--------------------------------------------------------------
void() func_bob =
{
// new spawnflags for all entities -- iw
if (SUB_Inhibit())
return;
func_bob_init (self);
};
#endif
// };
/*QUAKED misc_bob (0 0.5 0.8) (-8 -8 -8) (8 8 8) X BOB_COLLISION BOB_NONSOLID X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
{
model ({"path" : mdl, "skin" : skin, "frame": frame});
}
Same as func_bob but uses a custom model instead of a brush. Use the mdl key to set the path of the model.
*/
//----------------------------------------------------------------------
// class misc_bob: base_func_bob
// {
#ifdef SSQC
//--------------------------------------------------------------
void(entity e) misc_bob_init =
{
e.classname = "misc_bob";
e.classtype = CT_MISC_BOB;
if (e.mdl == "")
e.mdl = __NULL__;
precache_model (e.mdl);
base_func_bob_init (e);
};
//--------------------------------------------------------------
void() misc_bob =
{
// new spawnflags for all entities -- iw
if (SUB_Inhibit())
return;
misc_bob_init (self);
};
#endif
// };
Return to the top of this page or return to the overview of this repo.
Log bob.qc
Date | Commit Message | Author | + | - |
---|---|---|---|---|
2024-06-15 | Major update, committing as-is, will have bugs | cev | +17 | -1 |
2024-04-05 | Player footsteps, shareware monsters, misc? | cev | -4 | |
2024-03-24 | 2nd pass refactor, rework QC class structure | cev | +155 | -133 |
2024-01-31 | Class based monster refactor & start projectiles | cev | +10 | -2 |
2024-01-09 | Continue OO / Class-based refactor | cev | +189 | -144 |
2023-11-27 | Code reorg, minor movement changes, misc | cev | +210 |
Return to the top of this page or return to the overview of this repo.