Update 4 QuakeC

This commit is contained in:
Mike Rubits 2022-08-17 16:53:34 -05:00
parent 4a992dc9a3
commit bebf782915
25 changed files with 13236 additions and 1 deletions

View file

@ -1,6 +1,6 @@
# Quake Rerelease QuakeC Source Code
This repository contains the QuakeC source code for the four codebases that were used in the 2021 re-release of Quake: the base campaign, Scourge of Armagon, Dissolution of Eternity, and Dimension of the Machine. Dimension of the Past shares the same codebase as Dimension of the Machine.
This repository contains the QuakeC source code for the five codebases that were used in the 2021 re-release of Quake: the base campaign, Scourge of Armagon, Dissolution of Eternity, Dimension of the Machine, and Capture the Flag. Dimension of the Past shares the same codebase as Dimension of the Machine.
In comparison with the original QuakeC, these codebases have been updated to replace all instances of strings with placeholder strings that can be used for localization. This requires some support on the engine side in order to handle printing messages correctly. There have also been bug fixes and modifications to behaviors from the original game.

54
quakec_ctf/bots/bot.qc Normal file
View file

@ -0,0 +1,54 @@
/* Copyright (C) 1996-2022 id Software LLC
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
See file, 'COPYING', for details.
*/
/*
========================
Bot_PreThink
Called by the engine every frame before running the bots update in C++
NOTE: "self" will be the calling bot
Example usages of this function:
1. Telling bots what to do or where to go ( i.e. setting a high level goal ).
2. Modifying properties on the bot player ( or other players in-game ) that the bots can see/use doing their update.
========================
*/
void Bot_PreThink() {
// add your code here!
};
/*
========================
Bot_PostThink
Called by the engine every frame after running the bots update in C++
NOTE: "self" will be the calling bot
Example usages of this function:
1. Overriding/modifying bot user cmds.
2. Overriding/modifying bot player properties.
========================
*/
void Bot_PostThink() {
// add your code here!
};

160
quakec_ctf/buttons.qc Normal file
View file

@ -0,0 +1,160 @@
/* Copyright (C) 1996-2022 id Software LLC
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
See file, 'COPYING', for details.
*/
// button and multiple button
void() button_wait;
void() button_return;
void() button_wait =
{
self.state = STATE_TOP;
self.nextthink = self.ltime + self.wait;
self.think = button_return;
activator = self.enemy;
SUB_UseTargets();
self.frame = 1; // use alternate textures
};
void() button_done =
{
self.state = STATE_BOTTOM;
};
void() button_return =
{
self.state = STATE_DOWN;
SUB_CalcMove (self.pos1, self.speed, button_done);
self.frame = 0; // use normal textures
if (self.health)
self.takedamage = DAMAGE_YES; // can be shot again
};
void() button_blocked =
{ // do nothing, just don't ome all the way back out
};
void() button_fire =
{
if (self.state == STATE_UP || self.state == STATE_TOP)
return;
sound (self, CHAN_VOICE, self.noise, 1, ATTN_NORM);
self.state = STATE_UP;
SUB_CalcMove (self.pos2, self.speed, button_wait);
};
void() button_use =
{
self.enemy = activator;
button_fire ();
};
void() button_touch =
{
if (other.classname != "player" || other.observer)
return;
self.enemy = other;
button_fire ();
};
void() button_killed =
{
self.enemy = damage_attacker;
self.health = self.max_health;
self.takedamage = DAMAGE_NO; // wil be reset upon return
button_fire ();
};
/*QUAKED func_button (0 .5 .8) ?
When a button is touched, it moves some distance in the direction of it's angle, triggers all of it's targets, waits some time, then returns to it's original position where it can be triggered again.
"angle" determines the opening direction
"target" all entities with a matching targetname will be used
"speed" override the default 40 speed
"wait" override the default 1 second wait (-1 = never return)
"lip" override the default 4 pixel lip remaining at end of move
"health" if set, the button must be killed instead of touched
"sounds"
0) steam metal
1) wooden clunk
2) metallic click
3) in-out
*/
void() func_button =
{
local float gtemp, ftemp;
if (self.sounds == 0)
{
precache_sound ("buttons/airbut1.wav");
self.noise = "buttons/airbut1.wav";
}
if (self.sounds == 1)
{
precache_sound ("buttons/switch21.wav");
self.noise = "buttons/switch21.wav";
}
if (self.sounds == 2)
{
precache_sound ("buttons/switch02.wav");
self.noise = "buttons/switch02.wav";
}
if (self.sounds == 3)
{
precache_sound ("buttons/switch04.wav");
self.noise = "buttons/switch04.wav";
}
SetMovedir ();
self.movetype = MOVETYPE_PUSH;
self.solid = SOLID_BSP;
setmodel (self, self.model);
self.blocked = button_blocked;
self.use = button_use;
if (self.health)
{
self.max_health = self.health;
self.th_die = button_killed;
self.takedamage = DAMAGE_YES;
}
else
self.touch = button_touch;
if (!self.speed)
self.speed = 40;
if (!self.wait)
self.wait = 1;
if (!self.lip)
self.lip = 4;
self.state = STATE_BOTTOM;
self.pos1 = self.origin;
self.pos2 = self.pos1 + self.movedir*(fabs(self.movedir*self.size) - self.lip);
};

1848
quakec_ctf/client.qc Normal file

File diff suppressed because it is too large Load diff

324
quakec_ctf/combat.qc Normal file
View file

@ -0,0 +1,324 @@
/* Copyright (C) 1996-2022 id Software LLC
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
See file, 'COPYING', for details.
*/
void() T_MissileTouch;
void() info_player_start;
void(entity targ, entity attacker) ClientObituary;
void(entity who) ResistanceSound;
//============================================================================
/*
============
CanDamage
Returns true if the inflictor can directly damage the target. Used for
explosions and melee attacks.
============
*/
float(entity targ, entity inflictor) CanDamage =
{
// bmodels need special checking because their origin is 0,0,0
if (targ.movetype == MOVETYPE_PUSH)
{
traceline(inflictor.origin, 0.5 * (targ.absmin + targ.absmax), TRUE, self);
if (trace_fraction == 1)
return TRUE;
if (trace_ent == targ)
return TRUE;
return FALSE;
}
traceline(inflictor.origin, targ.origin, TRUE, self);
if (trace_fraction == 1)
return TRUE;
traceline(inflictor.origin, targ.origin + '15 15 0', TRUE, self);
if (trace_fraction == 1)
return TRUE;
traceline(inflictor.origin, targ.origin + '-15 -15 0', TRUE, self);
if (trace_fraction == 1)
return TRUE;
traceline(inflictor.origin, targ.origin + '-15 15 0', TRUE, self);
if (trace_fraction == 1)
return TRUE;
traceline(inflictor.origin, targ.origin + '15 -15 0', TRUE, self);
if (trace_fraction == 1)
return TRUE;
return FALSE;
};
/*
============
Killed
============
*/
void(entity targ, entity attacker) Killed =
{
local entity oself;
oself = self;
self = targ;
if (self.health < -99)
self.health = -99; // don't let sbar look bad if a player
if (self.movetype == MOVETYPE_PUSH || self.movetype == MOVETYPE_NONE)
{ // doors, triggers, etc
self.th_die ();
self = oself;
return;
}
self.enemy = attacker;
// bump the monster counter
if (self.flags & FL_MONSTER)
{
killed_monsters = killed_monsters + 1;
WriteByte (MSG_ALL, SVC_KILLEDMONSTER);
}
ClientObituary(self, attacker);
self.takedamage = DAMAGE_NO;
self.touch = SUB_Null;
// removed monsters
// monster_death_use();
self.th_die ();
self = oself;
};
// *TEAMPLAY*
// Prototypes
float(entity targ, entity inflictor, entity attacker, float damage) TeamArmorDam;
float(entity targ, entity inflictor, entity attacker, float damage) TeamHealthDam;
/*
============
T_Damage
The damage is coming from inflictor, but get mad at attacker
This should be the only function that ever reduces health.
============
*/
void(entity targ, entity inflictor, entity attacker, float damage) T_Damage=
{
local vector dir;
local entity oldself;
local float save;
local float take;
if (!targ.takedamage)
return;
// used by buttons and triggers to set activator for target firing
damage_attacker = attacker;
// check for quad damage powerup on the attacker
if (attacker.super_damage_finished > time)
damage = damage * 4;
// RUNE: check for double damage for rune of Black Magic powerup
if (attacker.player_flag & ITEM_RUNE2_FLAG)
damage = damage * 2;
// RUNE
//RUNE check if target has rune of Earth Magic (half damage)
if (targ.player_flag & ITEM_RUNE1_FLAG) {
damage = damage / 2;
ResistanceSound(targ);
}
//RUNE
// *XXX* EXPERT CTF mark players who hurt the flag carrier, so they
// are worth more points for a while.
if ( (attacker.classname == "player") && // attacker must be a player
(targ.player_flag & ITEM_ENEMY_FLAG) && // target is a flag carrier
(attacker.lastteam != targ.lastteam) && // target and attacker on diff teams
(targ.lastteam > 0) ) // unconnected check?
attacker.last_hurt_carrier = time;
// save damage based on the target's armor level
// *TEAMPLAY*
// TeamArmorDam returns true iff the attacker can damage the target's armor
if (TeamArmorDam(targ, inflictor, attacker, damage))
save = ceil(targ.armortype*damage);
else
save = 0;
if (save >= targ.armorvalue)
{
save = targ.armorvalue;
targ.armortype = 0; // lost all armor
targ.items = targ.items - (targ.items & (IT_ARMOR1 | IT_ARMOR2 | IT_ARMOR3));
}
targ.armorvalue = targ.armorvalue - save;
take = ceil(damage-save);
// add to the damage total for clients, which will be sent as a single
// message at the end of the frame
// FIXME: remove after combining shotgun blasts?
if (targ.flags & FL_CLIENT)
{
targ.dmg_take = targ.dmg_take + take;
targ.dmg_save = targ.dmg_save + save;
targ.dmg_inflictor = inflictor;
}
// figure momentum add
if ( (inflictor != world) && (targ.movetype == MOVETYPE_WALK) )
{
dir = targ.origin - (inflictor.absmin + inflictor.absmax) * 0.5;
dir = normalize(dir);
targ.velocity = targ.velocity + dir*damage*8;
}
// check for godmode or invincibility
if (targ.team == targ.lastteam) { // 666 or god mode doesn't save ya
if (targ.flags & FL_GODMODE)
return;
if (targ.invincible_finished >= time)
{
if (self.invincible_sound < time)
{
sound (targ, CHAN_ITEM, "items/protect3.wav", 1, ATTN_NORM);
self.invincible_sound = time + 2;
}
return;
}
}
// team play damage avoidance
if ( (teamplay == 1) && (targ.team > 0)&&(targ.team == attacker.team) )
return;
// *TEAMPLAY*
// TeamHealthDam will return true if the attacker can damage the target's
// health
if (!TeamHealthDam(targ, inflictor, attacker, damage))
return;
// do the damage
targ.health = targ.health - take;
if (targ.health <= 0)
{
Killed (targ, attacker);
return;
}
// react to the damage
oldself = self;
self = targ;
if (self.th_pain)
self.th_pain (attacker, take);
self = oldself;
};
/*
============
T_RadiusDamage
============
*/
void(entity inflictor, entity attacker, float damage, entity ignore) T_RadiusDamage =
{
local float points;
local entity head;
local vector org;
head = findradius(inflictor.origin, damage+40);
while (head)
{
if (head != ignore)
{
if (head.takedamage)
{
org = head.origin + (head.mins + head.maxs)*0.5;
points = 0.5*vlen (inflictor.origin - org);
if (points < 0)
points = 0;
points = damage - points;
if (head == attacker)
points = points * 0.5;
if (points > 0)
{
if (CanDamage (head, inflictor))
{ // shambler takes half damage from all explosions
if (head.classname == "monster_shambler")
T_Damage (head, inflictor, attacker, points*0.5);
else
T_Damage (head, inflictor, attacker, points);
}
}
}
}
head = head.chain;
}
};
/*
============
T_BeamDamage
============
*/
void(entity attacker, float damage) T_BeamDamage =
{
local float points;
local entity head;
head = findradius(attacker.origin, damage+40);
while (head)
{
if (head.takedamage)
{
points = 0.5*vlen (attacker.origin - head.origin);
if (points < 0)
points = 0;
points = damage - points;
if (head == attacker)
points = points * 0.5;
if (points > 0)
{
if (CanDamage (head, attacker))
{
if (head.classname == "monster_shambler")
T_Damage (head, attacker, attacker, points*0.5);
else
T_Damage (head, attacker, attacker, points);
}
}
}
head = head.chain;
}
};

153
quakec_ctf/ctfgame.qc Normal file
View file

@ -0,0 +1,153 @@
/* Copyright (C) 1996-2022 id Software LLC
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
See file, 'COPYING', for details.
*/
float VOTEEXIT_TIME_LIMIT = 60; // 60 seconds after first vote
float voteexit_time;
entity vote_leader; // current leader
entity lastvotespawn;
void(vector org) spawn_tfog;
void(vector org, entity death_owner) spawn_tdeath;
void() InitTrigger;
/*QUAKED info_vote_destination (.5 .5 .5) (-8 -8 -8) (8 8 32)
This is the destination marker for a voteexit. It should have a "targetname"
field with the same value as a voteexit's "target" field.
*/
void() info_vote_destination =
{
// this does nothing, just serves as a target spot
self.mangle = self.angles;
self.angles = '0 0 0';
self.model = "";
self.origin = self.origin + '0 0 27';
if (!self.targetname)
objerror ("no targetname");
};
void() voteexit_teleport =
{
local entity t;
local vector org;
// put a tfog where the player was
spawn_tfog (other.origin);
t = find (world, targetname, self.target);
if (!t)
objerror ("couldn't find target");
// spawn a tfog flash in front of the destination
makevectors (t.mangle);
org = t.origin + 32 * v_forward;
spawn_tfog (org);
spawn_tdeath(t.origin, other);
// move the player and lock him down for a little while
if (!other.health)
{
other.origin = t.origin;
other.velocity = (v_forward * other.velocity_x) + (v_forward * other.velocity_y);
return;
}
setorigin (other, t.origin);
other.angles = t.mangle;
other.fixangle = 1; // turn this way immediately
other.teleport_time = time + 0.7;
if (other.flags & FL_ONGROUND)
other.flags = other.flags - FL_ONGROUND;
other.velocity = v_forward * 300;
};
void() voteexit_touch =
{
local entity t;
if (other.classname != "player")
return;
// only teleport living creatures
if (other.health <= 0 || other.solid != SOLID_SLIDEBOX)
return;
if (other.voted) {
if (other.voted < time)
centerprint(other, "$qc_ctf_already_voted");
other.voted = time + 1;
voteexit_teleport();
return;
}
// non-zero for vote, time is when to display a 'you voted' msg
other.voted = time + 1;
SUB_UseTargets ();
bprint("$qc_ctf_has_voted", other.netname, self.message);
// ok, the player has voted for this exit
self.cnt = self.cnt + 1;
// find new leader
// we're on the start map, something special is happening
vote_leader = world;
t = find(world, classname, "trigger_voteexit");
while (t != world) {
if ((t.cnt > vote_leader.cnt) && (t != self))
vote_leader = t;
t = find(t, classname, "trigger_voteexit");
}
// if we are higher than the current leader, then we are the new
// leader, if we are same, half chance
if (self.cnt > vote_leader.cnt)
vote_leader = self;
else if ((self.cnt == vote_leader.cnt) && (random() > 0.5))
vote_leader = self;
// we check here about exit time
if (vote_leader != world && voteexit_time == 0)
voteexit_time = time + VOTEEXIT_TIME_LIMIT;
voteexit_teleport();
};
/*QUAKED trigger_voteexit (.5 .5 .5) ?
A merge of trigger_changelevel and trigger_teleport. A player touching
this this teleported just like a trigger_teleport, except this triggers
.cnt field gets incremented. This allows players to vote for their exit.
See status.qc for the display and total of the voting.
Any object touching this will be transported to the corresponding
info_vote_destination entity. You must set the "target" field, and
create an object with a "targetname" field that matches.
*/
void() trigger_voteexit =
{
local vector o;
InitTrigger ();
self.touch = voteexit_touch;
self.cnt = 0;
// find the destination
objerror ("no target");
};

889
quakec_ctf/defs.qc Normal file
View file

@ -0,0 +1,889 @@
/* Copyright (C) 1996-2022 id Software LLC
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
See file, 'COPYING', for details.
*/
/*
==============================================================================
SOURCE FOR GLOBALVARS_T C STRUCTURE
==============================================================================
*/
//
// system globals
//
entity self;
entity other;
entity world;
float time;
float frametime;
float force_retouch; // force all entities to touch triggers
// next frame. this is needed because
// non-moving things don't normally scan
// for triggers, and when a trigger is
// created (like a teleport trigger), it
// needs to catch everything.
// decremented each frame, so set to 2
// to guarantee everything is touched
string mapname;
float deathmatch;
float coop;
float teamplay;
float serverflags; // propagated from level to level, used to
// keep track of completed episodes
float total_secrets;
float total_monsters;
float found_secrets; // number of secrets found
float killed_monsters; // number of monsters killed
// spawnparms are used to encode information about clients across server
// level changes
float parm1, parm2, parm3, parm4, parm5, parm6, parm7, parm8, parm9, parm10, parm11, parm12, parm13, parm14, parm15, parm16;
//
// global variables set by built in functions
//
vector v_forward, v_up, v_right; // set by makevectors()
// set by traceline / tracebox
float trace_allsolid;
float trace_startsolid;
float trace_fraction;
vector trace_endpos;
vector trace_plane_normal;
float trace_plane_dist;
entity trace_ent;
float trace_inopen;
float trace_inwater;
entity msg_entity; // destination of single entity writes
//
// required prog functions
//
void() main; // only for testing
void() StartFrame;
void() PlayerPreThink;
void() PlayerPostThink;
void() ClientKill;
void() ClientConnect;
void() PutClientInServer; // call after setting the parm1... parms
void() ClientDisconnect;
void() SetNewParms; // called when a client first connects to
// a server. sets parms so they can be
// saved off for restarts
void() SetChangeParms; // call to set parms for self so they can
// be saved for a level transition
//================================================
void end_sys_globals; // flag for structure dumping
//================================================
/*
==============================================================================
SOURCE FOR ENTVARS_T C STRUCTURE
==============================================================================
*/
//
// system fields (*** = do not set in prog code, maintained by C code)
//
.float modelindex; // *** model index in the precached list
.vector absmin, absmax; // *** origin + mins / maxs
.float ltime; // local time for entity
.float movetype;
.float solid;
.vector origin; // ***
.vector oldorigin; // ***
.vector velocity;
.vector angles;
.vector avelocity;
.vector punchangle; // temp angle adjust from damage or recoil
.string classname; // spawn function
.string model;
.float frame;
.float skin;
.float effects;
.vector mins, maxs; // bounding box extents reletive to origin
.vector size; // maxs - mins
.void() touch;
.void() use;
.void() think;
.void() blocked; // for doors or plats, called when can't push other
.float nextthink;
.entity groundentity;
// stats
.float health;
.float frags;
.float weapon; // one of the IT_SHOTGUN, etc flags
.string weaponmodel;
.float weaponframe;
.float currentammo;
.float ammo_shells, ammo_nails, ammo_rockets, ammo_cells;
.float items; // bit flags
.float takedamage;
.entity chain;
.float deadflag;
.vector view_ofs; // add to origin to get eye point
.float button0; // fire
.float button1; // use
.float button2; // jump
.float impulse; // weapon changes
.float fixangle;
.vector v_angle; // view / targeting angle for players
.float idealpitch; // calculated pitch angle for lookup up slopes
.string netname;
.entity enemy;
.float flags;
.float colormap;
.float team;
.float max_health; // players maximum health is stored here
.float teleport_time; // don't back up
.float armortype; // save this fraction of incoming damage
.float armorvalue;
.float waterlevel; // 0 = not in, 1 = feet, 2 = waist, 3 = eyes
.float watertype; // a contents value
.float ideal_yaw;
.float yaw_speed;
.entity aiment;
.entity goalentity; // a movetarget or an enemy
.float spawnflags;
.string target;
.string targetname;
// damage is accumulated through a frame. and sent as one single
// message, so the super shotgun doesn't generate huge messages
.float dmg_take;
.float dmg_save;
.entity dmg_inflictor;
.entity owner; // who launched a missile
.vector movedir; // mostly for doors, but also used for waterjump
.string message; // trigger messages
.float sounds; // either a cd track number or sound number
.string noise, noise1, noise2, noise3; // contains names of wavs to play
//================================================
void end_sys_fields; // flag for structure dumping
//================================================
/*
==============================================================================
VARS NOT REFERENCED BY C CODE
==============================================================================
*/
//
// constants
//
float FALSE = 0;
float TRUE = 1;
// edict.flags
float FL_FLY = 1;
float FL_SWIM = 2;
float FL_CLIENT = 8; // set for all client edicts
float FL_INWATER = 16; // for enter / leave water splash
float FL_MONSTER = 32;
float FL_GODMODE = 64; // player cheat
float FL_NOTARGET = 128; // player cheat
float FL_ITEM = 256; // extra wide size for bonus items
float FL_ONGROUND = 512; // standing on something
float FL_PARTIALGROUND = 1024; // not all corners are valid
float FL_WATERJUMP = 2048; // player jumping out of water
float FL_JUMPRELEASED = 4096; // for jump debouncing
float FL_ISBOT = 8192; // mal: this will be set on bot players
float FL_NO_PLAYERS = 16384; // mal: used by the spawn point editor
float FL_NO_MONSTERS = 32768; // mal: used by the spawn point editor
float FL_NO_BOTS = 65536; // mal: any item marked with this will be ignored by bots.
float FL_OBJECTIVE = 131072; // mal: any item marked with this is an objective of some kind.
// edict.movetype values
float MOVETYPE_NONE = 0; // never moves
//float MOVETYPE_ANGLENOCLIP = 1;
//float MOVETYPE_ANGLECLIP = 2;
float MOVETYPE_WALK = 3; // players only
float MOVETYPE_STEP = 4; // discrete, not real time unless fall
float MOVETYPE_FLY = 5;
float MOVETYPE_TOSS = 6; // gravity
float MOVETYPE_PUSH = 7; // no clip to world, push and crush
float MOVETYPE_NOCLIP = 8;
float MOVETYPE_FLYMISSILE = 9; // fly with extra size against monsters
float MOVETYPE_BOUNCE = 10;
float MOVETYPE_GIB = 11; // like MOVETYPE_BOUNCE, but with adjustable gravity
// edict.solid values
float SOLID_NOT = 0; // no interaction with other objects
float SOLID_TRIGGER = 1; // touch on edge, but not blocking
float SOLID_BBOX = 2; // touch on edge, block
float SOLID_SLIDEBOX = 3; // touch on edge, but not an onground
float SOLID_BSP = 4; // bsp clip, touch on edge, block
float SOLID_CORPSE = 5; // reports touch and can shoot it, but not blocking otherwise.
// range values
float RANGE_MELEE = 0;
float RANGE_NEAR = 1;
float RANGE_MID = 2;
float RANGE_FAR = 3;
// deadflag values
float DEAD_NO = 0;
float DEAD_DYING = 1;
float DEAD_DEAD = 2;
float DEAD_RESPAWNABLE = 3;
// takedamage values
float DAMAGE_NO = 0;
float DAMAGE_YES = 1;
float DAMAGE_AIM = 2;
// items
float IT_AXE = 4096;
float IT_SHOTGUN = 1;
float IT_SUPER_SHOTGUN = 2;
float IT_NAILGUN = 4;
float IT_SUPER_NAILGUN = 8;
float IT_GRENADE_LAUNCHER = 16;
float IT_ROCKET_LAUNCHER = 32;
float IT_LIGHTNING = 64;
float IT_HOOK = 128;
float IT_SHELLS = 256;
float IT_NAILS = 512;
float IT_ROCKETS = 1024;
float IT_CELLS = 2048;
float IT_ARMOR1 = 8192;
float IT_ARMOR2 = 16384;
float IT_ARMOR3 = 32768;
float IT_SUPERHEALTH = 65536;
float IT_KEY1 = 131072;
float IT_KEY2 = 262144;
float IT_INVISIBILITY = 524288;
float IT_INVULNERABILITY = 1048576;
float IT_SUIT = 2097152;
float IT_QUAD = 4194304;
float IT_SIGIL1 = 268435456;
float IT_SIGIL2 = 536870912;
float IT_SIGIL3 = 1073741824;
float IT_SIGIL4 = 2147483648;
// point content values
float CONTENT_EMPTY = -1;
float CONTENT_SOLID = -2;
float CONTENT_WATER = -3;
float CONTENT_SLIME = -4;
float CONTENT_LAVA = -5;
float CONTENT_SKY = -6;
float STATE_TOP = 0;
float STATE_BOTTOM = 1;
float STATE_UP = 2;
float STATE_DOWN = 3;
vector VEC_ORIGIN = '0 0 0';
vector VEC_HULL_MIN = '-16 -16 -24';
vector VEC_HULL_MAX = '16 16 32';
vector VEC_HULL2_MIN = '-32 -32 -24';
vector VEC_HULL2_MAX = '32 32 64';
// protocol bytes
float SVC_TEMPENTITY = 23;
float SVC_KILLEDMONSTER = 27;
float SVC_FOUNDSECRET = 28;
float SVC_INTERMISSION = 30;
float SVC_FINALE = 31;
float SVC_CDTRACK = 32;
float SVC_SELLSCREEN = 33;
float SVC_SPAWNEDMONSTER = 39;
float SVC_ACHIEVEMENT = 52;
float SVC_CHAT = 53;
float SVC_LEVELCOMPLETED = 54;
float SVC_BACKTOLOBBY = 55;
float SVC_LOCALSOUND = 56;
float SVC_PROMPT = 57;
float TE_SPIKE = 0;
float TE_SUPERSPIKE = 1;
float TE_GUNSHOT = 2;
float TE_EXPLOSION = 3;
float TE_TAREXPLOSION = 4;
float TE_LIGHTNING1 = 5;
float TE_LIGHTNING2 = 6;
float TE_WIZSPIKE = 7;
float TE_KNIGHTSPIKE = 8;
float TE_LIGHTNING3 = 9;
float TE_LAVASPLASH = 10;
float TE_TELEPORT = 11;
float TE_EXPLOSION2 = 12;
float TE_BEAM = 13;
// sound channels
// channel 0 never willingly overrides
// other channels (1-7) allways override a playing sound on that channel
float CHAN_AUTO = 0;
float CHAN_WEAPON = 1;
float CHAN_VOICE = 2;
float CHAN_ITEM = 3;
float CHAN_BODY = 4;
float ATTN_NONE = 0;
float ATTN_NORM = 1;
float ATTN_IDLE = 2;
float ATTN_STATIC = 3;
// update types
float UPDATE_GENERAL = 0;
float UPDATE_STATIC = 1;
float UPDATE_BINARY = 2;
float UPDATE_TEMP = 3;
// entity effects
float EF_BRIGHTFIELD = 1;
float EF_MUZZLEFLASH = 2;
float EF_BRIGHTLIGHT = 4;
float EF_DIMLIGHT = 8;
float EF_QUADLIGHT = 16;
float EF_PENTALIGHT = 32;
float EF_CANDLELIGHT = 64;
// messages
float MSG_BROADCAST = 0; // unreliable to all
float MSG_ONE = 1; // reliable to one (msg_entity)
float MSG_ALL = 2; // reliable to all
float MSG_INIT = 3; // write to the init string
// mal: basic colors - based on the Quake color palette.
float COLOR_RED = 251;
float COLOR_GREEN = 184;
float COLOR_BLUE = 208;
float COLOR_YELLOW = 192;
float COLOR_WHITE = 254;
float COLOR_BLACK = 0;
float COLOR_CYAN = 244;
float COLOR_ORANGE = 95;
float DRAW_AI_SINGLE_FRAME = .1; // mal: use for AI that think every 10th of a second
float DRAW_GAME_SINGLE_FRAME = -1; // mal: use in game code that updates every frame.
// player expanded settings flags
float PEF_CHANGEONLYNEW = 1;
float PEF_CHANGENEVER = 2;
// mal: codes that the QuakeC built-ins "bot_movetopoint" and "bot_followentity" will return each time they're called
float BOT_GOAL_ERROR = 0; // can't do this goal for some reason.
float BOT_GOAL_SUCCESS = 1; // goal as requested is complete.
float BOT_GOAL_IN_PROGRESS = 2; // goal is in progress
// mal: codes that the QuakeC built-in "walkpathtogoal" will return each time it's called
float PATH_ERROR = 0; // something bad happened ( no nav nodes, no nearby nodes, no path, etc. ).
float PATH_REACHED_GOAL = 1; // reached whatever we were trying to get to.
float PATH_REACHED_PATH_END = 2; // reached the end of the path - can now move directly to target.
float PATH_MOVE_BLOCKED = 3; // something ( or someone ) is in our way.
float PATH_IN_PROGRESS = 4; // path was found, and we're following it.
//================================================
//
// globals
//
float movedist;
float gameover; // set when a rule exits
string string_null; // null string, nothing should be held here
float empty_float;
entity newmis; // launch_spike sets this after spawning it
entity activator; // the entity that activated a trigger or brush
entity damage_attacker; // set by T_Damage
float framecount;
float skill;
entity runespawn;
float runespawned;
float cheats_allowed; // mal: let's us run cheat commands in DM/Coop games.
float gamestart; // at start
//================================================
//
// world fields (FIXME: make globals)
//
.string wad;
.string map;
float WORLDTYPE_MEDIEVAL = 0;
float WORLDTYPE_METAL = 1;
float WORLDTYPE_BASE = 2;
.float worldtype;
//================================================
.string killtarget;
//
// quakeed fields
//
.float light_lev; // not used by game, but parsed by light util
.float style;
//
// monster ai
//
.void() th_stand;
.void() th_walk;
.void() th_run;
.void() th_missile;
.void() th_melee;
.void(entity attacker, float damage) th_pain;
.void() th_die;
.entity oldenemy; // mad at this player before taking damage
.float speed;
.float lefty;
.float search_time;
// Attack state ( not really used in Vanilla )
.float attack_state;
float AS_STRAIGHT = 1;
float AS_SLIDING = 2;
float AS_MELEE = 3;
float AS_MISSILE = 4;
.float allowPathFind; // not used in Vanilla, but added for demonstration purposes...
// Combat style
.float combat_style;
float CS_NONE = 0; // default - used for bosses or other monsters that don't move
float CS_RANGED = 1;
float CS_MELEE = 2;
float CS_MIXED = 3; // can do ranged or melee equally.
//
// player only fields
//
// *TEAMPLAY*
.float lastteam; // The last team this player was a member of.
// *XXX* EXPERT CTF ALTERNATE SCORING
// time values
.float flag_since; // how long a player has had the flag
.float last_returned_flag; // last time player returned his own flag
.float last_fragged_carrier; // last time player fragged a flag carrier
.float last_hurt_carrier; // last time player hurt the flag carrier
// *XXX* end
// OBSERVER
.float observer;
.float do_observer;
.float motd_sent;
.float obs_fire_held;
//ADMIN
.float accesslvl; // current access level
.float accessparm; // current access parm
.float walkframe;
.float attack_finished;
.float pain_finished;
.float hook_out;
.float hook_pulling;
.float hook_fire_time;
.float invincible_finished;
.float invisible_finished;
.float super_damage_finished;
.float radsuit_finished;
.float invincible_time, invincible_sound;
.float invisible_time, invisible_sound;
.float super_time, super_sound;
.float regeneration_sound;//RUNE: Elder Magic
.float haste_sound;//RUNE: Hell Magic
.float rad_time;
.float fly_sound;
.float healthrot_nextcheck; // if grabbed Mega-Health, the next time we'll rot the players health
.float axhitme;
.float show_hostile; // set to time+0.2 whenever a client fires a
// weapon or takes damage. Used to alert
// monsters that otherwise would let the player go
.float jump_flag; // player jump flag
.float swim_flag; // player swimming sound flag
.float air_finished; // when time > air_finished, start drowning
.float bubble_count; // keeps track of the number of bubbles
.string deathtype; // keeps track of how the player died
.float player_flag; // misc flags (skins, etc.)
.float staydeadtime; // how long we should stay dead
.float regen_time; // time to next regen
.float rune_notice_time; // last time we notified about multi-runes
.float voted; // non-zero if voted
// ZOID: Runes
float ITEM_RUNE1_FLAG = 1;
float ITEM_RUNE2_FLAG = 2;
float ITEM_RUNE3_FLAG = 4;
float ITEM_RUNE4_FLAG = 8;
float ITEM_RUNE_MASK = 15;
// ZOID: Capture the flag
float ITEM_ENEMY_FLAG = 16;
// TEAMPLAY
float TEAM_STUFF_COLOR = 32;
.float suicide_count;
.float killed; // have we been killed yet
//
// object stuff
//
.string mdl;
.vector mangle; // angle at start
.vector oldorigin; // only used by secret door
.float t_length, t_width;
//
// doors, etc
//
.vector dest, dest1, dest2;
.float wait; // time from firing to restarting
.float delay; // time from activation to firing
.entity trigger_field; // door's trigger entity
.string noise4;
//
// monsters
//
.float pausetime;
.entity movetarget;
//
// doors
//
.float aflag;
.float dmg; // damage done by door when hit
//
// misc
//
.float cnt; // misc flag
//
// subs
//
.void() think1;
.vector finaldest, finalangle;
//
// triggers
//
.float count; // for counting triggers
//
// plats / doors / buttons
//
.float lip;
.float state;
.vector pos1, pos2; // top and bottom positions
.float height;
//
// sounds
//
.float waitmin, waitmax;
.float distance;
.float volume;
.string killstring; // monster kill message
.float items2; // supported by engine to send down runes
//===========================================================================
//
// builtin functions
//
void(vector ang) makevectors = #1; // sets v_forward, etc globals
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;
// #5 was removed
void() break = #6;
float() random = #7; // returns 0 - 1
void(entity e, float chan, string samp, float vol, float atten) sound = #8;
vector(vector v) normalize = #9;
void(string e) error = #10;
void(string e) objerror = #11;
float(vector v) vlen = #12;
float(vector v) vectoyaw = #13;
entity() spawn = #14;
void(entity e) remove = #15;
// 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;
entity() checkclient = #17; // returns a client to look for
entity(entity start, .string fld, string match) find = #18;
string(string s) precache_sound = #19;
string(string s) precache_model = #20;
void(entity client, string s)stuffcmd = #21;
entity(vector org, float rad) findradius = #22;
void(string s, ...) bprint = #0:ex_bprint;
void(entity client, string s, ...) sprint = #0:ex_sprint;
void(string s, ...) dprint = #25;
string(float f) ftos = #26;
string(vector v) vtos = #27;
void() coredump = #28; // prints all edicts
void() traceon = #29; // turns statment trace on
void() traceoff = #30;
void(entity e) eprint = #31; // prints an entire edict
float(float yaw, float dist) walkmove = #32; // returns TRUE or FALSE
// #33 was removed
float() droptofloor= #34; // TRUE if landed on floor
void(float style, string value) lightstyle = #35;
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
// #39 was removed
float(entity e) checkbottom = #40; // true if self is on ground
float(vector v) pointcontents = #41; // returns a CONTENT_*
// #42 was removed
float(float f) fabs = #43;
vector(entity e, float speed) aim = #44; // returns the shooting vector
float(string s) cvar = #45; // return cvar.value
void(string s) localcmd = #46; // put string into local que
entity(entity e) nextent = #47; // for looping through all ents
void(vector o, vector d, float color, float count) particle = #48;// start a particle effect
void() ChangeYaw = #49; // turn towards self.ideal_yaw
// at self.yaw_speed
// #50 was removed
vector(vector v) vectoangles = #51;
//
// 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;
//
// broadcast client message generation
//
// void(float f) bWriteByte = #59;
// void(float f) bWriteChar = #60;
// void(float f) bWriteShort = #61;
// void(float f) bWriteLong = #62;
// void(float f) bWriteCoord = #63;
// void(float f) bWriteAngle = #64;
// void(string s) bWriteString = #65;
// void(entity e) bWriteEntity = #66;
void(float step) movetogoal = #67;
string(string s) precache_file = #68; // no effect except for -copy
void(entity e) makestatic = #69;
void(string s) changelevel = #70;
//#71 was removed
void(string var, string val) cvar_set = #72; // sets cvar.value
void(entity client, string s, ...) centerprint = #0:ex_centerprint; // sprint, but in middle
void(vector pos, string samp, float vol, float atten) ambientsound = #74;
string(string s) precache_model2 = #75; // registered version only
string(string s) precache_sound2 = #76; // registered version only
string(string s) precache_file2 = #77; // registered version only
void(entity e) setspawnparms = #78; // set parm1... to the
// values at level start
// for coop respawn
float() finaleFinished = #0:ex_finaleFinished;
// Plays a sound that only "client" can hear. Useful for announcers...
void localsound( entity client, string sample ) = #0:ex_localsound;
// Debug rendering functions.
void draw_point( vector point, float colormap, float lifetime, float depthtest ) = #0:ex_draw_point;
void draw_line( vector start, vector end, float colormap, float lifetime, float depthtest ) = #0:ex_draw_line;
void draw_arrow( vector start, vector end, float colormap, float size, float lifetime, float depthtest ) = #0:ex_draw_arrow;
void draw_ray( vector start, vector direction, float length, float colormap, float size, float lifetime, float depthtest ) = #0:ex_draw_ray;
void draw_circle( vector origin, float radius, float colormap, float lifetime, float depthtest ) = #0:ex_draw_circle;
void draw_bounds( vector min, vector max, float colormap, float lifetime, float depthtest ) = #0:ex_draw_bounds;
void draw_worldtext( string s, vector origin, float size, float lifetime, float depthtest ) = #0:ex_draw_worldtext;
void draw_sphere( vector origin, float radius, float colormap, float lifetime, float depthtest ) = #0:ex_draw_sphere;
void draw_cylinder( vector origin, float halfHeight, float radius, float colormap, float lifetime, float depthtest ) = #0:ex_draw_cylinder;
// Bot functions that return a value based on "BOT_GOAL_<X>", depending on the status of the goal.
float bot_movetopoint( entity bot, vector point ) = #0:ex_bot_movetopoint;
float bot_followentity( entity bot, entity goal ) = #0:ex_bot_followentity;
// Function for checking new player configured flags, such as weapon swap behaviour
float CheckPlayerEXFlags( entity playerEnt ) = #0:ex_CheckPlayerEXFlags;
// Path monsters to the goal using any available nav nodes on the map
float walkpathtogoal( float movedist, vector goal ) = #0:ex_walkpathtogoal;
float checkextension( string s ) = #99;
void setcolor( entity client, float color ) = #401;
void prompt( entity client, string text, float numChoices ) = #0:ex_prompt;
void promptchoice( entity client, string text, float impulse ) = #0:ex_promptchoice;
void clearprompt( entity client ) = #0:ex_clearprompt;
//============================================================================
//
// subs.qc
//
void(vector tdest, float tspeed, void() func) SUB_CalcMove;
void(entity ent, vector tdest, float tspeed, void() func) SUB_CalcMoveEnt;
void(vector destangle, float tspeed, void() func) SUB_CalcAngleMove;
void() SUB_CalcMoveDone;
void() SUB_CalcAngleMoveDone;
void() SUB_Null;
void() SUB_UseTargets;
void() SUB_Remove;
//
// combat.qc
//
void(entity targ, entity inflictor, entity attacker, float damage) T_Damage;
float (entity e, float healamount, float ignore) T_Heal; // health function
float(entity targ, entity inflictor) CanDamage;
//
// status.qc
//
float teamscr1; // team 1's capture score
float teamscr2; // team 2's capture score
void(entity e) SendCTFScoresUpdate;
void() SendCTFScoresUpdateAll; // send score update to all players using new EX HUD
void (entity head, entity tail) GrappleTrail;
void makevectorsfixed(vector ang) {
ang_x *= -1;
makevectors(ang);
};
float PromptSupported() {
if (!cvar("pr_checkextension"))
return FALSE;
return checkextension("EX_PROMPT");
}

835
quakec_ctf/doors.qc Normal file
View file

@ -0,0 +1,835 @@
/* Copyright (C) 1996-2022 id Software LLC
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
See file, 'COPYING', for details.
*/
float DOOR_START_OPEN = 1;
float DOOR_DONT_LINK = 4;
float DOOR_GOLD_KEY = 8;
float DOOR_SILVER_KEY = 16;
float DOOR_TOGGLE = 32;
/*
Doors are similar to buttons, but can spawn a fat trigger field around them
to open without a touch, and they link together to form simultanious
double/quad doors.
Door.owner is the master door. If there is only one door, it points to itself.
If multiple doors, all will point to a single one.
Door.enemy chains from the master door through all doors linked in the chain.
*/
/*
=============================================================================
THINK FUNCTIONS
=============================================================================
*/
void() door_go_down;
void() door_go_up;
void() door_blocked =
{
T_Damage (other, self, self, self.dmg);
// if a door has a negative wait, it would never come back if blocked,
// so let it just squash the object to death real fast
if (self.wait >= 0)
{
if (self.state == STATE_DOWN)
door_go_up ();
else
door_go_down ();
}
};
void() door_hit_top =
{
sound (self, CHAN_VOICE, self.noise1, 1, ATTN_NORM);
self.state = STATE_TOP;
if (self.spawnflags & DOOR_TOGGLE)
return; // don't come down automatically
self.think = door_go_down;
self.nextthink = self.ltime + self.wait;
};
void() door_hit_bottom =
{
sound (self, CHAN_VOICE, self.noise1, 1, ATTN_NORM);
self.state = STATE_BOTTOM;
};
void() door_go_down =
{
sound (self, CHAN_VOICE, self.noise2, 1, ATTN_NORM);
if (self.max_health)
{
self.takedamage = DAMAGE_YES;
self.health = self.max_health;
}
self.state = STATE_DOWN;
SUB_CalcMove (self.pos1, self.speed, door_hit_bottom);
};
void() door_go_up =
{
if (self.state == STATE_UP)
return; // allready going up
if (self.state == STATE_TOP)
{ // reset top wait time
self.nextthink = self.ltime + self.wait;
return;
}
sound (self, CHAN_VOICE, self.noise2, 1, ATTN_NORM);
self.state = STATE_UP;
SUB_CalcMove (self.pos2, self.speed, door_hit_top);
SUB_UseTargets();
};
/*
=============================================================================
ACTIVATION FUNCTIONS
=============================================================================
*/
void() door_fire =
{
local entity oself;
local entity starte;
if (self.owner != self)
objerror ("door_fire: self.owner != self");
// play use key sound
if (self.items)
sound (self, CHAN_ITEM, self.noise4, 1, ATTN_NORM); // door unlock sound bugfix
self.message = string_null; // no more message
oself = self;
if (self.spawnflags & DOOR_TOGGLE)
{
if (self.state == STATE_UP || self.state == STATE_TOP)
{
starte = self;
do
{
door_go_down ();
self = self.enemy;
} while ( (self != starte) && (self != world) );
self = oself;
return;
}
}
// trigger all paired doors
starte = self;
do
{
door_go_up ();
self = self.enemy;
} while ( (self != starte) && (self != world) );
self = oself;
};
void() door_use =
{
local entity oself;
self.message = string_null; // door message are for touch only
self.owner.message = string_null;
self.enemy.message = string_null;
oself = self;
self = self.owner;
door_fire ();
self = oself;
};
void() door_trigger_touch =
{
if (other.health <= 0)
return;
if (time < self.attack_finished)
return;
self.attack_finished = time + 1;
activator = other;
self = self.owner;
door_use ();
};
void() door_killed =
{
local entity oself;
oself = self;
self = self.owner;
self.health = self.max_health;
self.takedamage = DAMAGE_NO; // wil be reset upon return
door_use ();
self = oself;
};
/*
================
door_touch
Prints messages and opens key doors
================
*/
void() door_touch =
{
if (other.classname != "player")
return;
if (self.owner.attack_finished > time)
return;
self.owner.attack_finished = time + 2;
if (self.owner.message != string_null)
{
centerprint (other, self.owner.message);
sound (other, CHAN_VOICE, "misc/talk.wav", 1, ATTN_NORM);
}
// key door stuff
if (!self.items)
return;
// FIXME: blink key on player's status bar
if ( (self.items & other.items) != self.items )
{
if (self.owner.items == IT_KEY1)
{
if (world.worldtype == WORLDTYPE_BASE)
{
centerprint (other, "$qc_need_silver_keycard");
sound (self, CHAN_VOICE, self.noise3, 1, ATTN_NORM);
}
else if (world.worldtype == WORLDTYPE_METAL)
{
centerprint (other, "$qc_need_silver_runekey");
sound (self, CHAN_VOICE, self.noise3, 1, ATTN_NORM);
}
else if (world.worldtype == WORLDTYPE_MEDIEVAL)
{
centerprint (other, "$qc_need_silver_key");
sound (self, CHAN_VOICE, self.noise3, 1, ATTN_NORM);
}
}
else
{
if (world.worldtype == WORLDTYPE_BASE)
{
centerprint (other, "$qc_need_gold_keycard");
sound (self, CHAN_VOICE, self.noise3, 1, ATTN_NORM);
}
else if (world.worldtype == WORLDTYPE_METAL)
{
centerprint (other, "$qc_need_gold_runekey");
sound (self, CHAN_VOICE, self.noise3, 1, ATTN_NORM);
}
else if (world.worldtype == WORLDTYPE_MEDIEVAL)
{
centerprint (other, "$qc_need_gold_key");
sound (self, CHAN_VOICE, self.noise3, 1, ATTN_NORM);
}
}
return;
}
other.items = other.items - self.items;
self.touch = SUB_Null;
if (self.enemy)
self.enemy.touch = SUB_Null; // get paired door
door_use ();
};
/*
=============================================================================
SPAWNING FUNCTIONS
=============================================================================
*/
entity(vector fmins, vector fmaxs) spawn_field =
{
local entity trigger;
local vector t1, t2;
trigger = spawn();
trigger.movetype = MOVETYPE_NONE;
trigger.solid = SOLID_TRIGGER;
trigger.owner = self;
trigger.touch = door_trigger_touch;
t1 = fmins;
t2 = fmaxs;
setsize (trigger, t1 - '60 60 8', t2 + '60 60 8');
return (trigger);
};
float (entity e1, entity e2) EntitiesTouching =
{
if (e1.mins_x > e2.maxs_x)
return FALSE;
if (e1.mins_y > e2.maxs_y)
return FALSE;
if (e1.mins_z > e2.maxs_z)
return FALSE;
if (e1.maxs_x < e2.mins_x)
return FALSE;
if (e1.maxs_y < e2.mins_y)
return FALSE;
if (e1.maxs_z < e2.mins_z)
return FALSE;
return TRUE;
};
/*
=============
LinkDoors
=============
*/
void() LinkDoors =
{
local entity t, starte;
local vector cmins, cmaxs;
if (self.enemy)
return; // already linked by another door
if (self.spawnflags & 4)
{
self.owner = self.enemy = self;
return; // don't want to link this door
}
cmins = self.mins;
cmaxs = self.maxs;
starte = self;
t = self;
do
{
self.owner = starte; // master door
if (self.health)
starte.health = self.health;
if (self.targetname != string_null)
starte.targetname = self.targetname;
if (self.message != string_null)
starte.message = self.message;
t = find (t, classname, self.classname);
if (!t)
{
self.enemy = starte; // make the chain a loop
// shootable, fired, or key doors just needed the owner/enemy links,
// they don't spawn a field
self = self.owner;
if (self.health)
return;
if (self.targetname != string_null)
return;
if (self.items)
return;
self.owner.trigger_field = spawn_field(cmins, cmaxs);
return;
}
if (EntitiesTouching(self,t))
{
if (t.enemy)
objerror ("cross connected doors");
self.enemy = t;
self = t;
if (t.mins_x < cmins_x)
cmins_x = t.mins_x;
if (t.mins_y < cmins_y)
cmins_y = t.mins_y;
if (t.mins_z < cmins_z)
cmins_z = t.mins_z;
if (t.maxs_x > cmaxs_x)
cmaxs_x = t.maxs_x;
if (t.maxs_y > cmaxs_y)
cmaxs_y = t.maxs_y;
if (t.maxs_z > cmaxs_z)
cmaxs_z = t.maxs_z;
}
} while (1 );
};
/*QUAKED func_door (0 .5 .8) ? START_OPEN x DOOR_DONT_LINK GOLD_KEY SILVER_KEY TOGGLE
if two doors touch, they are assumed to be connected and operate as a unit.
TOGGLE causes the door to wait in both the start and end states for a trigger event.
START_OPEN causes the door to move to its destination when spawned, and operate in reverse. It is used to temporarily or permanently close off an area when triggered (not usefull for touch or takedamage doors).
Key doors are allways wait -1.
"message" is printed when the door is touched if it is a trigger door and it hasn't been fired yet
"angle" determines the opening direction
"targetname" if set, no touch field will be spawned and a remote button or trigger field activates the door.
"health" if set, door must be shot open
"speed" movement speed (100 default)
"wait" wait before returning (3 default, -1 = never return)
"lip" lip remaining at end of move (8 default)
"dmg" damage to inflict when blocked (2 default)
"sounds"
0) no sound
1) stone
2) base
3) stone chain
4) screechy metal
*/
void() func_door =
{
if (world.worldtype == WORLDTYPE_MEDIEVAL)
{
precache_sound ("doors/medtry.wav");
precache_sound ("doors/meduse.wav");
self.noise3 = "doors/medtry.wav";
self.noise4 = "doors/meduse.wav";
}
else if (world.worldtype == WORLDTYPE_METAL)
{
precache_sound ("doors/runetry.wav");
precache_sound ("doors/runeuse.wav");
self.noise3 = "doors/runetry.wav";
self.noise4 = "doors/runeuse.wav";
}
else if (world.worldtype == WORLDTYPE_BASE)
{
precache_sound ("doors/basetry.wav");
precache_sound ("doors/baseuse.wav");
self.noise3 = "doors/basetry.wav";
self.noise4 = "doors/baseuse.wav";
}
else
{
dprint ("no worldtype set!\n");
}
if (self.sounds == 0)
{
precache_sound ("misc/null.wav");
precache_sound ("misc/null.wav");
self.noise1 = "misc/null.wav";
self.noise2 = "misc/null.wav";
}
if (self.sounds == 1)
{
precache_sound ("doors/drclos4.wav");
precache_sound ("doors/doormv1.wav");
self.noise1 = "doors/drclos4.wav";
self.noise2 = "doors/doormv1.wav";
}
if (self.sounds == 2)
{
precache_sound ("doors/hydro1.wav");
precache_sound ("doors/hydro2.wav");
self.noise2 = "doors/hydro1.wav";
self.noise1 = "doors/hydro2.wav";
}
if (self.sounds == 3)
{
precache_sound ("doors/stndr1.wav");
precache_sound ("doors/stndr2.wav");
self.noise2 = "doors/stndr1.wav";
self.noise1 = "doors/stndr2.wav";
}
if (self.sounds == 4)
{
precache_sound ("doors/ddoor1.wav");
precache_sound ("doors/ddoor2.wav");
self.noise1 = "doors/ddoor2.wav";
self.noise2 = "doors/ddoor1.wav";
}
SetMovedir ();
self.max_health = self.health;
self.solid = SOLID_BSP;
self.movetype = MOVETYPE_PUSH;
setorigin (self, self.origin);
setmodel (self, self.model);
self.classname = "func_door";
self.blocked = door_blocked;
self.use = door_use;
if (self.spawnflags & DOOR_SILVER_KEY)
self.items = IT_KEY1;
if (self.spawnflags & DOOR_GOLD_KEY)
self.items = IT_KEY2;
if (!self.speed)
self.speed = 100;
if (!self.wait)
self.wait = 3;
if (!self.lip)
self.lip = 8;
if (!self.dmg)
self.dmg = 2;
self.pos1 = self.origin;
vector movedir_fabs = { fabs(self.movedir[0]), fabs(self.movedir[1]), fabs(self.movedir[2]) };
self.pos2 = self.pos1 + ((movedir_fabs * self.size) - self.lip) * self.movedir;
// DOOR_START_OPEN is to allow an entity to be lighted in the closed position
// but spawn in the open position
if (self.spawnflags & DOOR_START_OPEN)
{
setorigin (self, self.pos2);
self.pos2 = self.pos1;
self.pos1 = self.origin;
}
self.state = STATE_BOTTOM;
if (self.health)
{
self.takedamage = DAMAGE_YES;
self.th_die = door_killed;
}
if (self.items)
self.wait = -1;
self.touch = door_touch;
// LinkDoors can't be done until all of the doors have been spawned, so
// the sizes can be detected properly.
self.think = LinkDoors;
self.nextthink = self.ltime + 0.1;
};
/*
=============================================================================
SECRET DOORS
=============================================================================
*/
void() fd_secret_move1;
void() fd_secret_move2;
void() fd_secret_move3;
void() fd_secret_move4;
void() fd_secret_move5;
void() fd_secret_move6;
void() fd_secret_done;
float SECRET_OPEN_ONCE = 1; // stays open
float SECRET_1ST_LEFT = 2; // 1st move is left of arrow
float SECRET_1ST_DOWN = 4; // 1st move is down from arrow
float SECRET_NO_SHOOT = 8; // only opened by trigger
float SECRET_YES_SHOOT = 16; // shootable even if targeted
void () fd_secret_use =
{
local float temp;
self.health = 10000;
// exit if still moving around...
if (self.origin != self.oldorigin)
return;
self.message = string_null; // no more message
SUB_UseTargets(); // fire all targets / killtargets
if (!(self.spawnflags & SECRET_NO_SHOOT))
{
self.th_pain = SUB_Null;
self.takedamage = DAMAGE_NO;
}
self.velocity = '0 0 0';
// Make a sound, wait a little...
sound(self, CHAN_VOICE, self.noise1, 1, ATTN_NORM);
self.nextthink = self.ltime + 0.1;
temp = 1 - (self.spawnflags & SECRET_1ST_LEFT); // 1 or -1
makevectors(self.mangle);
if (!self.t_width)
{
if (self.spawnflags & SECRET_1ST_DOWN)
self. t_width = fabs(v_up * self.size);
else
self. t_width = fabs(v_right * self.size);
}
if (!self.t_length)
self. t_length = fabs(v_forward * self.size);
if (self.spawnflags & SECRET_1ST_DOWN)
self.dest1 = self.origin - v_up * self.t_width;
else
self.dest1 = self.origin + v_right * (self.t_width * temp);
self.dest2 = self.dest1 + v_forward * self.t_length;
SUB_CalcMove(self.dest1, self.speed, fd_secret_move1);
sound(self, CHAN_VOICE, self.noise2, 1, ATTN_NORM);
};
// Wait after first movement...
void () fd_secret_move1 =
{
self.nextthink = self.ltime + 1.0;
self.think = fd_secret_move2;
sound(self, CHAN_VOICE, self.noise3, 1, ATTN_NORM);
};
// Start moving sideways w/sound...
void () fd_secret_move2 =
{
sound(self, CHAN_VOICE, self.noise2, 1, ATTN_NORM);
SUB_CalcMove(self.dest2, self.speed, fd_secret_move3);
};
// Wait here until time to go back...
void () fd_secret_move3 =
{
sound(self, CHAN_VOICE, self.noise3, 1, ATTN_NORM);
if (!(self.spawnflags & SECRET_OPEN_ONCE))
{
self.nextthink = self.ltime + self.wait;
self.think = fd_secret_move4;
}
};
// Move backward...
void () fd_secret_move4 =
{
sound(self, CHAN_VOICE, self.noise2, 1, ATTN_NORM);
SUB_CalcMove(self.dest1, self.speed, fd_secret_move5);
};
// Wait 1 second...
void () fd_secret_move5 =
{
self.nextthink = self.ltime + 1.0;
self.think = fd_secret_move6;
sound(self, CHAN_VOICE, self.noise3, 1, ATTN_NORM);
};
void () fd_secret_move6 =
{
sound(self, CHAN_VOICE, self.noise2, 1, ATTN_NORM);
SUB_CalcMove(self.oldorigin, self.speed, fd_secret_done);
};
void () fd_secret_done =
{
if (!self.targetname || self.spawnflags&SECRET_YES_SHOOT)
{
self.health = 10000;
self.takedamage = DAMAGE_YES;
self.th_pain = fd_secret_use;
self.th_die = fd_secret_use; // secret door kill crash fix
}
sound(self, CHAN_VOICE, self.noise3, 1, ATTN_NORM);
};
void () secret_blocked =
{
if (time < self.attack_finished)
return;
self.attack_finished = time + 0.5;
T_Damage (other, self, self, self.dmg);
};
/*
================
secret_touch
Prints messages
================
*/
void() secret_touch =
{
if (other.classname != "player")
return;
if (self.attack_finished > time)
return;
self.attack_finished = time + 2;
if (self.message != string_null)
{
centerprint (other, self.message);
sound (other, CHAN_BODY, "misc/talk.wav", 1, ATTN_NORM);
}
};
/*QUAKED func_door_secret (0 .5 .8) ? open_once 1st_left 1st_down no_shoot always_shoot
Basic secret door. Slides back, then to the side. Angle determines direction.
wait = # of seconds before coming back
1st_left = 1st move is left of arrow
1st_down = 1st move is down from arrow
always_shoot = even if targeted, keep shootable
t_width = override WIDTH to move back (or height if going down)
t_length = override LENGTH to move sideways
"dmg" damage to inflict when blocked (2 default)
If a secret door has a targetname, it will only be opened by it's botton or trigger, not by damage.
"sounds"
1) medieval
2) metal
3) base
*/
void () func_door_secret =
{
if (self.sounds == 0)
self.sounds = 3;
if (self.sounds == 1)
{
precache_sound ("doors/latch2.wav");
precache_sound ("doors/winch2.wav");
precache_sound ("doors/drclos4.wav");
self.noise1 = "doors/latch2.wav";
self.noise2 = "doors/winch2.wav";
self.noise3 = "doors/drclos4.wav";
}
if (self.sounds == 2)
{
precache_sound ("doors/airdoor1.wav");
precache_sound ("doors/airdoor2.wav");
self.noise2 = "doors/airdoor1.wav";
self.noise1 = "doors/airdoor2.wav";
self.noise3 = "doors/airdoor2.wav";
}
if (self.sounds == 3)
{
precache_sound ("doors/basesec1.wav");
precache_sound ("doors/basesec2.wav");
self.noise2 = "doors/basesec1.wav";
self.noise1 = "doors/basesec2.wav";
self.noise3 = "doors/basesec2.wav";
}
if (!self.dmg)
self.dmg = 2;
// Magic formula...
self.mangle = self.angles;
self.angles = '0 0 0';
self.solid = SOLID_BSP;
self.movetype = MOVETYPE_PUSH;
self.classname = "func_door_secret";
setmodel (self, self.model);
setorigin (self, self.origin);
self.touch = secret_touch;
self.blocked = secret_blocked;
self.speed = 50;
self.use = fd_secret_use;
if ( !self.targetname || self.spawnflags&SECRET_YES_SHOOT)
{
self.health = 10000;
self.takedamage = DAMAGE_YES;
self.th_pain = fd_secret_use;
self.th_die = fd_secret_use;
}
self.oldorigin = self.origin;
if (!self.wait)
self.wait = 5; // 5 seconds before closing
};

285
quakec_ctf/hook.qc Normal file
View file

@ -0,0 +1,285 @@
/* Copyright (C) 1996-2022 id Software LLC
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
See file, 'COPYING', for details.
*/
/************\
* BreakChain *
\************/
void (entity Head) BreakChain =
{
local entity link;
link = Head.goalentity;
while (link != world)
{
Head = link.goalentity;
remove (link);
link = Head;
}
};
/*********\
* LinkPos *
\*********/
void () LinkPos =
{
makevectors (self.enemy.angles);
setorigin (self, self.owner.origin + ( ( ( self.enemy.origin +
(v_up * 16 * (!self.enemy.button2)) + (v_forward * 16) ) - self.owner.origin ) *
( self.weapon ) ) );
self.nextthink = time + 0.1;
};
/**************\
* GrappleTrail *
\**************/
void (entity head, entity tail) GrappleTrail =
{
// offset the hook beam by a bit to line up with the notch on the model
local vector start = head.origin;
makevectors(head.angles);
local vector offset = v_forward * -7;
offset.z *= -1; // z axis from makevectors is inverted
start += offset;
// draw_sphere(start, 1, 42, 0.1, 1);
// draw a line to the hook
WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
WriteByte (MSG_BROADCAST, TE_BEAM);
WriteEntity (MSG_BROADCAST, head);
WriteCoord (MSG_BROADCAST, start_x);
WriteCoord (MSG_BROADCAST, start_y);
WriteCoord (MSG_BROADCAST, start_z);
WriteCoord (MSG_BROADCAST, tail.origin_x);
WriteCoord (MSG_BROADCAST, tail.origin_y);
WriteCoord (MSG_BROADCAST, tail.origin_z + 16);
};
/************\
* HookVanish *
\************/
void () HookVanish =
{
self.owner.hook_out = FALSE;
self.owner.hook_pulling = FALSE;
/*
if (self.enemy.classname == "player")
self.enemy.attack_finished = time + 0.1;
*/
// sound(self.owner, CHAN_WEAPON, "weapons/bounce2.wav", 1, ATTN_NORM);
BreakChain (self);
remove (self);
};
void() UnHookPlayer =
{
local entity oself;
if (self.hook_out) {
oself = self;
self = self.goalentity;
HookVanish();
self = oself;
}
};
/**********\
* HookPull *
\**********/
void () HookPull =
{
local vector vel, spray;
local float v, dorg;
self.owner.hook_pulling = TRUE;
if ((!self.owner.button0 && (self.owner.weapon == IT_HOOK)) ||
(self.owner.teleport_time > time ) || self.owner.deadflag ) {
HookVanish();
return;
} else {
if (self.enemy.takedamage) {
// don't hurt teammates
if (self.enemy.classname != "player" || !teamplay ||
self.enemy.lastteam != self.owner.lastteam) {
// 4.1, if we can't see our enemy, unlock
if (!CanDamage(self.enemy, self.owner)) {
HookVanish();
return;
}
sound (self, CHAN_WEAPON, "blob/land1.wav", 1, ATTN_NORM);
T_Damage (self.enemy, self, self.owner, 1);
makevectors (self.v_angle);
spray_x = 100 * crandom();
spray_y = 100 * crandom();
spray_z = 100 * crandom() + 50;
SpawnBlood (self.origin, spray, 20);
}
if (self.enemy.solid == SOLID_SLIDEBOX) {
self.velocity = '0 0 0';
setorigin (self, self.enemy.origin +
self.enemy.mins +
(self.enemy.size * 0.5));
} else {
self.velocity = self.enemy.velocity;
}
} else {
self.velocity = self.enemy.velocity;
}
if (self.enemy.solid == SOLID_NOT) {
HookVanish();
return;
}
makevectors (self.owner.angles);
vel = self.origin - ( self.owner.origin + (v_up * 16 *
(!self.owner.button2)) + (v_forward * 16));
v = vlen (vel);
if (v <= 100)
vel = normalize(vel) * v * 10;
if ( v > 100 )
vel = normalize(vel) * 1000;
// custom assets are always enabled
dorg = vlen(self.owner.origin - self.dest);
if (dorg > 10 && self.style == 3) {
// sound(self.owner, CHAN_WEAPON, "weapons/chain2.wav", 1, ATTN_NORM);
self.style = 2;
}
if (dorg < 10 && self.style == 2) {
// sound(self.owner, CHAN_WEAPON, "weapons/chain3.wav", 1, ATTN_NORM);
self.style = 3;
}
self.owner.velocity = vel;
self.dest = self.owner.origin;
self.nextthink = time + 0.1;
}
};
/**************\
* T_ChainTouch *
\**************/
void() T_ChainTouch =
{
if (other == self.owner)
return; // don't attach to owner
if (pointcontents(self.origin) == CONTENT_SKY) {
HookVanish();
return;
}
if (other.classname == "player" && teamplay &&
other.team == self.owner.lastteam)
return; // just pass through teammates
if (other.takedamage) {
// don't damage teammates
if (other.classname == "player")
other.axhitme = 1; // make axe noise
else
sound (self, CHAN_WEAPON, "player/axhit2.wav", 1, ATTN_NORM);
T_Damage (other, self, self.owner, 10 );
SpawnBlood (self.origin, self.velocity, 10);
} else {
sound (self, CHAN_WEAPON, "player/axhit2.wav", 1, ATTN_NORM);
self.avelocity = '0 0 0';
}
if (!self.owner.button0) {
HookVanish();
return;
} else {
if (other.solid == SOLID_SLIDEBOX) {
setorigin (self, other.origin + other.mins +
(other.size * 0.5));
self.velocity = '0 0 0';
} else {
self.velocity = other.velocity;
}
self.weapon = other.nextthink - time;
// if (teamplay & TEAM_CAPTURE_CUSTOM)
// sound (self.owner, CHAN_WEAPON, "weapons/chain2.wav", 1, ATTN_NORM);
self.style = 2;
self.enemy = other;
self.nextthink = time + 0.1;
self.think = HookPull;
self.touch = SUB_Null;
}
};
void() T_ChainThink =
{
if (time >= self.hook_fire_time + 5) {
HookVanish();
}
if (!self.owner.button0 && self.owner.weapon == IT_HOOK) {
HookVanish();
return;
}
self.nextthink = time + 0.1;
}
/*************\
* W_FireChain *
\*************/
void() W_FireChain =
{
local entity hook;
self.hook_out = TRUE;
hook = spawn ();
hook.owner = self;
self.goalentity = hook;
hook.movetype = MOVETYPE_FLY;
hook.solid = SOLID_BBOX;
// set hook speed
makevectors (self.v_angle);
hook.velocity = aim(self, 1000);
hook.velocity = hook.velocity * 800;
hook.angles = vectoangles(hook.velocity);
hook.avelocity = '0 0 -500';
hook.touch = T_ChainTouch;
// set hook sound
hook.hook_fire_time = time;
hook.nextthink = time + 0.1;
hook.think = T_ChainThink;
setmodel (hook, "progs/star.mdl");
setsize (hook, '0 0 0', '0 0 0');
setorigin (hook, self.origin + (v_forward*16) + '0 0 16' );
sound (self, CHAN_WEAPON, "weapons/chain1.wav", 1, ATTN_NORM);
};

84
quakec_ctf/itemnames.qc Normal file
View file

@ -0,0 +1,84 @@
/* Copyright (C) 1996-2022 id Software LLC
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
See file, 'COPYING', for details.
*/
string GetNetName( float item_number ) = {
switch ( item_number ) {
case IT_AXE:
return "Axe";
case IT_SHOTGUN:
return "Shotgun";
case IT_SUPER_SHOTGUN:
return "Super Shotgun";
case IT_NAILGUN:
return "Nailgun";
case IT_SUPER_NAILGUN:
return "Perforator";
case IT_GRENADE_LAUNCHER:
return "Grenade Launcher";
case IT_ROCKET_LAUNCHER:
return "Rocket Launcher";
case IT_LIGHTNING:
return "Lightning Gun";
case IT_HOOK:
return "Grappling Hook";
case IT_SHELLS:
return "Shells";
case IT_NAILS:
return "Nails";
case IT_ROCKETS:
return "Rockets";
case IT_CELLS:
return "Cells";
case IT_ARMOR1:
return "Green Armor";
case IT_ARMOR2:
return "Yellow Armor";
case IT_ARMOR3:
return "Red Armor";
case IT_SUPERHEALTH:
return "Mega Health";
case IT_KEY1: {
if ( world.worldtype == WORLDTYPE_MEDIEVAL )
return "Silver key";
else if ( world.worldtype == WORLDTYPE_METAL )
return "Silver runkey";
else if ( world.worldtype == WORLDTYPE_BASE )
return "Silver keycard";
}
case IT_KEY2: {
if ( world.worldtype == WORLDTYPE_MEDIEVAL )
return "Gold key";
else if ( world.worldtype == WORLDTYPE_METAL )
return "Gold runkey";
else if ( world.worldtype == WORLDTYPE_BASE )
return "Gold keycard";
}
case IT_INVISIBILITY:
return "Ring of Shadows";
case IT_INVULNERABILITY:
return "Pentagram of Protection";
case IT_SUIT:
return "Biohazard Suit";
case IT_QUAD:
return "Quad Damage";
default:
return string_null;
}
};

1747
quakec_ctf/items.qc Normal file

File diff suppressed because it is too large Load diff

57
quakec_ctf/log.qc Normal file
View file

@ -0,0 +1,57 @@
/* Copyright (C) 1996-2022 id Software LLC
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
See file, 'COPYING', for details.
*/
void(entity targ, entity attacker, string what) LogPlayerDMDeath =
{
// note embedded tabs in the next string
localcmd("echo ");
localcmd("LOG: DEATH ");
localcmd(targ.netname);
localcmd("/");
localcmd(ftos(targ.frags));
localcmd(" ");
localcmd(attacker.netname);
localcmd("/");
localcmd(ftos(attacker.frags));
localcmd(" ");
localcmd(what);
localcmd("\n");
};
void (entity targ, string what) LogPlayerDeath =
{
localcmd("echo ");
localcmd("LOG: DEATH ");
localcmd(targ.netname);
localcmd("/");
localcmd(ftos(targ.frags));
localcmd(" ");
localcmd(what);
localcmd("\n");
};
void (entity who, string what) LogMsg =
{
localcmd("echo ");
localcmd("LOG: ");
localcmd(what);
localcmd(" ");
localcmd(who.netname);
localcmd("\n");
};

763
quakec_ctf/misc.qc Normal file
View file

@ -0,0 +1,763 @@
/* Copyright (C) 1996-2022 id Software LLC
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
See file, 'COPYING', for details.
*/
/*QUAKED info_null (0 0.5 0) (-4 -4 -4) (4 4 4)
Used as a positional target for spotlights, etc.
*/
void() info_null =
{
remove(self);
};
/*QUAKED info_notnull (0 0.5 0) (-4 -4 -4) (4 4 4)
Used as a positional target for lightning.
*/
void() info_notnull =
{
};
//============================================================================
float START_OFF = 1;
void() light_use =
{
if (self.spawnflags & START_OFF)
{
lightstyle(self.style, "m");
self.spawnflags = self.spawnflags - START_OFF;
}
else
{
lightstyle(self.style, "a");
self.spawnflags = self.spawnflags + START_OFF;
}
};
/*QUAKED light (0 1 0) (-8 -8 -8) (8 8 8) START_OFF
Non-displayed light.
Default light value is 300
Default style is 0
If targeted, it will toggle between on or off.
*/
void() light =
{
if (!self.targetname)
{ // inert light
remove(self);
return;
}
if (self.style >= 32)
{
self.use = light_use;
if (self.spawnflags & START_OFF)
lightstyle(self.style, "a");
else
lightstyle(self.style, "m");
}
};
/*QUAKED light_fluoro (0 1 0) (-8 -8 -8) (8 8 8) START_OFF
Non-displayed light.
Default light value is 300
Default style is 0
If targeted, it will toggle between on or off.
Makes steady fluorescent humming sound
*/
void() light_fluoro =
{
if (self.style >= 32)
{
self.use = light_use;
if (self.spawnflags & START_OFF)
lightstyle(self.style, "a");
else
lightstyle(self.style, "m");
}
precache_sound ("ambience/fl_hum1.wav");
ambientsound (self.origin, "ambience/fl_hum1.wav", 0.5, ATTN_STATIC);
};
/*QUAKED light_fluorospark (0 1 0) (-8 -8 -8) (8 8 8)
Non-displayed light.
Default light value is 300
Default style is 10
Makes sparking, broken fluorescent sound
*/
void() light_fluorospark =
{
if (!self.style)
self.style = 10;
precache_sound ("ambience/buzz1.wav");
ambientsound (self.origin, "ambience/buzz1.wav", 0.5, ATTN_STATIC);
};
/*QUAKED light_globe (0 1 0) (-8 -8 -8) (8 8 8)
Sphere globe light.
Default light value is 300
Default style is 0
*/
void() light_globe =
{
precache_model ("progs/s_light.spr");
setmodel (self, "progs/s_light.spr");
makestatic (self);
};
void() FireAmbient =
{
precache_sound ("ambience/fire1.wav");
// attenuate fast
ambientsound (self.origin, "ambience/fire1.wav", 0.5, ATTN_STATIC);
};
/*QUAKED light_torch_small_walltorch (0 .5 0) (-10 -10 -20) (10 10 20)
Short wall torch
Default light value is 200
Default style is 0
*/
void() light_torch_small_walltorch =
{
precache_model ("progs/flame.mdl");
setmodel (self, "progs/flame.mdl");
FireAmbient ();
makestatic (self);
};
/*QUAKED light_flame_large_yellow (0 1 0) (-10 -10 -12) (12 12 18)
Large yellow flame ball
*/
void() light_flame_large_yellow =
{
precache_model ("progs/flame2.mdl");
setmodel (self, "progs/flame2.mdl");
self.frame = 1;
FireAmbient ();
makestatic (self);
};
/*QUAKED light_flame_small_yellow (0 1 0) (-8 -8 -8) (8 8 8) START_OFF
Small yellow flame ball
*/
void() light_flame_small_yellow =
{
precache_model ("progs/flame2.mdl");
setmodel (self, "progs/flame2.mdl");
FireAmbient ();
makestatic (self);
};
/*QUAKED light_flame_small_white (0 1 0) (-10 -10 -40) (10 10 40) START_OFF
Small white flame ball
*/
void() light_flame_small_white =
{
precache_model ("progs/flame2.mdl");
setmodel (self, "progs/flame2.mdl");
FireAmbient ();
makestatic (self);
};
//============================================================================
/*QUAKED misc_fireball (0 .5 .8) (-8 -8 -8) (8 8 8)
Lava Balls
*/
void() fire_fly;
void() fire_touch;
void() misc_fireball =
{
precache_model ("progs/lavaball.mdl");
self.classname = "fireball";
self.nextthink = time + (random() * 5);
self.think = fire_fly;
self.netname = "$qc_lava_ball";
self.killstring = "$qc_ks_lavaball";
if (!self.speed)
self.speed = 1000;
};
void() fire_fly =
{
local entity fireball;
fireball = spawn();
fireball.solid = SOLID_TRIGGER;
fireball.movetype = MOVETYPE_TOSS;
fireball.velocity = '0 0 1000';
fireball.velocity_x = (random() * 100) - 50;
fireball.velocity_y = (random() * 100) - 50;
fireball.velocity_z = self.speed + (random() * 200);
fireball.classname = "fireball";
setmodel (fireball, "progs/lavaball.mdl");
setsize (fireball, '0 0 0', '0 0 0');
setorigin (fireball, self.origin);
fireball.nextthink = time + 5;
fireball.think = SUB_Remove;
fireball.touch = fire_touch;
self.netname = "$qc_lava_ball";
self.killstring = "$qc_ks_lavaball";
self.nextthink = time + (random() * 5) + 3;
self.think = fire_fly;
};
void() fire_touch =
{
T_Damage (other, self, self, 20);
remove(self);
};
//============================================================================
void() barrel_explode =
{
// did say self.owner
T_RadiusDamage (self, self.enemy, 160, world);
sound (self, CHAN_VOICE, "weapons/r_exp3.wav", 1, ATTN_NORM);
particle (self.origin, '0 0 0', 75, 255);
self.origin_z = self.origin_z + 32;
BecomeExplosion ();
};
void() barrel_detonate =
{
self.classname = "explo_box";
self.takedamage = DAMAGE_NO;
self.think = barrel_explode;
self.nextthink = self.ltime + 0.3;
}
/*QUAKED misc_explobox (0 .5 .8) (0 0 0) (32 32 64)
TESTING THING
*/
void() misc_explobox =
{
local float oldz;
if(!self.mdl)
self.mdl = "maps/b_explob.bsp";
self.solid = SOLID_BSP;
self.movetype = MOVETYPE_PUSH;
precache_model (self.mdl);
setmodel (self, self.mdl);
precache_sound ("weapons/r_exp3.wav");
self.health = 20;
self.th_die = barrel_detonate;
self.takedamage = DAMAGE_AIM;
self.netname = "$qc_exploding_barrel";
self.killstring = "$qc_ks_blew_up";
self.origin_z = self.origin_z + 2;
oldz = self.origin_z;
droptofloor();
if (oldz - self.origin_z > 250)
{
dprint ("explobox fell out of level at ");
dprint (vtos(self.origin));
dprint ("\n");
remove(self);
}
};
/*QUAKED misc_explobox2 (0 .5 .8) (0 0 0) (32 32 64)
Smaller exploding box, REGISTERED ONLY
*/
void() misc_explobox2 =
{
self.mdl = "maps/b_exbox2.bsp";
misc_explobox();
};
//============================================================================
float SPAWNFLAG_SUPERSPIKE = 1;
float SPAWNFLAG_LASER = 2;
void() Laser_Touch =
{
local vector org;
if (other == self.owner)
return; // don't explode on owner
if (pointcontents(self.origin) == CONTENT_SKY)
{
remove(self);
return;
}
sound (self, CHAN_WEAPON, "enforcer/enfstop.wav", 1, ATTN_STATIC);
org = self.origin - 8*normalize(self.velocity);
if (other.health)
{
SpawnBlood (org, self.velocity, 15);
T_Damage (other, self, self.owner, 15);
}
else
{
WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
WriteByte (MSG_BROADCAST, TE_GUNSHOT);
WriteCoord (MSG_BROADCAST, org_x);
WriteCoord (MSG_BROADCAST, org_y);
WriteCoord (MSG_BROADCAST, org_z);
}
remove(self);
};
void(vector org, vector vec) LaunchLaser =
{
local vector vec;
if (self.classname == "monster_enforcer")
sound (self, CHAN_WEAPON, "enforcer/enfire.wav", 1, ATTN_NORM);
vec = normalize(vec);
newmis = spawn();
newmis.owner = self;
newmis.movetype = MOVETYPE_FLY;
newmis.solid = SOLID_BBOX;
newmis.effects = EF_DIMLIGHT;
setmodel (newmis, "progs/laser.mdl");
setsize (newmis, '0 0 0', '0 0 0');
setorigin (newmis, org);
newmis.velocity = vec * 600;
newmis.angles = vectoangles(newmis.velocity);
newmis.nextthink = time + 5;
newmis.think = SUB_Remove;
newmis.touch = Laser_Touch;
};
void() spikeshooter_use =
{
if (self.spawnflags & SPAWNFLAG_LASER)
{
sound (self, CHAN_VOICE, "enforcer/enfire.wav", 1, ATTN_NORM);
LaunchLaser (self.origin, self.movedir);
}
else
{
sound (self, CHAN_VOICE, "weapons/spike2.wav", 1, ATTN_NORM);
launch_spike (self.origin, self.movedir);
newmis.velocity = self.movedir * 500;
if (self.spawnflags & SPAWNFLAG_SUPERSPIKE)
newmis.touch = superspike_touch;
}
};
void() shooter_think =
{
spikeshooter_use ();
self.nextthink = time + self.wait;
newmis.velocity = self.movedir * 500;
};
/*QUAKED trap_spikeshooter (0 .5 .8) (-8 -8 -8) (8 8 8) superspike laser
When triggered, fires a spike in the direction set in QuakeEd.
Laser is only for REGISTERED.
*/
void() trap_spikeshooter =
{
SetMovedir ();
self.use = spikeshooter_use;
self.netname = "$qc_spike_trap";
self.killstring ="$qc_ks_spiked";
if (self.spawnflags & SPAWNFLAG_LASER)
{
precache_model2 ("progs/laser.mdl");
precache_sound2 ("enforcer/enfire.wav");
precache_sound2 ("enforcer/enfstop.wav");
}
else
precache_sound ("weapons/spike2.wav");
};
/*QUAKED trap_shooter (0 .5 .8) (-8 -8 -8) (8 8 8) superspike laser
Continuously fires spikes.
"wait" time between spike (1.0 default)
"nextthink" delay before firing first spike, so multiple shooters can be stagered.
*/
void() trap_shooter =
{
trap_spikeshooter ();
if (self.wait == 0)
self.wait = 1;
self.nextthink = self.nextthink + self.wait + self.ltime;
self.think = shooter_think;
};
/*
===============================================================================
===============================================================================
*/
void() make_bubbles;
void() bubble_remove;
void() bubble_bob;
/*QUAKED air_bubbles (0 .5 .8) (-8 -8 -8) (8 8 8)
testing air bubbles
*/
void() air_bubbles =
{
if (deathmatch)
{
remove (self);
return;
}
precache_model ("progs/s_bubble.spr");
self.nextthink = time + 1;
self.think = make_bubbles;
};
void() make_bubbles =
{
local entity bubble;
bubble = spawn();
setmodel (bubble, "progs/s_bubble.spr");
setorigin (bubble, self.origin);
bubble.movetype = MOVETYPE_NOCLIP;
bubble.solid = SOLID_NOT;
bubble.velocity = '0 0 15';
bubble.nextthink = time + 0.5;
bubble.think = bubble_bob;
bubble.touch = bubble_remove;
bubble.classname = "bubble";
bubble.frame = 0;
bubble.cnt = 0;
setsize (bubble, '-8 -8 -8', '8 8 8');
self.nextthink = time + random() + 0.5;
self.think = make_bubbles;
};
void() bubble_split =
{
local entity bubble;
bubble = spawn();
setmodel (bubble, "progs/s_bubble.spr");
setorigin (bubble, self.origin);
bubble.movetype = MOVETYPE_NOCLIP;
bubble.solid = SOLID_NOT;
bubble.velocity = self.velocity;
bubble.nextthink = time + 0.5;
bubble.think = bubble_bob;
bubble.touch = bubble_remove;
bubble.classname = "bubble";
bubble.frame = 1;
bubble.cnt = 10;
setsize (bubble, '-8 -8 -8', '8 8 8');
self.frame = 1;
self.cnt = 10;
if (self.waterlevel != 3)
remove (self);
};
void() bubble_remove =
{
if (other.classname == self.classname)
return;
remove(self);
};
void() bubble_bob =
{
local float rnd1, rnd2, rnd3;
self.cnt = self.cnt + 1;
if (self.cnt == 4)
bubble_split();
if (self.cnt == 20)
remove(self);
rnd1 = self.velocity_x + (-10 + (random() * 20));
rnd2 = self.velocity_y + (-10 + (random() * 20));
rnd3 = self.velocity_z + 10 + random() * 10;
if (rnd1 > 10)
rnd1 = 5;
if (rnd1 < -10)
rnd1 = -5;
if (rnd2 > 10)
rnd2 = 5;
if (rnd2 < -10)
rnd2 = -5;
if (rnd3 < 10)
rnd3 = 15;
if (rnd3 > 30)
rnd3 = 25;
self.velocity_x = rnd1;
self.velocity_y = rnd2;
self.velocity_z = rnd3;
self.nextthink = time + 0.5;
self.think = bubble_bob;
};
/*~>~<~>~<~>~<~>~<~>~<~>~<~>~<~>~<~>~<~>~<~>~<~>~<~>~<~>~<~>~<~>~<~>~<~>
~>~<~>~<~>~<~>~<~>~<~>~<~>~<~>~<~>~<~>~<~>~<~>~<~>~<~>~<~>~<~>~<~>~<~>~*/
/*QUAKED viewthing (0 .5 .8) (-8 -8 -8) (8 8 8)
Just for the debugging level. Don't use
*/
void() viewthing =
{
self.movetype = MOVETYPE_NONE;
self.solid = SOLID_NOT;
precache_model ("progs/player.mdl");
setmodel (self, "progs/player.mdl");
};
/*
==============================================================================
SIMPLE BMODELS
==============================================================================
*/
void() func_wall_use =
{ // change to alternate textures
self.frame = 1 - self.frame;
};
/*
QUAKED func_wall (0 .5 .8) ?
This is just a solid wall if not inhibitted
*/
void() func_wall =
{
if (gamestart && self.model == "*47")
return; // remove deathmatch only wall on start map
self.angles = '0 0 0';
self.classname = "func_wall";
self.movetype = MOVETYPE_PUSH; // so it doesn't get pushed by anything
self.solid = SOLID_BSP;
self.use = func_wall_use;
setmodel (self, self.model);
};
/*
QUAKED func_illusionary (0 .5 .8) ?
A simple entity that looks solid but lets you walk through it.
*/
void() func_illusionary =
{
self.angles = '0 0 0';
self.movetype = MOVETYPE_NONE;
self.solid = SOLID_NOT;
setmodel (self, self.model);
makestatic (self);
};
/*
QUAKED func_episodegate (0 .5 .8) ? E1 E2 E3 E4
This bmodel will appear if the episode has allready been completed, so players can't reenter it.
*/
void() func_episodegate =
{
if (!(serverflags & self.spawnflags))
return; // can still enter episode
self.angles = '0 0 0';
self.movetype = MOVETYPE_PUSH; // so it doesn't get pushed by anything
self.solid = SOLID_BSP;
self.use = func_wall_use;
setmodel (self, self.model);
};
/*
QUAKED func_bossgate (0 .5 .8) ?
This bmodel appears unless players have all of the episode sigils.
*/
void() func_bossgate =
{
if ( (serverflags & 15) == 15 || gamestart)
return; // all episodes completed
self.angles = '0 0 0';
self.movetype = MOVETYPE_PUSH; // so it doesn't get pushed by anything
self.solid = SOLID_BSP;
self.use = func_wall_use;
setmodel (self, self.model);
};
//============================================================================
/*QUAKED ambient_suck_wind (0.3 0.1 0.6) (-10 -10 -8) (10 10 8)
*/
void() ambient_suck_wind =
{
precache_sound ("ambience/suck1.wav");
ambientsound (self.origin, "ambience/suck1.wav", 1, ATTN_STATIC);
};
/*QUAKED ambient_drone (0.3 0.1 0.6) (-10 -10 -8) (10 10 8)
*/
void() ambient_drone =
{
precache_sound ("ambience/drone6.wav");
ambientsound (self.origin, "ambience/drone6.wav", 0.5, ATTN_STATIC);
};
/*QUAKED ambient_flouro_buzz (0.3 0.1 0.6) (-10 -10 -8) (10 10 8)
*/
void() ambient_flouro_buzz =
{
precache_sound ("ambience/buzz1.wav");
ambientsound (self.origin, "ambience/buzz1.wav", 1, ATTN_STATIC);
};
/*QUAKED ambient_drip (0.3 0.1 0.6) (-10 -10 -8) (10 10 8)
*/
void() ambient_drip =
{
precache_sound ("ambience/drip1.wav");
ambientsound (self.origin, "ambience/drip1.wav", 0.5, ATTN_STATIC);
};
/*QUAKED ambient_comp_hum (0.3 0.1 0.6) (-10 -10 -8) (10 10 8)
*/
void() ambient_comp_hum =
{
precache_sound ("ambience/comp1.wav");
ambientsound (self.origin, "ambience/comp1.wav", 1, ATTN_STATIC);
};
/*QUAKED ambient_thunder (0.3 0.1 0.6) (-10 -10 -8) (10 10 8)
*/
void() ambient_thunder =
{
precache_sound ("ambience/thunder1.wav");
ambientsound (self.origin, "ambience/thunder1.wav", 0.5, ATTN_STATIC);
};
/*QUAKED ambient_light_buzz (0.3 0.1 0.6) (-10 -10 -8) (10 10 8)
*/
void() ambient_light_buzz =
{
precache_sound ("ambience/fl_hum1.wav");
ambientsound (self.origin, "ambience/fl_hum1.wav", 0.5, ATTN_STATIC);
};
/*QUAKED ambient_swamp1 (0.3 0.1 0.6) (-10 -10 -8) (10 10 8)
*/
void() ambient_swamp1 =
{
precache_sound ("ambience/swamp1.wav");
ambientsound (self.origin, "ambience/swamp1.wav", 0.5, ATTN_STATIC);
};
/*QUAKED ambient_swamp2 (0.3 0.1 0.6) (-10 -10 -8) (10 10 8)
*/
void() ambient_swamp2 =
{
precache_sound ("ambience/swamp2.wav");
ambientsound (self.origin, "ambience/swamp2.wav", 0.5, ATTN_STATIC);
};
//============================================================================
void() noise_think =
{
self.nextthink = time + 0.5;
sound (self, 1, "enforcer/enfire.wav", 1, ATTN_NORM);
sound (self, 2, "enforcer/enfstop.wav", 1, ATTN_NORM);
sound (self, 3, "enforcer/sight1.wav", 1, ATTN_NORM);
sound (self, 4, "enforcer/sight2.wav", 1, ATTN_NORM);
sound (self, 5, "enforcer/sight3.wav", 1, ATTN_NORM);
sound (self, 6, "enforcer/sight4.wav", 1, ATTN_NORM);
sound (self, 7, "enforcer/pain1.wav", 1, ATTN_NORM);
};
/*QUAKED misc_noisemaker (1 0.5 0) (-10 -10 -10) (10 10 10)
For optimzation testing, starts a lot of sounds.
*/
void() misc_noisemaker =
{
precache_sound2 ("enforcer/enfire.wav");
precache_sound2 ("enforcer/enfstop.wav");
precache_sound2 ("enforcer/sight1.wav");
precache_sound2 ("enforcer/sight2.wav");
precache_sound2 ("enforcer/sight3.wav");
precache_sound2 ("enforcer/sight4.wav");
precache_sound2 ("enforcer/pain1.wav");
precache_sound2 ("enforcer/pain2.wav");
precache_sound2 ("enforcer/death1.wav");
precache_sound2 ("enforcer/idle1.wav");
self.nextthink = time + 0.1 + random();
self.think = noise_think;
};

285
quakec_ctf/observ.qc Normal file
View file

@ -0,0 +1,285 @@
/* Copyright (C) 1996-2022 id Software LLC
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
See file, 'COPYING', for details.
*/
void() respawn;
entity() SelectSpawnPoint;
void(entity player,entity door) ObserverDoor =
{
local entity d,d_master;
local vector dmin,dmax;
local float is_x,is_y,is_z,set;
local vector dir,or;
d_master = d = door.owner;
if (d_master) {
dmin = d_master.absmin;
dmax = d_master.absmax;
} else {
dmin = dmax = '0 0 0';
}
if (dmin != dmax) {
// regular doors
if (d_master.state != STATE_BOTTOM) return;
do {
// dprint (vtos(d.absmin)); dprint (" "); dprint (vtos(d.absmax)); dprint ("\n");
if (d.absmin_x < dmin_x) { dmin_x = d.absmin_x; }
if (d.absmax_x > dmax_x) { dmax_x = d.absmax_x; }
if (d.absmin_y < dmin_y) { dmin_y = d.absmin_y; }
if (d.absmax_y > dmax_y) { dmax_y = d.absmax_y; }
if (d.absmin_z < dmin_z) { dmin_z = d.absmin_z; }
if (d.absmax_z > dmax_z) { dmax_z = d.absmax_z; }
d = d.enemy; // next linked door;
} while ((d != d_master) && (d != world));
}
else {
// secret doors
// we ignore these currently
return;
}
set = is_x = is_y = is_z = FALSE;
or = player.origin;
if (dmin_x + 15 < player.absmin_x && player.absmax_x < dmax_x - 15) is_x = TRUE;
if (dmin_y + 15 < player.absmin_y && player.absmax_y < dmax_y - 15) is_y = TRUE;
if (dmin_z + 15 < player.absmin_z && player.absmax_z < dmax_z - 15) is_z = TRUE;
// dprint("doors: "); dprint (vtos(dmin)); dprint (" "); dprint (vtos(dmax)); dprint ("\n");
// dprint("player: "); dprint (vtos(player.absmin)); dprint (" "); dprint (vtos(player.absmax)); dprint ("\n");
if (is_x && is_y) {
// dprint("door is in xy plane\n");
if (or_z < dmin_z) { dir = '0 0 1'; or_z = dmax_z + 25; }
else if (or_z > dmax_z) { dir = '0 0 -1'; or_z = dmin_z - 25; }
set = TRUE;
}
else if (is_x && is_z) {
// dprint("door is in xz plane\n");
if (or_y < dmin_y) { dir = '0 1 0'; or_y = dmax_y + 25; }
else if (or_y > dmax_y) { dir = '0 -1 0'; or_y = dmin_y - 25; }
set = TRUE;
}
else if (is_y && is_z) {
// dprint("door is in yz plane\n");
if (or_x < dmin_x) { dir = ' 1 0 0'; or_x = dmax_x + 25; }
else if (or_x > dmax_x) { dir = '-1 0 0'; or_x = dmin_x - 25; }
set = TRUE;
}
if (set) {
local vector v;
v = normalize(player.velocity);
if (dir * v < 0.5) return;
player.origin = or;
setorigin (player, player.origin);
}
};
void(entity player,entity tele) ObserverTeleporter =
{
local entity targ;
local vector v1,v2;
v1 = ((tele.absmax + tele.absmin) * 0.5) - player.origin; normalize(v1);
v2 = player.velocity; normalize(v2);
if (v1 * v2 <= 0.1) return;
targ = find (world, targetname, tele.target);
if (!targ) {
dprint("ObserverTeleportThroughTeleporter: couldn't find teleporter target\n");
return;
}
makevectors (targ.mangle);
setorigin (player, targ.origin);
player.angles = targ.mangle;
player.fixangle = TRUE; // turn this way immediately
player.teleport_time = time + 0.7;
player.velocity = v_forward * 300;
// player.flags = player.flags - player.flags & FL_ONGROUND;
};
float() DoObserverImpulse =
{
local float teamImpulse = FALSE;
if (!PromptSupported() && self.observer && (self.impulse == 1 || self.impulse == 2 || self.impulse == 3 || self.button2)) {
teamImpulse = TRUE;
} else if (self.impulse >= 100 && self.impulse <= 104) {
teamImpulse = TRUE;
}
if (!teamImpulse) {
return FALSE;
}
if (self.impulse == 100 && teamplay & TEAM_STATIC_TEAMS) {
centerprint(self, "$qc_ctf_teams_locked");
return TRUE;
}
if (!self.observer) {
T_Damage(self,self,self,1000);
}
self.observer = 0;
SetChangeParms ();
self.killed = 0;
if (self.impulse == 100) { // put the player into observer and send the team selection
self.team = self.lastteam = 0;
self.do_observer = 1;
self.observer = 1;
self.motd_sent = 0;
}
if (self.impulse == 1 || self.impulse == 101 ) // red
self.team = self.lastteam = TEAM_COLOR1;
else if (self.impulse == 2 || self.impulse == 102) // blue
self.team = self.lastteam = TEAM_COLOR2;
else if (self.impulse == 103) { // automatic
self.lastteam = -50;
TeamCheckTeam();
}
else if (self.impulse == 104) { // observer
self.team = self.lastteam = 0;
self.do_observer = 1;
self.observer = 1;
}
if (PromptSupported()) {
clearprompt(self);
}
if (self.lastteam == TEAM_COLOR1) {
bprint("$qc_ks_joined_red", self.netname); // red
} else if (self.lastteam == TEAM_COLOR2) {
bprint("$qc_ks_joined_blue", self.netname); // blue
}
self.impulse = 0;
self.player_flag = self.player_flag | TEAM_STUFF_COLOR;
// disable skin swaps since we don't have those skins in the md5
// if (self.lastteam == TEAM_COLOR1)
// self.skin = 1;
// else
// self.skin = 3;
// if (random() < 0.5)
// self.skin = self.skin + 1; // visor dude
self.player_flag = self.player_flag - (self.player_flag & 65280);
self.player_flag = self.player_flag | (self.skin * 256);
self.weapon = W_BestWeapon();
respawn();
W_SetCurrentAmmo();
TeamSetColor(self, self.lastteam - 1, self.lastteam - 1);
return TRUE;
};
void () ObserverThink =
{
local entity e;
local float cont;
self.weaponmodel = "";
self.weaponframe = 0;
self.flags = self.flags | FL_ONGROUND;
{
local float invcos,nv,nvp,nvpmax,nvs,nsp,sp,svz;
local vector f,vp,vs;
svz = self.velocity_z * 0.75;
self.velocity_z = 0;
// v_forward is already normalized
f_x = v_forward_x;
f_y = v_forward_y;
f_z = 0;
invcos = vlen(f); if (invcos) invcos= 1/invcos; else invcos=0;
f = f*invcos; // normalize f
sp = f * self.velocity;
vp = sp*f;
nvp = vlen(vp); if (sp<0) nvp = nvp*(-1);
vs = self.velocity - vp;
vp = v_forward * (nvp * invcos);
vp_z = vp_z + svz;
nvp = vlen(vp);
nvpmax = (320 - 100*(v_forward * '0 0 1'));
if (nvp > nvpmax) { vp = vp * (nvpmax/nvp); }
// swap z if going straight up and down due to 90/-90 deg
if (fabs(self.angles_x) == 30)
vp_z *= -1;
self.velocity = vp + vs;
}
// look for doors, etc.
e = findradius(self.origin,75);
while (e != world) {
if (e.classname == "func_door") {
ObserverDoor(self, e);
e = world;
}
if (e.classname == "trigger_teleport") {
ObserverTeleporter(self,e);
e = world;
}
e = e.chain;
if (!e) e = world;
}
if (self.button2 && !self.obs_fire_held) {
local entity spot = SelectSpawnPoint();
self.origin = spot.origin + '0 0 1';
self.angles = spot.angles;
self.fixangle = TRUE;
self.obs_fire_held = 1;
}
if (!self.button2 && self.obs_fire_held) {
self.obs_fire_held = 0;
}
};
void(entity player) BecomeObserver =
{
player.health = 999;
player.takedamage = DAMAGE_NO;
player.solid = SOLID_NOT;
player.movetype = MOVETYPE_FLY;
player.deadflag = DEAD_NO;
setmodel (player, string_null);
player.weaponmodel = "";
player.weaponframe = 0;
player.weapon = 0;
setsize(player, '-12 -12 -12', '12 12 12');
player.view_ofs = '0 0 10';
player.observer = 1;
player.do_observer = 0;
};

396
quakec_ctf/plats.qc Normal file
View file

@ -0,0 +1,396 @@
/* Copyright (C) 1996-2022 id Software LLC
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
See file, 'COPYING', for details.
*/
void() plat_center_touch;
void() plat_outside_touch;
void() plat_trigger_use;
void() plat_go_up;
void() plat_go_down;
void() plat_crush;
float PLAT_LOW_TRIGGER = 1;
void() plat_spawn_inside_trigger =
{
local entity trigger;
local vector tmin, tmax;
//
// middle trigger
//
trigger = spawn();
trigger.touch = plat_center_touch;
trigger.movetype = MOVETYPE_NONE;
trigger.solid = SOLID_TRIGGER;
trigger.enemy = self;
tmin = self.mins + '25 25 0';
tmax = self.maxs - '25 25 -8';
tmin_z = tmax_z - (self.pos1_z - self.pos2_z + 8);
if (self.spawnflags & PLAT_LOW_TRIGGER)
tmax_z = tmin_z + 8;
if (self.size_x <= 50)
{
tmin_x = (self.mins_x + self.maxs_x) / 2;
tmax_x = tmin_x + 1;
}
if (self.size_y <= 50)
{
tmin_y = (self.mins_y + self.maxs_y) / 2;
tmax_y = tmin_y + 1;
}
setsize (trigger, tmin, tmax);
};
void() plat_hit_top =
{
sound (self, CHAN_VOICE, self.noise1, 1, ATTN_NORM);
self.state = STATE_TOP;
self.think = plat_go_down;
self.nextthink = self.ltime + 3;
};
void() plat_hit_bottom =
{
sound (self, CHAN_VOICE, self.noise1, 1, ATTN_NORM);
self.state = STATE_BOTTOM;
};
void() plat_go_down =
{
sound (self, CHAN_VOICE, self.noise, 1, ATTN_NORM);
self.state = STATE_DOWN;
SUB_CalcMove (self.pos2, self.speed, plat_hit_bottom);
};
void() plat_go_up =
{
sound (self, CHAN_VOICE, self.noise, 1, ATTN_NORM);
self.state = STATE_UP;
SUB_CalcMove (self.pos1, self.speed, plat_hit_top);
};
void() plat_center_touch =
{
if (other.classname != "player")
return;
if (other.health <= 0)
return;
self = self.enemy;
if (self.state == STATE_BOTTOM)
plat_go_up ();
else if (self.state == STATE_TOP)
self.nextthink = self.ltime + 1; // delay going down
};
void() plat_outside_touch =
{
if (other.classname != "player")
return;
if (other.health <= 0)
return;
self = self.enemy;
if (self.state == STATE_TOP)
plat_go_down ();
};
void() plat_trigger_use =
{
if (self.think)
return; // allready activated
plat_go_down();
};
void() plat_crush =
{
T_Damage (other, self, self, 1);
if (self.state == STATE_UP)
plat_go_down ();
else if (self.state == STATE_DOWN)
plat_go_up ();
else
objerror ("plat_crush: bad self.state\n");
};
void() plat_use =
{
self.use = SUB_Null;
if (self.state != STATE_UP)
objerror ("plat_use: not in up state");
plat_go_down();
};
/*QUAKED func_plat (0 .5 .8) ? PLAT_LOW_TRIGGER
speed default 150
Plats are always drawn in the extended position, so they will light correctly.
If the plat is the target of another trigger or button, it will start out disabled in the extended position until it is trigger, when it will lower and become a normal plat.
If the "height" key is set, that will determine the amount the plat moves, instead of being implicitly determined by the model's height.
Set "sounds" to one of the following:
1) base fast
2) chain slow
*/
void() func_plat =
{
if (!self.t_length)
self.t_length = 80;
if (!self.t_width)
self.t_width = 10;
if (self.sounds == 0)
self.sounds = 2;
// FIX THIS TO LOAD A GENERIC PLAT SOUND
if (self.sounds == 1)
{
precache_sound ("plats/plat1.wav");
precache_sound ("plats/plat2.wav");
self.noise = "plats/plat1.wav";
self.noise1 = "plats/plat2.wav";
}
if (self.sounds == 2)
{
precache_sound ("plats/medplat1.wav");
precache_sound ("plats/medplat2.wav");
self.noise = "plats/medplat1.wav";
self.noise1 = "plats/medplat2.wav";
}
self.mangle = self.angles;
self.angles = '0 0 0';
self.classname = "func_plat";
self.solid = SOLID_BSP;
self.movetype = MOVETYPE_PUSH;
setorigin (self, self.origin);
setmodel (self, self.model);
setsize (self, self.mins , self.maxs);
self.blocked = plat_crush;
if (!self.speed)
self.speed = 150;
// pos1 is the top position, pos2 is the bottom
self.pos1 = self.origin;
self.pos2 = self.origin;
if (self.height)
self.pos2_z = self.origin_z - self.height;
else
self.pos2_z = self.origin_z - self.size_z + 8;
self.use = plat_trigger_use;
plat_spawn_inside_trigger (); // the "start moving" trigger
if (self.targetname != string_null)
{
self.state = STATE_UP;
self.use = plat_use;
}
else
{
setorigin (self, self.pos2);
self.state = STATE_BOTTOM;
}
};
//============================================================================
void() train_next;
void() func_train_find;
void() train_blocked =
{
if (time < self.attack_finished)
return;
self.attack_finished = time + 0.5;
T_Damage (other, self, self, self.dmg);
};
void() train_use =
{
if (self.think != func_train_find)
return; // already activated
train_next();
};
void() train_wait =
{
if (self.wait)
{
self.nextthink = self.ltime + self.wait;
sound (self, CHAN_VOICE, self.noise, 1, ATTN_NORM);
}
else
self.nextthink = self.ltime + 0.1;
self.think = train_next;
};
void() train_next =
{
local entity targ;
targ = find (world, targetname, self.target);
self.target = targ.target;
if (!self.target)
objerror ("train_next: no next target");
if (targ.wait)
self.wait = targ.wait;
else
self.wait = 0;
sound (self, CHAN_VOICE, self.noise1, 1, ATTN_NORM);
SUB_CalcMove (targ.origin - self.mins, self.speed, train_wait);
};
void() func_train_find =
{
local entity targ;
targ = find (world, targetname, self.target);
self.target = targ.target;
setorigin (self, targ.origin - self.mins);
if (!self.targetname)
{ // not triggered, so start immediately
self.nextthink = self.ltime + 0.1;
self.think = train_next;
}
};
/*QUAKED func_train (0 .5 .8) ?
Trains are moving platforms that players can ride.
The targets origin specifies the min point of the train at each corner.
The train spawns at the first target it is pointing at.
If the train is the target of a button or trigger, it will not begin moving until activated.
speed default 100
dmg default 2
sounds
1) ratchet metal
*/
void() func_train =
{
if (!self.speed)
self.speed = 100;
if (!self.target)
objerror ("func_train without a target");
if (!self.dmg)
self.dmg = 2;
if (self.sounds == 0)
{
self.noise = ("misc/null.wav");
precache_sound ("misc/null.wav");
self.noise1 = ("misc/null.wav");
precache_sound ("misc/null.wav");
}
if (self.sounds == 1)
{
self.noise = ("plats/train2.wav");//stop sound
precache_sound ("plats/train2.wav");
self.noise1 = ("plats/train1.wav");//move sound
precache_sound ("plats/train1.wav");
}
self.cnt = 1;
self.solid = SOLID_BSP;
self.movetype = MOVETYPE_PUSH;
self.blocked = train_blocked;
self.use = train_use;
self.classname = "train";
setmodel (self, self.model);
setsize (self, self.mins , self.maxs);
setorigin (self, self.origin);
// start trains on the second frame, to make sure their targets have had
// a chance to spawn
self.nextthink = self.ltime + 0.1;
self.think = func_train_find;
};
/*QUAKED misc_teleporttrain (0 .5 .8) (-8 -8 -8) (8 8 8)
This is used for the final bos
*/
void() misc_teleporttrain =
{
if (!self.speed)
self.speed = 100;
if (!self.target)
objerror ("func_train without a target");
self.cnt = 1;
self.solid = SOLID_NOT;
self.movetype = MOVETYPE_PUSH;
self.blocked = train_blocked;
self.use = train_use;
self.avelocity = '100 200 300';
self.noise = ("misc/null.wav");
precache_sound ("misc/null.wav");
self.noise1 = ("misc/null.wav");
precache_sound ("misc/null.wav");
precache_model2 ("progs/teleport.mdl");
setmodel (self, "progs/teleport.mdl");
setsize (self, self.mins , self.maxs);
setorigin (self, self.origin);
// start trains on the second frame, to make sure their targets have had
// a chance to spawn
self.nextthink = self.ltime + 0.1;
self.think = func_train_find;
};

761
quakec_ctf/player.qc Normal file
View file

@ -0,0 +1,761 @@
/* Copyright (C) 1996-2022 id Software LLC
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
See file, 'COPYING', for details.
*/
void() bubble_bob;
void() W_FireChain;
void() player_chain5;
void() player_chain4;
/*
==============================================================================
PLAYER
==============================================================================
*/
$cd /raid/quake/id1/models/player_4
$origin 0 -6 24
$base base
$skin skin
//
// running
//
$frame axrun1 axrun2 axrun3 axrun4 axrun5 axrun6
$frame rockrun1 rockrun2 rockrun3 rockrun4 rockrun5 rockrun6
//
// standing
//
$frame stand1 stand2 stand3 stand4 stand5
$frame axstnd1 axstnd2 axstnd3 axstnd4 axstnd5 axstnd6
$frame axstnd7 axstnd8 axstnd9 axstnd10 axstnd11 axstnd12
//
// pain
//
$frame axpain1 axpain2 axpain3 axpain4 axpain5 axpain6
$frame pain1 pain2 pain3 pain4 pain5 pain6
//
// death
//
$frame axdeth1 axdeth2 axdeth3 axdeth4 axdeth5 axdeth6
$frame axdeth7 axdeth8 axdeth9
$frame deatha1 deatha2 deatha3 deatha4 deatha5 deatha6 deatha7 deatha8
$frame deatha9 deatha10 deatha11
$frame deathb1 deathb2 deathb3 deathb4 deathb5 deathb6 deathb7 deathb8
$frame deathb9
$frame deathc1 deathc2 deathc3 deathc4 deathc5 deathc6 deathc7 deathc8
$frame deathc9 deathc10 deathc11 deathc12 deathc13 deathc14 deathc15
$frame deathd1 deathd2 deathd3 deathd4 deathd5 deathd6 deathd7
$frame deathd8 deathd9
$frame deathe1 deathe2 deathe3 deathe4 deathe5 deathe6 deathe7
$frame deathe8 deathe9
//
// attacks
//
$frame nailatt1 nailatt2
$frame light1 light2
$frame rockatt1 rockatt2 rockatt3 rockatt4 rockatt5 rockatt6
$frame shotatt1 shotatt2 shotatt3 shotatt4 shotatt5 shotatt6
$frame axatt1 axatt2 axatt3 axatt4 axatt5 axatt6
$frame axattb1 axattb2 axattb3 axattb4 axattb5 axattb6
$frame axattc1 axattc2 axattc3 axattc4 axattc5 axattc6
$frame axattd1 axattd2 axattd3 axattd4 axattd5 axattd6
/*
==============================================================================
PLAYER
==============================================================================
*/
void() player_run;
void() player_stand1 =[ $axstnd1, player_stand1 ]
{
self.weaponframe = 0;
if (self.velocity_x || self.velocity_y)
{
self.walkframe=0;
player_run();
return;
}
if (self.weapon == IT_AXE || self.weapon == IT_HOOK)
{
if (self.walkframe >= 12)
self.walkframe = 0;
self.frame = $axstnd1 + self.walkframe;
}
else
{
if (self.walkframe >= 5)
self.walkframe = 0;
self.frame = $stand1 + self.walkframe;
}
self.walkframe = self.walkframe + 1;
};
void() player_run =[ $rockrun1, player_run ]
{
self.weaponframe = 0;
if (!self.velocity_x && !self.velocity_y)
{
self.walkframe=0;
player_stand1();
return;
}
if (self.weapon == IT_AXE || self.weapon == IT_HOOK)
{
if (self.walkframe == 6)
self.walkframe = 0;
self.frame = $axrun1 + self.walkframe;
}
else
{
if (self.walkframe == 6)
self.walkframe = 0;
self.frame = self.frame + self.walkframe;
}
self.walkframe = self.walkframe + 1;
};
void() player_shot1 = [$shotatt1, player_shot2 ] {
self.weaponframe = 1;
self.effects = self.effects | EF_MUZZLEFLASH;
};
void() player_shot2 = [$shotatt2, player_shot3 ] {self.weaponframe=2;};
void() player_shot3 = [$shotatt3, player_shot4 ] {self.weaponframe=3;};
void() player_shot4 = [$shotatt4, player_shot5 ] {self.weaponframe=4;};
void() player_shot5 = [$shotatt5, player_shot6 ] {self.weaponframe=5;};
void() player_shot6 = [$shotatt6, player_run ] {self.weaponframe=6;};
void() player_axe1 = [$axatt1, player_axe2 ] {self.weaponframe=1;};
void() player_axe2 = [$axatt2, player_axe3 ] {self.weaponframe=2;};
void() player_axe3 = [$axatt3, player_axe4 ] {self.weaponframe=3;W_FireAxe();};
void() player_axe4 = [$axatt4, player_run ] {self.weaponframe=4;};
void() player_axeb1 = [$axattb1, player_axeb2 ] {self.weaponframe=5;};
void() player_axeb2 = [$axattb2, player_axeb3 ] {self.weaponframe=6;};
void() player_axeb3 = [$axattb3, player_axeb4 ] {self.weaponframe=7;W_FireAxe();};
void() player_axeb4 = [$axattb4, player_run ] {self.weaponframe=8;};
void() player_axec1 = [$axattc1, player_axec2 ] {self.weaponframe=1;};
void() player_axec2 = [$axattc2, player_axec3 ] {self.weaponframe=2;};
void() player_axec3 = [$axattc3, player_axec4 ] {self.weaponframe=3;W_FireAxe();};
void() player_axec4 = [$axattc4, player_run ] {self.weaponframe=4;};
void() player_axed1 = [$axattd1, player_axed2 ] {self.weaponframe=5;};
void() player_axed2 = [$axattd2, player_axed3 ] {self.weaponframe=6;};
void() player_axed3 = [$axattd3, player_axed4 ] {self.weaponframe=7;W_FireAxe();};
void() player_axed4 = [$axattd4, player_run ] {self.weaponframe=8;};
void() player_chain1= [$axattd1, player_chain2 ] {self.weaponframe=2;};
void() player_chain2= [$axattd2, player_chain3 ] {self.weaponframe=3;W_FireChain();};
void() player_chain3= [$axattd3, player_chain3 ]
{
self.weaponframe=3;
if (!self.hook_out)
{
player_chain5();
return;
}
if (vlen(self.velocity) >= 750)
{
player_chain4();
return;
}
};
void() player_chain4= [$deathc4, player_chain4 ]
{
self.weaponframe=4;
if (!self.hook_out)
{
player_chain5();
return;
}
if (vlen(self.velocity) < 750)
{
player_chain3();
return;
}
};
void() player_chain5= [$axattd4, player_run ] {self.weaponframe=5;};
//============================================================================
void() player_nail1 =[$nailatt1, player_nail2 ]
{
self.effects = self.effects | EF_MUZZLEFLASH;
if (!self.button0)
{player_run ();return;}
self.weaponframe = self.weaponframe + 1;
if (self.weaponframe == 9)
self.weaponframe = 1;
SuperDamageSound();
W_FireSpikes (4);
self.attack_finished = time + 0.2;
};
void() player_nail2 =[$nailatt2, player_nail1 ]
{
self.effects = self.effects | EF_MUZZLEFLASH;
if (!self.button0)
{player_run ();return;}
self.weaponframe = self.weaponframe + 1;
if (self.weaponframe == 9)
self.weaponframe = 1;
SuperDamageSound();
W_FireSpikes (-4);
self.attack_finished = time + 0.2;
};
//============================================================================
void() player_light1 =[$light1, player_light2 ]
{
self.effects = self.effects | EF_MUZZLEFLASH;
if (!self.button0)
{player_run ();return;}
self.weaponframe = self.weaponframe + 1;
if (self.weaponframe == 5)
self.weaponframe = 1;
SuperDamageSound();
W_FireLightning();
self.attack_finished = time + 0.2;
};
void() player_light2 =[$light2, player_light1 ]
{
self.effects = self.effects | EF_MUZZLEFLASH;
if (!self.button0)
{player_run ();return;}
self.weaponframe = self.weaponframe + 1;
if (self.weaponframe == 5)
self.weaponframe = 1;
SuperDamageSound();
W_FireLightning();
self.attack_finished = time + 0.2;
};
//============================================================================
void() player_rocket1 =[$rockatt1, player_rocket2 ] {
self.weaponframe = 1;
self.effects = self.effects | EF_MUZZLEFLASH;
};
void() player_rocket2 =[$rockatt2, player_rocket3 ] {self.weaponframe=2;};
void() player_rocket3 =[$rockatt3, player_rocket4 ] {self.weaponframe=3;};
void() player_rocket4 =[$rockatt4, player_rocket5 ] {self.weaponframe=4;};
void() player_rocket5 =[$rockatt5, player_rocket6 ] {self.weaponframe=5;};
void() player_rocket6 =[$rockatt6, player_run ] {self.weaponframe=6;};
void(float num_bubbles) DeathBubbles;
void() PainSound =
{
local float rs;
if (self.health < 0)
return;
if (damage_attacker.classname == "teledeath")
{
sound (self, CHAN_VOICE, "player/teledth1.wav", 1, ATTN_NONE);
return;
}
// water pain sounds
if (self.watertype == CONTENT_WATER && self.waterlevel == 3)
{
DeathBubbles(1);
if (random() > 0.5)
sound (self, CHAN_VOICE, "player/drown1.wav", 1, ATTN_NORM);
else
sound (self, CHAN_VOICE, "player/drown2.wav", 1, ATTN_NORM);
return;
}
// slime pain sounds
if (self.watertype == CONTENT_SLIME)
{
// FIX ME put in some steam here
if (random() > 0.5)
sound (self, CHAN_VOICE, "player/lburn1.wav", 1, ATTN_NORM);
else
sound (self, CHAN_VOICE, "player/lburn2.wav", 1, ATTN_NORM);
return;
}
if (self.watertype == CONTENT_LAVA)
{
if (random() > 0.5)
sound (self, CHAN_VOICE, "player/lburn1.wav", 1, ATTN_NORM);
else
sound (self, CHAN_VOICE, "player/lburn2.wav", 1, ATTN_NORM);
return;
}
if (self.pain_finished > time)
{
self.axhitme = 0;
return;
}
self.pain_finished = time + 0.5;
// don't make multiple pain sounds right after each other
// ax pain sound
if (self.axhitme == 1)
{
self.axhitme = 0;
sound (self, CHAN_VOICE, "player/axhit1.wav", 1, ATTN_NORM);
return;
}
rs = rint((random() * 5) + 1);
self.noise = string_null;
if (rs == 1)
self.noise = "player/pain1.wav";
else if (rs == 2)
self.noise = "player/pain2.wav";
else if (rs == 3)
self.noise = "player/pain3.wav";
else if (rs == 4)
self.noise = "player/pain4.wav";
else if (rs == 5)
self.noise = "player/pain5.wav";
else
self.noise = "player/pain6.wav";
sound (self, CHAN_VOICE, self.noise, 1, ATTN_NORM);
return;
};
void() player_pain1 = [ $pain1, player_pain2 ] {PainSound();self.weaponframe=0;};
void() player_pain2 = [ $pain2, player_pain3 ] {};
void() player_pain3 = [ $pain3, player_pain4 ] {};
void() player_pain4 = [ $pain4, player_pain5 ] {};
void() player_pain5 = [ $pain5, player_pain6 ] {};
void() player_pain6 = [ $pain6, player_run ] {};
void() player_axpain1 = [ $axpain1, player_axpain2 ] {PainSound();self.weaponframe=0;};
void() player_axpain2 = [ $axpain2, player_axpain3 ] {};
void() player_axpain3 = [ $axpain3, player_axpain4 ] {};
void() player_axpain4 = [ $axpain4, player_axpain5 ] {};
void() player_axpain5 = [ $axpain5, player_axpain6 ] {};
void() player_axpain6 = [ $axpain6, player_run ] {};
void(entity attacker, float damage) player_pain =
{
if (self.weaponframe)
return;
if (self.invisible_finished > time)
return; // eyes don't have pain frames
if (self.weapon == IT_AXE || self.weapon == IT_HOOK)
player_axpain1 ();
else
player_pain1 ();
};
void() player_diea1;
void() player_dieb1;
void() player_diec1;
void() player_died1;
void() player_diee1;
void() player_die_ax1;
void() DeathBubblesSpawn =
{
local entity bubble;
if (self.owner.waterlevel != 3)
return;
bubble = spawn();
setmodel (bubble, "progs/s_bubble.spr");
setorigin (bubble, self.owner.origin + '0 0 24');
bubble.movetype = MOVETYPE_NOCLIP;
bubble.solid = SOLID_NOT;
bubble.velocity = '0 0 15';
bubble.nextthink = time + 0.5;
bubble.think = bubble_bob;
bubble.classname = "bubble";
bubble.frame = 0;
bubble.cnt = 0;
setsize (bubble, '-8 -8 -8', '8 8 8');
self.nextthink = time + 0.1;
self.think = DeathBubblesSpawn;
self.air_finished = self.air_finished + 1;
if (self.air_finished >= self.bubble_count)
remove(self);
};
void(float num_bubbles) DeathBubbles =
{
local entity bubble_spawner;
bubble_spawner = spawn();
setorigin (bubble_spawner, self.origin);
bubble_spawner.movetype = MOVETYPE_NONE;
bubble_spawner.solid = SOLID_NOT;
bubble_spawner.nextthink = time + 0.1;
bubble_spawner.think = DeathBubblesSpawn;
bubble_spawner.air_finished = 0;
bubble_spawner.owner = self;
bubble_spawner.bubble_count = num_bubbles;
return;
};
void() DeathSound =
{
local float rs;
// water death sounds
if (self.waterlevel == 3)
{
DeathBubbles(20);
sound (self, CHAN_VOICE, "player/h2odeath.wav", 1, ATTN_NONE);
return;
}
rs = rint ((random() * 4) + 1);
if (rs == 1)
self.noise = "player/death1.wav";
if (rs == 2)
self.noise = "player/death2.wav";
if (rs == 3)
self.noise = "player/death3.wav";
if (rs == 4)
self.noise = "player/death4.wav";
if (rs == 5)
self.noise = "player/death5.wav";
sound (self, CHAN_VOICE, self.noise, 1, ATTN_NONE);
return;
};
void() PlayerDead =
{
self.nextthink = -1;
self.deadflag = DEAD_DEAD; // allow respawn after a certain time
};
vector(float dm) VelocityForDamage =
{
local vector v;
v_x = 100 * crandom();
v_y = 100 * crandom();
v_z = 200 + 100 * random();
if (dm > -50)
{
v = v * 0.7;
}
else if (dm > -200)
{
v = v * 2;
}
else
v = v * 10;
return v;
};
void(string gibname, float dm) ThrowGib =
{
local entity new;
new = spawn();
new.origin = self.origin;
setmodel (new, gibname);
setsize (new, '0 0 0', '0 0 0');
new.velocity = VelocityForDamage (dm);
new.movetype = MOVETYPE_BOUNCE;
if (cvar("pr_checkextension"))
if (checkextension("EX_MOVETYPE_GIB"))
new.movetype = MOVETYPE_GIB;
new.solid = SOLID_NOT;
new.avelocity_x = random()*600;
new.avelocity_y = random()*600;
new.avelocity_z = random()*600;
new.think = SUB_Remove;
new.ltime = time;
new.nextthink = time + 10 + random()*10;
new.frame = 0;
new.flags = 0;
};
void(string gibname, float dm) ThrowHead =
{
setmodel (self, gibname);
self.frame = 0;
self.nextthink = -1;
self.movetype = MOVETYPE_BOUNCE;
if (cvar("pr_checkextension"))
if (checkextension("EX_MOVETYPE_GIB"))
self.movetype = MOVETYPE_GIB;
self.takedamage = DAMAGE_NO;
self.solid = SOLID_NOT;
self.view_ofs = '0 0 8';
setsize (self, '-16 -16 0', '16 16 56');
self.velocity = VelocityForDamage (dm);
self.origin_z = self.origin_z - 24;
self.flags = self.flags - (self.flags & FL_ONGROUND);
self.avelocity = crandom() * '0 600 0';
};
void() GibPlayer =
{
ThrowHead ("progs/h_player.mdl", self.health);
ThrowGib ("progs/gib1.mdl", self.health);
ThrowGib ("progs/gib2.mdl", self.health);
ThrowGib ("progs/gib3.mdl", self.health);
self.deadflag = DEAD_DEAD;
if (damage_attacker.classname == "teledeath")
{
sound (self, CHAN_VOICE, "player/teledth1.wav", 1, ATTN_NONE);
return;
}
if (damage_attacker.classname == "teledeath2")
{
sound (self, CHAN_VOICE, "player/teledth1.wav", 1, ATTN_NONE);
return;
}
if (random() < 0.5)
sound (self, CHAN_VOICE, "player/gib.wav", 1, ATTN_NONE);
else
sound (self, CHAN_VOICE, "player/udeath.wav", 1, ATTN_NONE);
};
void() PlayerDie =
{
local float i;
self.items = self.items - (self.items & ( IT_INVISIBILITY | IT_INVULNERABILITY | IT_SUIT | IT_QUAD ) );
self.invisible_finished = 0; // don't die as eyes
self.invincible_finished = 0;
self.super_damage_finished = 0;
self.radsuit_finished = 0;
self.effects = 0;
self.modelindex = modelindex_player; // don't use eyes
if (deathmatch || coop) {
DropBackpack();
DropRune();
TeamCaptureDropFlagOfPlayer(self);
}
self.weaponmodel = string_null;
self.view_ofs = '0 0 -8';
self.deadflag = DEAD_DYING;
self.solid = SOLID_NOT;
self.flags = self.flags - (self.flags & FL_ONGROUND);
self.movetype = MOVETYPE_TOSS;
if (self.velocity_z < 10)
self.velocity_z = self.velocity_z + random()*300;
if (self.health < -40)
{
GibPlayer ();
return;
}
DeathSound();
self.angles_x = 0;
self.angles_z = 0;
if (self.weapon == IT_AXE || self.weapon == IT_HOOK)
{
player_die_ax1 ();
return;
}
i = ( 1 + floor( random() * 6 ) );
if (i == 1)
player_diea1();
else if (i == 2)
player_dieb1();
else if (i == 3)
player_diec1();
else if (i == 4)
player_died1();
else
player_diee1();
};
void() set_suicide_frame =
{ // used by klill command and diconnect command
if (self.model != "progs/player.mdl")
return; // allready gibbed
self.frame = $deatha11;
self.solid = SOLID_NOT;
self.movetype = MOVETYPE_TOSS;
self.deadflag = DEAD_DEAD;
self.nextthink = -1;
};
void() player_diea1 = [ $deatha1, player_diea2 ] {};
void() player_diea2 = [ $deatha2, player_diea3 ] {};
void() player_diea3 = [ $deatha3, player_diea4 ] {};
void() player_diea4 = [ $deatha4, player_diea5 ] {};
void() player_diea5 = [ $deatha5, player_diea6 ] {};
void() player_diea6 = [ $deatha6, player_diea7 ] {};
void() player_diea7 = [ $deatha7, player_diea8 ] {};
void() player_diea8 = [ $deatha8, player_diea9 ] {};
void() player_diea9 = [ $deatha9, player_diea10 ] {};
void() player_diea10 = [ $deatha10, player_diea11 ] {};
void() player_diea11 = [ $deatha11, player_diea11 ] {PlayerDead();};
void() player_dieb1 = [ $deathb1, player_dieb2 ] {};
void() player_dieb2 = [ $deathb2, player_dieb3 ] {};
void() player_dieb3 = [ $deathb3, player_dieb4 ] {};
void() player_dieb4 = [ $deathb4, player_dieb5 ] {};
void() player_dieb5 = [ $deathb5, player_dieb6 ] {};
void() player_dieb6 = [ $deathb6, player_dieb7 ] {};
void() player_dieb7 = [ $deathb7, player_dieb8 ] {};
void() player_dieb8 = [ $deathb8, player_dieb9 ] {};
void() player_dieb9 = [ $deathb9, player_dieb9 ] {PlayerDead();};
void() player_diec1 = [ $deathc1, player_diec2 ] {};
void() player_diec2 = [ $deathc2, player_diec3 ] {};
void() player_diec3 = [ $deathc3, player_diec4 ] {};
void() player_diec4 = [ $deathc4, player_diec5 ] {};
void() player_diec5 = [ $deathc5, player_diec6 ] {};
void() player_diec6 = [ $deathc6, player_diec7 ] {};
void() player_diec7 = [ $deathc7, player_diec8 ] {};
void() player_diec8 = [ $deathc8, player_diec9 ] {};
void() player_diec9 = [ $deathc9, player_diec10 ] {};
void() player_diec10 = [ $deathc10, player_diec11 ] {};
void() player_diec11 = [ $deathc11, player_diec12 ] {};
void() player_diec12 = [ $deathc12, player_diec13 ] {};
void() player_diec13 = [ $deathc13, player_diec14 ] {};
void() player_diec14 = [ $deathc14, player_diec15 ] {};
void() player_diec15 = [ $deathc15, player_diec15 ] {PlayerDead();};
void() player_died1 = [ $deathd1, player_died2 ] {};
void() player_died2 = [ $deathd2, player_died3 ] {};
void() player_died3 = [ $deathd3, player_died4 ] {};
void() player_died4 = [ $deathd4, player_died5 ] {};
void() player_died5 = [ $deathd5, player_died6 ] {};
void() player_died6 = [ $deathd6, player_died7 ] {};
void() player_died7 = [ $deathd7, player_died8 ] {};
void() player_died8 = [ $deathd8, player_died9 ] {};
void() player_died9 = [ $deathd9, player_died9 ] {PlayerDead();};
void() player_diee1 = [ $deathe1, player_diee2 ] {};
void() player_diee2 = [ $deathe2, player_diee3 ] {};
void() player_diee3 = [ $deathe3, player_diee4 ] {};
void() player_diee4 = [ $deathe4, player_diee5 ] {};
void() player_diee5 = [ $deathe5, player_diee6 ] {};
void() player_diee6 = [ $deathe6, player_diee7 ] {};
void() player_diee7 = [ $deathe7, player_diee8 ] {};
void() player_diee8 = [ $deathe8, player_diee9 ] {};
void() player_diee9 = [ $deathe9, player_diee9 ] {PlayerDead();};
void() player_die_ax1 = [ $axdeth1, player_die_ax2 ] {};
void() player_die_ax2 = [ $axdeth2, player_die_ax3 ] {};
void() player_die_ax3 = [ $axdeth3, player_die_ax4 ] {};
void() player_die_ax4 = [ $axdeth4, player_die_ax5 ] {};
void() player_die_ax5 = [ $axdeth5, player_die_ax6 ] {};
void() player_die_ax6 = [ $axdeth6, player_die_ax7 ] {};
void() player_die_ax7 = [ $axdeth7, player_die_ax8 ] {};
void() player_die_ax8 = [ $axdeth8, player_die_ax9 ] {};
void() player_die_ax9 = [ $axdeth9, player_die_ax9 ] {PlayerDead();};

143
quakec_ctf/progdefs.h Normal file
View file

@ -0,0 +1,143 @@
/* file generated by qcc, do not modify */
typedef struct
{ int pad[28];
int self;
int other;
int world;
float time;
float frametime;
float force_retouch;
string_t mapname;
float deathmatch;
float coop;
float teamplay;
float serverflags;
float total_secrets;
float total_monsters;
float found_secrets;
float killed_monsters;
float parm1;
float parm2;
float parm3;
float parm4;
float parm5;
float parm6;
float parm7;
float parm8;
float parm9;
float parm10;
float parm11;
float parm12;
float parm13;
float parm14;
float parm15;
float parm16;
vec3_t v_forward;
vec3_t v_up;
vec3_t v_right;
float trace_allsolid;
float trace_startsolid;
float trace_fraction;
vec3_t trace_endpos;
vec3_t trace_plane_normal;
float trace_plane_dist;
int trace_ent;
float trace_inopen;
float trace_inwater;
int msg_entity;
func_t main;
func_t StartFrame;
func_t PlayerPreThink;
func_t PlayerPostThink;
func_t ClientKill;
func_t ClientConnect;
func_t PutClientInServer;
func_t ClientDisconnect;
func_t SetNewParms;
func_t SetChangeParms;
} globalvars_t;
typedef struct
{
float modelindex;
vec3_t absmin;
vec3_t absmax;
float ltime;
float movetype;
float solid;
vec3_t origin;
vec3_t oldorigin;
vec3_t velocity;
vec3_t angles;
vec3_t avelocity;
vec3_t punchangle;
string_t classname;
string_t model;
float frame;
float skin;
float effects;
vec3_t mins;
vec3_t maxs;
vec3_t size;
func_t touch;
func_t use;
func_t think;
func_t blocked;
float nextthink;
int groundentity;
float health;
float frags;
float weapon;
string_t weaponmodel;
float weaponframe;
float currentammo;
float ammo_shells;
float ammo_nails;
float ammo_rockets;
float ammo_cells;
float items;
float takedamage;
int chain;
float deadflag;
vec3_t view_ofs;
float button0;
float button1;
float button2;
float impulse;
float fixangle;
vec3_t v_angle;
float idealpitch;
string_t netname;
int enemy;
float flags;
float colormap;
float team;
float max_health;
float teleport_time;
float armortype;
float armorvalue;
float waterlevel;
float watertype;
float ideal_yaw;
float yaw_speed;
int aiment;
int goalentity;
float spawnflags;
string_t target;
string_t targetname;
float dmg_take;
float dmg_save;
int dmg_inflictor;
int owner;
vec3_t movedir;
string_t message;
float sounds;
string_t noise;
string_t noise1;
string_t noise2;
string_t noise3;
} entvars_t;
#define PROGHEADER_CRC 5927

24
quakec_ctf/progs.src Normal file
View file

@ -0,0 +1,24 @@
../qsrc/ctf/progs.dat
defs.qc
log.qc // Console logging of game actions
teamplay.qc // Compile the teamplay file
ctfgame.qc // vote exit stuff
status.qc // team status stuff
subs.qc
combat.qc
itemnames.qc
items.qc
observ.qc
weapons.qc
world.qc
client.qc
player.qc
doors.qc
buttons.qc
triggers.qc
plats.qc
misc.qc
hook.qc
server.qc
bots/bot.qc

114
quakec_ctf/server.qc Normal file
View file

@ -0,0 +1,114 @@
/* Copyright (C) 1996-2022 id Software LLC
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
See file, 'COPYING', for details.
*/
void() monster_ogre = {remove(self);};
void() monster_demon1 = {remove(self);};
void() monster_shambler = {remove(self);};
void() monster_knight = {remove(self);};
void() monster_army = {remove(self);};
void() monster_wizard = {remove(self);};
void() monster_dog = {remove(self);};
void() monster_zombie = {remove(self);};
void() monster_boss = {remove(self);};
void() monster_tarbaby = {remove(self);};
void() monster_hell_knight = {remove(self);};
void() monster_fish = {remove(self);};
void() monster_shalrath = {remove(self);};
void() monster_enforcer = {remove(self);};
void() monster_oldone = {remove(self);};
/*
==============================================================================
MOVETARGET CODE
The angle of the movetarget effects standing and bowing direction, but has no effect on movement, which allways heads to the next target.
targetname
must be present. The name of this movetarget.
target
the next spot to move to. If not present, stop here for good.
pausetime
The number of seconds to spend standing or bowing for path_stand or path_bow
==============================================================================
*/
/*
=============
t_movetarget
Something has bumped into a movetarget. If it is a monster
moving towards it, change the next destination and continue.
==============
*/
void() t_movetarget =
{
local entity temp;
if (other.movetarget != self)
return;
if (other.enemy)
return; // fighting, not following a path
temp = self;
self = other;
other = temp;
if (self.classname == "monster_ogre")
sound (self, CHAN_VOICE, "ogre/ogdrag.wav", 1, ATTN_IDLE);// play chainsaw drag sound
//dprint ("t_movetarget\n");
self.goalentity = self.movetarget = find (world, targetname, other.target);
self.ideal_yaw = vectoyaw(self.goalentity.origin - self.origin);
if (!self.movetarget)
{
self.pausetime = time + 999999;
self.th_stand ();
return;
}
};
void() movetarget_f =
{
if (!self.targetname)
objerror ("monster_movetarget: no targetname");
self.solid = SOLID_TRIGGER;
self.touch = t_movetarget;
setsize (self, '-8 -8 -8', '8 8 8');
};
/*QUAKED path_corner (0.5 0.3 0) (-8 -8 -8) (8 8 8)
Monsters will continue walking towards the next target corner.
*/
void() path_corner =
{
movetarget_f ();
};
//============================================================================

117
quakec_ctf/status.qc Normal file
View file

@ -0,0 +1,117 @@
/* Copyright (C) 1996-2022 id Software LLC
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
See file, 'COPYING', for details.
*/
.float laststattime; // time of last status update
.float statstate; // is the status bar on?
float PLAYERSTATTIME = 1.75;
void() MOTD =
{
SendCTFScoresUpdate(self);
if (gamestart) {
centerprint(self, "$qc_choose_exit");
return;
}
if (self.team == TEAM_COLOR1)
centerprint(self, "$qc_ctf_red"); //red
else
centerprint(self, "$qc_ctf_blue"); //blue
return;
};
void() MOTD_ChooseTeam =
{
SendCTFScoresUpdate(self);
if (PromptSupported()) {
prompt(self, "$qc_ctf_intro", 4);
promptchoice(self, "$qc_ctf_intro_auto", 103);
promptchoice(self, "$qc_ctf_intro_red", 101);
promptchoice(self, "$qc_ctf_intro_blue", 102);
promptchoice(self, "$qc_ctf_intro_observer", 104);
} else {
centerprint(self, "Welcome!\nRunning ThreeWave CTF 5.0\n\nCapture the Flag!\n\nPress 1 for RED team\nPress 2 for BLUE team\nOr press JUMP for automatic team\n");
}
};
void() TeamEndScore =
{
local string s;
if (gamestart)
return;
if (teamscr1 > teamscr2) {
s = ftos(teamscr1);
bprint("$qc_ks_red_won", s);
s = ftos(teamscr2);
bprint("$qc_ks_blue_lost", s);
} else if (teamscr1 < teamscr2) {
s = ftos(teamscr2);
bprint("$qc_ks_blue_won", s);
s = ftos(teamscr1);
bprint("$qc_ks_red_lost", s);
} else {
s = ftos(teamscr1);
bprint("$qc_ks_match_tied", s);
}
};
void(entity e) SendCTFScoresUpdate =
{
local float flagstatus = 0;
local entity flag;
flag = find(world, classname, "item_flag_team1");
if (flag.cnt == FLAG_AT_BASE)
flagstatus |= 1;
else if (flag.cnt == FLAG_CARRIED)
flagstatus |= 2;
else if (flag.cnt == FLAG_DROPPED)
flagstatus |= 4;
flag = find(world, classname, "item_flag_team2");
if (flag.cnt == FLAG_AT_BASE)
flagstatus |= 8;
else if (flag.cnt == FLAG_CARRIED)
flagstatus |= 16;
else if (flag.cnt == FLAG_DROPPED)
flagstatus |= 32;
stuffcmd(e, "ctfscores ");
stuffcmd(e, ftos(teamscr1));
stuffcmd(e, " ");
stuffcmd(e, ftos(teamscr2));
stuffcmd(e, " ");
stuffcmd(e, ftos(flagstatus));
stuffcmd(e, "\n");
};
void() SendCTFScoresUpdateAll =
{
local entity e = find(world, classname, "player");
while(e)
{
SendCTFScoresUpdate(e);
e = find(e, classname, "player");
}
}

301
quakec_ctf/subs.qc Normal file
View file

@ -0,0 +1,301 @@
/* Copyright (C) 1996-2022 id Software LLC
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
See file, 'COPYING', for details.
*/
void() SUB_Null = {};
void() SUB_Remove = {remove(self);};
/*
QuakeEd only writes a single float for angles (bad idea), so up and down are
just constant angles.
*/
void() SetMovedir =
{
if (self.angles == '0 -1 0')
self.movedir = '0 0 1';
else if (self.angles == '0 -2 0')
self.movedir = '0 0 -1';
else
{
makevectors(self.angles);
self.movedir = v_forward;
}
self.angles = '0 0 0';
};
/*
================
InitTrigger
================
*/
void() InitTrigger =
{
// trigger angles are used for one-way touches. An angle of 0 is assumed
// to mean no restrictions, so use a yaw of 360 instead.
if (self.angles != '0 0 0')
SetMovedir ();
self.solid = SOLID_TRIGGER;
setmodel (self, self.model); // set size and link into world
self.movetype = MOVETYPE_NONE;
self.modelindex = 0;
self.model = string_null;
};
/*
=============
SUB_CalcMove
calculate self.velocity and self.nextthink to reach dest from
self.origin traveling at speed
===============
*/
void(entity ent, vector tdest, float tspeed, void() func) SUB_CalcMoveEnt =
{
local entity stemp;
stemp = self;
self = ent;
SUB_CalcMove (tdest, tspeed, func);
self = stemp;
};
void(vector tdest, float tspeed, void() func) SUB_CalcMove =
{
local vector vdestdelta;
local float len, traveltime;
if (!tspeed)
objerror("No speed is defined!");
self.think1 = func;
self.finaldest = tdest;
self.think = SUB_CalcMoveDone;
if (tdest == self.origin)
{
self.velocity = '0 0 0';
self.nextthink = self.ltime + 0.1;
return;
}
// set destdelta to the vector needed to move
vdestdelta = tdest - self.origin;
// calculate length of vector
len = vlen (vdestdelta);
// divide by speed to get time to reach dest
traveltime = len / tspeed;
if (traveltime < 0.1)
{
self.velocity = '0 0 0';
self.nextthink = self.ltime + 0.1;
return;
}
// set nextthink to trigger a think when dest is reached
self.nextthink = self.ltime + traveltime;
// scale the destdelta vector by the time spent traveling to get velocity
self.velocity = vdestdelta * (1/traveltime); // qcc won't take vec/float
};
/*
============
After moving, set origin to exact final destination
============
*/
void() SUB_CalcMoveDone =
{
setorigin(self, self.finaldest);
self.velocity = '0 0 0';
self.nextthink = -1;
if (self.think1)
self.think1();
};
/*
=============
SUB_CalcAngleMove
calculate self.avelocity and self.nextthink to reach destangle from
self.angles rotating
The calling function should make sure self.think is valid
===============
*/
void(entity ent, vector destangle, float tspeed, void() func) SUB_CalcAngleMoveEnt =
{
local entity stemp;
stemp = self;
self = ent;
SUB_CalcAngleMove (destangle, tspeed, func);
self = stemp;
};
void(vector destangle, float tspeed, void() func) SUB_CalcAngleMove =
{
local vector destdelta;
local float len, traveltime;
if (!tspeed)
objerror("No speed is defined!");
// set destdelta to the vector needed to move
destdelta = destangle - self.angles;
// calculate length of vector
len = vlen (destdelta);
// divide by speed to get time to reach dest
traveltime = len / tspeed;
// set nextthink to trigger a think when dest is reached
self.nextthink = self.ltime + traveltime;
// scale the destdelta vector by the time spent traveling to get velocity
self.avelocity = destdelta * (1 / traveltime);
self.think1 = func;
self.finalangle = destangle;
self.think = SUB_CalcAngleMoveDone;
};
/*
============
After rotating, set angle to exact final angle
============
*/
void() SUB_CalcAngleMoveDone =
{
self.angles = self.finalangle;
self.avelocity = '0 0 0';
self.nextthink = -1;
if (self.think1)
self.think1();
};
//=============================================================================
void() DelayThink =
{
activator = self.enemy;
SUB_UseTargets ();
remove(self);
};
/*
==============================
SUB_UseTargets
the global "activator" should be set to the entity that initiated the firing.
If self.delay is set, a DelayedUse entity will be created that will actually
do the SUB_UseTargets after that many seconds have passed.
Centerprints any self.message to the activator.
Removes all entities with a targetname that match self.killtarget,
and removes them, so some events can remove other triggers.
Search for (string)targetname in all entities that
match (string)self.target and call their .use function
==============================
*/
void() SUB_UseTargets =
{
local entity t, act, stemp, otemp;
//
// check for a delay
//
if (self.delay)
{
// create a temp object to fire at a later time
t = spawn();
t.classname = "DelayedUse";
t.nextthink = time + self.delay;
t.think = DelayThink;
t.enemy = activator;
t.message = self.message;
t.killtarget = self.killtarget;
t.target = self.target;
return;
}
//
// print the message
//
if (activator.classname == "player" && self.message != string_null)
{
centerprint (activator, self.message);
if (!self.noise)
sound (activator, CHAN_VOICE, "misc/talk.wav", 1, ATTN_NORM);
}
//
// kill the killtagets
//
if (self.killtarget != string_null)
{
t = find (world, targetname, self.killtarget);
while( t )
{
remove (t);
t = find (t, targetname, self.killtarget);
}
}
//
// fire targets
//
if (self.target != string_null)
{
act = activator;
t = find (world, targetname, self.target);
while( t )
{
stemp = self;
otemp = other;
self = t;
other = stemp;
if (self.use != SUB_Null)
{
if (self.use)
self.use ();
}
self = stemp;
other = otemp;
activator = act;
t = find (t, targetname, self.target);
}
}
};

1249
quakec_ctf/teamplay.qc Normal file

File diff suppressed because it is too large Load diff

686
quakec_ctf/triggers.qc Normal file
View file

@ -0,0 +1,686 @@
/* Copyright (C) 1996-2022 id Software LLC
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
See file, 'COPYING', for details.
*/
entity s;
void() trigger_reactivate =
{
self.solid = SOLID_TRIGGER;
};
//=============================================================================
float SPAWNFLAG_NOMESSAGE = 1;
float SPAWNFLAG_NOTOUCH = 1;
// the wait time has passed, so set back up for another activation
void() multi_wait =
{
if (self.max_health)
{
self.health = self.max_health;
self.takedamage = DAMAGE_YES;
self.solid = SOLID_BBOX;
}
};
// the trigger was just touched/killed/used
// self.enemy should be set to the activator so it can be held through a delay
// so wait for the delay time before firing
void() multi_trigger =
{
if (self.nextthink > time)
{
return; // allready been triggered
}
if (self.classname == "trigger_secret")
{
if (self.enemy.classname != "player")
return;
found_secrets = found_secrets + 1;
WriteByte (MSG_ALL, SVC_FOUNDSECRET);
}
if (self.noise != string_null)
sound (self, CHAN_VOICE, self.noise, 1, ATTN_NORM);
// don't trigger again until reset
self.takedamage = DAMAGE_NO;
activator = self.enemy;
SUB_UseTargets();
if (self.wait > 0)
{
self.think = multi_wait;
self.nextthink = time + self.wait;
}
else
{ // we can't just remove (self) here, because this is a touch function
// called wheil C code is looping through area links...
self.touch = SUB_Null;
self.nextthink = time + 0.1;
self.think = SUB_Remove;
}
};
void() multi_killed =
{
self.enemy = damage_attacker;
multi_trigger();
};
void() multi_use =
{
self.enemy = activator;
multi_trigger();
};
void() multi_touch =
{
if (other.classname != "player")
return;
// if the trigger has an angles field, check player's facing direction
if (self.movedir != '0 0 0')
{
makevectors(other.angles);
if (v_forward * self.movedir < 0)
return; // not facing the right way
}
self.enemy = other;
multi_trigger ();
};
/*QUAKED trigger_multiple (.5 .5 .5) ? notouch
Variable sized repeatable trigger. Must be targeted at one or more entities. If "health" is set, the trigger must be killed to activate each time.
If "delay" is set, the trigger waits some time after activating before firing.
"wait" : Seconds between triggerings. (.2 default)
If notouch is set, the trigger is only fired by other entities, not by touching.
NOTOUCH has been obsoleted by trigger_relay!
sounds
1) secret
2) beep beep
3) large switch
4)
set "message" to text string
*/
void() trigger_multiple =
{
if (self.sounds == 1)
{
precache_sound ("misc/secret.wav");
self.noise = "misc/secret.wav";
}
else if (self.sounds == 2)
{
precache_sound ("misc/talk.wav");
self.noise = "misc/talk.wav";
}
else if (self.sounds == 3)
{
precache_sound ("misc/trigger1.wav");
self.noise = "misc/trigger1.wav";
}
if (!self.wait)
self.wait = 0.2;
self.use = multi_use;
InitTrigger ();
if (self.health)
{
if (self.spawnflags & SPAWNFLAG_NOTOUCH)
objerror ("health and notouch don't make sense\n");
self.max_health = self.health;
self.th_die = multi_killed;
self.takedamage = DAMAGE_YES;
self.solid = SOLID_BBOX;
setorigin (self, self.origin); // make sure it links into the world
}
else
{
if ( !(self.spawnflags & SPAWNFLAG_NOTOUCH) )
{
self.touch = multi_touch;
}
}
};
/*QUAKED trigger_once (.5 .5 .5) ? notouch
Variable sized trigger. Triggers once, then removes itself. You must set the key "target" to the name of another object in the level that has a matching
"targetname". If "health" is set, the trigger must be killed to activate.
If notouch is set, the trigger is only fired by other entities, not by touching.
if "killtarget" is set, any objects that have a matching "target" will be removed when the trigger is fired.
if "angle" is set, the trigger will only fire when someone is facing the direction of the angle. Use "360" for an angle of 0.
sounds
1) secret
2) beep beep
3) large switch
4)
set "message" to text string
*/
void() trigger_once =
{
self.wait = -1;
trigger_multiple();
};
//=============================================================================
/*QUAKED trigger_relay (.5 .5 .5) (-8 -8 -8) (8 8 8)
This fixed size trigger cannot be touched, it can only be fired by other events. It can contain killtargets, targets, delays, and messages.
*/
void() trigger_relay =
{
self.use = SUB_UseTargets;
};
//=============================================================================
/*QUAKED trigger_secret (.5 .5 .5) ?
secret counter trigger
sounds
1) secret
2) beep beep
3)
4)
set "message" to text string
*/
void() trigger_secret =
{
total_secrets = total_secrets + 1;
self.wait = -1;
if (!self.message)
self.message = "$qc_found_secret";
if (!self.sounds)
self.sounds = 1;
if (self.sounds == 1)
{
precache_sound ("misc/secret.wav");
self.noise = "misc/secret.wav";
}
else if (self.sounds == 2)
{
precache_sound ("misc/talk.wav");
self.noise = "misc/talk.wav";
}
trigger_multiple ();
};
//=============================================================================
void() counter_use =
{
self.count = self.count - 1;
if (self.count < 0)
return;
if (self.count != 0)
{
if (activator.classname == "player" && (self.spawnflags & SPAWNFLAG_NOMESSAGE) == 0)
{
if (self.count >= 4)
centerprint (activator, "$qc_more_go");
else if (self.count == 3)
centerprint (activator, "$qc_three_more");
else if (self.count == 2)
centerprint (activator, "$qc_two_more");
else
centerprint (activator, "$qc_one_more");
}
return;
}
if (activator.classname == "player" && (self.spawnflags & SPAWNFLAG_NOMESSAGE) == 0)
centerprint(activator, "$qc_sequence_completed");
self.enemy = activator;
multi_trigger ();
};
/*QUAKED trigger_counter (.5 .5 .5) ? nomessage
Acts as an intermediary for an action that takes multiple inputs.
If nomessage is not set, t will print "1 more.. " etc when triggered and "sequence complete" when finished.
After the counter has been triggered "count" times (default 2), it will fire all of it's targets and remove itself.
*/
void() trigger_counter =
{
self.wait = -1;
if (!self.count)
self.count = 2;
self.use = counter_use;
};
/*
==============================================================================
TELEPORT TRIGGERS
==============================================================================
*/
float PLAYER_ONLY = 1;
float SILENT = 2;
void() play_teleport =
{
local float v;
local string tmpstr;
v = random() * 5;
if (v < 1)
tmpstr = "misc/r_tele1.wav";
else if (v < 2)
tmpstr = "misc/r_tele2.wav";
else if (v < 3)
tmpstr = "misc/r_tele3.wav";
else if (v < 4)
tmpstr = "misc/r_tele4.wav";
else
tmpstr = "misc/r_tele5.wav";
sound (self, CHAN_VOICE, tmpstr, 1, ATTN_NORM);
remove (self);
};
void(vector org) spawn_tfog =
{
s = spawn ();
s.origin = org;
s.nextthink = time + 0.2;
s.think = play_teleport;
WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
WriteByte (MSG_BROADCAST, TE_TELEPORT);
WriteCoord (MSG_BROADCAST, org_x);
WriteCoord (MSG_BROADCAST, org_y);
WriteCoord (MSG_BROADCAST, org_z);
};
void() tdeath_touch =
{
if (other == self.owner)
return;
// frag anyone who teleports in on top of an invincible player
if (other.classname == "player")
{
if (other.invincible_finished > time)
self.classname = "teledeath2";
if (self.owner.classname != "player")
{ // other monsters explode themselves
T_Damage (self.owner, self, self, 50000);
return;
}
}
if (other.health)
{
T_Damage (other, self, self, 50000);
}
};
void(vector org, entity death_owner) spawn_tdeath =
{
local entity death;
death = spawn();
death.classname = "teledeath";
death.movetype = MOVETYPE_NONE;
death.solid = SOLID_TRIGGER;
death.angles = '0 0 0';
setsize (death, death_owner.mins - '1 1 1', death_owner.maxs + '1 1 1');
setorigin (death, org);
death.touch = tdeath_touch;
death.nextthink = time + 0.2;
death.think = SUB_Remove;
death.owner = death_owner;
force_retouch = 2; // make sure even still objects get hit
};
void() teleport_touch =
{
local entity t;
local vector org;
if (self.targetname != string_null)
{
if (self.nextthink < time)
{
return; // not fired yet
}
}
if (self.spawnflags & PLAYER_ONLY)
{
if (other.classname != "player")
return;
}
// only teleport living creatures
if (other.health <= 0 || other.solid != SOLID_SLIDEBOX)
return;
SUB_UseTargets ();
// put a tfog where the player was
spawn_tfog (other.origin);
t = find (world, targetname, self.target);
if (!t)
objerror ("couldn't find target");
// spawn a tfog flash in front of the destination
makevectors (t.mangle);
org = t.origin + 32 * v_forward;
spawn_tfog (org);
spawn_tdeath(t.origin, other);
// move the player and lock him down for a little while
if (!other.health)
{
other.origin = t.origin;
other.velocity = (v_forward * other.velocity_x) + (v_forward * other.velocity_y);
return;
}
setorigin (other, t.origin);
other.angles = t.mangle;
if (other.classname == "player")
{
other.fixangle = 1; // turn this way immediately
other.teleport_time = time + 0.7;
if (other.flags & FL_ONGROUND)
other.flags = other.flags - FL_ONGROUND;
other.velocity = v_forward * 300;
}
other.flags = other.flags - other.flags & FL_ONGROUND;
};
/*QUAKED info_teleport_destination (.5 .5 .5) (-8 -8 -8) (8 8 32)
This is the destination marker for a teleporter. It should have a "targetname" field with the same value as a teleporter's "target" field.
*/
void() info_teleport_destination =
{
// this does nothing, just serves as a target spot
self.mangle = self.angles;
self.angles = '0 0 0';
self.model = string_null;
self.origin = self.origin + '0 0 27';
if (!self.targetname)
objerror ("no targetname");
};
void() teleport_use =
{
self.nextthink = time + 0.2;
force_retouch = 2; // make sure even still objects get hit
self.think = SUB_Null;
};
/*QUAKED trigger_teleport (.5 .5 .5) ? PLAYER_ONLY SILENT
Any object touching this will be transported to the corresponding info_teleport_destination entity. You must set the "target" field, and create an object with a "targetname" field that matches.
If the trigger_teleport has a targetname, it will only teleport entities when it has been fired.
*/
void() trigger_teleport =
{
local vector o;
InitTrigger ();
self.touch = teleport_touch;
// find the destination
if (!self.target)
objerror ("no target");
self.use = teleport_use;
self.netname = "trigger_teleport"; // lets us ID the entity in C code...
if (!(self.spawnflags & SILENT))
{
precache_sound ("ambience/hum1.wav");
o = (self.mins + self.maxs)*0.5;
ambientsound (o, "ambience/hum1.wav",0.5 , ATTN_STATIC);
}
};
/*
==============================================================================
trigger_setskill
==============================================================================
*/
void() trigger_skill_touch =
{
if (other.classname != "player")
return;
cvar_set ("skill", self.message);
};
/*QUAKED trigger_setskill (.5 .5 .5) ?
sets skill level to the value of "message".
Only used on start map.
*/
void() trigger_setskill =
{
InitTrigger ();
self.touch = trigger_skill_touch;
};
/*
==============================================================================
ONLY REGISTERED TRIGGERS
==============================================================================
*/
void() trigger_onlyregistered_touch =
{
if (other.classname != "player")
return;
if (self.attack_finished > time)
return;
self.attack_finished = time + 2;
if (cvar("registered"))
{
self.message = string_null;
SUB_UseTargets ();
remove (self);
}
else
{
if (self.message != string_null)
{
centerprint (other, self.message);
sound (other, CHAN_BODY, "misc/talk.wav", 1, ATTN_NORM);
}
}
};
/*QUAKED trigger_onlyregistered (.5 .5 .5) ?
Only fires if playing the registered version, otherwise prints the message
*/
void() trigger_onlyregistered =
{
precache_sound ("misc/talk.wav");
InitTrigger ();
self.touch = trigger_onlyregistered_touch;
};
//============================================================================
void() hurt_on =
{
self.solid = SOLID_TRIGGER;
self.nextthink = -1;
};
void() hurt_touch =
{
if (other.takedamage)
{
self.solid = SOLID_NOT;
T_Damage (other, self, self, self.dmg);
self.think = hurt_on;
self.nextthink = time + 1;
}
return;
};
/*QUAKED trigger_hurt (.5 .5 .5) ?
Any object touching this will be hurt
set dmg to damage amount
defalt dmg = 5
*/
void() trigger_hurt =
{
InitTrigger ();
self.touch = hurt_touch;
if (!self.dmg)
self.dmg = 5;
};
//============================================================================
float PUSH_ONCE = 1;
void() trigger_push_touch =
{
if (other.classname == "grenade")
other.velocity = self.speed * self.movedir * 10;
else if (other.health > 0)
{
other.velocity = self.speed * self.movedir * 10;
if (other.classname == "player")
{
if (other.fly_sound < time)
{
other.fly_sound = time + 1.5;
sound (other, CHAN_AUTO, "ambience/windfly.wav", 1, ATTN_NORM);
}
}
}
if (self.spawnflags & PUSH_ONCE)
remove(self);
};
/*QUAKED trigger_push (.5 .5 .5) ? PUSH_ONCE
Pushes the player
*/
void() trigger_push =
{
InitTrigger ();
precache_sound ("ambience/windfly.wav");
self.touch = trigger_push_touch;
self.netname = "trigger_push"; // lets us ID the entity in C code...
if (!self.speed)
self.speed = 1000;
};
//============================================================================
void() trigger_monsterjump_touch =
{
if ( other.flags & (FL_MONSTER | FL_FLY | FL_SWIM) != FL_MONSTER )
return;
// set XY even if not on ground, so the jump will clear lips
other.velocity_x = self.movedir_x * self.speed;
other.velocity_y = self.movedir_y * self.speed;
if ( !(other.flags & FL_ONGROUND) )
return;
other.flags = other.flags - FL_ONGROUND;
other.velocity_z = self.height;
};
/*QUAKED trigger_monsterjump (.5 .5 .5) ?
Walking monsters that touch this will jump in the direction of the trigger's angle
"speed" default to 200, the speed thrown forward
"height" default to 200, the speed thrown upwards
*/
void() trigger_monsterjump =
{
if (!self.speed)
self.speed = 200;
if (!self.height)
self.height = 200;
if (self.angles == '0 0 0')
self.angles = '0 360 0';
InitTrigger ();
self.touch = trigger_monsterjump_touch;
};

1543
quakec_ctf/weapons.qc Normal file

File diff suppressed because it is too large Load diff

417
quakec_ctf/world.qc Normal file
View file

@ -0,0 +1,417 @@
/* Copyright (C) 1996-2022 id Software LLC
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
See file, 'COPYING', for details.
*/
void() InitBodyQueue;
void() main =
{
dprint ("main function\n");
// these are just commands the the prog compiler to copy these files
precache_file ("progs.dat");
precache_file ("gfx.wad");
precache_file ("quake.rc");
precache_file ("default.cfg");
precache_file ("end1.bin");
precache_file2 ("end2.bin");
precache_file ("demo1.dem");
precache_file ("demo2.dem");
precache_file ("demo3.dem");
//
// these are all of the lumps from the cached.ls files
//
precache_file ("gfx/palette.lmp");
precache_file ("gfx/colormap.lmp");
precache_file2 ("gfx/pop.lmp");
precache_file ("gfx/complete.lmp");
precache_file ("gfx/inter.lmp");
precache_file ("gfx/ranking.lmp");
precache_file ("gfx/vidmodes.lmp");
precache_file ("gfx/finale.lmp");
precache_file ("gfx/conback.lmp");
precache_file ("gfx/qplaque.lmp");
precache_file ("gfx/menudot1.lmp");
precache_file ("gfx/menudot2.lmp");
precache_file ("gfx/menudot3.lmp");
precache_file ("gfx/menudot4.lmp");
precache_file ("gfx/menudot5.lmp");
precache_file ("gfx/menudot6.lmp");
precache_file ("gfx/menuplyr.lmp");
precache_file ("gfx/bigbox.lmp");
precache_file ("gfx/dim_modm.lmp");
precache_file ("gfx/dim_drct.lmp");
precache_file ("gfx/dim_ipx.lmp");
precache_file ("gfx/dim_tcp.lmp");
precache_file ("gfx/dim_mult.lmp");
precache_file ("gfx/mainmenu.lmp");
precache_file ("gfx/box_tl.lmp");
precache_file ("gfx/box_tm.lmp");
precache_file ("gfx/box_tr.lmp");
precache_file ("gfx/box_ml.lmp");
precache_file ("gfx/box_mm.lmp");
precache_file ("gfx/box_mm2.lmp");
precache_file ("gfx/box_mr.lmp");
precache_file ("gfx/box_bl.lmp");
precache_file ("gfx/box_bm.lmp");
precache_file ("gfx/box_br.lmp");
precache_file ("gfx/sp_menu.lmp");
precache_file ("gfx/ttl_sgl.lmp");
precache_file ("gfx/ttl_main.lmp");
precache_file ("gfx/ttl_cstm.lmp");
precache_file ("gfx/mp_menu.lmp");
precache_file ("gfx/netmen1.lmp");
precache_file ("gfx/netmen2.lmp");
precache_file ("gfx/netmen3.lmp");
precache_file ("gfx/netmen4.lmp");
precache_file ("gfx/netmen5.lmp");
precache_file ("gfx/sell.lmp");
precache_file ("gfx/help0.lmp");
precache_file ("gfx/help1.lmp");
precache_file ("gfx/help2.lmp");
precache_file ("gfx/help3.lmp");
precache_file ("gfx/help4.lmp");
precache_file ("gfx/help5.lmp");
precache_file ("gfx/pause.lmp");
precache_file ("gfx/loading.lmp");
precache_file ("gfx/p_option.lmp");
precache_file ("gfx/p_load.lmp");
precache_file ("gfx/p_save.lmp");
precache_file ("gfx/p_multi.lmp");
// sounds loaded by C code
precache_sound ("misc/menu1.wav");
precache_sound ("misc/menu2.wav");
precache_sound ("misc/menu3.wav");
precache_sound ("ambience/water1.wav");
precache_sound ("ambience/wind2.wav");
// shareware
precache_file ("maps/start.bsp");
precache_file ("maps/e1m1.bsp");
precache_file ("maps/e1m2.bsp");
precache_file ("maps/e1m3.bsp");
precache_file ("maps/e1m4.bsp");
precache_file ("maps/e1m5.bsp");
precache_file ("maps/e1m6.bsp");
precache_file ("maps/e1m7.bsp");
precache_file ("maps/e1m8.bsp");
// registered
precache_file2 ("gfx/pop.lmp");
precache_file2 ("maps/e2m1.bsp");
precache_file2 ("maps/e2m2.bsp");
precache_file2 ("maps/e2m3.bsp");
precache_file2 ("maps/e2m4.bsp");
precache_file2 ("maps/e2m5.bsp");
precache_file2 ("maps/e2m6.bsp");
precache_file2 ("maps/e2m7.bsp");
precache_file2 ("maps/e3m1.bsp");
precache_file2 ("maps/e3m2.bsp");
precache_file2 ("maps/e3m3.bsp");
precache_file2 ("maps/e3m4.bsp");
precache_file2 ("maps/e3m5.bsp");
precache_file2 ("maps/e3m6.bsp");
precache_file2 ("maps/e3m7.bsp");
precache_file2 ("maps/e4m1.bsp");
precache_file2 ("maps/e4m2.bsp");
precache_file2 ("maps/e4m3.bsp");
precache_file2 ("maps/e4m4.bsp");
precache_file2 ("maps/e4m5.bsp");
precache_file2 ("maps/e4m6.bsp");
precache_file2 ("maps/e4m7.bsp");
precache_file2 ("maps/e4m8.bsp");
precache_file2 ("maps/end.bsp");
precache_file2 ("maps/dm1.bsp");
precache_file2 ("maps/dm2.bsp");
precache_file2 ("maps/dm3.bsp");
precache_file2 ("maps/dm4.bsp");
precache_file2 ("maps/dm5.bsp");
precache_file2 ("maps/dm6.bsp");
};
entity lastspawn;
//=======================
/*QUAKED worldspawn (0 0 0) ?
Only used for the world entity.
Set message to the level name.
Set sounds to the cd track to play.
World Types:
0: medieval
1: metal
2: base
*/
//=======================
void() worldspawn =
{
lastspawn = world;
runespawn = world;
runespawned = 0;
InitBodyQueue ();
// custom map attributes
if (self.model == "maps/e1m8.bsp")
cvar_set ("sv_gravity", "100");
else
cvar_set ("sv_gravity", "800");
// the area based ambient sounds MUST be the first precache_sounds
// player precaches
W_Precache (); // get weapon precaches
// sounds used from C physics code
precache_sound ("demon/dland2.wav"); // landing thud
precache_sound ("misc/h2ohit1.wav"); // landing splash
// setup precaches allways needed
precache_sound ("items/itembk2.wav"); // item respawn sound
precache_sound ("player/plyrjmp8.wav"); // player jump
precache_sound ("player/land.wav"); // player landing
precache_sound ("player/land2.wav"); // player hurt landing
precache_sound ("player/drown1.wav"); // drowning pain
precache_sound ("player/drown2.wav"); // drowning pain
precache_sound ("player/gasp1.wav"); // gasping for air
precache_sound ("player/gasp2.wav"); // taking breath
precache_sound ("player/h2odeath.wav"); // drowning death
precache_sound ("misc/talk.wav"); // talk
precache_sound ("player/teledth1.wav"); // telefrag
precache_sound ("misc/r_tele1.wav"); // teleport sounds
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 ("weapons/lock4.wav"); // ammo pick up
precache_sound ("weapons/pkup.wav"); // weapon up
precache_sound ("items/armor1.wav"); // armor up
precache_sound ("weapons/lhit.wav"); //lightning
precache_sound ("weapons/lstart.wav"); //lightning start
precache_sound ("items/damage3.wav");
precache_sound ("misc/power.wav"); //lightning for boss
// player gib sounds
precache_sound ("player/gib.wav"); // player gib sound
precache_sound ("player/udeath.wav"); // player gib sound
precache_sound ("player/tornoff2.wav"); // gib sound
// player pain sounds
precache_sound ("player/pain1.wav");
precache_sound ("player/pain2.wav");
precache_sound ("player/pain3.wav");
precache_sound ("player/pain4.wav");
precache_sound ("player/pain5.wav");
precache_sound ("player/pain6.wav");
// player death sounds
precache_sound ("player/death1.wav");
precache_sound ("player/death2.wav");
precache_sound ("player/death3.wav");
precache_sound ("player/death4.wav");
precache_sound ("player/death5.wav");
// ax sounds
precache_sound ("weapons/ax1.wav"); // ax swoosh
precache_sound ("player/axhit1.wav"); // ax hit meat
precache_sound ("player/axhit2.wav"); // ax hit world
precache_sound ("hknight/hit.wav"); // ZOID: hook launch
precache_sound ("player/h2ojump.wav"); // player jumping into water
precache_sound ("player/slimbrn2.wav"); // player enter slime
precache_sound ("player/inh2o.wav"); // player enter water
precache_sound ("player/inlava.wav"); // player enter lava
precache_sound ("misc/outwater.wav"); // leaving water sound
precache_sound ("player/lburn1.wav"); // lava burn
precache_sound ("player/lburn2.wav"); // lava burn
precache_sound ("misc/water1.wav"); // swimming
precache_sound ("misc/water2.wav"); // swimming
precache_model ("progs/player.mdl");
precache_model ("progs/eyes.mdl");
precache_model ("progs/h_player.mdl");
precache_model ("progs/gib1.mdl");
precache_model ("progs/gib2.mdl");
precache_model ("progs/gib3.mdl");
precache_model ("progs/s_bubble.spr"); // drowning bubbles
precache_model ("progs/s_explod.spr"); // sprite explosion
precache_model ("progs/v_axe.mdl");
precache_model ("progs/v_shot.mdl");
precache_model ("progs/v_nail.mdl");
precache_model ("progs/v_rock.mdl");
precache_model ("progs/v_shot2.mdl");
precache_model ("progs/v_nail2.mdl");
precache_model ("progs/v_rock2.mdl");
precache_model ("progs/bolt.mdl"); // for lightning gun
precache_model ("progs/bolt2.mdl"); // for lightning gun
precache_model ("progs/bolt3.mdl"); // for boss shock
precache_model ("progs/lavaball.mdl"); // for testing
precache_model ("progs/missile.mdl");
precache_model ("progs/grenade.mdl");
precache_model ("progs/spike.mdl");
precache_model ("progs/s_spike.mdl");
// for hook
precache_model ("progs/beam.mdl");
precache_model ("progs/star.mdl");
precache_model ("progs/v_star.mdl");
precache_model ("progs/backpack.mdl");
precache_model ("progs/zom_gib.mdl");
precache_model ("progs/v_light.mdl");
//
// Setup light animation tables. 'a' is total darkness, 'z' is maxbright.
//
// 0 normal
lightstyle(0, "m");
// 1 FLICKER (first variety)
lightstyle(1, "mmnmmommommnonmmonqnmmo");
// 2 SLOW STRONG PULSE
lightstyle(2, "abcdefghijklmnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba");
// 3 CANDLE (first variety)
lightstyle(3, "mmmmmaaaaammmmmaaaaaabcdefgabcdefg");
// 4 FAST STROBE
lightstyle(4, "mamamamamama");
// 5 GENTLE PULSE 1
lightstyle(5,"jklmnopqrstuvwxyzyxwvutsrqponmlkj");
// 6 FLICKER (second variety)
lightstyle(6, "nmonqnmomnmomomno");
// 7 CANDLE (second variety)
lightstyle(7, "mmmaaaabcdefgmmmmaaaammmaamm");
// 8 CANDLE (third variety)
lightstyle(8, "mmmaaammmaaammmabcdefaaaammmmabcdefmmmaaaa");
// 9 SLOW STROBE (fourth variety)
lightstyle(9, "aaaaaaaazzzzzzzz");
// 10 FLUORESCENT FLICKER
lightstyle(10, "mmamammmmammamamaaamammma");
// 11 SLOW PULSE NOT FADE TO BLACK
lightstyle(11, "abcdefghijklmnopqrrqponmlkjihgfedcba");
// styles 32-62 are assigned by the light program for switchable lights
// 63 testing
lightstyle(63, "a");
};
void StartFrame() {
teamplay = cvar("teamplay");
skill = cvar("skill");
cheats_allowed = cvar("sv_cheats");
framecount = framecount + 1;
};
/*
==============================================================================
BODY QUE
==============================================================================
*/
entity bodyqueue_head;
void() bodyqueue =
{ // just here so spawn functions don't complain after the world
// creates bodyqueues
};
void() InitBodyQueue =
{
bodyqueue_head = spawn();
bodyqueue_head.classname = "bodyqueue";
bodyqueue_head.owner = spawn();
bodyqueue_head.owner.classname = "bodyqueue";
bodyqueue_head.owner.owner = spawn();
bodyqueue_head.owner.owner.classname = "bodyqueue";
bodyqueue_head.owner.owner.owner = spawn();
bodyqueue_head.owner.owner.owner.classname = "bodyqueue";
bodyqueue_head.owner.owner.owner.owner = bodyqueue_head;
};
// make a body que entry for the given ent so the ent can be
// respawned elsewhere
void(entity ent) CopyToBodyQueue =
{
bodyqueue_head.angles = ent.angles;
bodyqueue_head.model = ent.model;
bodyqueue_head.modelindex = ent.modelindex;
bodyqueue_head.frame = ent.frame;
bodyqueue_head.colormap = ent.colormap;
bodyqueue_head.movetype = ent.movetype;
bodyqueue_head.velocity = ent.velocity;
bodyqueue_head.flags = 0;
setorigin (bodyqueue_head, ent.origin);
setsize (bodyqueue_head, ent.mins, ent.maxs);
bodyqueue_head = bodyqueue_head.owner;
};