djcev.com

//

Git Repos / fte_dogmode / qc / misc / air_bubbles.qc

Last update to this file was on 2024-03-24 at 02:40.

Show air_bubbles.qc

//==============================================================================
// air_bubbles
//==============================================================================

//======================================================================
// forward declarations
//======================================================================

// temp_bubbles
void() temp_bubbles_think;
void() temp_bubbles_touch;
void() temp_bubbles_split;
entity(entity own, vector org, vector v, float fr, float c) spawn_temp_bubbles;
void(entity e) temp_bubbles_init;
strip void() temp_bubbles;

// air_bubbles
void() air_bubbles_think;
entity(entity own, vector org, float num) spawn_air_bubbles;
void(entity e) air_bubbles_init;
void() air_bubbles;

//------------------------------------------------------------------------------

//----------------------------------------------------------------------
// class temp_bubbles: base_tempentity
// {
//--------------------------------------------------------------
// was bubble_bob -- CEV
//--------------------------------------------------------------
void() temp_bubbles_think =
{
local float rnd1, rnd2, rnd3;

self.cnt = self.cnt + 1;

if (self.cnt == 4)
temp_bubbles_split ();

if (self.cnt == 20)
{
remove (self);
return;
}

rnd1 = self.velocity_x + (-10 + (random() * 20));
rnd2 = self.velocity_y + (-10 + (random() * 20));
rnd3 = self.velocity_z + 10 + random() * 10;

if (rnd1 > 10)
rnd1 = 5;
if (rnd1 < -10)
rnd1 = -5;

if (rnd2 > 10)
rnd2 = 5;
if (rnd2 < -10)
rnd2 = -5;

if (rnd3 < 10)
rnd3 = 15;
if (rnd3 > 30)
rnd3 = 25;

self.velocity_x = rnd1;
self.velocity_y = rnd2;
self.velocity_z = rnd3;

self.nextthink = time + 0.5;
};

//--------------------------------------------------------------
void() temp_bubbles_touch =
{
if (other.classtype == self.classtype)
// dprint ("bump");
return;

remove (self);
};

//--------------------------------------------------------------
void() temp_bubbles_split =
{
spawn_temp_bubbles (self, self.origin, self.velocity, 1, 10);
self.frame = 1;
self.cnt = 10;

if (self.waterlevel != WATERLEVEL_EYES)
remove (self);
};

//--------------------------------------------------------------
entity(entity own, vector org, vector v, float fr, float c)
spawn_temp_bubbles =
{
local entity e = spawn ();
e.owner = own;
e.origin = org;
e.velocity = v;
e.frame = fr;
e.cnt = c;
temp_bubbles_init (e);
return e;
};

//--------------------------------------------------------------
void(entity e) temp_bubbles_init =
{
e.classname = "bubble";
e.classtype = CT_TEMP_BUBBLES;
base_tempentity_init (e);

// no touch function when spawning death bubbles -- CEV
if (e.owner && e.owner.classtype == CT_PLAYER)
e.touch = sub_null;
else
e.touch = temp_bubbles_touch;

// make bubbles
setmodel (e, "progs/s_bubble.spr");
setorigin (e, e.origin);
e.movetype = MOVETYPE_NOCLIP;
e.solid = SOLID_NOT;

e.think = temp_bubbles_think;
e.nextthink = time + 0.5;

// e.frame = 0;
// e.cnt = 0;
setsize (e, '-8 -8 -8', '8 8 8');
};

//--------------------------------------------------------------
strip void() temp_bubbles =
{
temp_bubbles_init (self);
};
// };

/*QUAKED air_bubbles (0 .5 .8) (-8 -8 -8) (8 8 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

air bubbles entity

*/
//----------------------------------------------------------------------
// class air_bubbles: base_mapentity
// {
//--------------------------------------------------------------
// was make_bubbles -- CEV
//--------------------------------------------------------------
void() air_bubbles_think =
{
if (self.owner && self.owner.classtype == CT_PLAYER)
{
// PlayerDeathBubbleSpawn -- CEV
if (self.owner.waterlevel != WATERLEVEL_EYES &&
self.owner.health > 0)
{
// remove bubble spawner
remove (self);
return;
}

spawn_temp_bubbles (self, self.origin, '0 0 15', 0, 0);

self.air_finished = self.air_finished + 1;
if (self.air_finished >= self.count)
{
remove (self);
return;
}

// 1998-08-14 Improved bubble spawn by Maddes start
self.nextthink = time + 0.01;
// 1998-08-14 Improved bubble spawn by Maddes end
return;
}

spawn_temp_bubbles (self, self.origin, '0 0 15', 0, 0);
self.nextthink = time + random() + 0.5;
};

//--------------------------------------------------------------
entity(entity own, vector org, float num) spawn_air_bubbles =
{
local entity e = spawn ();
e.owner = own;
e.count = num; // bubble_count
e.air_finished = 0;
setorigin (e, org);
air_bubbles_init (e);
return e;
};

//--------------------------------------------------------------
void(entity e) air_bubbles_init =
{
e.classname = "air_bubbles";
e.classtype = CT_MISC_AIR_BUBBLES;
base_mapentity_init (e);

precache_model ("progs/s_bubble.spr");
e.movetype = MOVETYPE_NONE;
e.solid = SOLID_NOT;
e.think = air_bubbles_think;
if (e.owner && e.owner.classtype == CT_PLAYER)
{
if (!e.count)
e.count = 1;

// 1998-08-14 Improved bubble spawn by Maddes start
e.nextthink = time + 0.01;
// 1998-08-14 Improved bubble spawn by Maddes end
}
else
{
e.nextthink = time + 1;
}
};

//--------------------------------------------------------------
void() air_bubbles =
{
// new spawnflags for all entities -- iw
if (SUB_Inhibit())
return;

if (deathmatch)
{
remove (self);
return;
}

air_bubbles_init (self);
};
// };

Return to the top of this page or return to the overview of this repo.

Log air_bubbles.qc

Date Commit Message Author + -
2024-03-24 2nd pass refactor, rework QC class structure cev +158 -59
2024-01-31 Class based monster refactor & start projectiles cev +3 -2
2024-01-09 Continue OO / Class-based refactor cev +35 -22
2023-12-09 Start OO / class-based refactor, work on items cev +108 -108
2023-12-02 More refactoring & moving, begin adding mdls & snd cev +124  

Return to the top of this page or return to the overview of this repo.