Whitespace, codingstyle, and other QFisms.

This commit is contained in:
Ragnvald Maartmann-Moe IV 2004-02-08 07:34:17 +00:00
parent 12b2ce3787
commit 88fcbcbcfd
34 changed files with 1004 additions and 769 deletions

View file

@ -9,7 +9,7 @@ CPP=cpp
CPPFLAGS=-I. -Iweapons -Imdl -Iact -Imapents CPPFLAGS=-I. -Iweapons -Imdl -Iact -Imapents
QFCC=qfcc QFCC=qfcc
QFCCFLAGS=-q --warn all,error --code v6only $(CPPFLAGS) QFCCFLAGS=-q --warn all,error $(CPPFLAGS)
############################################### ###############################################

View file

@ -11,13 +11,15 @@
float _bodyque_current; float _bodyque_current;
entity bodyque_head; entity bodyque_head;
void() bodyque_init = { void ()
bodyque_init =
{
local float i; local float i;
local entity e; local entity e;
e = bodyque_head = spawn ("BODYQUE"); e = bodyque_head = spawn ("BODYQUE");
bodyque_head.owner = bodyque_head; bodyque_head.owner = bodyque_head;
for (i = 1; i < CONFIG_BODYQUE_MAX; i = i + 1) { for (i = 1; i < CONFIG_BODYQUE_MAX; i++) {
bodyque_head.owner = spawn ("BODYQUE"); bodyque_head.owner = spawn ("BODYQUE");
bodyque_head.owner.chain = bodyque_head; bodyque_head.owner.chain = bodyque_head;
bodyque_head = bodyque_head.owner; bodyque_head = bodyque_head.owner;
@ -31,11 +33,14 @@ void() bodyque_init = {
precache_sound ("player/udeath.wav"); precache_sound ("player/udeath.wav");
}; };
void() _bodyque_fade_think = { void ()
_bodyque_fade_think =
{
local vector org; local vector org;
if (self.mdl_think) { if (self.mdl_think) {
if (!self.mdl_thought) self.mdl_think(); if (!self.mdl_thought)
self.mdl_think ();
self.mdl_thought = FALSE; self.mdl_thought = FALSE;
} }
@ -50,7 +55,9 @@ void() _bodyque_fade_think = {
self.nextthink = time + 0.1; self.nextthink = time + 0.1;
}; };
void() _bodyque_fade_from_reality = { void ()
_bodyque_fade_from_reality =
{
local entity new_bodyque; local entity new_bodyque;
if (_bodyque_current >= CONFIG_BODYQUE_FADE_MAX) if (_bodyque_current >= CONFIG_BODYQUE_FADE_MAX)
@ -81,16 +88,21 @@ void() _bodyque_fade_from_reality = {
_bodyque_current = _bodyque_current + 1; _bodyque_current = _bodyque_current + 1;
}; };
void() _bodyque_think = { void ()
_bodyque_think =
{
if (self.mdl_think) { if (self.mdl_think) {
if (!self.mdl_thought) self.mdl_think(); if (!self.mdl_thought)
self.mdl_think ();
self.mdl_thought = FALSE; self.mdl_thought = FALSE;
} }
self.nextthink = time + 0.1; self.nextthink = time + 0.1;
}; };
entity(entity body) bodyque_que = { entity (entity body)
bodyque_que =
{
local entity ret; local entity ret;
if (bodyque_head.count) if (bodyque_head.count)

View file

@ -2,10 +2,8 @@
#define BODYQUE_qh 1 #define BODYQUE_qh 1
@extern { @extern {
void () bodyque_init; void () bodyque_init;
entity (entity body) bodyque_que; entity (entity body) bodyque_que;
}; };
#endif #endif

View file

@ -22,13 +22,17 @@
#include "teleport.qh" #include "teleport.qh"
void() client_init = { void ()
client_init =
{
precache_model ("progs/player.mdl"); precache_model ("progs/player.mdl");
precache_model ("progs/eyes.mdl"); precache_model ("progs/eyes.mdl");
}; };
// This is the first function called by C code for a new player. // This is the first function called by C code for a new player.
void() SetNewParms = { void ()
SetNewParms =
{
parm1 = CONFIG_START_CURRENCY; parm1 = CONFIG_START_CURRENCY;
parm2 = parm3 = parm4 = parm5 = 0; parm2 = parm3 = parm4 = parm5 = 0;
@ -46,12 +50,16 @@ void() SetNewParms = {
parm16 = EQUIP_STATE_CHOOSE; parm16 = EQUIP_STATE_CHOOSE;
}; };
void() SetDeadParms = { void ()
SetDeadParms =
{
SetNewParms(); SetNewParms();
}; };
// Called when about to change maps // Called when about to change maps
void() SetChangeParms = { void ()
SetChangeParms =
{
/* Currency */ /* Currency */
parm1 = self.currency; parm1 = self.currency;
@ -62,7 +70,8 @@ void() SetChangeParms = {
parm5 = self.itemfield_4; parm5 = self.itemfield_4;
/* Health and such */ /* Health and such */
if (self.health < 0) self.health = 0; if (self.health < 0)
self.health = 0;
parm6 = self.health + self.armorvalue * 999; parm6 = self.health + self.armorvalue * 999;
parm7 = self.armortype; parm7 = self.armortype;
@ -83,7 +92,9 @@ void() SetChangeParms = {
SetDeadParms (); SetDeadParms ();
}; };
void() DecodeParms = { void ()
DecodeParms =
{
/* Currency */ /* Currency */
self.currency = parm1; self.currency = parm1;
@ -124,13 +135,17 @@ void() DecodeParms = {
SetDeadParms (); SetDeadParms ();
}; };
void() RemoveClientFromGame = { void ()
RemoveClientFromGame =
{
self.classname = "player_outofgame"; self.classname = "player_outofgame";
mdl_setup_void (); mdl_setup_void ();
act_setup_dead (); act_setup_dead ();
}; };
void() PutClientInGame = { void ()
PutClientInGame =
{
local entity ent; local entity ent;
local float spawncount; local float spawncount;
@ -167,7 +182,9 @@ void() PutClientInGame = {
}; };
// Called right after ClientConnect, and on new maps. // Called right after ClientConnect, and on new maps.
void() PutClientInServer = { void ()
PutClientInServer =
{
local entity spot; local entity spot;
/* Hack to get pmodel for servers that check it */ /* Hack to get pmodel for servers that check it */
@ -188,17 +205,24 @@ void() PutClientInServer = {
RemoveClientFromGame (); RemoveClientFromGame ();
}; };
void() _deathmsg_suicide = { void ()
_deathmsg_suicide =
{
local float r; local float r;
local string nname; local string nname;
nname = name (self); nname = name (self);
r = random(); r = random();
if (r < 0.25) bprint(PRINT_DEATH, nname, " says good bye to this cruel world.\n"); if (r < 0.25)
else if (r < 0.5) bprint(PRINT_DEATH, nname, " takes the easy way out.\n"); bprint (PRINT_DEATH, nname, " says good bye to this cruel world.\n");
else if (r < 0.75) bprint(PRINT_DEATH, nname, " suicides.\n"); else if (r < 0.5)
else bprint(PRINT_DEATH, nname, " stands at the wrong end of his shotgun.\n"); bprint (PRINT_DEATH, nname, " takes the easy way out.\n");
else if (r < 0.75)
bprint (PRINT_DEATH, nname, " suicides.\n");
else
bprint (PRINT_DEATH, nname,
" stands at the wrong end of his shotgun.\n");
}; };
// C Code calls this when the player issues a 'kill' command. // C Code calls this when the player issues a 'kill' command.
@ -207,14 +231,19 @@ ClientKill = {
damage (self, self, self, DAMAGE_MUSTDIE, _deathmsg_suicide); damage (self, self, self, DAMAGE_MUSTDIE, _deathmsg_suicide);
}; };
void() _client_th_kill = { void ()
if (other == self) self.frags--; _client_th_kill =
else self.frags++; {
if (other == self)
self.frags--;
else
self.frags++;
logfrag (self, other); logfrag (self, other);
}; };
// Called after the client is fully connected // Called after the client is fully connected
void() ClientConnect = { void ()
ClientConnect = {
bprint (PRINT_HIGH, name (self), " connected\n"); bprint (PRINT_HIGH, name (self), " connected\n");
self.flags |= FL_CLIENT; self.flags |= FL_CLIENT;
@ -222,9 +251,12 @@ void() ClientConnect = {
}; };
// Called when the client disconnects // Called when the client disconnects
void() ClientDisconnect = { void ()
ClientDisconnect =
{
self.flags = 0; self.flags = 0;
bprint(PRINT_HIGH, name(self), " disconnected with ", ftos(self.frags), " frags\n"); bprint (PRINT_HIGH, name(self), " disconnected with ", ftos(self.frags),
" frags\n");
override_set_th_kill (self, NOTHING_function); override_set_th_kill (self, NOTHING_function);
self.deathmsg1 = NIL; self.deathmsg1 = NIL;

View file

@ -2,7 +2,6 @@
#define CLIENT_qh 1 #define CLIENT_qh 1
@extern { @extern {
void () client_init; void () client_init;
void () RemoveClientFromGame; void () RemoveClientFromGame;
@ -10,7 +9,6 @@ void() PutClientInGame;
void () ClientConnect; void () ClientConnect;
void () ClientDisconnect; void () ClientDisconnect;
}; };
#endif #endif

View file

@ -29,11 +29,15 @@
entity ghost_inflictor; entity ghost_inflictor;
void() damage_init = { void ()
damage_init =
{
ghost_inflictor = spawn ("GHOST_INFLICTOR"); ghost_inflictor = spawn ("GHOST_INFLICTOR");
}; };
void(entity from, entity to) deathmsg_copy = { void (entity from, entity to)
deathmsg_copy =
{
to.deathmsg1 = from.deathmsg1; to.deathmsg1 = from.deathmsg1;
to.deathmsg2 = from.deathmsg2; to.deathmsg2 = from.deathmsg2;
to.deathmsg3 = from.deathmsg3; to.deathmsg3 = from.deathmsg3;
@ -43,39 +47,53 @@ void(entity from, entity to) deathmsg_copy = {
}; };
string (entity e, string s) _deathmsg_custom_str = { string (entity e, string s) _deathmsg_custom_str = {
if (s == "name(self)") return name(self); if (s == "name(self)")
if (s == "name(attacker)") return name(self.dmg_attacker); return name(self);
if (s == "name(inflictor)") return name(self.dmg_inflictor); if (s == "name(attacker)")
return name (self.dmg_attacker);
if (s == "name(inflictor)")
return name (self.dmg_inflictor);
return s; return s;
}; };
void() _deathmsg_custom = { void ()
_deathmsg_custom =
{
local string s1, s2, s3, s4, s5, s6; local string s1, s2, s3, s4, s5, s6;
s1 = s2 = s3 = s4 = s5 = s6 = ""; s1 = s2 = s3 = s4 = s5 = s6 = "";
s1 = _deathmsg_custom_str (self, self.deathmsg1); s1 = _deathmsg_custom_str (self, self.deathmsg1);
if (s1) s2 = _deathmsg_custom_str(self, self.deathmsg2); if (s1)
if (s2) s3 = _deathmsg_custom_str(self, self.deathmsg3); s2 = _deathmsg_custom_str (self, self.deathmsg2);
if (s3) s4 = _deathmsg_custom_str(self, self.deathmsg4); if (s2)
if (s4) s5 = _deathmsg_custom_str(self, self.deathmsg5); s3 = _deathmsg_custom_str (self, self.deathmsg3);
if (s5) s6 = _deathmsg_custom_str(self, self.deathmsg6); if (s3)
s4 = _deathmsg_custom_str (self, self.deathmsg4);
if (s4)
s5 = _deathmsg_custom_str (self, self.deathmsg5);
if (s5)
s6 = _deathmsg_custom_str (self, self.deathmsg6);
// I don't use separate bprints, because iD in all its wisdom // I don't use separate bprints, because iD in all its wisdom
// made them unreliable -- I'd rather lose the whole thing than parts. // made them unreliable -- I'd rather lose the whole thing than parts.
bprint (PRINT_DEATH, s1, s2, s3, s4, s5, s6); bprint (PRINT_DEATH, s1, s2, s3, s4, s5, s6);
}; };
void() deathmsg_nodisplay = { void ()
//XXX refcount_dec(self.dmg_attacker); deathmsg_nodisplay =
//XXX refcount_dec(self.dmg_inflictor); {
// refcount_dec (self.dmg_attacker);
// refcount_dec (self.dmg_inflictor);
self.dmg_attacker = world; self.dmg_attacker = world;
self.dmg_inflictor = world; self.dmg_inflictor = world;
self.deathmsg = NOTHING_function; self.deathmsg = NOTHING_function;
}; };
void() deathmsg_display = { void ()
deathmsg_display =
{
if (self.th_die) if (self.th_die)
self.th_die (); self.th_die ();
@ -98,7 +116,8 @@ void() deathmsg_display = {
deathmsg_nodisplay (); deathmsg_nodisplay ();
}; };
float(float d) damage_armor = { float (float d)
damage_armor = {
local float adamg, rest; local float adamg, rest;
adamg = d * self.armortype; adamg = d * self.armortype;
@ -116,7 +135,9 @@ float(float d) damage_armor = {
return rest; return rest;
}; };
void(float d) damage_push = { void (float d)
damage_push =
{
local vector vel; local vector vel;
if (self.mass == 0) { if (self.mass == 0) {
@ -139,8 +160,10 @@ void(float d) damage_push = {
}; };
// deathmessage _IS_ overridden if inflictor.deathmsg1 // deathmessage _IS_ overridden if inflictor.deathmsg1
float(entity ent, entity attacker, entity inflictor, float d, void() deathmessage) float (entity ent, entity attacker, entity inflictor, float d,
damage = { void() deathmessage)
damage =
{
local entity oldself, oldother; local entity oldself, oldother;
local float wasdamaged; local float wasdamaged;
@ -153,8 +176,8 @@ damage = {
ent.dmg_attacker = attacker; ent.dmg_attacker = attacker;
ent.dmg_inflictor = inflictor; ent.dmg_inflictor = inflictor;
//XXX refcount_inc(ent.dmg_attacker); // refcount_inc (ent.dmg_attacker);
//XXX refcount_inc(ent.dmg_inflictor); // refcount_inc (ent.dmg_inflictor);
if (inflictor.deathmsg1) if (inflictor.deathmsg1)
ent.deathmsg = _deathmsg_custom; ent.deathmsg = _deathmsg_custom;
@ -170,7 +193,8 @@ damage = {
self = oldself; self = oldself;
other = oldother; other = oldother;
if (d < 0) return FALSE; if (d < 0)
return FALSE;
} }
self = ent; self = ent;
@ -184,7 +208,9 @@ damage = {
return wasdamaged; return wasdamaged;
}; };
float(vector org, entity e) _damage_radius_can_hit = { float (vector org, entity e)
_damage_radius_can_hit =
{
if (e.movetype == MOVETYPE_PUSH) { if (e.movetype == MOVETYPE_PUSH) {
traceline (org, center (e), TRUE, world); traceline (org, center (e), TRUE, world);
@ -194,25 +220,30 @@ float(vector org, entity e) _damage_radius_can_hit = {
} }
traceline (org, e.origin, TRUE, self); traceline (org, e.origin, TRUE, self);
if (trace_fraction == 1) return TRUE; if (trace_fraction == 1)
return TRUE;
traceline (org, e.origin + '15 15 0', TRUE, self); traceline (org, e.origin + '15 15 0', TRUE, self);
if (trace_fraction == 1) return TRUE; if (trace_fraction == 1)
return TRUE;
traceline (org, e.origin + '15 -15 0', TRUE, self); traceline (org, e.origin + '15 -15 0', TRUE, self);
if (trace_fraction == 1) return TRUE; if (trace_fraction == 1)
return TRUE;
traceline (org, e.origin + '-15 15 0', TRUE, self); traceline (org, e.origin + '-15 15 0', TRUE, self);
if (trace_fraction == 1) return TRUE; if (trace_fraction == 1)
return TRUE;
traceline (org, e.origin + '-15 -15 0', TRUE, self); traceline (org, e.origin + '-15 -15 0', TRUE, self);
if (trace_fraction == 1) return TRUE; if (trace_fraction == 1)
return TRUE;
return FALSE; return FALSE;
}; };
void (entity ignore, entity attacker, entity inflictor, void () deathmessage) void (entity ignore, entity attacker, entity inflictor, void () deathmessage)
damage_radius = { damage_radius =
{
local entity head; local entity head;
local vector iorg, org; local vector iorg, org;
local float points; local float points, d, m, r;
local float d, m, r;
d = inflictor.dmg; d = inflictor.dmg;
m = inflictor.mass; m = inflictor.mass;

View file

@ -2,7 +2,6 @@
#define DAMAGE_qh 1 #define DAMAGE_qh 1
@extern { @extern {
#define DAMAGE_SHOULDDIE 16777214 #define DAMAGE_SHOULDDIE 16777214
#define DAMAGE_MUSTDIE 16777215 #define DAMAGE_MUSTDIE 16777215
@ -54,7 +53,6 @@ float(entity ent, entity attacker, entity inflictor, float d, void() deathmessag
void (entity ignore, entity attacker, entity inflictor, void () deathmessage) damage_radius; void (entity ignore, entity attacker, entity inflictor, void () deathmessage) damage_radius;
float (vector org, entity e) _damage_radius_can_hit; float (vector org, entity e) _damage_radius_can_hit;
}; };
#endif #endif

View file

@ -1,12 +1,13 @@
#include "common.qh" #include "common.qh"
#include "debug.qh" #include "debug.qh"
void() debug_impulse = { void ()
debug_impulse =
{
local float imp; local float imp;
imp = self.impulse; imp = self.impulse;
self.impulse = 0; self.impulse = 0;
{ {
self.impulse = imp; self.impulse = imp;
} }

View file

@ -2,9 +2,7 @@
#define DEBUG_qh 1 #define DEBUG_qh 1
@extern { @extern {
void () debug_impulse; void () debug_impulse;
}; };
#endif #endif

View file

@ -139,8 +139,8 @@
#define MULTICAST_PHS_R 4 /* within hearing, reliable */ #define MULTICAST_PHS_R 4 /* within hearing, reliable */
#define MULTICAST_PVS_R 5 /* within sight, reliable */ #define MULTICAST_PVS_R 5 /* within sight, reliable */
// ========================================================================== // // ========================================================================= //
// ========================================================================== // // ========================================================================= //
// takedamage values // takedamage values
#define DAMAGE_NO 0 #define DAMAGE_NO 0

View file

@ -33,8 +33,6 @@ void() func##_all = { \
self = oldself; \ self = oldself; \
} }
#define do_fields() \ #define do_fields() \
do_(health); \ do_(health); \
do_(armorvalue); \ do_(armorvalue); \
@ -44,15 +42,17 @@ void() func##_all = { \
do_(ammo_shells); \ do_(ammo_shells); \
do_(ammo_nails); \ do_(ammo_nails); \
do_(ammo_rockets); \ do_(ammo_rockets); \
do_(ammo_cells) do_(ammo_cells);
void() delays_swapin_stats = { void ()
delays_swapin_stats =
{
local float tmp; local float tmp;
#define do_(field) \ #define do_(field) \
tmp = self.field; \ tmp = self.field; \
self.field = self.delay_##field; \ self.field = self.delay_##field; \
self.delay_##field = tmp self.delay_##field = tmp;
do_fields (); do_fields ();
#undef do_ #undef do_
@ -62,7 +62,9 @@ all_func(delays_swapin_stats);
// ===================================================================== // // ===================================================================== //
float() delays_changed = { float ()
delays_changed =
{
#define do_(field) \ #define do_(field) \
if (floor (self.field) != floor (self.delay_##field)) \ if (floor (self.field) != floor (self.delay_##field)) \
return TRUE return TRUE
@ -74,21 +76,26 @@ float() delays_changed = {
// ===================================================================== // // ===================================================================== //
void() delays_force_update = { void ()
delays_force_update =
{
self.delay_time = 0; self.delay_time = 0;
}; };
all_func (delays_force_update); all_func (delays_force_update);
// ===================================================================== // // ===================================================================== //
void() delays_swapout_stats = { void ()
delays_swapout_stats =
{
if (delays_changed ()) if (delays_changed ())
self.delay_last_change = time; self.delay_last_change = time;
self.delay_dmg_take += self.dmg_take; self.dmg_take = 0; self.delay_dmg_take += self.dmg_take;
self.delay_dmg_save += self.dmg_save; self.dmg_save = 0; self.dmg_take = 0;
self.delay_dmg_save += self.dmg_save;
self.dmg_save = 0;
if (time < self.delay_time) { if (time < self.delay_time) {
delays_swapin_stats (); delays_swapin_stats ();
@ -99,11 +106,14 @@ void() delays_swapout_stats = {
do_fields (); do_fields ();
#undef do_ #undef do_
self.dmg_take = ceil(self.delay_dmg_take); self.delay_dmg_take = 0; self.dmg_take = ceil (self.delay_dmg_take);
if (self.dmg_take > 255) self.dmg_take = 255; self.delay_dmg_take = 0;
if (self.dmg_take > 255)
self.dmg_take = 255;
self.dmg_save = ceil(self.delay_dmg_save); self.delay_dmg_save = 0; self.dmg_save = ceil(self.delay_dmg_save); self.delay_dmg_save = 0;
if (self.dmg_save > 255) self.dmg_save = 255; if (self.dmg_save > 255)
self.dmg_save = 255;
if ((self.delay_last_change - time) >= -CONFIG_STATS_DELAY) if ((self.delay_last_change - time) >= -CONFIG_STATS_DELAY)
self.delay_time = time + CONFIG_STATS_DELAY; self.delay_time = time + CONFIG_STATS_DELAY;

View file

@ -2,7 +2,6 @@
#define DELAYS_qh 1 #define DELAYS_qh 1
@extern { @extern {
void () delays_swapin_stats; void () delays_swapin_stats;
void () delays_swapout_stats; void () delays_swapout_stats;
@ -11,7 +10,6 @@ void() delays_force_update;
void () delays_swapin_stats_all; void () delays_swapin_stats_all;
void () delays_swapout_stats_all; void () delays_swapout_stats_all;
void () delays_force_update_all; void () delays_force_update_all;
}; };
#endif #endif

View file

@ -2,7 +2,6 @@
#define EFFECT_qh 1 #define EFFECT_qh 1
@extern { @extern {
void () effect_muzzleflash; void () effect_muzzleflash;
void (entity e) effect_smallkick; void (entity e) effect_smallkick;
void (vector org, vector dir, float d) effect_blood; void (vector org, vector dir, float d) effect_blood;
@ -11,7 +10,6 @@ void(vector org, vector vel) effect_nail_spark;
void (vector org) effect_explosion; void (vector org) effect_explosion;
void (vector org) effect_teleport_fog; void (vector org) effect_teleport_fog;
void (entity from, vector p1, vector p2) effect_lightning2; void (entity from, vector p1, vector p2) effect_lightning2;
}; };
#endif #endif

View file

@ -10,7 +10,9 @@
.float itemfield_3; .float itemfield_3;
.float itemfield_4; .float itemfield_4;
float(entity e, float eid) equip_flag = { float (entity e, float eid)
equip_flag =
{
if (eid < 24) { if (eid < 24) {
e.itemfield = itemfield_1; e.itemfield = itemfield_1;
} else if (eid < 48) { } else if (eid < 48) {
@ -24,10 +26,12 @@ float(entity e, float eid) equip_flag = {
eid -= 72; eid -= 72;
} }
return shl(1, eid); /* FIXME: use (1 << eid) when the compiler isn't b0rk */ return (1 << eid);
}; };
float(entity e, float eid) equip_query = { float (entity e, float eid)
equip_query =
{
eid = equip_flag (e, eid); eid = equip_flag (e, eid);
if (e.(e.itemfield) & eid) if (e.(e.itemfield) & eid)
@ -36,7 +40,9 @@ float(entity e, float eid) equip_query = {
return FALSE; return FALSE;
}; };
float(entity e, float eid) equip_grant = { float (entity e, float eid)
equip_grant =
{
eid = equip_flag (e, eid); eid = equip_flag (e, eid);
if (e.(e.itemfield) & eid) if (e.(e.itemfield) & eid)
@ -47,7 +53,9 @@ float(entity e, float eid) equip_grant = {
return TRUE; return TRUE;
}; };
float(entity e, float eid) equip_remove = { float (entity e, float eid)
equip_remove =
{
eid = equip_flag (e, eid); eid = equip_flag (e, eid);
if (e.(e.itemfield) & eid) { if (e.(e.itemfield) & eid) {
@ -60,7 +68,9 @@ float(entity e, float eid) equip_remove = {
float _equip_iter_id; float _equip_iter_id;
/* Returns EQUIPID_* or -1 when done */ /* Returns EQUIPID_* or -1 when done */
float(entity iteme) equip_iter = { float (entity iteme)
equip_iter =
{
local float ret, flag; local float ret, flag;
while (1) { while (1) {

View file

@ -4,7 +4,6 @@
#include "equipid.qh" #include "equipid.qh"
@extern { @extern {
#define EQUIP_STATE_CHOOSE 0 #define EQUIP_STATE_CHOOSE 0
#define EQUIP_STATE_CHOSEN 1 #define EQUIP_STATE_CHOSEN 1
@ -25,7 +24,6 @@ float(entity e, float eid) equip_remove;
float (entity iteme) equip_iter; float (entity iteme) equip_iter;
string (float eid) equip_id_to_string; string (float eid) equip_id_to_string;
}; };
#endif #endif

View file

@ -2,20 +2,52 @@
#include "builtins.qh" #include "builtins.qh"
/* Ugh. QuakeC doesn't include these ops. */ /* Ugh. QuakeC doesn't include these ops. */
float(float num, float bits) shl = { float (float num, float bits)
if (bits >= 16) { num *= 65536; bits -= 16; } shl =
if (bits >= 8) { num *= 256; bits -= 8; } {
if (bits >= 4) { num *= 16; bits -= 4; } if (bits >= 16) {
if (bits >= 2) { num *= 4; bits -= 2; } num *= 65536;
if (bits >= 1) { num *= 2; } bits -= 16;
}
if (bits >= 8) {
num *= 256;
bits -= 8;
}
if (bits >= 4) {
num *= 16;
bits -= 4;
}
if (bits >= 2) {
num *= 4;
bits -= 2;
}
if (bits >= 1) {
num *= 2;
}
return num; return num;
}; };
float(float num, float bits) shr = { float (float num, float bits)
if (bits >= 16) { num /= 65536; bits -= 16; } shr =
if (bits >= 8) { num /= 256; bits -= 8; } {
if (bits >= 4) { num /= 16; bits -= 4; } if (bits >= 16) {
if (bits >= 2) { num /= 4; bits -= 2; } num /= 65536;
if (bits >= 1) { num /= 2; } bits -= 16;
}
if (bits >= 8) {
num /= 256;
bits -= 8;
}
if (bits >= 4) {
num /= 16;
bits -= 4;
}
if (bits >= 2) {
num /= 4;
bits -= 2;
}
if (bits >= 1) {
num /= 2;
}
return floor (num); return floor (num);
}; };

View file

@ -2,13 +2,11 @@
#define MATH_qh 1 #define MATH_qh 1
@extern { @extern {
float (float num, float bits) shl; float (float num, float bits) shl;
float (float num, float bits) shr; float (float num, float bits) shr;
#define min(a, b) ((a)>(b)?(b):(a)) #define min(a, b) ((a)>(b)?(b):(a))
#define max(a, b) ((a)>(b)?(a):(b)) #define max(a, b) ((a)>(b)?(a):(b))
}; };
#endif #endif

View file

@ -5,13 +5,17 @@
.float menu_time; .float menu_time;
.void () menu_think; .void () menu_think;
void(void() menu_func) menu_set = { void (void () menu_func)
menu_set =
{
self.menu_state = 0; self.menu_state = 0;
self.menu_time = 0; self.menu_time = 0;
self.menu_think = menu_func; self.menu_think = menu_func;
}; };
float() util_menu_needs_print = { float ()
util_menu_needs_print =
{
if (time > self.menu_time) { if (time > self.menu_time) {
self.menu_time = time + 1.4; self.menu_time = time + 1.4;
return TRUE; return TRUE;

View file

@ -4,7 +4,9 @@
#include "misc.qh" #include "misc.qh"
/* /*
void() menu_team = { void ()
menu_team =
{
if (team_ischosen (self)) if (team_ischosen (self))
menu_set (menu_equip); menu_set (menu_equip);
@ -15,15 +17,15 @@ void() menu_team = {
"1\b.\b Red\n" "1\b.\b Red\n"
"2\b.\b Blue\n" "2\b.\b Blue\n"
"\n" "\n"
"0\b.\b Auto\n" "0\b.\b Auto\n");
);
} }
if (self.impulse == 1) { if (self.impulse == 1) {
team_join (TEAM_RED); team_join (TEAM_RED);
} else if (self.impulse == 2) { } else if (self.impulse == 2) {
team_join (TEAM_BLUE); team_join (TEAM_BLUE);
} else if (self.impulse == 10 || self.button0 || self.button1 || self.button2) { } else if (self.impulse == 10 || self.button0 || self.button1
|| self.button2) {
team_join_auto (); team_join_auto ();
} }
@ -49,7 +51,6 @@ void() menu_intro = {
"\[ by Zinx Verituse \]\n" "\[ by Zinx Verituse \]\n"
"\[ http://staff.xmms.org/zinx/klik \]\n" "\[ http://staff.xmms.org/zinx/klik \]\n"
"\n" "\n"
"\<[ It's a Quake World. ]\>\n" "\<[ It's a Quake World. ]\>\n");
);
} }
}; };

View file

@ -9,7 +9,9 @@
// ===================================================================== // // ===================================================================== //
entity(string clname) spawn = { entity (string clname)
spawn =
{
local entity e; local entity e;
e = BUILTIN_spawn (); e = BUILTIN_spawn ();
@ -20,9 +22,15 @@ entity(string clname) spawn = {
// ===================================================================== // // ===================================================================== //
void() SUB_remove = { remove(self); }; void ()
SUB_remove =
{
remove (self);
};
void(entity e) safe_remove = { void (entity e)
safe_remove =
{
e.takedamage = DAMAGE_NO; e.takedamage = DAMAGE_NO;
e.solid = SOLID_NOT; e.solid = SOLID_NOT;
e.model = NIL; e.model = NIL;
@ -34,9 +42,15 @@ void(entity e) safe_remove = {
// ===================================================================== // // ===================================================================== //
void() SUB_makestatic = { makestatic(self); }; void ()
SUB_makestatic =
{
makestatic (self);
};
void(entity e) safe_makestatic = { void (entity e)
safe_makestatic =
{
if (sv_spawning) { if (sv_spawning) {
makestatic (self); makestatic (self);
return; return;
@ -51,11 +65,16 @@ void(entity e) safe_makestatic = {
// ===================================================================== // // ===================================================================== //
void() _sound_vector_think = { void ()
_sound_vector_think =
{
sound (self, CHAN_VOICE, self.noise1, self.volume, self.attenuation); sound (self, CHAN_VOICE, self.noise1, self.volume, self.attenuation);
remove (self); remove (self);
}; };
void(vector org, string samp, float vol, float atten) sound_vector = {
void (vector org, string samp, float vol, float atten)
sound_vector =
{
local entity e; local entity e;
e = spawn("SOUND"); e = spawn("SOUND");
@ -70,30 +89,41 @@ void(vector org, string samp, float vol, float atten) sound_vector = {
// ===================================================================== // // ===================================================================== //
float(vector org) _missile_th_teleport = { float (vector org)
_missile_th_teleport =
{
self.owner = world; self.owner = world;
return TRUE; return TRUE;
}; };
void (entity mis) missile_check_teleport; void (entity mis) missile_check_teleport;
void() _missile_always_trigger = {
void ()
_missile_always_trigger =
{
self.think = SUB_remove; self.think = SUB_remove;
self.nextthink = self.attack_finished; self.nextthink = self.attack_finished;
if (self.movetype != MOVETYPE_FLYMISSILE && self.movetype != MOVETYPE_FLY) if ((self.movetype != MOVETYPE_FLYMISSILE)
&& (self.movetype != MOVETYPE_FLY))
return; return;
tl_proj_begin (); tl_proj_begin ();
/* Make sure we're still going to hit the thing */ /* Make sure we're still going to hit the thing */
traceline(self.origin, self.origin + self.velocity * sv_maxtic*2, FALSE, self); traceline (self.origin, self.origin + self.velocity * sv_maxtic * 2, FALSE,
if (trace_ent == self.enemy) tl_touch(trace_ent, self); self);
else self.enemy = world; if (trace_ent == self.enemy)
tl_touch (trace_ent, self);
else
self.enemy = world;
tl_proj_end (); tl_proj_end ();
missile_check_teleport (self); missile_check_teleport (self);
}; };
void(entity mis) missile_check_teleport = { void (entity mis)
missile_check_teleport =
{
local float duration; local float duration;
tl_proj_begin (); tl_proj_begin ();
@ -103,14 +133,16 @@ void(entity mis) missile_check_teleport = {
duration = mis.attack_finished - time; duration = mis.attack_finished - time;
while (duration > sv_maxtic) { while (duration > sv_maxtic) {
traceline(trace_endpos, trace_endpos + mis.velocity*duration, FALSE, trace_ent); traceline (trace_endpos, trace_endpos + mis.velocity * duration,
FALSE, trace_ent);
if (!trace_ent || trace_ent.solid == SOLID_BSP) { if (!trace_ent || trace_ent.solid == SOLID_BSP) {
/* Don't bother tracing through BSP, it won't happen. */ /* Don't bother tracing through BSP, it won't happen. */
break; break;
} }
if (tl_issolid(trace_ent) || mis.enemy == trace_ent || (duration*trace_fraction) <= sv_maxtic) { if (tl_issolid (trace_ent) || mis.enemy == trace_ent
|| (duration * trace_fraction) <= sv_maxtic) {
/* We hit a triggered trigger, /* We hit a triggered trigger,
a solid ent, or something we _just_ hit */ a solid ent, or something we _just_ hit */
if (trace_fraction == 0) { if (trace_fraction == 0) {
@ -132,7 +164,9 @@ void(entity mis) missile_check_teleport = {
tl_proj_end (); tl_proj_end ();
}; };
entity(string clname, string mod, vector org, vector dir, float spd) spawn_missile = { entity (string clname, string mod, vector org, vector dir, float spd)
spawn_missile =
{
newmis = spawn (clname); newmis = spawn (clname);
newmis.owner = self; newmis.owner = self;
@ -166,7 +200,9 @@ entity(string clname, string mod, vector org, vector dir, float spd) spawn_missi
entity tl_first; entity tl_first;
.entity tl_next; .entity tl_next;
void() tl_proj_begin = { void ()
tl_proj_begin =
{
local entity walk; local entity walk;
tl_first = world; tl_first = world;
@ -183,7 +219,9 @@ void() tl_proj_begin = {
} }
}; };
void() tl_proj_end = { void ()
tl_proj_end =
{
local entity walk; local entity walk;
for (walk = tl_first; walk; walk = walk.tl_next) { for (walk = tl_first; walk; walk = walk.tl_next) {
@ -193,7 +231,9 @@ void() tl_proj_end = {
} }
}; };
void(entity trigger, entity fake_proj) tl_touch = { void (entity trigger, entity fake_proj)
tl_touch =
{
local entity oldself, oldother; local entity oldself, oldother;
if (!trigger.touch) if (!trigger.touch)
@ -217,9 +257,13 @@ void(entity trigger, entity fake_proj) tl_touch = {
// ===================================================================== // // ===================================================================== //
string(entity e) name = { string (entity e)
if (e.netname) return e.netname; name =
if (e.classname) return e.classname; {
if (e.netname)
return e.netname;
if (e.classname)
return e.classname;
if (e.velocity) if (e.velocity)
return "an unidentified flying object"; return "an unidentified flying object";
@ -228,13 +272,16 @@ string(entity e) name = {
// ===================================================================== // // ===================================================================== //
void(.string fld, string match, void(entity e) func) foreach = { void (.string fld, string match, void (entity e) func)
foreach =
{
local entity ent; local entity ent;
ent = world; ent = world;
while ((ent = find (ent, fld, match))) { while ((ent = find (ent, fld, match))) {
if (!func) { if (!func) {
dprint("NULL function in foreach, classname: ", ent.classname, "\n"); dprint ("NULL function in foreach, classname: ", ent.classname,
"\n");
continue; continue;
} }
@ -242,7 +289,9 @@ void(.string fld, string match, void(entity e) func) foreach = {
} }
}; };
void(.string fld, string match, .void() func) foreach_field = { void (.string fld, string match, .void () func)
foreach_field =
{
local entity oldself; local entity oldself;
oldself = self; oldself = self;
@ -250,7 +299,8 @@ void(.string fld, string match, .void() func) foreach_field = {
self = world; self = world;
while ((self = find (self, fld, match))) { while ((self = find (self, fld, match))) {
if (!self.func) { if (!self.func) {
dprint("NULL function in foreach_field, classname: ", self.classname, "\n"); dprint ("NULL function in foreach_field, classname: ",
self.classname, "\n");
continue; continue;
} }
@ -262,7 +312,8 @@ void(.string fld, string match, .void() func) foreach_field = {
// ===================================================================== // // ===================================================================== //
float(entity newself, entity newother, float() func) switcheroo = { float (entity newself, entity newother, float () func)
switcheroo = {
local entity oldself, oldother; local entity oldself, oldother;
local float ret; local float ret;
@ -282,16 +333,22 @@ float(entity newself, entity newother, float() func) switcheroo = {
// ===================================================================== // // ===================================================================== //
float(float current, float increment, float max) increase_bound = { float (float current, float increment, float max)
increase_bound =
{
local float diff; local float diff;
diff = max - current; diff = max - current;
if (diff <= 0) return current; if (diff <= 0)
if (diff > increment) diff = increment; return current;
if (diff > increment)
diff = increment;
return current + diff; return current + diff;
}; };
float(.float fld, float increment, float max) increase_field = { float (.float fld, float increment, float max)
increase_field =
{
local float new; local float new;
new = increase_bound (self.fld, increment, max); new = increase_bound (self.fld, increment, max);
@ -306,7 +363,9 @@ float(.float fld, float increment, float max) increase_field = {
// ===================================================================== // // ===================================================================== //
/* Not to be confused with maxspeed */ /* Not to be confused with maxspeed */
float(entity e) calc_max_speed = { float (entity e)
calc_max_speed =
{
local float spd; local float spd;
spd = e.maxspeed; spd = e.maxspeed;
@ -325,21 +384,26 @@ float(entity e) calc_max_speed = {
entity _xprint_client; entity _xprint_client;
float _xprint_level; float _xprint_level;
void(entity client, float level) xprint_start = { void (entity client, float level)
xprint_start =
{
_xprint_client = client; _xprint_client = client;
_xprint_level = level; _xprint_level = level;
}; };
void(string str) xprint_str = { void (string str)
xprint_str =
{
msg_entity = _xprint_client; msg_entity = _xprint_client;
WriteByte(MSG_ONE, SVC_PRINT); WriteBytes (MSG_ONE, (float) SVC_PRINT, _xprint_level);
WriteByte(MSG_ONE, _xprint_level);
WriteString (MSG_ONE, str); WriteString (MSG_ONE, str);
}; };
// ===================================================================== // // ===================================================================== //
entity(.string fld, string str) find_random = { entity (.string fld, string str)
find_random =
{
local float r, numents; local float r, numents;
local entity ent; local entity ent;
@ -348,13 +412,15 @@ entity(.string fld, string str) find_random = {
while (1) { while (1) {
ent = find (world, fld, str); ent = find (world, fld, str);
if (!ent) return world; if (!ent)
return world;
while (ent) { while (ent) {
numents++; numents++;
r--; r--;
if (r <= 0) return ent; if (r <= 0)
return ent;
ent = find (ent, fld, str); ent = find (ent, fld, str);
} }
@ -367,7 +433,9 @@ entity(.string fld, string str) find_random = {
// ===================================================================== // // ===================================================================== //
entity(entity ech) random_enemy_chain = { entity (entity ech)
random_enemy_chain =
{
local entity walk; local entity walk;
local float tot, r; local float tot, r;
@ -401,6 +469,3 @@ entity(entity ech) random_enemy_chain = {
return world; return world;
}; };
// ===================================================================== //

View file

@ -4,7 +4,6 @@
/* Random miscellaneous functions */ /* Random miscellaneous functions */
@extern { @extern {
entity (string clname) spawn; entity (string clname) spawn;
string (entity e) name; /* Returns the pretty entity name */ string (entity e) name; /* Returns the pretty entity name */
@ -67,7 +66,6 @@ void(entity trigger, entity fake_proj) tl_touch;
.float tl_notsolid; .float tl_notsolid;
#define tl_issolid(ent) (!ent.tl_notsolid) #define tl_issolid(ent) (!ent.tl_notsolid)
}; };
#endif #endif

View file

@ -74,7 +74,9 @@ all_types();
// ===================================================================== // // ===================================================================== //
void(entity e1, entity e2) _override_swap = { void (entity e1, entity e2)
_override_swap =
{
#define one_type(type1,type2) local type1 t_##type2 #define one_type(type1,type2) local type1 t_##type2
all_types(); all_types();
#undef one_type #undef one_type
@ -86,19 +88,21 @@ void(entity e1, entity e2) _override_swap = {
e2.func = t_##type2 e2.func = t_##type2
all_funcs(); all_funcs();
#undef one_func #undef one_func
}; };
// ===================================================================== // // ===================================================================== //
entity(entity e, string override_class, float priority) override_create = { entity (entity e, string override_class, float priority)
override_create =
{
local entity ovr, ovr2; local entity ovr, ovr2;
for (ovr = e.overrider; ovr; ovr = ovr.overrider) { for (ovr = e.overrider; ovr; ovr = ovr.overrider) {
if (ovr.classname == override_class) { if (ovr.classname == override_class) {
ovr2 = ovr.overrider; ovr2 = ovr.overrider;
if (!ovr2) ovr2 = e; if (!ovr2)
ovr2 = e;
_override_swap (ovr, ovr2); _override_swap (ovr, ovr2);
return ovr; return ovr;
} }
@ -114,9 +118,11 @@ entity(entity e, string override_class, float priority) override_create = {
ovr.overrider = spawn(override_class); ovr.overrider = spawn(override_class);
ovr.overrider.owner = ovr; ovr.overrider.owner = ovr;
ovr.overrider.overrider = ovr2; ovr.overrider.overrider = ovr2;
if (ovr2) ovr2.owner = ovr.overrider;
if (!ovr2) ovr2 = e; if (ovr2)
ovr2.owner = ovr.overrider;
if (!ovr2)
ovr2 = e;
ovr = ovr.overrider; ovr = ovr.overrider;
ovr.overrider_priority = priority; ovr.overrider_priority = priority;
@ -127,23 +133,27 @@ entity(entity e, string override_class, float priority) override_create = {
ovr.func = _passthru_##func ovr.func = _passthru_##func
all_funcs (); all_funcs ();
#undef one_func #undef one_func
return ovr; return ovr;
}; };
void(entity ovr) override_finalize = { void (entity ovr)
override_finalize =
{
_override_swap (ovr, ovr.goalentity); _override_swap (ovr, ovr.goalentity);
}; };
entity() override_findself = { entity ()
override_findself =
{
local entity ovrself; local entity ovrself;
ovrself = self.overrider_self; ovrself = self.overrider_self;
if (!ovrself) { if (!ovrself) {
/* Move to the end of the list */ /* Move to the end of the list */
for (ovrself = self.overrider; ovrself.overrider; ovrself = ovrself.overrider) ; for (ovrself = self.overrider; ovrself.overrider;
ovrself = ovrself.overrider);
} }
self.overrider_self = ovrself.owner; self.overrider_self = ovrself.owner;
@ -153,25 +163,30 @@ entity() override_findself = {
return ovrself; return ovrself;
}; };
void() override_halt = { void ()
override_halt =
{
self.overrider_self = world; self.overrider_self = world;
}; };
void(entity e, entity ovr) override_destroy = { void (entity e, entity ovr)
override_destroy =
{
local entity ovr2; local entity ovr2;
ovr2 = ovr.overrider; ovr2 = ovr.overrider;
if (!ovr2) ovr2 = e; if (!ovr2)
ovr2 = e;
/* Copy the funcs from ovr to ovr2 */ /* Copy the funcs from ovr to ovr2 */
#define one_func(type1,type2,func,args,return,val) \ #define one_func(type1,type2,func,args,return,val) \
ovr2.func = ovr.func ovr2.func = ovr.func
all_funcs(); all_funcs();
#undef one_func #undef one_func
if (ovr.overrider) ovr.overrider.owner = ovr.owner; if (ovr.overrider)
ovr.overrider.owner = ovr.owner;
ovr.owner.overrider = ovr.overrider; ovr.owner.overrider = ovr.overrider;
ovr.think = SUB_remove; ovr.think = SUB_remove;

View file

@ -2,7 +2,6 @@
#define OVERRIDE_qh 1 #define OVERRIDE_qh 1
@extern { @extern {
/* Returns an overrider with matching class, creating one if needed */ /* Returns an overrider with matching class, creating one if needed */
entity (entity e, string override_class, float priority) override_create; entity (entity e, string override_class, float priority) override_create;
@ -27,23 +26,16 @@ void(entity e, .float(vector vec) fld, float(vector vec) func) override_set_f_c;
void (entity e, .float (entity ent) fld, float (entity ent) func) override_set_f_e; void (entity e, .float (entity ent) fld, float (entity ent) func) override_set_f_e;
#define override_set_th_takeitem(e, func) override_set_f_v(e, th_takeitem, func) #define override_set_th_takeitem(e, func) override_set_f_v(e, th_takeitem, func)
#define override_set_th_attack(e, func) override_set_f_e(e, th_attack, func) #define override_set_th_attack(e, func) override_set_f_e(e, th_attack, func)
#define override_set_th_takedamage(e, func) override_set_f_f(e, th_takedamage, func) #define override_set_th_takedamage(e, func) override_set_f_f(e, th_takedamage, func)
#define override_set_th_dealdamage(e, func) override_set_f_f(e, th_dealdamage, func) #define override_set_th_dealdamage(e, func) override_set_f_f(e, th_dealdamage, func)
#define override_set_th_die(e, func) override_set_v_v(e, th_die, func) #define override_set_th_die(e, func) override_set_v_v(e, th_die, func)
#define override_set_th_kill(e, func) override_set_v_v(e, th_kill, func) #define override_set_th_kill(e, func) override_set_v_v(e, th_kill, func)
#define override_set_prethink(e, func) override_set_v_v(e, prethink, func) #define override_set_prethink(e, func) override_set_v_v(e, prethink, func)
#define override_set_actthink(e, func) override_set_v_v(e, actthink, func) #define override_set_actthink(e, func) override_set_v_v(e, actthink, func)
#define override_set_postthink(e, func) override_set_v_v(e, postthink, func) #define override_set_postthink(e, func) override_set_v_v(e, postthink, func)
#define override_set_th_teleport(e, func) override_set_f_c(e, th_teleport, func) #define override_set_th_teleport(e, func) override_set_f_c(e, th_teleport, func)
#define override_set_th_projectile(e, func) override_set_f_e(e, th_projectile, func) #define override_set_th_projectile(e, func) override_set_f_e(e, th_projectile, func)
}; };
#endif #endif

View file

@ -60,7 +60,7 @@ entity(entity e) nextent = #47; // for looping through all ents
void (float level, string s, ...) bprint = #23; void (float level, string s, ...) bprint = #23;
void (entity client, float level, string s, ...) sprint = #24; void (entity client, float level, string s, ...) sprint = #24;
void(entity client, string s, ...) centerprint = #73; // sprint, but in middle void (entity client, string s, ...) centerprint = #73; // sprint, but centered
void (string s, ...) dprint = #25; void (string s, ...) dprint = #25;
void (entity e) eprint = #31; // prints an entire edict void (entity e) eprint = #31; // prints an entire edict
@ -73,6 +73,9 @@ void(entity client, string s) stuffcmd = #21;
void () ChangeYaw = #49; // turn towards self.ideal_yaw void () ChangeYaw = #49; // turn towards self.ideal_yaw
// at self.yaw_speed // at self.yaw_speed
// direct client message generation // direct client message generation
void (float to, vector v) WriteAngleV = #0;
void (float to, vector v) WriteCoordV = #0;
void (float to, ...) WriteBytes = #0;
void (float to, float f) WriteByte = #52; void (float to, float f) WriteByte = #52;
void (float to, float f) WriteChar = #53; void (float to, float f) WriteChar = #53;
void (float to, float f) WriteShort = #54; void (float to, float f) WriteShort = #54;

View file

@ -33,13 +33,16 @@ float cl_rollangle, cl_rollspeed;
#define SV_FRAMES_BEFORE_SPAWN 3 #define SV_FRAMES_BEFORE_SPAWN 3
void() main = { void ()
main =
{
local entity walk; local entity walk;
/* Must be first. */ /* Must be first. */
max_clients = 0; max_clients = 0;
walk = world; walk = world;
while ((walk = nextent(walk))) max_clients++; while ((walk = nextent(walk)))
max_clients++;
sv_spawning = SV_FRAMES_BEFORE_SPAWN; sv_spawning = SV_FRAMES_BEFORE_SPAWN;
@ -56,9 +59,11 @@ void() main = {
}; };
float players_frame_started; float players_frame_started;
void() StartFrame = { void ()
StartFrame =
{
if (sv_spawning) { if (sv_spawning) {
sv_spawning = sv_spawning - 1; sv_spawning--;
if (!sv_spawning) { if (!sv_spawning) {
if (!intermission_head) if (!intermission_head)
intermission_head = spawn_head; intermission_head = spawn_head;
@ -71,7 +76,8 @@ void() StartFrame = {
SZ_frame (); SZ_frame ();
rocket_jump = stof (infokey (world, "rj")); rocket_jump = stof (infokey (world, "rj"));
if (rocket_jump <= 1) rocket_jump = 0; if (rocket_jump <= 1)
rocket_jump = 0;
sv_mintic = cvar ("sv_mintic"); sv_mintic = cvar ("sv_mintic");
sv_maxtic = cvar ("sv_maxtic"); sv_maxtic = cvar ("sv_maxtic");
@ -99,7 +105,9 @@ void() StartFrame = {
/* This is really called by QSG engines */ /* This is really called by QSG engines */
// void () EndFrame = {}; // void () EndFrame = {};
void() PlayerStartFrame = { void ()
PlayerStartFrame =
{
if (players_frame_started == -1) { if (players_frame_started == -1) {
/* First player after StartFrame */ /* First player after StartFrame */
players_frame_started = TRUE; players_frame_started = TRUE;
@ -114,7 +122,9 @@ void() PlayerStartFrame = {
delays_swapin_stats_all (); delays_swapin_stats_all ();
}; };
void() PlayerEndFrame = { void ()
PlayerEndFrame =
{
/* Unfortunately, a newmis can us damage this frame, /* Unfortunately, a newmis can us damage this frame,
after our postthink has been called. Damn. */ after our postthink has been called. Damn. */
/* We just force an update this frame for now. */ /* We just force an update this frame for now. */

View file

@ -2,7 +2,6 @@
#define SERVER_qh 1 #define SERVER_qh 1
@extern { @extern {
float max_clients; float max_clients;
// Various cvars [possibly] referenced by QC // Various cvars [possibly] referenced by QC
@ -21,7 +20,6 @@ void() StartFrame;
void () PlayerStartFrame; void () PlayerStartFrame;
void () PlayerEndFrame; void () PlayerEndFrame;
}; };
#endif #endif

View file

@ -1,16 +1,22 @@
#include "common.qh" #include "common.qh"
// Called when a spectator connects // Called when a spectator connects
void() SpectatorConnect = { void ()
SpectatorConnect =
{
bprint (PRINT_MEDIUM, "Spectator ", self.netname, " entered the game.\n"); bprint (PRINT_MEDIUM, "Spectator ", self.netname, " entered the game.\n");
}; };
// Called when a spectator disconnects // Called when a spectator disconnects
void() SpectatorDisconnect = { void ()
SpectatorDisconnect =
{
bprint (PRINT_MEDIUM, "Spectator ", self.netname, " left the game.\n"); bprint (PRINT_MEDIUM, "Spectator ", self.netname, " left the game.\n");
}; };
// Called around the same time as player thinks? // Called around the same time as player thinks?
void() SpectatorThink = { void ()
SpectatorThink =
{
self.impulse = 0; self.impulse = 0;
}; };

View file

@ -1,7 +1,7 @@
void () NOTHING_function = {}; void () NOTHING_function = {};
// ========================================================================== // // ========================================================================= //
// ========================================================================== // // ========================================================================= //
/* Fields in maps */ /* Fields in maps */
@ -43,8 +43,8 @@ void() NOTHING_function = {};
.string noise5, noise6; // can't activate, can activate. .string noise5, noise6; // can't activate, can activate.
.string noise7; // for items, respawn .string noise7; // for items, respawn
// ========================================================================== // // ========================================================================= //
// ========================================================================== // // ========================================================================= //
#if 0 #if 0
// used by QSG engines // used by QSG engines
@ -61,8 +61,8 @@ void() NOTHING_function = {};
.float gravity; // Gravity Multiplier (0 to 1.0) .float gravity; // Gravity Multiplier (0 to 1.0)
.float maxspeed; // Used to set Maxspeed on a player .float maxspeed; // Used to set Maxspeed on a player
// ========================================================================== // // ========================================================================= //
// ========================================================================== // // ========================================================================= //
.float mass; // for projectile collisions .float mass; // for projectile collisions
@ -79,5 +79,5 @@ void() NOTHING_function = {};
.float water_finished; // swim sound .float water_finished; // swim sound
.float pain_finished; // pain sound .float pain_finished; // pain sound
// ========================================================================== // // ========================================================================= //
// ========================================================================== // // ========================================================================= //

View file

@ -7,19 +7,25 @@
.float (vector org) th_teleport; .float (vector org) th_teleport;
void() _deathmsg_teleport = { void ()
_deathmsg_teleport =
{
local string att_nname, def_nname; local string att_nname, def_nname;
def_nname = name (self); def_nname = name (self);
att_nname = name (self.dmg_attacker); att_nname = name (self.dmg_attacker);
if (self.dmg_inflictor.owner == self) if (self.dmg_inflictor.owner == self)
bprint(PRINT_DEATH, "Satan's power deflects ", att_nname, "'s telefrag.\n"); bprint (PRINT_DEATH, "Satan's power deflects ", att_nname,
"'s telefrag.\n");
else else
bprint(PRINT_DEATH, def_nname, " was telefragged by ", att_nname, ".\n"); bprint (PRINT_DEATH, def_nname, " was telefragged by ", att_nname,
".\n");
}; };
void() _teleport_death_touch = { void ()
_teleport_death_touch =
{
if (self.owner == other) if (self.owner == other)
return; return;
@ -33,10 +39,13 @@ void() _teleport_death_touch = {
ghost_inflictor.speed = 1000; ghost_inflictor.speed = 1000;
ghost_inflictor.owner = self.owner; ghost_inflictor.owner = self.owner;
damage(other, self.owner, ghost_inflictor, DAMAGE_SHOULDDIE, _deathmsg_teleport); damage (other, self.owner, ghost_inflictor, DAMAGE_SHOULDDIE,
_deathmsg_teleport);
}; };
void(vector org, entity death_owner) _teleport_death_spawn = { void (vector org, entity death_owner)
_teleport_death_spawn =
{
local entity death; local entity death;
death = spawn ("TELEDEATH"); death = spawn ("TELEDEATH");
@ -53,7 +62,9 @@ void(vector org, entity death_owner) _teleport_death_spawn = {
force_retouch = 2; force_retouch = 2;
}; };
void(entity e, entity spot) teleport = { void (entity e, entity spot)
teleport =
{
local float spd; local float spd;
if (e.th_teleport) { if (e.th_teleport) {

View file

@ -2,11 +2,9 @@
#define TELEPORT_qh 1 #define TELEPORT_qh 1
@extern { @extern {
.float(vector org) th_teleport; .float(vector org) th_teleport;
void (entity e, entity spot) teleport; void (entity e, entity spot) teleport;
}; };
#endif #endif

View file

@ -6,7 +6,9 @@
#include "effect.qh" #include "effect.qh"
void() _w_axe_deathmsg = { void ()
_w_axe_deathmsg =
{
local float r; local float r;
local string att_nname, def_nname; local string att_nname, def_nname;
@ -15,13 +17,22 @@ void() _w_axe_deathmsg = {
def_nname = name (self); def_nname = name (self);
att_nname = name (self.dmg_attacker); att_nname = name (self.dmg_attacker);
if (r < 0.25) bprint(PRINT_DEATH, def_nname, " gets chopped down to size by ", att_nname, ".\n"); if (r < 0.25)
else if (r < 0.5) bprint(PRINT_DEATH, att_nname, " mames ", def_nname, " with a rusty axe.\n"); bprint (PRINT_DEATH, def_nname, " gets chopped down to size by ",
else if (r < 0.75) bprint(PRINT_DEATH, def_nname, " loses his scalp to ", att_nname, ".\n"); att_nname, ".\n");
else bprint(PRINT_DEATH, att_nname, "'s axe penetrates ", def_nname, " straight to the bone.\n"); else if (r < 0.5)
bprint (PRINT_DEATH, att_nname, " mames ", def_nname,
" with a rusty axe.\n");
else if (r < 0.75)
bprint (PRINT_DEATH, def_nname, " loses his scalp to ", att_nname,
".\n");
else
bprint (PRINT_DEATH, att_nname, "'s axe penetrates ", def_nname,
" straight to the bone.\n");
}; };
void() _w_axe_fire = void ()
_w_axe_fire =
{ {
local vector source; local vector source;
@ -39,15 +50,18 @@ void() _w_axe_fire =
damage_attack (ghost_inflictor); damage_attack (ghost_inflictor);
if (!damage(trace_ent, self, ghost_inflictor, ghost_inflictor.dmg, _w_axe_deathmsg)) { if (!damage (trace_ent, self, ghost_inflictor, ghost_inflictor.dmg,
_w_axe_deathmsg)) {
/* We hit the world. */ /* We hit the world. */
sound (self, CHAN_WEAPON, "player/axhit2.wav", 1, ATTN_NORM); sound (self, CHAN_WEAPON, "player/axhit2.wav", 1, ATTN_NORM);
effect_gun_spark (trace_endpos, v_forward * 250, 3); effect_gun_spark (trace_endpos, v_forward * 250, 3);
} }
}; };
void() _w_axe_think_1 = { void ()
self.weaponframe = self.weaponframe + 1; _w_axe_think_1 =
{
self.weaponframe++;
if (self.weaponframe == 3) if (self.weaponframe == 3)
_w_axe_fire(); _w_axe_fire();
if (self.weaponframe <= 1 || self.weaponframe > 4) { if (self.weaponframe <= 1 || self.weaponframe > 4) {
@ -56,8 +70,10 @@ void() _w_axe_think_1 = {
} }
}; };
void() _w_axe_think_2 = { void ()
self.weaponframe = self.weaponframe + 1; _w_axe_think_2 =
{
self.weaponframe++;
if (self.weaponframe == 7) if (self.weaponframe == 7)
_w_axe_fire(); _w_axe_fire();
if (self.weaponframe <= 5 || self.weaponframe > 8) { if (self.weaponframe <= 5 || self.weaponframe > 8) {
@ -68,14 +84,16 @@ void() _w_axe_think_2 = {
/* WEAPON 1 axe */ /* WEAPON 1 axe */
float (float action) float (float action)
w_axe = { w_axe =
if (action == WEAPON_AMMO) { {
switch (action) {
case WEAPON_AMMO:
return 0; return 0;
} else if (action == WEAPON_WEIGHT) { case WEAPON_WEIGHT:
return 1; return 1;
} else if (action == WEAPON_SELECTABLE) { case WEAPON_SELECTABLE:
return TRUE; return TRUE;
} else if (action == WEAPON_FIRE) { case WEAPON_FIRE:
self.attack_finished = time + 0.5; self.attack_finished = time + 0.5;
sound (self, CHAN_WEAPON, "weapons/ax1.wav", 1, ATTN_NORM); sound (self, CHAN_WEAPON, "weapons/ax1.wav", 1, ATTN_NORM);
@ -89,17 +107,19 @@ w_axe = {
self.w_thought = TRUE; self.w_thought = TRUE;
self.mdl_func (MDL_FUNC_FIRE, 0); self.mdl_func (MDL_FUNC_FIRE, 0);
} else if (action == WEAPON_SELECT) { break;
case WEAPON_SELECT:
self.weaponmodel = "progs/v_axe.mdl"; self.weaponmodel = "progs/v_axe.mdl";
self.weaponframe = 0; self.weaponframe = 0;
self.mdl_mod = (self.mdl_mod & ~MDL_MOD_WEP_MASK) | MDL_MOD_WEP_AXE; self.mdl_mod = (self.mdl_mod & ~MDL_MOD_WEP_MASK) | MDL_MOD_WEP_AXE;
weaponprint ("Axe"); weaponprint ("Axe");
} else if (action == WEAPON_INIT) { break;
case WEAPON_INIT:
precache_model ("progs/v_axe.mdl"); precache_model ("progs/v_axe.mdl");
precache_sound ("player/axhit1.wav"); precache_sound ("player/axhit1.wav");
precache_sound ("player/axhit2.wav"); precache_sound ("player/axhit2.wav");
precache_sound ("weapons/ax1.wav"); precache_sound ("weapons/ax1.wav");
break;
} }
return 0; return 0;

View file

@ -1,6 +1,8 @@
#include "common.qh" #include "common.qh"
void() worldspawn = { void ()
worldspawn =
{
/* These are used be the server C code, but not precached. Bad iD. */ /* These are used be the server C code, but not precached. Bad iD. */
precache_sound ("misc/h2ohit1.wav"); precache_sound ("misc/h2ohit1.wav");
precache_sound ("demon/dland2.wav"); precache_sound ("demon/dland2.wav");