Compare commits

...

2 Commits

Author SHA1 Message Date
fa8592e377 clean up weird code 2019-09-18 10:54:42 -04:00
d7ef811865 move common functions with no home to common.qc 2019-09-18 10:16:58 -04:00
9 changed files with 199 additions and 363 deletions

View File

@ -1,6 +1,7 @@
progs.dat progs.dat
source/defs.qc source/defs.qc
source/common.qc
source/fight.qc source/fight.qc
source/subs.qc source/subs.qc

View File

@ -90,83 +90,6 @@ void() t_movetarget = {
}; };
//============================================================================
/*
=============
range
returns the range catagorization of an entity reletive to self
0 melee range, will become hostile even if back is turned
1 visibility and infront, or visibility and show hostile
2 infront and show hostile
3 only triggered by damage
=============
*/
float(entity targ) range = {
vector spot1, spot2;
float r;
spot1 = self.origin + self.view_ofs;
spot2 = targ.origin + targ.view_ofs;
r = vlen(spot1 - spot2);
if(r < 120) {
return RANGE_MELEE;
}
if(r < 500) {
return RANGE_NEAR;
}
if(r < 1000) {
return RANGE_MID;
}
return RANGE_FAR;
};
/*
=============
visible
returns 1 if the entity is visible to self, even if not infront()
=============
*/
float(entity targ) visible = {
vector spot1, spot2;
spot1 = self.origin + self.view_ofs;
spot2 = targ.origin + targ.view_ofs;
traceline(spot1, spot2, TRUE, self); // see through other monsters
if(trace_inopen && trace_inwater) {
return FALSE; // sight line crossed contents
}
if(trace_fraction == 1) {
return TRUE;
}
return FALSE;
};
/*
=============
infront
returns 1 if the entity is in front(in sight) of self
=============
*/
float(entity targ) infront = {
vector vec;
float dot;
makevectors(self.angles);
vec = normalize(targ.origin - self.origin);
dot = vec * v_forward;
if(dot > 0.3) {
return TRUE;
}
return FALSE;
};
//============================================================================ //============================================================================
void() HuntTarget = { void() HuntTarget = {

82
source/common.qc Normal file
View File

@ -0,0 +1,82 @@
// common.qc: common functions
float() crandom = {
return 2 * (random() - 0.5);
};
/*
=============
range
returns the range catagorization of an entity reletive to self
0 melee range, will become hostile even if back is turned
1 visibility and infront, or visibility and show hostile
2 infront and show hostile
3 only triggered by damage
=============
*/
float(entity targ) range = {
vector spot1, spot2;
float r;
spot1 = self.origin + self.view_ofs;
spot2 = targ.origin + targ.view_ofs;
r = vlen(spot1 - spot2);
if(r < 120) {
return RANGE_MELEE;
}
if(r < 500) {
return RANGE_NEAR;
}
if(r < 1000) {
return RANGE_MID;
}
return RANGE_FAR;
};
/*
=============
visible
returns 1 if the entity is visible to self, even if not infront()
=============
*/
float(entity targ) visible = {
vector spot1, spot2;
spot1 = self.origin + self.view_ofs;
spot2 = targ.origin + targ.view_ofs;
traceline(spot1, spot2, TRUE, self); // see through other monsters
if(trace_inopen && trace_inwater) {
return FALSE; // sight line crossed contents
}
if(trace_fraction == 1) {
return TRUE;
}
return FALSE;
};
/*
=============
infront
returns 1 if the entity is in front(in sight) of self
=============
*/
float(entity targ) infront = {
vector vec;
float dot;
makevectors(self.angles);
vec = normalize(targ.origin - self.origin);
dot = vec * v_forward;
if(dot > 0.3) {
return TRUE;
}
return FALSE;
};
// EOF

View File

@ -127,7 +127,7 @@ void end_sys_globals; // flag for structure dumping
.float button1; // use .float button1; // use
.float button2; // jump .float button2; // jump
.float impulse; // weapon changes .float impulse; // user commands
.float fixangle; .float fixangle;
.vector v_angle; // view / targeting angle for players .vector v_angle; // view / targeting angle for players
@ -216,8 +216,8 @@ string(string s) precache_sound = #19;
string(string s) precache_model = #20; string(string s) precache_model = #20;
void(entity client, string s) stuffcmd = #21; void(entity client, string s) stuffcmd = #21;
entity(vector org, float rad) findradius = #22; entity(vector org, float rad) findradius = #22;
void(string s) bprint = #23; void(string... s) bprint = #23;
void(entity client, string s) sprint = #24; void(entity client, string... s) sprint = #24;
void(string s) dprint = #25; void(string s) dprint = #25;
string(float f) ftos = #26; string(float f) ftos = #26;
string(vector v) vtos = #27; string(vector v) vtos = #27;
@ -259,7 +259,7 @@ string(string s) precache_file = #68; // no effect except for -copy
void(entity e) makestatic = #69; void(entity e) makestatic = #69;
void(string s) changelevel = #70; void(string s) changelevel = #70;
void(string var, string val) cvar_set = #72; // sets cvar.value void(string var, string val) cvar_set = #72; // sets cvar.value
void(entity client, string s) centerprint = #73; // sprint, but in middle void(entity client, string... s) centerprint = #73; // sprint, but in middle
void(vector pos, string samp, float vol, float atten) ambientsound = #74; void(vector pos, string samp, float vol, float atten) ambientsound = #74;
string(string s) precache_model2 = #75; // registered version only string(string s) precache_model2 = #75; // registered version only
@ -467,6 +467,12 @@ enum {
AS_MELEE, AS_MELEE,
AS_MISSILE, AS_MISSILE,
}; };
enum {
WORLD_MEDIEVAL,
WORLD_METAL,
WORLD_BASE,
};
#pragma noref 0 #pragma noref 0
// globals -------------------------------------------------------------------| // globals -------------------------------------------------------------------|
@ -517,7 +523,7 @@ float sight_entity_time;
// world fields // world fields
.string wad; .string wad;
.string map; .string map;
.float worldtype; // 0=medieval 1=metal 2=base .float worldtype;
.string killtarget; .string killtarget;
@ -676,12 +682,7 @@ void() ShalHome;
void() ShalMissile; void() ShalMissile;
void() ShalMissileTouch; void() ShalMissileTouch;
float() crandom;
float(entity targ) infront;
float(entity targ) range;
float(entity targ) visible;
float(entity targ, entity attacker) SameTeam; float(entity targ, entity attacker) SameTeam;
float(float v) anglemod;
void() DecodeLevelParms; void() DecodeLevelParms;
void(entity ent) CopyToBodyQue; void(entity ent) CopyToBodyQue;
void() InitBodyQue; void() InitBodyQue;

View File

@ -201,29 +201,11 @@ void() door_touch = {
// FIXME: blink key on player's status bar // FIXME: blink key on player's status bar
if((self.items & other.items) != self.items) { if((self.items & other.items) != self.items) {
if(self.owner.items == IT_KEY1) { switch(self.owner.items) {
if(world.worldtype == 2) { case IT_KEY1: centerprint(other, "You need the ", Key1Name()); break;
centerprint(other, "You need the silver keycard"); case IT_KEY2: centerprint(other, "You need the ", Key2Name()); break;
sound(self, CHAN_VOICE, self.noise3, 1, ATTN_NORM);
} else if(world.worldtype == 1) {
centerprint(other, "You need the silver runekey");
sound(self, CHAN_VOICE, self.noise3, 1, ATTN_NORM);
} else if(world.worldtype == 0) {
centerprint(other, "You need the silver key");
sound(self, CHAN_VOICE, self.noise3, 1, ATTN_NORM);
} }
} else {
if(world.worldtype == 2) {
centerprint(other, "You need the gold keycard");
sound(self, CHAN_VOICE, self.noise3, 1, ATTN_NORM); sound(self, CHAN_VOICE, self.noise3, 1, ATTN_NORM);
} else if(world.worldtype == 1) {
centerprint(other, "You need the gold runekey");
sound(self, CHAN_VOICE, self.noise3, 1, ATTN_NORM);
} else if(world.worldtype == 0) {
centerprint(other, "You need the gold key");
sound(self, CHAN_VOICE, self.noise3, 1, ATTN_NORM);
}
}
return; return;
} }
@ -388,27 +370,26 @@ Key doors are allways wait -1.
4) screechy metal 4) screechy metal
*/ */
void() func_door = void() func_door = {
switch(world.worldtype) {
{ case WORLD_MEDIEVAL:
if(world.worldtype == 0) {
precache_sound("doors/medtry.wav"); precache_sound("doors/medtry.wav");
precache_sound("doors/meduse.wav"); precache_sound("doors/meduse.wav");
self.noise3 = "doors/medtry.wav"; self.noise3 = "doors/medtry.wav";
self.noise4 = "doors/meduse.wav"; self.noise4 = "doors/meduse.wav";
} else if(world.worldtype == 1) { break;
case WORLD_METAL:
precache_sound("doors/runetry.wav"); precache_sound("doors/runetry.wav");
precache_sound("doors/runeuse.wav"); precache_sound("doors/runeuse.wav");
self.noise3 = "doors/runetry.wav"; self.noise3 = "doors/runetry.wav";
self.noise4 = "doors/runeuse.wav"; self.noise4 = "doors/runeuse.wav";
} else if(world.worldtype == 2) { break;
case WORLD_BASE:
precache_sound("doors/basetry.wav"); precache_sound("doors/basetry.wav");
precache_sound("doors/baseuse.wav"); precache_sound("doors/baseuse.wav");
self.noise3 = "doors/basetry.wav"; self.noise3 = "doors/basetry.wav";
self.noise4 = "doors/baseuse.wav"; self.noise4 = "doors/baseuse.wav";
} else { break;
dprint("no worldtype set!\n");
} }
if(self.sounds == 0) { if(self.sounds == 0) {
precache_sound("misc/null.wav"); precache_sound("misc/null.wav");

View File

@ -11,11 +11,11 @@ const string WEPNAME_LIGHTNING = "Thunderbolt";
string() Key1Name = { string() Key1Name = {
switch(world.worldtype) { switch(world.worldtype) {
case 0: case WORLD_MEDIEVAL:
return "silver key"; return "silver key";
case 1: case WORLD_METAL:
return "silver runekey"; return "silver runekey";
case 2: case WORLD_BASE:
return "silver keycard"; return "silver keycard";
default: default:
return string_null; return string_null;
@ -24,11 +24,11 @@ string() Key1Name = {
string() Key2Name = { string() Key2Name = {
switch(world.worldtype) { switch(world.worldtype) {
case 0: case WORLD_MEDIEVAL:
return "gold key"; return "gold key";
case 1: case WORLD_METAL:
return "gold runekey"; return "gold runekey";
case 2: case WORLD_BASE:
return "gold keycard"; return "gold keycard";
default: default:
return string_null; return string_null;
@ -886,17 +886,19 @@ void() key_touch = {
void() key_setsounds = { void() key_setsounds = {
if(world.worldtype == 0) { switch(world.worldtype) {
case WORLD_MEDIEVAL:
precache_sound("misc/medkey.wav"); precache_sound("misc/medkey.wav");
self.noise = "misc/medkey.wav"; self.noise = "misc/medkey.wav";
} break;
if(world.worldtype == 1) { case WORLD_METAL:
precache_sound("misc/runekey.wav"); precache_sound("misc/runekey.wav");
self.noise = "misc/runekey.wav"; self.noise = "misc/runekey.wav";
} break;
if(world.worldtype == 2) { case WORLD_BASE:
precache_sound2("misc/basekey.wav"); precache_sound2("misc/basekey.wav");
self.noise = "misc/basekey.wav"; self.noise = "misc/basekey.wav";
break;
} }
}; };
@ -914,15 +916,15 @@ following:
void() item_key1 = { void() item_key1 = {
self.netname = Key1Name(); self.netname = Key1Name();
switch(world.worldtype) { switch(world.worldtype) {
case 0: case WORLD_MEDIEVAL:
precache_model("progs/w_s_key.mdl"); precache_model("progs/w_s_key.mdl");
setmodel(self, "progs/w_s_key.mdl"); setmodel(self, "progs/w_s_key.mdl");
break; break;
case 1: case WORLD_METAL:
precache_model("progs/m_s_key.mdl"); precache_model("progs/m_s_key.mdl");
setmodel(self, "progs/m_s_key.mdl"); setmodel(self, "progs/m_s_key.mdl");
break; break;
case 2: case WORLD_BASE:
precache_model2("progs/b_s_key.mdl"); precache_model2("progs/b_s_key.mdl");
setmodel(self, "progs/b_s_key.mdl"); setmodel(self, "progs/b_s_key.mdl");
break; break;
@ -948,15 +950,15 @@ following:
void() item_key2 = { void() item_key2 = {
self.netname = Key2Name(); self.netname = Key2Name();
switch(world.worldtype) { switch(world.worldtype) {
case 0: case WORLD_MEDIEVAL:
precache_model("progs/w_g_key.mdl"); precache_model("progs/w_g_key.mdl");
setmodel(self, "progs/w_g_key.mdl"); setmodel(self, "progs/w_g_key.mdl");
break; break;
case 1: case WORLD_METAL:
precache_model("progs/m_g_key.mdl"); precache_model("progs/m_g_key.mdl");
setmodel(self, "progs/m_g_key.mdl"); setmodel(self, "progs/m_g_key.mdl");
break; break;
case 2: case WORLD_BASE:
precache_model2("progs/b_g_key.mdl"); precache_model2("progs/b_g_key.mdl");
setmodel(self, "progs/b_g_key.mdl"); setmodel(self, "progs/b_g_key.mdl");
break; break;

View File

@ -211,7 +211,7 @@ void() finale_4 = {
remove(self); remove(self);
// switch cd track // change cd track
WriteByte(MSG_ALL, SVC_CDTRACK); WriteByte(MSG_ALL, SVC_CDTRACK);
WriteByte(MSG_ALL, 3); WriteByte(MSG_ALL, 3);
WriteByte(MSG_ALL, 3); WriteByte(MSG_ALL, 3);

View File

@ -16,10 +16,6 @@ void() W_Precache = {
precache_sound("weapons/shotgn2.wav"); // super shotgun precache_sound("weapons/shotgn2.wav"); // super shotgun
}; };
float() crandom = {
return 2 * (random() - 0.5);
};
/* /*
================ ================
W_FireAxe W_FireAxe

View File

@ -1,157 +1,8 @@
// world.qc: basic entry point functions // world.qc: basic entry point functions
void() main = { void() main = {
dprint("main function\n");
// these are just commands the the prog compiler to copy these files
precache_file("progs.dat");
precache_file("gfx.wad");
precache_file("quake.rc");
precache_file("default.cfg");
precache_file("end1.bin");
precache_file2("end2.bin");
precache_file("demo1.dem");
precache_file("demo2.dem");
precache_file("demo3.dem");
//
// these are all of the lumps from the cached.ls files
//
precache_file("gfx/palette.lmp");
precache_file("gfx/colormap.lmp");
precache_file2("gfx/pop.lmp");
precache_file("gfx/complete.lmp");
precache_file("gfx/inter.lmp");
precache_file("gfx/ranking.lmp");
precache_file("gfx/vidmodes.lmp");
precache_file("gfx/finale.lmp");
precache_file("gfx/conback.lmp");
precache_file("gfx/qplaque.lmp");
precache_file("gfx/menudot1.lmp");
precache_file("gfx/menudot2.lmp");
precache_file("gfx/menudot3.lmp");
precache_file("gfx/menudot4.lmp");
precache_file("gfx/menudot5.lmp");
precache_file("gfx/menudot6.lmp");
precache_file("gfx/menuplyr.lmp");
precache_file("gfx/bigbox.lmp");
precache_file("gfx/dim_modm.lmp");
precache_file("gfx/dim_drct.lmp");
precache_file("gfx/dim_ipx.lmp");
precache_file("gfx/dim_tcp.lmp");
precache_file("gfx/dim_mult.lmp");
precache_file("gfx/mainmenu.lmp");
precache_file("gfx/box_tl.lmp");
precache_file("gfx/box_tm.lmp");
precache_file("gfx/box_tr.lmp");
precache_file("gfx/box_ml.lmp");
precache_file("gfx/box_mm.lmp");
precache_file("gfx/box_mm2.lmp");
precache_file("gfx/box_mr.lmp");
precache_file("gfx/box_bl.lmp");
precache_file("gfx/box_bm.lmp");
precache_file("gfx/box_br.lmp");
precache_file("gfx/sp_menu.lmp");
precache_file("gfx/ttl_sgl.lmp");
precache_file("gfx/ttl_main.lmp");
precache_file("gfx/ttl_cstm.lmp");
precache_file("gfx/mp_menu.lmp");
precache_file("gfx/netmen1.lmp");
precache_file("gfx/netmen2.lmp");
precache_file("gfx/netmen3.lmp");
precache_file("gfx/netmen4.lmp");
precache_file("gfx/netmen5.lmp");
precache_file("gfx/sell.lmp");
precache_file("gfx/help0.lmp");
precache_file("gfx/help1.lmp");
precache_file("gfx/help2.lmp");
precache_file("gfx/help3.lmp");
precache_file("gfx/help4.lmp");
precache_file("gfx/help5.lmp");
precache_file("gfx/pause.lmp");
precache_file("gfx/loading.lmp");
precache_file("gfx/p_option.lmp");
precache_file("gfx/p_load.lmp");
precache_file("gfx/p_save.lmp");
precache_file("gfx/p_multi.lmp");
// sounds loaded by C code
precache_sound("misc/menu1.wav");
precache_sound("misc/menu2.wav");
precache_sound("misc/menu3.wav");
precache_sound("ambience/water1.wav");
precache_sound("ambience/wind2.wav");
// shareware
precache_file("maps/start.bsp");
precache_file("maps/e1m1.bsp");
precache_file("maps/e1m2.bsp");
precache_file("maps/e1m3.bsp");
precache_file("maps/e1m4.bsp");
precache_file("maps/e1m5.bsp");
precache_file("maps/e1m6.bsp");
precache_file("maps/e1m7.bsp");
precache_file("maps/e1m8.bsp");
// registered
precache_file2("gfx/pop.lmp");
precache_file2("maps/e2m1.bsp");
precache_file2("maps/e2m2.bsp");
precache_file2("maps/e2m3.bsp");
precache_file2("maps/e2m4.bsp");
precache_file2("maps/e2m5.bsp");
precache_file2("maps/e2m6.bsp");
precache_file2("maps/e2m7.bsp");
precache_file2("maps/e3m1.bsp");
precache_file2("maps/e3m2.bsp");
precache_file2("maps/e3m3.bsp");
precache_file2("maps/e3m4.bsp");
precache_file2("maps/e3m5.bsp");
precache_file2("maps/e3m6.bsp");
precache_file2("maps/e3m7.bsp");
precache_file2("maps/e4m1.bsp");
precache_file2("maps/e4m2.bsp");
precache_file2("maps/e4m3.bsp");
precache_file2("maps/e4m4.bsp");
precache_file2("maps/e4m5.bsp");
precache_file2("maps/e4m6.bsp");
precache_file2("maps/e4m7.bsp");
precache_file2("maps/e4m8.bsp");
precache_file2("maps/end.bsp");
precache_file2("maps/dm1.bsp");
precache_file2("maps/dm2.bsp");
precache_file2("maps/dm3.bsp");
precache_file2("maps/dm4.bsp");
precache_file2("maps/dm5.bsp");
precache_file2("maps/dm6.bsp");
}; };
//=======================
/*QUAKED worldspawn(0 0 0) ? /*QUAKED worldspawn(0 0 0) ?
Only used for the world entity. Only used for the world entity.
Set message to the level name. Set message to the level name.
@ -162,7 +13,6 @@ World Types:
1: metal 1: metal
2: base 2: base
*/ */
//=======================
void() worldspawn = { void() worldspawn = {
lastspawn = world; lastspawn = world;
InitBodyQue(); InitBodyQue();