mirror of
https://git.code.sf.net/p/quake/game-source
synced 2024-11-10 06:31:52 +00:00
Whitespace, codingstyle, and other QFisms.
This commit is contained in:
parent
12b2ce3787
commit
88fcbcbcfd
34 changed files with 1004 additions and 769 deletions
|
@ -9,7 +9,7 @@ CPP=cpp
|
|||
CPPFLAGS=-I. -Iweapons -Imdl -Iact -Imapents
|
||||
|
||||
QFCC=qfcc
|
||||
QFCCFLAGS=-q --warn all,error --code v6only $(CPPFLAGS)
|
||||
QFCCFLAGS=-q --warn all,error $(CPPFLAGS)
|
||||
|
||||
###############################################
|
||||
|
||||
|
|
|
@ -11,46 +11,53 @@
|
|||
float _bodyque_current;
|
||||
entity bodyque_head;
|
||||
|
||||
void() bodyque_init = {
|
||||
void ()
|
||||
bodyque_init =
|
||||
{
|
||||
local float i;
|
||||
local entity e;
|
||||
|
||||
e = bodyque_head = spawn("BODYQUE");
|
||||
e = bodyque_head = spawn ("BODYQUE");
|
||||
bodyque_head.owner = bodyque_head;
|
||||
for (i = 1; i < CONFIG_BODYQUE_MAX; i = i + 1) {
|
||||
bodyque_head.owner = spawn("BODYQUE");
|
||||
for (i = 1; i < CONFIG_BODYQUE_MAX; i++) {
|
||||
bodyque_head.owner = spawn ("BODYQUE");
|
||||
bodyque_head.owner.chain = bodyque_head;
|
||||
bodyque_head = bodyque_head.owner;
|
||||
}
|
||||
e.chain = bodyque_head;
|
||||
bodyque_head.owner = e;
|
||||
|
||||
precache_sound("zombie/z_miss.wav");
|
||||
precache_sound ("zombie/z_miss.wav");
|
||||
|
||||
precache_sound("player/gib.wav");
|
||||
precache_sound("player/udeath.wav");
|
||||
precache_sound ("player/gib.wav");
|
||||
precache_sound ("player/udeath.wav");
|
||||
};
|
||||
|
||||
void() _bodyque_fade_think = {
|
||||
void ()
|
||||
_bodyque_fade_think =
|
||||
{
|
||||
local vector org;
|
||||
|
||||
if (self.mdl_think) {
|
||||
if (!self.mdl_thought) self.mdl_think();
|
||||
if (!self.mdl_thought)
|
||||
self.mdl_think ();
|
||||
self.mdl_thought = FALSE;
|
||||
}
|
||||
|
||||
org = self.origin;
|
||||
org_z = org_z + self.maxs_z;
|
||||
if (pointcontents(org) == CONTENT_SOLID) {
|
||||
if (pointcontents (org) == CONTENT_SOLID) {
|
||||
_bodyque_current = _bodyque_current - 1;
|
||||
remove(self);
|
||||
remove (self);
|
||||
return;
|
||||
}
|
||||
|
||||
self.nextthink = time + 0.1;
|
||||
};
|
||||
|
||||
void() _bodyque_fade_from_reality = {
|
||||
void ()
|
||||
_bodyque_fade_from_reality =
|
||||
{
|
||||
local entity new_bodyque;
|
||||
|
||||
if (_bodyque_current >= CONFIG_BODYQUE_FADE_MAX)
|
||||
|
@ -81,20 +88,25 @@ void() _bodyque_fade_from_reality = {
|
|||
_bodyque_current = _bodyque_current + 1;
|
||||
};
|
||||
|
||||
void() _bodyque_think = {
|
||||
void ()
|
||||
_bodyque_think =
|
||||
{
|
||||
if (self.mdl_think) {
|
||||
if (!self.mdl_thought) self.mdl_think();
|
||||
if (!self.mdl_thought)
|
||||
self.mdl_think ();
|
||||
self.mdl_thought = FALSE;
|
||||
}
|
||||
|
||||
self.nextthink = time + 0.1;
|
||||
};
|
||||
|
||||
entity(entity body) bodyque_que = {
|
||||
entity (entity body)
|
||||
bodyque_que =
|
||||
{
|
||||
local entity ret;
|
||||
|
||||
if (bodyque_head.count)
|
||||
_bodyque_fade_from_reality();
|
||||
_bodyque_fade_from_reality ();
|
||||
|
||||
ret = bodyque_head;
|
||||
|
||||
|
|
|
@ -2,10 +2,8 @@
|
|||
#define BODYQUE_qh 1
|
||||
|
||||
@extern {
|
||||
|
||||
void() bodyque_init;
|
||||
entity(entity body) bodyque_que;
|
||||
|
||||
void () bodyque_init;
|
||||
entity (entity body) bodyque_que;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
176
klik/client.qc
176
klik/client.qc
|
@ -22,36 +22,44 @@
|
|||
|
||||
#include "teleport.qh"
|
||||
|
||||
void() client_init = {
|
||||
precache_model("progs/player.mdl");
|
||||
precache_model("progs/eyes.mdl");
|
||||
void ()
|
||||
client_init =
|
||||
{
|
||||
precache_model ("progs/player.mdl");
|
||||
precache_model ("progs/eyes.mdl");
|
||||
};
|
||||
|
||||
// This is the first function called by C code for a new player.
|
||||
void() SetNewParms = {
|
||||
void ()
|
||||
SetNewParms =
|
||||
{
|
||||
parm1 = CONFIG_START_CURRENCY;
|
||||
|
||||
parm2 = parm3 = parm4 = parm5 = 0;
|
||||
|
||||
parm6 = CONFIG_START_HEALTH + CONFIG_START_ARMOR*999;
|
||||
parm6 = CONFIG_START_HEALTH + CONFIG_START_ARMOR * 999;
|
||||
parm7 = CONFIG_START_ARMOR_TYPE;
|
||||
parm8 = CONFIG_MAX_HEALTH + CONFIG_MAX_ARMOR*999;
|
||||
parm8 = CONFIG_MAX_HEALTH + CONFIG_MAX_ARMOR * 999;
|
||||
|
||||
parm9 = CONFIG_START_SHELLS + CONFIG_START_NAILS*999;
|
||||
parm10 = CONFIG_START_ROCKETS + CONFIG_START_CELLS*999;
|
||||
parm11 = CONFIG_MAX_SHELLS + CONFIG_MAX_NAILS*999;
|
||||
parm12 = CONFIG_MAX_ROCKETS + CONFIG_MAX_CELLS*999;
|
||||
parm9 = CONFIG_START_SHELLS + CONFIG_START_NAILS * 999;
|
||||
parm10 = CONFIG_START_ROCKETS + CONFIG_START_CELLS * 999;
|
||||
parm11 = CONFIG_MAX_SHELLS + CONFIG_MAX_NAILS * 999;
|
||||
parm12 = CONFIG_MAX_ROCKETS + CONFIG_MAX_CELLS * 999;
|
||||
|
||||
parm15 = weapon_player_parm1_default();
|
||||
parm15 = weapon_player_parm1_default ();
|
||||
parm16 = EQUIP_STATE_CHOOSE;
|
||||
};
|
||||
|
||||
void() SetDeadParms = {
|
||||
void ()
|
||||
SetDeadParms =
|
||||
{
|
||||
SetNewParms();
|
||||
};
|
||||
|
||||
// Called when about to change maps
|
||||
void() SetChangeParms = {
|
||||
void ()
|
||||
SetChangeParms =
|
||||
{
|
||||
/* Currency */
|
||||
parm1 = self.currency;
|
||||
|
||||
|
@ -62,28 +70,31 @@ void() SetChangeParms = {
|
|||
parm5 = self.itemfield_4;
|
||||
|
||||
/* 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;
|
||||
parm8 = self.max_health + self.max_armor*999;
|
||||
parm8 = self.max_health + self.max_armor * 999;
|
||||
|
||||
/* Ammo */
|
||||
parm9 = self.ammo_shells + self.ammo_nails*999;
|
||||
parm10 = self.ammo_rockets + self.ammo_cells*999;
|
||||
parm11 = self.max_ammo_shells + self.max_ammo_nails*999;
|
||||
parm12 = self.max_ammo_rockets + self.max_ammo_cells*999;
|
||||
parm9 = self.ammo_shells + self.ammo_nails * 999;
|
||||
parm10 = self.ammo_rockets + self.ammo_cells * 999;
|
||||
parm11 = self.max_ammo_shells + self.max_ammo_nails * 999;
|
||||
parm12 = self.max_ammo_rockets + self.max_ammo_cells * 999;
|
||||
|
||||
/* Wheeee */
|
||||
parm15 = weapon_player_parm1();
|
||||
parm15 = weapon_player_parm1 ();
|
||||
parm16 = self.equip_state;
|
||||
|
||||
/* H4x0r */
|
||||
if (self.deadflag)
|
||||
SetDeadParms();
|
||||
SetDeadParms ();
|
||||
};
|
||||
|
||||
void() DecodeParms = {
|
||||
void ()
|
||||
DecodeParms =
|
||||
{
|
||||
/* Currency */
|
||||
self.currency = parm1;
|
||||
|
||||
|
@ -96,52 +107,56 @@ void() DecodeParms = {
|
|||
equip_grant(self, EQUIPID_SHOTGUN);
|
||||
|
||||
/* Health and such */
|
||||
self.armorvalue = floor(parm6 / 999);
|
||||
self.armorvalue = floor (parm6 / 999);
|
||||
self.armortype = parm7;
|
||||
|
||||
self.health = parm6 - self.armorvalue*999;
|
||||
self.health = parm6 - self.armorvalue * 999;
|
||||
|
||||
self.max_armor = floor(parm8 / 999);
|
||||
self.max_health = parm8 - self.max_armor*999;
|
||||
self.max_armor = floor (parm8 / 999);
|
||||
self.max_health = parm8 - self.max_armor * 999;
|
||||
|
||||
/* Ammo */
|
||||
self.ammo_nails = floor(parm9 / 999);
|
||||
self.ammo_shells = parm9 - self.ammo_nails*999;
|
||||
self.ammo_nails = floor (parm9 / 999);
|
||||
self.ammo_shells = parm9 - self.ammo_nails * 999;
|
||||
|
||||
self.ammo_rockets = floor(parm10 / 999);
|
||||
self.ammo_cells = parm10 - self.ammo_rockets*999;
|
||||
self.ammo_rockets = floor (parm10 / 999);
|
||||
self.ammo_cells = parm10 - self.ammo_rockets * 999;
|
||||
|
||||
self.max_ammo_nails = floor(parm11 / 999);
|
||||
self.max_ammo_shells = parm11 - self.max_ammo_nails*999;
|
||||
self.max_ammo_nails = floor (parm11 / 999);
|
||||
self.max_ammo_shells = parm11 - self.max_ammo_nails * 999;
|
||||
|
||||
self.max_ammo_rockets = floor(parm12 / 999);
|
||||
self.max_ammo_cells = parm12 - self.max_ammo_rockets*999;
|
||||
self.max_ammo_rockets = floor (parm12 / 999);
|
||||
self.max_ammo_cells = parm12 - self.max_ammo_rockets * 999;
|
||||
|
||||
/* Wheeee */
|
||||
weapon_player_parm1_decode(parm15);
|
||||
weapon_player_parm1_decode (parm15);
|
||||
self.equip_state = parm16;
|
||||
|
||||
SetDeadParms();
|
||||
SetDeadParms ();
|
||||
};
|
||||
|
||||
void() RemoveClientFromGame = {
|
||||
void ()
|
||||
RemoveClientFromGame =
|
||||
{
|
||||
self.classname = "player_outofgame";
|
||||
mdl_setup_void();
|
||||
act_setup_dead();
|
||||
mdl_setup_void ();
|
||||
act_setup_dead ();
|
||||
};
|
||||
|
||||
void() PutClientInGame = {
|
||||
void ()
|
||||
PutClientInGame =
|
||||
{
|
||||
local entity ent;
|
||||
local float spawncount;
|
||||
|
||||
menu_set(NOTHING_function);
|
||||
menu_set (NOTHING_function);
|
||||
|
||||
self.classname = "player";
|
||||
|
||||
DecodeParms();
|
||||
DecodeParms ();
|
||||
|
||||
mdl_setup_player();
|
||||
act_setup_player();
|
||||
mdl_setup_player ();
|
||||
act_setup_player ();
|
||||
|
||||
self.velocity = '0 0 0';
|
||||
self.flags &= ~FL_INWATER;
|
||||
|
@ -151,8 +166,8 @@ void() PutClientInGame = {
|
|||
|
||||
/* Select a spawn point.. */
|
||||
for (spawncount = 5; spawncount > 0; spawncount--) {
|
||||
spawn_head = random_enemy_chain(spawn_head);
|
||||
ent = findradius(spawn_head.origin, 100);
|
||||
spawn_head = random_enemy_chain (spawn_head);
|
||||
ent = findradius (spawn_head.origin, 100);
|
||||
while (ent) {
|
||||
if (ent.classname == "player")
|
||||
break;
|
||||
|
@ -163,70 +178,87 @@ void() PutClientInGame = {
|
|||
break;
|
||||
}
|
||||
|
||||
teleport(self, spawn_head);
|
||||
teleport (self, spawn_head);
|
||||
};
|
||||
|
||||
// Called right after ClientConnect, and on new maps.
|
||||
void() PutClientInServer = {
|
||||
void ()
|
||||
PutClientInServer =
|
||||
{
|
||||
local entity spot;
|
||||
|
||||
/* Hack to get pmodel for servers that check it */
|
||||
self.model = "progs/player.mdl";
|
||||
self.modelindex = 0;
|
||||
|
||||
intermission_head = spot = random_enemy_chain(intermission_head);
|
||||
intermission_head = spot = random_enemy_chain (intermission_head);
|
||||
self.origin = spot.origin;
|
||||
self.angles = spot.angles;
|
||||
self.fixangle = TRUE;
|
||||
|
||||
self.velocity = '0 0 0';
|
||||
|
||||
weapon_player_init();
|
||||
weapon_player_init ();
|
||||
|
||||
menu_set(menu_intro);
|
||||
menu_set (menu_intro);
|
||||
|
||||
RemoveClientFromGame();
|
||||
RemoveClientFromGame ();
|
||||
};
|
||||
|
||||
void() _deathmsg_suicide = {
|
||||
void ()
|
||||
_deathmsg_suicide =
|
||||
{
|
||||
local float r;
|
||||
local string nname;
|
||||
|
||||
nname = name(self);
|
||||
nname = name (self);
|
||||
|
||||
r = random();
|
||||
if (r < 0.25) bprint(PRINT_DEATH, nname, " says good bye to this cruel world.\n");
|
||||
else if (r < 0.5) 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");
|
||||
if (r < 0.25)
|
||||
bprint (PRINT_DEATH, nname, " says good bye to this cruel world.\n");
|
||||
else if (r < 0.5)
|
||||
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.
|
||||
void()
|
||||
void ()
|
||||
ClientKill = {
|
||||
damage(self, self, self, DAMAGE_MUSTDIE, _deathmsg_suicide);
|
||||
damage (self, self, self, DAMAGE_MUSTDIE, _deathmsg_suicide);
|
||||
};
|
||||
|
||||
void() _client_th_kill = {
|
||||
if (other == self) self.frags--;
|
||||
else self.frags++;
|
||||
logfrag(self, other);
|
||||
void ()
|
||||
_client_th_kill =
|
||||
{
|
||||
if (other == self)
|
||||
self.frags--;
|
||||
else
|
||||
self.frags++;
|
||||
logfrag (self, other);
|
||||
};
|
||||
|
||||
// Called after the client is fully connected
|
||||
void() ClientConnect = {
|
||||
bprint(PRINT_HIGH, name(self), " connected\n");
|
||||
void ()
|
||||
ClientConnect = {
|
||||
bprint (PRINT_HIGH, name (self), " connected\n");
|
||||
self.flags |= FL_CLIENT;
|
||||
|
||||
override_set_th_kill(self, _client_th_kill);
|
||||
override_set_th_kill (self, _client_th_kill);
|
||||
};
|
||||
|
||||
// Called when the client disconnects
|
||||
void() ClientDisconnect = {
|
||||
void ()
|
||||
ClientDisconnect =
|
||||
{
|
||||
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;
|
||||
damage(self, self, self, DAMAGE_MUSTDIE, NOTHING_function);
|
||||
damage (self, self, self, DAMAGE_MUSTDIE, NOTHING_function);
|
||||
};
|
||||
|
|
|
@ -2,15 +2,13 @@
|
|||
#define CLIENT_qh 1
|
||||
|
||||
@extern {
|
||||
void () client_init;
|
||||
|
||||
void() client_init;
|
||||
|
||||
void() RemoveClientFromGame;
|
||||
void() PutClientInGame;
|
||||
|
||||
void() ClientConnect;
|
||||
void() ClientDisconnect;
|
||||
void () RemoveClientFromGame;
|
||||
void () PutClientInGame;
|
||||
|
||||
void () ClientConnect;
|
||||
void () ClientDisconnect;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
151
klik/damage.qc
151
klik/damage.qc
|
@ -7,33 +7,37 @@
|
|||
|
||||
.entity dmg_attacker;
|
||||
|
||||
.void() deathmsg;
|
||||
.void () deathmsg;
|
||||
.string deathmsg1, deathmsg2, deathmsg3, deathmsg4, deathmsg5, deathmsg6;
|
||||
|
||||
// You _MUST_ have th_takedamage if you .takedamage!
|
||||
// Return TRUE if you were damaged, FALSE otherwise.
|
||||
.float(float dmg) th_takedamage;
|
||||
.float (float dmg) th_takedamage;
|
||||
|
||||
/* Allows you to globally override damage you deal */
|
||||
/* self = you, other = target */
|
||||
/* returns new amount of damage, or < 0 for don't */
|
||||
.float(float dmg) th_dealdamage;
|
||||
.float (float dmg) th_dealdamage;
|
||||
|
||||
.void(entity missile) th_attack;
|
||||
.void (entity missile) th_attack;
|
||||
|
||||
/* Update frags in these. */
|
||||
.void() th_die;
|
||||
.void() th_kill;
|
||||
.void () th_die;
|
||||
.void () th_kill;
|
||||
|
||||
.float(entity missile) th_projectile;
|
||||
.float (entity missile) th_projectile;
|
||||
|
||||
entity ghost_inflictor;
|
||||
|
||||
void() damage_init = {
|
||||
ghost_inflictor = spawn("GHOST_INFLICTOR");
|
||||
void ()
|
||||
damage_init =
|
||||
{
|
||||
ghost_inflictor = spawn ("GHOST_INFLICTOR");
|
||||
};
|
||||
|
||||
void(entity from, entity to) deathmsg_copy = {
|
||||
void (entity from, entity to)
|
||||
deathmsg_copy =
|
||||
{
|
||||
to.deathmsg1 = from.deathmsg1;
|
||||
to.deathmsg2 = from.deathmsg2;
|
||||
to.deathmsg3 = from.deathmsg3;
|
||||
|
@ -42,42 +46,56 @@ void(entity from, entity to) deathmsg_copy = {
|
|||
to.deathmsg6 = from.deathmsg6;
|
||||
};
|
||||
|
||||
string(entity e, string s) _deathmsg_custom_str = {
|
||||
if (s == "name(self)") return name(self);
|
||||
if (s == "name(attacker)") return name(self.dmg_attacker);
|
||||
if (s == "name(inflictor)") return name(self.dmg_inflictor);
|
||||
string (entity e, string s) _deathmsg_custom_str = {
|
||||
if (s == "name(self)")
|
||||
return name(self);
|
||||
if (s == "name(attacker)")
|
||||
return name (self.dmg_attacker);
|
||||
if (s == "name(inflictor)")
|
||||
return name (self.dmg_inflictor);
|
||||
return s;
|
||||
};
|
||||
|
||||
void() _deathmsg_custom = {
|
||||
void ()
|
||||
_deathmsg_custom =
|
||||
{
|
||||
local string s1, s2, s3, s4, s5, s6;
|
||||
|
||||
s1 = s2 = s3 = s4 = s5 = s6 = "";
|
||||
|
||||
s1 = _deathmsg_custom_str(self, self.deathmsg1);
|
||||
if (s1) s2 = _deathmsg_custom_str(self, self.deathmsg2);
|
||||
if (s2) s3 = _deathmsg_custom_str(self, self.deathmsg3);
|
||||
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);
|
||||
s1 = _deathmsg_custom_str (self, self.deathmsg1);
|
||||
if (s1)
|
||||
s2 = _deathmsg_custom_str (self, self.deathmsg2);
|
||||
if (s2)
|
||||
s3 = _deathmsg_custom_str (self, self.deathmsg3);
|
||||
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
|
||||
// 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 = {
|
||||
//XXX refcount_dec(self.dmg_attacker);
|
||||
//XXX refcount_dec(self.dmg_inflictor);
|
||||
void ()
|
||||
deathmsg_nodisplay =
|
||||
{
|
||||
// refcount_dec (self.dmg_attacker);
|
||||
// refcount_dec (self.dmg_inflictor);
|
||||
self.dmg_attacker = world;
|
||||
self.dmg_inflictor = world;
|
||||
|
||||
self.deathmsg = NOTHING_function;
|
||||
};
|
||||
|
||||
void() deathmsg_display = {
|
||||
void ()
|
||||
deathmsg_display =
|
||||
{
|
||||
if (self.th_die)
|
||||
self.th_die();
|
||||
self.th_die ();
|
||||
|
||||
if (other.th_kill) {
|
||||
local entity oldself, oldother;
|
||||
|
@ -88,17 +106,18 @@ void() deathmsg_display = {
|
|||
self = oldother;
|
||||
other = oldself;
|
||||
|
||||
self.th_kill();
|
||||
self.th_kill ();
|
||||
|
||||
self = oldself;
|
||||
other = oldother;
|
||||
}
|
||||
|
||||
self.deathmsg();
|
||||
deathmsg_nodisplay();
|
||||
self.deathmsg ();
|
||||
deathmsg_nodisplay ();
|
||||
};
|
||||
|
||||
float(float d) damage_armor = {
|
||||
float (float d)
|
||||
damage_armor = {
|
||||
local float adamg, rest;
|
||||
|
||||
adamg = d * self.armortype;
|
||||
|
@ -116,20 +135,22 @@ float(float d) damage_armor = {
|
|||
return rest;
|
||||
};
|
||||
|
||||
void(float d) damage_push = {
|
||||
void (float d)
|
||||
damage_push =
|
||||
{
|
||||
local vector vel;
|
||||
|
||||
if (self.mass == 0) {
|
||||
d = 0;
|
||||
} else {
|
||||
if (self.dmg_attacker == self)
|
||||
d = (self.dmg_inflictor.mass + d*rocket_jump) / self.mass;
|
||||
d = (self.dmg_inflictor.mass + d * rocket_jump) / self.mass;
|
||||
else
|
||||
d = self.dmg_inflictor.mass / self.mass;
|
||||
}
|
||||
|
||||
if (self.dmg_inflictor.velocity == '0 0 0') {
|
||||
vel = normalize(self.origin - self.dmg_inflictor.origin);
|
||||
vel = normalize (self.origin - self.dmg_inflictor.origin);
|
||||
vel *= self.dmg_inflictor.speed;
|
||||
} else {
|
||||
vel = self.dmg_inflictor.velocity;
|
||||
|
@ -139,8 +160,10 @@ void(float d) damage_push = {
|
|||
};
|
||||
|
||||
// deathmessage _IS_ overridden if inflictor.deathmsg1
|
||||
float(entity ent, entity attacker, entity inflictor, float d, void() deathmessage)
|
||||
damage = {
|
||||
float (entity ent, entity attacker, entity inflictor, float d,
|
||||
void() deathmessage)
|
||||
damage =
|
||||
{
|
||||
local entity oldself, oldother;
|
||||
local float wasdamaged;
|
||||
|
||||
|
@ -153,8 +176,8 @@ damage = {
|
|||
ent.dmg_attacker = attacker;
|
||||
ent.dmg_inflictor = inflictor;
|
||||
|
||||
//XXX refcount_inc(ent.dmg_attacker);
|
||||
//XXX refcount_inc(ent.dmg_inflictor);
|
||||
// refcount_inc (ent.dmg_attacker);
|
||||
// refcount_inc (ent.dmg_inflictor);
|
||||
|
||||
if (inflictor.deathmsg1)
|
||||
ent.deathmsg = _deathmsg_custom;
|
||||
|
@ -170,7 +193,8 @@ damage = {
|
|||
self = oldself;
|
||||
other = oldother;
|
||||
|
||||
if (d < 0) return FALSE;
|
||||
if (d < 0)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
self = ent;
|
||||
|
@ -184,52 +208,59 @@ damage = {
|
|||
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) {
|
||||
traceline(org, center(e), TRUE, world);
|
||||
traceline (org, center (e), TRUE, world);
|
||||
|
||||
if (trace_fraction == 1 || trace_ent == e)
|
||||
return TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
traceline(org, e.origin, TRUE, self);
|
||||
if (trace_fraction == 1) return TRUE;
|
||||
traceline(org, e.origin + '15 15 0', TRUE, self);
|
||||
if (trace_fraction == 1) return TRUE;
|
||||
traceline(org, e.origin + '15 -15 0', TRUE, self);
|
||||
if (trace_fraction == 1) return TRUE;
|
||||
traceline(org, e.origin + '-15 15 0', TRUE, self);
|
||||
if (trace_fraction == 1) return TRUE;
|
||||
traceline(org, e.origin + '-15 -15 0', TRUE, self);
|
||||
if (trace_fraction == 1) return TRUE;
|
||||
traceline (org, e.origin, TRUE, self);
|
||||
if (trace_fraction == 1)
|
||||
return TRUE;
|
||||
traceline (org, e.origin + '15 15 0', TRUE, self);
|
||||
if (trace_fraction == 1)
|
||||
return TRUE;
|
||||
traceline (org, e.origin + '15 -15 0', TRUE, self);
|
||||
if (trace_fraction == 1)
|
||||
return TRUE;
|
||||
traceline (org, e.origin + '-15 15 0', TRUE, self);
|
||||
if (trace_fraction == 1)
|
||||
return TRUE;
|
||||
traceline (org, e.origin + '-15 -15 0', TRUE, self);
|
||||
if (trace_fraction == 1)
|
||||
return TRUE;
|
||||
|
||||
return FALSE;
|
||||
};
|
||||
|
||||
void(entity ignore, entity attacker, entity inflictor, void() deathmessage)
|
||||
damage_radius = {
|
||||
void (entity ignore, entity attacker, entity inflictor, void () deathmessage)
|
||||
damage_radius =
|
||||
{
|
||||
local entity head;
|
||||
local vector iorg, org;
|
||||
local float points;
|
||||
local float d, m, r;
|
||||
local float points, d, m, r;
|
||||
|
||||
d = inflictor.dmg;
|
||||
m = inflictor.mass;
|
||||
r = inflictor.lip;
|
||||
|
||||
iorg = center(inflictor);
|
||||
iorg = center (inflictor);
|
||||
|
||||
for (head = findradius(iorg, r + 40); head; head = head.chain) {
|
||||
for (head = findradius (iorg, r + 40); head; head = head.chain) {
|
||||
if (head == ignore)
|
||||
continue;
|
||||
|
||||
if (!_damage_radius_can_hit(iorg, head))
|
||||
if (!_damage_radius_can_hit (iorg, head))
|
||||
continue;
|
||||
|
||||
org = center(head);
|
||||
|
||||
points = r - (0.5 * vlen(iorg - org));
|
||||
points = r - (0.5 * vlen (iorg - org));
|
||||
if (points <= 0)
|
||||
continue;
|
||||
|
||||
|
@ -239,6 +270,6 @@ damage_radius = {
|
|||
inflictor.dmg = (points * d) / r;
|
||||
inflictor.mass = (points * m) / r;
|
||||
|
||||
damage(head, attacker, inflictor, inflictor.dmg, deathmessage);
|
||||
damage (head, attacker, inflictor, inflictor.dmg, deathmessage);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -2,35 +2,34 @@
|
|||
#define DAMAGE_qh 1
|
||||
|
||||
@extern {
|
||||
|
||||
#define DAMAGE_SHOULDDIE 16777214
|
||||
#define DAMAGE_MUSTDIE 16777215
|
||||
|
||||
.entity dmg_attacker;
|
||||
|
||||
.void() deathmsg;
|
||||
.void () deathmsg;
|
||||
.string deathmsg1, deathmsg2, deathmsg3, deathmsg4, deathmsg5, deathmsg6;
|
||||
|
||||
// You _MUST_ have th_takedamage if you .takedamage!
|
||||
// Return TRUE if you were damaged, FALSE otherwise.
|
||||
.float(float dmg) th_takedamage;
|
||||
.float (float dmg) th_takedamage;
|
||||
|
||||
/* Allows you to globally override damage you deal */
|
||||
/* self = you, other = target */
|
||||
/* returns new amount of damage, or < 0 for don't */
|
||||
.float(float dmg) th_dealdamage;
|
||||
.float (float dmg) th_dealdamage;
|
||||
|
||||
/* Use this when you attack something. It may modify missile. */
|
||||
/* You should have at least classname, velocity, dmg, and mass */
|
||||
#define damage_attack(missile) do{ if (self.th_attack) self.th_attack(missile); }while(0)
|
||||
#define damage_attack(missile) do { if (self.th_attack) self.th_attack (missile); } while (0)
|
||||
|
||||
.void(entity missile) th_attack;
|
||||
.void (entity missile) th_attack;
|
||||
|
||||
/* Update frags in these. */
|
||||
.void() th_die;
|
||||
.void() th_kill;
|
||||
.void () th_die;
|
||||
.void () th_kill;
|
||||
|
||||
.float(entity missile) th_projectile;
|
||||
.float (entity missile) th_projectile;
|
||||
|
||||
/* ghost_inflictor is for radius and bullets...
|
||||
Only guaranteed to have:
|
||||
|
@ -40,21 +39,20 @@
|
|||
*/
|
||||
entity ghost_inflictor;
|
||||
|
||||
void() damage_init;
|
||||
void () damage_init;
|
||||
|
||||
void(entity from, entity to) deathmsg_copy;
|
||||
void() deathmsg_display;
|
||||
void() deathmsg_nodisplay;
|
||||
void (entity from, entity to) deathmsg_copy;
|
||||
void () deathmsg_display;
|
||||
void () deathmsg_nodisplay;
|
||||
|
||||
float(float d) damage_armor;
|
||||
void(float d) damage_push;
|
||||
float(entity ent, entity attacker, entity inflictor, float d, void() deathmessage) damage;
|
||||
float (float d) damage_armor;
|
||||
void (float d) damage_push;
|
||||
float (entity ent, entity attacker, entity inflictor, float d, void () deathmessage) damage;
|
||||
|
||||
/* Fill in appropriate fields, inflictor _WILL_ be modified. */
|
||||
void(entity ignore, entity attacker, entity inflictor, void() deathmessage) damage_radius;
|
||||
|
||||
float(vector org, entity e) _damage_radius_can_hit;
|
||||
void (entity ignore, entity attacker, entity inflictor, void () deathmessage) damage_radius;
|
||||
|
||||
float (vector org, entity e) _damage_radius_can_hit;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
#include "common.qh"
|
||||
#include "debug.qh"
|
||||
|
||||
void() debug_impulse = {
|
||||
void ()
|
||||
debug_impulse =
|
||||
{
|
||||
local float imp;
|
||||
|
||||
imp = self.impulse;
|
||||
self.impulse = 0;
|
||||
|
||||
{
|
||||
self.impulse = imp;
|
||||
}
|
||||
|
|
|
@ -2,9 +2,7 @@
|
|||
#define DEBUG_qh 1
|
||||
|
||||
@extern {
|
||||
|
||||
void() debug_impulse;
|
||||
|
||||
void () debug_impulse;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
82
klik/defs.qh
82
klik/defs.qh
|
@ -14,37 +14,37 @@
|
|||
// edict.flags
|
||||
#define FL_FLY 1
|
||||
#define FL_SWIM 2
|
||||
#define FL_CLIENT 8 /* set for all client edicts */
|
||||
#define FL_INWATER 16 /* for enter / leave water splash */
|
||||
#define FL_CLIENT 8 /* set for all client edicts */
|
||||
#define FL_INWATER 16 /* for enter / leave water splash */
|
||||
#define FL_MONSTER 32
|
||||
#define FL_GODMODE 64 /* player cheat */
|
||||
#define FL_NOTARGET 128 /* player cheat */
|
||||
#define FL_ITEM 256 /* extra wide size for bonus items */
|
||||
#define FL_ONGROUND 512 /* standing on something */
|
||||
#define FL_PARTIALGROUND 1024 /* not all corners are valid */
|
||||
#define FL_WATERJUMP 2048 /* player jumping out of water */
|
||||
#define FL_JUMPRELEASED 4096 /* for jump debouncing */
|
||||
#define FL_GODMODE 64 /* player cheat */
|
||||
#define FL_NOTARGET 128 /* player cheat */
|
||||
#define FL_ITEM 256 /* extra wide size for bonus items */
|
||||
#define FL_ONGROUND 512 /* standing on something */
|
||||
#define FL_PARTIALGROUND 1024 /* not all corners are valid */
|
||||
#define FL_WATERJUMP 2048 /* player jumping out of water */
|
||||
#define FL_JUMPRELEASED 4096 /* for jump debouncing */
|
||||
|
||||
// edict.movetype values
|
||||
#define MOVETYPE_NONE 0 /* never moves */
|
||||
#define MOVETYPE_NONE 0 /* never moves */
|
||||
#define MOVETYPE_ANGLENOCLIP 1 /* NO LONGER SUPPORTED. */
|
||||
#define MOVETYPE_ANGLECLIP 2 /* NO LONGER SUPPORTED. */
|
||||
#define MOVETYPE_WALK 3 /* players only */
|
||||
#define MOVETYPE_STEP 4 /* discrete, not real time unless fall */
|
||||
#define MOVETYPE_WALK 3 /* players only */
|
||||
#define MOVETYPE_STEP 4 /* discrete, not real time unless fall */
|
||||
#define MOVETYPE_FLY 5
|
||||
#define MOVETYPE_TOSS 6 /* gravity */
|
||||
#define MOVETYPE_PUSH 7 /* no clip to world, push and crush */
|
||||
#define MOVETYPE_TOSS 6 /* gravity */
|
||||
#define MOVETYPE_PUSH 7 /* no clip to world, push and crush */
|
||||
#define MOVETYPE_NOCLIP 8
|
||||
#define MOVETYPE_FLYMISSILE 9 /* fly with extra size against monsters */
|
||||
#define MOVETYPE_FLYMISSILE 9 /* fly with extra size against monsters */
|
||||
#define MOVETYPE_BOUNCE 10
|
||||
#define MOVETYPE_BOUNCEMISSILE 11 /* bounce with extra size */
|
||||
#define MOVETYPE_BOUNCEMISSILE 11 /* bounce with extra size */
|
||||
|
||||
// edict.solid values
|
||||
#define SOLID_NOT 0 /* no interaction with other objects */
|
||||
#define SOLID_TRIGGER 1 /* touch on edge, but not blocking */
|
||||
#define SOLID_BBOX 2 /* touch on edge, block */
|
||||
#define SOLID_SLIDEBOX 3 /* touch on edge, but not an onground */
|
||||
#define SOLID_BSP 4 /* bsp clip, touch on edge, block */
|
||||
#define SOLID_NOT 0 /* no interaction with other objects */
|
||||
#define SOLID_TRIGGER 1 /* touch on edge, but not blocking */
|
||||
#define SOLID_BBOX 2 /* touch on edge, block */
|
||||
#define SOLID_SLIDEBOX 3 /* touch on edge, but not an onground */
|
||||
#define SOLID_BSP 4 /* bsp clip, touch on edge, block */
|
||||
|
||||
// items
|
||||
#define IT_AXE 4096
|
||||
|
@ -99,7 +99,7 @@
|
|||
#define CHAN_VOICE 2
|
||||
#define CHAN_ITEM 3
|
||||
#define CHAN_BODY 4
|
||||
#define CHAN_NO_PHS_ADD 8 /* ie: CHAN_BODY | CHAN_NO_PHS_ADD */
|
||||
#define CHAN_NO_PHS_ADD 8 /* ie: CHAN_BODY | CHAN_NO_PHS_ADD */
|
||||
|
||||
#define ATTN_NONE 0
|
||||
#define ATTN_NORM 1
|
||||
|
@ -114,33 +114,33 @@
|
|||
#define EF_FLAG1 16
|
||||
#define EF_FLAG2 32
|
||||
// GLQuakeWorld Stuff
|
||||
#define EF_BLUE 64 /* Blue Globe effect for Quad */
|
||||
#define EF_RED 128 /* Red Globe effect for Pentagram */
|
||||
#define EF_BLUE 64 /* Blue Globe effect for Quad */
|
||||
#define EF_RED 128 /* Red Globe effect for Pentagram */
|
||||
|
||||
// messages
|
||||
#define MSG_BROADCAST 0 /* unreliable to all */
|
||||
#define MSG_ONE 1 /* reliable to one (msg_entity) */
|
||||
#define MSG_ALL 2 /* reliable to all */
|
||||
#define MSG_INIT 3 /* write to the init string */
|
||||
#define MSG_MULTICAST 4 /* for multicast() call */
|
||||
#define MSG_BROADCAST 0 /* unreliable to all */
|
||||
#define MSG_ONE 1 /* reliable to one (msg_entity) */
|
||||
#define MSG_ALL 2 /* reliable to all */
|
||||
#define MSG_INIT 3 /* write to the init string */
|
||||
#define MSG_MULTICAST 4 /* for multicast () call */
|
||||
|
||||
// message levels
|
||||
#define PRINT_LOW 0 /* pickup messages */
|
||||
#define PRINT_LOW 0 /* pickup messages */
|
||||
#define PRINT_MEDIUM 1
|
||||
#define PRINT_DEATH 1 /* death messages */
|
||||
#define PRINT_HIGH 2 /* critical messages */
|
||||
#define PRINT_CHAT 3 /* also goes to chat console */
|
||||
#define PRINT_DEATH 1 /* death messages */
|
||||
#define PRINT_HIGH 2 /* critical messages */
|
||||
#define PRINT_CHAT 3 /* also goes to chat console */
|
||||
|
||||
// multicast sets
|
||||
#define MULTICAST_ALL 0 /* every client */
|
||||
#define MULTICAST_PHS 1 /* within hearing */
|
||||
#define MULTICAST_PVS 2 /* within sight */
|
||||
#define MULTICAST_ALL_R 3 /* every client, reliable */
|
||||
#define MULTICAST_PHS_R 4 /* within hearing, reliable */
|
||||
#define MULTICAST_PVS_R 5 /* within sight, reliable */
|
||||
#define MULTICAST_ALL 0 /* every client */
|
||||
#define MULTICAST_PHS 1 /* within hearing */
|
||||
#define MULTICAST_PVS 2 /* within sight */
|
||||
#define MULTICAST_ALL_R 3 /* every client, reliable */
|
||||
#define MULTICAST_PHS_R 4 /* within hearing, reliable */
|
||||
#define MULTICAST_PVS_R 5 /* within sight, reliable */
|
||||
|
||||
// ========================================================================== //
|
||||
// ========================================================================== //
|
||||
// ========================================================================= //
|
||||
// ========================================================================= //
|
||||
|
||||
// takedamage values
|
||||
#define DAMAGE_NO 0
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
.float delay_time, delay_last_change;
|
||||
|
||||
#define all_func(func) \
|
||||
void() func##_all = { \
|
||||
void () func##_all = { \
|
||||
local entity oldself; \
|
||||
local float i; \
|
||||
\
|
||||
|
@ -22,19 +22,17 @@ void() func##_all = { \
|
|||
\
|
||||
self = world; \
|
||||
for (i = 0; i < max_clients; i++) { \
|
||||
self = nextent(self); \
|
||||
self = nextent (self); \
|
||||
\
|
||||
if (!is_cl(self)) \
|
||||
if (!is_cl (self)) \
|
||||
continue; \
|
||||
\
|
||||
func(); \
|
||||
func (); \
|
||||
} \
|
||||
\
|
||||
self = oldself; \
|
||||
}
|
||||
|
||||
|
||||
|
||||
#define do_fields() \
|
||||
do_(health); \
|
||||
do_(armorvalue); \
|
||||
|
@ -44,29 +42,33 @@ void() func##_all = { \
|
|||
do_(ammo_shells); \
|
||||
do_(ammo_nails); \
|
||||
do_(ammo_rockets); \
|
||||
do_(ammo_cells)
|
||||
do_(ammo_cells);
|
||||
|
||||
void() delays_swapin_stats = {
|
||||
void ()
|
||||
delays_swapin_stats =
|
||||
{
|
||||
local float tmp;
|
||||
|
||||
#define do_(field) \
|
||||
tmp = self.field; \
|
||||
self.field = self.delay_##field; \
|
||||
self.delay_##field = tmp
|
||||
self.delay_##field = tmp;
|
||||
|
||||
do_fields();
|
||||
do_fields ();
|
||||
#undef do_
|
||||
};
|
||||
|
||||
all_func(delays_swapin_stats);
|
||||
all_func (delays_swapin_stats);
|
||||
|
||||
// ===================================================================== //
|
||||
|
||||
float() delays_changed = {
|
||||
float ()
|
||||
delays_changed =
|
||||
{
|
||||
#define do_(field) \
|
||||
if (floor(self.field) != floor(self.delay_##field)) \
|
||||
if (floor (self.field) != floor (self.delay_##field)) \
|
||||
return TRUE
|
||||
do_fields();
|
||||
do_fields ();
|
||||
#undef do_
|
||||
|
||||
return FALSE;
|
||||
|
@ -74,39 +76,47 @@ float() delays_changed = {
|
|||
|
||||
// ===================================================================== //
|
||||
|
||||
void() delays_force_update = {
|
||||
void ()
|
||||
delays_force_update =
|
||||
{
|
||||
self.delay_time = 0;
|
||||
};
|
||||
|
||||
|
||||
all_func(delays_force_update);
|
||||
all_func (delays_force_update);
|
||||
|
||||
// ===================================================================== //
|
||||
|
||||
void() delays_swapout_stats = {
|
||||
if (delays_changed())
|
||||
void ()
|
||||
delays_swapout_stats =
|
||||
{
|
||||
if (delays_changed ())
|
||||
self.delay_last_change = time;
|
||||
|
||||
self.delay_dmg_take += self.dmg_take; self.dmg_take = 0;
|
||||
self.delay_dmg_save += self.dmg_save; self.dmg_save = 0;
|
||||
self.delay_dmg_take += self.dmg_take;
|
||||
self.dmg_take = 0;
|
||||
self.delay_dmg_save += self.dmg_save;
|
||||
self.dmg_save = 0;
|
||||
|
||||
if (time < self.delay_time) {
|
||||
delays_swapin_stats();
|
||||
delays_swapin_stats ();
|
||||
return;
|
||||
}
|
||||
|
||||
#define do_(field) self.delay_##field = self.field
|
||||
do_fields();
|
||||
do_fields ();
|
||||
#undef do_
|
||||
|
||||
self.dmg_take = ceil(self.delay_dmg_take); self.delay_dmg_take = 0;
|
||||
if (self.dmg_take > 255) self.dmg_take = 255;
|
||||
self.dmg_take = ceil (self.delay_dmg_take);
|
||||
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;
|
||||
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)
|
||||
self.delay_time = time + CONFIG_STATS_DELAY;
|
||||
};
|
||||
|
||||
all_func(delays_swapout_stats);
|
||||
all_func (delays_swapout_stats);
|
||||
|
|
|
@ -2,16 +2,14 @@
|
|||
#define DELAYS_qh 1
|
||||
|
||||
@extern {
|
||||
void () delays_swapin_stats;
|
||||
void () delays_swapout_stats;
|
||||
|
||||
void() delays_swapin_stats;
|
||||
void() delays_swapout_stats;
|
||||
|
||||
void() delays_force_update;
|
||||
|
||||
void() delays_swapin_stats_all;
|
||||
void() delays_swapout_stats_all;
|
||||
void() delays_force_update_all;
|
||||
void () delays_force_update;
|
||||
|
||||
void () delays_swapin_stats_all;
|
||||
void () delays_swapout_stats_all;
|
||||
void () delays_force_update_all;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -2,16 +2,14 @@
|
|||
#define EFFECT_qh 1
|
||||
|
||||
@extern {
|
||||
|
||||
void() effect_muzzleflash;
|
||||
void(entity e) effect_smallkick;
|
||||
void(vector org, vector dir, float d) effect_blood;
|
||||
void(vector org, vector vel, float d) effect_gun_spark;
|
||||
void(vector org, vector vel) effect_nail_spark;
|
||||
void(vector org) effect_explosion;
|
||||
void(vector org) effect_teleport_fog;
|
||||
void(entity from, vector p1, vector p2) effect_lightning2;
|
||||
|
||||
void () effect_muzzleflash;
|
||||
void (entity e) effect_smallkick;
|
||||
void (vector org, vector dir, float d) effect_blood;
|
||||
void (vector org, vector vel, float d) effect_gun_spark;
|
||||
void (vector org, vector vel) effect_nail_spark;
|
||||
void (vector org) effect_explosion;
|
||||
void (vector org) effect_teleport_fog;
|
||||
void (entity from, vector p1, vector p2) effect_lightning2;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -10,7 +10,9 @@
|
|||
.float itemfield_3;
|
||||
.float itemfield_4;
|
||||
|
||||
float(entity e, float eid) equip_flag = {
|
||||
float (entity e, float eid)
|
||||
equip_flag =
|
||||
{
|
||||
if (eid < 24) {
|
||||
e.itemfield = itemfield_1;
|
||||
} else if (eid < 48) {
|
||||
|
@ -24,11 +26,13 @@ float(entity e, float eid) equip_flag = {
|
|||
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 = {
|
||||
eid = equip_flag(e, eid);
|
||||
float (entity e, float eid)
|
||||
equip_query =
|
||||
{
|
||||
eid = equip_flag (e, eid);
|
||||
|
||||
if (e.(e.itemfield) & eid)
|
||||
return TRUE;
|
||||
|
@ -36,8 +40,10 @@ float(entity e, float eid) equip_query = {
|
|||
return FALSE;
|
||||
};
|
||||
|
||||
float(entity e, float eid) equip_grant = {
|
||||
eid = equip_flag(e, eid);
|
||||
float (entity e, float eid)
|
||||
equip_grant =
|
||||
{
|
||||
eid = equip_flag (e, eid);
|
||||
|
||||
if (e.(e.itemfield) & eid)
|
||||
return FALSE;
|
||||
|
@ -47,8 +53,10 @@ float(entity e, float eid) equip_grant = {
|
|||
return TRUE;
|
||||
};
|
||||
|
||||
float(entity e, float eid) equip_remove = {
|
||||
eid = equip_flag(e, eid);
|
||||
float (entity e, float eid)
|
||||
equip_remove =
|
||||
{
|
||||
eid = equip_flag (e, eid);
|
||||
|
||||
if (e.(e.itemfield) & eid) {
|
||||
e.(e.itemfield) -= eid;
|
||||
|
@ -60,7 +68,9 @@ float(entity e, float eid) equip_remove = {
|
|||
|
||||
float _equip_iter_id;
|
||||
/* Returns EQUIPID_* or -1 when done */
|
||||
float(entity iteme) equip_iter = {
|
||||
float (entity iteme)
|
||||
equip_iter =
|
||||
{
|
||||
local float ret, flag;
|
||||
|
||||
while (1) {
|
||||
|
@ -69,7 +79,7 @@ float(entity iteme) equip_iter = {
|
|||
return -1;
|
||||
}
|
||||
|
||||
flag = equip_flag(iteme, _equip_iter_id);
|
||||
flag = equip_flag (iteme, _equip_iter_id);
|
||||
|
||||
ret = _equip_iter_id;
|
||||
_equip_iter_id++;
|
||||
|
|
|
@ -4,28 +4,26 @@
|
|||
#include "equipid.qh"
|
||||
|
||||
@extern {
|
||||
#define EQUIP_STATE_CHOOSE 0
|
||||
#define EQUIP_STATE_CHOSEN 1
|
||||
|
||||
#define EQUIP_STATE_CHOOSE 0
|
||||
#define EQUIP_STATE_CHOSEN 1
|
||||
.float equip_state;
|
||||
|
||||
.float equip_state;
|
||||
..float itemfield;
|
||||
.float itemfield_1;
|
||||
.float itemfield_2;
|
||||
.float itemfield_3;
|
||||
.float itemfield_4;
|
||||
|
||||
..float itemfield;
|
||||
.float itemfield_1;
|
||||
.float itemfield_2;
|
||||
.float itemfield_3;
|
||||
.float itemfield_4;
|
||||
float (entity e, float eid) equip_flag;
|
||||
|
||||
float(entity e, float eid) equip_flag;
|
||||
float (entity e, float eid) equip_query;
|
||||
float (entity e, float eid) equip_grant;
|
||||
float (entity e, float eid) equip_remove;
|
||||
|
||||
float(entity e, float eid) equip_query;
|
||||
float(entity e, float eid) equip_grant;
|
||||
float(entity e, float eid) equip_remove;
|
||||
|
||||
float(entity iteme) equip_iter;
|
||||
|
||||
string(float eid) equip_id_to_string;
|
||||
float (entity iteme) equip_iter;
|
||||
|
||||
string (float eid) equip_id_to_string;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
58
klik/math.qc
58
klik/math.qc
|
@ -2,20 +2,52 @@
|
|||
#include "builtins.qh"
|
||||
|
||||
/* Ugh. QuakeC doesn't include these ops. */
|
||||
float(float num, float bits) shl = {
|
||||
if (bits >= 16) { num *= 65536; 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; }
|
||||
float (float num, float bits)
|
||||
shl =
|
||||
{
|
||||
if (bits >= 16) {
|
||||
num *= 65536;
|
||||
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;
|
||||
};
|
||||
|
||||
float(float num, float bits) shr = {
|
||||
if (bits >= 16) { num /= 65536; 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);
|
||||
float (float num, float bits)
|
||||
shr =
|
||||
{
|
||||
if (bits >= 16) {
|
||||
num /= 65536;
|
||||
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);
|
||||
};
|
||||
|
|
10
klik/math.qh
10
klik/math.qh
|
@ -2,13 +2,11 @@
|
|||
#define MATH_qh 1
|
||||
|
||||
@extern {
|
||||
float (float num, float bits) shl;
|
||||
float (float num, float bits) shr;
|
||||
|
||||
float(float num, float bits) shl;
|
||||
float(float num, float bits) shr;
|
||||
|
||||
#define min(a, b) ((a)>(b)?(b):(a))
|
||||
#define max(a, b) ((a)>(b)?(a):(b))
|
||||
|
||||
#define min(a, b) ((a)>(b)?(b):(a))
|
||||
#define max(a, b) ((a)>(b)?(a):(b))
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
10
klik/menu.qc
10
klik/menu.qc
|
@ -3,15 +3,19 @@
|
|||
|
||||
.float menu_state;
|
||||
.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_time = 0;
|
||||
self.menu_think = menu_func;
|
||||
};
|
||||
|
||||
float() util_menu_needs_print = {
|
||||
float ()
|
||||
util_menu_needs_print =
|
||||
{
|
||||
if (time > self.menu_time) {
|
||||
self.menu_time = time + 1.4;
|
||||
return TRUE;
|
||||
|
|
|
@ -5,9 +5,9 @@
|
|||
|
||||
@extern .float menu_state;
|
||||
@extern .float menu_time;
|
||||
@extern .void() menu_think;
|
||||
@extern .void () menu_think;
|
||||
|
||||
@extern void(void() menu_func) menu_set;
|
||||
@extern float() util_menu_needs_print;
|
||||
@extern void (void() menu_func) menu_set;
|
||||
@extern float () util_menu_needs_print;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -4,27 +4,29 @@
|
|||
#include "misc.qh"
|
||||
|
||||
/*
|
||||
void() menu_team = {
|
||||
if (team_ischosen(self))
|
||||
menu_set(menu_equip);
|
||||
void ()
|
||||
menu_team =
|
||||
{
|
||||
if (team_ischosen (self))
|
||||
menu_set (menu_equip);
|
||||
|
||||
if (util_menu_needs_print() && is_cl(self)) {
|
||||
centerprint(self,
|
||||
"Team\n"
|
||||
"\<\-\-\-\-\>\n"
|
||||
"1\b.\b Red\n"
|
||||
"2\b.\b Blue\n"
|
||||
"\n"
|
||||
"0\b.\b Auto\n"
|
||||
);
|
||||
if (util_menu_needs_print () && is_cl (self)) {
|
||||
centerprint (self,
|
||||
"Team\n"
|
||||
"\<\-\-\-\-\>\n"
|
||||
"1\b.\b Red\n"
|
||||
"2\b.\b Blue\n"
|
||||
"\n"
|
||||
"0\b.\b Auto\n");
|
||||
}
|
||||
|
||||
if (self.impulse == 1) {
|
||||
team_join(TEAM_RED);
|
||||
team_join (TEAM_RED);
|
||||
} else if (self.impulse == 2) {
|
||||
team_join(TEAM_BLUE);
|
||||
} else if (self.impulse == 10 || self.button0 || self.button1 || self.button2) {
|
||||
team_join_auto();
|
||||
team_join (TEAM_BLUE);
|
||||
} else if (self.impulse == 10 || self.button0 || self.button1
|
||||
|| self.button2) {
|
||||
team_join_auto ();
|
||||
}
|
||||
|
||||
self.impulse = 0;
|
||||
|
@ -36,20 +38,19 @@ void() menu_intro = {
|
|||
if (!self.menu_state)
|
||||
self.menu_state = time + 3;
|
||||
else if (time >= self.menu_state) {
|
||||
if (is_cl(self))
|
||||
centerprint(self, "");
|
||||
PutClientInGame();
|
||||
if (is_cl (self))
|
||||
centerprint (self, "");
|
||||
PutClientInGame ();
|
||||
return;
|
||||
}
|
||||
|
||||
if (util_menu_needs_print()) {
|
||||
if (is_cl(self))
|
||||
centerprint(self,
|
||||
"\[ This server is running Klik 0.0.7 \]\n"
|
||||
"\[ by Zinx Verituse \]\n"
|
||||
"\[ http://staff.xmms.org/zinx/klik \]\n"
|
||||
"\n"
|
||||
"\<[ It's a Quake World. ]\>\n"
|
||||
);
|
||||
if (util_menu_needs_print ()) {
|
||||
if (is_cl (self))
|
||||
centerprint (self,
|
||||
"\[ This server is running Klik 0.0.7 \]\n"
|
||||
"\[ by Zinx Verituse \]\n"
|
||||
"\[ http://staff.xmms.org/zinx/klik \]\n"
|
||||
"\n"
|
||||
"\<[ It's a Quake World. ]\>\n");
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#ifndef MENUS_qh
|
||||
#define MENUS_qh 1
|
||||
|
||||
@extern void() menu_intro;
|
||||
@extern void () menu_intro;
|
||||
|
||||
#endif
|
||||
|
|
227
klik/misc.qc
227
klik/misc.qc
|
@ -9,10 +9,12 @@
|
|||
|
||||
// ===================================================================== //
|
||||
|
||||
entity(string clname) spawn = {
|
||||
entity (string clname)
|
||||
spawn =
|
||||
{
|
||||
local entity e;
|
||||
|
||||
e = BUILTIN_spawn();
|
||||
e = BUILTIN_spawn ();
|
||||
e.classname = clname;
|
||||
|
||||
return e;
|
||||
|
@ -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.solid = SOLID_NOT;
|
||||
e.model = NIL;
|
||||
|
@ -34,11 +42,17 @@ 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) {
|
||||
makestatic(self);
|
||||
makestatic (self);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -51,11 +65,16 @@ void(entity e) safe_makestatic = {
|
|||
|
||||
// ===================================================================== //
|
||||
|
||||
void() _sound_vector_think = {
|
||||
sound(self, CHAN_VOICE, self.noise1, self.volume, self.attenuation);
|
||||
remove(self);
|
||||
void ()
|
||||
_sound_vector_think =
|
||||
{
|
||||
sound (self, CHAN_VOICE, self.noise1, self.volume, self.attenuation);
|
||||
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;
|
||||
|
||||
e = spawn("SOUND");
|
||||
|
@ -70,47 +89,60 @@ 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;
|
||||
return TRUE;
|
||||
};
|
||||
|
||||
void(entity mis) missile_check_teleport;
|
||||
void() _missile_always_trigger = {
|
||||
void (entity mis) missile_check_teleport;
|
||||
|
||||
void ()
|
||||
_missile_always_trigger =
|
||||
{
|
||||
self.think = SUB_remove;
|
||||
self.nextthink = self.attack_finished;
|
||||
|
||||
if (self.movetype != MOVETYPE_FLYMISSILE && self.movetype != MOVETYPE_FLY)
|
||||
if ((self.movetype != MOVETYPE_FLYMISSILE)
|
||||
&& (self.movetype != MOVETYPE_FLY))
|
||||
return;
|
||||
|
||||
tl_proj_begin();
|
||||
tl_proj_begin ();
|
||||
/* Make sure we're still going to hit the thing */
|
||||
traceline(self.origin, self.origin + self.velocity * sv_maxtic*2, FALSE, self);
|
||||
if (trace_ent == self.enemy) tl_touch(trace_ent, self);
|
||||
else self.enemy = world;
|
||||
tl_proj_end();
|
||||
traceline (self.origin, self.origin + self.velocity * sv_maxtic * 2, FALSE,
|
||||
self);
|
||||
if (trace_ent == self.enemy)
|
||||
tl_touch (trace_ent, self);
|
||||
else
|
||||
self.enemy = world;
|
||||
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;
|
||||
|
||||
tl_proj_begin();
|
||||
tl_proj_begin ();
|
||||
|
||||
trace_ent = mis;
|
||||
trace_endpos = mis.origin;
|
||||
duration = mis.attack_finished - time;
|
||||
|
||||
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) {
|
||||
/* Don't bother tracing through BSP, it won't happen. */
|
||||
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,
|
||||
a solid ent, or something we _just_ hit */
|
||||
if (trace_fraction == 0) {
|
||||
|
@ -118,22 +150,24 @@ void(entity mis) missile_check_teleport = {
|
|||
break;
|
||||
}
|
||||
/* Trace on past it. */
|
||||
duration -= duration*trace_fraction;
|
||||
duration -= duration * trace_fraction;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Reached a [new] trigger */
|
||||
mis.enemy = trace_ent;
|
||||
mis.think = _missile_always_trigger;
|
||||
mis.nextthink = time + duration*trace_fraction - sv_maxtic;
|
||||
mis.nextthink = time + duration * trace_fraction - sv_maxtic;
|
||||
break;
|
||||
}
|
||||
|
||||
tl_proj_end();
|
||||
tl_proj_end ();
|
||||
};
|
||||
|
||||
entity(string clname, string mod, vector org, vector dir, float spd) spawn_missile = {
|
||||
newmis = spawn(clname);
|
||||
entity (string clname, string mod, vector org, vector dir, float spd)
|
||||
spawn_missile =
|
||||
{
|
||||
newmis = spawn (clname);
|
||||
|
||||
newmis.owner = self;
|
||||
newmis.goalentity = self;
|
||||
|
@ -144,11 +178,11 @@ entity(string clname, string mod, vector org, vector dir, float spd) spawn_missi
|
|||
|
||||
newmis.th_teleport = _missile_th_teleport;
|
||||
|
||||
setmodel(newmis, mod);
|
||||
setsize(newmis, '0 0 0', '0 0 0');
|
||||
setorigin(newmis, org);
|
||||
setmodel (newmis, mod);
|
||||
setsize (newmis, '0 0 0', '0 0 0');
|
||||
setorigin (newmis, org);
|
||||
|
||||
newmis.angles = vectoangles(dir);
|
||||
newmis.angles = vectoangles (dir);
|
||||
newmis.speed = spd;
|
||||
newmis.velocity = dir * spd;
|
||||
|
||||
|
@ -157,7 +191,7 @@ entity(string clname, string mod, vector org, vector dir, float spd) spawn_missi
|
|||
newmis.think = SUB_remove;
|
||||
newmis.nextthink = newmis.attack_finished;
|
||||
|
||||
missile_check_teleport(newmis);
|
||||
missile_check_teleport (newmis);
|
||||
|
||||
return newmis;
|
||||
};
|
||||
|
@ -166,11 +200,13 @@ entity(string clname, string mod, vector org, vector dir, float spd) spawn_missi
|
|||
|
||||
entity tl_first;
|
||||
.entity tl_next;
|
||||
void() tl_proj_begin = {
|
||||
void ()
|
||||
tl_proj_begin =
|
||||
{
|
||||
local entity walk;
|
||||
|
||||
tl_first = world;
|
||||
for (walk = nextent(world); walk; walk = nextent(walk)) {
|
||||
for (walk = nextent (world); walk; walk = nextent (walk)) {
|
||||
if (walk.solid != SOLID_TRIGGER)
|
||||
continue;
|
||||
|
||||
|
@ -179,27 +215,31 @@ void() tl_proj_begin = {
|
|||
|
||||
walk.solid = SOLID_BBOX;
|
||||
walk.tl_notsolid = TRUE;
|
||||
setorigin(walk, walk.origin); // relink
|
||||
setorigin (walk, walk.origin); // relink
|
||||
}
|
||||
};
|
||||
|
||||
void() tl_proj_end = {
|
||||
void ()
|
||||
tl_proj_end =
|
||||
{
|
||||
local entity walk;
|
||||
|
||||
for (walk = tl_first; walk; walk = walk.tl_next) {
|
||||
walk.solid = SOLID_TRIGGER;
|
||||
walk.tl_notsolid = FALSE;
|
||||
setorigin(walk, walk.origin); // relink
|
||||
setorigin (walk, walk.origin); // relink
|
||||
}
|
||||
};
|
||||
|
||||
void(entity trigger, entity fake_proj) tl_touch = {
|
||||
void (entity trigger, entity fake_proj)
|
||||
tl_touch =
|
||||
{
|
||||
local entity oldself, oldother;
|
||||
|
||||
if (!trigger.touch)
|
||||
return;
|
||||
|
||||
tl_proj_end();
|
||||
tl_proj_end ();
|
||||
|
||||
oldself = self;
|
||||
oldother = other;
|
||||
|
@ -207,19 +247,23 @@ void(entity trigger, entity fake_proj) tl_touch = {
|
|||
self = trigger;
|
||||
other = fake_proj;
|
||||
|
||||
self.touch();
|
||||
self.touch ();
|
||||
|
||||
self = oldself;
|
||||
other = oldother;
|
||||
|
||||
tl_proj_begin();
|
||||
tl_proj_begin ();
|
||||
};
|
||||
|
||||
// ===================================================================== //
|
||||
|
||||
string(entity e) name = {
|
||||
if (e.netname) return e.netname;
|
||||
if (e.classname) return e.classname;
|
||||
string (entity e)
|
||||
name =
|
||||
{
|
||||
if (e.netname)
|
||||
return e.netname;
|
||||
if (e.classname)
|
||||
return e.classname;
|
||||
|
||||
if (e.velocity)
|
||||
return "an unidentified flying object";
|
||||
|
@ -228,33 +272,39 @@ 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;
|
||||
|
||||
ent = world;
|
||||
while ((ent = find(ent, fld, match))) {
|
||||
while ((ent = find (ent, fld, match))) {
|
||||
if (!func) {
|
||||
dprint("NULL function in foreach, classname: ", ent.classname, "\n");
|
||||
dprint ("NULL function in foreach, classname: ", ent.classname,
|
||||
"\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
func(ent);
|
||||
func (ent);
|
||||
}
|
||||
};
|
||||
|
||||
void(.string fld, string match, .void() func) foreach_field = {
|
||||
void (.string fld, string match, .void () func)
|
||||
foreach_field =
|
||||
{
|
||||
local entity oldself;
|
||||
|
||||
oldself = self;
|
||||
|
||||
self = world;
|
||||
while ((self = find(self, fld, match))) {
|
||||
while ((self = find (self, fld, match))) {
|
||||
if (!self.func) {
|
||||
dprint("NULL function in foreach_field, classname: ", self.classname, "\n");
|
||||
dprint ("NULL function in foreach_field, classname: ",
|
||||
self.classname, "\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
self.func();
|
||||
self.func ();
|
||||
}
|
||||
|
||||
self = oldself;
|
||||
|
@ -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 float ret;
|
||||
|
||||
|
@ -272,7 +323,7 @@ float(entity newself, entity newother, float() func) switcheroo = {
|
|||
self = newself;
|
||||
other = newother;
|
||||
|
||||
ret = func();
|
||||
ret = func ();
|
||||
|
||||
self = oldself;
|
||||
other = oldother;
|
||||
|
@ -282,19 +333,25 @@ 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;
|
||||
|
||||
diff = max - current;
|
||||
if (diff <= 0) return current;
|
||||
if (diff > increment) diff = increment;
|
||||
if (diff <= 0)
|
||||
return current;
|
||||
if (diff > increment)
|
||||
diff = increment;
|
||||
return current + diff;
|
||||
};
|
||||
|
||||
float(.float fld, float increment, float max) increase_field = {
|
||||
float (.float fld, float increment, float max)
|
||||
increase_field =
|
||||
{
|
||||
local float new;
|
||||
|
||||
new = increase_bound(self.fld, increment, max);
|
||||
new = increase_bound (self.fld, increment, max);
|
||||
if (new == self.fld)
|
||||
return FALSE;
|
||||
|
||||
|
@ -306,7 +363,9 @@ float(.float fld, float increment, float max) increase_field = {
|
|||
// ===================================================================== //
|
||||
|
||||
/* Not to be confused with maxspeed */
|
||||
float(entity e) calc_max_speed = {
|
||||
float (entity e)
|
||||
calc_max_speed =
|
||||
{
|
||||
local float spd;
|
||||
|
||||
spd = e.maxspeed;
|
||||
|
@ -325,41 +384,48 @@ float(entity e) calc_max_speed = {
|
|||
|
||||
entity _xprint_client;
|
||||
float _xprint_level;
|
||||
void(entity client, float level) xprint_start = {
|
||||
void (entity client, float level)
|
||||
xprint_start =
|
||||
{
|
||||
_xprint_client = client;
|
||||
_xprint_level = level;
|
||||
};
|
||||
|
||||
void(string str) xprint_str = {
|
||||
void (string str)
|
||||
xprint_str =
|
||||
{
|
||||
msg_entity = _xprint_client;
|
||||
WriteByte(MSG_ONE, SVC_PRINT);
|
||||
WriteByte(MSG_ONE, _xprint_level);
|
||||
WriteString(MSG_ONE, str);
|
||||
WriteBytes (MSG_ONE, (float) SVC_PRINT, _xprint_level);
|
||||
WriteString (MSG_ONE, str);
|
||||
};
|
||||
|
||||
// ===================================================================== //
|
||||
|
||||
entity(.string fld, string str) find_random = {
|
||||
entity (.string fld, string str)
|
||||
find_random =
|
||||
{
|
||||
local float r, numents;
|
||||
local entity ent;
|
||||
|
||||
numents = 0;
|
||||
r = floor(random() * 512);
|
||||
r = floor (random () * 512);
|
||||
|
||||
while (1) {
|
||||
ent = find(world, fld, str);
|
||||
if (!ent) return world;
|
||||
ent = find (world, fld, str);
|
||||
if (!ent)
|
||||
return world;
|
||||
|
||||
while (ent) {
|
||||
numents++;
|
||||
|
||||
r--;
|
||||
if (r <= 0) return ent;
|
||||
if (r <= 0)
|
||||
return ent;
|
||||
|
||||
ent = find(ent, fld, str);
|
||||
ent = find (ent, fld, str);
|
||||
}
|
||||
|
||||
r -= numents * floor(r / numents);
|
||||
r -= numents * floor (r / numents);
|
||||
}
|
||||
|
||||
return world;
|
||||
|
@ -367,11 +433,13 @@ entity(.string fld, string str) find_random = {
|
|||
|
||||
// ===================================================================== //
|
||||
|
||||
entity(entity ech) random_enemy_chain = {
|
||||
entity (entity ech)
|
||||
random_enemy_chain =
|
||||
{
|
||||
local entity walk;
|
||||
local float tot, r;
|
||||
|
||||
r = floor(random()*64) + 1;
|
||||
r = floor (random () * 64) + 1;
|
||||
|
||||
tot = 1;
|
||||
for (walk = ech.enemy; walk != ech; walk = walk.enemy) {
|
||||
|
@ -386,7 +454,7 @@ entity(entity ech) random_enemy_chain = {
|
|||
return ech;
|
||||
|
||||
/* Ok, only look at half the remaining ones */
|
||||
tot = floor(tot * 0.5);
|
||||
tot = floor (tot * 0.5);
|
||||
if (!tot)
|
||||
return ech.enemy;
|
||||
|
||||
|
@ -401,6 +469,3 @@ entity(entity ech) random_enemy_chain = {
|
|||
|
||||
return world;
|
||||
};
|
||||
|
||||
// ===================================================================== //
|
||||
|
||||
|
|
86
klik/misc.qh
86
klik/misc.qh
|
@ -4,70 +4,68 @@
|
|||
/* Random miscellaneous functions */
|
||||
|
||||
@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 */
|
||||
#define crandom() (2.0 * (random () - 0.5))
|
||||
|
||||
#define crandom() (2.0*(random() - 0.5))
|
||||
void (entity e) makestatic;
|
||||
void (vector pos, string samp, float vol, float atten) ambientsound;
|
||||
|
||||
void(entity e) makestatic;
|
||||
void(vector pos, string samp, float vol, float atten) ambientsound;
|
||||
void () SUB_remove;
|
||||
void (entity e) safe_remove;
|
||||
|
||||
void() SUB_remove;
|
||||
void(entity e) safe_remove;
|
||||
void () SUB_makestatic;
|
||||
void (entity e) safe_makestatic;
|
||||
|
||||
void() SUB_makestatic;
|
||||
void(entity e) safe_makestatic;
|
||||
void (vector org, string samp, float vol, float atten) sound_vector;
|
||||
entity (string clname, string mod, vector org, vector dir, float speed) spawn_missile;
|
||||
|
||||
void(vector org, string samp, float vol, float atten) sound_vector;
|
||||
entity(string clname, string mod, vector org, vector dir, float speed) spawn_missile;
|
||||
/* :) */
|
||||
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(entity e) func) foreach;
|
||||
void(.string fld, string match, .void() func) foreach_field;
|
||||
/* swaps self/other temporarily */
|
||||
float (entity newself, entity newother, float() func) switcheroo;
|
||||
|
||||
/* swaps self/other temporarily */
|
||||
float(entity newself, entity newother, float() func) switcheroo;
|
||||
/* Returns new value */
|
||||
float (float current, float increment, float max) increase_bound;
|
||||
|
||||
/* Returns new value */
|
||||
float(float current, float increment, float max) increase_bound;
|
||||
/* Returns FALSE if not increased */
|
||||
float (.float fld, float increment, float max) increase_field;
|
||||
|
||||
/* Returns FALSE if not increased */
|
||||
float(.float fld, float increment, float max) increase_field;
|
||||
/* Calculate the player's current maximum speed, taking water/air in to account */
|
||||
float (entity e) calc_max_speed;
|
||||
|
||||
/* Calculate the player's current maximum speed, taking water/air in to account */
|
||||
float(entity e) calc_max_speed;
|
||||
/* sprint one string at a time, and get them all to the destination */
|
||||
void (entity client, float level) xprint_start;
|
||||
void (string str) xprint_str;
|
||||
|
||||
/* sprint one string at a time, and get them all to the destination */
|
||||
void(entity client, float level) xprint_start;
|
||||
void(string str) xprint_str;
|
||||
#define is_activeplayer(e) (e.flags & FL_CLIENT)
|
||||
|
||||
#define is_activeplayer(e) (e.flags & FL_CLIENT)
|
||||
#define is_cl(e) (e.flags & FL_CLIENT)
|
||||
#define is_autothink(e) (e.flags & FL_AUTOTHINK)
|
||||
|
||||
#define is_cl(e) (e.flags & FL_CLIENT)
|
||||
#define is_autothink(e) (e.flags & FL_AUTOTHINK)
|
||||
/* Return a random entity that matches, or world */
|
||||
entity (.string fld, string str) find_random;
|
||||
|
||||
/* Return a random entity that matches, or world */
|
||||
entity(.string fld, string str) find_random;
|
||||
/* Return something from the .enemy chain */
|
||||
entity (entity ech) random_enemy_chain;
|
||||
|
||||
/* Return something from the .enemy chain */
|
||||
entity(entity ech) random_enemy_chain;
|
||||
#define vieworigin(e) (e.origin + e.view_ofs)
|
||||
#define center(e) ((e.absmin + e.absmax) * 0.5)
|
||||
|
||||
#define vieworigin(e) (e.origin + e.view_ofs)
|
||||
#define center(e) ((e.absmin + e.absmax) * 0.5)
|
||||
/* FIXME: Make this an mdl func? */
|
||||
#define shootorigin(e) (vieworigin(e) - '0 0 6')
|
||||
|
||||
/* FIXME: Make this an mdl func? */
|
||||
#define shootorigin(e) (vieworigin(e) - '0 0 6')
|
||||
|
||||
/* Stuff for traceline "projectiles" to hit triggers like normal projectiles */
|
||||
void() tl_proj_begin;
|
||||
void() tl_proj_end;
|
||||
void(entity trigger, entity fake_proj) tl_touch;
|
||||
|
||||
.float tl_notsolid;
|
||||
#define tl_issolid(ent) (!ent.tl_notsolid)
|
||||
/* Stuff for traceline "projectiles" to hit triggers like normal projectiles */
|
||||
void () tl_proj_begin;
|
||||
void () tl_proj_end;
|
||||
void (entity trigger, entity fake_proj) tl_touch;
|
||||
|
||||
.float tl_notsolid;
|
||||
#define tl_issolid(ent) (!ent.tl_notsolid)
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
103
klik/override.qc
103
klik/override.qc
|
@ -16,32 +16,32 @@
|
|||
|
||||
/* Let's make my life simpler when I add new ones, mmmkay? */
|
||||
#define all_funcs() \
|
||||
one_func(float(), f_v, th_takeitem, (), return, FALSE); \
|
||||
one_func(float (), f_v, th_takeitem, (), return, FALSE); \
|
||||
\
|
||||
one_func(void(entity missile), v_e, th_attack, (missile), , ); \
|
||||
one_func(void (entity missile), v_e, th_attack, (missile), , ); \
|
||||
\
|
||||
one_func(float(float dmg), f_f, th_takedamage, (dmg), return, FALSE); \
|
||||
one_func(float(float dmg), f_f, th_dealdamage, (dmg), return, dmg); \
|
||||
one_func(float (float dmg), f_f, th_takedamage, (dmg), return, FALSE); \
|
||||
one_func(float (float dmg), f_f, th_dealdamage, (dmg), return, dmg); \
|
||||
\
|
||||
one_func(void(), v_v, th_die, (), , ); \
|
||||
one_func(void(), v_v, th_kill, (), , ); \
|
||||
one_func(void (), v_v, th_die, (), , ); \
|
||||
one_func(void (), v_v, th_kill, (), , ); \
|
||||
\
|
||||
one_func(void(), v_v, prethink, (), , ); \
|
||||
one_func(void(), v_v, actthink, (), , ); \
|
||||
one_func(void(), v_v, postthink, (), , ); \
|
||||
one_func(void (), v_v, prethink, (), , ); \
|
||||
one_func(void (), v_v, actthink, (), , ); \
|
||||
one_func(void (), v_v, postthink, (), , ); \
|
||||
\
|
||||
one_func(float(vector org), f_c, th_teleport, (org), return, TRUE); \
|
||||
one_func(float (vector org), f_c, th_teleport, (org), return, TRUE); \
|
||||
\
|
||||
one_func(float(entity missile), f_e, th_projectile, (missile), return, TRUE)
|
||||
one_func(float (entity missile), f_e, th_projectile, (missile), return, TRUE)
|
||||
|
||||
|
||||
#define all_types() \
|
||||
one_type(void(), v_v); \
|
||||
one_type(float(), f_v); \
|
||||
one_type(void(entity ent), v_e); \
|
||||
one_type(float(float flt), f_f); \
|
||||
one_type(float(vector vec), f_c); \
|
||||
one_type(float(entity ent), f_e)
|
||||
one_type (void (), v_v); \
|
||||
one_type (float (), f_v); \
|
||||
one_type (void (entity ent), v_e); \
|
||||
one_type (float (float flt), f_f); \
|
||||
one_type (float (vector vec), f_c); \
|
||||
one_type (float (entity ent), f_e)
|
||||
|
||||
// ===================================================================== //
|
||||
|
||||
|
@ -49,7 +49,7 @@
|
|||
#define one_func(type1,type2,func,args,return,val) \
|
||||
type1 _passthru_##func = { \
|
||||
local entity ovr; \
|
||||
ovr = override_findself(); \
|
||||
ovr = override_findself (); \
|
||||
if (ovr.func) \
|
||||
return ovr.func args; \
|
||||
return val; \
|
||||
|
@ -61,45 +61,49 @@ all_funcs();
|
|||
|
||||
/* for the override_set_FUNCTION macros in override.qh */
|
||||
#define one_type(type1,type2) \
|
||||
void(entity e, .type1 fld, type1 func) override_set_##type2 = {\
|
||||
void(entity e, .type1 fld, type1 func) override_set_##type2 = { \
|
||||
if (e.overrider) \
|
||||
e.overrider.fld = func; \
|
||||
else \
|
||||
e.fld = func; \
|
||||
}
|
||||
}
|
||||
|
||||
all_types();
|
||||
all_types ();
|
||||
|
||||
#undef one_type
|
||||
|
||||
// ===================================================================== //
|
||||
|
||||
void(entity e1, entity e2) _override_swap = {
|
||||
void (entity e1, entity e2)
|
||||
_override_swap =
|
||||
{
|
||||
#define one_type(type1,type2) local type1 t_##type2
|
||||
all_types();
|
||||
#undef one_type
|
||||
|
||||
/* Swap all the functions */
|
||||
#define one_func(type1,type2,func,args,return,val) \
|
||||
t_##type2 = e1.func; \
|
||||
e1.func = e2.func; \
|
||||
e2.func = t_##type2
|
||||
t_##type2 = e1.func; \
|
||||
e1.func = e2.func; \
|
||||
e2.func = t_##type2
|
||||
|
||||
all_funcs();
|
||||
|
||||
#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;
|
||||
|
||||
for (ovr = e.overrider; ovr; ovr = ovr.overrider) {
|
||||
if (ovr.classname == override_class) {
|
||||
ovr2 = ovr.overrider;
|
||||
if (!ovr2) ovr2 = e;
|
||||
_override_swap(ovr, ovr2);
|
||||
if (!ovr2)
|
||||
ovr2 = e;
|
||||
_override_swap (ovr, ovr2);
|
||||
return ovr;
|
||||
}
|
||||
}
|
||||
|
@ -114,9 +118,11 @@ entity(entity e, string override_class, float priority) override_create = {
|
|||
ovr.overrider = spawn(override_class);
|
||||
ovr.overrider.owner = ovr;
|
||||
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.overrider_priority = priority;
|
||||
|
@ -124,26 +130,30 @@ entity(entity e, string override_class, float priority) override_create = {
|
|||
|
||||
/* Set default passthru funcs for ovr */
|
||||
#define one_func(type1,type2,func,args,return,val) \
|
||||
ovr.func = _passthru_##func
|
||||
|
||||
all_funcs();
|
||||
ovr.func = _passthru_##func
|
||||
|
||||
all_funcs ();
|
||||
#undef one_func
|
||||
|
||||
return ovr;
|
||||
};
|
||||
|
||||
void(entity ovr) override_finalize = {
|
||||
_override_swap(ovr, ovr.goalentity);
|
||||
void (entity ovr)
|
||||
override_finalize =
|
||||
{
|
||||
_override_swap (ovr, ovr.goalentity);
|
||||
};
|
||||
|
||||
entity() override_findself = {
|
||||
entity ()
|
||||
override_findself =
|
||||
{
|
||||
local entity ovrself;
|
||||
|
||||
ovrself = self.overrider_self;
|
||||
if (!ovrself) {
|
||||
/* 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;
|
||||
|
@ -153,25 +163,30 @@ entity() override_findself = {
|
|||
return ovrself;
|
||||
};
|
||||
|
||||
void() override_halt = {
|
||||
void ()
|
||||
override_halt =
|
||||
{
|
||||
self.overrider_self = world;
|
||||
};
|
||||
|
||||
void(entity e, entity ovr) override_destroy = {
|
||||
void (entity e, entity ovr)
|
||||
override_destroy =
|
||||
{
|
||||
local entity ovr2;
|
||||
|
||||
ovr2 = ovr.overrider;
|
||||
if (!ovr2) ovr2 = e;
|
||||
if (!ovr2)
|
||||
ovr2 = e;
|
||||
|
||||
/* Copy the funcs from ovr to ovr2 */
|
||||
#define one_func(type1,type2,func,args,return,val) \
|
||||
ovr2.func = ovr.func
|
||||
ovr2.func = ovr.func
|
||||
|
||||
all_funcs();
|
||||
|
||||
#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.think = SUB_remove;
|
||||
|
|
|
@ -2,48 +2,40 @@
|
|||
#define OVERRIDE_qh 1
|
||||
|
||||
@extern {
|
||||
/* Returns an overrider with matching class, creating one if needed */
|
||||
entity (entity e, string override_class, float priority) override_create;
|
||||
|
||||
/* Returns an overrider with matching class, creating one if needed */
|
||||
entity(entity e, string override_class, float priority) override_create;
|
||||
/* Finalizes the above, call this once you set what you want to override. */
|
||||
void (entity ovr) override_finalize;
|
||||
|
||||
/* Finalizes the above, call this once you set what you want to override. */
|
||||
void(entity ovr) override_finalize;
|
||||
/* Use this in your overrider to get your entity. Call it _EXACTLY ONCE_ per overrider */
|
||||
entity () override_findself;
|
||||
|
||||
/* Use this in your overrider to get your entity. Call it _EXACTLY ONCE_ per overrider */
|
||||
entity() override_findself;
|
||||
/* This _MUST_ be called if you don't continue down the chain! */
|
||||
void () override_halt;
|
||||
|
||||
/* This _MUST_ be called if you don't continue down the chain! */
|
||||
void() override_halt;
|
||||
/* Guess. */
|
||||
void (entity e, entity ovr) override_destroy;
|
||||
|
||||
/* Guess. */
|
||||
void(entity e, entity ovr) override_destroy;
|
||||
|
||||
/* FIXME: Use 'any' type when compiler supports it */
|
||||
void(entity e, .void() fld, void() func) override_set_v_v;
|
||||
void(entity e, .float(entity ent) fld, float(entity ent) func) override_set_f_e;
|
||||
void(entity e, .float(float flt) fld, float(float flt) func) override_set_f_f;
|
||||
void(entity e, .float() fld, float() func) override_set_f_v;
|
||||
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;
|
||||
|
||||
#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_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_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_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_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_projectile(e, func) override_set_f_e(e, th_projectile, func)
|
||||
/* FIXME: Use 'any' type when compiler supports it */
|
||||
void (entity e, .void () fld, void () func) override_set_v_v;
|
||||
void (entity e, .float (entity ent) fld, float (entity ent) func) override_set_f_e;
|
||||
void (entity e, .float (float flt) fld, float (float flt) func) override_set_f_f;
|
||||
void (entity e, .float () fld, float () func) override_set_f_v;
|
||||
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;
|
||||
|
||||
#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_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_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_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_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_projectile(e, func) override_set_f_e(e, th_projectile, func)
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,96 +1,99 @@
|
|||
/* Builtin functions */
|
||||
|
||||
entity() BUILTIN_spawn = #14;
|
||||
void(entity e) remove = #15;
|
||||
entity () BUILTIN_spawn = #14;
|
||||
void (entity e) remove = #15;
|
||||
|
||||
void(entity e, vector o) setorigin = #2;
|
||||
void(entity e, string m) setmodel = #3; // set movetype and solid first
|
||||
void(entity e, vector min, vector max) setsize = #4;
|
||||
void (entity e, vector o) setorigin = #2;
|
||||
void (entity e, string m) setmodel = #3; // set movetype and solid first
|
||||
void (entity e, vector min, vector max) setsize = #4;
|
||||
|
||||
string(string s) precache_sound = #19;
|
||||
string(string s) precache_model = #20;
|
||||
string(string s) precache_file = #68; // no effect except for -copy
|
||||
string(string s) precache_sound2 = #76; // registered version only
|
||||
string(string s) precache_model2 = #75; // registered version only
|
||||
string(string s) precache_file2 = #77; // registered version only
|
||||
void(float style, string value) lightstyle = #35;
|
||||
string (string s) precache_sound = #19;
|
||||
string (string s) precache_model = #20;
|
||||
string (string s) precache_file = #68; // no effect except for -copy
|
||||
string (string s) precache_sound2 = #76; // registered version only
|
||||
string (string s) precache_model2 = #75; // registered version only
|
||||
string (string s) precache_file2 = #77; // registered version only
|
||||
void (float style, string value) lightstyle = #35;
|
||||
|
||||
// debug functions
|
||||
void() BUILTIN_break = #6; // shatter progs
|
||||
void(string e, ...) error = #10;
|
||||
void(string e, ...) objerror = #11;
|
||||
void() coredump = #28; // prints all edicts
|
||||
void() traceon = #29; // turns statment trace on
|
||||
void() traceoff = #30;
|
||||
void () BUILTIN_break = #6; // shatter progs
|
||||
void (string e, ...) error = #10;
|
||||
void (string e, ...) objerror = #11;
|
||||
void () coredump = #28; // prints all edicts
|
||||
void () traceon = #29; // turns statment trace on
|
||||
void () traceoff = #30;
|
||||
|
||||
void(entity e, float chan, string samp, float vol, float atten) sound = #8;
|
||||
void (entity e, float chan, string samp, float vol, float atten) sound = #8;
|
||||
|
||||
void(vector ang) makevectors = #1; // sets v_forward, etc globals
|
||||
vector(vector v) normalize = #9;
|
||||
float(vector v) vlen = #12;
|
||||
float(vector v) vectoyaw = #13;
|
||||
vector(vector v) vectoangles = #51;
|
||||
vector(entity e, float speed) aim = #44; // returns the shooting vector
|
||||
void (vector ang) makevectors = #1; // sets v_forward, etc globals
|
||||
vector (vector v) normalize = #9;
|
||||
float (vector v) vlen = #12;
|
||||
float (vector v) vectoyaw = #13;
|
||||
vector (vector v) vectoangles = #51;
|
||||
vector (entity e, float speed) aim = #44; // returns the shooting vector
|
||||
|
||||
float() random = #7; // returns 0 - 1
|
||||
string(float f) ftos = #26;
|
||||
float(string s) stof = #81; // convert string to float
|
||||
string(vector v) vtos = #27;
|
||||
float(float v) rint = #36; // round to nearest int
|
||||
float(float v) floor = #37; // largest integer <= v
|
||||
float(float v) ceil = #38; // smallest integer >= v
|
||||
float(float f) fabs = #43;
|
||||
float () random = #7; // returns 0 - 1
|
||||
string (float f) ftos = #26;
|
||||
float (string s) stof = #81; // convert string to float
|
||||
string (vector v) vtos = #27;
|
||||
float (float v) rint = #36; // round to nearest int
|
||||
float (float v) floor = #37; // largest integer <= v
|
||||
float (float v) ceil = #38; // smallest integer >= v
|
||||
float (float f) fabs = #43;
|
||||
|
||||
// sets trace_* globals
|
||||
// nomonsters can be:
|
||||
// An entity will also be ignored for testing if forent == test,
|
||||
// forent->owner == test, or test->owner == forent
|
||||
// a forent of world is ignored
|
||||
void(vector v1, vector v2, float nomonsters, entity forent) traceline = #16;
|
||||
float(vector v) pointcontents = #41; // returns a CONTENT_*
|
||||
float(entity e) checkbottom = #40; // true if self is on ground
|
||||
float() droptofloor = #34; // TRUE if landed on floor
|
||||
float(float yaw, float dist) walkmove = #32; // returns TRUE or FALSE
|
||||
void(float step) movetogoal = #67;
|
||||
void (vector v1, vector v2, float nomonsters, entity forent) traceline = #16;
|
||||
float (vector v) pointcontents = #41; // returns a CONTENT_*
|
||||
float (entity e) checkbottom = #40; // true if self is on ground
|
||||
float () droptofloor = #34; // TRUE if landed on floor
|
||||
float (float yaw, float dist) walkmove = #32; // returns TRUE or FALSE
|
||||
void (float step) movetogoal = #67;
|
||||
|
||||
entity() checkclient = #17; // returns a client to look for
|
||||
entity(entity start, .string fld, string match) find = #18;
|
||||
entity(vector org, float rad) findradius = #22;
|
||||
entity(entity e) nextent = #47; // for looping through all ents
|
||||
entity () checkclient = #17; // returns a client to look for
|
||||
entity (entity start, .string fld, string match) find = #18;
|
||||
entity (vector org, float rad) findradius = #22;
|
||||
entity (entity e) nextent = #47; // for looping through all ents
|
||||
|
||||
void(float level, string s, ...) bprint = #23;
|
||||
void(entity client, float level, string s, ...) sprint = #24;
|
||||
void(entity client, string s, ...) centerprint = #73; // sprint, but in middle
|
||||
void(string s, ...) dprint = #25;
|
||||
void(entity e) eprint = #31; // prints an entire edict
|
||||
void (float level, string s, ...) bprint = #23;
|
||||
void (entity client, float level, string s, ...) sprint = #24;
|
||||
void (entity client, string s, ...) centerprint = #73; // sprint, but centered
|
||||
void (string s, ...) dprint = #25;
|
||||
void (entity e) eprint = #31; // prints an entire edict
|
||||
|
||||
float(string s) cvar = #45; // return cvar.value
|
||||
void(string var, string val) cvar_set = #72; // sets cvar.value
|
||||
string(entity e, string key) infokey = #80; // get a key value (world = serverinfo)
|
||||
void(string s1, ...) localcmd = #46; // put string into local que
|
||||
void(entity client, string s) stuffcmd = #21;
|
||||
float (string s) cvar = #45; // return cvar.value
|
||||
void (string var, string val) cvar_set = #72; // sets cvar.value
|
||||
string (entity e, string key) infokey = #80; // get a key value (world = serverinfo)
|
||||
void (string s1, ...) localcmd = #46; // put string into local que
|
||||
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
|
||||
// direct client message generation
|
||||
void(float to, float f) WriteByte = #52;
|
||||
void(float to, float f) WriteChar = #53;
|
||||
void(float to, float f) WriteShort = #54;
|
||||
void(float to, float f) WriteLong = #55;
|
||||
void(float to, float f) WriteCoord = #56;
|
||||
void(float to, float f) WriteAngle = #57;
|
||||
void(float to, string s) WriteString = #58;
|
||||
void(float to, entity s) WriteEntity = #59;
|
||||
void(vector where, float set) multicast = #82; // sends the temp message to a set
|
||||
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) WriteChar = #53;
|
||||
void (float to, float f) WriteShort = #54;
|
||||
void (float to, float f) WriteLong = #55;
|
||||
void (float to, float f) WriteCoord = #56;
|
||||
void (float to, float f) WriteAngle = #57;
|
||||
void (float to, string s) WriteString = #58;
|
||||
void (float to, entity s) WriteEntity = #59;
|
||||
void (vector where, float set) multicast = #82; // sends the temp message to a set
|
||||
|
||||
void(entity e) BUILTIN_makestatic = #69;
|
||||
void(string s) changelevel = #70;
|
||||
void (entity e) BUILTIN_makestatic = #69;
|
||||
void (string s) changelevel = #70;
|
||||
|
||||
|
||||
void(vector pos, string samp, float vol, float atten) BUILTIN_ambientsound = #74;
|
||||
void (vector pos, string samp, float vol, float atten) BUILTIN_ambientsound = #74;
|
||||
|
||||
void(entity e) setspawnparms = #78; // set parm1... to the
|
||||
void (entity e) setspawnparms = #78; // set parm1... to the
|
||||
// values at level start
|
||||
// for coop respawn
|
||||
|
||||
void(entity killer, entity killee) logfrag = #79; // add to stats
|
||||
void (entity killer, entity killee) logfrag = #79; // add to stats
|
||||
|
|
|
@ -33,73 +33,81 @@ float cl_rollangle, cl_rollspeed;
|
|||
|
||||
#define SV_FRAMES_BEFORE_SPAWN 3
|
||||
|
||||
void() main = {
|
||||
void ()
|
||||
main =
|
||||
{
|
||||
local entity walk;
|
||||
|
||||
/* Must be first. */
|
||||
max_clients = 0;
|
||||
walk = world;
|
||||
while ((walk = nextent(walk))) max_clients++;
|
||||
while ((walk = nextent(walk)))
|
||||
max_clients++;
|
||||
|
||||
sv_spawning = SV_FRAMES_BEFORE_SPAWN;
|
||||
|
||||
damage_init();
|
||||
bodyque_init();
|
||||
weapon_init();
|
||||
client_init();
|
||||
SZ_init();
|
||||
damage_init ();
|
||||
bodyque_init ();
|
||||
weapon_init ();
|
||||
client_init ();
|
||||
SZ_init ();
|
||||
|
||||
mdl_player_init();
|
||||
mdl_eyes_init();
|
||||
mdl_player_init ();
|
||||
mdl_eyes_init ();
|
||||
|
||||
act_player_init();
|
||||
act_player_init ();
|
||||
};
|
||||
|
||||
float players_frame_started;
|
||||
void() StartFrame = {
|
||||
void ()
|
||||
StartFrame =
|
||||
{
|
||||
if (sv_spawning) {
|
||||
sv_spawning = sv_spawning - 1;
|
||||
sv_spawning--;
|
||||
if (!sv_spawning) {
|
||||
if (!intermission_head)
|
||||
intermission_head = spawn_head;
|
||||
|
||||
if (!spawn_head)
|
||||
error("Unable to find a spawn point.\n");
|
||||
error ("Unable to find a spawn point.\n");
|
||||
}
|
||||
}
|
||||
|
||||
SZ_frame();
|
||||
SZ_frame ();
|
||||
|
||||
rocket_jump = stof(infokey(world, "rj"));
|
||||
if (rocket_jump <= 1) rocket_jump = 0;
|
||||
rocket_jump = stof (infokey (world, "rj"));
|
||||
if (rocket_jump <= 1)
|
||||
rocket_jump = 0;
|
||||
|
||||
sv_mintic = cvar("sv_mintic");
|
||||
sv_maxtic = cvar("sv_maxtic");
|
||||
sv_mintic = cvar ("sv_mintic");
|
||||
sv_maxtic = cvar ("sv_maxtic");
|
||||
|
||||
sv_gravity = cvar("sv_gravity");
|
||||
sv_gravity = cvar ("sv_gravity");
|
||||
|
||||
sv_stopspeed = cvar("sv_stopspeed");
|
||||
sv_maxspeed = cvar("sv_maxspeed");
|
||||
sv_spectatormaxspeed = cvar("sv_spectatormaxspeed");
|
||||
sv_stopspeed = cvar ("sv_stopspeed");
|
||||
sv_maxspeed = cvar ("sv_maxspeed");
|
||||
sv_spectatormaxspeed = cvar ("sv_spectatormaxspeed");
|
||||
|
||||
sv_accelerate = cvar("sv_accelerate");
|
||||
sv_airaccelerate = cvar("sv_airaccelerate");
|
||||
sv_wateraccelerate = cvar("sv_wateraccelerate");
|
||||
sv_accelerate = cvar ("sv_accelerate");
|
||||
sv_airaccelerate = cvar ("sv_airaccelerate");
|
||||
sv_wateraccelerate = cvar ("sv_wateraccelerate");
|
||||
|
||||
sv_friction = cvar("sv_friction");
|
||||
sv_waterfriction = cvar("sv_waterfriction");
|
||||
sv_friction = cvar ("sv_friction");
|
||||
sv_waterfriction = cvar ("sv_waterfriction");
|
||||
|
||||
cl_rollangle = cvar("cl_rollangle");
|
||||
cl_rollspeed = cvar("cl_rollspeed");
|
||||
cl_rollangle = cvar ("cl_rollangle");
|
||||
cl_rollspeed = cvar ("cl_rollspeed");
|
||||
|
||||
PlayerStartFrame();
|
||||
PlayerStartFrame ();
|
||||
players_frame_started = -1;
|
||||
};
|
||||
|
||||
/* This is really called by QSG engines */
|
||||
// void() EndFrame = { };
|
||||
// void () EndFrame = {};
|
||||
|
||||
void() PlayerStartFrame = {
|
||||
void ()
|
||||
PlayerStartFrame =
|
||||
{
|
||||
if (players_frame_started == -1) {
|
||||
/* First player after StartFrame */
|
||||
players_frame_started = TRUE;
|
||||
|
@ -111,17 +119,19 @@ void() PlayerStartFrame = {
|
|||
|
||||
players_frame_started = TRUE;
|
||||
|
||||
delays_swapin_stats_all();
|
||||
delays_swapin_stats_all ();
|
||||
};
|
||||
|
||||
void() PlayerEndFrame = {
|
||||
void ()
|
||||
PlayerEndFrame =
|
||||
{
|
||||
/* Unfortunately, a newmis can us damage this frame,
|
||||
after our postthink has been called. Damn. */
|
||||
/* We just force an update this frame for now. */
|
||||
if (newmis) {
|
||||
delays_force_update_all();
|
||||
delays_force_update_all ();
|
||||
} else {
|
||||
players_frame_started = FALSE;
|
||||
delays_swapout_stats_all();
|
||||
delays_swapout_stats_all ();
|
||||
}
|
||||
};
|
||||
|
|
|
@ -2,26 +2,24 @@
|
|||
#define SERVER_qh 1
|
||||
|
||||
@extern {
|
||||
float max_clients;
|
||||
|
||||
float max_clients;
|
||||
// Various cvars [possibly] referenced by QC
|
||||
float rocket_jump;
|
||||
|
||||
// Various cvars [possibly] referenced by QC
|
||||
float rocket_jump;
|
||||
float sv_mintic, sv_maxtic;
|
||||
|
||||
float sv_mintic, sv_maxtic;
|
||||
float sv_gravity;
|
||||
float sv_stopspeed, sv_maxspeed, sv_spectatormaxspeed;
|
||||
float sv_accelerate, sv_airaccelerate, sv_wateraccelerate;
|
||||
float sv_friction, sv_waterfriction;
|
||||
|
||||
float sv_gravity;
|
||||
float sv_stopspeed, sv_maxspeed, sv_spectatormaxspeed;
|
||||
float sv_accelerate, sv_airaccelerate, sv_wateraccelerate;
|
||||
float sv_friction, sv_waterfriction;
|
||||
float cl_rollangle, cl_rollspeed;
|
||||
|
||||
float cl_rollangle, cl_rollspeed;
|
||||
|
||||
void() StartFrame;
|
||||
|
||||
void() PlayerStartFrame;
|
||||
void() PlayerEndFrame;
|
||||
void () StartFrame;
|
||||
|
||||
void () PlayerStartFrame;
|
||||
void () PlayerEndFrame;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,16 +1,22 @@
|
|||
#include "common.qh"
|
||||
|
||||
// Called when a spectator connects
|
||||
void() SpectatorConnect = {
|
||||
bprint(PRINT_MEDIUM, "Spectator ", self.netname, " entered the game.\n");
|
||||
void ()
|
||||
SpectatorConnect =
|
||||
{
|
||||
bprint (PRINT_MEDIUM, "Spectator ", self.netname, " entered the game.\n");
|
||||
};
|
||||
|
||||
// Called when a spectator disconnects
|
||||
void() SpectatorDisconnect = {
|
||||
bprint(PRINT_MEDIUM, "Spectator ", self.netname, " left the game.\n");
|
||||
void ()
|
||||
SpectatorDisconnect =
|
||||
{
|
||||
bprint (PRINT_MEDIUM, "Spectator ", self.netname, " left the game.\n");
|
||||
};
|
||||
|
||||
// Called around the same time as player thinks?
|
||||
void() SpectatorThink = {
|
||||
void ()
|
||||
SpectatorThink =
|
||||
{
|
||||
self.impulse = 0;
|
||||
};
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
void() NOTHING_function = {};
|
||||
void () NOTHING_function = {};
|
||||
|
||||
// ========================================================================== //
|
||||
// ========================================================================== //
|
||||
// ========================================================================= //
|
||||
// ========================================================================= //
|
||||
|
||||
/* Fields in maps */
|
||||
|
||||
|
@ -43,8 +43,8 @@ void() NOTHING_function = {};
|
|||
.string noise5, noise6; // can't activate, can activate.
|
||||
.string noise7; // for items, respawn
|
||||
|
||||
// ========================================================================== //
|
||||
// ========================================================================== //
|
||||
// ========================================================================= //
|
||||
// ========================================================================= //
|
||||
|
||||
#if 0
|
||||
// used by QSG engines
|
||||
|
@ -61,8 +61,8 @@ void() NOTHING_function = {};
|
|||
.float gravity; // Gravity Multiplier (0 to 1.0)
|
||||
.float maxspeed; // Used to set Maxspeed on a player
|
||||
|
||||
// ========================================================================== //
|
||||
// ========================================================================== //
|
||||
// ========================================================================= //
|
||||
// ========================================================================= //
|
||||
|
||||
.float mass; // for projectile collisions
|
||||
|
||||
|
@ -79,5 +79,5 @@ void() NOTHING_function = {};
|
|||
.float water_finished; // swim sound
|
||||
.float pain_finished; // pain sound
|
||||
|
||||
// ========================================================================== //
|
||||
// ========================================================================== //
|
||||
// ========================================================================= //
|
||||
// ========================================================================= //
|
||||
|
|
|
@ -5,21 +5,27 @@
|
|||
#include "misc.qh"
|
||||
#include "teleport.qh"
|
||||
|
||||
.float(vector org) th_teleport;
|
||||
.float (vector org) th_teleport;
|
||||
|
||||
void() _deathmsg_teleport = {
|
||||
void ()
|
||||
_deathmsg_teleport =
|
||||
{
|
||||
local string att_nname, def_nname;
|
||||
|
||||
def_nname = name(self);
|
||||
att_nname = name(self.dmg_attacker);
|
||||
def_nname = name (self);
|
||||
att_nname = name (self.dmg_attacker);
|
||||
|
||||
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
|
||||
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)
|
||||
return;
|
||||
|
||||
|
@ -33,17 +39,20 @@ void() _teleport_death_touch = {
|
|||
ghost_inflictor.speed = 1000;
|
||||
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;
|
||||
|
||||
death = spawn("TELEDEATH");
|
||||
death = spawn ("TELEDEATH");
|
||||
death.owner = death_owner;
|
||||
death.solid = SOLID_TRIGGER;
|
||||
setsize(death, death_owner.mins - '1 1 1', death_owner.maxs + '1 1 1');
|
||||
setorigin(death, org);
|
||||
setsize (death, death_owner.mins - '1 1 1', death_owner.maxs + '1 1 1');
|
||||
setorigin (death, org);
|
||||
|
||||
death.touch = _teleport_death_touch;
|
||||
|
||||
|
@ -53,7 +62,9 @@ void(vector org, entity death_owner) _teleport_death_spawn = {
|
|||
force_retouch = 2;
|
||||
};
|
||||
|
||||
void(entity e, entity spot) teleport = {
|
||||
void (entity e, entity spot)
|
||||
teleport =
|
||||
{
|
||||
local float spd;
|
||||
|
||||
if (e.th_teleport) {
|
||||
|
@ -66,7 +77,7 @@ void(entity e, entity spot) teleport = {
|
|||
self = e;
|
||||
other = spot;
|
||||
|
||||
do_teleport = self.th_teleport(other.origin);
|
||||
do_teleport = self.th_teleport (other.origin);
|
||||
|
||||
self = oldself;
|
||||
other = oldother;
|
||||
|
@ -75,20 +86,20 @@ void(entity e, entity spot) teleport = {
|
|||
return;
|
||||
}
|
||||
|
||||
spd = vlen(e.velocity);
|
||||
spd = vlen (e.velocity);
|
||||
if (spd < 200)
|
||||
spd = 200;
|
||||
|
||||
setorigin(e, spot.origin);
|
||||
setorigin (e, spot.origin);
|
||||
e.angles = spot.angles;
|
||||
e.fixangle = TRUE;
|
||||
e.teleport_time = 0.1;
|
||||
|
||||
makevectors(e.angles);
|
||||
makevectors (e.angles);
|
||||
e.velocity = v_forward*spd;
|
||||
|
||||
if (is_living(e))
|
||||
_teleport_death_spawn(spot.origin, e);
|
||||
if (is_living (e))
|
||||
_teleport_death_spawn (spot.origin, e);
|
||||
|
||||
effect_teleport_fog(spot.origin);
|
||||
effect_teleport_fog (spot.origin);
|
||||
};
|
||||
|
|
|
@ -2,11 +2,9 @@
|
|||
#define TELEPORT_qh 1
|
||||
|
||||
@extern {
|
||||
.float(vector org) th_teleport;
|
||||
|
||||
.float(vector org) th_teleport;
|
||||
|
||||
void(entity e, entity spot) teleport;
|
||||
|
||||
void (entity e, entity spot) teleport;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -6,48 +6,62 @@
|
|||
|
||||
#include "effect.qh"
|
||||
|
||||
void() _w_axe_deathmsg = {
|
||||
void ()
|
||||
_w_axe_deathmsg =
|
||||
{
|
||||
local float r;
|
||||
local string att_nname, def_nname;
|
||||
|
||||
r = random();
|
||||
r = random ();
|
||||
|
||||
def_nname = name(self);
|
||||
att_nname = name(self.dmg_attacker);
|
||||
def_nname = name (self);
|
||||
att_nname = name (self.dmg_attacker);
|
||||
|
||||
if (r < 0.25) bprint(PRINT_DEATH, def_nname, " gets chopped down to size by ", att_nname, ".\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");
|
||||
if (r < 0.25)
|
||||
bprint (PRINT_DEATH, def_nname, " gets chopped down to size by ",
|
||||
att_nname, ".\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;
|
||||
|
||||
source = shootorigin(self);
|
||||
source = shootorigin (self);
|
||||
|
||||
makevectors (self.v_angle);
|
||||
traceline (source, source + v_forward*64, FALSE, self);
|
||||
traceline (source, source + v_forward * 64, FALSE, self);
|
||||
if (trace_fraction == 1.0)
|
||||
return;
|
||||
|
||||
ghost_inflictor.classname = "AXE";
|
||||
ghost_inflictor.dmg = 20;
|
||||
ghost_inflictor.mass = ghost_inflictor.mass * 8;
|
||||
ghost_inflictor.velocity = v_forward*1000;
|
||||
ghost_inflictor.velocity = v_forward * 1000;
|
||||
|
||||
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. */
|
||||
sound(self, CHAN_WEAPON, "player/axhit2.wav", 1, ATTN_NORM);
|
||||
effect_gun_spark(trace_endpos, v_forward * 250, 3);
|
||||
sound (self, CHAN_WEAPON, "player/axhit2.wav", 1, ATTN_NORM);
|
||||
effect_gun_spark (trace_endpos, v_forward * 250, 3);
|
||||
}
|
||||
};
|
||||
|
||||
void() _w_axe_think_1 = {
|
||||
self.weaponframe = self.weaponframe + 1;
|
||||
void ()
|
||||
_w_axe_think_1 =
|
||||
{
|
||||
self.weaponframe++;
|
||||
if (self.weaponframe == 3)
|
||||
_w_axe_fire();
|
||||
if (self.weaponframe <= 1 || self.weaponframe > 4) {
|
||||
|
@ -56,8 +70,10 @@ void() _w_axe_think_1 = {
|
|||
}
|
||||
};
|
||||
|
||||
void() _w_axe_think_2 = {
|
||||
self.weaponframe = self.weaponframe + 1;
|
||||
void ()
|
||||
_w_axe_think_2 =
|
||||
{
|
||||
self.weaponframe++;
|
||||
if (self.weaponframe == 7)
|
||||
_w_axe_fire();
|
||||
if (self.weaponframe <= 5 || self.weaponframe > 8) {
|
||||
|
@ -67,15 +83,17 @@ void() _w_axe_think_2 = {
|
|||
};
|
||||
|
||||
/* WEAPON 1 axe */
|
||||
float(float action)
|
||||
w_axe = {
|
||||
if (action == WEAPON_AMMO) {
|
||||
float (float action)
|
||||
w_axe =
|
||||
{
|
||||
switch (action) {
|
||||
case WEAPON_AMMO:
|
||||
return 0;
|
||||
} else if (action == WEAPON_WEIGHT) {
|
||||
case WEAPON_WEIGHT:
|
||||
return 1;
|
||||
} else if (action == WEAPON_SELECTABLE) {
|
||||
case WEAPON_SELECTABLE:
|
||||
return TRUE;
|
||||
} else if (action == WEAPON_FIRE) {
|
||||
case WEAPON_FIRE:
|
||||
self.attack_finished = time + 0.5;
|
||||
sound (self, CHAN_WEAPON, "weapons/ax1.wav", 1, ATTN_NORM);
|
||||
|
||||
|
@ -88,18 +106,20 @@ w_axe = {
|
|||
}
|
||||
self.w_thought = TRUE;
|
||||
|
||||
self.mdl_func(MDL_FUNC_FIRE, 0);
|
||||
} else if (action == WEAPON_SELECT) {
|
||||
self.mdl_func (MDL_FUNC_FIRE, 0);
|
||||
break;
|
||||
case WEAPON_SELECT:
|
||||
self.weaponmodel = "progs/v_axe.mdl";
|
||||
self.weaponframe = 0;
|
||||
self.mdl_mod = (self.mdl_mod & ~MDL_MOD_WEP_MASK) | MDL_MOD_WEP_AXE;
|
||||
|
||||
weaponprint("Axe");
|
||||
} else if (action == WEAPON_INIT) {
|
||||
precache_model("progs/v_axe.mdl");
|
||||
precache_sound("player/axhit1.wav");
|
||||
precache_sound("player/axhit2.wav");
|
||||
precache_sound("weapons/ax1.wav");
|
||||
weaponprint ("Axe");
|
||||
break;
|
||||
case WEAPON_INIT:
|
||||
precache_model ("progs/v_axe.mdl");
|
||||
precache_sound ("player/axhit1.wav");
|
||||
precache_sound ("player/axhit2.wav");
|
||||
precache_sound ("weapons/ax1.wav");
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -1,57 +1,59 @@
|
|||
#include "common.qh"
|
||||
|
||||
void() worldspawn = {
|
||||
void ()
|
||||
worldspawn =
|
||||
{
|
||||
/* These are used be the server C code, but not precached. Bad iD. */
|
||||
precache_sound("misc/h2ohit1.wav");
|
||||
precache_sound("demon/dland2.wav");
|
||||
precache_sound("misc/r_tele1.wav");
|
||||
precache_sound("misc/r_tele2.wav");
|
||||
precache_sound("misc/r_tele3.wav");
|
||||
precache_sound("misc/r_tele4.wav");
|
||||
precache_sound("misc/r_tele5.wav");
|
||||
precache_sound ("misc/h2ohit1.wav");
|
||||
precache_sound ("demon/dland2.wav");
|
||||
precache_sound ("misc/r_tele1.wav");
|
||||
precache_sound ("misc/r_tele2.wav");
|
||||
precache_sound ("misc/r_tele3.wav");
|
||||
precache_sound ("misc/r_tele4.wav");
|
||||
precache_sound ("misc/r_tele5.wav");
|
||||
|
||||
/* Compatibility :) */
|
||||
if (self.model == "maps/e1m8.bsp")
|
||||
cvar_set("sv_gravity", "100");
|
||||
cvar_set ("sv_gravity", "100");
|
||||
|
||||
// Setup light animation tables. 'a' is total darkness, 'z' is maxbright.
|
||||
// 0 normal
|
||||
lightstyle(0, "m");
|
||||
lightstyle (0, "m");
|
||||
|
||||
// 1 FLICKER (first variety)
|
||||
lightstyle(1, "mmnmmommommnonmmonqnmmo");
|
||||
lightstyle (1, "mmnmmommommnonmmonqnmmo");
|
||||
|
||||
// 2 SLOW STRONG PULSE
|
||||
lightstyle(2, "abcdefghijklmnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba");
|
||||
lightstyle (2, "abcdefghijklmnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba");
|
||||
|
||||
// 3 CANDLE (first variety)
|
||||
lightstyle(3, "mmmmmaaaaammmmmaaaaaabcdefgabcdefg");
|
||||
lightstyle (3, "mmmmmaaaaammmmmaaaaaabcdefgabcdefg");
|
||||
|
||||
// 4 FAST STROBE
|
||||
lightstyle(4, "ma");
|
||||
lightstyle (4, "ma");
|
||||
|
||||
// 5 GENTLE PULSE 1
|
||||
lightstyle(5,"jklmnopqrstuvwxyzyxwvutsrqponmlkj");
|
||||
lightstyle (5,"jklmnopqrstuvwxyzyxwvutsrqponmlkj");
|
||||
|
||||
// 6 FLICKER (second variety)
|
||||
lightstyle(6, "nmonqnmomnmomomno");
|
||||
lightstyle (6, "nmonqnmomnmomomno");
|
||||
|
||||
// 7 CANDLE (second variety)
|
||||
lightstyle(7, "mmmaaaabcdefgmmmmaaaammmaamm");
|
||||
lightstyle (7, "mmmaaaabcdefgmmmmaaaammmaamm");
|
||||
|
||||
// 8 CANDLE (third variety)
|
||||
lightstyle(8, "mmmaaammmaaammmabcdefaaaammmmabcdefmmmaaaa");
|
||||
lightstyle (8, "mmmaaammmaaammmabcdefaaaammmmabcdefmmmaaaa");
|
||||
|
||||
// 9 SLOW STROBE (fourth variety)
|
||||
lightstyle(9, "aaaaaaaazzzzzzzz");
|
||||
lightstyle (9, "aaaaaaaazzzzzzzz");
|
||||
|
||||
// 10 FLUORESCENT FLICKER
|
||||
lightstyle(10, "mmamammmmammamamaaamammma");
|
||||
lightstyle (10, "mmamammmmammamamaaamammma");
|
||||
|
||||
// 11 SLOW PULSE NOT FADE TO BLACK
|
||||
lightstyle(11, "abcdefghijklmnopqrrqponmlkjihgfedcba");
|
||||
lightstyle (11, "abcdefghijklmnopqrrqponmlkjihgfedcba");
|
||||
|
||||
// styles 32-62 are assigned by the light program for switchable lights
|
||||
|
||||
main();
|
||||
main ();
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue