djcev.com

//

Git Repos / fte_dogmode / commit 675fa9a

Commit: 675fa9ab1cf7bc70bcb59470fae33221ebf5df5d
Parent: b08b2be7a820b3b765066496c25d50108acd182c
Author: Cameron Vanderzanden, 2024-03-24 02:40
Committer: Cameron Vanderzanden, 2024-03-24 02:40

Commit Message

2nd pass refactor, rework QC class structure

Using proper QuakeC 'classes' was showing strange performance results
in FTE's in-engine profiler. So I've commented out the class definitions
and reworked the structure of the server-side QuakeC into its previous
form. (All but the monsters which are next). The program is still in
the same form as before - a class/object hierarchy - but no longer
defines actual 'classes'. This should peform roughly the same as PD3.

I took this opportunity to change a few other things, mainly object
initialization. I've tried to retain the convenience of spawning
objects of a class by creating specialized spawn_xyz helper functions.
Not everything can be spawned this way, of course, spawning brush
based func_ objects doesn't make a whole lot of sense.

And of course there are a bunch of other changes in here. Movement
should now be closer to CPM, I hope.

Need to post this before I continue. It's a big update so there will
be bugs (haven't done much testing yet).

Change List

?File Add Del
M .gitignore +1
M Makefile +2 -2
M qc/Makefile +5 -2
M qc/base_entities.qc +713 -507
M qc/base_func.qc +107 -70
M qc/base_item.qc +182 -255
M qc/base_monster.qc +33 -2
A qc/base_proj.qc +615
D qc/base_projectile.qc -501
M qc/base_trigger.qc +62 -82
A qc/cl_entry.qc +487
A qc/cl_hud.qc +1033
A qc/cl_player.qc +329
A qc/cl_progs.src +32
M qc/compat_quake3.qc +80 -33
M qc/cshift.qc +33 -11
D qc/csqc/Makefile -5
D qc/csqc/csqc_defs.qc -102
D qc/csqc/csqc_defsbuiltins.qc -898
D qc/csqc/csqc_defsclient.qc -426
D qc/csqc/csqc_entrypoints.qc -351
D qc/csqc/csqc_fteopts.qc -14
D qc/csqc/csqc_hudvanilla.qc -997
D qc/csqc/csqc_player.qc -325
D qc/csqc/csqc_progs.src -26
M qc/custom_mdls.qc +79 -36
M qc/custom_snd.qc +117 -54
M qc/cutscene.qc +32
M qc/defs_builtins.qc +662 -96
D qc/defs_classtype.qc -298
A qc/defs_const.qc +268
A qc/defs_ctypes.qc +300
D qc/defs_entvars.qc -115
A qc/defs_fields.qc +115
A qc/defs_globals.qc +84
D qc/defs_globalvars.qc -84
D qc/defs_misc.qc -569
D qc/entrypoints.qc -638
M qc/fteqcc.ini +3 -3
M qc/func/bob.qc +155 -133
M qc/func/bossgate.qc +37 -11
M qc/func/breakable.qc +214 -193
M qc/func/brush.qc +16 -7
M qc/func/button.qc +120 -95
M qc/func/counter.qc +133 -141
M qc/func/door.qc +389 -386
M qc/func/door_secret.qc +147 -111
M qc/func/elvtr_button.qc +120 -94
M qc/func/episodegate.qc +36 -13
M qc/func/explobox.qc +50 -27
M qc/func/fall.qc +70 -43
M qc/func/fall2.qc +213 -198
M qc/func/illusionary.qc +31 -10
M qc/func/laser.qc +109 -73
M qc/func/new_plat.qc +421 -425
M qc/func/particlefield.qc +111 -113
M qc/func/plat.qc +148 -193
M qc/func/rotate.qc +713 -743
M qc/func/shadow.qc +155 -119
M qc/func/togglevisiblewall.qc +53 -29
M qc/func/togglewall.qc +64 -38
M qc/func/train.qc +267 -216
M qc/func/wall.qc +58 -14
M qc/gore.qc +7 -5
M qc/hazards/ltrail.qc +137 -120
M qc/hazards/shooter.qc +159 -139
M qc/info/camera.qc +86 -35
M qc/info/intermission.qc +74 -11
M qc/info/notnull.qc +39 -4
M qc/info/null.qc +40 -5
M qc/info/path_corner.qc +109 -125
M qc/info/rotate.qc +32 -8
M qc/info/spawnpoints.qc +212 -30
M qc/info/teleport_changedest.qc +54 -19
M qc/info/teleport_destination.qc +79 -26
M qc/items/ammo.qc +252 -184
M qc/items/armor.qc +247 -125
M qc/items/backpacks.qc +193 -316
M qc/items/health.qc +195 -132
M qc/items/keys.qc +282 -127
M qc/items/powerups.qc +212 -93
M qc/items/runes.qc +77 -54
M qc/items/weapons.qc +392 -198
M qc/keylock.qc +23 -21
M qc/math.qc +36 -10
M qc/misc/air_bubbles.qc +158 -59
M qc/misc/ambient_sound.qc +359 -131
M qc/misc/deadstuff.qc +356 -154
M qc/misc/explobox.qc +101 -52
M qc/misc/fireball.qc +38 -47
M qc/misc/infight.qc +61 -30
M qc/misc/light_candle.qc +55 -20
M qc/misc/lights.qc +286 -165
M qc/misc/model.qc +125 -111
M qc/misc/modeltrain.qc +156 -257
M qc/misc/noisemaker.qc +36 -15
M qc/misc/particle_stream.qc +49 -24
M qc/misc/particles.qc +78 -34
M qc/misc/particlespray.qc +58 -44
M qc/misc/play.qc +452 -222
M qc/misc/sparks.qc +136 -110
M qc/misc/target_autosave.qc +44 -29
M qc/misc/teleporttrain.qc +108 -104
M qc/misc/viewthing.qc +28 -8
M qc/monsters/playerclient.qc +1051 -994
M qc/newflags.qc +50 -36
M qc/obituary.qc +20 -3
M qc/pmove.qc +272 -223
D qc/progs.src -213
M qc/projectiles/bullet.qc +85 -52
A qc/projectiles/fireball.qc +85
M qc/projectiles/flak.qc +103 -57
M qc/projectiles/grenade.qc +98 -54
M qc/projectiles/hknightspell.qc +83 -37
M qc/projectiles/laser.qc +77 -32
M qc/projectiles/lavaball.qc +77 -37
M qc/projectiles/multigrenade.qc +188 -95
M qc/projectiles/rocket.qc +76 -35
M qc/projectiles/spike.qc +83 -41
M qc/projectiles/voreball.qc +93 -45
M qc/projectiles/wizardspell.qc +158 -77
M qc/projectiles/zombiechunk.qc +77 -34
M qc/subs.qc +16 -394
A qc/sv_entry.qc +903
A qc/sv_progs.src +216
M qc/triggers/changelevel.qc +76 -38
M qc/triggers/changemusic.qc +102 -35
M qc/triggers/changetarget.qc +55 -17
M qc/triggers/counter.qc +45 -20
M qc/triggers/cvarset.qc +41 -21
M qc/triggers/everything.qc +33 -16
M qc/triggers/filter.qc +64 -34
M qc/triggers/fog.qc +340 -206
M qc/triggers/heal.qc +108 -103
M qc/triggers/hurt.qc +60 -35
M qc/triggers/ladder.qc +37 -20
M qc/triggers/look.qc +70 -52
M qc/triggers/monsterface.qc +40 -23
M qc/triggers/monsterjump.qc +51 -43
M qc/triggers/multiple.qc +138 -113
M qc/triggers/onlyregistered.qc +38 -16
M qc/triggers/push.qc +130 -90
M qc/triggers/relay.qc +31 -6
M qc/triggers/secret.qc +32 -15
M qc/triggers/setcount.qc +56 -35
M qc/triggers/setgravity.qc +50 -25
M qc/triggers/setskill.qc +30 -10
M qc/triggers/setstate.qc +102 -82
M qc/triggers/shake.qc +65 -39
M qc/triggers/take_weapon.qc +39 -19
M qc/triggers/teleport.qc +109 -76
M qc/triggers/textstory.qc +176 -135
M qc/triggers/usekey.qc +68 -52
M qc/triggers/void.qc +47 -27
M qc/utility.qc +29 -10
M qc/world.qc +92 -220

Diff .gitignore

diff --git a/.gitignore b/.gitignore
index bc1fac7..e36c813 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,3 +3,4 @@
*.swp
assets
qc/fteextensions.qc
+temp

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

Diff Makefile

diff --git a/Makefile b/Makefile
index 5f7e146..c9dbdd6 100644
--- a/Makefile
+++ b/Makefile
@@ -9,14 +9,14 @@ install:
make server-install

client:
- cd qc/csqc && $(MAKE)
+ cd qc && $(MAKE) client

client-install:
cp csprogs.dat $(INSTALLDIR)/csprogs.dat
cp csprogs.lno $(INSTALLDIR)/csprogs.lno

server:
- cd qc && $(MAKE)
+ cd qc && $(MAKE) server

server-install:
cp progs.dat $(INSTALLDIR)/progs.dat

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

Diff qc/Makefile

diff --git a/qc/Makefile b/qc/Makefile
index 6059f23..1164a10 100644
--- a/qc/Makefile
+++ b/qc/Makefile
@@ -1,5 +1,8 @@
CC=fteqcc64
CCOPTS=-Wall -O2

-all:
- $(CC) $(CCOPTS) progs.src
+client:
+ $(CC) $(CCOPTS) cl_progs.src
+
+server:
+ $(CC) $(CCOPTS) sv_progs.src

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

Diff qc/base_entities.qc

diff --git a/qc/base_entities.qc b/qc/base_entities.qc
index 12f5d1d..f37275a 100644
--- a/qc/base_entities.qc
+++ b/qc/base_entities.qc
@@ -2,37 +2,144 @@
// base_entities.qc -- top-level entities (entity, tempentity, mapentity)
//==============================================================================

+//======================================================================
// constants
-enumflags
-{
- DISABLE_BLOCKED,
- DISABLE_DAMAGE,
- DISABLE_DESTROY,
- DISABLE_THINK,
- DISABLE_TOUCH,
- DISABLE_USE
-};
+//======================================================================

-//----------------------------------------------------------------------
-// droptofloorwrapper -- CallAsSelf-style drop-to-floor from Nuclide -- CEV
-//----------------------------------------------------------------------
-float(entity caller) droptofloorwrapper =
-{
- local float result;
- local entity old_self = self;
+const float STATE_ACTIVE = 0; // .estate field values
+const float STATE_INACTIVE = 1;
+const float STATE_INVISIBLE = 8;
+
+//======================================================================
+// globals
+//======================================================================
+
+#ifdef SSQC
+entity activator; // entity that activated trigger/brush
+entity damage_attacker; // set by T_Damage
+// string lastnameused; // targetname last used to trigger
+#endif
+
+//======================================================================
+// fields
+//======================================================================
+
+.float aflag; // trigger_filter, func_counter, item_
+.float alpha; // translucency in supported engines
+.float cnt; // misc flag
+.float color; // Hipnotic
+.float count; // for counting triggers
+.float damage_mod; // dumptruck_ds
+.float delay; // time from activation to firing
+.float distance;
+.float dmg; // damage done by door when hit
+.float height;
+.float gravity; // from custdefs.qc by way of Hipnotic
+.float is_waiting; // wait until activated before trigger?
+.float lefty; // used by monsters and func_bob
+.float light_lev; // not used ingame, parsed by light util
+.float speed;
+.float speed2;
+.float state; // plats / doors / buttons
+.float style, style2;
+.float t_length, t_width; // func_, monster face, player LG, etc
+.float wait; // time from firing to restarting
+.float waitmin; // sounds (removed: waitmax)
+.float wantedgravity; // thanks Spike!
+.float volume; // sounds
+
+.float estate; // entity state
+.float prevstate; // previous entity state
+.void() olduse; // previous use function
+
+.string mdl; // object stuff
+.string message2; // func_laser & trigger_heal
+.string noise4; // noise & noise1-3 defined in entvars_t
+.string origmodel; // switchables brushes (added by bmFbr)
+
+.vector mangle; // angle at start
+.vector pos1; // used by some func_ classes
+.vector pos2;
+
+.entity oldenemy; // mad at this ent before taking damage
+.entity trigger_field; // TODO CEV: cutscene, door, shambler
+
+// variables for enhanced triggering from Custents -- dumptruck_ds
+// .string target // defined in entvars_t -- CEV
+.string target2; // second target's name
+.string target3; // third target's name
+.string target4; // fourth target's name
+// .string targetname // defined in entvars_t -- CEV
+.string targetname2; // second name
+.string targetname3; // third name
+.string targetname4; // fourth name
+.string killtarget; // first target to kill
+.string killtarget2; // second target to kill
+.string pain_target; // dumptruck_ds
+
+.void(entity src, float amount) pain; // th_pain
+.void() destroy; // th_die
+
+#ifdef SSQC
+// Called by the engine whenever an entity needs to be (re)sent to a client's
+// csprogs, either because SendFlags was set or because data was lost. Must
+// write its data to the MSG_ENTITY buffer. Will be called at the engine's
+// leasure.
+.float(entity e, float changedflags) SendEntity;
+// Indicates that something in the entity has been changed, and that it needs
+// to be updated to all players that can see it. The engine will clear it at
+// some point, with the cleared bits appearing in the 'changedflags' argument
+// of the SendEntity method.
+.float SendFlags;
+#endif

- self = caller;
- result = droptofloor ();
- self = old_self;
- return result;
-}
+//======================================================================
+// forward declarations
+//======================================================================

+#ifdef SSQC
+// base entity
+float(entity src, entity dest) can_damage;
+void(entity targ, entity inflictor, entity attacker) killed;
+void(entity inflictor, entity attacker, float damage, entity ignore)
+ t_radiusdamage2;
+void(entity attacker, float damage) t_beamdamage2;
+void(entity targ, entity inflictor, entity attacker, float damage) t_damage2;
+// void(entity targ, entity inflictor, entity attacker, float damage) t_damage2;
+// void(entity inflictor, entity attacker, float damage) t_damage2_receive;
+void(entity doas, void() f) sub_runvoidas;
+float(entity doas, float() f) sub_runfloatas;
+float(entity toucher) sub_checkvalidtouch;
+void() sub_usetargets;
+void(string matchstring, .string matchfield) sub_killtarget;
+void(string matchstring, .string matchfield) sub_usetarget;
+
+// base_tempentity
+void(entity e) base_tempentity_init;
+strip void() base_tempentity;
+
+// temp_delayed_targets
+void() temp_delayed_targets_think;
+entity() spawn_temp_delayed_targets;
+void(entity e) temp_delayed_targets_init;
+strip void() temp_delayed_targets;
+
+// base_mapentity
+void(entity e) sub_setmovedir;
+void() sub_useandforgettargets;
+void(entity e) base_mapentity_init;
+strip void() base_mapentity;
+
+// noclass
+void() noclass;
+#endif
+
//------------------------------------------------------------------------------
-class base_entity: entity
-{
- // class fields
- float interaction_flags;

+#ifdef SSQC
+//----------------------------------------------------------------------
+// class base_entity: entity
+// {
//==============================================================
// Damage Functions
//==============================================================
@@ -40,15 +147,15 @@ class base_entity: entity
//--------------------------------------------------------------
// CanDamage
// Returns true if the source (inflictor) can directly damage
- // the destinatino (target). Used for explosions and melee attacks.
+ // the destination (target). Used for explosions and melee attacks.
//--------------------------------------------------------------
- nonvirtual float(entity src, entity dest) can_damage =
+ float(entity src, entity dest) can_damage =
{
// bmodels need special checking because their origin is 0,0,0
if (dest.movetype == MOVETYPE_PUSH)
{
traceline (src.origin,
- 0.5 * (dest.absmin + dest.absmax), TRUE, this);
+ 0.5 * (dest.absmin + dest.absmax), TRUE, self);
if (trace_fraction == 1)
return TRUE;
if (trace_ent == dest)
@@ -56,19 +163,19 @@ class base_entity: entity
return FALSE;
}

- traceline (src.origin, dest.origin, TRUE, this);
+ traceline (src.origin, dest.origin, TRUE, self);
if (trace_fraction == 1)
return TRUE;
- traceline (src.origin, dest.origin + '15 15 0', TRUE, this);
+ traceline (src.origin, dest.origin + '15 15 0', TRUE, self);
if (trace_fraction == 1)
return TRUE;
- traceline (src.origin, dest.origin + '-15 -15 0', TRUE, this);
+ traceline (src.origin, dest.origin + '-15 -15 0', TRUE, self);
if (trace_fraction == 1)
return TRUE;
- traceline (src.origin, dest.origin + '-15 15 0', TRUE, this);
+ traceline (src.origin, dest.origin + '-15 15 0', TRUE, self);
if (trace_fraction == 1)
return TRUE;
- traceline (src.origin, dest.origin + '15 -15 0', TRUE, this);
+ traceline (src.origin, dest.origin + '15 -15 0', TRUE, self);
if (trace_fraction == 1)
return TRUE;

@@ -76,10 +183,58 @@ class base_entity: entity
};

//--------------------------------------------------------------
+ // Killed
+ //--------------------------------------------------------------
+ void(entity targ, entity inflictor, entity attacker) killed =
+ {
+ local entity stemp = self;
+ self = targ;
+
+ if (self.health < -99)
+ // don't let sbar look bad if a player
+ self.health = -99;
+
+ if (self.movetype == MOVETYPE_NONE ||
+ self.movetype == MOVETYPE_PUSH ||
+ self.movetype == MOVETYPE_FLYMISSILE ||
+ self.movetype == MOVETYPE_BOUNCE)
+ {
+ // doors, triggers, missiles, etc
+ self.destroy ();
+ self = stemp;
+ 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, inflictor, attacker);
+
+ self.takedamage = DAMAGE_NO;
+ self.touch = sub_null;
+
+ // TODO CEV
+ /*
+ if (self.classgroup & CG_MONSTER)
+ sub_death_use ();
+ */
+
+ self.destroy ();
+
+ self = stemp;
+ };
+
+ //--------------------------------------------------------------
// T_RadiusDamage
//--------------------------------------------------------------
- nonvirtual void(entity inflictor, entity attacker, float damage,
- entity ignore) t_radiusdamage2 =
+ void(entity inflictor, entity attacker, float damage, entity ignore)
+ t_radiusdamage2 =
{
local float points;
local entity head;
@@ -95,28 +250,29 @@ class base_entity: entity
continue;
}

- org = head.origin + (head.mins + head.maxs)*0.5;
+ 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 (this.can_damage (inflictor, head))
+ if (can_damage(inflictor, head))
{
// shambler takes half damage from
// all explosions
if (head.classtype ==
CT_MONSTER_SHAMBLER)
{
- this.t_damage2 (head, inflictor,
+ t_damage2 (head, inflictor,
attacker, points * 0.5);
}
else
{
- this.t_damage2 (head, inflictor,
+ t_damage2 (head, inflictor,
attacker, points);
}
}
@@ -128,7 +284,7 @@ class base_entity: entity
//--------------------------------------------------------------
// T_BeamDamage
//--------------------------------------------------------------
- nonvirtual void(entity attacker, float damage) t_beamdamage2 =
+ void(entity attacker, float damage) t_beamdamage2 =
{
local float points;
local entity head;
@@ -143,7 +299,7 @@ class base_entity: entity
continue;
}

- points = 0.5 * vlen ( attacker.origin - head.origin);
+ points = 0.5 * vlen (attacker.origin - head.origin);
if (points < 0)
points = 0;
points = damage - points;
@@ -151,17 +307,17 @@ class base_entity: entity
points = points * 0.5;
if (points > 0)
{
- if (this.can_damage (attacker, head))
+ if (can_damage(attacker, head))
{
if (head.classtype ==
CT_MONSTER_SHAMBLER)
{
- this.t_damage2 (head, attacker,
+ t_damage2 (head, attacker,
attacker, points * 0.5);
}
else
{
- this.t_damage2 (head, attacker,
+ t_damage2 (head, attacker,
attacker, points);
}
}
@@ -175,8 +331,244 @@ class base_entity: entity
// The damage is coming from inflictor, but get mad at attacker
// This should be the only function that ever reduces health.
//--------------------------------------------------------------
- static void(entity targ, entity inflictor, entity attacker,
- float damage) t_damage2 =
+ void(entity targ, entity inflictor, entity attacker, float damage)
+ t_damage2 =
+ {
+ local entity stemp;
+ local vector dir;
+ local float save;
+ local float take;
+ local float ignore_armor; // johnfitz
+ local string death_type; // johnfitz
+
+ // don't try to damage the world. Not healthy -- bmFbr
+ if (!targ)
+ return;
+
+ // make sure targ.deathtype doesn't keep stale info
+ // after this function is done -- johnfitz
+ death_type = targ.deathtype;
+ targ.deathtype = "";
+ // johnfitz
+
+ if (!targ.takedamage)
+ return;
+
+ // some func_breakables ignore monster damage -- johnfitz
+ // dded from Rubicon2 combat.qc -- dumptruck_ds
+ if (targ.classtype == CT_FUNC_BREAKABLE)
+ {
+ if (targ.spawnflags & BREAKABLE_NO_MONSTERS &&
+ attacker.flags & FL_MONSTER)
+ {
+ return;
+ }
+ }
+ // johnfitz
+
+ // 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;
+
+ // damage mod for monsters -- dumptruck_ds
+ if (attacker.damage_mod)
+ damage = damage * attacker.damage_mod;
+
+ // don't deplete armor if drowning/burning, or
+ // protected by biosuit/pentagram/godmode (note:
+ // in ID1 // pentagram/godmode doesn't actually
+ // protect your armor)
+ if (death_type == "burning" || death_type == "drowning" ||
+ targ.invincible_finished >= time ||
+ targ.flags & FL_GODMODE)
+ {
+ ignore_armor = TRUE;
+ }
+ else
+ {
+ ignore_armor = FALSE;
+ }
+ // johnfitz
+
+ // save damage based on the target's armor level
+ if (ignore_armor)
+ {
+ // some damage doesn't deplete armor -- johnfitz
+ save = 0;
+ }
+ else
+ {
+ save = ceil (targ.armortype * damage);
+ if (save >= targ.armorvalue)
+ {
+ save = targ.armorvalue;
+ // lost all armor
+ targ.armortype = 0;
+ targ.items = targ.items - (targ.items &
+ (IT_ARMOR1 | IT_ARMOR2 | IT_ARMOR3));
+ }
+ }
+ // 1998-08-12 Drowning doesn't hurt armor by Maddes/Athos start
+ // else
+ // {
+ // save = 0;
+ // }
+ // 1998-08-12 Drowning doesn't hurt armor by Maddes/Athos end
+ 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.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
+ // 1998-07-29 Teamplay 1 fix by Maddes start
+ if ((teamplay == 1) && (targ.team > 0) &&
+ (targ.team == attacker.team) &&
+ (targ != attacker) &&
+ (attacker.classtype == CT_PLAYER) &&
+ // because squishing a teammate is still possible
+ (inflictor.classtype != CT_FUNC_DOOR))
+ {
+ return;
+ }
+ // 1998-07-29 Teamplay 1 fix by Maddes end
+
+ // do the damage
+ targ.health = targ.health - take;
+
+ /*
+ // TODO CEV
+ // fire pain_target if appropriate
+ if ((targ.flags & FL_MONSTER) &&
+ targ.pain_target != "" &&
+ targ.health <= targ.pain_threshold)
+ {
+ // TODO CEV
+ oldself = self;
+ self = targ;
+ monster_pain_use ();
+ self = oldself;
+ }
+ */
+
+ if (targ.health <= 0)
+ {
+ killed (targ, inflictor, attacker);
+ return;
+ }
+
+ // react to the damage
+ stemp = self;
+ self = targ;
+
+ if ((self.flags & FL_MONSTER) && attacker != world)
+ {
+ // get mad unless of the same class (except soldiers)
+ if (self != attacker && attacker != self.enemy)
+ {
+ local float mode = 0;
+ // take highest mode so infighting
+ // happens consistently
+ if (self.infight_mode == -1 ||
+ self.infight_mode > mode)
+ {
+ mode = self.infight_mode;
+ }
+ if (mode != -1 && attacker.infight_mode > mode)
+ {
+ mode = attacker.infight_mode;
+ }
+ // soldiers of the same style will infight
+ // -- dumptruck_ds - thanks for c0burn and
+ // Shamblernaut for your help!
+ if (mode == -1)
+ {
+ if (attacker.classtype == CT_PLAYER)
+ {
+ if (self.enemy.classtype ==
+ CT_PLAYER)
+ self.oldenemy =
+ self.enemy;
+ self.enemy = attacker;
+ // TODO CEV
+ // ai_foundtarget ();
+ }
+ }
+ else if ((self.classname != attacker.classname)
+ || ((self.classtype == CT_MONSTER_GRUNT)
+ && (self.style == attacker.style)) ||
+ // infight if different models
+ (mode > 0 &&
+ self.mdl_body != attacker.mdl_body) ||
+ // infight if different skin
+ (mode > 1 &&
+ self.skin != attacker.skin) ||
+ // always infight
+ (mode > 2))
+ {
+ if (self.enemy.classtype == CT_PLAYER)
+ self.oldenemy = self.enemy;
+ self.enemy = attacker;
+ // TODO CEV
+ // ai_foundtarget ();
+ }
+ }
+ }
+
+ if (self.pain)
+ {
+ self.pain (attacker, take);
+ // nightmare mode monsters don't go into
+ // pain frames often
+ if (skill == 3)
+ self.pain_finished = time + 5;
+ }
+
+ self = stemp;
+ };
+
+ //--------------------------------------------------------------
+ // 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_damage2 =
{
// don't try to damage the world. Not healthy - bmFbr
if (!targ)
@@ -221,16 +613,16 @@ class base_entity: entity
if (attacker.damage_mod)
damage = damage * attacker.damage_mod;

- if (targ.classgroup & CG_ENTITY)
- ((base_entity)targ).t_damage2_receive (inflictor,
- attacker, damage);
- else
- dprint (sprintf("base_entity::t_damage2: unknown "
- "entity of type %s\n", targ.classname));
+ local entity stemp = self;
+ self = targ;
+ t_damage2_receive (inflictor, attacker, damage);
+ self = stemp;
};

//--------------------------------------------------------------
- nonvirtual void(entity inflictor, entity attacker, float damage)
+ // 'self' in this function should be the receiver of the damage
+ //--------------------------------------------------------------
+ void(entity inflictor, entity attacker, float damage)
t_damage2_receive =
{
local vector dir;
@@ -241,16 +633,16 @@ class base_entity: entity

// make sure deathtype doesn't keep stale info after
// this function is done -- johnfitz
- death_type = this.deathtype;
- this.deathtype = "";
+ death_type = self.deathtype;
+ self.deathtype = "";
// johnfitz

// don't deplete armor if drowning/burning, or protected by
// biosuit/pentagram/godmode (note: in ID1 pentagram/godmode
// doesn't actually protect your armor)
if (death_type == "burning" || death_type == "drowning" ||
- this.invincible_finished >= time ||
- this.flags & FL_GODMODE)
+ self.invincible_finished >= time ||
+ self.flags & FL_GODMODE)
{
ignore_armor = TRUE;
}
@@ -268,95 +660,87 @@ class base_entity: entity
}
else
{
- save = ceil (this.armortype * damage);
- if (save >= this.armorvalue)
+ save = ceil (self.armortype * damage);
+ if (save >= self.armorvalue)
{
- save = this.armorvalue;
+ save = self.armorvalue;
// lost all armor
- this.armortype = 0;
- this.items = this.items - (this.items &
+ self.armortype = 0;
+ self.items = self.items - (self.items &
(IT_ARMOR1 | IT_ARMOR2 | IT_ARMOR3));
}
}

- this.armorvalue = this.armorvalue - save;
+ self.armorvalue = self.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 (this.flags & FL_CLIENT)
+ if (self.flags & FL_CLIENT)
{
- this.dmg_take = this.dmg_take + take;
- this.dmg_save = this.dmg_save + save;
- this.dmg_inflictor = inflictor;
+ self.dmg_take = self.dmg_take + take;
+ self.dmg_save = self.dmg_save + save;
+ self.dmg_inflictor = inflictor;
}

// figure momentum add
- if ((inflictor != world) && (this.movetype == MOVETYPE_WALK))
+ if ((inflictor != world) && (self.movetype == MOVETYPE_WALK))
{
- dir = this.origin -
+ dir = self.origin -
(inflictor.absmin + inflictor.absmax) * 0.5;
dir = normalize (dir);
- this.velocity = this.velocity + dir * damage * 8;
+ self.velocity = self.velocity + dir * damage * 8;
}

// check for godmode, then invincibility
// must happen after possibly changing velocity -- CEV
- if (this.flags & FL_GODMODE)
+ if (self.flags & FL_GODMODE)
return;

- if (this.invincible_finished >= time)
+ if (self.invincible_finished >= time)
{
- if (this.invincible_sound < time)
+ if (self.invincible_sound < time)
{
- sound (this, CHAN_ITEM, "items/protect3.wav",
+ sound (self, CHAN_ITEM, "items/protect3.wav",
1, ATTN_NORM);
- this.invincible_sound = time + 2;
+ self.invincible_sound = time + 2;
}
return;
}

// do the damage
- this.health = this.health - take;
+ self.health = self.health - take;

// fire pain_target if appropriate
- if ((this.flags & FL_MONSTER) && this.pain_target != "" &&
- this.health <= this.pain_threshold)
+ if ((self.flags & FL_MONSTER) && self.pain_target != "" &&
+ self.health <= self.pain_threshold)
{
- if (this.classgroup & CG_MONSTER)
- {
- ((base_monster)this).sub_pain_use ();
- }
- else
- {
- dprint (sprintf("base_entity::t_damage2_receive:"
- " unknown target type %s!\n",
- this.classname));
- }
+ // TODO CEV
+ sub_pain_use ();
}

- if (this.health <= 0)
+ if (self.health <= 0)
{
- this.killed (inflictor, attacker);
+ killed (inflictor, attacker);
return;
}

// react to the damage
- if ((this.flags & FL_MONSTER) && attacker != world)
+ if ((self.flags & FL_MONSTER) && attacker != world)
{
- // get mad unless of the same class (except for soldiers)
- if (this != attacker && attacker != this.enemy)
+ // get mad unless of the same class (except soldiers)
+ if (self != attacker && attacker != self.enemy)
{
local float mode;
mode = 0;

// take highest mode so infighting happens
// consistently
- if (this.infight_mode == -1 ||
- this.infight_mode > mode)
+ if (self.infight_mode == -1 ||
+ self.infight_mode > mode)
{
- mode = this.infight_mode;
+ mode = self.infight_mode;
}

if (mode != -1 && attacker.infight_mode > mode)
@@ -372,479 +756,371 @@ class base_entity: entity
{
if (attacker.classtype == CT_PLAYER)
{
- if (enemy.classtype==CT_PLAYER)
- oldenemy = enemy;
- enemy = attacker;
- if (this.classgroup & CG_MONSTER)
- {
- local base_monster m;
- m = (base_monster)this;
- m.ai_foundtarget ();
- }
- else
+ if (self.enemy.classtype ==
+ CT_PLAYER)
{
- dprint (sprintf(
- "T_Damage: "
- "unknown class "
- "%s!\n",
- classname));
+ self.oldenemy =
+ self.enemy;
}
+ self.enemy = attacker;
+ // TODO CEV
+ ai_foundtarget ();
}
}
- else if ((this.classname != attacker.classname)
- || ((this.classname == "monster_army")
- && (this.style == attacker.style)) ||
+ else if ((self.classtype != attacker.classtype)
+ || ((self.classtype == CT_MONSTER_GRUNT)
+ && (self.style == attacker.style)) ||
// infight if different models
- (mode > 0 && this.mdl_body !=
+ (mode > 0 && self.mdl_body !=
attacker.mdl_body) ||
// infight if different skin
- (mode > 1 && this.skin !=
+ (mode > 1 && self.skin !=
attacker.skin) ||
// always infight
(mode > 2))
{
- if (this.enemy.classname == "player")
- this.oldenemy = this.enemy;
- this.enemy = attacker;
- if (this.classgroup & CG_MONSTER)
- {
- local base_monster m1 =
- (base_monster)this;
- m1.ai_foundtarget ();
- }
- else
- {
- dprint (sprintf("T_Damage: "
- "infight check unk"
- "nown classname %s\n",
- this.classname));
- }
+ if (self.enemy.classtype == CT_PLAYER)
+ self.oldenemy = self.enemy;
+ self.enemy = attacker;
+ // TODO CEV
+ ai_foundtarget ();
}
}
}

// TODO CEV
- this.do_damage (attacker, take);
- if (skill == 3)
- this.pain_finished = time + 5;
+ if (self.pain)
+ {
+ self.pain (attacker, take);
+ if (skill == 3)
+ self.pain_finished = time + 5;
+ }
};
+ */
+
+ //==============================================================
+ // Subs
+ //==============================================================

//--------------------------------------------------------------
- // Killed
+ // SUB_CallAsSelf
//--------------------------------------------------------------
- nonvirtual void(entity inflictor, entity attacker) killed =
+ void(entity doas, void() f) sub_runvoidas =
{
- if (this.health < -99)
- // don't let sbar look bad if a player
- this.health = -99;
-
- if (movetype == MOVETYPE_NONE ||
- movetype == MOVETYPE_PUSH ||
- movetype == MOVETYPE_FLYMISSILE ||
- movetype == MOVETYPE_BOUNCE)
- {
- // doors, triggers, missiles, etc
- this.do_destroy ();
- // this.th_die ();
+ if (doas == world)
return;
- }
-
- this.enemy = attacker;

- // bump the monster counter
- if (this.flags & FL_MONSTER)
- {
- killed_monsters = killed_monsters + 1;
- WriteByte (MSG_ALL, SVC_KILLEDMONSTER);
- }
-
- ClientObituary (this, inflictor, attacker);
-
- this.takedamage = DAMAGE_NO;
- this.touch = sub_null;
-
- // TODO CEV
- if (this.classgroup & CG_MONSTER)
- ((base_monster)this).sub_death_use ();
-
- this.do_destroy ();
- // this.th_die ();
+ local entity stemp = self;
+ self = doas;
+ f ();
+ self = stemp;
};

- //==============================================================
- // Subs
- //==============================================================
+ //--------------------------------------------------------------
+ // SUB_CallAsSelfFloat
+ //--------------------------------------------------------------
+ float(entity doas, float() f) sub_runfloatas =
+ {
+ if (doas == world)
+ return 0;
+
+ local entity stemp = self;
+ local float fl;
+ self = doas;
+ fl = f ();
+ self = stemp;
+ return fl;
+ };

//--------------------------------------------------------------
// was CheckValidTouch(); needed for both spawnable map entities
// and temporary entities -- CEV
//--------------------------------------------------------------
- nonvirtual float(entity toucher) sub_checkvalidtouch =
+ float(entity toucher) sub_checkvalidtouch =
{
if (toucher.classtype != CT_PLAYER)
return FALSE;
+
if (toucher.health <= 0)
return FALSE;
+
if (toucher.movetype == MOVETYPE_NOCLIP)
return FALSE;
- if (this.estate != STATE_ACTIVE)
+
+ // if (toucher.classtype & CG_PROJECTILE)
+ // return FALSE;
+
+ if (self.estate != STATE_ACTIVE)
return FALSE;
+
return TRUE;
};

//--------------------------------------------------------------
- nonvirtual void() sub_usetargets =
+ void() sub_usetargets =
{
- if (this.estate != STATE_ACTIVE)
+ if (self.estate != STATE_ACTIVE)
return;

- if (this.delay)
+ if (self.delay)
{
// create a temp object to fire at a later time
- spawn (temp_delayed_use,
- enemy: activator,
- nextthink: time + this.delay,
- message: this.message,
- killtarget: this.killtarget,
- killtarget2: this.killtarget2,
- target: this.target,
- target2: this.target2,
- target3: this.target3,
- target4: this.target4);
+ spawn_temp_delayed_targets ();
return;
}

- local entity original_other = other;
local entity t;
- local string match = "";
+ local string s = "";

// print the message
- if (this.message != "" && !(flags & FL_NOCENTERPRINT))
+ if (self.message != "" && !(self.flags & FL_NOCENTERPRINT))
{
- if (this.spawnflags & TRIGGER_CENTERPRINTALL)
+ if (self.spawnflags & TRIGGER_CENTERPRINTALL)
{
- t = findfloat (world, ::classtype, CT_PLAYER);
+ t = findfloat (world, classtype, CT_PLAYER);
while (t)
{
- centerprint (t, this.message);
- if (!this.noise)
+ centerprint (t, self.message);
+ if (!self.noise)
sound (t, CHAN_VOICE,
"misc/talk.wav",
1, ATTN_NORM);
- t = findfloat (t, ::classtype,
- CT_PLAYER);
+ t = findfloat (t, classtype, CT_PLAYER);
}
}
else if (activator.classtype == CT_PLAYER)
{
- centerprint (activator, this.message);
- if (!this.noise)
+ centerprint (activator, self.message);
+ if (!self.noise)
sound (activator, CHAN_VOICE,
"misc/talk.wav", 1, ATTN_NORM);
}
}

// killtargets
- for (float i = 0; i < 2; i++)
+ for (float g = 0; g < 2; g++)
{
- if (i == 0)
- match = this.killtarget;
- else if (i == 1)
- match = this.killtarget2;
+ if (g == 1)
+ s = self.killtarget2;
+ else if (g == 0)
+ s = self.killtarget;

- if (match == __NULL__ || match == "")
+ if (s == __NULL__ || s == "")
continue;

- // copy-and-pasting a little code here -- CEV
- t = find (world, ::targetname, match);
- while (t != world)
+ for (float h = 0; h < 4; h++)
{
- if (t.switchshadstyle)
- lightstyle (t.switchshadstyle, "m");
- if (t)
- remove (t);
- t = find (t, ::targetname, match);
- }
-
- t = find (world, ::targetname2, match);
- while (t != world)
- {
- if (t.switchshadstyle)
- lightstyle (t.switchshadstyle, "m");
- if (t)
- remove (t);
- t = find (t, ::targetname2, match);
- }
-
- t = find (world, ::targetname3, match);
- while (t != world)
- {
- if (t.switchshadstyle)
- lightstyle (t.switchshadstyle, "m");
- if (t)
- remove (t);
- t = find (t, ::targetname3, match);
+ if (h == 3)
+ sub_killtarget (s, targetname4);
+ else if (h == 2)
+ sub_killtarget (s, targetname3);
+ else if (h == 1)
+ sub_killtarget (s, targetname2);
+ else
+ sub_killtarget (s, targetname);
}

- t = find (world, ::targetname4, match);
- while (t != world)
- {
- if (t.switchshadstyle)
- lightstyle (t.switchshadstyle, "m");
- if (t)
- remove (t);
- t = find (t, ::targetname4, match);
- }
- match = "";
+ s = "";
}

- // for the use calls below
- other = this;
-
// regular targets
for (float i = 0; i < 4; i++)
{
- switch (i)
- {
- case 3:
- match = this.target4;
- break;
- case 2:
- match = this.target3;
- break;
- case 1:
- match = this.target2;
- break;
- default:
- match = this.target;
- }
+ if (i == 3)
+ s = self.target4;
+ else if (i == 2)
+ s = self.target3;
+ else if (i == 1)
+ s = self.target2;
+ else
+ s = self.target;

- if (match == __NULL__ || match == "")
+ if (s == __NULL__ || s == "")
continue;

- // copy-and-pasting again -- CEV
- t = find (world, ::targetname, match);
- while (t != world)
- {
- // TODO CEV
- if (t.classgroup & CG_ENTITY)
- ((base_entity)t).use ();
- else
- SUB_UseAsSelf (t, match);
- t = find (t, ::targetname, match);
- }
-
- t = find (world, ::targetname2, match);
- while (t != world)
+ for (float j = 0; j < 4; j++)
{
- // TODO CEV
- if (t.classgroup & CG_ENTITY)
- ((base_entity)t).use ();
- else
- SUB_UseAsSelf (t, match);
- t = find (t, ::targetname2, match);
- }
-
- t = find (world, ::targetname3, match);
- while (t != world)
- {
- // TODO CEV
- if (t.classgroup & CG_ENTITY)
- ((base_entity)t).use ();
- else
- SUB_UseAsSelf (t, match);
- t = find (t, ::targetname3, match);
+ if (j == 3)
+ sub_usetarget (s, targetname4);
+ else if (j == 2)
+ sub_usetarget (s, targetname3);
+ else if (j == 1)
+ sub_usetarget (s, targetname2);
+ else if (j == 0)
+ sub_usetarget (s, targetname);
}

- t = find (world, ::targetname4, match);
- while (t != world)
- {
- // TODO CEV
- if (t.classgroup & CG_ENTITY)
- ((base_entity)t).use ();
- else
- SUB_UseAsSelf (t, match);
- t = find (t, ::targetname4, match);
- }
+ s = "";
}
-
- // reverse the 'other' global before finishing
- other = original_other;
};

//--------------------------------------------------------------
- nonvirtual void(string matchstring, .string matchfield) sub_usetarget =
+ void(string matchstring, .string matchfield) sub_killtarget =
{
- if (matchstring == __NULL__ || matchstring == "")
- return;
-
- local entity otemp = other;
- local entity t;
- other = this;
-
- t = find (world, ::matchfield, matchstring);
+ local entity t = find (world, matchfield, matchstring);
while (t != world)
{
- // TODO CEV
- if (t.classgroup & CG_ENTITY)
- ((base_entity)t).use ();
- else
- SUB_UseAsSelf (t, matchstring);
- t = find (t, ::matchfield, matchstring);
+ if (t.switchshadstyle)
+ lightstyle (t.switchshadstyle, "m");
+ if (t)
+ remove (t);
+ t = find (t, matchfield, matchstring);
}
-
- other = otemp;
};

- //==============================================================
- // Interfacing
- //==============================================================
-
- // blocked() seems to only be used by func_ entities so it's
- // undefined here & defined later in the base_func class -- CEV
-
- //--------------------------------------------------------------
- virtual void(entity attacker, float damage) do_damage = { };
-
//--------------------------------------------------------------
- virtual void() do_destroy = { };
-
- //--------------------------------------------------------------
- virtual void() do_think = { };
-
- //--------------------------------------------------------------
- virtual void() think =
+ void(string matchstring, .string matchfield) sub_usetarget =
{
- // has think been disabled? -- CEV
- if (this.interaction_flags & DISABLE_THINK)
+ if (matchstring == __NULL__ || matchstring == "")
return;

- do_think ();
- };
+ local entity stemp, otemp;
+ local entity atemp = activator;
+ local entity t = find (world, matchfield, matchstring);

- //--------------------------------------------------------------
- virtual void(entity toucher) do_touch = { };
+ while (t != world)
+ {
+ stemp = self;
+ otemp = other;
+ self = t;
+ other = stemp;
+ if (self.use != sub_null)
+ {
+ if (self.use)
+ {
+ // lastnameused = matchstring;
+ self.use ();
+ }
+ }
+ self = stemp;
+ other = otemp;
+ activator = atemp;
+ t = find (t, matchfield, matchstring);
+ }
+ };
+// };
+#endif

+#ifdef SSQC
+//----------------------------------------------------------------------
+// base_tempentity -- QC generated temporary entities
+//----------------------------------------------------------------------
+// class base_tempentity: base_entity
+// {
//--------------------------------------------------------------
- virtual void() touch =
+ void(entity e) base_tempentity_init =
{
- // has touch been disabled? -- CEV
- if (this.interaction_flags & DISABLE_TOUCH)
- return;
-
- do_touch (other);
+ e.classgroup |= CG_TEMPENTITY;
};

//--------------------------------------------------------------
- virtual void(entity caller) do_use = { };
-
- //--------------------------------------------------------------
- virtual void() use =
+ strip void() base_tempentity =
{
- // has use been disabled? -- CEV
- if (this.interaction_flags & DISABLE_USE)
- return;
-
- do_use (other);
+ base_tempentity_init (self);
};
+// };
+#endif

- //==============================================================
- // Constructor & Spawn Functions
- //==============================================================
-
+#ifdef SSQC
+//----------------------------------------------------------------------
+// temp_delayed_targets -- to facilitate delayed SUB_UseTargets
+//----------------------------------------------------------------------
+// class temp_delayed_targets: base_tempentity
+// {
//--------------------------------------------------------------
- void() base_entity =
+ void() temp_delayed_targets_think =
{
- this.classgroup |= CG_ENTITY;
+ activator = self.enemy;
+ sub_usetargets ();
+ remove (self);
};
-};
-
-//------------------------------------------------------------------------------
-// base_tempentity -- QC generated temporary entities
-//------------------------------------------------------------------------------
-class base_tempentity: base_entity
-{
- //==============================================================
- // Interfacing
- //==============================================================
-
- //==============================================================
- // Initialization
- //==============================================================

//--------------------------------------------------------------
- void() base_tempentity =
+ // 'self' in this context is the caller, not temp_delayed_targets
+ //--------------------------------------------------------------
+ entity() spawn_temp_delayed_targets =
{
- this.classgroup |= CG_TEMPENTITY;
+ // create a temp object to fire at a later time
+ local entity e = spawn ();
+
+ temp_delayed_targets_init (e);
+
+ e.enemy = activator;
+ e.message = self.message;
+ e.killtarget = self.killtarget;
+ e.killtarget2 = self.killtarget2;
+ e.target = self.target;
+ e.target2 = self.target2;
+ e.target3 = self.target3;
+ e.target4 = self.target4;
+ e.nextthink = time + self.delay;
+
+ return e;
};
-};

-//------------------------------------------------------------------------------
-// temp_delayed_use -- to facilitate delayed SUB_UseTargets
-//------------------------------------------------------------------------------
-class temp_delayed_use: base_tempentity
-{
//--------------------------------------------------------------
- virtual void() think =
+ void(entity e) temp_delayed_targets_init =
{
- activator = this.enemy;
- this.sub_usetargets ();
- remove (this);
+ base_tempentity_init (e);
+
+ e.classname = "DelayedUse";
+ e.classtype = CT_TEMP_DELAYEDUSE;
+ e.think = temp_delayed_targets_think;
};

//--------------------------------------------------------------
- void() temp_delayed_use =
+ strip void() temp_delayed_targets =
{
- this.classname = "DelayedUse";
- this.classtype = CT_TEMP_DELAYEDUSE;
- this.classgroup = CG_TEMPENTITY;
+ temp_delayed_targets_init (self);
};
-};
+// };
+#endif

-//------------------------------------------------------------------------------
+#ifdef SSQC
+//----------------------------------------------------------------------
// base_mapentity -- spawnable mapper-placeable entities
-//------------------------------------------------------------------------------
-class base_mapentity: base_entity
-{
+//----------------------------------------------------------------------
+// class base_mapentity: base_entity
+// {
//==============================================================
// Subs
//==============================================================

//--------------------------------------------------------------
- nonvirtual void() sub_setmovedir =
+ void(entity e) sub_setmovedir =
{
// QuakeEd only writes a single float for angles (bad idea),
// so up and down are just constant angles.
- if (this.angles == '0 -1 0')
+ if (e.angles == '0 -1 0')
{
- this.movedir = '0 0 1';
+ e.movedir = '0 0 1';
}
- else if (this.angles == '0 -2 0')
+ else if (e.angles == '0 -2 0')
{
- this.movedir = '0 0 -1';
+ e.movedir = '0 0 -1';
}
else
{
- makevectors (this.angles);
- this.movedir = v_forward;
+ makevectors (e.angles);
+ e.movedir = v_forward;
}

- this.angles = '0 0 0';
+ e.angles = '0 0 0';
};

//--------------------------------------------------------------
- nonvirtual void() sub_useandforgettargets =
+ void() sub_useandforgettargets =
{
sub_usetargets ();

- this.delay = 0;
- this.killtarget = "";
- this.killtarget2 = "";
- this.message = "";
- this.target = "";
- this.target2 = "";
- this.target3 = "";
- this.target4 = "";
+ self.delay = 0;
+ self.killtarget = "";
+ self.killtarget2 = "";
+ self.message = "";
+ self.target = "";
+ self.target2 = "";
+ self.target3 = "";
+ self.target4 = "";
};

//==============================================================
@@ -852,101 +1128,31 @@ class base_mapentity: base_entity
//==============================================================

//--------------------------------------------------------------
- // Ian "iw" Walshaw's new spawnflags for entities, created for
- // progs_dump August 2019.
- //
- // The SPAWNFLAG constants & setup functions are defined elsewhere;
- // see newflags.qc for documentation.
- //--------------------------------------------------------------
- virtual float() sub_inhibit =
+ void(entity e) base_mapentity_init =
{
- if (coop && (spawnflags & SPAWNFLAG_NOT_IN_COOP))
- {
- total_not_in_coop = total_not_in_coop + 1;
- remove (this);
- return TRUE;
- }
-
- if (!coop && !deathmatch && (spawnflags & SPAWNFLAG_NOT_IN_SP))
- {
- total_not_in_sp = total_not_in_sp + 1;
- remove (this);
- return TRUE;
- }
-
- // The built-in skill level spawnflags are ignored in
- // Deathmatch, so we ignore the new ones in Deathmatch, too.
- // -- iw
- if (!deathmatch)
- {
- if (skill == 2 &&
- (spawnflags & SPAWNFLAG_NOT_ON_SKILL2))
- {
- total_not_on_skill2 = total_not_on_skill2 + 1;
- remove (this);
- return TRUE;
- }
-
- if (skill == 3 &&
- (spawnflags & SPAWNFLAG_NOT_ON_SKILL3))
- {
- total_not_on_skill3 = total_not_on_skill3 + 1;
- remove (this);
- return TRUE;
- }
- }
-
- return FALSE;
+ e.classgroup |= CG_MAPENTITY;
};

//--------------------------------------------------------------
- // class fields are set _after_ the individual class constructors
- // are run -- CEV
- //--------------------------------------------------------------
- virtual void(string fieldname, string fieldvalue) init_field = { };
-
- //--------------------------------------------------------------
- // because the constructor doesn't have reliable access to class
- // fields, do any field handling in init_spawned -- CEV
- //--------------------------------------------------------------
- virtual void() init_spawned = { };
-
- //--------------------------------------------------------------
- void() base_mapentity =
+ strip void() base_mapentity =
{
- // new spawnflags for all entities -- iw
- // "all entities", well, all base_mapentities anyway -- CEV
- if (sub_inhibit())
- return;
+ base_mapentity_init (self);
+ };
+// };
+#endif

- // this is from Nuclide -- CEV
- if (__fullspawndata != __NULL__ && __fullspawndata != "")
- {
- // __fullspawndata contains an entity's fields as
- // set in the map file in a format suitable for
- // reading with tokenize () -- CEV
#ifdef SSQC
- // according to Nuclide start offsets differ between
- // client and server Quake C
- for (float i = 1; i < (tokenize(__fullspawndata) - 1);
- i += 2)
-#else
- // client starts at 0
- for (float i = 0; i < (tokenize(__fullspawndata) - 1);
- i += 2)
-#endif
- {
- /*
- dprint (sprintf("base_mapentity::base_mapentity"
- ": classname %s, fieldname %s\n",
- this.classname, argv(i)));
- */
- init_field (argv(i), argv(i + 1));
- }
- __fullspawndata = "";
- }
+/*QUAKED noclass (0 0 0) (-8 -8 -8) (8 8 8)
+prints a warning message when spawned
+*/
+//----------------------------------------------------------------------
+void() noclass =
+{
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;

- classgroup |= CG_MAPENTITY;
- init_spawned ();
- };
+ dprint (sprintf("noclass: spawned at %v\n", self.origin));
+ remove (self);
};
+#endif

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

Diff qc/base_func.qc

diff --git a/qc/base_func.qc b/qc/base_func.qc
index 858a045..6a88388 100644
--- a/qc/base_func.qc
+++ b/qc/base_func.qc
@@ -6,75 +6,82 @@
// Constants
//======================================================================

-// button, door, elevator states -- CEV
-const float FUNC_STATE_TOP = 0;
+const float FUNC_STATE_TOP = 0; // button, door, elevator states
const float FUNC_STATE_BOTTOM = 1;
const float FUNC_STATE_UP = 2;
const float FUNC_STATE_DOWN = 3;

-//------------------------------------------------------------------------------
-class base_func: base_mapentity
-{
- //==============================================================
- // class fields
- //==============================================================
- float aflag;
- float calc_move_done;
+//======================================================================
+// fields
+//======================================================================

- //==============================================================
- // Interfacing
- //==============================================================
+.float lip; //

- //--------------------------------------------------------------
- virtual void(entity blocker) do_blocked = { };
+.void() think1; // called by calcmove_done
+.vector finaldest, finalangle;

- //--------------------------------------------------------------
- virtual void() blocked =
- {
- // has think been disabled? -- CEV
- if (this.interaction_flags & DISABLE_BLOCKED)
- return;
+//======================================================================
+// forward declarations
+//======================================================================

- // don't call blocked when stopped by a projectile -- CEV
- if (other.classgroup & CG_PROJECTILE)
- return;
+void() sub_calcmove_done_think;
+void(entity e, vector tdest, float tspeed, void() newthink) sub_calcmove;
+void() sub_calcanglemovecontroller_done;
+void(entity e, vector destangle, float tspeed, void() func, entity c)
+ sub_calcanglemovecontroller;
+void(entity e) base_func_init;
+strip void() base_func;

- do_blocked (other);
- };
+//------------------------------------------------------------------------------

+//----------------------------------------------------------------------
+// class base_func: base_mapentity
+// {
//==============================================================
// Subs
//==============================================================

//--------------------------------------------------------------
+ void() sub_calcmove_done_think =
+ {
+ setorigin (self, self.finaldest);
+ self.velocity = '0 0 0';
+ self.nextthink = -1;
+
+ if (self.think1)
+ self.think1 ();
+ };
+
+ //--------------------------------------------------------------
// SUB_CalcMove
//--------------------------------------------------------------
- nonvirtual void(vector tdest, float tspeed, void() newthink) calc_move =
+ void(entity e, vector tdest, float tspeed, void() newthink)
+ sub_calcmove =
{
local vector vdestdelta;
local float len, traveltime, localtime;

if (!tspeed)
- objerror ("mapentity::calc_move: No speed is defined!");
+ objerror ("sub_calcmove: No speed is defined!");

- if (this.movetype == MOVETYPE_PUSH)
- localtime = this.ltime;
+ if (e.movetype == MOVETYPE_PUSH)
+ localtime = self.ltime;
else
localtime = time;

- this.think1 = newthink;
- this.finaldest = tdest;
- this.calc_move_done = TRUE;
+ e.think1 = newthink;
+ e.finaldest = tdest;
+ e.think = sub_calcmove_done_think;

- if (tdest == this.origin)
+ if (tdest == self.origin)
{
- this.velocity = '0 0 0';
- this.nextthink = localtime + 0.1;
+ e.velocity = '0 0 0';
+ e.nextthink = localtime + 0.1;
return;
}

// set destdelta to the vector needed to move
- vdestdelta = tdest - this.origin;
+ vdestdelta = tdest - self.origin;

// calculate length of vector
len = vlen (vdestdelta);
@@ -84,61 +91,91 @@ class base_func: base_mapentity

if (traveltime < 0.1)
{
- this.velocity = '0 0 0';
- this.nextthink = localtime + 0.1;
+ e.velocity = '0 0 0';
+ e.nextthink = localtime + 0.1;
return;
}

// set nextthink to trigger a think when d is reached
- this.nextthink = localtime + traveltime;
+ e.nextthink = localtime + traveltime;

// scale the destdelta vector by the time spent traveling
// to get velocity
// qcc won't take vec/float
- this.velocity = vdestdelta * (1 / traveltime);
+ e.velocity = vdestdelta * (1 / traveltime);
};

- //==============================================================
- // Interfacing
- //==============================================================
+ //--------------------------------------------------------------
+ // SUB_CalcAngleMoveDoneController
+ // After rotating, set angle to exact final angle
+ //--------------------------------------------------------------
+ void() sub_calcanglemovecontroller_done =
+ {
+ self.owner.angles = self.finalangle;
+ self.owner.avelocity = '0 0 0';
+ self.nextthink = -1;
+ if (self.think1)
+ sub_runvoidas (self.owner, self.think1);
+ };

//--------------------------------------------------------------
- virtual void() think =
+ // SUB_CalcAngleMoveController -- Same as SUB_CalcAngleMove, but
+ // using a separate controller entity to not lose track of current
+ // think functions.
+ //--------------------------------------------------------------
+ void(entity e, vector destangle, float tspeed, void() func,
+ entity c) sub_calcanglemovecontroller =
{
- // has think been disabled? -- CEV
- if (this.interaction_flags & DISABLE_THINK)
- return;
+ local vector destdelta;
+ local float len, traveltime;

- if (this.calc_move_done == TRUE)
- {
- setorigin (this, this.finaldest);
- this.velocity = '0 0 0';
- this.nextthink = -1;
+ if (!tspeed)
+ objerror("sub_calcanglemove: No speed is defined!\n");

- // clear calc_move_done before calling think1 -- CEV
- if (this.calc_move_done == TRUE)
- this.calc_move_done = FALSE;
+ // set destdelta to the vector needed to move
+ destdelta = normalize_angles180 (destangle - e.angles);

- if (this.think1)
- this.think1 ();
- }
- else
- {
- do_think ();
- }
- };
+ /*
+ dprint3 ("destangle: ", vtos(destangle), "\n");
+ dprint3 ("self.angles: ", vtos(self.angles), "\n");
+ dprint3 ("destdelta: ", vtos(destdelta), "\n");
+ */

- //--------------------------------------------------------------
- virtual void() think1 = { };
+ // 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
+ c.nextthink = time + traveltime;
+
+ // scale the destdelta vector by the time spent traveling to
+ // get velocity
+ e.avelocity = destdelta * (1 / traveltime);
+
+ // Makes sure controller.owner points to self so it can be
+ // referenced later in the think function
+ c.owner = e;
+ c.think1 = func;
+ c.finalangle = destangle;
+ c.think = sub_calcanglemovecontroller_done;
+ };

//==============================================================
// Constructor & Spawn Functions
//==============================================================

//--------------------------------------------------------------
- void() base_func =
+ void(entity e) base_func_init =
+ {
+ base_mapentity_init (e);
+ e.classgroup |= CG_FUNC;
+ };
+
+ //--------------------------------------------------------------
+ strip void() base_func =
{
- this.classgroup |= CG_FUNC;
- this.calc_move_done = FALSE;
+ base_func_init (self);
};
-};
+// };

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

Diff qc/base_item.qc

diff --git a/qc/base_item.qc b/qc/base_item.qc
index 9a27a02..ff2e106 100644
--- a/qc/base_item.qc
+++ b/qc/base_item.qc
@@ -2,143 +2,131 @@
// base_item.qc -- top-level item pickups
//==============================================================================

-// constants - spawnflags
-const float ITEM_SPAWNSILENT = 32;
+//======================================================================
+// constants
+//======================================================================
+
+const float ITEM_SPAWNSILENT = 32; // item spawnflags
const float ITEM_SPAWNED = 64;
const float ITEM_SUSPENDED = 128;
const float ITEM_RESPAWNDM = 16384;
const float ITEM_DONTDROP = 8388608;

-// constants - alpha values (for respawn feedback)
-const float ITEM_ALPHA_WAITSPAWN = 0.1;
+const float ITEM_ALPHA_WAITSPAWN = 0.1; // alpha values (respawn feedback)
const float ITEM_ALPHA_NEARSPAWN = 0.25;
const float ITEM_ALPHA_OPAQUE = 1.0;

const string ITEM_SOUND_SPAWN = "items/item_respawn_q3.wav";

-// constants - internal flags
-enumflags
-{
- ITEM_FLAG_DELAYSPAWN,
- ITEM_FLAG_RHULL,
- ITEM_FLAG_RESPAWN,
- ITEM_FLAG_SPAWN,
- ITEM_FLAG_NEARSPAWNTIME,
- ITEM_FLAG_REMOVE
-};
+//======================================================================
+// fields
+//======================================================================
+
+// Supa, Quoth respawning items support
+//
+// Respawn item like in DM if 'ritem' TRUE, override respawn time
+// with 'respawndelay' if set, inc 'cnt' with each respawn and if
+// 'respawncount' is set we'll remove the item if cnt > respawncount
+// remember that SUB_Regen is already set on every item that can
+// respawn, all we need to do is give a nextthink time in order
+// to trigger it
+
+.float ritem; // legacy SP item respawn flag
+.float respawndelay; // legacy SP respawn delay
+.float respawncount; // legacy SP respawn limit
+
+.vector particles_offset;
+
+//======================================================================
+// forward declarations
+//======================================================================
+
+void(entity actor) base_item_drop_stuff;
+float(entity item, float delay_sp, float delay_dm) base_item_check_respawn;
+void() base_item_think_respawn;
+void() base_item_think_nearspawn;
+void() base_item_think_rhull;
+void() base_item_think_place;
+void() base_item_use_delayspawn;
+void(entity e) base_item_init;
+strip void() base_item;

//------------------------------------------------------------------------------
-class base_item: base_mapentity
-{
- //==============================================================
- // class fields
- //==============================================================
- float aflag;
- float item_flags; // internal think & use state flags
- vector pos1;
- vector pos2;
-
- // Supa, Quoth respawning items support
- //
- // Respawn item like in DM if 'ritem' TRUE, override respawn time
- // with 'respawndelay' if set, inc 'cnt' with each respawn and if
- // 'respawncount' is set we'll remove the item if cnt > respawncount
- // remember that SUB_Regen is already set on every item that can
- // respawn, all we need to do is give a nextthink time in order
- // to trigger it
-
- float ritem; // legacy singleplayer item respawn flag
- float respawndelay; // legacy singleplayer respawn delay
- float respawncount; // legacy singleplayer respawn limit
-
- string respawn_sound; // custom respawn sound
-
- vector particles_offset;
- vector size_min; // item bounding box mins
- vector size_max; // item bounding box maxs
-
- //--------------------------------------------------------------
- virtual void(string fieldname, string fieldvalue) init_field =
- {
- switch (fieldname)
- {
- case "particles_offset":
- particles_offset = stov (fieldvalue);
- break;
- case "ritem":
- ritem = stof (fieldvalue);
- break;
- case "respawndelay":
- respawndelay = stof (fieldvalue);
- break;
- case "respawncount":
- respawncount = stof (fieldvalue);
- break;
- default:
- super::init_field (fieldname, fieldvalue);
- }
- };

+//----------------------------------------------------------------------
+// class base_item: base_mapentity
+// {
//==============================================================
// Static Helper Functions
//==============================================================

//--------------------------------------------------------------
+ // DropStuff -- dumptruck_ds
+ // set drops_item on a monster to a number:
+ //
+ // 1 = Silver Key
+ // 2 = Gold Key
+ // 3 = Health Vial
+ // 4 = Armor Shard
+ // 5 = Health Vial & Armor Shard
+ // 6 = random combination of 3 Vials and/or Shards
+ //
// TODO CEV this should probably be outside of base_item
//--------------------------------------------------------------
- static void(entity actor) drop_stuff =
+ void(entity actor) base_item_drop_stuff =
{
switch (actor.drop_item)
{
+ case 0:
+ // drop nothing
+ break;
case 1:
- DropKey1 ();
+ item_key1_drop (self);
break;
case 2:
- DropKey2 ();
+ item_key2_drop (self);
break;
case 3:
- DropVial ();
+ item_health_vial_drop (self);
break;
case 4:
- DropShard ();
+ item_armor_shard_drop (self);
break;
case 5:
- DropVial ();
- DropShard ();
+ item_health_vial_drop (self);
+ item_armor_shard_drop (self);
break;
case 6:
local float rand_drop = rint(random() * 3);
if (rand_drop == 1)
{
- DropShard ();
- DropVial ();
- DropVial ();
+ item_armor_shard_drop (self);
+ item_health_vial_drop (self);
+ item_health_vial_drop (self);
}
else if (rand_drop == 2)
{
- DropShard ();
- DropShard ();
- DropVial ();
+ item_armor_shard_drop (self);
+ item_armor_shard_drop (self);
+ item_health_vial_drop (self);
}
else if (rand_drop == 0)
{
- DropShard ();
- DropShard ();
- DropShard ();
+ item_armor_shard_drop (self);
+ item_armor_shard_drop (self);
+ item_armor_shard_drop (self);
}
else
{
- DropVial ();
- DropVial ();
- DropVial ();
+ item_health_vial_drop (self);
+ item_health_vial_drop (self);
+ item_health_vial_drop (self);
}
break;
- /*
default:
- dprint (sprintf("base_item::drop_stuff: "
+ dprint (sprintf("base_item_drop_stuff: "
"unhandled drop_item %g\n",
actor.drop_item));
- */
}
};

@@ -149,8 +137,8 @@ class base_item: base_mapentity
//--------------------------------------------------------------
// CheckItemRespawn -- was in items.qc
//--------------------------------------------------------------
- static float(base_item item, float delay_sp, float delay_dm)
- check_respawn =
+ float(entity item, float delay_sp, float delay_dm)
+ base_item_check_respawn =
{
// DM rules first
if (deathmatch == 1)
@@ -158,8 +146,7 @@ class base_item: base_mapentity
if (delay_dm > 5.0)
{
item.alpha = ITEM_ALPHA_WAITSPAWN;
- item.item_flags |= ITEM_FLAG_NEARSPAWNTIME;
- item.item_flags &= ~ITEM_FLAG_RESPAWN;
+ item.think = base_item_think_nearspawn;
item.nextthink = time + delay_dm - 5.0;
}
else
@@ -169,13 +156,13 @@ class base_item: base_mapentity
}

item.nextthink = time + delay_dm;
- setmodel (this, this.mdl);
+ setmodel (item, item.mdl);
return TRUE;
}

if (deathmatch)
{
- dprint (sprintf("base_item::check_respawn: unhandled "
+ dprint (sprintf("base_item_check_respawn: unhandled "
"deathmatch state %f\n", deathmatch));
return FALSE;
}
@@ -199,8 +186,7 @@ class base_item: base_mapentity
if (item.respawndelay > 5.0)
{
item.alpha = ITEM_ALPHA_WAITSPAWN;
- item.item_flags |= ITEM_FLAG_NEARSPAWNTIME;
- item.item_flags &= ~ITEM_FLAG_RESPAWN;
+ item.think = base_item_think_nearspawn;
item.nextthink = time + item.respawndelay - 5.0;
}
else
@@ -214,8 +200,7 @@ class base_item: base_mapentity
if (delay_sp > 5.0)
{
item.alpha = ITEM_ALPHA_WAITSPAWN;
- item.item_flags |= ITEM_FLAG_NEARSPAWNTIME;
- item.item_flags &= ~ITEM_FLAG_RESPAWN;
+ item.think = base_item_think_nearspawn;
item.nextthink = time + delay_sp - 5.0;
}
else
@@ -229,56 +214,82 @@ class base_item: base_mapentity
return TRUE;
};

+ //==============================================================
+ // Interfacing
+ //==============================================================
+
//--------------------------------------------------------------
// SUB_Regen -- was in items.qc
//--------------------------------------------------------------
- nonvirtual void() sub_regen =
+ void() base_item_think_respawn =
{
// restore original model
- this.model = this.mdl;
- this.alpha = ITEM_ALPHA_OPAQUE;
+ self.model = self.mdl;
+ self.alpha = ITEM_ALPHA_OPAQUE;

// allow it to be touched again
- this.solid = SOLID_TRIGGER;
+ self.solid = SOLID_TRIGGER;

// new respawning effects -- CEV
- // Respawn with DM effects
- // if (deathmatch || (this.spawnflags & ITEM_RESPAWNDM))
- // play respawn sound
- if (respawn_sound && respawn_sound != "")
- sound (this, CHAN_VOICE, respawn_sound, 1, ATTN_NORM);
+ sound (self, CHAN_VOICE, ITEM_SOUND_SPAWN, 1, ATTN_NORM);
+
+ setorigin (self, self.origin);
+ setsize (self, self.pos1, self.pos2);
+ };
+
+ //--------------------------------------------------------------
+ void() base_item_think_nearspawn =
+ {
+ // bump alpha when 5s remain -- CEV
+ self.alpha = ITEM_ALPHA_NEARSPAWN;
+ self.think = base_item_think_respawn;
+ self.nextthink = time + 5.0;
+ };
+
+ //--------------------------------------------------------------
+ // RefreshHull -- Supa, restore old hull and lock movement
+ //--------------------------------------------------------------
+ void() base_item_think_rhull =
+ {
+ dprint ("base_item_think_rhull: fix for bboxes\n");
+
+ // dumptruck_ds -- fix for bounding boxes
+ if (self.pos1 && self.pos2)
+ setsize (self, self.pos1, self.pos2);
else
- sound (this, CHAN_VOICE, ITEM_SOUND_SPAWN, 1, ATTN_NORM);
+ setsize (self, '0 0 0', '32 32 56');

- setorigin (this, this.origin);
- setsize (this, this.size_min, this.size_max);
+ self.movetype = MOVETYPE_NONE;
+ self.velocity = '0 0 0';
};

//--------------------------------------------------------------
// PlaceItem -- plants the object on the floor
//--------------------------------------------------------------
- nonvirtual void() sub_place_item =
+ void() base_item_think_place =
{
- // so it can be restored on respawn
- this.mdl = this.model;
- this.alpha = ITEM_ALPHA_OPAQUE;
- if (!this.size_min && !this.size_max)
- {
- this.size_min = '0 0 0';
- this.size_max = '32 32 56';
- }
- setsize (this, this.size_min, this.size_max);
+ self.alpha = ITEM_ALPHA_OPAQUE;
+ self.solid = SOLID_TRIGGER;
+ self.velocity = '0 0 0';
+ self.think = base_item_think_respawn;

// make extra wide
- this.flags = FL_ITEM;
+ self.flags = FL_ITEM;
+
+ // so it can be restored on respawn
+ self.mdl = self.model;

- this.solid = SOLID_TRIGGER;
- this.velocity = '0 0 0';
+ if (!self.pos1 && !self.pos2)
+ {
+ self.pos1 = '0 0 0';
+ self.pos2 = '32 32 56';
+ }
+ setsize (self, self.pos1, self.pos2);

- if (this.spawnflags & ITEM_SUSPENDED)
+ if (self.spawnflags & ITEM_SUSPENDED)
{
// ijed Don't drop spawnflag
- this.movetype = MOVETYPE_FLY;
+ self.movetype = MOVETYPE_FLY;
}
else
{
@@ -297,149 +308,75 @@ class base_item: base_mapentity
// func_mapjamx maps is being played. -- iw
if (known_release == KNOWN_RELEASE_FUNC_MAPJAMX)
{
- if (this.classtype == CT_ITEM_HEALTH)
+ if (self.classtype == CT_ITEM_HEALTH)
{
// Supa, CTF
// hacking around hull issues..
// void hull for now
- setsize (this, '0 0 0', '0 0 0');
- this.item_flags &= ~ITEM_FLAG_SPAWN;
- this.item_flags &= ~ITEM_FLAG_RESPAWN;
- this.item_flags |= ITEM_FLAG_RHULL;
- this.nextthink = time + 0.2;
+ setsize (self, '0 0 0', '0 0 0');
+ self.think = base_item_think_rhull;
+ self.nextthink = time + 0.2;
}
}

- this.movetype = MOVETYPE_TOSS;
+ self.movetype = MOVETYPE_TOSS;

- if (!(this.spawnflags & ITEM_DONTDROP))
+ if (!(self.spawnflags & ITEM_DONTDROP))
{
- setorigin (this, this.origin + '0 0 6');
+ setorigin (self, self.origin + '0 0 6');

- if (!droptofloorwrapper(this))
+ if (!droptofloor())
{
- dprint (sprintf("base_item::sub_place_"
- "item: bonus item %s fell out "
- "of level at %v\n",
- this.classname, this.origin));
+ dprint (sprintf("base_item_think_place"
+ ": bonus item %s fell out of "
+ "level at %v\n",
+ self.classname, self.origin));
// TODO CEV
- // remove (this);
+ // remove (self);
return;
}
}
}

- if (this.spawnflags & ITEM_SPAWNED)
+ if (self.spawnflags & ITEM_SPAWNED)
{
// SPAWNED, gb
- this.pos1 = this.mins;
- this.pos2 = this.maxs;
+ self.pos1 = self.mins;
+ self.pos2 = self.maxs;

- this.model = "";
- this.solid = SOLID_NOT;
+ self.model = "";
+ self.solid = SOLID_NOT;

- if (this.spawnflags & ITEM_DONTDROP)
- this.movetype = MOVETYPE_NONE;
+ if (self.spawnflags & ITEM_DONTDROP)
+ self.movetype = MOVETYPE_NONE;

- this.item_flags |= ITEM_FLAG_DELAYSPAWN;
+ self.use = base_item_use_delayspawn;
}
};

//--------------------------------------------------------------
- // RefreshHull -- Supa, restore old hull and lock movement
+ // DelaySpawnItem -- this is from rmq-items.qc
+ // Makes a SPAWNED item ready for pickup on a trigger event
+ // - modified a bit -- dumptruck_ds
//--------------------------------------------------------------
- nonvirtual void() sub_refresh_hull =
+ void() base_item_use_delayspawn =
{
- dprint ("base_item::sub_refresh_hull: fix for bboxes\n");
-
- // dumptruck_ds -- fix for bounding boxes
- if (this.size_min && this.size_max)
- setsize (this, this.size_min, this.size_max);
+ self.solid = SOLID_TRIGGER;
+ setmodel (self, self.mdl);
+ setsize (self, self.pos1, self.pos2);
+
+ if (!(self.spawnflags & ITEM_SPAWNSILENT))
+ // SILENT, gb
+ // sound (self, CHAN_VOICE, "items/itembk2.wav",
+ // 1, ATTN_NORM);
+ spawn_tfog (self.origin + self.particles_offset);
+
+ if (self.spawnflags & ITEM_SUSPENDED)
+ self.movetype = MOVETYPE_FLY;
else
- setsize (this, '0 0 0', '32 32 56');
+ self.movetype = MOVETYPE_TOSS;

- this.movetype = MOVETYPE_NONE;
- this.velocity = '0 0 0';
- };
-
- //==============================================================
- // Interfacing
- //==============================================================
-
- //--------------------------------------------------------------
- virtual void() do_think =
- {
- if (this.item_flags & ITEM_FLAG_SPAWN)
- {
- // flags might be altered by place_item, so
- // set them beforehand -- CEV
- this.item_flags &= ~ITEM_FLAG_SPAWN;
- this.item_flags |= ITEM_FLAG_RESPAWN;
- sub_place_item ();
- }
- else if (this.item_flags & ITEM_FLAG_RESPAWN)
- {
- sub_regen ();
- }
- else if (this.item_flags & ITEM_FLAG_NEARSPAWNTIME)
- {
- // bump alpha when 5s remain -- CEV
- this.alpha = ITEM_ALPHA_NEARSPAWN;
- this.item_flags &= ~ITEM_FLAG_NEARSPAWNTIME;
- this.item_flags |= ITEM_FLAG_RESPAWN;
- this.nextthink = time + 5.0;
- }
- else if (this.item_flags & ITEM_FLAG_RHULL)
- {
- sub_refresh_hull ();
- }
- else if (this.item_flags & ITEM_FLAG_REMOVE)
- {
- remove (this);
- }
- };
-
- //--------------------------------------------------------------
- virtual void() touch =
- {
- // has touch been disabled? -- CEV
- if (this.interaction_flags & DISABLE_TOUCH)
- return;
-
- if (sub_checkvalidtouch(other) == FALSE)
- return;
-
- do_touch (other);
- };
-
- //--------------------------------------------------------------
- virtual void(entity caller) do_use =
- {
- if (this.item_flags & ITEM_FLAG_DELAYSPAWN)
- {
- //----------------------------------------------
- // DelaySpawnItem -- this is from rmq-items.qc;
- // Makes a SPAWNED item ready for pickup on a
- // trigger event - modified a bit -- dumptruck_ds
- //----------------------------------------------
- this.solid = SOLID_TRIGGER;
- setmodel (this, this.mdl);
- setsize (this, this.pos1, this.pos2);
-
- if (!(this.spawnflags & ITEM_SPAWNSILENT))
- // SILENT, gb
- // sound (this, CHAN_VOICE, "items/itembk2.wav",
- // 1, ATTN_NORM);
- spawn_tfog (this.origin +
- this.particles_offset);
-
- if (this.spawnflags & ITEM_SUSPENDED)
- this.movetype = MOVETYPE_FLY;
- else
- this.movetype = MOVETYPE_TOSS;
-
- this.item_flags &= ~ITEM_FLAG_DELAYSPAWN;
- }
+ self.use = sub_null;
};

//==============================================================
@@ -447,33 +384,23 @@ class base_item: base_mapentity
//==============================================================

//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) base_item_init =
{
+ base_mapentity_init (e);
+ e.classgroup |= CG_ITEM;
+
//------------------------------------------------------
// StartItem -- Sets the clipping size and plants the
// object on the floor
//------------------------------------------------------
-
+ e.think = base_item_think_place;
// items start after other solids || was 0.2 -- dumptruck_ds
- this.nextthink = time + 0.3;
- this.item_flags |= ITEM_FLAG_SPAWN;
+ e.nextthink = time + 0.3;
};

//--------------------------------------------------------------
- void() base_item =
+ strip void() base_item =
{
- this.classgroup |= CG_ITEM;
- this.item_flags |= ITEM_FLAG_SPAWN;
+ base_item_init (self);
};
-};
-
-//==============================================================================
-
-/*QUAKED noclass (0 0 0) (-8 -8 -8) (8 8 8)
-prints a warning message when spawned
-*/
-void() noclass =
-{
- dprint (sprintf("noclass: spawned at %v\n", self.origin));
- remove (self);
-};
+// };

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

Diff qc/base_monster.qc

diff --git a/qc/base_monster.qc b/qc/base_monster.qc
index 8167d3f..2849d15 100644
--- a/qc/base_monster.qc
+++ b/qc/base_monster.qc
@@ -25,16 +25,46 @@ const float AS_MELEE = 3;
const float AS_MISSILE = 4;
const float AS_TURRET = 5;

+const float I_AM_TURRET = 262144; // dumptruck_ds
+
//======================================================================
// globals
//======================================================================
-entity sight_entity; // was in ai.qc
-float sight_entity_time; // was in ai.qc
+
float enemy_vis; // was in fight.qc
float enemy_infront; // was in fight.qc
float enemy_range; // was in fight.qc
float enemy_yaw; // was in fight.qc
+float movedist; // base_monster
+float sight_entity_time; // was in ai.qc
+
+entity sight_entity; // was in ai.qc
+
+//======================================================================
+// fields
+//======================================================================
+
+.float berserk; // dumptruck_ds
+.float drop_item; // key DropStuff
+.float infight_mode;
+.float keep_ammo; // dumptruck_ds
+.float pausetime;
+.float search_time; // base_monster
+.float sight_trigger; // dumptruck_ds
+.float spawn_angry; // dumptruck_ds
+
+.float pain_threshold; // dumptruck_ds
+
+.entity infight_activator;
+.entity movetarget;
+
+//======================================================================
+// forward declarations
+//======================================================================
+
+//------------------------------------------------------------------------------

+#if 0
//======================================================================
// .enemy
// Will be world if not currently angry at anyone.
@@ -1918,3 +1948,4 @@ class base_walkmonster: base_monster
// by Lord Sméagol end
};
};
+#endif

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

Diff qc/base_proj.qc

diff --git a/qc/base_proj.qc b/qc/base_proj.qc
new file mode 100644
index 0000000..8813c6f
--- /dev/null
+++ b/qc/base_proj.qc
@@ -0,0 +1,615 @@
+//==============================================================================
+// base_projectile.qc -- generated projectile entities -- CEV
+//==============================================================================
+
+/*
+========================================================================
+Projectile init checklist, required & optional settings, in suggested
+order, for reference when writing a projectile constructor function
+
+1. classtype & classname (required)
+2. movetype & solid (required)
+3. set touch, pain, and destroy (if desired)
+4. set aflags
+ a. set PROJECTILE_EXPLOSIVE if necessary (parse_projexpl)
+5. set health and takedamage if desired (for explosives)
+6. angles (required) & avelocity
+7. check (and set if necessary) proj_basespeed
+8. check (and set if necessary) direct_damage and splash_damage
+9. setmodel and skin (required)
+10. setup_homing
+11. setsize, setorigin (required)
+12. think & nextthink (if not capable of homing)
+
+see the files in projectiles/ for examples -- CEV
+========================================================================
+*/
+
+//======================================================================
+// Constants
+//======================================================================
+
+enum
+{
+ EXPLOSION_THINK_1, // explosion frame/think tracking
+ EXPLOSION_THINK_2,
+ EXPLOSION_THINK_3,
+ EXPLOSION_THINK_4,
+ EXPLOSION_THINK_5,
+ EXPLOSION_THINK_6,
+ EXPLOSION_THINK_REMOVE
+};
+
+enumflags
+{
+ PROJECTILE_EXPLOSIVE // .aflag projectile options
+};
+
+const float BP_BOUNCE_BACKOFF = 1.5; // MOVETYPE_BOUNCE clipvel mult; id1 1.5
+const float BP_BOUNCE_MIN_ZVEL = 60; // MOVETYPE_BOUNCE stop if _z less than
+
+//======================================================================
+// fields
+//======================================================================
+
+.float direct_damage; // for t_damage
+.float splash_damage; // for t_radiusdamage
+
+// the following are really monster fields. they alter projectile
+// behavior and get transferred to projectile objects so they're
+// defined here -- CEV
+.float homing; // projectile homing
+.float projexpl; // explosive?
+.float proj_speed_mod; // projectile speed modifier
+.float proj_basespeed; // projectile base speed
+.vector cust_avelocity; // projectile custom avelocity
+
+//======================================================================
+// forward declarations
+//======================================================================
+
+// base_explosion
+void(vector org) write_explosion;
+void(vector org) write_explosion2;
+void() base_explosion_think;
+entity(vector org) spawn_base_explosion;
+void(entity e) base_explosion_init;
+strip void() base_explosion;
+
+// base_projectile
+float(float testexpl, float offset) base_projectile_parse_projexpl;
+void(entity p) write_projectile_impact;
+void() base_projectile_homing_think;
+void(entity mis, float speed) base_projectile_setup_homing;
+void() base_projectile_touch_explosive;
+void() base_projectile_touch_normal;
+float() base_projectile_check_touch;
+void() base_projectile_touch;
+void(entity e) base_projectile_init;
+strip void() base_projectile;
+
+// base_projectile_qcphys
+void() base_projectile_qcphys_physics;
+void(entity e) base_projectile_qcphys_init;
+strip void() base_projectile_qcphys;
+
+//------------------------------------------------------------------------------
+
+//----------------------------------------------------------------------
+// standard id1 explosion sprite + a few helper functions -- CEV
+//----------------------------------------------------------------------
+// class base_explosion: base_tempentity
+// {
+ //--------------------------------------------------------------
+ void(vector org) write_explosion =
+ {
+ WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
+ WriteByte (MSG_BROADCAST, TE_EXPLOSION);
+ WriteCoord (MSG_BROADCAST, org_x);
+ WriteCoord (MSG_BROADCAST, org_y);
+ WriteCoord (MSG_BROADCAST, org_z);
+ };
+
+ //--------------------------------------------------------------
+ void(vector org) write_explosion2 =
+ {
+ WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
+ WriteByte (MSG_BROADCAST, TE_EXPLOSION2);
+ WriteCoord (MSG_BROADCAST, org_x);
+ WriteCoord (MSG_BROADCAST, org_y);
+ WriteCoord (MSG_BROADCAST, org_z);
+ };
+
+ //==============================================================
+ // Interaction
+ //==============================================================
+
+ //--------------------------------------------------------------
+ void() base_explosion_think =
+ {
+ if (self.state == EXPLOSION_THINK_REMOVE)
+ {
+ remove (self);
+ return;
+ }
+
+ if (self.state == EXPLOSION_THINK_1)
+ self.frame = 0;
+ else
+ self.frame += 1;
+
+ self.state += 1;
+ self.nextthink = time + 0.1;
+ };
+
+ //==============================================================
+ // Initialization
+ //==============================================================
+
+ //--------------------------------------------------------------
+ // replacement for BecomeExplosion -- CEV
+ //--------------------------------------------------------------
+ entity(vector org) spawn_base_explosion =
+ {
+ local entity e = spawn ();
+
+ e.origin = org;
+ base_explosion_init (e);
+ return e;
+ };
+
+ //--------------------------------------------------------------
+ void(entity e) base_explosion_init =
+ {
+ base_tempentity_init (e);
+
+ e.classname = "base_explosion";
+ e.classtype = CT_TEMP_EXPLOSION;
+ e.movetype = MOVETYPE_NONE;
+ e.solid = SOLID_NOT;
+ e.state = EXPLOSION_THINK_1;
+ e.think = base_explosion_think;
+ e.touch = sub_null;
+ e.use = sub_null;
+ e.velocity = '0 0 0';
+ if (e.origin == '0 0 0')
+ dprint ("spawn_base_explosion: zero origin\n");
+ setorigin (e, e.origin);
+ setmodel (e, "progs/s_explod.spr");
+ sub_think (e, base_explosion_think);
+ };
+
+ //--------------------------------------------------------------
+ strip void() base_explosion =
+ {
+ base_explosion_init (self);
+ };
+// };
+
+//----------------------------------------------------------------------
+// class base_projectile: base_tempentity
+// {
+
+ //--------------------------------------------------------------
+ float(float testexpl, float offset) base_projectile_parse_projexpl =
+ {
+ return testexpl == 1 ||
+ (testexpl == 2 && offset % 2 == 0) ||
+ (testexpl == 3 && random() * 2 < 1);
+ };
+
+ //--------------------------------------------------------------
+ // I'm sure there's a better way to do this -- CEV
+ //--------------------------------------------------------------
+ void(entity p) write_projectile_impact =
+ {
+ WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
+ if (p.snd_hit != __NULL__ && p.snd_hit != "")
+ {
+ // dumptruck_ds
+ sound (p, CHAN_WEAPON, p.snd_hit, 1, ATTN_STATIC);
+ WriteByte (MSG_BROADCAST, TE_GUNSHOT);
+ }
+ else if (p.classtype == CT_PROJECTILE_BULLET)
+ {
+ WriteByte (MSG_BROADCAST, TE_GUNSHOT);
+ }
+ else if (p.classtype == CT_PROJECTILE_WIZARDMISSILE)
+ {
+ WriteByte (MSG_BROADCAST, TE_WIZSPIKE);
+ }
+ else if (p.classtype == CT_PROJECTILE_HKNIGHT)
+ {
+ WriteByte (MSG_BROADCAST, TE_KNIGHTSPIKE);
+ }
+ else
+ {
+ WriteByte (MSG_BROADCAST, TE_SPIKE);
+ }
+ WriteCoord (MSG_BROADCAST, p.origin_x);
+ WriteCoord (MSG_BROADCAST, p.origin_y);
+ WriteCoord (MSG_BROADCAST, p.origin_z);
+ };
+
+ //--------------------------------------------------------------
+ void() base_projectile_homing_think =
+ {
+ local vector dir, vtemp;
+ vtemp = self.enemy.origin + '0 0 10';
+
+ if (self.enemy.health < 1)
+ {
+ remove (self);
+ return;
+ }
+
+ dir = normalize (vtemp - self.origin);
+ // can't do better than 100% homing
+ if (self.homing < 1 && self.homing > 0)
+ {
+ // This finds a vector somewhere between the vector
+ // the projectile is currently travelling on and
+ // the vector that it would normally snap to for
+ // homing
+ //
+ // homing = .25 means it will go 25% to the new
+ // direction, but keep 75% of the original vector,
+ // resulting in a wider turning range.
+ dir = normalize((dir * self.homing) +
+ normalize(self.velocity * (1 - self.homing)));
+ }
+
+ if (!self.avelocity)
+ self.angles = vectoangles (dir);
+
+ // SetSpeed
+ self.velocity = dir * min (self.proj_basespeed,
+ world_maxvelocity);
+
+ if (self.homing > 0)
+ {
+ if (self.homing < 1 && self.attack_finished &&
+ self.attack_finished < time)
+ {
+ // dprint("incrementing homing | ");
+ // dprint("old: ");
+ // dprint(ftos(self.homing));
+ // dprint(" | new: ");
+ self.homing = self.homing + 0.005;
+ // dprint(ftos(self.homing));
+ // dprint("\n");
+ }
+
+ self.nextthink = time + 0.2;
+ self.think = base_projectile_homing_think;
+ }
+ };
+
+ //--------------------------------------------------------------
+ void(entity mis, float speed) base_projectile_setup_homing =
+ {
+ local vector dir;
+ local float dist, flytime, speedmod;
+
+ if (!mis.owner)
+ {
+ objerror (sprintf("base_projectile_setup_homing: "
+ "%s has no owner!\n", mis.classname));
+ return;
+ }
+
+ if (!mis.enemy)
+ {
+ objerror (sprintf("base_projectile_setup_homing: "
+ "%s has no enemy!\n", mis.classname));
+ return;
+ }
+
+ if (mis.owner.proj_speed_mod > 1)
+ speedmod = 1 / mis.owner.proj_speed_mod;
+ else if (speed > 250)
+ speedmod = 1 / (speed / 250);
+ else
+ speedmod = 1;
+
+ dir = normalize ((mis.enemy.origin + '0 0 10') - mis.origin);
+ dist = vlen (mis.enemy.origin - mis.origin);
+ flytime = dist * 0.002 * speedmod;
+ if (flytime < 0.1)
+ flytime = 0.1;
+
+ mis.proj_basespeed = speed;
+ mis.homing = mis.owner.homing;
+ mis.think = base_projectile_homing_think;
+ mis.nextthink = flytime + time;
+ if (mis.owner.waitmin > 0)
+ // store time to start increasing
+ mis.attack_finished = time + mis.owner.waitmin;
+ };
+
+ //==============================================================
+ // Interaction
+ //==============================================================
+
+ //--------------------------------------------------------------
+ // was T_MissileTouch -- CEV
+ //--------------------------------------------------------------
+ void() base_projectile_touch_explosive =
+ {
+ // standard id1 behavior is to add 1-20 on a direct hit.
+ // I've removed that here. -- CEV
+ // damg = direct_damage + random() * 20;
+
+ if (other.health)
+ {
+ // TODO CEV
+ if (other.classname == "monster_shambler")
+ // mostly immune
+ t_damage2 (other, self, self.owner,
+ self.direct_damage * 0.5);
+ else
+ t_damage2 (other, self, self.owner,
+ self.direct_damage);
+ }
+
+ // do before radius damage -- CEV
+ if (self.takedamage)
+ self.takedamage = DAMAGE_NO;
+
+ // don't do radius damage to the other, because all the damage
+ // was done in the impact
+ t_radiusdamage2 (self, self.owner, self.splash_damage, other);
+
+ // sound (self, CHAN_WEAPON, "weapons/r_exp3.wav",
+ // 1, ATTN_NORM);
+ self.origin = self.origin - 8 * normalize (self.velocity);
+
+ // BecomeExplosion
+ write_explosion (self.origin);
+ spawn_base_explosion (self.origin);
+ remove (self);
+ };
+
+ //--------------------------------------------------------------
+ // was spike_touch; override if you need to implement special
+ // projectile damage logic -- CEV
+ //--------------------------------------------------------------
+ void() base_projectile_touch_normal =
+ {
+ // hit something that bleeds
+ if (other.takedamage)
+ {
+ spawn_touchblood (self.direct_damage);
+ t_damage2 (other, self, self.owner, self.direct_damage);
+ }
+ else
+ {
+ write_projectile_impact (self);
+ }
+
+ remove (self);
+ };
+
+
+ //--------------------------------------------------------------
+ // returns TRUE if the touch function shouldn't continue
+ //--------------------------------------------------------------
+ float() base_projectile_check_touch =
+ {
+ // don't damage or touch owner -- CEV
+ if (other == self.owner)
+ return TRUE;
+
+ // remove any projectile that hits the sky -- CEV
+ if (pointcontents(self.origin) == CONTENT_SKY)
+ {
+ remove (self);
+ return TRUE;
+ }
+
+ if (other.solid == SOLID_TRIGGER)
+ // trigger field, do nothing
+ return TRUE;
+
+ return FALSE;
+ };
+
+ //--------------------------------------------------------------
+ void() base_projectile_touch =
+ {
+ if (base_projectile_check_touch())
+ return;
+
+ if (self.aflag & PROJECTILE_EXPLOSIVE)
+ base_projectile_touch_explosive ();
+ else
+ base_projectile_touch_normal ();
+ };
+
+ //==============================================================
+ // Initialization
+ //==============================================================
+
+ //--------------------------------------------------------------
+ void(entity e) base_projectile_init =
+ {
+ base_tempentity_init (e);
+
+ e.classgroup |= CG_PROJECTILE;
+
+ // default value for proj_speed_mod is 1 -- CEV
+ if (!e.proj_speed_mod)
+ e.proj_speed_mod = 1;
+
+ e.touch = base_projectile_touch;
+ };
+
+ //--------------------------------------------------------------
+ strip void() base_projectile =
+ {
+ base_projectile_init (self);
+ };
+// };
+
+//----------------------------------------------------------------------
+// Custom Physics for projectiles. Subclass this if you want a projectile
+// to have one size for other objects to collide with but another size
+// when moving through the world. Useful for creating shootable grenades
+// and missiles. This is slower than engine physics so use sparingly. -- CEV
+//----------------------------------------------------------------------
+// class base_projectile_qcphys: base_projectile
+// {
+ //--------------------------------------------------------------
+ // This is a vague imitation of SV_Physics_Toss as found in
+ // Ironwail but with an alternate mins and maxs when testing
+ // movement -- CEV
+ //--------------------------------------------------------------
+ void() base_projectile_qcphys_physics =
+ {
+ if (self.think && self.nextthink > 0.0f)
+ {
+ if (self.nextthink < time)
+ {
+ self.nextthink = 0.0f;
+ self.think ();
+ }
+ }
+
+ // were we removed by think?
+ if (!self)
+ return;
+
+ // are we onground?
+ if (self.flags & FL_ONGROUND)
+ return;
+
+ // move angles
+ if (self.avelocity)
+ self.angles += self.avelocity * frametime;
+
+ // apply gravity if desired
+ if (self.movetype == MOVETYPE_BOUNCE)
+ {
+ local float grav = self.gravity ? self.gravity : 1.0;
+ self.velocity_z -= grav * world_gravity * frametime;
+ }
+
+ // test the move with an alternate mins and maxs (pos1 and
+ // pos2) and suitable flags for FLYMISSILE if set -- CEV
+ tracebox (self.origin, self.pos1, self.pos2,
+ self.origin + (self.velocity * frametime),
+ self.movetype == MOVETYPE_FLYMISSILE ?
+ MOVE_MISSILE: FALSE,
+ self);
+
+ if (trace_allsolid || trace_startsolid)
+ {
+ dprint (sprintf("base_projectile_qcphys_physics: "
+ "in a solid at %v\n", trace_endpos));
+
+ if (self.movetype == MOVETYPE_BOUNCE)
+ {
+ // TODO CEV figure out what to do here
+ return;
+ }
+ else
+ {
+ // in the world so just explode
+ local entity oldother2 = other;
+ other = world;
+ self.touch ();
+ other = oldother2;
+ return;
+ }
+ }
+
+ // clear to accept the move
+ setorigin (self, trace_endpos);
+
+ if (trace_fraction >= 1.0f)
+ {
+ // didn't hit anything; touch triggers and exit
+ touchtriggers ();
+ return;
+ }
+
+ // immediate clipvelocity for MOVETYPE_BOUNCE -- CEV
+ if (self.movetype == MOVETYPE_BOUNCE)
+ {
+ self.velocity -= trace_plane_normal *
+ ((self.velocity * trace_plane_normal) *
+ BP_BOUNCE_BACKOFF);
+
+ // set ONGROUND while we're at it -- CEV
+ if (trace_plane_normal_z > 0.7)
+ {
+ if (self.velocity_z < BP_BOUNCE_MIN_ZVEL)
+ {
+ self.flags |= FL_ONGROUND;
+ self.groundentity = trace_ent;
+ self.groundnormal = trace_plane_normal;
+ self.velocity = '0 0 0';
+ self.avelocity = '0 0 0';
+ }
+ }
+ }
+
+ // SV_Impact lookalike -- CEV
+ local entity oldother = other;
+ if (trace_ent)
+ {
+ // we can make some assumptions and skip a few
+ // checks here -- CEV
+ if (trace_ent)
+ other = trace_ent;
+ else
+ other = world;
+ self.touch ();
+
+ // check trace_ent again just in case the call
+ // to touch above somehow removed it -- CEV
+ if (trace_ent && trace_ent.touch &&
+ trace_ent.solid != SOLID_NOT)
+ {
+ if (self)
+ other = self;
+ else
+ other = world;
+
+ local entity stemp = self;
+ self = trace_ent;
+ self.touch ();
+ self = stemp;
+ }
+ }
+ else if (trace_fraction < 1.0f)
+ {
+ // for the bounce sound
+ other = world;
+ self.touch ();
+ }
+ other = oldother;
+
+ // be sure to touch triggers! -- CEV
+ touchtriggers ();
+ };
+
+ //--------------------------------------------------------------
+ void(entity e) base_projectile_qcphys_init =
+ {
+ base_projectile_init (e);
+
+ if (!e.pos1)
+ e.pos1 = '-1 -1 -1';
+ if (!e.pos2)
+ e.pos2 = '1 1 1';
+
+ e.customphysics = base_projectile_qcphys_physics;
+ };
+
+ //--------------------------------------------------------------
+ strip void() base_projectile_qcphys =
+ {
+ base_projectile_qcphys_init (self);
+ };
+// };

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

Diff qc/base_projectile.qc

diff --git a/qc/base_projectile.qc b/qc/base_projectile.qc
deleted file mode 100644
index 384cf51..0000000
--- a/qc/base_projectile.qc
+++ /dev/null
@@ -1,501 +0,0 @@
-//==============================================================================
-// base_projectile.qc -- generated projectile entities
-//==============================================================================
-
-/*
-Projectile init checklist, required & optional settings, in suggested
-order, for reference when writing a projectile constructor function
-
-1. classtype & classname (required)
-2. movetype & solid (required)
-3. set explosive if necessary (parse_projexpl)
-4. set health and takedamage if desired (for explosives)
-5. angles (required) & avelocity
-6. check (and set if necessary) proj_basespeed
-7. check (and set if necessary) direct_damage and splash_damage
-8. setmodel and skin (required)
-9. setup_homing
-10. setsize, setorigin (required)
-11. think & nextthink (if not capable of homing)
-
-see the files in projectiles/ for examples -- CEV
-*/
-
-//======================================================================
-// Constants
-//======================================================================
-
-enum
-{
- EXPLOSION_THINK_1, // explosion frame/think tracking
- EXPLOSION_THINK_2,
- EXPLOSION_THINK_3,
- EXPLOSION_THINK_4,
- EXPLOSION_THINK_5,
- EXPLOSION_THINK_6,
- EXPLOSION_THINK_REMOVE
-};
-
-const float BOUNCE_BACKOFF = 1.5; // MOVETYPE_BOUNCE clipvel mult; id1 1.5
-const float BOUNCE_MIN_ZVEL = 60; // MOVETYPE_BOUNCE stop if _z less than
-
-//------------------------------------------------------------------------------
-// standard id1 explosion sprite + a few helper functions -- CEV
-//------------------------------------------------------------------------------
-class base_explosion: base_tempentity
-{
- float explosion_think_state;
-
- //--------------------------------------------------------------
- static void(vector org) write_explosion =
- {
- WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
- WriteByte (MSG_BROADCAST, TE_EXPLOSION);
- WriteCoord (MSG_BROADCAST, org_x);
- WriteCoord (MSG_BROADCAST, org_y);
- WriteCoord (MSG_BROADCAST, org_z);
- };
-
- //--------------------------------------------------------------
- static void(vector org) write_explosion2 =
- {
- WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
- WriteByte (MSG_BROADCAST, TE_EXPLOSION2);
- WriteCoord (MSG_BROADCAST, org_x);
- WriteCoord (MSG_BROADCAST, org_y);
- WriteCoord (MSG_BROADCAST, org_z);
- };
-
- //==============================================================
- // Interaction
- //==============================================================
-
- //--------------------------------------------------------------
- virtual void() think =
- {
- if (this.explosion_think_state == EXPLOSION_THINK_REMOVE)
- {
- remove (this);
- return;
- }
-
- if (this.explosion_think_state == EXPLOSION_THINK_1)
- this.frame = 0;
- else
- this.frame += 1;
-
- this.explosion_think_state += 1;
- this.nextthink = time + 0.1;
- };
-
- //--------------------------------------------------------------
- virtual void() touch =
- {
- // sub_null - no-op
- };
-
- //==============================================================
- // Initialization
- //==============================================================
-
- //--------------------------------------------------------------
- void() base_explosion =
- {
- this.classtype = CT_TEMP_EXPLOSION;
- this.movetype = MOVETYPE_NONE;
- this.solid = SOLID_NOT;
- if (this.origin == '0 0 0')
- dprint ("base_explosion: spawned at zero origin\n");
- setorigin (this, this.origin);
- this.velocity = '0 0 0';
- setmodel (this, "progs/s_explod.spr");
- this.explosion_think_state = EXPLOSION_THINK_1;
- this.think ();
- };
-};
-
-//------------------------------------------------------------------------------
-class base_projectile: base_tempentity
-{
- float explosive; // set TRUE if explosive projectile
- float direct_damage; // for t_damage
- float splash_damage; // for t_radiusdamage
-
- //--------------------------------------------------------------
- static float(float testexpl, float offset) parse_projexpl =
- {
- return testexpl == 1 ||
- (testexpl == 2 && offset % 2 == 0) ||
- (testexpl == 3 && random() * 2 < 1);
- };
-
- //--------------------------------------------------------------
- // I'm sure there's a better way to do this -- CEV
- //--------------------------------------------------------------
- static void(base_projectile p) write_projectile_impact =
- {
- WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
- if (p.snd_hit != __NULL__ && p.snd_hit != "")
- {
- // dumptruck_ds
- sound (p, CHAN_WEAPON, p.snd_hit, 1, ATTN_STATIC);
- WriteByte (MSG_BROADCAST, TE_GUNSHOT);
- }
- else if (p.classtype == CT_PROJECTILE_BULLET)
- {
- WriteByte (MSG_BROADCAST, TE_GUNSHOT);
- }
- else if (p.classtype == CT_PROJECTILE_WIZARDMISSILE)
- {
- WriteByte (MSG_BROADCAST, TE_WIZSPIKE);
- }
- else if (p.classtype == CT_PROJECTILE_HKNIGHT)
- {
- WriteByte (MSG_BROADCAST, TE_KNIGHTSPIKE);
- }
- else
- {
- WriteByte (MSG_BROADCAST, TE_SPIKE);
- }
- WriteCoord (MSG_BROADCAST, p.origin_x);
- WriteCoord (MSG_BROADCAST, p.origin_y);
- WriteCoord (MSG_BROADCAST, p.origin_z);
- };
-
- //--------------------------------------------------------------
- nonvirtual void() think_homing =
- {
- local vector dir, vtemp;
- vtemp = this.enemy.origin + '0 0 10';
-
- if (this.enemy.health < 1)
- {
- remove (this);
- return;
- }
-
- dir = normalize (vtemp - this.origin);
- // can't do better than 100% homing
- if (this.homing < 1 && this.homing > 0)
- {
- // This finds a vector somewhere between the vector
- // the projectile is currently travelling on and
- // the vector that it would normally snap to for
- // homing
- //
- // homing = .25 means it will go 25% to the new
- // direction, but keep 75% of the original vector,
- // resulting in a wider turning range.
- dir = normalize((dir * this.homing) +
- normalize(this.velocity * (1 - this.homing)));
- }
-
- if (!this.avelocity)
- this.angles = vectoangles (dir);
-
- // SetSpeed
- this.velocity = dir * min (proj_basespeed, frame_maxvelocity);
-
- if (this.homing > 0)
- {
- if (this.homing < 1 && this.attack_finished &&
- this.attack_finished < time)
- {
- // dprint("incrementing homing | ");
- // dprint("old: ");
- // dprint(ftos(this.homing));
- // dprint(" | new: ");
- this.homing = this.homing + 0.005;
- // dprint(ftos(this.homing));
- // dprint("\n");
- }
-
- this.nextthink = time + 0.2;
- this.think = think_homing;
- }
- };
-
- //--------------------------------------------------------------
- nonvirtual void(float speed) setup_homing =
- {
- local vector dir;
- local float dist, flytime, speedmod;
-
- if (this.proj_speed_mod > 1)
- speedmod = 1 / this.proj_speed_mod;
- else if (speed > 250)
- speedmod = 1 / (speed / 250);
- else
- speedmod = 1;
-
- dir = normalize ((this.enemy.origin + '0 0 10') - this.origin);
- dist = vlen (this.enemy.origin - this.origin);
- flytime = dist * 0.002 * speedmod;
- if (flytime < 0.1)
- flytime = 0.1;
-
- this.proj_basespeed = speed;
- this.think = think_homing;
- this.nextthink = flytime + time;
- if (this.waitmin > 0)
- // store time to start increasing
- this.attack_finished = time + this.waitmin;
- };
-
- //==============================================================
- // Interaction
- //==============================================================
-
- //--------------------------------------------------------------
- // was T_MissileTouch -- CEV
- //--------------------------------------------------------------
- virtual void(entity toucher) do_touch_explosive =
- {
- // standard id1 behavior is to add 1-20 on a direct hit.
- // I've removed that here. -- CEV
- // damg = direct_damage + random() * 20;
-
- if (toucher.health)
- {
- // TODO CEV
- if (toucher.classname == "monster_shambler")
- // mostly immune
- t_damage2 (toucher, this, this.owner,
- direct_damage * 0.5);
- else
- t_damage2 (toucher, this, this.owner,
- direct_damage);
- }
-
- // do before radius damage -- CEV
- if (this.takedamage)
- this.takedamage = DAMAGE_NO;
-
- // don't do radius damage to the other, because all the damage
- // was done in the impact
- t_radiusdamage2 (this, this.owner, splash_damage, toucher);
-
- // sound (this, CHAN_WEAPON, "weapons/r_exp3.wav",
- // 1, ATTN_NORM);
- this.origin = this.origin - 8 * normalize (this.velocity);
-
- // BecomeExplosion
- base_explosion::write_explosion (this.origin);
- spawn (base_explosion, origin: this.origin);
- remove (this);
- };
-
- //--------------------------------------------------------------
- // was spike_touch; override if you need to implement special
- // projectile damage logic -- CEV
- //--------------------------------------------------------------
- virtual void(entity toucher) do_touch =
- {
- // hit something that bleeds
- if (other.takedamage)
- {
- spawn_touchblood (direct_damage);
- t_damage2 (toucher, this, this.owner, direct_damage);
- }
- else
- {
- base_projectile::write_projectile_impact (this);
- }
-
- remove (this);
- };
-
- //--------------------------------------------------------------
- virtual void() touch =
- {
- // duplicated functionality from base_entity -- CEV
- if (this.interaction_flags & DISABLE_TOUCH)
- return;
-
- // don't damage or touch owner -- CEV
- if (other == this.owner)
- return;
-
- // remove any projectile that hits the sky -- CEV
- if (pointcontents(this.origin) == CONTENT_SKY)
- {
- remove (this);
- return;
- }
-
- if (other.solid == SOLID_TRIGGER)
- // trigger field, do nothing
- return;
-
- if (this.explosive)
- do_touch_explosive (other);
- else
- do_touch (other);
- };
-
- //==============================================================
- // Initialization
- //==============================================================
-
- //--------------------------------------------------------------
- void() base_projectile =
- {
- this.classgroup |= CG_PROJECTILE;
-
- // default value for proj_speed_mod is 1 -- CEV
- if (!this.proj_speed_mod)
- this.proj_speed_mod = 1;
- };
-};
-
-//------------------------------------------------------------------------------
-// Custom Physics for projectiles. Subclass this if you want a projectile
-// to have a fixed size for other objects to collide with but zero size
-// when moving through the world. Useful for creating shootable grenades
-// and missiles. This is slower than engine physics so use sparingly. -- CEV
-//------------------------------------------------------------------------------
-class base_projectile_qcphys: base_projectile
-{
- vector movement_mins;
- vector movement_maxs;
-
- //--------------------------------------------------------------
- // This is a vague imitation of SV_Physics_Toss as found in
- // Ironwail but with an alternate mins and maxs when testing
- // movement -- CEV
- //--------------------------------------------------------------
- virtual void() customphysics =
- {
- if (this.think && this.nextthink > 0.0f)
- {
- if (this.nextthink < time)
- {
- this.nextthink = 0.0f;
- this.think ();
- }
- }
-
- // were we removed by think?
- if (!this)
- return;
-
- // are we onground?
- if (this.flags & FL_ONGROUND)
- return;
-
- // move angles
- if (this.avelocity)
- this.angles += this.avelocity * frametime;
-
- // apply gravity if desired
- if (this.movetype == MOVETYPE_BOUNCE)
- {
- local float grav = this.gravity ? this.gravity : 1.0;
- this.velocity_z -= grav * frame_gravity * frametime;
- }
-
- // test the move with an alternate mins and maxs and
- // suitable flags for FLYMISSILE if set -- CEV
- tracebox (this.origin, movement_mins, movement_maxs,
- this.origin + (this.velocity * frametime),
- movetype == MOVETYPE_FLYMISSILE ? MOVE_MISSILE: FALSE,
- this);
-
- if (trace_allsolid || trace_startsolid)
- {
- dprint (sprintf("base_projectile_qcphys::custom"
- "physics: in a solid at %v\n", trace_endpos));
-
- if (this.movetype == MOVETYPE_BOUNCE)
- {
- // TODO CEV figure out what to do here
- return;
- }
- else
- {
- // in the world, so just explode
- local entity oldother2 = other;
- other = world;
- this.touch ();
- other = oldother2;
- return;
- }
- }
-
- // clear to accept the move
- setorigin (this, trace_endpos);
-
- if (trace_fraction >= 1.0f)
- {
- // didn't hit anything; touch triggers and exit
- touchtriggers ();
- return;
- }
-
- // immediate clipvelocity for MOVETYPE_BOUNCE -- CEV
- if (this.movetype == MOVETYPE_BOUNCE)
- {
- this.velocity -= trace_plane_normal *
- ((this.velocity * trace_plane_normal) *
- BOUNCE_BACKOFF);
-
- // set ONGROUND while we're at it -- CEV
- if (trace_plane_normal_z > 0.7)
- {
- if (this.velocity_z < BOUNCE_MIN_ZVEL)
- {
- this.flags |= FL_ONGROUND;
- this.groundentity = trace_ent;
- this.groundnormal = trace_plane_normal;
- this.velocity = '0 0 0';
- this.avelocity = '0 0 0';
- }
- }
- }
-
- // SV_Impact lookalike -- CEV
- local entity oldother = other;
- if (trace_ent)
- {
- // we can make some assumptions and skip a few
- // checks here -- CEV
- if (trace_ent)
- other = trace_ent;
- else
- other = world;
- this.touch ();
-
- // check trace_ent again just in case the call
- // to touch above somehow removed it -- CEV
- if (trace_ent && trace_ent.touch &&
- trace_ent.solid != SOLID_NOT)
- {
- if (this)
- other = this;
- else
- other = world;
-
- // check classgroup before cast -- CEV
- if (trace_ent.classgroup & CG_ENTITY)
- ((base_entity)trace_ent).touch ();
- }
- }
- else if (trace_fraction < 1.0f)
- {
- // for the bounce sound
- other = world;
- this.touch ();
- }
- other = oldother;
-
- // be sure to touch triggers! -- CEV
- touchtriggers ();
- };
-
- //--------------------------------------------------------------
- void() base_projectile_qcphys =
- {
- this.movement_mins = '-1 -1 -1';
- this.movement_maxs = '1 1 1';
- };
-};

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

Diff qc/base_trigger.qc

diff --git a/qc/base_trigger.qc b/qc/base_trigger.qc
index 774440f..8196d5e 100644
--- a/qc/base_trigger.qc
+++ b/qc/base_trigger.qc
@@ -2,77 +2,54 @@
// base_trigger.qc -- trigger base class
//==============================================================================

-//------------------------------------------------------------------------------
-class base_trigger: base_mapentity
-{
- //==============================================================
- // class fields
- //==============================================================
- float aflag;
- float count;
+//======================================================================
+// forward declarations
+//======================================================================

- // Supa, triggers, wait until activated before we can trigger?
- float is_waiting;
- float endwaiting;
+void(entity e) sub_checkwaiting;
+void() sub_endwaiting;
+void(entity e) base_trigger_point_init;
+void(entity e) base_trigger_init;
+strip void() base_trigger;

- //--------------------------------------------------------------
- virtual void(string fieldname, string fieldvalue) init_field =
- {
- switch (fieldname)
- {
- case "count":
- count = stof (fieldvalue);
- break;
- case "is_waiting":
- is_waiting = stof (fieldvalue);
- break;
- default:
- super::init_field (fieldname, fieldvalue);
- }
- };
+//------------------------------------------------------------------------------

+//----------------------------------------------------------------------
+// class base_trigger: base_mapentity
+// {
//==============================================================
// Subs
//==============================================================

//--------------------------------------------------------------
- nonvirtual void() sub_checkwaiting =
+ void(entity e) sub_checkwaiting =
{
- if (this.is_waiting <= 0)
+ if (e.is_waiting <= 0)
return;

- this.estate = STATE_INACTIVE;
- this.endwaiting = TRUE;
+ // store current use to swap later
+ e.olduse = e.use;
+ e.use = sub_endwaiting;
+ e.estate = STATE_INACTIVE;

- dprint (sprintf("base_mapentity::sub_checkwaiting: spawned "
- "a waiting %s with targetname %s and target %s\n",
- this.classname, this.targetname, this.target));
+ dprint (sprintf("sub_checkwaiting: spawned a waiting %s "
+ "with targetname %s and target %s\n",
+ e.classname, e.targetname, e.target));
};

- static void(base_trigger bt) sub_endwaiting =
+ //--------------------------------------------------------------
+ void() sub_endwaiting =
{
- bt.endwaiting = FALSE;
- bt.is_waiting = FALSE;
- bt.estate = STATE_ACTIVE;
+ self.is_waiting = FALSE;
+ self.estate = STATE_ACTIVE;
+
+ if (self.use == sub_endwaiting)
+ self.use = self.olduse;

// special case for teleports, makes it ignore the
// fact that it has a targetname when touched
- if (bt.classtype == CT_TRIGGER_TELEPORT)
- bt.is_waiting = -1;
- };
-
- //--------------------------------------------------------------
- virtual void() use =
- {
- // SUB_EndWaiting -- CEV
- if (this.is_waiting == TRUE && this.endwaiting == TRUE)
- {
- sub_endwaiting (this);
- }
- else
- {
- super::use ();
- }
+ if (self.classtype == CT_TRIGGER_TELEPORT)
+ self.is_waiting = -1;
};

//==============================================================
@@ -80,48 +57,51 @@ class base_trigger: base_mapentity
//==============================================================

//--------------------------------------------------------------
- // InitTrigger
+ // InitPointTrigger -- Drake -- dumptruck_ds
+ // PM: The point trigger version of InitTrigger.
//--------------------------------------------------------------
- nonvirtual void() init_trigger =
+ void(entity e) base_trigger_point_init =
{
- // 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 (this.angles != '0 0 0')
- sub_setmovedir ();
+ local vector v1, v2;

- this.solid = SOLID_TRIGGER;
- // set size and link into world
- setmodel (this, this.model);
- this.movetype = MOVETYPE_NONE;
- this.modelindex = 0;
- this.model = "";
+ v1 = e.origin;
+ v2 = v1 + e.mangle;
+ e.model = "";
+ setorigin (e, '0 0 0');
+
+ // Calls 'setmodel', so do first.
+ base_trigger_init (e);
+
+ // Calling 'setmodel' resets entity size.
+ setsize (e, v1, v2);
};

//--------------------------------------------------------------
- // InitPointTrigger -- Drake -- dumptruck_ds
- // PM: The point trigger version of InitTrigger.
+ // InitTrigger
//--------------------------------------------------------------
- nonvirtual void() init_point_trigger =
+ void(entity e) base_trigger_init =
{
- local vector v1, v2;
+ base_mapentity_init (e);

- v1 = this.origin;
- v2 = v1 + this.mangle;
- this.model = "";
- setorigin (this, '0 0 0');
+ e.classgroup |= CG_TRIGGER;

- // Calls 'setmodel', so do first.
- init_trigger ();
+ // 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 (e.angles != '0 0 0')
+ sub_setmovedir (e);

- // Calling 'setmodel' resets entity size.
- setsize (this, v1, v2);
+ e.solid = SOLID_TRIGGER;
+ // set size and link into world
+ setmodel (e, e.model);
+ e.movetype = MOVETYPE_NONE;
+ e.modelindex = 0;
+ e.model = "";
};

//--------------------------------------------------------------
- void() base_trigger =
+ strip void() base_trigger =
{
- this.classgroup |= CG_TRIGGER;
- this.endwaiting = FALSE;
+ base_trigger_init (self);
};
-};
+// };

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

Diff qc/cl_entry.qc

diff --git a/qc/cl_entry.qc b/qc/cl_entry.qc
new file mode 100644
index 0000000..361f7af
--- /dev/null
+++ b/qc/cl_entry.qc
@@ -0,0 +1,487 @@
+//==============================================================================
+// CSQC entrypoints
+//==============================================================================
+
+//======================================================================
+// globals
+//======================================================================
+
+#ifdef CSQC
+float nocsqc; // CSQC State (0=on, 1=off)
+float sitems; // CSQC copy of .items
+float sitems2; // CSQC copy of .items2 (or serverflags)
+float sweapon; // CSQC copy of .weapon
+float shealth; // CSQC copy of .health
+
+float painfinishtime; // Track player damage for hud face
+
+float intermission; // in intermission
+float intermission_time; // when the intermission started
+
+float numclientseats; // coop or splitscreen?
+float maxclients; // max players possible on this server
+float cltime; // inc. regardless of pause or gamespeed
+
+// float player_localnum; // Player slot that is assigned to us
+float player_localentnum; // Ent number that csqc is attached to
+
+float sb_showscores; // Show lower tab scores
+
+// This is the input-frame sequence. frames < clientcommandframe have been
+// sent to the server. frame==clientcommandframe is still being generated
+// and can still change.
+float clientcommandframe;
+// This is the input-frame that was last acknowledged by the server.
+// Input frames greater than this should be applied to the player's entity.
+float servercommandframe;
+
+string CSQC_PING = "csqcping"; // Test command to check if CSCQ alive
+
+entity viewentity; // camera -- CEV
+vector view_origin; // origin for viewentity -- CEV
+vector view_angles; // +x=DOWN
+
+entity player_local; // handle to the local player entity
+
+vector player_org; // prediction -- from CSQCTest -- CEV
+vector player_vel;
+float player_flags;
+float player_doublejump_timer;
+float player_pmove_flags;
+float player_sequence;
+float player_step;
+float player_steptime;
+float player_step_oldz;
+vector pmove_error;
+float pmove_errortime;
+float pmove_frame;
+#endif
+
+//======================================================================
+// fields
+//======================================================================
+
+#ifdef CSQC
+.float drawmask; // a filter in the addentities call
+.float entnum; // The entnum as its known on the server
+.float ext_csqc; // Client Server Quake C HUD alive!
+.float renderflags;
+
+// The current frame the entity is meant to be displayed in. In CSQC,
+// note the lerpfrac and frame2 fields as well. if it specifies a
+// framegroup, the framegroup will autoanimate in ssqc, but not in csqc.
+// .float frame; // already defined in entvars_t -- CEV
+.float frame1time; // absolute time into anim/framegroup
+.float frame2; // alt frame visible when lerpfrac is 1
+.float frame2time; // absolute time into anim/group frame2
+.float oldframe;
+.float lerpfrac; // if 0 use frame1, if 1 use frame2,
+.float lerptime; // mix together for values between
+
+.string oldskin;
+
+// Called by addentities after the filter and before the entity is actually
+// drawn. Do your interpolation and animation in here. Should return one of
+// the PREDRAW_* constants.
+.float() predraw;
+
+.void() removefunc;
+#endif
+
+//======================================================================
+// forward declarations
+//======================================================================
+
+#ifdef CSQC
+float(string cmd) CSQC_ConsoleCommand;
+// float(float evtype, float scanx, float chary, float devid) CSQC_InputEvent;
+// float(float save, float take, vector dir) CSQC_Parse_Damage;
+void(string printmsg, float printlvl) CSQC_Parse_Print;
+void(string str) SV_ParseClientCommand;
+void(entity ent) CSQC_DrawViewModel;
+void(float vwidth, float vheight, float notmenu) CSQC_UpdateView;
+// float() CSQC_Parse_TempEntity;
+void(float isnew) CSQC_Ent_Update;
+void(float apilevel, string enginename, float engineversion) CSQC_Init;
+__wrap void(float apilevel, string enginename, float engineversion) CSQC_Init;
+__wrap float(string str) CSQC_ConsoleCommand;
+#endif
+
+//------------------------------------------------------------------------------
+
+#ifdef CSQC
+//----------------------------------------------------------------------
+// stubs for server-side entry functions (silences compiler warnings)
+//----------------------------------------------------------------------
+void() main = sub_null;
+void() StartFrame = sub_null;
+void() PlayerPreThink = sub_null;
+void() PlayerPostThink = sub_null;
+void() ClientKill = sub_null;
+void() ClientConnect = sub_null;
+void() PutClientInServer = sub_null;
+void() ClientDisconnect = sub_null;
+void() SetNewParms = sub_null;
+void() SetChangeParms = sub_null;
+#endif
+
+#ifdef CSQC
+//----------------------------------------------------------------------
+// Stubs for extra CSQC functions (not all supported)
+//----------------------------------------------------------------------
+
+// Can query or check anything types on the console here
+float(string cmd) CSQC_ConsoleCommand =
+{
+ tokenize_console (cmd);
+ return FALSE;
+};
+
+// Can query/check keyboard/mouse/joystick input with this function
+// For key events, scanx is one of the KEY_* values
+// chary is the character code (chr2str to shove it into a string)
+// For mouse events then x+y are the mouse delta/position values
+/*
+float(float evtype, float scanx, float chary, float devid) CSQC_InputEvent =
+{
+ return FALSE;
+};
+*/
+
+// This is linked to client dmg_take / dmg_save / dmg_inflictor fields
+// returning TRUE will block the red flash damage stuff
+/*
+float(float save, float take, vector dir) CSQC_Parse_Damage =
+{
+ painfinishtime = time + 0.2;
+ return FALSE;
+};
+*/
+
+// Can query/check server MSG events
+// CSQC_Parse_Event is called when the client sees a
+// #define svcfte_cgamepacket (83) message from the server
+// Not supported for DP, is called from only QSS/FTE
+// void() CSQC_Parse_Event = { };
+
+// Can intercept printed messages from the server (top of screen)
+// printlvl (text filtering) 0=low, 1=medium, 2=high, 3=chat
+// con_notifytime = amount of time the text remains on screen
+// ONLY define this function, if doing something with the text!!
+void(string printmsg, float printlvl) CSQC_Parse_Print =
+{
+ print (printmsg);
+};
+
+// Running on the Server side of CSQC listening for commands back
+// This is never called on the client side of the progs
+void(string str) SV_ParseClientCommand =
+{
+ local string ostr, cmd;
+ // Save command string for later
+ ostr = str;
+ // Search for tokens in string
+ tokenize_console (str);
+ // Find the first argument of the command
+ cmd = argv (0);
+ // Is this my (AD CSQC) command?
+ if (cmd == CSQC_PING)
+ self.ext_csqc = TRUE;
+ else
+ // Pass through original command
+ clientcommand (self, ostr);
+};
+
+//----------------------------------------------------------------------
+// TODO CEV
+//----------------------------------------------------------------------
+void(entity ent) CSQC_DrawViewModel =
+{
+ float newframe, newmodel;
+
+ newframe = getstatf (STAT_WEAPONFRAME);
+ newmodel = getstatf (STAT_WEAPONMODELI);
+
+ if (newmodel != ent.modelindex)
+ {
+ // changed entirely
+ ent.modelindex = newmodel;
+ ent.frame2 = ent.frame = newframe;
+ ent.lerptime = time;
+ }
+ else if (newframe != ent.frame)
+ {
+ ent.frame2 = ent.frame;
+ ent.frame = newframe;
+ ent.lerptime = time;
+ }
+
+ ent.lerpfrac = 1 - (time - ent.lerptime) * 10;
+
+ ent.origin = '0 0 0';
+ ent.angles = '0 0 0';
+ ent.effects = player_local.effects;
+
+ addentity (ent);
+};
+
+//----------------------------------------------------------------------
+void(float vwidth, float vheight, float notmenu) CSQC_UpdateView =
+{
+ local vector ssize;
+
+ ssize_x = vwidth;
+ ssize_y = vheight;
+ ssize_z = 0;
+
+ // Is the CSQC functionality enabled/disabled?
+ nocsqc = cvar ("cl_nocsqc");
+
+ clearscene ();
+
+ // TODO CEV
+ // addentities (MASK_ENGINE|MASK_VIEWMODEL);
+ // addentities (MASK_NORMAL | MASK_ENGINE);
+ setproperty (VF_DRAWWORLD, (float)1);
+ setproperty (VF_MIN, '0 0');
+ setproperty (VF_SIZE, ssize);
+
+ // If hud is disabled, draw engine hud instead
+ setproperty (VF_DRAWENGINESBAR, nocsqc);
+ setproperty (VF_DRAWCROSSHAIR, TRUE);
+
+ // TODO CEV
+ if (self.entnum == player_localentnum)
+ {
+ // read our smoothed & predicted view origin
+ setproperty (VF_VIEWENTITY, viewentity.entnum);
+ setproperty (VF_ORIGIN, viewentity.origin);
+ setproperty (VF_ANGLES, viewentity.angles);
+ setproperty (VF_CL_VIEWANGLES, view_angles);
+
+ makevectors (viewentity.angles);
+ SetListener (view_origin, v_forward, v_right, v_up);
+
+ if (intermission)
+ {
+ // don't draw crosshair in intermission
+ setproperty (VF_DRAWCROSSHAIR, FALSE);
+ }
+ else
+ {
+ // draw view model when not in intermission
+ CSQC_DrawViewModel (viewentity);
+ }
+
+ if (player_local.effects & EF_MUZZLEFLASH)
+ dprint ("CSQC_UpdateView: muzzleflash\n");
+
+ // setproperty (VF_VIEWENTITY, player_localentnum);
+ addentities (MASK_ENGINE | MASK_VIEWMODEL | MASK_NORMAL);
+ }
+ else
+ {
+ // engine didn't tell us about our player entity.
+ // that's not right...
+ dprint ("CSQC_UpdateView: no player_local\n");
+ addentities (MASK_ENGINE | MASK_VIEWMODEL | MASK_NORMAL);
+ }
+
+ renderscene ();
+
+ // Revert back to using engine HUD?
+ if (nocsqc > 0)
+ return;
+
+ // Used on intermission screen later
+ if (!intermission)
+ intermission_time = time;
+
+ // Read deathmatch variable and create csprogs coop variable
+ // csprogs has no knowledge of the coop variable
+ deathmatch = stof (serverkey("deathmatch"));
+ coop = !deathmatch && maxclients > 1;
+
+ // Draw the HUDs and scoreboards
+ CSQC_DrawHud (ssize, sb_showscores);
+ CSQC_DrawScores (ssize, sb_showscores);
+};
+
+/*
+//----------------------------------------------------------------------
+// Handle SVC_TEMPENTITY data from the server -- CEV
+//
+// Based on code by PrimalLove found at:
+// https://forums.insideqc.com/viewtopic.php?p=55772#p55772
+//----------------------------------------------------------------------
+float() CSQC_Parse_TempEntity =
+{
+ float teid, eid;
+ vector pos, end, vel;
+ entity e;
+
+ teid = ReadByte ();
+
+ switch (teid)
+ {
+ case 6:
+ eid = ReadEntityNum ();
+ pos_x = ReadCoord ();
+ pos_y = ReadCoord ();
+ pos_z = ReadCoord ();
+ end_x = ReadCoord ();
+ end_y = ReadCoord ();
+ end_z = ReadCoord ();
+
+ trailparticles (particleeffectnum("TE_LIGHTNING2"),
+ edict_num(eid), pos, end);
+
+ // pointparticles (
+ // particleeffectnum("TE_LIGHTNING2"),
+ // pos, end, 1);
+
+ // if (player_local && player_local.entnum == eid)
+ // te_lightning2 (player_local, pos, end);
+ // else
+ // return FALSE;
+
+ return TRUE;
+ default:
+ return FALSE;
+ }
+
+ return FALSE;
+};
+*/
+
+//----------------------------------------------------------------------
+// Handle incoming MSG_ENTITY data from the server -- CEV
+//----------------------------------------------------------------------
+void(float isnew) CSQC_Ent_Update =
+{
+ local float classtype;
+
+ classtype = ReadByte ();
+
+ switch (classtype)
+ {
+ case CT_PLAYER:
+ PlayerUpdate (isnew);
+ break;
+ case CT_TRIGGER_LADDER:
+ break;
+ }
+};
+
+//----------------------------------------------------------------------
+void() CSQC_WorldLoaded =
+{
+ world_latched_cvars ();
+};
+
+//----------------------------------------------------------------------
+// Registers HUD gfx images (all setup in string arrays)
+//----------------------------------------------------------------------
+void(float apilevel, string enginename, float engineversion) CSQC_Init =
+{
+ local float i, wadonly;
+
+ // Is the CSQC functionality enabled/disabled?
+ nocsqc = cvar ("cl_nocsqc");
+ // Revert back to using engine HUD?
+ if (nocsqc > 0)
+ return;
+
+ // Send ping back to server that CSQC client is alive
+ // This can be used on the server side to detect CSQC
+ // and change functions for new features
+ localcmd (strcat("cmd ", CSQC_PING, "\n"));
+
+ // precache from gfx.wad ONLY!?!
+ wadonly = TRUE;
+
+ // Cache all string tables
+ for (i = 0; i < 14; i++)
+ {
+ // HUD background images (320 wide+)
+ if (i < backgrd.length)
+ precache_pic (backgrd[i], wadonly);
+ // Large 24x24 brown/red numbers
+ if (i < number.length)
+ {
+ precache_pic (number[i], wadonly);
+ precache_pic (anumber[i], wadonly);
+ }
+ // Large 24x24 extra font characters (intermission)
+ if (i < extrachar.length)
+ precache_pic (extrachar[i], wadonly);
+ // Large 24x24 player face
+ if (i < facetab.length)
+ precache_pic (facetab[i], wadonly);
+ // Large 24x24 icons
+ if (i < sbitems.length)
+ precache_pic (sbitems[i], wadonly);
+ // Small 16x16 icons
+ if (i < ibitems.length)
+ precache_pic (ibitems[i], wadonly);
+ // Special 8x16 runes
+ if (i < ibrunes.length)
+ precache_pic (ibrunes[i], wadonly);
+ // All weapon setups (on/off/flashing)
+ if (i < wpnnames.length)
+ {
+ precache_pic(strcat(wpnselect[0], wpnnames[i]),wadonly);
+ precache_pic(strcat(wpnselect[1], wpnnames[i]),wadonly);
+ precache_pic(strcat(wpnflash[0], wpnnames[i]), wadonly);
+ precache_pic(strcat(wpnflash[1], wpnnames[i]), wadonly);
+ precache_pic(strcat(wpnflash[2], wpnnames[i]), wadonly);
+ precache_pic(strcat(wpnflash[3], wpnnames[i]), wadonly);
+ precache_pic(strcat(wpnflash[4], wpnnames[i]), wadonly);
+ }
+ }
+
+ // TODO CEV
+ precache_model ("progs/player.mdl");
+
+ viewentity = spawn ();
+ viewentity.renderflags = RF_VIEWMODEL|RF_DEPTHHACK|RF_NOSHADOW;
+};
+
+//----------------------------------------------------------------------
+// Wrapper for CSQC_Init to try and detect DP engine
+//----------------------------------------------------------------------
+__wrap void(float apilevel, string enginename, float engineversion) CSQC_Init =
+{
+ // Execute previous CSQC_Init function
+ prior (apilevel, enginename, engineversion);
+
+ registercommand ("+showscores");
+ registercommand ("+showscores");
+ registercommand ("+showteamscores");
+ registercommand ("+showteamscores");
+};
+
+//----------------------------------------------------------------------
+// Wrapper for CSQC_ConsoleCommand to show different scoreboards
+//----------------------------------------------------------------------
+__wrap float(string str) CSQC_ConsoleCommand =
+{
+ if (prior(str))
+ return TRUE;
+
+ string c = argv(0);
+
+ if (c == "+showscores")
+ sb_showscores |= 1;
+ else if (c == "-showscores")
+ sb_showscores &~= 1;
+ else if (c == "+showteamscores")
+ sb_showscores |= 2;
+ else if (c == "-showteamscores")
+ sb_showscores &~= 2;
+ else
+ return FALSE;
+
+ return TRUE;
+};
+#endif

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

Diff qc/cl_hud.qc

diff --git a/qc/cl_hud.qc b/qc/cl_hud.qc
new file mode 100644
index 0000000..5a3023c
--- /dev/null
+++ b/qc/cl_hud.qc
@@ -0,0 +1,1033 @@
+//==============================================================================
+// CSQC_HUDVANILLA
+//==============================================================================
+
+/*======================================================================
+ All CSQC functions (Vanilla ONLY version)
+
+ * This file is heavily influenced by QSS devkit (credit=spike)
+ * re-written some functions to make better sense to me
+ * Contains all HUD elements for full quake interface (SP/Coop/Dm)
+ * Sripped out the experimental stuff included in devkit
+ * Converted most of the hardcoded values into constants
+ * Added loads of extra comments to show what is going on
+
+======================================================================*/
+
+//======================================================================
+// constants
+//======================================================================
+
+// Default sizes for HUD elements
+const vector HUDSIZE_320 = '320 24 0'; // Background images
+const vector HUDSIZE_24 = '24 24 0'; // Status Bar
+const vector HUDSIZE_16 = '16 16 0'; // Inventory/Powerups
+const vector HUDSIZE_816 = '8 16 0'; // Runes
+const vector HUDSIZE_8 = '8 8 0'; // Ammo numbers
+const vector HUDSIZE_C8 = '8 0 0'; // Character sizes
+
+// 8 pixel font table (index positions)
+const float HUDFONT_WHITE = 0; // Default index = 48-57
+const float HUDFONT_YELLOW = 1; // index = index - 30
+const float HUDFONT_RED = 2; // index = index + 128
+
+// Default sizes for weapons
+const vector HUDWPN_48 = '48 16 0'; // Vanilla LG
+const vector HUDWPN_32 = '32 16 0'; // AD/Hipnotic LG
+const vector HUDWPN_24 = '24 16 0'; // Default
+
+const vector HUDRGB_DEF = '1 1 1';
+
+//----------------------------------------------------------------------
+// All weapon HUD graphics are prefixed with certain characters which
+// means all weapon filenames can be generated with string commands
+// CSQC is really an advanced (QSS/FTE/DP) engine only thing and its
+// very likely that FTE_STRINGS is supported for string manipulation
+//----------------------------------------------------------------------
+// Special constants for weapons
+const float WPN_ICONS = 7; // weapons precache pics + flash timers
+const float WPN_WIDTHLG = 6; // Odd weapon gfx width (48)
+
+// Statue, Inventory and Score bars (All 320 x 24)
+const string backgrd[3] = { "gfx/sbar", "gfx/ibar", "gfx/scorebar" };
+
+// Ranking (168 x 24), Complete (184 x 24), Inter (160 x 144)
+// Require .lmp extensions if not loaded diectly from GFX file
+const string backlmp[3] =
+{
+ "gfx/ranking.lmp", "gfx/complete.lmp", "gfx/inter.lmp"
+};
+
+// Regular (24x24) brown numbers
+const string number[10] =
+{
+ "gfx/num_0", "gfx/num_1", "gfx/num_2", "gfx/num_3", "gfx/num_4",
+ "gfx/num_5", "gfx/num_6", "gfx/num_7", "gfx/num_8", "gfx/num_9"
+};
+
+// Red (24x24) numbers for no armour, low HP (<25) and no ammo
+const string anumber[10] =
+{
+ "gfx/anum_0", "gfx/anum_1", "gfx/anum_2", "gfx/anum_3", "gfx/anum_4",
+ "gfx/anum_5", "gfx/anum_6", "gfx/anum_7", "gfx/anum_8", "gfx/anum_9"
+};
+
+// Regular (24x24) characters for intermission
+const string extrachar[3] =
+{
+ "gfx/num_colon", "gfx/num_minus", "gfx/num_slash"
+};
+
+// 24x24 pixel icons for Status Bar
+const string sbitems[8] =
+{
+ "gfx/sb_shells", "gfx/sb_nails", "gfx/sb_rocket", "gfx/sb_cells",
+ "gfx/sb_armor1", "gfx/sb_armor2", "gfx/sb_armor3", "gfx/disc"
+};
+
+// 16x16 pixel icons for Information Bar
+const string ibitems[6] =
+{
+ "gfx/sb_key1", "gfx/sb_key2", "gfx/sb_invis", "gfx/sb_invuln",
+ "gfx/sb_suit", "gfx/sb_quad"
+};
+
+// 8x16 pixel runes for Information Bar
+const string ibrunes[4] =
+{
+ "gfx/sb_sigil1", "gfx/sb_sigil2", "gfx/sb_sigil3", "gfx/sb_sigil4"
+};
+
+// Shotgun, SuperShotgun, Nailgun, SuperNailGun, GrenadeLauncher
+// RocketLauncher, LightningGun
+const string wpnnames[7] =
+{
+ "shotgun", "sshotgun", "nailgun", "snailgun", "rlaunch",
+ "srlaunch", "lightng"
+};
+
+// OFF / ON gfx (reflects active weapon)
+const string wpnselect[2] = { "gfx/inv_", "gfx/inv2_" };
+
+// Special flash set for when the player gets weapon
+const string wpnflash[5] =
+{
+ "gfx/inva1_","gfx/inva2_","gfx/inva3_","gfx/inva4_","gfx/inva5_"
+};
+
+// Frame 00-04 : Regular HP 100/80/60/40/20
+// Frame 05-09 : InPain HP 100/80/60/40/20
+// Frame 10 : Invisibility Ring + Pentagram!
+// Frame 11 : Quad Damage
+// Frame 12 : Invisibility Ring
+// Frame 13 : Pentagram (invulnerability)
+const string facetab[14] =
+{
+ "gfx/face5", "gfx/face4", "gfx/face3", "gfx/face2", "gfx/face1",
+ "gfx/face_p5", "gfx/face_p4", "gfx/face_p3", "gfx/face_p2",
+ "gfx/face_p1",
+ "gfx/face_inv2", "gfx/face_quad", "gfx/face_invis", "gfx/face_invul2"
+};
+
+//======================================================================
+// globals
+//======================================================================
+
+float baralpha; // Read scr_sbaralpha variable
+float hudalpha; // All gfx on hud bars
+float flashtime[7]; // record when weapons have been added
+
+//======================================================================
+// forward declarations
+//======================================================================
+
+void(vector pos, float value, float threshhold) Hud_DrawNoFont24;
+void(vector pos, string num) Hud_DrawCharFont24;
+void(vector pos, float value, float digit, float zerofill, float fontcol)
+ Hud_DrawNoFont8;
+void(vector pos) Hud_DrawFace;
+static void(float num, vector pos) Hud_DrawWeapon;
+void (vector pos, vector virtsize) Hud_DrawSBar;
+void (vector pos, vector br) Hud_DrawIBar;
+void(vector pos, float bx, float by, float bwidth, float bheight,
+ float pixelspeed, string draw_str) Hud_ScrollTextBox;
+void(vector pos) Hud_QSScores_SBar;
+void(vector pos) Hud_IDScores_SBar;
+vector(string picname, float height) Hud_AspectSize;
+void(string picname, float scrwidth, vector pos, float height) Hud_CentrePic;
+void(vector virtmin, vector virtsize) Hud_DMScoreboard;
+void(vector virtmin, vector virtsize) Hud_Intermission;
+void(vector pos) Hud_InputMonitor;
+void(vector pos) Hud_Speedometer;
+void(vector virtsize, float showscores) CSQC_DrawHud;
+void(vector virtsize, float showscores) CSQC_DrawScores;
+
+//------------------------------------------------------------------------------
+
+//----------------------------------------------------------------------
+// Display 24pixel numbers to HUD (cope with red version)
+//----------------------------------------------------------------------
+void(vector pos, float value, float threshhold) Hud_DrawNoFont24 =
+{
+ local string val_str, disp_str;
+ local float disp_col, disp_len, disp_no;
+
+ // Make sure value is within range
+ if (value < 0)
+ value = 0;
+ else if (value > 999)
+ value = 999;
+
+ disp_col = FALSE;
+
+ // Round number down (floor) and work out length
+ val_str = ftos (floor(value));
+ disp_len = strlen (val_str);
+ // Move to the lowest digit position first
+ pos_x = pos_x + (3 * HUDSIZE_24_x);
+
+ // Work out which number colour to use
+ if (value <= threshhold)
+ disp_col = TRUE;
+
+ while (disp_len > 0)
+ {
+ // Countdown early (range is 0-2, strlen returns 1-3)
+ disp_len = disp_len - 1;
+
+ // Move backward to display a digit
+ pos_x = pos_x - HUDSIZE_24_x;
+
+ // Convert str character to font index numbers
+ disp_no = (str2chr (val_str, disp_len) - '0');
+
+ // Double check for any wierd range issues
+ if (disp_no < 0 || disp_no > 9)
+ disp_no = 0;
+
+ // Work out which number colour to use
+ if (disp_col)
+ disp_str = anumber[disp_no];
+ else
+ disp_str = number[disp_no];
+
+ // Draw number in correct (right-justified) position
+ drawpic (pos, disp_str, HUDSIZE_24, HUDRGB_DEF, hudalpha, 0);
+ }
+};
+
+//----------------------------------------------------------------------
+// Display 24pixel characters to HUD (limited chars available)
+//----------------------------------------------------------------------
+void(vector pos, string num) Hud_DrawCharFont24 =
+{
+ float i, c;
+ // Endless loop until end of string
+ // Keep moving draw pos forward (pos_x)
+ for (i = 0; ; i++, pos_x += HUDSIZE_24_x)
+ {
+ // Read next character from string
+ c = str2chr (num, i);
+ // End of string found?
+ if (!c)
+ break;
+ // Check for special characters
+ else if (c == ':' || c == '.')
+ drawpic (pos, extrachar[0], HUDSIZE_24, HUDRGB_DEF,
+ hudalpha, 0);
+ else if (c == '-')
+ drawpic (pos, extrachar[1], HUDSIZE_24, HUDRGB_DEF,
+ hudalpha, 0);
+ else if (c == '/')
+ drawpic (pos, extrachar[2], HUDSIZE_24, HUDRGB_DEF,
+ hudalpha, 0);
+ // Draw rest of the numbers
+ else if (c >= '0' && c <= '9')
+ {
+ // Sanity check, make sure within range of array
+ c = c - 48;
+ if (c < 0 || c > 9) c = 0;
+ drawpic (pos, number[c], HUDSIZE_24, HUDRGB_DEF,
+ hudalpha, 0);
+ }
+ }
+};
+
+//----------------------------------------------------------------------
+// Draws small 8 pixel numbers to HUD (white/yellow/red text options)
+//----------------------------------------------------------------------
+void(vector pos, float value, float digit, float zerofill, float fontcol)
+ Hud_DrawNoFont8 =
+{
+ local string val_str;
+ local float disp_len, disp_no;
+
+ // Make sure value is within range
+ if (value < 0)
+ value = 0;
+ // Check max range against max digits
+ else if (value > 999 && digit >= 3)
+ value = 999;
+ else if (value > 99 && digit == 2)
+ value = 99;
+ else if (value > 9 && digit <= 1)
+ value = 9;
+
+ // Round number down (floor) and work out length
+ val_str = ftos (floor(value));
+ disp_len = strlen (val_str);
+
+ // Zero fill number?
+ if (zerofill)
+ {
+ while (disp_len < digit)
+ {
+ // Keep adding more zero's
+ val_str = strcat ("0", val_str);
+ // Exit condition?
+ disp_len = strlen (val_str);
+ }
+ }
+
+ // Move to the lowest digit position first
+ pos_x = pos_x + (digit * HUDSIZE_8_x);
+
+ while (disp_len > 0)
+ {
+ // Countdown first (digit positions = 0-2)
+ disp_len = disp_len - 1;
+ // Move backward to display a digit
+ pos_x = pos_x - HUDSIZE_8_x;
+ // Convert character to number (font table index 48-57)
+ disp_no = str2chr (val_str, disp_len);
+ if (fontcol == HUDFONT_YELLOW)
+ disp_no = disp_no - 30;
+ else if (fontcol == HUDFONT_RED)
+ disp_no = disp_no + 128;
+ // Draw character from ascii font table (right-justified)
+ drawcharacter (pos, disp_no, HUDSIZE_8, HUDRGB_DEF,
+ hudalpha, 0);
+ }
+};
+
+//----------------------------------------------------------------------
+// Change HUD face to reflect Health, Pain or Powerups
+//----------------------------------------------------------------------
+void(vector pos) Hud_DrawFace =
+{
+ string face;
+ local float hpframe;
+
+ // Start with InvRing as it has two states
+ if (sitems & IT_INVISIBILITY)
+ {
+ if (sitems & IT_INVULNERABILITY)
+ // InvRing + Pentagram!?! WTF!?! SandyP E4 design!
+ face = facetab[10];
+ else
+ // Just InvRing only
+ face = facetab[12];
+ }
+ else if (sitems & IT_QUAD)
+ {
+ // Quad only
+ face = facetab[11];
+ }
+ else if (sitems & IT_INVULNERABILITY)
+ {
+ // Pentagram only
+ face = facetab[13];
+ }
+ else
+ {
+ // Regular face
+ // Work out face based on HP (100/80/60/40/20)
+ hpframe = floor (shealth / 20);
+
+ // Check for negative and upper (MegaHP) limits
+ if (hpframe < 0)
+ hpframe = 0;
+ else if (hpframe > 4)
+ hpframe = 4;
+
+ // Check for any pain/flinch updates
+ if (painfinishtime > time)
+ hpframe = hpframe + 5;
+
+ // Final HP face
+ face = facetab[hpframe];
+ }
+
+ // Draw face - always 24x24 size, full rgb/alpha
+ drawpic (pos, face, HUDSIZE_24, HUDRGB_DEF, hudalpha, 0);
+};
+
+//----------------------------------------------------------------------
+// Update a weapon icon with selection or flash features
+//----------------------------------------------------------------------
+static void(float num, vector pos) Hud_DrawWeapon =
+{
+ local string prefix, file_str;
+ local vector gfx_size;
+ local float flash;
+
+ // The weapon flash is done every 0.1s and repeated twice!
+ // When the player gets a new weapon the time is reset
+ // This function will count the time difference for flashing
+ // Convert the flash time to a 0-10+ range
+ flash = (time - flashtime[num]) * 10;
+
+ // Has the flash happened twice? (finished)
+ if (flash >= 10)
+ {
+ // Work out if this weapon is currently selected
+ if (sweapon == (1 << num))
+ prefix = wpnselect[1];
+ // Default is no highlight
+ else
+ prefix = wpnselect[0];
+ }
+ else
+ {
+ // Flashing!
+ // Is the flash into second phase?
+ if (flash < 0)
+ flash = 0;
+ else if (flash >= 5)
+ flash = flash - 5;
+
+ // flash is only 0-4 frames
+ prefix = wpnflash[flash];
+ }
+
+ // Merge prefix type (defined above) to weapon filename
+ // Without string (str) functions this would involve a giant table
+ // This sorta assumes that CSQC is running on an advanced engine
+ // QSS/FTE/DP all support FTE_STRINGS extra str functions
+ file_str = strcat (prefix, wpnnames[num]);
+
+ // Most weapons are 24 pixels wide (half of ammo above)
+ // As always there is an exception (lightning gun)
+ if (num == WPN_WIDTHLG)
+ gfx_size = HUDWPN_48;
+ else
+ gfx_size = HUDWPN_24;
+
+ // Show weapon GFX (active/deactive/flashing)
+ drawpic (pos, file_str, gfx_size, HUDRGB_DEF, hudalpha, 0);
+};
+
+//----------------------------------------------------------------------
+// STATUS BAR ( Armour / Health quantities and current Ammo selected)
+//----------------------------------------------------------------------
+void (vector pos, vector virtsize) Hud_DrawSBar =
+{
+ // Draw primary HUD bar (Armour/Face/Health/Ammo)
+ drawpic (pos, backgrd[0], HUDSIZE_320, HUDRGB_DEF, baralpha, 0);
+
+ // Deal with Pentagram first, its a simple test/update
+ if (sitems & IT_INVULNERABILITY)
+ {
+ // Make sure 666 is in 24 pixel giant red numbers!
+ Hud_DrawNoFont24 (pos + [24, 0], 666, 666);
+ // Draw a pentagram symbol in the armour HUD slot
+ drawpic (pos, sbitems[7], HUDSIZE_24, HUDRGB_DEF, hudalpha, 0);
+ }
+ else
+ {
+ // Show armour type/quantity active
+ Hud_DrawNoFont24 (pos + '24 0 0', getstatf(STAT_ARMOR), 25);
+ // Only 3 armour types (green/yellow/red)
+ if (sitems & IT_ARMOR1)
+ drawpic (pos, sbitems[4], HUDSIZE_24, HUDRGB_DEF,
+ hudalpha, 0);
+ else if (sitems & IT_ARMOR2)
+ drawpic (pos, sbitems[5], HUDSIZE_24, HUDRGB_DEF,
+ hudalpha, 0);
+ else if (sitems & IT_ARMOR3)
+ drawpic (pos, sbitems[6], HUDSIZE_24, HUDRGB_DEF,
+ hudalpha, 0);
+ }
+
+ // Draw face + HP value
+ Hud_DrawFace (pos + [112, 0]);
+ Hud_DrawNoFont24 (pos + [136, 0], shealth, 25);
+
+ // Only update ammo type/quantity if not using axe!
+ if (sweapon != IT_AXE)
+ {
+ Hud_DrawNoFont24 (pos + [248, 0], getstatf(STAT_AMMO), 10);
+ if (sitems & IT_SHELLS)
+ drawpic (pos + [224, 0], sbitems[0], HUDSIZE_24,
+ HUDRGB_DEF, hudalpha, 0);
+ else if (sitems & IT_NAILS)
+ drawpic (pos + [224, 0], sbitems[1], HUDSIZE_24,
+ HUDRGB_DEF, hudalpha, 0);
+ else if (sitems & IT_ROCKETS)
+ drawpic (pos + [224, 0], sbitems[2], HUDSIZE_24,
+ HUDRGB_DEF, hudalpha, 0);
+ else if (sitems & IT_CELLS)
+ drawpic (pos + [224, 0], sbitems[3], HUDSIZE_24,
+ HUDRGB_DEF, hudalpha, 0);
+ }
+};
+
+//----------------------------------------------------------------------
+// INVENTORY BAR ( Ammo quantities, keys/runes and powerups )
+//----------------------------------------------------------------------
+void (vector pos, vector br) Hud_DrawIBar =
+{
+ local vector topcol, botcol;
+ local string player_frags;
+
+ // Draw background bar using scr_sbaralpha default
+ drawpic (pos, backgrd[1], HUDSIZE_320, HUDRGB_DEF, baralpha, 0);
+
+ // Always draw ammo scores
+ Hud_DrawNoFont8 (pos + [10, 0], getstatf(STAT_SHELLS), 3,
+ FALSE, HUDFONT_YELLOW);
+ Hud_DrawNoFont8 (pos + [58, 0], getstatf(STAT_NAILS), 3,
+ FALSE, HUDFONT_YELLOW);
+ Hud_DrawNoFont8 (pos + [106, 0], getstatf(STAT_ROCKETS), 3,
+ FALSE, HUDFONT_YELLOW);
+ Hud_DrawNoFont8 (pos + [154, 0], getstatf(STAT_CELLS), 3,
+ FALSE, HUDFONT_YELLOW);
+
+ // Draw weapons and highlight current one
+ if (sitems & IT_SHOTGUN)
+ Hud_DrawWeapon (0, pos + [24 * 0, 8]);
+ if (sitems & IT_SUPER_SHOTGUN)
+ Hud_DrawWeapon (1, pos + [24 * 1, 8]);
+ if (sitems & IT_NAILGUN)
+ Hud_DrawWeapon (2, pos + [24 * 2, 8]);
+ if (sitems & IT_SUPER_NAILGUN)
+ Hud_DrawWeapon (3, pos + [24 * 3, 8]);
+ if (sitems & IT_GRENADE_LAUNCHER)
+ Hud_DrawWeapon (4, pos + [24 * 4, 8]);
+ if (sitems & IT_ROCKET_LAUNCHER)
+ Hud_DrawWeapon (5, pos + [24 * 5, 8]);
+ if (sitems & IT_LIGHTNING)
+ Hud_DrawWeapon (6, pos + [24 * 6, 8]);
+
+ // Draw inventory items
+ if (sitems & IT_KEY1)
+ drawpic (pos + [192, 8], ibitems[0], HUDSIZE_16, HUDRGB_DEF,
+ hudalpha, 0);
+ if (sitems & IT_KEY2)
+ drawpic (pos + [208, 8], ibitems[1], HUDSIZE_16, HUDRGB_DEF,
+ hudalpha, 0);
+ if (sitems & IT_INVISIBILITY)
+ drawpic (pos + [224, 8], ibitems[2], HUDSIZE_16, HUDRGB_DEF,
+ hudalpha, 0);
+ if (sitems & IT_INVULNERABILITY)
+ drawpic (pos + [240, 8], ibitems[3], HUDSIZE_16, HUDRGB_DEF,
+ hudalpha, 0);
+ if (sitems & IT_SUIT)
+ drawpic (pos + [256, 8], ibitems[4], HUDSIZE_16, HUDRGB_DEF,
+ hudalpha, 0);
+ if (sitems & IT_QUAD)
+ drawpic (pos + [272, 8], ibitems[5], HUDSIZE_16, HUDRGB_DEF,
+ hudalpha, 0);
+
+ // Draw Runes (special size + location)
+ if (sitems2 & SERVERFLAGS_RUNE1)
+ drawpic (pos + [288, 8], ibrunes[0], HUDSIZE_816, HUDRGB_DEF,
+ hudalpha, 0);
+ if (sitems2 & SERVERFLAGS_RUNE2)
+ drawpic (pos + [296, 8], ibrunes[1], HUDSIZE_816, HUDRGB_DEF,
+ hudalpha, 0);
+ if (sitems2 & SERVERFLAGS_RUNE3)
+ drawpic (pos + [304, 8], ibrunes[2], HUDSIZE_816, HUDRGB_DEF,
+ hudalpha, 0);
+ if (sitems2 & SERVERFLAGS_RUNE4)
+ drawpic (pos + [312, 8], ibrunes[3], HUDSIZE_816, HUDRGB_DEF,
+ hudalpha, 0);
+
+ //should probably show team scores, but this mimics vanilla
+ if (deathmatch)
+ {
+ // Move to space above powerups
+ pos_x += 194;
+
+ // Loop through 4 players
+ for (float i = -1; i >= -4; i--)
+ {
+ // Read frag score of next player
+ player_frags = getplayerkeyvalue (i, "frags");
+
+ // No frags? stop loop
+ if (player_frags == "")
+ break;
+
+ // Read deathmatch player top/bottom skin colours
+ topcol = stov (getplayerkeyvalue(i, "topcolor_rgb"));
+ botcol = stov (getplayerkeyvalue(i, "bottomcolor_rgb"));
+
+ // Draw skin colours (alpha was 0.75 hardcoded)
+ drawfill (pos + [0, 1], [28, 3], topcol, 0.75, 0);
+ drawfill (pos + [0, 4], [28, 4], botcol, 0.75, 0);
+
+ // Draw frag score (New global small font function)
+ Hud_DrawNoFont8 (pos + '2 0 0', stof(player_frags), 3,
+ FALSE, HUDFONT_WHITE);
+
+ // Find player entity attached to this HUD
+ if (player_localentnum == stof(getplayerkeyvalue(i,
+ "viewentity")))
+ {
+ // special characters = []
+ drawcharacter (pos + [-4, 0], 0xe010,
+ HUDSIZE_8, HUDRGB_DEF, hudalpha, 0);
+ drawcharacter (pos + [24, 0], 0xe011,
+ HUDSIZE_8, HUDRGB_DEF, hudalpha, 0);
+ }
+
+ // Move forward to next hud space
+ pos_x += 8 * 4;
+ }
+ }
+};
+
+//----------------------------------------------------------------------
+// Scoreboard Bar (shows monster/secret quantities and map info)
+//----------------------------------------------------------------------
+void(vector pos, float bx, float by, float bwidth, float bheight,
+ float pixelspeed, string draw_str) Hud_ScrollTextBox =
+{
+ local float str_width, str_double, str_speed;
+ local string wide_str;
+
+ // draw debug visual box to show area on screen
+ //drawfill (pos + [bx, by], [bwidth, bheight], HUDRGB_DEF, 0.1, 0);
+
+ // Find out width of string in pixels (using font 8)
+ str_width = stringwidth (draw_str, TRUE, HUDSIZE_8);
+
+ // String less than window width?
+ if (str_width < bwidth)
+ {
+ // Center the map name string in the box area
+ str_double = (bwidth - str_width) / 2;
+
+ // Display string normally (no scrolling required)
+ drawstring (pos + [bx + str_double, by], draw_str, HUDSIZE_8,
+ HUDRGB_DEF, hudalpha, 0);
+ }
+ else
+ {
+ // Create double length string with boundary marker
+ wide_str = strcat (draw_str, " /// ", draw_str);
+
+ // Setup clip (scissor) area for exclusive drawing
+ drawsetcliparea (pos_x + bx, pos_y + by, bwidth, bheight);
+ str_double = stringwidth (wide_str, TRUE, HUDSIZE_8);
+
+ // create offset of string to make it look like its scrolling
+ str_speed = mod (cltime * pixelspeed, (str_double - str_width));
+
+ // draw string (with offset) inside of clip (scissor) area only
+ drawstring (pos + [bx - str_speed, by], wide_str, HUDSIZE_8,
+ HUDRGB_DEF, hudalpha, 0);
+
+ // Reset clip string area to default
+ drawresetcliparea ();
+ }
+};
+
+//----------------------------------------------------------------------
+// Quakespasm scoreboard layout (no time)
+//----------------------------------------------------------------------
+void(vector pos) Hud_QSScores_SBar =
+{
+ local string skill_str, map_str;
+ local float digit;
+
+ // Clear status bar ready for map info/scores
+ drawpic (pos, backgrd[2], HUDSIZE_320, HUDRGB_DEF, baralpha, 0);
+
+ // Display headings
+ drawstring (pos + [8, 12], "Kills:", HUDSIZE_8, HUDRGB_DEF,
+ hudalpha, 0);
+ drawstring (pos + [80, 12], "/", HUDSIZE_8, HUDRGB_DEF,
+ hudalpha, 0);
+ drawstring (pos + [132, 12], "Skill ", HUDSIZE_8, HUDRGB_DEF,
+ hudalpha, 0);
+ drawstring (pos + [208, 12], "Secrets:", HUDSIZE_8, HUDRGB_DEF,
+ hudalpha, 0);
+ drawstring (pos + [288, 12], "/", HUDSIZE_8, HUDRGB_DEF,
+ hudalpha, 0);
+
+ // Display monster/secret totals
+ Hud_DrawNoFont8 (pos + [56, 12], getstatf(STAT_KILLEDMONSTERS), 3,
+ FALSE, HUDFONT_WHITE);
+ if (getstatf(STAT_TOTALMONSTERS) < 100)
+ digit = 2;
+ else
+ digit = 3;
+ Hud_DrawNoFont8 (pos + [88, 12], getstatf(STAT_TOTALMONSTERS), digit,
+ FALSE, HUDFONT_WHITE);
+ Hud_DrawNoFont8 (pos + [272, 12], getstatf(STAT_FOUNDSECRETS), 2,
+ FALSE, HUDFONT_WHITE);
+ Hud_DrawNoFont8 (pos + [296, 12], getstatf(STAT_TOTALSECRETS), 2,
+ FALSE, HUDFONT_WHITE);
+
+ // Display map skill level
+ skill_str = autocvar (skill, "1");
+ drawstring (pos + [180, 12], skill_str, HUDSIZE_8, HUDRGB_DEF,
+ hudalpha, 0);
+
+ // Level designers Map name + File name
+ map_str = strcat (world.message, " (", mapname, ")");
+ Hud_ScrollTextBox (pos, 8, 4, 304, 8, 16, map_str);
+};
+
+//----------------------------------------------------------------------
+// The original ID scoreboard layout (no skill, map filename)
+//----------------------------------------------------------------------
+void(vector pos) Hud_IDScores_SBar =
+{
+ local float nsecs, nmins;
+
+ // Clear status bar ready for map info/scores
+ drawpic (pos, backgrd[2], HUDSIZE_320, HUDRGB_DEF, baralpha, 0);
+ // Display headings
+ drawstring (pos+[8,4], "Monsters:", HUDSIZE_8, HUDRGB_DEF, hudalpha, 0);
+ drawstring (pos+[104,4], "/", HUDSIZE_8, HUDRGB_DEF, hudalpha, 0);
+ drawstring (pos+[8,12], "Secrets :", HUDSIZE_8, HUDRGB_DEF, hudalpha,0);
+ drawstring (pos+[104,12], "/", HUDSIZE_8, HUDRGB_DEF, hudalpha, 0);
+ drawstring (pos+[184,4], "Time :", HUDSIZE_8, HUDRGB_DEF, hudalpha, 0);
+ drawstring (pos+[256,4], ":", HUDSIZE_8, HUDRGB_DEF, hudalpha, 0);
+ // Display monster/secret totals
+ Hud_DrawNoFont8 (pos + [80, 4], getstatf(STAT_KILLEDMONSTERS), 3,
+ FALSE, HUDFONT_WHITE);
+ Hud_DrawNoFont8 (pos + [112, 4], getstatf(STAT_TOTALMONSTERS), 3,
+ FALSE, HUDFONT_WHITE);
+ Hud_DrawNoFont8 (pos + [80, 12], getstatf(STAT_FOUNDSECRETS), 3,
+ FALSE, HUDFONT_WHITE);
+ Hud_DrawNoFont8 (pos + [112, 12], getstatf(STAT_TOTALSECRETS), 3,
+ FALSE, HUDFONT_WHITE);
+ // Work out time passed
+ nmins = floor (time / 60);
+ nsecs = floor (time - nmins * 60);
+ Hud_DrawNoFont8 (pos + [232, 4], nmins, 3, FALSE, HUDFONT_WHITE);
+ Hud_DrawNoFont8 (pos + [264, 4], nsecs, 2, TRUE, HUDFONT_WHITE);
+ // Level designers Map name
+ Hud_ScrollTextBox (pos, 140, 12, 176, 8, 16, world.message);
+};
+
+//----------------------------------------------------------------------
+// Deathmatch scoreboard
+//----------------------------------------------------------------------
+vector(string picname, float height) Hud_AspectSize =
+{
+ local vector sz;
+ sz = drawgetimagesize (picname);
+ return [sz_x * height / sz_y, height];
+};
+
+//----------------------------------------------------------------------
+void(string picname, float scrwidth, vector pos, float height) Hud_CentrePic =
+{
+ local vector sz;
+ sz = Hud_AspectSize (picname, height);
+ pos_x += (scrwidth - sz_x) / 2;
+ drawpic (pos, picname, sz, HUDRGB_DEF, hudalpha, 0);
+};
+
+//----------------------------------------------------------------------
+void(vector virtmin, vector virtsize) Hud_DMScoreboard =
+{
+ local float isspec;
+ local vector pos, topcol, botcol;
+ string player_name, player_frags, player_ping;
+
+ // Working copy
+ pos = virtmin;
+
+ // Check for 16 players?
+ player_name = getplayerkeyvalue (-16, "name");
+ if (player_name == "")
+ pos_y += (virtsize_y - 200) / 2;
+
+ // Only draw the header when its not a really big game
+ player_name = getplayerkeyvalue (-24, "name");
+ if (player_name == "")
+ {
+ pos_y += 8;
+ // Display header (ranking.lmp) gfx for DM scoreboard
+ Hud_CentrePic (backlmp[0], virtsize_x, pos, 24);
+ // A double update of Y, only spike knows why!?!
+ pos_y += 24;
+ pos_y += 10;
+ }
+
+ // Another double X update, no idea why!
+ pos_x += (virtsize_x - 320) / 2;
+ pos_x += 80;
+
+ // negative numbers are players sorted by frags.
+ for (float i = -1; ; i--, pos_y += 10)
+ {
+ // Check for next player name
+ player_name = getplayerkeyvalue (i, "name");
+ // No more in list, end loop
+ if (player_name == "")
+ break;
+
+ // Read player stats (frag/ping)
+ isspec = stof (getplayerkeyvalue(i, "*spectator"));
+ player_frags = getplayerkeyvalue (i, "frags");
+ player_ping = getplayerkeyvalue (i, "ping");
+ // Read deathmatch player top/bottom skin colours
+ topcol = stov (getplayerkeyvalue(i, "topcolor_rgb"));
+ botcol = stov (getplayerkeyvalue(i, "bottomcolor_rgb"));
+
+ // Re-format the player name (no case conversion, force red)
+ player_name = strconv (0,2,2, player_name);
+ // Draw frag score (New global small font function)
+ Hud_DrawNoFont8 (pos - [8 * 5, 0], stof(player_ping), 3,
+ FALSE, HUDFONT_WHITE);
+
+ // Which type of player? Spectator or Active?
+ if (isspec)
+ {
+ drawstring (pos + [4, 0], "spec", [8, 8],
+ HUDRGB_DEF, hudalpha, 0);
+ }
+ else
+ {
+ // Draw skin colours (alpha was 0.75 hardcoded)
+ drawfill (pos + [0, 0], [40, 4], topcol, 0.75, 0);
+ drawfill (pos + [0, 4], [40, 4], botcol, 0.75, 0);
+
+ // Draw frag score (New global small font function)
+ Hud_DrawNoFont8 (pos + [8, 0], stof(player_frags), 3,
+ FALSE, HUDFONT_WHITE);
+ // Find player entity attached to this HUD
+ if (player_localentnum == stof(getplayerkeyvalue(i,
+ "viewentity")))
+ {
+ // special characters = []
+ drawcharacter (pos + [0, 0], 0xe010,
+ HUDSIZE_8, HUDRGB_DEF, hudalpha, 0);
+ drawcharacter (pos + [32, 0], 0xe011,
+ HUDSIZE_8, HUDRGB_DEF, hudalpha, 0);
+ }
+ }
+ // Finally draw player name
+ drawstring (pos + [64, 0], player_name, HUDSIZE_8,
+ HUDRGB_DEF, hudalpha, 0);
+ }
+};
+
+//----------------------------------------------------------------------
+// Final Intermission
+//----------------------------------------------------------------------
+void(vector virtmin, vector virtsize) Hud_Intermission =
+{
+ local vector pos;
+ // Create positions based on virtual screen
+ pos = virtmin + (virtsize - [320, 200]) / 2;
+
+ // Draw Intermission title and table info (Time/secret/kill)
+ Hud_CentrePic (backlmp[1], 320, pos + [0, 24], 24);
+ drawpic (pos + [0,56], backlmp[2], [160,144], HUDRGB_DEF, hudalpha, 0);
+
+ // Generate complete string and then draw 1 character at time
+ // Uses Sprintf function to feed values into final string
+ // This function should be supported by Advanced engines
+ Hud_DrawCharFont24 (pos + [144, 64], sprintf("%3.0f:%02.0f",
+ intermission_time / 60, intermission_time % 60));
+ Hud_DrawCharFont24 (pos + [144, 104],
+ sprintf ("%3.0f/%.0f",
+ getstatf (STAT_FOUNDSECRETS),
+ getstatf (STAT_TOTALSECRETS)
+ )
+ );
+ Hud_DrawCharFont24 (pos + [144, 144],
+ sprintf ("%3.0f/%.0f",
+ getstatf (STAT_KILLEDMONSTERS),
+ getstatf (STAT_TOTALMONSTERS)
+ )
+ );
+};
+
+
+//----------------------------------------------------------------------
+// Input Monitor -- CEV
+//----------------------------------------------------------------------
+void(vector pos) Hud_InputMonitor =
+{
+ if (input_movevalues_x)
+ if (input_movevalues_x < 0)
+ // backward
+ drawcharacter ([pos_x, pos_y, pos_z],
+ str2chr ("-", 0),
+ HUDSIZE_8, HUDRGB_DEF, hudalpha, 0);
+ else if (input_movevalues_x > 0)
+ // forward
+ drawcharacter ([pos_x, pos_y - 8, pos_z],
+ str2chr ("^", 0),
+ HUDSIZE_8, HUDRGB_DEF, hudalpha, 0);
+
+ if (input_movevalues_y)
+ if (input_movevalues_y < 0)
+ // left
+ drawcharacter ([pos_x - 12, pos_y, pos_z],
+ str2chr ("<", 0),
+ HUDSIZE_8, HUDRGB_DEF, hudalpha, 0);
+ else if (input_movevalues_y > 0)
+ // right
+ drawcharacter ([pos_x + 12, pos_y, pos_z],
+ str2chr (">", 0),
+ HUDSIZE_8, HUDRGB_DEF, hudalpha, 0);
+
+ if (input_movevalues_z)
+ if (input_movevalues_z < 0)
+ // down
+ drawcharacter ([pos_x - 38, pos_y, pos_z],
+ str2chr ("#", 0),
+ HUDSIZE_8, HUDRGB_DEF, hudalpha, 0);
+ else if (input_movevalues_z > 0)
+ // up
+ drawcharacter ([pos_x - 24, pos_y, pos_z],
+ str2chr ("^", 0),
+ HUDSIZE_8, HUDRGB_DEF, hudalpha, 0);
+
+ if (input_buttons & 0x00000002)
+ // INPUT_BUTTON2 jumping
+ drawcharacter ([pos_x - 24, pos_y, pos_z], str2chr ("^", 0),
+ HUDSIZE_8, HUDRGB_DEF, hudalpha, 0);
+};
+
+//----------------------------------------------------------------------
+// Speedometer -- CEV
+//----------------------------------------------------------------------
+void(vector pos) Hud_Speedometer =
+{
+ // fancy -- CEV
+ local vector v = [player_local.velocity_x, player_local.velocity_y, 0];
+
+ Hud_DrawNoFont8 (pos, ceil(vlen(v)), 3, FALSE, HUDFONT_WHITE);
+};
+
+//----------------------------------------------------------------------
+// MAIN ENTRY POINT FOR HUD!!!
+//----------------------------------------------------------------------
+void(vector virtsize, float showscores) CSQC_DrawHud =
+{
+ local vector pos, pos_speedo;
+ local float oitems, hudviewsize, i;
+
+ // Save previous HUD versions for flash function
+ oitems = sitems;
+
+ //------------------------------------------------------------------
+ // All variables have to be specially setup and passed between
+ // progs and csprogs as they are not connected in VM space
+ // By default CSQC has 30 (most commonly used) parameters setup
+ // Unfortunately some of them need to be converted (bitswapped)
+ // to make them readable again (I blame spike for this mess)
+ // The downside to this bitswapping mess is that the serverflags
+ // is not passed to CSQC completely, only the first 4bits (runes)
+ //------------------------------------------------------------------
+ sitems = getstatf (STAT_ITEMS, 0, 23);
+ sitems2 = getstatf (STAT_ITEMS, 23, 9);
+ sweapon = getstatf (STAT_ACTIVEWEAPON);
+ shealth = getstatf (STAT_HEALTH);
+
+ // Don't show HUD, intermission or dead
+ if (intermission || shealth <= 0)
+ return;
+
+ //--------------------------------------------------------------
+ // Read console variable for background HUD alpha
+ baralpha = cvar ("scr_sbaralpha");
+ if (baralpha == 0)
+ baralpha = 0.75;
+ // Default is 1 for everything else
+ hudalpha = 1;
+
+ //--------------------------------------------------------------
+ // Check if any weapons have been added to the inventory
+ // Update time so the flash function can detect it
+ // Check for player count for splitscreen!?! QSS/FTE feature
+ if (numclientseats <= 1)
+ {
+ // Player alive and inventory changd?
+ if (shealth && sitems != oitems)
+ {
+ // Go through all weapon flash counters
+ for (i = 0; i < WPN_ICONS; i++)
+ {
+ // Found weapon and its new?
+ if ((sitems & (1<<i)) && !(oitems & (1<<i)))
+ // Reset timer
+ flashtime[i] = time;
+ }
+ }
+ }
+
+ //--------------------------------------------------------------
+ // Find out how much of the HUD is being displayed
+ // 100 = InfoBar & StatusBar (ALL=Default)
+ // 110 = StatusBar Only
+ // 120 = Speedometer
+ // 130 = Nothing
+ //--------------------------------------------------------------
+
+ // Read current HUD size
+ hudviewsize = cvar ("viewsize");
+
+ // Any HUD to display?
+ if (hudviewsize < 130)
+ {
+ // Override scoreboard - check if no player health
+ if (shealth <= 0)
+ showscores = TRUE;
+
+ // Find out mid point of screen
+ pos_x = (virtsize_x - 320) / 2;
+ pos_y = virtsize_y;
+ pos_z = 0;
+
+ // trying to center the speedometer display just below
+ // the crosshair. This doesn't seem to be right but it
+ // works on my 960x720 window. -- CEV.
+ pos_speedo_x = virtsize_x / 2.0;
+ pos_speedo_y = virtsize_y / 2.0;
+ pos_speedo_z = 0;
+ Hud_Speedometer (pos_speedo - [8 * 1.5, -8]);
+
+ // Input Monitor TODO CEV
+ if (!cvar("crosshair"))
+ Hud_InputMonitor (pos_speedo - [4, 4, 0]);
+
+ if (hudviewsize < 120)
+ {
+ // Either show Sbar or Scores (bars are centered)
+ if (showscores)
+ Hud_QSScores_SBar (pos - '0 24 0');
+ else
+ Hud_DrawSBar (pos - '0 24 0', virtsize);
+ }
+
+ // Can the Info Bar be displayed?
+ if (hudviewsize < 110)
+ Hud_DrawIBar (pos - '0 48 0', virtsize);
+ }
+};
+
+//----------------------------------------------------------------------
+void(vector virtsize, float showscores) CSQC_DrawScores =
+{
+ shealth = getstatf (STAT_HEALTH);
+
+ if (intermission || showscores || shealth <= 0)
+ {
+ if (deathmatch)
+ Hud_DMScoreboard ('0 0 0', virtsize);
+ else if (intermission)
+ Hud_Intermission ('0 0 0', virtsize);
+ }
+};

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

Diff qc/cl_player.qc

diff --git a/qc/cl_player.qc b/qc/cl_player.qc
new file mode 100644
index 0000000..ae3b75d
--- /dev/null
+++ b/qc/cl_player.qc
@@ -0,0 +1,329 @@
+//==============================================================================
+// CSQC PLAYER MOVEMENT & PREDICTION
+//
+// This is based on code by Eukara [1] and the CSQCTest code shipped with
+// FTEQW [2].
+//
+// [1]: https://icculus.org/~marco/quakec/csqc/prediction.html
+// [2]: https://sourceforge.net/p/fteqw/code/HEAD/tree/trunk/quakec/csqctest/src
+//==============================================================================
+
+//======================================================================
+// constants
+//======================================================================
+
+#ifdef CSQC
+const float PRED_ERRORTIME = 20; //
+const float PRED_STEPTIME = 8;
+#endif
+
+//======================================================================
+// forward declarations
+//======================================================================
+
+#ifdef CSQC
+void(entity ent) PlayerResetPrediction;
+void(entity ent, float endframe) PlayerRunMovement;
+float() PlayerPreDraw;
+static void() PlayerRemove;
+void() PlayerNew;
+void(float isnew) PlayerUpdate;
+#endif
+
+//------------------------------------------------------------------------------
+
+#ifdef CSQC
+//----------------------------------------------------------------------
+// PlayerResetPrediction
+// was Pred_ResetPlayerPrediction in CSQCTest cs/prediction.qc
+//----------------------------------------------------------------------
+void(entity e) PlayerResetPrediction =
+{
+ e.origin = player_org;
+ e.velocity = player_vel;
+ e.flags = player_flags;
+ e.pmove_flags = player_pmove_flags;
+ e.doublejump_timer = player_doublejump_timer;
+
+ // +1 because the received frame has the move already done (server side)
+ pmove_frame = player_sequence + 1;
+
+ if (pmove_frame < clientcommandframe - 128)
+ // avoid an infinite loop
+ pmove_frame = clientcommandframe - 128;
+};
+
+//----------------------------------------------------------------------
+// PlayerRunMovement
+// was Pred_RunMovement in CSQCTest cs/prediction.qc
+//----------------------------------------------------------------------
+void(entity e, float endframe) PlayerRunMovement =
+{
+ if (servercommandframe >= player_sequence + 63)
+ {
+ // we're meant to be updating the player faster than
+ // this. hopefully its just that we're throttled...
+
+ // you can comment out this block and the player will
+ // continue to be predicted locally. But its best to
+ // freeze them
+
+ // as a note we also hit this block when the console is
+ // down -- CEV
+
+ player_sequence = servercommandframe - 63;
+ return;
+ }
+
+ PlayerResetPrediction (e);
+
+ if (getstatf(STAT_HEALTH) <= 0)
+ {
+ // dead, so don't run prediction. :D
+ pmove_frame = clientcommandframe;
+ if (!getinputstate(pmove_frame - 1))
+ {
+ dprint ("PlayerRunMovement: no-op if statement?\n");
+ // no-op ? -- CEV
+ }
+ return;
+ }
+
+ /*
+ if (getinputstate(pmove_frame - 1))
+ // from CSQCTest; what is this doing? -- TODO CEV;
+ e.pmove_flags |= PMF_JUMP_HELD;
+ */
+
+ while (pmove_frame <= endframe)
+ {
+ if (!getinputstate(pmove_frame))
+ {
+ // no input from client
+ // pmove_frame++;
+ break;
+ }
+
+ if (world_standardphysics)
+ // for testing
+ runstandardplayerphysics (e);
+ else
+ // for real
+ PM_Move (e);
+ pmove_frame++;
+ }
+
+ // add anything that was applied after (for low packet
+ // rate protocols)
+ // TODO CEV
+ input_angles = view_angles;
+};
+
+//----------------------------------------------------------------------
+// PlayerPreDraw
+// Incorporates Pred_UpdateLocalMovement from CSQCTest.
+//----------------------------------------------------------------------
+float() PlayerPreDraw =
+{
+ local float viewheight;
+
+ if (self.entnum != player_localentnum)
+ {
+ self.renderflags = 0;
+ }
+ else
+ {
+ PlayerRunMovement (self, clientcommandframe);
+
+ if (self.origin_z >= player_step_oldz + 6 &&
+ self.origin_z < player_step_oldz + 24 &&
+ self.velocity_z == 0)
+ {
+ // evaluate out the remaining old step
+ if (player_steptime - time > 0)
+ player_step = (player_steptime - time) *
+ PRED_STEPTIME * player_step;
+ else
+ player_step = 0;
+
+ // work out the new step
+ player_step += (player_step_oldz - self.origin_z);
+ player_steptime = time + 1 / PRED_STEPTIME;
+ }
+ player_step_oldz = self.origin_z;
+
+ // allow the user to move the viewheight down 6 units so
+ // it's at +16, where projectiles come from.
+ viewheight = autocvar (v_viewheight, 0);
+ if (viewheight < -7)
+ viewheight = -7;
+ else if (viewheight > 7)
+ viewheight = 7;
+
+ view_origin = self.origin;
+ view_origin_z += getstatf (STAT_VIEWHEIGHT) + viewheight;
+
+ // correct the view position to compensate for any errors,
+ // slowly over time, 0.1 seconds.
+ if (pmove_errortime - time > 0)
+ {
+ dprint ("PlayerPreDraw: pmove error\n");
+ view_origin += (pmove_errortime - time) *
+ PRED_ERRORTIME * pmove_error;
+ }
+
+ if (player_steptime - time > 0)
+ view_origin_z += (player_steptime - time) *
+ PRED_STEPTIME * player_step;
+
+ if (self.lerptime)
+ self.lerpfrac = 1 - (time - self.lerptime) * 10;
+
+ self.renderflags |= RF_EXTERNALMODEL;
+ }
+
+ viewentity.angles = view_angles;
+ viewentity.origin = view_origin;
+
+ addentity (self);
+ return PREDRAW_NEXT;
+};
+
+//----------------------------------------------------------------------
+// PlayerRemove
+//----------------------------------------------------------------------
+static void() PlayerRemove =
+{
+ if (player_local == self)
+ player_local = world;
+
+ setmodel (self, "");
+ self.oldskin = "";
+ self.predraw = __NULL__;
+};
+
+//----------------------------------------------------------------------
+// PlayerNew
+//----------------------------------------------------------------------
+void() PlayerNew =
+{
+ self.classname = "player";
+ self.customphysics = sub_null;
+ // MASK_NORMAL ?
+ self.drawmask = MASK_ENGINE;
+ self.movetype = MOVETYPE_WALK;
+ self.predraw = PlayerPreDraw;
+ self.removefunc = PlayerRemove;
+ self.solid = SOLID_SLIDEBOX;
+ setmodel (self, "progs/player.mdl");
+};
+
+//----------------------------------------------------------------------
+// PlayerUpdate
+// called from CSQC_Ent_Update for CT_PLAYER entities
+//----------------------------------------------------------------------
+void(float isnew) PlayerUpdate =
+{
+ local float f;
+
+ f = ReadByte ();
+ self.origin_x = ReadCoord ();
+ self.origin_y = ReadCoord ();
+ self.origin_z = ReadCoord ();
+ self.angles_x = ReadShort () / (32767 / 360);
+ self.angles_y = ReadShort () / (32767 / 360);
+ self.angles_z = ReadShort () / (32767 / 360);
+ self.velocity_x = ReadShort ();
+ self.velocity_y = ReadShort ();
+ self.velocity_z = ReadShort ();
+ self.effects = ReadFloat ();
+ self.flags = ReadFloat ();
+ self.pmove_flags = ReadFloat ();
+ self.doublejump_timer = ReadFloat ();
+
+ if (isnew && !(self.predraw))
+ PlayerNew ();
+
+ if (intermission)
+ {
+ // zero out velocity if in intermission -- CEV
+ world_gravity = 0.0f;
+ input_movevalues = '0 0 0';
+ self.velocity = '0 0 0';
+ viewentity.velocity = '0 0 0';
+ // viewentity.angles = self.angles;
+ // viewentity.origin = self.origin;
+ // setorigin (self, self.origin);
+ // setorigin (viewentity, viewentity.origin);
+ return;
+ }
+
+ if (f != self.frame || isnew)
+ {
+ self.frame2 = self.frame;
+ self.lerptime = time;
+ self.frame = f;
+ }
+
+ if (self.entnum == player_localentnum)
+ {
+ local vector o, v;
+ local float djt, gbt, pmflags, tempflags;
+
+ // this is us; save for later
+ player_local = self;
+ o = self.origin;
+ v = self.velocity;
+ djt = self.doublejump_timer;
+ tempflags = self.flags;
+ pmflags = self.pmove_flags;
+
+ // PlayerRunMovement calls ResetPrediction -- CEV
+ // PlayerResetPrediction (self);
+ PlayerRunMovement (self, servercommandframe + 1);
+
+ // TODO CEV ????
+ player_doublejump_timer = djt;
+ player_flags = tempflags;
+ player_pmove_flags = pmflags;
+ player_org = o;
+ player_vel = v;
+ player_sequence = servercommandframe;
+
+ if (autocvar(cg_noerror, TRUE))
+ {
+ pmove_error = '0 0 0';
+ pmove_errortime = time;
+ PlayerResetPrediction (self);
+ }
+ else
+ {
+ PlayerRunMovement (self, clientcommandframe);
+ o = self.origin;
+ // again: PlayerRunMovement calls ResetPrediction
+ // PlayerResetPrediction (self);
+ PlayerRunMovement (self, clientcommandframe);
+
+ if (vlen(o - self.origin) > 64)
+ {
+ // teleport
+ pmove_error = '0 0 0';
+ pmove_errortime = time;
+ }
+ else
+ {
+ pmove_error = (pmove_errortime - time) *
+ PRED_ERRORTIME * pmove_error +
+ (o - self.origin);
+ if (vlen(pmove_error) < 1)
+ pmove_error = '0 0 0';
+ pmove_errortime = time + 1 / PRED_ERRORTIME;
+ }
+ }
+ }
+
+ setsize (self, VEC_HULL_MIN, VEC_HULL_MAX);
+ self.oldframe = self.frame;
+ // setorigin (self, self.origin);
+};
+#endif

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

Diff qc/cl_progs.src

diff --git a/qc/cl_progs.src b/qc/cl_progs.src
new file mode 100644
index 0000000..f81ab77
--- /dev/null
+++ b/qc/cl_progs.src
@@ -0,0 +1,32 @@
+#pragma target fte
+#pragma progs_dat "../csprogs.dat"
+#pragma autoproto
+
+#define FTE
+#define CSQC
+
+#includelist
+//----------------------------------------------------------------------
+// CSQC defs
+//----------------------------------------------------------------------
+defs_globals.qc // id1 globalvars_t
+defs_fields.qc // id1 entvars_t
+defs_builtins.qc // curated builtins list
+defs_const.qc // program-wide constants
+defs_ctypes.qc // global class list
+
+//----------------------------------------------------------------------
+// object bootstrapping
+//----------------------------------------------------------------------
+base_entities.qc //
+world.qc //
+subs.qc //
+
+//----------------------------------------------------------------------
+// movement & client prediction, HUD, entity handling
+//----------------------------------------------------------------------
+pmove.qc // player movement code
+cl_player.qc // clientside player prediction
+cl_hud.qc // modified AD HUD (originally by Sock)
+cl_entry.qc // modified AD CSQC (originally by Sock)
+#endlist

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

Diff qc/compat_quake3.qc

diff --git a/qc/compat_quake3.qc b/qc/compat_quake3.qc
index a2ee243..998d4cb 100644
--- a/qc/compat_quake3.qc
+++ b/qc/compat_quake3.qc
@@ -2,7 +2,11 @@
// Quake 3 compatibility entrypoints / functions
//==============================================================================

-class item_quad: item_artifact_super_damage { };
+//----------------------------------------------------------------------
+void() spawnfunc_item_quad =
+{
+ item_artifact_super_damage ();
+};

//======================================================================
// Quake 3 armor item support -- CEV
@@ -11,44 +15,52 @@ class item_quad: item_artifact_super_damage { };
//----------------------------------------------------------------------
// Green Armor -- CEV
//----------------------------------------------------------------------
-class item_armor_jacket: item_armor1 { };
+void() spawnfunc_item_armor_jacket =
+{
+ item_armor1 ();
+};

//----------------------------------------------------------------------
// Yellow Armor -- CEV
//----------------------------------------------------------------------
-class item_armor_combat: item_armor2 { };
+void() spawnfunc_item_armor_combat =
+{
+ item_armor2 ();
+};

//----------------------------------------------------------------------
// Red Armor -- CEV
//----------------------------------------------------------------------
-class item_armor_body: item_armorInv { };
+void() spawnfunc_item_armor_body =
+{
+ item_armorInv ();
+};

//======================================================================
// Quake 3 health item support -- CEV
//======================================================================

//----------------------------------------------------------------------
-class item_health_mega: item_health
+void() spawnfunc_item_health_mega =
{
- virtual void() init_spawned =
- {
- this.spawnflags |= 2;
- super::init_spawned ();
- };
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit ())
+ return;

- void() item_health_mega =
- {
- this.classname = "item_health";
- };
+ self.classname = "item_health";
+ self.spawnflags |= 2;
+ item_health_init (self);
};

//----------------------------------------------------------------------
-class item_health_small: item_health_vial
+void() spawnfunc_item_health_small =
{
- void() item_health_small =
- {
- this.classname = "item_health_vial";
- };
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit ())
+ return;
+
+ self.classname = "item_health_vial";
+ item_health_vial_init (self);
};

//======================================================================
@@ -56,27 +68,44 @@ class item_health_small: item_health_vial
//======================================================================

//----------------------------------------------------------------------
-class ammo_cells: item_spikes { };
+void() spawnfunc_ammo_cells =
+{
+ item_spikes ();
+};

//----------------------------------------------------------------------
-class ammo_grenades: item_rockets { };
+void() spawnfunc_ammo_grenades =
+{
+ item_rockets ();
+};

//----------------------------------------------------------------------
-class ammo_lightning: item_cells { };
+void() spawnfunc_ammo_lightning =
+{
+ item_cells ();
+};

//----------------------------------------------------------------------
-class ammo_rockets: item_rockets { };
+void() spawnfunc_ammo_rockets =
+{
+ item_rockets ();
+};

//----------------------------------------------------------------------
-class ammo_shells: item_shells { };
+void() spawnfunc_ammo_shells =
+{
+ item_shells ();
+};

//----------------------------------------------------------------------
-class weapon_plasmagun: weapon_supernailgun
+void() spawnfunc_weapon_plasmagun =
{
- void() weapon_plasmagun =
- {
- this.classname = "weapon_supernailgun";
- };
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit ())
+ return;
+
+ self.classname = "weapon_supernailgun";
+ weapon_supernailgun_init (self);
};

//======================================================================
@@ -109,8 +138,26 @@ void() spawnfunc_target_position =
// Quake 3 Teleporter targets -- CEV
//======================================================================

-class misc_teleport_dest: info_teleport_destination {};
-class misc_teleporter_dest: info_teleport_destination {};
-class misc_teleporter_destination: info_teleport_destination {};
-class target_teleporter: info_teleport_destination {};
+//----------------------------------------------------------------------
+void() spawnfunc_misc_teleport_dest =
+{
+ info_teleport_destination ();
+};
+
+//----------------------------------------------------------------------
+void() spawnfunc_misc_teleporter_dest =
+{
+ info_teleport_destination ();
+};

+//----------------------------------------------------------------------
+void() spawnfunc_misc_teleporter_destination =
+{
+ info_teleport_destination ();
+};
+
+//----------------------------------------------------------------------
+void() spawnfunc_target_teleporter =
+{
+ info_teleport_destination ();
+};

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

Diff qc/cshift.qc

diff --git a/qc/cshift.qc b/qc/cshift.qc
index 527471a..182f594 100644
--- a/qc/cshift.qc
+++ b/qc/cshift.qc
@@ -2,6 +2,28 @@
// cshift.qc
//==============================================================================

+//======================================================================
+// fields
+//======================================================================
+
+.entity csf_controller; // cshift controller
+.vector csf_color;
+.float csf_density;
+.float fade_amt;
+
+//======================================================================
+// forward declarations
+//======================================================================
+
+inline void(entity client, float density, vector color) csf_save;
+inline void(entity client) csf_apply;
+void(entity client, float density, vector color) csf_set;
+void() csf_controller_think;
+void(entity client) csf_controller_start;
+void(entity client, float density, vector color, float spd) csf_fade;
+
+//------------------------------------------------------------------------------
+
//----------------------------------------------------------------------
inline void(entity client, float density, vector color) csf_save =
{
@@ -31,7 +53,7 @@ void(entity client, float density, vector color) csf_set =
};

//----------------------------------------------------------------------
-void() csfcontroller_think =
+void() csf_controller_think =
{
entity e = self.owner;

@@ -43,9 +65,9 @@ void() csfcontroller_think =
// wat
fraction = 1 - (self.pain_finished - time) / self.speed;

- density = lerpHermite (e.csf_density, self.csf_density,
+ density = lerp_hermite (e.csf_density, self.csf_density,
fraction);
- color = lerpVectorHermite (e.csf_color, self.csf_color,
+ color = lerp_vector_hermite (e.csf_color, self.csf_color,
fraction);

csf_set (e, density, color);
@@ -54,32 +76,32 @@ void() csfcontroller_think =
}
else
{
- csf_set(e, self.csf_density, self.csf_color);
+ csf_set (e, self.csf_density, self.csf_color);
}
};

//----------------------------------------------------------------------
-void(entity client) csfcontroller_start =
+void(entity client) csf_controller_start =
{
- if (client.csfcontroller.classname == "csfcontroller" &&
- client.csfcontroller.owner == client)
+ if (client.csf_controller.classname == "csfcontroller" &&
+ client.csf_controller.owner == client)
{
return;
}

entity e = spawn ();
- client.csfcontroller = e;
+ client.csf_controller = e;
e.owner = client;
e.classname = "csfcontroller";
- e.think = csfcontroller_think;
+ e.think = csf_controller_think;
};

//----------------------------------------------------------------------
void(entity client, float density, vector color, float spd) csf_fade =
{
- csfcontroller_start (client);
+ csf_controller_start (client);

- entity ct = client.csfcontroller;
+ entity ct = client.csf_controller;

ct.speed = spd;
ct.pain_finished = time + spd;

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

Diff qc/csqc/Makefile

diff --git a/qc/csqc/Makefile b/qc/csqc/Makefile
deleted file mode 100644
index 28788fc..0000000
--- a/qc/csqc/Makefile
+++ /dev/null
@@ -1,5 +0,0 @@
-CC=fteqcc64
-CCOPTS=-Wall -O2
-
-all:
- $(CC) $(CCOPTS) csqc_progs.src

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

Diff qc/csqc/csqc_defs.qc

diff --git a/qc/csqc/csqc_defs.qc b/qc/csqc/csqc_defs.qc
deleted file mode 100644
index 27d74b9..0000000
--- a/qc/csqc/csqc_defs.qc
+++ /dev/null
@@ -1,102 +0,0 @@
-//======================================================================
-// Author : Simon "Sock" OCallaghan
-// Website: www.simonoc.com
-//
-// This is a special defs file with all the relevant CSQC references
-// Should be included into progs and csprogs to reduce duplicates
-//
-//----------------------------------------------------------------------
-// The CSQC files are setup to be self contained and easy to port
-// to other MODS, but some stuff needs to exist in other QC files
-// In world.qc the extra variables for AD are located there
-//
-//----------------------------------------------------------------------
-// Special Variables used by CSQC (Client Side Quake C)
-// The engine will keep these insync between server and client
-// Defined with the addstat/clientstat command DP/FTE
-//----------------------------------------------------------------------
-
-const float CLIENT_HEALTH = 0; // Player's health
-const float CLIENT_WEAPONMODELI = 2; // Modelidx of current viewmodel
-const float CLIENT_AMMO = 3; // player.currentammo
-const float CLIENT_ARMOR = 4;
-const float CLIENT_WEAPONFRAME = 5;
-const float CLIENT_SHELLS = 6;
-const float CLIENT_NAILS = 7;
-const float CLIENT_ROCKETS = 8;
-const float CLIENT_CELLS = 9;
-const float CLIENT_ACTIVEWEAPON = 10; // player.weapon
-const float CLIENT_TOTALSECRETS = 11;
-const float CLIENT_TOTALMONSTERS = 12;
-const float CLIENT_FOUNDSECRETS = 13;
-const float CLIENT_KILLEDMONSTERS = 14;
-// getstatbits(CLIENT_ITEMS,0,23) to read self.items
-// getstatbits(CLIENT_ITEMS,23,11) to read self.items2
-// or getstatbits(CLIENT_ITEMS,28,4) to read the visible part of serverflags
-const float CLIENT_ITEMS = 15; // self.items | (self.items2<<23)
-const float CLIENT_VIEWHEIGHT = 16; // player.view_ofs_z
-const float CLIENT_VIEW2 = 20; // Entity Qty in server's .view2 field
-const float CLIENT_VIEWZOOM = 21; // Scales fov and sensitiity
-const float CLIENT_IDEALPITCH = 25;
-const float CLIENT_PUNCHANGLE_X = 26;
-const float CLIENT_PUNCHANGLE_Y = 27;
-const float CLIENT_PUNCHANGLE_Z = 28;
-// 32-127 is custom variables (defined here and linked in world.qc)
-const float CLIENT_MODITEMS = 40; // self.moditems (AD extra stuff)
-const float CLIENT_CKEYNAME1 = 50; // self.ckeyname1
-const float CLIENT_CKEYNAME2 = 51; // self.ckeyname2
-const float CLIENT_CKEYNAME3 = 52; // self.ckeyname3
-const float CLIENT_CKEYNAME4 = 53; // self.ckeyname4
-const float CLIENT_CKEYSKIN1 = 55; // self.ckeyskin1
-const float CLIENT_CKEYSKIN2 = 56; // self.ckeyskin2
-const float CLIENT_CKEYSKIN3 = 57; // self.ckeyskin3
-const float CLIENT_CKEYSKIN4 = 58; // self.ckeyskin4
-
-//----------------------------------------------------------------------
-// Duplicate of IT_ references in defs.qc
-//----------------------------------------------------------------------
-const float CSQC_SHOTGUN = 1<<0; // 1
-const float CSQC_SUPER_SHOTGUN = 1<<1; // 2
-const float CSQC_NAILGUN = 1<<2; // 4
-const float CSQC_SUPER_NAILGUN = 1<<3; // 8
-const float CSQC_GRENADE_LAUNCHER = 1<<4; // 16
-const float CSQC_ROCKET_LAUNCHER = 1<<5; // 32
-const float CSQC_LIGHTNING = 1<<6; // 64
-// const float CSQC_EXTRA_WEAPON = 1<<7; // 128
-
-const float CSQC_SHELLS = 1<<8; // 256
-const float CSQC_NAILS = 1<<9; // 512
-const float CSQC_ROCKETS = 1<<10; // 1024
-const float CSQC_CELLS = 1<<11; // 2048
-const float CSQC_AXE = 1<<12; // 4096
-
-const float CSQC_ARMOR1 = 1<<13; // 8192
-const float CSQC_ARMOR2 = 1<<14; // 16384
-const float CSQC_ARMOR3 = 1<<15; // 32768
-// const float CSQC_SUPERHEALTH = 1<<16; // 65536
-
-const float CSQC_KEY1 = 1<<17; // 131072
-const float CSQC_KEY2 = 1<<18; // 262144
-
-const float CSQC_INVISIBILITY = 1<<19; // 524288
-const float CSQC_INVULNERABILITY = 1<<20; // 1048576
-const float CSQC_SUIT = 1<<21; // 2097152
-const float CSQC_QUAD = 1<<22; // 4194304
-
-// Runes in Serverflags
-const float CSQC_RUNE1 = 1<<5; // 32
-const float CSQC_RUNE2 = 1<<6; // 64
-const float CSQC_RUNE3 = 1<<7; // 128
-const float CSQC_RUNE4 = 1<<8; // 256
-
-// Variable types
-const float EV_VOID = 0;
-const float EV_STRING = 1;
-const float EV_FLOAT = 2;
-const float EV_VECTOR = 3;
-const float EV_ENTITY = 4;
-const float EV_FIELD = 5;
-const float EV_FUNCTION = 6;
-const float EV_POINTER = 7;
-const float EV_INTEGER = 8;
-

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

Diff qc/csqc/csqc_defsbuiltins.qc

diff --git a/qc/csqc/csqc_defsbuiltins.qc b/qc/csqc/csqc_defsbuiltins.qc
deleted file mode 100644
index 8ac0e23..0000000
--- a/qc/csqc/csqc_defsbuiltins.qc
+++ /dev/null
@@ -1,898 +0,0 @@
-/*==============================================================================
- BUILTIN FUNCTIONS (CSQC)
-==============================================================================*/
-
-//======================================================================
-// Portions of this have been copied from Arcane Dimensions' CSQC by Sock
-// (Simon OCallaghan). Rest has been sourced from fteextensions.qc as
-// needed. -- CEV
-//======================================================================
-
-// Custom types redefined as accessors
-// need to do this here as some of it is referenced below -- CEV
-#ifdef _ACCESSORS
-accessor strbuf:float;
-accessor searchhandle:float;
-accessor hashtable:float;
-accessor infostring:string;
-accessor filestream:float;
-#else
-#define strbuf float
-#define searchhandle float
-#define hashtable float
-#define infostring string
-#define filestream float
-#endif
-
-//----------------------------------------------------------------------
-// Vanilla Builtin list (reduced, so as to avoid conflicts)
-//----------------------------------------------------------------------
-void(vector) makevectors = #1;
-void(entity,vector) setorigin = #2;
-void(entity,string) setmodel = #3;
-void(entity,vector,vector) setsize = #4;
-float() random = #7;
-vector(vector) normalize = #9;
-void(string e) error = #10;
-void(string n) objerror = #11;
-float(vector) vlen = #12;
-
-// Given a direction vector, returns the yaw angle in which that direction
-// vector points. If an entity is passed, the yaw angle will be relative to
-// that entity's gravity direction.
-float(vector v, optional entity reference) vectoyaw = #13;
-
-entity() spawn = #14;
-void(entity e) remove = #15;
-
-// Traces a thin line through the world from v1 towards v2. Will not collide
-// with ent, ent.owner, or any entity who's owner field refers to ent. The
-// passed entity will also be used to determine whether to use a capsule
-// trace, the contents that the trace should impact, and a couple of other
-// extra fields that define the trace.
-//
-// There are no side effects beyond the trace_* globals being written.
-// flags&MOVE_NOMONSTERS will not impact on non-bsp entities.
-// flags&MOVE_MISSILE will impact with increased size.
-// flags&MOVE_HITMODEL will impact upon model meshes, instead of their
-// bounding boxes.
-// flags&MOVE_TRIGGERS will also stop on triggers
-// flags&MOVE_EVERYTHING will stop if it hits anything, even non-solid entities.
-// flags&MOVE_LAGGED will backdate entity positions for the purposes of
-// this builtin according to the indicated player ent's latency, to provide
-// lag compensation.
-void(vector v1, vector v2, float flags, entity ent) traceline = #16;
-
-// Precaches a model, making it known to clients and loading it from disk
-// if it has a .bsp extension. This builtin (strongly) should be called
-// during spawn functions. This must be called for each model name before
-// setmodel may use that model name.
-// Modelindicies precached in SSQC will always be positive. CSQC precaches
-// will be negative if they are not also on the server.
-string(string s) precache_model = #20;
-void(string,...) dprint = #25;
-string(float) ftos = #26;
-string(vector) vtos = #27;
-float(float n) rint = #36;
-float(float n) floor = #37;
-float(float n) ceil = #38;
-// Checks the given point to see what is there. Returns one of the SOLID_*
-// constants. Just because a spot is empty does not mean that the player
-// can stand there due to the size of the player - use tracebox for such tests.
-float(vector pos) pointcontents = #41;
-float(float n) fabs = #43;
-float(string) cvar = #45;
-void(string,...) localcmd = #46;
-entity(entity) nextent = #47;
-// Returns the angles (+x=UP) required to orient an entity to look in the
-// given direction. The 'up' argument is required if you wish to set a roll
-// angle, otherwise it will be limited to just monster-style turning.
-vector(vector fwd, optional vector up) vectoangles = #51;
-void(string var, string val) cvar_set = #72;
-
-//----------------------------------------------------------------------
-// Builtin list
-//----------------------------------------------------------------------
-
-// Returns the angles (+x=UP) required to orient an entity to look in the
-// given direction. The 'up' argument is required if you wish to set a roll
-// angle, otherwise it will be limited to just monster-style turning.
-vector(vector fwd, optional vector up) vectoangles2 = #51;
-float(float angle) sin = #60;
-float(float angle) cos = #61;
-float(float value) sqrt = #62;
-void(entity ent, entity ignore) tracetoss = #64;
-string(entity ent) etos = #65;
-// If e is world, returns the field 'key' from either the serverinfo or the
-// localinfo. If e is a player, returns the value of 'key' from the player's
-// userinfo string. There are a few special exceptions, like 'ip' which is not
-// technically part of the userinfo.
-string(entity e, string key) infokey = #80;
-float(string) stof = #81;
-#define unicast(pl,reli) do{msg_entity = pl; multicast('0 0 0', reli?MULITCAST_ONE_R:MULTICAST_ONE);}while(0)
-// Once the MSG_MULTICAST network message buffer has been filled with data,
-// this builtin is used to dispatch it to the given target, filtering by pvs
-// for reduced network bandwidth.
-void(vector where, float set) multicast = #82;
-// Exactly like traceline, but a box instead of a uselessly thin point.
-// Acceptable sizes are limited by bsp format, q1bsp has strict acceptable
-// size values.
-void(vector start, vector mins, vector maxs, vector end,
- float nomonsters, entity ent) tracebox = #90;
-
-// Returns a vector with random values. Each axis is independantly a value
-// between -1 and 1 inclusive.
-vector() randomvec = #91;
-vector(vector org) getlight = #92;
-// Creates a new cvar on the fly. If it does not already exist, it will be
-// given the specified value. If it does exist, this is a no-op.
-// This builtin has the limitation that it does not apply to configs or
-// commandlines. Such configs will need to use the set or seta commandx
-// causing this builtin to be a noop.
-// In engines that support it, you will generally find the autocvar feature
-// easier and more efficient to use.
-float(string cvarname, string defaultvalue) registercvar = #93;
-
-// Returns the lowest value of its arguments.
-float(float a, float b, ...) min = #94;
-
-// Returns the highest value of its arguments.
-float(float a, float b, ...) max = #95;
-
-// Returns val, unless minimum is higher, or maximum is less.
-float(float minimum, float val, float maximum) bound = #96;
-
-float(float value, float exp) pow = #97;
-
-
-// Equivelent to the find builtin, but instead of comparing strings
-// contents, this builtin compares the raw values. This builtin requires
-// multiple calls in order to scan all entities - set start to the previous
-// call's return value. world is returned when there are no more entities.
-#define findentity findfloat
-entity(entity start, .__variant fld, __variant match) findfloat = #98;
-
-// Checks for an extension by its name (eg: checkextension("FRIK_FILE")
-// says that its okay to go ahead and use strcat). Use
-// cvar("pr_checkextension") to see if this builtin exists.
-float(string extname) checkextension = #99;
-
-// Checks to see if the specified builtin is supported/mapped. This is
-// intended as a way to check for #0 functions, allowing for simple
-// single-builtin functions.
-float(__variant funcref) checkbuiltin = #0;
-
-//----------------------------------------------------------------------
-// 100-199 Range
-//----------------------------------------------------------------------
-
-// Looks to see if the named builtin is valid, and returns the builtin
-// number it exists at.
-float(string builtinname) builtin_find = #100;
-
-float(float value) anglemod = #102;
-
-// Opens a file, typically prefixed with "data/", for either read or
-// write access.
-filestream(string filename, float mode, optional float mmapminsize) fopen = #110;
-
-void(filestream fhandle) fclose = #111;
-// Reads a single line out of the file. The new line character is not
-// returned as part of the string. Returns the null string on EOF (use
-// if not(string) to easily test for this, which distinguishes it from
-// the empty string which is returned if the line being read is blank
-string(filestream fhandle) fgets = #112;
-
-// Writes the given string(s) into the file. For compatibility with fgets,
-// you should ensure that the string is terminated with a \n - this will
-// not otherwise be done for you. It is up to the engine whether dos or
-// unix line endings are actually written.
-void(filestream fhandle, string s, optional string s2, optional string s3,
- optional string s4, optional string s5, optional string s6,
- optional string s7) fputs = #113;
-
-// Changes the current position of the file, if specified.
-// Returns prior position, in bytes.
-#define ftell fseek // c-compat
-int(filestream fhandle, optional int newoffset) fseek = #0;
-
-float(string s) strlen = #114;
-string(string s1, optional string s2, optional string s3, optional string s4, optional string s5, optional string s6, optional string s7, optional string s8) strcat = #115;
-string(string s, float start, float length) substring = #116;
-vector(string s) stov = #117;
-
-// Create a semi-permanent copy of a string that only becomes invalid
-// once strunzone is called on the string (instead of when the engine
-// assumes your string has left scope).
-string(string s, ...) strzone = #118;
-
-// Destroys a string that was allocated by strunzone. Further references
-// to the string MAY crash the game.
-void(string s) strunzone = #119;
-
-//----------------------------------------------------------------------
-// 200-299 FTE Range
-//----------------------------------------------------------------------
-float(float number, float quantity) bitshift = #218;
-void(vector org) te_lightningblood = #219;
-// Returns the 0-based offset of sub within the s1 string, or -1 if sub
-// is not in s1. If startidx is set, this builtin will ignore matches
-// before that 0-based offset.
-float(string s1, string sub, optional float startidx) strstrofs = #221;
-
-// Retrieves the character value at offset 'index'.
-float(string str, float index) str2chr = #222;
-
-// The input floats are considered character values, and are concatenated.
-string(float chr, ...) chr2str = #223;
-
-/* Converts quake chars in the input string amongst different representations.
- * ccase specifies the new case for letters.
- * 0: not changed.
- * 1: forced to lower case.
- * 2: forced to upper case.
- * redalpha and redchars switch between colour ranges.
- * 0: no change.
- * 1: Forced white.
- * 2: Forced red.
- * 3: Forced gold(low) (numbers only).
- * 4: Forced gold (high) (numbers only).
- * 5+6: Forced to white and red alternately.
- * You should not use this builtin in combination with UTF-8.
- */
-string(float ccase, float redalpha, float redchars,
- string str, ...) strconv = #224;
-
-// Pads the string with spaces, to ensure its a specific length (so long
-// as a fixed-width font is used, anyway). If pad is negative, the spaces
-// are added on the left. If positive the padding is on the right.
-string(float pad, string str1, ...) strpad = #225;
-
-// Returns a new tempstring infostring with the named value changed (or
-// added if it was previously unspecified). Key and value may not contain
-// the \ character.
-string(infostring old, string key, string value) infoadd = #226;
-
-// Reads a named value from an infostring. The returned value is a tempstring
-string(infostring info, string key) infoget = #227;
-
-// Compares up to 'len' chars in the two strings. s1ofs allows you to
-// treat s2 as a substring to compare against, or should be 0. Returns 0
-// if the two strings are equal, a negative value if s1 appears numerically
-// lower, and positive if s1 appears numerically higher.
-#define strcmp strncmp
-float(string s1, string s2, optional float len, optional float s1ofs,
- optional float s2ofs) strncmp = #228;
-
-// Compares the two strings without case sensitivity. Returns 0 if they
-// are equal. The sign of the return value may be significant, but should
-// not be depended upon.
-float(string s1, string s2) strcasecmp = #229;
-
-// Compares up to 'len' chars in the two strings without case sensitivity.
-// s1ofs allows you to treat s2 as a substring to compare against, or should
-// be 0. Returns 0 if they are equal. The sign of the return value may be
-// significant, but should not be depended upon.
-float(string s1, string s2, float len, optional float s1ofs,
- optional float s2ofs) strncasecmp = #230;
-
-// Trims the whitespace from the start+end of the string.
-string(string s) strtrim = #0;
-
-// Specifies what data to use in order to send various stats, in a
-// client-specific way. 'num' should be a value between 32 and 127,
-// other values are reserved. 'type' must be set to one of the EV_*
-// constants, one of EV_FLOAT, EV_STRING, EV_INTEGER, EV_ENTITY.
-// fld must be a reference to the field used, each player will be
-// sent only their own copy of these fields.
-void(float num, float type, .__variant fld) clientstat = #232;
-
-// Specifies what data to use in order to send various stats, in a
-// non-client-specific way. num and type are as in clientstat, name
-// however, is the name of the global to read in the form of a
-// string (pass "foo").
-void(float num, float type, string name) globalstat = #233;
-
-// Returns if the given player's network buffer will take multiple network
-// frames in order to clear. If this builtin returns non-zero, you should
-// delay or reduce the amount of reliable (and also unreliable) data that
-// you are sending to that client.
-float(entity player) isbackbuffered = #234;
-
-void(vector org, float count) te_bloodqw = #239;
-float(float a, float n) mod = #245;
-
-// Converts the given string into a true integer. Base 8, 10, or 16 is
-// determined based upon the format of the string.
-int(string) stoi = #259;
-
-// Converts the passed true integer into a base10 string.
-string(int) itos = #260;
-
-// Reads a base-16 string (with or without 0x prefix) as an integer. Bugs
-// out if given a base 8 or base 10 string. :P
-int(string) stoh = #261;
-
-// Formats an integer as a base16 string, with leading 0s and no prefix.
-// Always returns 8 characters.
-string(int) htos = #262;
-
-// Converts the given float into a true integer without depending on
-// extended qcvm instructions.
-int(float) ftoi = #0;
-
-// Converts the given true integer into a float without depending on
-// extended qcvm instructions.
-float(int) itof = #0;
-
-#ifndef dotproduct
-#define dotproduct(v1,v2) ((vector)(v1)*(vector)(v2))
-#endif
-
-// Small helper function to calculate the crossproduct of two vectors.
-vector(vector v1, vector v2) crossproduct = #0;
-
-// Looks up a framegroup from a model by name, avoiding the need for
-// hardcoding. Returns -1 on error.
-float(float modidx, string framename) frameforname = #276;
-
-// Retrieves the duration (in seconds) of the specified framegroup.
-float(float modidx, float framenum) frameduration = #277;
-
-// Triggers a touch events between self and every SOLID_TRIGGER entity that
-// it is in contact with. This should typically just be the triggers touch
-// functions. Also optionally updates the origin of the moved entity.
-void(optional entity ent, optional vector neworigin) touchtriggers = #279;
-
-void(float buf, float fl) WriteFloat = #280;
-string(float modidx, float framenum) frametoname = #284;
-
-// Checks to see if the supplied name is a valid command, cvar, or
-// alias. Returns 0 if it does not exist.
-float(string name) checkcommand = #294;
-
-//======================================================================
-// This is a merge of three (DP/FTE/QSS) engine def files
-// dpextensions+csprogsdefs from SVN ICCULUS site (DP trunk)
-// fteexentions from triptohell website
-// qsextensions from QSS devkit on triptohell website
-//
-// CSQC range #300-#399
-//======================================================================
-
-//----------------------------------------------------------------------
-// DP/FTE extensions ONLY
-//----------------------------------------------------------------------
-// Forgets all rentities, polygons, and temporary dlights.
-// Resets all view properties to their default values.
-void() clearscene = #300;
-void(float mask) addentities = #301;
-// Copies the entity fields into a new rentity for
-// later rendering via addscene
-void(entity ent) addentity = #302;
-// Allows you to override default view properties like
-// viewport, fov, and whether the engine hud will be drawn.
-// Different VF_ values have slightly different arguments,
-// some are vectors, some floats.
-float(float property, ...) setproperty = #303;
-// Draws all entities, polygons, and particles on the rentity list
-// (which were added via addentities or addentity), using the various
-// view properties set via setproperty. There is no ordering dependancy.
-// The scene must generally be cleared again before more entities
-// are added, as entities will persist even over to the next frame.
-// You may call this builtin multiple times per frame, but should
-// only be called from CSQC_UpdateView.
-void() renderscene = #304;
-// Adds a temporary dlight, ready to be drawn via addscene.
-// Cubemap orientation will be read from v_forward/v_right/v_up.
-void(vector org, float radius, vector lightcolours) adddynamiclight = #305;
-void(vector org, float radius, vector lightcolours, float style,
- string cubemapname, float pflags) adddynamiclight2 = #305;
-// Specifies the shader to use for the following polygons, along
-// with optional flags.
-// If is2d, the polygon will be drawn as soon as the EndPolygon
-// call is made, rather than waiting for renderscene. This allows
-// complex 2d effects.
-// FTE = void(string texturename, optional float flags,
-// optional float is2d) R_BeginPolygon = #306;
-void(string texturename, float flag, ...) R_BeginPolygon = #306;
-// Specifies a polygon vertex with its various properties
-void(vector org, vector texcoords, vector rgb,
- float alpha) R_PolygonVertex = #307;
-// Ends the current polygon. At least 3 verticies must have been
-// specified. You do not need to call beginpolygon if you wish to
-// draw another polygon with the same shader
-void() R_EndPolygon = #308;
-// Retrieve a currently-set (typically view) property, allowing you
-// to read the current viewport or other things. Due to cheat protection,
-// certain values may be unretrievable
-// define = FTE version of DP version
-#define getviewprop getproperty
-float(float property) getproperty = #309;
-vector(float property) getpropertyvec = #309;
-// Transform a 2d screen-space point (with depth) into a 3d world-space
-// point, according the various origin+angle+fov etc settings set via
-// setproperty
-vector (vector v) cs_unproject = #310;
-// Transform a 3d world-space point into a 2d screen-space point,
-// according the various origin+angle+fov etc settings set via
-// setproperty
-vector (vector v) cs_project = #311;
-// Draws a 2d line between the two 2d points
-void(float width, vector pos1, vector pos2, vector rgb, float alpha,
- float flag) drawline = #315;
-// Tells the engine that the image is no longer needed.
-// The image will appear to be new the next time its needed
-void(string name) freepic = #319;
-// Draws the specified string without using any markup at all,
-// even in engines that support it.
-// If UTF-8 is globally enabled in the engine, then that encoding
-// is used (without additional markup), otherwise it is raw quake chars.
-// Software engines may assume a size of '8 8 0', rgb='1 1 1',
-// alpha=1, flag&3=0, but it is not an error to draw out of the screen.
-float(vector position, string text, vector scale, vector rgb,
- float alpha, float flag) drawstring = #321;
-// Retrieves the value of the given EV_STRING stat, as a tempstring.
-// Older engines may use 4 consecutive integer stats, with a limit
-// of 15 chars (yes, really. 15.), but FTE Quake uses a separate
-// namespace for string stats and has a much higher length limit.
-string(float stnum) getstats = #332;
-// Retrieves the name of the model based upon a precache index.
-// This can be used to reduce csqc network traffic by enabling
-// model matching
-string(float mdlindex) modelnameforindex = #334;
-// Looks up a named font slot. Matches the actual font name as a last resort.
-// find font by fontname and return it's index
-float findfont(string s) = #356;
-float loadfont(string fontname, string fontmaps, string sizes, float slot, float fix_scale, float fix_voffset) = #357;
-
-//----------------------------------------------------------------------
-// QSS (CSQC Lit) + DP/FTE extensions
-//----------------------------------------------------------------------
-// Checks to see if the image is currently loaded.
-// Engines might lie, or cache between maps.
-float(string name) iscachedpic = #316;
-// Forces the engine to load the named image. If trywad is specified,
-// the specified name must any lack path and extension.
-string(string name, optional float trywad) precache_pic = #317;
-// Returns the dimensions of the named image. Images specified
-// with .lmp should give the original .lmp's dimensions even if
-// texture replacements use a different resolution.
-// define = FTE version of DP version
-#define drawgetimagesize draw_getimagesize
-vector(string picname) draw_getimagesize = #318;
-// Draw the given quake character at the given position.
-// If flag&4, the function will consider the char to be a unicode
-// char instead (or display as a ? if outside the 32-127 range).
-// size should normally be something like '8 8 0'.
-// rgb should normally be '1 1 1' and alpha normally 1.
-// Software engines may assume the named defaults.
-// Note that ALL text may be rescaled on the X axis due to
-// variable width fonts. The X axis may even be ignored completely.
-float(vector position, float character, vector scale, vector rgb,
- float alpha, float flag) drawcharacter = #320;
-// Draws an shader within the given 2d screen box. Software engines
-// may omit support for rgb+alpha, but must support rescaling,
-// and must clip to the screen without crashing
-// flag = draw method; 0=normal, 1=additive, 2=modulate, 3=modulate2
-float(vector position, string pic, vector size, vector rgb,
- float alpha, float flag) drawpic = #322;
-// Draws a solid block over the given 2d box, with given colour,
-// alpha, and blend mode (specified via flags).
-// flags&3=0 simple blend flags&3=1 additive blend
-float(vector position, vector size, vector rgb,
- float alpha, float flag) drawfill = #323;
-// Specifies a 2d clipping region (aka: scissor test).
-// 2d draw calls will all be clipped to this 2d box,
-// the area outside will not be modified by any
-// 2d draw call (even 2d polygons).
-void(float x, float y, float width, float height) drawsetcliparea = #324;
-// Reverts the scissor/clip area to the whole screen
-void(void) drawresetcliparea = #325;
-// Draws a string, interpreting markup and recolouring as appropriate
-// QSS/FTE = drawstring, DP = drawcolorcodedstring/drawcolorcodedstring2
-// float(vector position, string text, vector size, vector rgb, float alpha, float drawflag) drawstring = #326;
-float(vector position, string text, vector scale,
- float alpha, float flag) drawcolorcodedstring = #326;
-vector(vector position, string text, vector scale, vector rgb,
- float alpha, float flag) drawcolorcodedstring2 = #326;
-// Calculates the width of the screen in virtual pixels.
-// If usecolours is 1, markup that does not affect the string
-// width will be ignored. Will always be decoded as UTF-8 if
-// UTF-8 is globally enabled.
-// If the char size is not specified, '8 8 0' will be assumed
-// float(string text, float usecolours, optional vector fontsize) stringwidth = #327;
-// QSS/FTE = float(string text, float usecolours, optional vector fontsize) stringwidth = #327;
-float(string text, float allowColorCodes, vector size) stringwidth = #327;
-// Draws a rescaled subsection of an image to the screen
-// QSS/FTE = void(vector pos, vector sz, string pic, vector srcpos, vector srcsz, vector rgb, float alpha, optional float drawflag) drawsubpic = #328;
-float(vector position, vector size, string pic, vector srcPosition,
- vector srcSize, vector rgb, float alpha, float flag) drawsubpic = #328;
-// Nasty convoluted DP extension. Typically returns deltas instead
-// of positions. Use CSQC_InputEvent for such things in csqc mods
-vector() getmousepos = #344;
-// Looks up an input frame from the log, setting the input_*
-// globals accordingly.
-// The sequence number range used for prediction should normally
-// be servercommandframe < sequence <= clientcommandframe.
-// The sequence equal to clientcommandframe will change between
-// input frames
-float(float framenum) getinputstate = #345;
-// Perform the engine's standard player movement prediction upon
-// the given entity using the input_* globals to describe movement
-// this may or may not take a player ent
-void(...) runstandardplayerphysics = #347;
-// Sets the position of the view, as far as the audio subsystem is
-// concerned. This should be called once per CSQC_UpdateView as it
-// will otherwise revert to default. For reverbtype,
-// see setup_reverb or treat as 'underwater'
-// FTE = void(vector origin, vector forward, vector right, vector up,
-// optional float reverbtype) SetListener = #351;
-void(vector origin, vector forward, vector right, vector up) SetListener = #351;
-
-//----------------------------------------------------------------------
-// This is a bit of mess with DP (below) and FTE/QSS (further below)
-// Going in different directions with the CSQC standard
-// This is all about #330 returning an INT instead of a FLOAT
-// As getstatf has optional parameters it will still work fine with DP
-// Going with the FTE/QSS direction as it still works for DP
-//----------------------------------------------------------------------
-//float(float stnum) getstatf = #330;
-// Can optionally take first bit and count
-//float(float stnum, ...) getstati = #331;
-
-// Retrieves the numerical value of the given EV_INTEGER or EV_ENTITY stat.
-// Use getstati_punf if you wish to type-pun a float stat as an int to
-// avoid truncation issues in DP
-#define getstati_punf(stnum) (float)(__variant)getstati(stnum)
-int(float stnum) getstati = #330;
-#define getstatbits getstatf
-float(float stnum, optional float firstbit,
- optional float bitcount) getstatf = #331;
-
-//----------------------------------------------------------------------
-// QSS (CSQC Lit) + DP/FTE extensions
-//----------------------------------------------------------------------
-// Sets a model by precache index instead of by name.
-// Otherwise identical to setmodel.
-void(entity e, float mdlindex) setmodelindex = #333;
-// Part of DP_ENT_TRAILEFFECTNUM, FTE_SV_POINTPARTICLES
-// Precaches the named particle effect. If your effect name is of
-// the form 'foo.bar' then particles/foo.cfg will be loaded by the
-// client if foo.bar was not already defined.
-// Different engines will have different particle systems, this
-// specifies the QC API only
-float(string effectname) particleeffectnum = #335;
-// Part of FTE_SV_POINTPARTICLES
-// Draws the given effect between the two named points. If ent is
-// not world, distances will be cached in the entity in order to
-// avoid framerate dependancies. The entity is not otherwise used
-void(float effectnum, entity ent, vector start, vector end)
- trailparticles = #336;
-// Part of FTE_SV_POINTPARTICLES
-// Spawn a load of particles from the given effect at the given
-// point traveling or aiming along the direction specified.
-// The number of particles are scaled by the count argument.
-// For regular particles, the dir vector is multiplied by the
-// 'veladd' property (while orgadd will push the particles along it).
-// Decals will use it as a hint to align to the correct surface.
-// In both cases, it should normally be a unit vector, but other
-// lengths will still work. If it has length 0 then FTE will
-// assume downwards
-void(float effectnum, vector origin,
- optional vector dir, optional float count) pointparticles = #337;
-
-// conflicts with void(entity client, string s1) centerprint = #73;
-void(string s, ...) csqc_centerprint = #338;
-// Print into the center of the screen just as ssqc's centerprint
-// would appear
-void(string s, ...) cprint = #338;
-// This is identical to dprint except that it always prints
-// regardless of the developer cvar. Same number as in EXT_CSQC
-// Unconditionally print on the local system's console, even in
-// ssqc (doesn't care about the value of the developer cvar)
-void(string s, ...) print = #339;
-// Returns a hunam-readable name for the given keycode, as a tempstring
-string(float keynum) keynumtostring = #340;
-// Looks up the key name in the same way that the bind command would,
-// returning the keycode for that key
-float(string keyname) stringtokeynum = #341;
-// Returns the current binding for the given key (returning only the
-// command executed when no modifiers are pressed)
-string(float key, float bindmap) getkeybind_bindmap = #342;
-string(float keynum) getkeybind = #342;
-// Pass TRUE if you want the engine to release the mouse cursor
-// (absolute input events + touchscreen mode). Pass FALSE if you
-// want the engine to grab the cursor (relative input
-// events + standard looking). If the image name is specified,
-// the engine will use that image for a cursor (use an empty
-// string to clear it again), in a way that will not conflict
-// with the console. Images specified this way will be hardware
-// accelerated, if supported by the platform/port
-// QSS/FTE = void(float usecursor, optional string cursorimage,
-// optional vector hotspot, optional float scale) setcursormode = #343;
-void(float usecursor) setcursormode = #343;
-// Reports the cursor mode this module previously attempted to use.
-// If 'effective' is true, reports the cursor mode currently active
-// (if was overriden by a different module which has precidence,
-// for instance, or if there is only a touchscreen and no mouse)
-float(float effective) getcursormode = #0;
-// Temporarily scales the player's mouse sensitivity based upon
-// something like zoom, avoiding potential cvar saving and thus
-// corruption
-void(float sens) setsensitivityscale = #346;
-// Look up a player's userinfo, to discover things like their name,
-// topcolor, bottomcolor, skin, team, *ver.
-// Also includes scoreboard info like frags, ping, pl, userid,
-// entertime, as well as voipspeaking and voiploudness
-string(float playernum, string keyname) getplayerkeyvalue = #348;
-// Cheaper version of getplayerkeyvalue that avoids the need for
-// so many tempstrings
-float(float playernum, string keyname,
- optional float assumevalue) getplayerkeyfloat = #0;
-// Returns if the client is currently playing a demo or not
-float() isdemo = #349;
-// Returns if the client is acting as the server (aka: listen server)
-float() isserver = #350;
-// Register the given console command, for easy console use.
-// Console commands that are later used will invoke CSQC_ConsoleCommand
-void(string cmdname) registercommand = #352;
-// Quickly check to see if the entity is currently free. This
-// function is only valid during the two-second non-reuse window,
-// after that it may give bad results. Try one second to make it
-// more robust.
-float(entity ent) wasfreed = #353;
-// Look up a key in the server's public serverinfo string
-string(string key) serverkey = #354;
-// Version of serverkey that returns the value as a float
-// (which avoids tempstrings)
-float(string key, optional float assumevalue) serverkeyfloat = #0;
-// Use proper case; refer to the id1 Write* functions!
-float() ReadByte = #360;
-float() ReadChar = #361;
-float() ReadShort = #362;
-float() ReadLong = #363;
-float() ReadCoord = #364;
-float() ReadAngle = #365;
-string() ReadString = #366;
-float() ReadFloat = #367;
-float() readentitynum = #368;
-// Reads a 32bit int without any conversions to float, otherwise
-// interchangable with readlong.
-int() ReadInt = #0:readint;
-
-// Replaces the title of the game window, as seen when
-// task switching or just running in windowed mode
-void(string newcaption) setwindowcaption = #0;
-
-// Specifies a per-modelindex callback to listen for engine-networking
-// entity updates. Such entities are automatically interpolated by the
-// engine (unless flags specifies not to).
-// The various standard entity fields will be overwritten each frame
-// before the updatecallback function is called.
-float(string modelname, float(float isnew) updatecallback, float flags) deltalisten = #371;
-
-//----------------------------------------------------------------------
-// 400-499 DP Range
-//----------------------------------------------------------------------
-// Copies all fields from one entity to another.
-entity(entity from, optional entity to) copyentity = #400;
-
-// Changes a player's colours. The bits 0-3 are the lower/trouser colour,
-// bits 4-7 are the upper/shirt colours.
-void(entity ent, float colours) setcolors = #401;
-
-entity(.string field, string match) findchain = #402;
-entity(.float fld, float match) findchainfloat = #403;
-void(vector org, vector dir, float count) te_blood = #405;
-void(vector mincorner, vector maxcorner, vector vel,
- float howmany, float color) te_particlerain = #409;
-void(vector mincorner, vector maxcorner, vector vel,
- float howmany, float color) te_particlesnow = #410;
-void(vector org, optional float count) te_gunshot = #418;
-void(vector org) te_spike = #419;
-void(vector org) te_superspike = #420;
-void(vector org) te_explosion = #421;
-void(vector org) te_tarexplosion = #422;
-void(vector org) te_wizspike = #423;
-void(vector org) te_knightspike = #424;
-void(vector org) te_lavasplash = #425;
-void(vector org) te_teleport = #426;
-void(vector org, float color, float colorlength) te_explosion2 = #427;
-void(entity own, vector start, vector end) te_lightning1 = #428;
-void(entity own, vector start, vector end) te_lightning2 = #429;
-void(entity own, vector start, vector end) te_lightning3 = #430;
-void(entity own, vector start, vector end) te_beam = #431;
-void(vector dir) vectorvectors = #432;
-float(entity e, float s) getsurfacenumpoints = #434;
-vector(entity e, float s, float n) getsurfacepoint = #435;
-vector(entity e, float s) getsurfacenormal = #436;
-string(entity e, float s) getsurfacetexture = #437;
-float(entity e, vector p) getsurfacenearpoint = #438;
-vector(entity e, float s, vector p) getsurfaceclippedpoint = #439;
-void(entity e, string s) clientcommand = #440;
-float(string s) tokenize = #441;
-string(float n) argv = #442;
-float() argc = #0;
-void(entity e, entity tagentity, string tagname) setattachment = #443;
-
-// initiate a filesystem scan based upon filenames. Be sure to call
-// search_end on the returned handle.
-searchhandle(string pattern, optional float caseinsensitive,
- optional float quiet) search_begin = #444;
-
-void(searchhandle handle) search_end = #445;
-
-// Retrieves the number of files that were found.
-float(searchhandle handle) search_getsize = #446;
-
-// Retrieves name of one of the files that was found by the initial search.
-string(searchhandle handle, float num) search_getfilename = #447;
-
-// Retrieves the size of one of the files that was found by the initial search.
-float(searchhandle handle, float num) search_getfilesize = #0;
-
-// Retrieves modification time of one of the files in %Y-%m-%d %H:%M:%S format.
-string(searchhandle handle, float num) search_getfilemtime = #0;
-
-string(string cvarname) cvar_string = #448;
-entity(entity start, .float fld, float match) findflags = #449;
-entity(.float fld, float match) findchainflags = #450;
-void(entity player) dropclient = #453;
-
-// Spawns a dummy player entity.
-// Note that such dummy players will be carried from one map to the next.
-// Warning: DP_SV_CLIENTCOLORS DP_SV_CLIENTNAME are not implemented in
-// quakespasm, so use KRIMZON_SV_PARSECLIENTCOMMAND's clientcommand builtin
-// to change the bot's name/colours/skin/team/etc, in the same way that
-// clients would ask.
-entity() spawnclient = #454;
-
-float(entity client) clienttype = #455;
-void(float target, string str) WriteUnterminatedString = #456;
-entity(float entnum) edict_num = #459;
-strbuf() buf_create = #460;
-void(strbuf bufhandle) buf_del = #461;
-float(strbuf bufhandle) buf_getsize = #462;
-void(strbuf bufhandle_from, strbuf bufhandle_to) buf_copy = #463;
-void(strbuf bufhandle, float sortprefixlen, float backward) buf_sort = #464;
-string(strbuf bufhandle, string glue) buf_implode = #465;
-string(strbuf bufhandle, float string_index) bufstr_get = #466;
-void(strbuf bufhandle, float string_index, string str) bufstr_set = #467;
-float(strbuf bufhandle, string str, float order) bufstr_add = #468;
-void(strbuf bufhandle, float string_index) bufstr_free = #469;
-float(float s) asin = #471;
-float(float c) acos = #472;
-float(float t) atan = #473;
-float(float c, float s) atan2 = #474;
-float(float a) tan = #475;
-
-// Returns the number of characters in the string after any colour codes
-// or other markup has been parsed.
-float(string s) strlennocol = #476;
-
-// Flattens any markup/colours, removing them from the string.
-string(string s) strdecolorize = #477;
-
-string(float uselocaltime, string format, ...) strftime = #478;
-float(string s, string separator1, ...) tokenizebyseparator = #479;
-string(string s) strtolower = #480;
-string(string s) strtoupper = #481;
-string(string s) cvar_defstring = #482;
-void(vector origin, string sample, float volume,
- float attenuation) pointsound = #483;
-string(string search, string replace, string subject) strreplace = #484;
-string(string search, string replace, string subject) strireplace = #485;
-vector(entity e, float s, float n, float a) getsurfacepointattribute = #486;
-float(float caseinsensitive, string s, ...) crc16 = #494;
-float(string name) cvar_type = #495;
-
-// Gives the number of named entity fields. Note that this is not the size
-// of an entity, but rather just the number of unique names (ie: vectors
-// use 4 names rather than 3).
-float() numentityfields = #496;
-
-// Find a field index by name.
-float(string fieldname) findentityfield = #0;
-
-// Returns a field value that can be directly used to read entity fields.
-// Be sure to validate the type with entityfieldtype before using.
-typedef .__variant field_t;
-field_t(float fieldnum) entityfieldref = #0;
-
-// Retrieves the name of the given entity field.
-string(float fieldnum) entityfieldname = #497;
-
-// Provides information about the type of the field specified by the field num.
-// Returns one of the EV_ values.
-float(float fieldnum) entityfieldtype = #498;
-
-string(float fieldnum, entity ent) getentityfieldstring = #499;
-
-//----------------------------------------------------------------------
-// 500-599 Range
-//----------------------------------------------------------------------
-float(float fieldnum, entity ent, string s) putentityfieldstring = #500;
-
-// Returns the pak file name that contains the file specified.
-// progs/player.mdl will generally return something like 'pak0.pak'.
-// If makereferenced is true, clients will automatically be told that
-// the returned package should be pre-downloaded and used, even if
-// allow_download_refpackages is not set.
-string(string filename, optional float makereferenced) whichpack = #503;
-
-string(string in) uri_escape = #510;
-string(string in) uri_unescape = #511;
-float(entity ent) num_for_edict = #512;
-
-// Tokenize a string exactly as the console's tokenizer would do so.
-// The regular tokenize builtin became bastardized for convienient
-// string parsing, which resulted in a large disparity that can be
-// exploited to bypass checks implemented in a naive
-// SV_ParseClientCommand function, therefore you can use this builtin
-// to make sure it exactly matches.
-float(string str) tokenize_console = #514;
-
-// Returns the character index that the tokenized arg started at.
-float(float idx) argv_start_index = #515;
-
-// Returns the character index that the tokenized arg stopped at.
-float(float idx) argv_end_index = #516;
-
-// Retrieves the description of a cvar, which might be useful for tooltips
-// or help files. This may still not be useful.
-string(string cvarname) cvar_description = #518;
-
-float(optional float timetype) gettime = #519;
-
-// Returns a list of keycodes that perform the given console command in a
-// format that can only be parsed via tokenize (NOT tokenize_console).
-// This always returns at least two values - if only one key is actually
-// bound, -1 will be returned. The bindmap argument is listed for
-// compatibility with dp-specific defs, but is ignored in FTE.
-string(string command, optional float bindmap) findkeysforcommand = #521;
-
-// Returns a list of key bindings in keyname format instead of keynums.
-// Use tokenize to parse. This list may contain modifiers. May return
-// large numbers of keys.
-string(string command, optional float bindmap) findkeysforcommandex = #0;
-
-// Determines the logarithm of the input value according to the specified base.
-// This can be used to calculate how much something was shifted by.
-float(float v, optional float base) log = #532;
-
-// Appends the named file into a string buffer (which must have been
-// created in advance). The return value merely says whether the file
-// was readable.
-float(string filename, strbuf bufhandle) buf_loadfile = #535;
-
-// Writes the contents of a string buffer onto the end of the supplied
-// filehandle (you must have already used fopen). Additional optional
-// arguments permit you to constrain the writes to a subsection of the
-// stringbuffer.
-float(filestream filehandle, strbuf bufhandle, optional float startpos,
- optional float numstrings) buf_writefile = #536;
-
-//----------------------------------------------------------------------
-// 600-699 Range
-//----------------------------------------------------------------------
-
-// Invokes the named function. The function name is always passed as the
-// last parameter and must always be present. The others are passed to
-// the named function as-is
-void(.../*, string funcname*/) callfunction = #605;
-
-// Returns true if the named function exists and can be called with the
-// callfunction builtin.
-float(string s) isfunction = #607;
-
-// Reads a single entity's fields into an already-spawned entity.
-// s should contain field pairs like in a saved game: {"foo1" "bar" "foo2" "5"}.
-// Returns <=0 on failure, otherwise returns the offset in the string that
-// was read to.
-float(entity e, string s, optional float offset) parseentitydata = #613;
-
-string(string fmt, ...) sprintf = #627;
-float(entity e, float s) getsurfacenumtriangles = #628;
-vector(entity e, float s, float n) getsurfacetriangle = #629;
-

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

Diff qc/csqc/csqc_defsclient.qc

diff --git a/qc/csqc/csqc_defsclient.qc b/qc/csqc/csqc_defsclient.qc
deleted file mode 100644
index 39237c9..0000000
--- a/qc/csqc/csqc_defsclient.qc
+++ /dev/null
@@ -1,426 +0,0 @@
-//======================================================================
-// Author : Simon "Sock" OCallaghan
-// Website: www.simonoc.com
-//
-// Based on the qsextensions.qc file in the QSS devkit
-// This is a special defs file for csprogs.dat ONLY
-// Requires csqc_defs.qc file for 300-399 range commands
-//
-//======================================================================
-
-void(string cmd) SV_ParseClientCommand;
-void() EndFrame;
-
-// Core CSQC functions called by engine
-void(float apilevel, string enginename, float engineversion) CSQC_Init;
-void(vector virtsize, float showscores) CSQC_DrawHud;
-void(vector virtsize, float showscores) CSQC_DrawScores;
-float(float evtype, float scanx, float chary, float devid) CSQC_InputEvent;
-float(float save, float take, vector dir) CSQC_Parse_Damage;
-float(string cmdstr) CSQC_ConsoleCommand;
-void() CSQC_Parse_Event;
-void(float isnew) CSQC_Ent_Update;
-
-// globals
-float nocsqc; // CSQC State (0=on, 1=off)
-float sitems; // CSQC copy of .items
-float sitems2; // CSQC copy of .items2 (or serverflags)
-float sweapon; // CSQC copy of .weapon
-float shealth; // CSQC copy of .health
-
-float painfinishtime; // Track player damage for hud face
-
-float intermission; // in intermission
-float intermission_time; // when the intermission started
-
-float numclientseats; // coop or splitscreen?
-float maxclients; // maximum players possible on this server
-float cltime; // increases regardless of pause or game speed
-
-float player_localnum; // Player slot that is assigned to us
-float player_localentnum; // Entity number that csqc is attached to
-
-float sb_showscores; // Show lower tab scores
-
-// This is the input-frame sequence. frames < clientcommandframe have been
-// sent to the server. frame==clientcommandframe is still being generated
-// and can still change.
-float clientcommandframe;
-// This is the input-frame that was last acknowledged by the server.
-// Input frames greater than this should be applied to the player's entity.
-float servercommandframe;
-
-string CSQC_PING = "csqcping"; // Test command to check if CSCQ alive
-
-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';
-
-entity viewentity; // camera -- CEV
-vector view_origin; // origin for viewentity -- CEV
-vector view_angles; // +x=DOWN
-
-entity player_local; // handle to the local player entity
-
-vector player_org; // prediction globals; from CSQCTest -- CEV
-vector player_vel;
-float player_flags;
-float player_doublejump_timer;
-float player_groundboost_timer;
-float player_pmflags;
-float player_sequence;
-float player_step;
-float player_steptime;
-float player_step_oldz;
-vector pmove_error;
-float pmove_errortime;
-float pmove_frame;
-
-// latched globals - re-set every StartFrame
-float frame_airstep;
-float frame_bigcoords;
-float frame_clrun;
-float frame_gravity;
-float frame_maxvelocity;
-float frame_nostep;
-float frame_standardphysics;
-float frame_walljump;
-
-//----------------------------------------------------------------------
-// Extra fields
-//----------------------------------------------------------------------
-.float gravity;
-// if defined, overrides serverflags for displaying runes on the hud
-//.float items2;
-// can also be set with 'traileffect' from a map editor
-//.float traileffectnum;
-// can also be set with 'traileffect' from a map editor
-.float emiteffectnum;
-// describes which forward/right/up keys the player is holidng
-.vector movement;
-// attaches this entity to the specified player's view.
-// invisible to other players
-.entity viewmodelforclient;
-.float scale; // rescales the etntiy
-.float alpha; // entity opacity
-.vector colormod; // tints the entity's colours
-.entity tag_entity;
-.float tag_index;
-.float button3;
-.float button4;
-.float button5;
-.float button6;
-.float button7;
-.float button8;
-.float viewzoom; // rescales the user's fov
-
-// provides additional modelflags to use (effects&EF_NOMODELFLAGS to replace
-// the original model's)
-.float modelflags;
-
-.float ext_csqc; // Client Server Quake C HUD alive!
-
-.float entnum; // The entity number as its known on the server
-
-// Called by addentities after the filter and before the entity is actually
-// drawn. Do your interpolation and animation in here. Should return one of
-// the PREDRAW_* constants.
-.float() predraw;
-
-.float renderflags;
-
-// The model name that was set via setmodel, in theory. Often, this is
-// cleared to null to prevent the engine from being seen by clients
-// while not changing modelindex. This behaviour allows inline models
-// to remain solid yet be invisible.
-.string model;
-// The current frame the entity is meant to be displayed in. In CSQC,
-// note the lerpfrac and frame2 fields as well. if it specifies a
-// framegroup, the framegroup will autoanimate in ssqc, but not in csqc.
-.float frame;
-// The absolute time into the animation/framegroup specified by .frame.
-.float frame1time;
-// The alternative frame. Visible only when lerpfrac is set to 1.
-.float frame2;
-// The absolute time into the animation/framegroup specified by .frame2.
-.float frame2time;
-.float frameold;
-// If 0, use frame1 only. If 1, use frame2 only.
-// Mix them together for values between.
-.float lerpfrac;
-.float lerptime;
-
-// .float oldframe;
-
-.void() removefunc;
-.string oldskin;
-
-.float drawmask; // Acts as a filter in the addentities call.
-
-//----------------------------------------------------------------------
-// Constants
-//----------------------------------------------------------------------
-
-const float FALSE = 0;
-const float TRUE = 1;
-
-const float IE_KEYDOWN = 0;
-const float IE_KEYUP = 1;
-const float IE_MOUSEDELTA = 2;
-const float IE_MOUSEABS = 3;
-const float IE_JOYAXIS = 6;
-
-#define ERRORTIME 20
-#define STEPTIME 8
-
-#define STAT_HEALTH 0
-#define STAT_WEAPONMODEL 2 // weapon model idx as evalutated by server code
-#define STAT_AMMO 3
-#define STAT_ARMOR 4
-#define STAT_WEAPONFRAME 5
-#define STAT_SHELLS 6
-#define STAT_NAILS 7
-#define STAT_ROCKETS 8
-#define STAT_CELLS 9
-#define STAT_ACTIVEWEAPON 10 // the one shown on the hud
-#define STAT_TOTALSECRETS 11
-#define STAT_TOTALMONSTERS 12
-#define STAT_FOUNDSECRETS 13
-#define STAT_KILLEDMONSTERS 14
-#define STAT_ITEMS 15
-#define STAT_VIEWHEIGHT 16 // player.view_ofs_z
-
-enumflags {
- RF_VIEWMODEL,
- RF_EXTERNALMODEL,
- RF_DEPTHHACK,
- RF_ADDATIVE,
- RF_USEAXIS
-};
-
-// edict.flags
-const float FL_FLY = 1;
-const float FL_SWIM = 2;
-const float FL_CLIENT = 8; // set for all client edicts
-const float FL_INWATER = 16; // for enter / leave water splash
-const float FL_MONSTER = 32;
-const float FL_GODMODE = 64; // player cheat
-const float FL_NOTARGET = 128; // player cheat
-const float FL_ITEM = 256; // extra wide size for bonus items
-const float FL_ONGROUND = 512; // standing on something
-const float FL_PARTIALGROUND = 1024; // not all corners are valid
-const float FL_WATERJUMP = 2048; // player jumping out of water
-const float FL_JUMPRELEASED = 4096; // for jump debouncing
-const float FL_DOUBLEJUMPED = 8192; // player has doublejumped
-const float FL_WALLJUMP = 16384; // player has jumped off a wall
-const float FL_NOCENTERPRINT = 65536; // don't centerprint entity's message
- // field when its targets are used
-// edict.movetype values
-const float MOVETYPE_NONE = 0; // never moves
-// const float MOVETYPE_ANGLENOCLIP = 1;
-// const float MOVETYPE_ANGLECLIP = 2;
-const float MOVETYPE_WALK = 3; // players only
-const float MOVETYPE_STEP = 4; // discrete, not real time unless fall
-const float MOVETYPE_FLY = 5;
-const float MOVETYPE_TOSS = 6; // gravity
-const float MOVETYPE_PUSH = 7; // no clip to world, push and crush
-const float MOVETYPE_NOCLIP = 8;
-const float MOVETYPE_FLYMISSILE = 9; // fly with extra size against monsters
-const float MOVETYPE_BOUNCE = 10;
-const float MOVETYPE_BOUNCEMISSILE = 11;// bounce with extra size
-const float MOVETYPE_FOLLOW = 12; // supported extension
-
-// edict.solid values
-const float SOLID_NOT = 0; // no interaction with other objects
-const float SOLID_TRIGGER = 1; // touch on edge, but not blocking
-const float SOLID_BBOX = 2; // touch on edge, block
-const float SOLID_SLIDEBOX = 3; // touch on edge, but not an onground
-const float SOLID_BSP = 4; // bsp clip, touch on edge, block
-const float SOLID_CORPSE = 5; // supported extension
-
-// point content values
-const float CONTENT_EMPTY = -1;
-const float CONTENT_SOLID = -2;
-const float CONTENT_WATER = -3;
-const float CONTENT_SLIME = -4;
-const float CONTENT_LAVA = -5;
-const float CONTENT_SKY = -6;
-
-// entity effects
-const float EF_BRIGHTFIELD = 1;
-const float EF_MUZZLEFLASH = 2;
-const float EF_BRIGHTLIGHT = 4;
-const float EF_DIMLIGHT = 8;
-
-//----------------------------------------------------------------------
-// Valid as a return value from the predraw function. Returning this will
-// simply move on to the next entity without the autoadd behaviour, so can
-// be used for particle/invisible/special entites, or entities that were
-// explicitly drawn with addentity.
-//----------------------------------------------------------------------
-const float PREDRAW_NEXT = 1;
-
-//----------------------------------------------------------------------
-// These constants are only used in CSQC_UpdateView
-//----------------------------------------------------------------------
-const float MASK_ENGINE = 1;
-const float MASK_VIEWMODEL = 2;
-const float MASK_NORMAL = 4;
-
-//----------------------------------------------------------------------
-const float VF_MIN = 1;
-const float VF_SIZE = 4;
-const float VF_ORIGIN = 11;
-const float VF_ORIGIN_X = 12;
-const float VF_ORIGIN_Y = 13;
-const float VF_ORIGIN_Z = 14;
-const float VF_ANGLES = 15;
-const float VF_ANGLES_X = 16;
-const float VF_ANGLES_Y = 17;
-const float VF_ANGLES_Z = 18;
-const float VF_DRAWWORLD = 19;
-const float VF_DRAWENGINESBAR = 20;
-const float VF_DRAWCROSSHAIR = 21;
-const float VF_CL_VIEWANGLES = 33;
-const float VF_CL_VIEWANGLES_X = 34;
-const float VF_CL_VIEWANGLES_Y = 35;
-const float VF_CL_VIEWANGLES_Z = 36;
-const float VF_VIEWENTITY = 206;
-
-//----------------------------------------------------------------------
-// Supported Extension Constants
-//----------------------------------------------------------------------
-const float CLIENTTYPE_DISCONNECT = 0;
-const float CLIENTTYPE_REAL = 1;
-const float CLIENTTYPE_BOT = 2;
-const float CLIENTTYPE_NOTCLIENT = 3;
-const float EF_NOSHADOW = 0x1000;
-// the standard modelflags from the model are ignored
-const float EF_NOMODELFLAGS = 0x800000;
-const float MF_ROCKET = 0x1;
-const float MF_GRENADE = 0x2;
-const float MF_GIB = 0x4;
-const float MF_ROTATE = 0x8;
-const float MF_TRACER = 0x10;
-const float MF_ZOMGIB = 0x20;
-const float MF_TRACER2 = 0x40;
-const float MF_TRACER3 = 0x80;
-const float MSG_MULTICAST = 4;
-const float MULTICAST_ALL = 0;
-const float MULTICAST_PVS = 2;
-const float MULTICAST_ONE = 6;
-const float MULTICAST_ALL_R = 3;
-const float MULTICAST_PVS_R = 5;
-const float MULTICAST_ONE_R = 7;
-const float MULTICAST_INIT = 8;
-const float FILE_READ = 0;
-const float FILE_APPEND = 1;
-const float FILE_WRITE = 2;
-
-//----------------------------------------------------------------------
-// Keyboard input values
-//----------------------------------------------------------------------
-const float K_TAB = 9;
-const float K_ENTER = 13;
-const float K_ESCAPE = 27;
-const float K_SPACE = 32;
-const float K_BACKSPACE = 127;
-const float K_UPARROW = 128;
-const float K_DOWNARROW = 129;
-const float K_LEFTARROW = 130;
-const float K_RIGHTARROW = 131;
-const float K_ALT = 132;
-const float K_CTRL = 133;
-const float K_SHIFT = 134;
-const float K_F1 = 135;
-const float K_F2 = 136;
-const float K_F3 = 137;
-const float K_F4 = 138;
-const float K_F5 = 139;
-const float K_F6 = 140;
-const float K_F7 = 141;
-const float K_F8 = 142;
-const float K_F9 = 143;
-const float K_F10 = 144;
-const float K_F11 = 145;
-const float K_F12 = 146;
-const float K_INS = 147;
-const float K_DEL = 148;
-const float K_PGDN = 149;
-const float K_PGUP = 150;
-const float K_HOME = 151;
-const float K_END = 152;
-const float K_KP_SLASH = 168;
-const float K_KP_STAR = 169;
-const float K_KP_MINUS = 170;
-const float K_KP_HOME = 164;
-const float K_KP_UPARROW = 165;
-const float K_KP_PGUP = 166;
-const float K_KP_PLUS = 171;
-const float K_KP_LEFTARROW = 161;
-const float K_KP_5 = 162;
-const float K_KP_RIGHTARROW = 163;
-const float K_KP_END = 158;
-const float K_KP_DOWNARROW = 159;
-const float K_KP_PGDN = 160;
-const float K_KP_ENTER = 172;
-const float K_KP_INS = 157;
-const float K_KP_DEL = 167;
-const float K_COMMAND = -170;
-const float K_MOUSE1 = 512;
-const float K_MOUSE2 = 513;
-const float K_MOUSE3 = 514;
-const float K_JOY1 = 768;
-const float K_JOY2 = 769;
-const float K_JOY3 = 770;
-const float K_JOY4 = 771;
-const float K_AUX1 = 784;
-const float K_AUX2 = 785;
-const float K_AUX3 = 786;
-const float K_AUX4 = 787;
-const float K_AUX5 = 788;
-const float K_AUX6 = 789;
-const float K_AUX7 = 790;
-const float K_AUX8 = 791;
-const float K_AUX9 = 792;
-const float K_AUX10 = 793;
-const float K_AUX11 = 794;
-const float K_AUX12 = 795;
-const float K_AUX13 = 796;
-const float K_AUX14 = 797;
-const float K_AUX15 = 798;
-const float K_AUX16 = 799;
-const float K_AUX17 = 800;
-const float K_AUX18 = 801;
-const float K_AUX19 = 802;
-const float K_AUX20 = 803;
-const float K_AUX21 = 804;
-const float K_AUX22 = 805;
-const float K_AUX23 = 806;
-const float K_AUX24 = 807;
-const float K_AUX25 = 808;
-const float K_AUX26 = 809;
-const float K_AUX27 = 810;
-const float K_AUX28 = 811;
-const float K_AUX29 = 812;
-const float K_AUX30 = 813;
-const float K_AUX31 = 814;
-const float K_AUX32 = 815;
-const float K_MWHEELUP = 515;
-const float K_MWHEELDOWN = 516;
-const float K_MOUSE4 = 517;
-const float K_MOUSE5 = 518;
-const float K_LTHUMB = 822;
-const float K_RTHUMB = 823;
-const float K_LSHOULDER = 824;
-const float K_RSHOULDER = 825;
-const float K_ABUTTON = 826;
-const float K_BBUTTON = 827;
-const float K_XBUTTON = 828;
-const float K_YBUTTON = 829;
-const float K_LTRIGGER = 830;
-const float K_RTRIGGER = 831;
-const float K_PAUSE = 153;

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

Diff qc/csqc/csqc_entrypoints.qc

diff --git a/qc/csqc/csqc_entrypoints.qc b/qc/csqc/csqc_entrypoints.qc
deleted file mode 100644
index b72b155..0000000
--- a/qc/csqc/csqc_entrypoints.qc
+++ /dev/null
@@ -1,351 +0,0 @@
-//==============================================================================
-// CSQC_ENTRYPOINTS
-//==============================================================================
-void(float isnew) PlayerUpdate;
-
-//----------------------------------------------------------------------
-// Stubs for extra CSQC functions (not all supported)
-//----------------------------------------------------------------------
-
-// Can query or check anything types on the console here
-float(string str) CSQC_ConsoleCommand =
-{
- tokenize_console (str);
- return FALSE;
-};
-
-// Can query/check keyboard/mouse/joystick input with this function
-// For key events, scanx is one of the KEY_* values
-// chary is the character code (chr2str to shove it into a string)
-// For mouse events then x+y are the mouse delta/position values
-/*
-float(float evtype, float scanx, float chary, float devid) CSQC_InputEvent =
-{
- return FALSE;
-};
-*/
-
-// This is linked to client dmg_take / dmg_save / dmg_inflictor fields
-// returning TRUE will block the red flash damage stuff
-float(float save, float take, vector dir) CSQC_Parse_Damage =
-{
- painfinishtime = time + 0.2;
- return FALSE;
-};
-
-// Can query/check server MSG events
-// CSQC_Parse_Event is called when the client sees a
-// #define svcfte_cgamepacket (83) message from the server
-// Not supported for DP, is called from only QSS/FTE
-// void() CSQC_Parse_Event = { };
-
-// Can intercept printed messages from the server (top of screen)
-// printlvl (text filtering) 0=low, 1=medium, 2=high, 3=chat
-// con_notifytime = amount of time the text remains on screen
-// ONLY define this function, if doing something with the text!!
-void(string printmsg, float printlvl) CSQC_Parse_Print =
-{
- print (printmsg);
-};
-
-// Running on the Server side of CSQC listening for commands back
-// This is never called on the client side of the progs
-void(string str) SV_ParseClientCommand =
-{
- local string ostr, cmd;
- // Save command string for later
- ostr = str;
- // Search for tokens in string
- tokenize_console (str);
- // Find the first argument of the command
- cmd = argv (0);
- // Is this my (AD CSQC) command?
- if (cmd == CSQC_PING)
- self.ext_csqc = TRUE;
- else
- // Pass through original command
- clientcommand (self, ostr);
-};
-
-//----------------------------------------------------------------------
-// TODO CEV
-//----------------------------------------------------------------------
-void(entity ent) CSQC_DrawViewModel =
-{
- float newframe, newmodel;
-
- newframe = getstatf (STAT_WEAPONFRAME);
- newmodel = getstatf (STAT_WEAPONMODEL);
-
- if (newmodel != ent.modelindex)
- {
- // changed entirely
- ent.modelindex = newmodel;
- ent.frame2 = ent.frame = newframe;
- ent.lerptime = time;
- }
- else if (newframe != ent.frame)
- {
- ent.frame2 = ent.frame;
- ent.frame = newframe;
- ent.lerptime = time;
- }
-
- ent.lerpfrac = 1 - (time - ent.lerptime) * 10;
-
- ent.origin = '0 0 0';
- ent.angles = '0 0 0';
- ent.effects = player_local.effects;
-
- // addentity (ent);
-};
-
-//----------------------------------------------------------------------
-void(float vwidth, float vheight, float notmenu) CSQC_UpdateView =
-{
- local vector ssize;
-
- ssize_x = vwidth;
- ssize_y = vheight;
- ssize_z = 0;
-
- // Is the CSQC functionality enabled/disabled?
- nocsqc = cvar ("cl_nocsqc");
-
- clearscene ();
-
- // TODO CEV
- // addentities (MASK_ENGINE|MASK_VIEWMODEL);
- // addentities (MASK_NORMAL | MASK_ENGINE);
- setproperty (VF_DRAWWORLD, (float)1);
- setproperty (VF_MIN, '0 0');
- setproperty (VF_SIZE, ssize);
-
- // If hud is disabled, draw engine hud instead
- setproperty (VF_DRAWENGINESBAR, nocsqc);
- setproperty (VF_DRAWCROSSHAIR, TRUE);
-
- // TODO CEV
- if (self.entnum == player_localentnum)
- {
- // read our smoothed & predicted view origin
- // setproperty (VF_VIEWENTITY, player_localentnum);
- setproperty (VF_ORIGIN, view_origin);
- setproperty (VF_ANGLES, view_angles);
- // setproperty (VF_ANGLES, player_local.angles);
- setproperty (VF_CL_VIEWANGLES, view_angles);
- // setproperty (VF_CL_VIEWANGLES, player_local.angles);
-
- makevectors (view_angles);
- SetListener (view_origin, v_forward, v_right, v_up);
-
- if (intermission)
- {
- // don't draw crosshair in intermission
- setproperty (VF_DRAWCROSSHAIR, FALSE);
- }
- else
- {
- // draw view model when not in intermission
- CSQC_DrawViewModel (viewentity);
- }
-
- if (player_local.effects & EF_MUZZLEFLASH)
- dprint ("CSQC_UpdateView: muzzleflash\n");
-
- setproperty (VF_VIEWENTITY, viewentity);
- addentities (MASK_ENGINE | MASK_VIEWMODEL | MASK_NORMAL);
- }
- else
- {
- // engine didn't tell us about our player entity.
- // that's not right...
- dprint ("csqc UpdateView: no player_local\n");
- addentities (MASK_ENGINE | MASK_VIEWMODEL | MASK_NORMAL);
- }
-
- renderscene ();
-
- // Revert back to using engine HUD?
- if (nocsqc > 0)
- return;
-
- // Used on intermission screen later
- if (!intermission)
- intermission_time = time;
-
- // Read deathmatch variable and create csprogs coop variable
- // csprogs has no knowledge of the coop variable
- deathmatch = stof (serverkey("deathmatch"));
- coop = !deathmatch && maxclients > 1;
-
- // Draw the HUDs and scoreboards
- CSQC_DrawHud (ssize, sb_showscores);
- CSQC_DrawScores (ssize, sb_showscores);
-};
-
-//----------------------------------------------------------------------
-// Handle SVC_TEMPENTITY data from the server -- CEV
-//
-// Based on code by PrimalLove found at:
-// https://forums.insideqc.com/viewtopic.php?p=55772#p55772
-//----------------------------------------------------------------------
-float CSQC_Parse_TempEntity()
-{
- float handled, teid;
- vector pos, end, vel;
- float eid;
- entity e;
-
- handled = FALSE;
- teid = ReadByte ();
-
- switch (teid)
- {
- case 6:
- eid = readentitynum ();
- pos_x = ReadCoord ();
- pos_y = ReadCoord ();
- pos_z = ReadCoord ();
- end_x = ReadCoord ();
- end_y = ReadCoord ();
- end_z = ReadCoord ();
- // pointparticles (
- // particleeffectnum("TE_LIGHTNING2"),
- // pos, end, 1);
- if (player_local)
- te_lightning2 (player_local, pos, end);
- else
- te_lightning2 (viewentity, pos, end);
- handled = TRUE;
- break;
- default:
- handled = FALSE;
- break;
- }
-
- return handled;
-};
-
-//----------------------------------------------------------------------
-// Handle incoming MSG_ENTITY data from the server -- CEV
-//----------------------------------------------------------------------
-void(float isnew) CSQC_Ent_Update =
-{
- local float classtype;
-
- classtype = ReadByte ();
-
- switch (classtype)
- {
- case CT_PLAYER:
- PlayerUpdate (isnew);
- break;
- }
-};
-
-//----------------------------------------------------------------------
-// Registers HUD gfx images (all setup in string arrays)
-//----------------------------------------------------------------------
-void(float apilevel, string enginename, float engineversion) CSQC_Init =
-{
- local float i, wadonly;
-
- // Is the CSQC functionality enabled/disabled?
- nocsqc = cvar ("cl_nocsqc");
- // Revert back to using engine HUD?
- if (nocsqc > 0)
- return;
-
- // Send ping back to server that CSQC client is alive
- // This can be used on the server side to detect CSQC
- // and change functions for new features
- localcmd (strcat("cmd ", CSQC_PING, "\n"));
-
- // precache from gfx.wad ONLY!?!
- wadonly = TRUE;
-
- // Cache all string tables
- for (i = 0; i < 14; i++)
- {
- // HUD background images (320 wide+)
- if (i < backgrd.length)
- precache_pic (backgrd[i], wadonly);
- // Large 24x24 brown/red numbers
- if (i < number.length)
- {
- precache_pic (number[i], wadonly);
- precache_pic (anumber[i], wadonly);
- }
- // Large 24x24 extra font characters (intermission)
- if (i < extrachar.length)
- precache_pic (extrachar[i], wadonly);
- // Large 24x24 player face
- if (i < facetab.length)
- precache_pic (facetab[i], wadonly);
- // Large 24x24 icons
- if (i < sbitems.length)
- precache_pic (sbitems[i], wadonly);
- // Small 16x16 icons
- if (i < ibitems.length)
- precache_pic (ibitems[i], wadonly);
- // Special 8x16 runes
- if (i < ibrunes.length)
- precache_pic (ibrunes[i], wadonly);
- // All weapon setups (on/off/flashing)
- if (i < wpnnames.length)
- {
- precache_pic(strcat(wpnselect[0], wpnnames[i]),wadonly);
- precache_pic(strcat(wpnselect[1], wpnnames[i]),wadonly);
- precache_pic(strcat(wpnflash[0], wpnnames[i]), wadonly);
- precache_pic(strcat(wpnflash[1], wpnnames[i]), wadonly);
- precache_pic(strcat(wpnflash[2], wpnnames[i]), wadonly);
- precache_pic(strcat(wpnflash[3], wpnnames[i]), wadonly);
- precache_pic(strcat(wpnflash[4], wpnnames[i]), wadonly);
- }
- }
-
- // TODO CEV
- precache_model ("progs/player.mdl");
-
- viewentity = spawn ();
- viewentity.renderflags = RF_VIEWMODEL|RF_DEPTHHACK;
-};
-
-//----------------------------------------------------------------------
-// Wrapper for CSQC_Init to try and detect DP engine
-//----------------------------------------------------------------------
-__wrap void(float apilevel, string enginename, float engineversion) CSQC_Init =
-{
- // Execute previous CSQC_Init function
- prior (apilevel, enginename, engineversion);
-
- registercommand ("+showscores");
- registercommand ("+showscores");
- registercommand ("+showteamscores");
- registercommand ("+showteamscores");
-};
-
-//----------------------------------------------------------------------
-// Wrapper for CSQC_ConsoleCommand to show different scoreboards
-//----------------------------------------------------------------------
-__wrap float(string str) CSQC_ConsoleCommand =
-{
- if (prior(str))
- return TRUE;
-
- string c = argv(0);
-
- if (c == "+showscores")
- sb_showscores |= 1;
- else if (c == "-showscores")
- sb_showscores &~= 1;
- else if (c == "+showteamscores")
- sb_showscores |= 2;
- else if (c == "-showteamscores")
- sb_showscores &~= 2;
- else
- return FALSE;
-
- return TRUE;
-};

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

Diff qc/csqc/csqc_fteopts.qc

diff --git a/qc/csqc/csqc_fteopts.qc b/qc/csqc/csqc_fteopts.qc
deleted file mode 100644
index 2fd08b0..0000000
--- a/qc/csqc/csqc_fteopts.qc
+++ /dev/null
@@ -1,14 +0,0 @@
-#define FTE
-#pragma TARGET FTE
-#ifndef CSQC
-#define CSQC
-#endif
-
-// Some extra defs (csqc/csqc_simple)
-#ifndef CSQC_SIMPLE
-#define CSQC_SIMPLE
-#endif
-// Suppress reference errors
-#pragma noref 1
-
-

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

Diff qc/csqc/csqc_hudvanilla.qc

diff --git a/qc/csqc/csqc_hudvanilla.qc b/qc/csqc/csqc_hudvanilla.qc
deleted file mode 100644
index bc721a6..0000000
--- a/qc/csqc/csqc_hudvanilla.qc
+++ /dev/null
@@ -1,997 +0,0 @@
-//==============================================================================
-// CSQC_HUDVANILLA
-//==============================================================================
-
-/*======================================================================
- All CSQC functions (Vanilla ONLY version)
-
- * This file is heavily influenced by QSS devkit (credit=spike)
- * re-written some functions to make better sense to me
- * Contains all HUD elements for full quake interface (SP/Coop/Dm)
- * Sripped out the experimental stuff included in devkit
- * Converted most of the hardcoded values into constants
- * Added loads of extra comments to show what is going on
-
-======================================================================*/
-
-// Default sizes for HUD elements
-vector HUDSIZE_320 = '320 24 0'; // Background images
-vector HUDSIZE_24 = '24 24 0'; // Status Bar
-vector HUDSIZE_16 = '16 16 0'; // Inventory/Powerups
-vector HUDSIZE_816 = '8 16 0'; // Runes
-vector HUDSIZE_8 = '8 8 0'; // Ammo numbers
-vector HUDSIZE_C8 = '8 0 0'; // Character sizes
-
-// 8 pixel font table (index positions)
-float HUDFONT_WHITE = 0; // Default index = 48-57
-float HUDFONT_YELLOW = 1; // index = index - 30
-float HUDFONT_RED = 2; // index = index + 128
-
-// Default sizes for weapons
-vector HUDWPN_48 = '48 16 0'; // Vanilla LG
-vector HUDWPN_32 = '32 16 0'; // AD/Hipnotic LG
-vector HUDWPN_24 = '24 16 0'; // Default
-
-vector HUDRGB_DEF = '1 1 1';
-float baralpha; // Read scr_sbaralpha variable
-float hudalpha; // All gfx on hud bars
-
-//----------------------------------------------------------------------
-// Statue, Inventory and Score bars (All 320 x 24)
-string backgrd[3] = { "gfx/sbar", "gfx/ibar", "gfx/scorebar" };
-// Ranking (168 x 24), Complete (184 x 24), Inter (160 x 144)
-// Require .lmp extensions if not loaded diectly from GFX file
-string backlmp[3] = { "gfx/ranking.lmp", "gfx/complete.lmp", "gfx/inter.lmp" };
-
-//----------------------------------------------------------------------
-// Regular (24x24) brown numbers
-string number[10] =
-{
- "gfx/num_0", "gfx/num_1", "gfx/num_2", "gfx/num_3", "gfx/num_4",
- "gfx/num_5", "gfx/num_6", "gfx/num_7", "gfx/num_8", "gfx/num_9"
-};
-// Red (24x24) numbers for no armour, low HP (<25) and no ammo
-string anumber[10] =
-{
- "gfx/anum_0", "gfx/anum_1", "gfx/anum_2", "gfx/anum_3", "gfx/anum_4",
- "gfx/anum_5", "gfx/anum_6", "gfx/anum_7", "gfx/anum_8", "gfx/anum_9"
-};
-
-// Regular (24x24) characters for intermission
-string extrachar[3] =
-{
- "gfx/num_colon", "gfx/num_minus", "gfx/num_slash"
-};
-
-// 24x24 pixel icons for Status Bar
-string sbitems[8] =
-{
- "gfx/sb_shells", "gfx/sb_nails", "gfx/sb_rocket", "gfx/sb_cells",
- "gfx/sb_armor1", "gfx/sb_armor2", "gfx/sb_armor3", "gfx/disc"
-};
-
-// 16x16 pixel icons for Information Bar
-string ibitems[6] =
-{
- "gfx/sb_key1", "gfx/sb_key2", "gfx/sb_invis", "gfx/sb_invuln",
- "gfx/sb_suit", "gfx/sb_quad"
-};
-
-// 8x16 pixel runes for Information Bar
-string ibrunes[4] =
-{
- "gfx/sb_sigil1", "gfx/sb_sigil2", "gfx/sb_sigil3", "gfx/sb_sigil4"
-};
-
-//----------------------------------------------------------------------
-// All weapon HUD graphics are prefixed with certain characters which
-// means all weapon filenames can be generated with string commands
-// CSQC is really an advanced (QSS/FTE/DP) engine only thing and its
-// very likely that FTE_STRINGS is supported for string manipulation
-//----------------------------------------------------------------------
-// Special constants for weapons
-float WPN_ICONS = 7; // Total weapons to precache pics + flash timers
-float WPN_WIDTHLG = 6; // Odd weapon gfx width (48) default (24)
-// Record when weapons have been added (flash mechanic)
-float flashtime[WPN_ICONS];
-
-// Shotgun, SuperShotgun, Nailgun, SuperNailGun, GrenadeLauncher
-// RocketLauncher, LightningGun
-string wpnnames[WPN_ICONS] =
-{
- "shotgun", "sshotgun", "nailgun", "snailgun", "rlaunch",
- "srlaunch", "lightng"
-};
-
-// OFF / ON gfx (reflects active weapon)
-string wpnselect[2] = { "gfx/inv_", "gfx/inv2_" };
-
-// Special flash set for when the player gets weapon
-string wpnflash[5] =
-{
- "gfx/inva1_","gfx/inva2_","gfx/inva3_","gfx/inva4_","gfx/inva5_"
-};
-
-//----------------------------------------------------------------------
-// Frame 00-04 : Regular HP 100/80/60/40/20
-// Frame 05-09 : InPain HP 100/80/60/40/20
-// Frame 10 : Invisibility Ring + Pentagram!
-// Frame 11 : Quad Damage
-// Frame 12 : Invisibility Ring
-// Frame 13 : Pentagram (invulnerability)
-//----------------------------------------------------------------------
-string facetab[14] =
-{
- "gfx/face5", "gfx/face4", "gfx/face3", "gfx/face2", "gfx/face1",
- "gfx/face_p5", "gfx/face_p4", "gfx/face_p3", "gfx/face_p2",
- "gfx/face_p1",
- "gfx/face_inv2", "gfx/face_quad", "gfx/face_invis", "gfx/face_invul2"
-};
-
-//======================================================================
-// Display 24pixel numbers to HUD (cope with red version)
-//----------------------------------------------------------------------
-void(vector pos, float value, float threshhold) Hud_DrawNoFont24 =
-{
- local string val_str, disp_str;
- local float disp_col, disp_len, disp_no;
-
- // Make sure value is within range
- if (value < 0)
- value = 0;
- else if (value > 999)
- value = 999;
-
- disp_col = FALSE;
-
- // Round number down (floor) and work out length
- val_str = ftos (floor(value));
- disp_len = strlen (val_str);
- // Move to the lowest digit position first
- pos_x = pos_x + (3 * HUDSIZE_24_x);
-
- // Work out which number colour to use
- if (value <= threshhold)
- disp_col = TRUE;
-
- while (disp_len > 0)
- {
- // Countdown early (range is 0-2, strlen returns 1-3)
- disp_len = disp_len - 1;
-
- // Move backward to display a digit
- pos_x = pos_x - HUDSIZE_24_x;
-
- // Convert str character to font index numbers
- disp_no = (str2chr (val_str, disp_len) - '0');
-
- // Double check for any wierd range issues
- if (disp_no < 0 || disp_no > 9)
- disp_no = 0;
-
- // Work out which number colour to use
- if (disp_col)
- disp_str = anumber[disp_no];
- else
- disp_str = number[disp_no];
-
- // Draw number in correct (right-justified) position
- drawpic (pos, disp_str, HUDSIZE_24, HUDRGB_DEF, hudalpha, 0);
- }
-};
-
-//----------------------------------------------------------------------
-// Display 24pixel characters to HUD (limited chars available)
-//----------------------------------------------------------------------
-void(vector pos, string num) Hud_DrawCharFont24 =
-{
- float i, c;
- // Endless loop until end of string
- // Keep moving draw pos forward (pos_x)
- for (i = 0; ; i++, pos_x += HUDSIZE_24_x)
- {
- // Read next character from string
- c = str2chr (num, i);
- // End of string found?
- if (!c)
- break;
- // Check for special characters
- else if (c == ':' || c == '.')
- drawpic (pos, extrachar[0], HUDSIZE_24, HUDRGB_DEF,
- hudalpha, 0);
- else if (c == '-')
- drawpic (pos, extrachar[1], HUDSIZE_24, HUDRGB_DEF,
- hudalpha, 0);
- else if (c == '/')
- drawpic (pos, extrachar[2], HUDSIZE_24, HUDRGB_DEF,
- hudalpha, 0);
- // Draw rest of the numbers
- else if (c >= '0' && c <= '9')
- {
- // Sanity check, make sure within range of array
- c = c - 48;
- if (c < 0 || c > 9) c = 0;
- drawpic (pos, number[c], HUDSIZE_24, HUDRGB_DEF,
- hudalpha, 0);
- }
- }
-};
-
-//----------------------------------------------------------------------
-// Draws small 8 pixel numbers to HUD (white/yellow/red text options)
-//----------------------------------------------------------------------
-void(vector pos, float value, float digit, float zerofill, float fontcol)
- Hud_DrawNoFont8 =
-{
- local string val_str;
- local float disp_len, disp_no;
-
- // Make sure value is within range
- if (value < 0)
- value = 0;
- // Check max range against max digits
- else if (value > 999 && digit >= 3)
- value = 999;
- else if (value > 99 && digit == 2)
- value = 99;
- else if (value > 9 && digit <= 1)
- value = 9;
-
- // Round number down (floor) and work out length
- val_str = ftos (floor(value));
- disp_len = strlen (val_str);
-
- // Zero fill number?
- if (zerofill)
- {
- while (disp_len < digit)
- {
- // Keep adding more zero's
- val_str = strcat ("0", val_str);
- // Exit condition?
- disp_len = strlen (val_str);
- }
- }
-
- // Move to the lowest digit position first
- pos_x = pos_x + (digit * HUDSIZE_8_x);
-
- while (disp_len > 0)
- {
- // Countdown first (digit positions = 0-2)
- disp_len = disp_len - 1;
- // Move backward to display a digit
- pos_x = pos_x - HUDSIZE_8_x;
- // Convert character to number (font table index 48-57)
- disp_no = str2chr (val_str, disp_len);
- if (fontcol == HUDFONT_YELLOW)
- disp_no = disp_no - 30;
- else if (fontcol == HUDFONT_RED)
- disp_no = disp_no + 128;
- // Draw character from ascii font table (right-justified)
- drawcharacter (pos, disp_no, HUDSIZE_8, HUDRGB_DEF,
- hudalpha, 0);
- }
-};
-
-//----------------------------------------------------------------------
-// Change HUD face to reflect Health, Pain or Powerups
-//----------------------------------------------------------------------
-void(vector pos) Hud_DrawFace =
-{
- string face;
- local float hpframe;
-
- // Start with InvRing as it has two states
- if (sitems & CSQC_INVISIBILITY)
- {
- if (sitems & CSQC_INVULNERABILITY)
- // InvRing + Pentagram!?! WTF!?! SandyP E4 design!
- face = facetab[10];
- else
- // Just InvRing only
- face = facetab[12];
- }
- else if (sitems & CSQC_QUAD)
- {
- // Quad only
- face = facetab[11];
- }
- else if (sitems & CSQC_INVULNERABILITY)
- {
- // Pentagram only
- face = facetab[13];
- }
- else
- {
- // Regular face
- // Work out face based on HP (100/80/60/40/20)
- hpframe = floor (shealth / 20);
-
- // Check for negative and upper (MegaHP) limits
- if (hpframe < 0)
- hpframe = 0;
- else if (hpframe > 4)
- hpframe = 4;
-
- // Check for any pain/flinch updates
- if (painfinishtime > time)
- hpframe = hpframe + 5;
-
- // Final HP face
- face = facetab[hpframe];
- }
-
- // Draw face - always 24x24 size, full rgb/alpha
- drawpic (pos, face, HUDSIZE_24, HUDRGB_DEF, hudalpha, 0);
-};
-
-//----------------------------------------------------------------------
-// Update a weapon icon with selection or flash features
-//----------------------------------------------------------------------
-static void(float num, vector pos) Hud_DrawWeapon =
-{
- local string prefix, file_str;
- local vector gfx_size;
- local float flash;
-
- // The weapon flash is done every 0.1s and repeated twice!
- // When the player gets a new weapon the time is reset
- // This function will count the time difference for flashing
- // Convert the flash time to a 0-10+ range
- flash = (time - flashtime[num]) * 10;
-
- // Has the flash happened twice? (finished)
- if (flash >= 10)
- {
- // Work out if this weapon is currently selected
- if (sweapon == (1 << num))
- prefix = wpnselect[1];
- // Default is no highlight
- else
- prefix = wpnselect[0];
- }
- else
- {
- // Flashing!
- // Is the flash into second phase?
- if (flash < 0)
- flash = 0;
- else if (flash >= 5)
- flash = flash - 5;
-
- // flash is only 0-4 frames
- prefix = wpnflash[flash];
- }
-
- // Merge prefix type (defined above) to weapon filename
- // Without string (str) functions this would involve a giant table
- // This sorta assumes that CSQC is running on an advanced engine
- // QSS/FTE/DP all support FTE_STRINGS extra str functions
- file_str = strcat (prefix, wpnnames[num]);
-
- // Most weapons are 24 pixels wide (half of ammo above)
- // As always there is an exception (lightning gun)
- if (num == WPN_WIDTHLG)
- gfx_size = HUDWPN_48;
- else
- gfx_size = HUDWPN_24;
-
- // Show weapon GFX (active/deactive/flashing)
- drawpic (pos, file_str, gfx_size, HUDRGB_DEF, hudalpha, 0);
-};
-
-//======================================================================
-// STATUS BAR ( Armour / Health quantities and current Ammo selected)
-//----------------------------------------------------------------------
-void (vector pos, vector virtsize) Hud_DrawSBar =
-{
- // Draw primary HUD bar (Armour/Face/Health/Ammo)
- drawpic (pos, backgrd[0], HUDSIZE_320, HUDRGB_DEF, baralpha, 0);
-
- // Deal with Pentagram first, its a simple test/update
- if (sitems & CSQC_INVULNERABILITY)
- {
- // Make sure 666 is in 24 pixel giant red numbers!
- Hud_DrawNoFont24 (pos + [24, 0], 666, 666);
- // Draw a pentagram symbol in the armour HUD slot
- drawpic (pos, sbitems[7], HUDSIZE_24, HUDRGB_DEF, hudalpha, 0);
- }
- else
- {
- // Show armour type/quantity active
- Hud_DrawNoFont24 (pos + '24 0 0', getstatf(CLIENT_ARMOR), 25);
- // Only 3 armour types (green/yellow/red)
- if (sitems & CSQC_ARMOR1)
- drawpic (pos, sbitems[4], HUDSIZE_24, HUDRGB_DEF,
- hudalpha, 0);
- else if (sitems & CSQC_ARMOR2)
- drawpic (pos, sbitems[5], HUDSIZE_24, HUDRGB_DEF,
- hudalpha, 0);
- else if (sitems & CSQC_ARMOR3)
- drawpic (pos, sbitems[6], HUDSIZE_24, HUDRGB_DEF,
- hudalpha, 0);
- }
-
- // Draw face + HP value
- Hud_DrawFace (pos + [112, 0]);
- Hud_DrawNoFont24 (pos + [136, 0], shealth, 25);
-
- // Only update ammo type/quantity if not using axe!
- if (sweapon != CSQC_AXE)
- {
- Hud_DrawNoFont24 (pos + [248, 0], getstatf(CLIENT_AMMO), 10);
- if (sitems & CSQC_SHELLS)
- drawpic (pos + [224, 0], sbitems[0], HUDSIZE_24,
- HUDRGB_DEF, hudalpha, 0);
- else if (sitems & CSQC_NAILS)
- drawpic (pos + [224, 0], sbitems[1], HUDSIZE_24,
- HUDRGB_DEF, hudalpha, 0);
- else if (sitems & CSQC_ROCKETS)
- drawpic (pos + [224, 0], sbitems[2], HUDSIZE_24,
- HUDRGB_DEF, hudalpha, 0);
- else if (sitems & CSQC_CELLS)
- drawpic (pos + [224, 0], sbitems[3], HUDSIZE_24,
- HUDRGB_DEF, hudalpha, 0);
- }
-};
-
-//======================================================================
-// INVENTORY BAR ( Ammo quantities, keys/runes and powerups )
-//----------------------------------------------------------------------
-void (vector pos, vector br) Hud_DrawIBar =
-{
- local vector topcol, botcol;
- local string player_frags;
-
- // Draw background bar using scr_sbaralpha default
- drawpic (pos, backgrd[1], HUDSIZE_320, HUDRGB_DEF, baralpha, 0);
-
- // Always draw ammo scores
- Hud_DrawNoFont8 (pos + [10, 0], getstatf(CLIENT_SHELLS), 3,
- FALSE, HUDFONT_YELLOW);
- Hud_DrawNoFont8 (pos + [58, 0], getstatf(CLIENT_NAILS), 3,
- FALSE, HUDFONT_YELLOW);
- Hud_DrawNoFont8 (pos + [106, 0], getstatf(CLIENT_ROCKETS), 3,
- FALSE, HUDFONT_YELLOW);
- Hud_DrawNoFont8 (pos + [154, 0], getstatf(CLIENT_CELLS), 3,
- FALSE, HUDFONT_YELLOW);
-
- // Draw weapons and highlight current one
- if (sitems & CSQC_SHOTGUN)
- Hud_DrawWeapon (0, pos + [24 * 0, 8]);
- if (sitems & CSQC_SUPER_SHOTGUN)
- Hud_DrawWeapon (1, pos + [24 * 1, 8]);
- if (sitems & CSQC_NAILGUN)
- Hud_DrawWeapon (2, pos + [24 * 2, 8]);
- if (sitems & CSQC_SUPER_NAILGUN)
- Hud_DrawWeapon (3, pos + [24 * 3, 8]);
- if (sitems & CSQC_GRENADE_LAUNCHER)
- Hud_DrawWeapon (4, pos + [24 * 4, 8]);
- if (sitems & CSQC_ROCKET_LAUNCHER)
- Hud_DrawWeapon (5, pos + [24 * 5, 8]);
- if (sitems & CSQC_LIGHTNING)
- Hud_DrawWeapon (6, pos + [24 * 6, 8]);
-
- // Draw inventory items
- if (sitems & CSQC_KEY1)
- drawpic (pos + [192, 8], ibitems[0], HUDSIZE_16, HUDRGB_DEF,
- hudalpha, 0);
- if (sitems & CSQC_KEY2)
- drawpic (pos + [208, 8], ibitems[1], HUDSIZE_16, HUDRGB_DEF,
- hudalpha, 0);
- if (sitems & CSQC_INVISIBILITY)
- drawpic (pos + [224, 8], ibitems[2], HUDSIZE_16, HUDRGB_DEF,
- hudalpha, 0);
- if (sitems & CSQC_INVULNERABILITY)
- drawpic (pos + [240, 8], ibitems[3], HUDSIZE_16, HUDRGB_DEF,
- hudalpha, 0);
- if (sitems & CSQC_SUIT)
- drawpic (pos + [256, 8], ibitems[4], HUDSIZE_16, HUDRGB_DEF,
- hudalpha, 0);
- if (sitems & CSQC_QUAD)
- drawpic (pos + [272, 8], ibitems[5], HUDSIZE_16, HUDRGB_DEF,
- hudalpha, 0);
-
- // Draw Runes (special size + location)
- if (sitems2 & CSQC_RUNE1)
- drawpic (pos + [288, 8], ibrunes[0], HUDSIZE_816, HUDRGB_DEF,
- hudalpha, 0);
- if (sitems2 & CSQC_RUNE2)
- drawpic (pos + [296, 8], ibrunes[1], HUDSIZE_816, HUDRGB_DEF,
- hudalpha, 0);
- if (sitems2 & CSQC_RUNE3)
- drawpic (pos + [304, 8], ibrunes[2], HUDSIZE_816, HUDRGB_DEF,
- hudalpha, 0);
- if (sitems2 & CSQC_RUNE4)
- drawpic (pos + [312, 8], ibrunes[3], HUDSIZE_816, HUDRGB_DEF,
- hudalpha, 0);
-
- //should probably show team scores, but this mimics vanilla
- if (deathmatch)
- {
- // Move to space above powerups
- pos_x += 194;
-
- // Loop through 4 players
- for (float i = -1; i >= -4; i--)
- {
- // Read frag score of next player
- player_frags = getplayerkeyvalue (i, "frags");
-
- // No frags? stop loop
- if (player_frags == "")
- break;
-
- // Read deathmatch player top/bottom skin colours
- topcol = stov (getplayerkeyvalue(i, "topcolor_rgb"));
- botcol = stov (getplayerkeyvalue(i, "bottomcolor_rgb"));
-
- // Draw skin colours (alpha was 0.75 hardcoded)
- drawfill (pos + [0, 1], [28, 3], topcol, 0.75, 0);
- drawfill (pos + [0, 4], [28, 4], botcol, 0.75, 0);
-
- // Draw frag score (New global small font function)
- Hud_DrawNoFont8 (pos + '2 0 0', stof(player_frags), 3,
- FALSE, HUDFONT_WHITE);
-
- // Find player entity attached to this HUD
- if (player_localentnum == stof(getplayerkeyvalue(
- i, "viewentity")))
- {
- // special characters = []
- drawcharacter (pos + [-4, 0], 0xe010,
- HUDSIZE_8, HUDRGB_DEF, hudalpha, 0);
- drawcharacter (pos + [24, 0], 0xe011,
- HUDSIZE_8, HUDRGB_DEF, hudalpha, 0);
- }
-
- // Move forward to next hud space
- pos_x += 8 * 4;
- }
- }
-};
-
-//======================================================================
-// Scoreboard Bar (shows monster/secret quantities and map info)
-//----------------------------------------------------------------------
-void(vector pos, float bx, float by, float bwidth, float bheight,
- float pixelspeed, string draw_str) Hud_ScrollTextBox =
-{
- local float str_width, str_double, str_speed;
- local string wide_str;
-
- // draw debug visual box to show area on screen
- //drawfill (pos + [bx, by], [bwidth, bheight], HUDRGB_DEF, 0.1, 0);
-
- // Find out width of string in pixels (using font 8)
- str_width = stringwidth (draw_str, TRUE, HUDSIZE_8);
-
- // String less than window width?
- if (str_width < bwidth)
- {
- // Center the map name string in the box area
- str_double = (bwidth - str_width) / 2;
-
- // Display string normally (no scrolling required)
- drawstring (pos + [bx + str_double, by], draw_str, HUDSIZE_8,
- HUDRGB_DEF, hudalpha, 0);
- }
- else
- {
- // Create double length string with boundary marker
- wide_str = strcat (draw_str, " /// ", draw_str);
-
- // Setup clip (scissor) area for exclusive drawing
- drawsetcliparea (pos_x + bx, pos_y + by, bwidth, bheight);
- str_double = stringwidth (wide_str, TRUE, HUDSIZE_8);
-
- // create offset of string to make it look like its scrolling
- str_speed = mod (cltime * pixelspeed, (str_double - str_width));
-
- // draw string (with offset) inside of clip (scissor) area only
- drawstring (pos + [bx - str_speed, by], wide_str, HUDSIZE_8,
- HUDRGB_DEF, hudalpha, 0);
-
- // Reset clip string area to default
- drawresetcliparea ();
- }
-};
-
-//----------------------------------------------------------------------
-// Quakespasm scoreboard layout (no time)
-//----------------------------------------------------------------------
-void(vector pos) Hud_QSScores_SBar =
-{
- local string skill_str, map_str;
- local float digit;
-
- // Clear status bar ready for map info/scores
- drawpic (pos, backgrd[2], HUDSIZE_320, HUDRGB_DEF, baralpha, 0);
-
- // Display headings
- drawstring (pos + [8, 12], "Kills:", HUDSIZE_8, HUDRGB_DEF,
- hudalpha, 0);
- drawstring (pos + [80, 12], "/", HUDSIZE_8, HUDRGB_DEF,
- hudalpha, 0);
- drawstring (pos + [132, 12], "Skill ", HUDSIZE_8, HUDRGB_DEF,
- hudalpha, 0);
- drawstring (pos + [208, 12], "Secrets:", HUDSIZE_8, HUDRGB_DEF,
- hudalpha, 0);
- drawstring (pos + [288, 12], "/", HUDSIZE_8, HUDRGB_DEF,
- hudalpha, 0);
-
- // Display monster/secret totals
- Hud_DrawNoFont8 (pos + [56, 12], getstatf(CLIENT_KILLEDMONSTERS), 3,
- FALSE, HUDFONT_WHITE);
- if (getstatf(CLIENT_TOTALMONSTERS) < 100)
- digit = 2;
- else
- digit = 3;
- Hud_DrawNoFont8 (pos + [88, 12], getstatf(CLIENT_TOTALMONSTERS), digit,
- FALSE, HUDFONT_WHITE);
- Hud_DrawNoFont8 (pos + [272, 12], getstatf(CLIENT_FOUNDSECRETS), 2,
- FALSE, HUDFONT_WHITE);
- Hud_DrawNoFont8 (pos + [296, 12], getstatf(CLIENT_TOTALSECRETS), 2,
- FALSE, HUDFONT_WHITE);
-
- // Display map skill level
- skill_str = autocvar (skill, "1");
- drawstring (pos + [180, 12], skill_str, HUDSIZE_8, HUDRGB_DEF,
- hudalpha, 0);
-
- // Level designers Map name + File name
- map_str = strcat (world.message, " (", mapname, ")");
- Hud_ScrollTextBox (pos, 8, 4, 304, 8, 16, map_str);
-};
-
-//----------------------------------------------------------------------
-// The original ID scoreboard layout (no skill, map filename)
-//----------------------------------------------------------------------
-void(vector pos) Hud_IDScores_SBar =
-{
- local float nsecs, nmins;
-
- // Clear status bar ready for map info/scores
- drawpic (pos, backgrd[2], HUDSIZE_320, HUDRGB_DEF, baralpha, 0);
- // Display headings
- drawstring (pos+[8,4], "Monsters:", HUDSIZE_8, HUDRGB_DEF, hudalpha, 0);
- drawstring (pos+[104,4], "/", HUDSIZE_8, HUDRGB_DEF, hudalpha, 0);
- drawstring (pos+[8,12], "Secrets :", HUDSIZE_8, HUDRGB_DEF, hudalpha,0);
- drawstring (pos+[104,12], "/", HUDSIZE_8, HUDRGB_DEF, hudalpha, 0);
- drawstring (pos+[184,4], "Time :", HUDSIZE_8, HUDRGB_DEF, hudalpha, 0);
- drawstring (pos+[256,4], ":", HUDSIZE_8, HUDRGB_DEF, hudalpha, 0);
- // Display monster/secret totals
- Hud_DrawNoFont8 (pos + [80, 4], getstatf(CLIENT_KILLEDMONSTERS), 3,
- FALSE, HUDFONT_WHITE);
- Hud_DrawNoFont8 (pos + [112, 4], getstatf(CLIENT_TOTALMONSTERS), 3,
- FALSE, HUDFONT_WHITE);
- Hud_DrawNoFont8 (pos + [80, 12], getstatf(CLIENT_FOUNDSECRETS), 3,
- FALSE, HUDFONT_WHITE);
- Hud_DrawNoFont8 (pos + [112, 12], getstatf(CLIENT_TOTALSECRETS), 3,
- FALSE, HUDFONT_WHITE);
- // Work out time passed
- nmins = floor (time / 60);
- nsecs = floor (time - nmins * 60);
- Hud_DrawNoFont8 (pos + [232, 4], nmins, 3, FALSE, HUDFONT_WHITE);
- Hud_DrawNoFont8 (pos + [264, 4], nsecs, 2, TRUE, HUDFONT_WHITE);
- // Level designers Map name
- Hud_ScrollTextBox (pos, 140, 12, 176, 8, 16, world.message);
-};
-
-//======================================================================
-// Deathmatch scoreboard
-//----------------------------------------------------------------------
-vector(string picname, float height) Hud_AspectSize =
-{
- local vector sz;
- sz = drawgetimagesize (picname);
- return [sz_x * height / sz_y, height];
-};
-
-//----------------------------------------------------------------------
-void(string picname, float scrwidth, vector pos, float height) Hud_CentrePic =
-{
- local vector sz;
- sz = Hud_AspectSize (picname, height);
- pos_x += (scrwidth - sz_x) / 2;
- drawpic (pos, picname, sz, HUDRGB_DEF, hudalpha, 0);
-};
-
-//----------------------------------------------------------------------
-void(vector virtmin, vector virtsize) Hud_DMScoreboard =
-{
- local float isspec;
- local vector pos, topcol, botcol;
- string player_name, player_frags, player_ping;
-
- // Working copy
- pos = virtmin;
-
- // Check for 16 players?
- player_name = getplayerkeyvalue (-16, "name");
- if (player_name == "")
- pos_y += (virtsize_y - 200) / 2;
-
- // Only draw the header when its not a really big game
- player_name = getplayerkeyvalue (-24, "name");
- if (player_name == "")
- {
- pos_y += 8;
- // Display header (ranking.lmp) gfx for DM scoreboard
- Hud_CentrePic (backlmp[0], virtsize_x, pos, 24);
- // A double update of Y, only spike knows why!?!
- pos_y += 24;
- pos_y += 10;
- }
-
- // Another double X update, no idea why!
- pos_x += (virtsize_x - 320) / 2;
- pos_x += 80;
-
- // negative numbers are players sorted by frags.
- for (float i = -1; ; i--, pos_y += 10)
- {
- // Check for next player name
- player_name = getplayerkeyvalue (i, "name");
- // No more in list, end loop
- if (player_name == "")
- break;
-
- // Read player stats (frag/ping)
- isspec = stof (getplayerkeyvalue(i, "*spectator"));
- player_frags = getplayerkeyvalue (i, "frags");
- player_ping = getplayerkeyvalue (i, "ping");
- // Read deathmatch player top/bottom skin colours
- topcol = stov (getplayerkeyvalue(i, "topcolor_rgb"));
- botcol = stov (getplayerkeyvalue(i, "bottomcolor_rgb"));
-
- // Re-format the player name (no case conversion, force red)
- player_name = strconv (0,2,2, player_name);
- // Draw frag score (New global small font function)
- Hud_DrawNoFont8 (pos - [8 * 5, 0], stof(player_ping), 3,
- FALSE, HUDFONT_WHITE);
-
- // Which type of player? Spectator or Active?
- if (isspec)
- {
- drawstring (pos + [4, 0], "spec", [8, 8],
- HUDRGB_DEF, hudalpha, 0);
- }
- else
- {
- // Draw skin colours (alpha was 0.75 hardcoded)
- drawfill (pos + [0, 0], [40, 4], topcol, 0.75, 0);
- drawfill (pos + [0, 4], [40, 4], botcol, 0.75, 0);
-
- // Draw frag score (New global small font function)
- Hud_DrawNoFont8 (pos + [8, 0], stof(player_frags), 3,
- FALSE, HUDFONT_WHITE);
- // Find player entity attached to this HUD
- if (player_localentnum == stof(getplayerkeyvalue(i,
- "viewentity")))
- {
- // special characters = []
- drawcharacter (pos + [0, 0], 0xe010,
- HUDSIZE_8, HUDRGB_DEF, hudalpha, 0);
- drawcharacter (pos + [32, 0], 0xe011,
- HUDSIZE_8, HUDRGB_DEF, hudalpha, 0);
- }
- }
- // Finally draw player name
- drawstring (pos + [64, 0], player_name, HUDSIZE_8,
- HUDRGB_DEF, hudalpha, 0);
- }
-};
-
-//======================================================================
-// Final Intermission
-//----------------------------------------------------------------------
-void(vector virtmin, vector virtsize) Hud_Intermission =
-{
- local vector pos;
- // Create positions based on virtual screen
- pos = virtmin + (virtsize - [320, 200]) / 2;
-
- // Draw Intermission title and table info (Time/secret/kill)
- Hud_CentrePic (backlmp[1], 320, pos + [0, 24], 24);
- drawpic (pos + [0,56], backlmp[2], [160,144], HUDRGB_DEF, hudalpha, 0);
-
- // Generate complete string and then draw 1 character at time
- // Uses Sprintf function to feed values into final string
- // This function should be supported by Advanced engines
- Hud_DrawCharFont24 (pos + [144, 64], sprintf("%3.0f:%02.0f",
- intermission_time / 60, intermission_time % 60));
- Hud_DrawCharFont24 (pos + [144, 104],
- sprintf ("%3.0f/%.0f",
- getstatf (CLIENT_FOUNDSECRETS),
- getstatf (CLIENT_TOTALSECRETS)
- )
- );
- Hud_DrawCharFont24 (pos + [144, 144],
- sprintf ("%3.0f/%.0f",
- getstatf (CLIENT_KILLEDMONSTERS),
- getstatf (CLIENT_TOTALMONSTERS)
- )
- );
-};
-
-
-//======================================================================
-// Input Monitor -- CEV
-//----------------------------------------------------------------------
-void(vector pos) Hud_InputMonitor =
-{
- if (input_movevalues_x)
- if (input_movevalues_x < 0)
- // backward
- drawcharacter ([pos_x, pos_y, pos_z],
- str2chr ("-", 0),
- HUDSIZE_8, HUDRGB_DEF, hudalpha, 0);
- else if (input_movevalues_x > 0)
- // forward
- drawcharacter ([pos_x, pos_y - 8, pos_z],
- str2chr ("^", 0),
- HUDSIZE_8, HUDRGB_DEF, hudalpha, 0);
-
- if (input_movevalues_y)
- if (input_movevalues_y < 0)
- // left
- drawcharacter ([pos_x - 12, pos_y, pos_z],
- str2chr ("<", 0),
- HUDSIZE_8, HUDRGB_DEF, hudalpha, 0);
- else if (input_movevalues_y > 0)
- // right
- drawcharacter ([pos_x + 12, pos_y, pos_z],
- str2chr (">", 0),
- HUDSIZE_8, HUDRGB_DEF, hudalpha, 0);
-
- if (input_movevalues_z)
- if (input_movevalues_z < 0)
- // down
- drawcharacter ([pos_x - 38, pos_y, pos_z],
- str2chr ("#", 0),
- HUDSIZE_8, HUDRGB_DEF, hudalpha, 0);
- else if (input_movevalues_z > 0)
- // up
- drawcharacter ([pos_x - 24, pos_y, pos_z],
- str2chr ("^", 0),
- HUDSIZE_8, HUDRGB_DEF, hudalpha, 0);
-
- if (input_buttons & 0x00000002)
- // INPUT_BUTTON2 jumping
- drawcharacter ([pos_x - 24, pos_y, pos_z], str2chr ("^", 0),
- HUDSIZE_8, HUDRGB_DEF, hudalpha, 0);
-};
-
-//======================================================================
-// Speedometer -- CEV
-//----------------------------------------------------------------------
-void(vector pos) Hud_Speedometer =
-{
- // fancy -- CEV
- local vector v = [player_local.velocity_x, player_local.velocity_y, 0];
-
- Hud_DrawNoFont8 (pos, ceil(vlen(v)), 3, FALSE, HUDFONT_WHITE);
-};
-
-//======================================================================
-// MAIN ENTRY POINT FOR HUD!!!
-//----------------------------------------------------------------------
-void(vector virtsize, float showscores) CSQC_DrawHud =
-{
- local vector pos, pos_speedo;
- local float oitems, hudviewsize, i;
-
- // Save previous HUD versions for flash function
- oitems = sitems;
-
- //------------------------------------------------------------------
- // All variables have to be specially setup and passed between
- // progs and csprogs as they are not connected in VM space
- // By default CSQC has 30 (most commonly used) parameters setup
- // Unfortunately some of them need to be converted (bitswapped)
- // to make them readable again (I blame spike for this mess)
- // The downside to this bitswapping mess is that the serverflags
- // is not passed to CSQC completely, only the first 4bits (runes)
- //------------------------------------------------------------------
- sitems = getstatbits (CLIENT_ITEMS, 0, 23);
- sitems2 = getstatbits (CLIENT_ITEMS, 23, 9);
- sweapon = getstatf (CLIENT_ACTIVEWEAPON);
- shealth = getstatf (CLIENT_HEALTH);
-
- // Don't show HUD, intermission or dead
- if (intermission || shealth <= 0)
- return;
-
- //--------------------------------------------------------------
- // Read console variable for background HUD alpha
- baralpha = cvar ("scr_sbaralpha");
- if (baralpha == 0)
- baralpha = 0.75;
- // Default is 1 for everything else
- hudalpha = 1;
-
- //--------------------------------------------------------------
- // Check if any weapons have been added to the inventory
- // Update time so the flash function can detect it
- // Check for player count for splitscreen!?! QSS/FTE feature
- if (numclientseats <= 1)
- {
- // Player alive and inventory changd?
- if (shealth && sitems != oitems)
- {
- // Go through all weapon flash counters
- for (i = 0; i < WPN_ICONS; i++)
- {
- // Found weapon and its new?
- if ((sitems & (1<<i)) && !(oitems & (1<<i)))
- // Reset timer
- flashtime[i] = time;
- }
- }
- }
-
- //--------------------------------------------------------------
- // Find out how much of the HUD is being displayed
- // 100 = InfoBar & StatusBar (ALL=Default)
- // 110 = StatusBar Only
- // 120 = Speedometer
- // 130 = Nothing
- //--------------------------------------------------------------
-
- // Read current HUD size
- hudviewsize = cvar ("viewsize");
-
- // Any HUD to display?
- if (hudviewsize < 130)
- {
- // Override scoreboard - check if no player health
- if (shealth <= 0)
- showscores = TRUE;
-
- // Find out mid point of screen
- pos_x = (virtsize_x - 320) / 2;
- pos_y = virtsize_y;
- pos_z = 0;
-
- // trying to center the speedometer display just below
- // the crosshair. This doesn't seem to be right but it
- // works on my 960x720 window. -- CEV.
- pos_speedo_x = virtsize_x / 2.0;
- pos_speedo_y = virtsize_y / 2.0;
- pos_speedo_z = 0;
- Hud_Speedometer (pos_speedo - [8 * 1.5, -8]);
-
- // Input Monitor TODO CEV
- if (!cvar("crosshair"))
- Hud_InputMonitor (pos_speedo - [4, 4, 0]);
-
- if (hudviewsize < 120)
- {
- // Either show Sbar or Scores (bars are centered)
- if (showscores)
- Hud_QSScores_SBar (pos - '0 24 0');
- else
- Hud_DrawSBar (pos - '0 24 0', virtsize);
- }
-
- // Can the Info Bar be displayed?
- if (hudviewsize < 110)
- Hud_DrawIBar (pos - '0 48 0', virtsize);
- }
-};
-
-//----------------------------------------------------------------------
-void(vector virtsize, float showscores) CSQC_DrawScores =
-{
- shealth = getstatf (CLIENT_HEALTH);
-
- if (intermission || showscores || shealth <= 0)
- {
- if (deathmatch)
- Hud_DMScoreboard ('0 0 0', virtsize);
- else if (intermission)
- Hud_Intermission ('0 0 0', virtsize);
- }
-};

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

Diff qc/csqc/csqc_player.qc

diff --git a/qc/csqc/csqc_player.qc b/qc/csqc/csqc_player.qc
deleted file mode 100644
index 260a27b..0000000
--- a/qc/csqc/csqc_player.qc
+++ /dev/null
@@ -1,325 +0,0 @@
-//==============================================================================
-// CSQC PLAYER MOVEMENT & PREDICTION
-//
-// This is based on code by Eukara [1] and the CSQCTest code shipped with
-// FTEQW [2].
-//
-// [1]: https://icculus.org/~marco/quakec/csqc/prediction.html
-// [2]: https://sourceforge.net/p/fteqw/code/HEAD/tree/trunk/quakec/csqctest/src
-//==============================================================================
-
-//======================================================================
-// No-op function for customphysics
-//----------------------------------------------------------------------
-void() sub_null = { };
-
-//======================================================================
-// PlayerResetPrediction
-//
-// was Pred_ResetPlayerPrediction in CSQCTest cs/prediction.qc
-//----------------------------------------------------------------------
-void(entity ent) PlayerResetPrediction =
-{
- ent.origin = player_org;
- ent.velocity = player_vel;
- ent.flags = player_flags;
- ent.pmove_flags = player_pmflags;
- ent.doublejump_timer = player_doublejump_timer;
- ent.groundboost_timer = player_groundboost_timer;
-
- // +1 because the received frame has the move already done (server side)
- pmove_frame = player_sequence + 1;
-
- if (pmove_frame < clientcommandframe - 128)
- // avoid an infinite loop
- pmove_frame = clientcommandframe - 128;
-};
-
-//======================================================================
-// PlayerRunMovement
-//
-// was Pred_RunMovement in CSQCTest cs/prediction.qc
-//----------------------------------------------------------------------
-void(entity ent, float endframe) PlayerRunMovement =
-{
- if (servercommandframe >= player_sequence + 63)
- {
- // we're meant to be updating the player faster than
- // this. hopefully its just that we're throttled...
-
- // you can comment out this block and the player will
- // continue to be predicted locally. But its best to
- // freeze them
-
- // as a note we also hit this block when the console is
- // down -- CEV
-
- player_sequence = servercommandframe - 63;
- return;
- }
-
- PlayerResetPrediction (ent);
-
- if (getstatf(STAT_HEALTH) <= 0)
- {
- // dead, so don't run prediction. :D
- pmove_frame = clientcommandframe;
- if (!getinputstate(pmove_frame - 1))
- {
- #ifdef CSQC
- dprint ("PlayerRunMovement: no-op if statement?\n");
- #endif
- // no-op ? -- CEV
- }
- return;
- }
-
- /*
- if (getinputstate(pmove_frame - 1))
- // from CSQCTest; what is this doing? -- TODO CEV;
- ent.pmove_flags |= PMF_JUMP_HELD;
- */
-
- // set all latched global variables now
- frame_airstep = autocvar (pm_airstep, TRUE);
- frame_bigcoords = autocvar (sv_bigcoords, FALSE);
- frame_clrun = autocvar (cl_run, FALSE);
- frame_gravity = autocvar (sv_gravity, 800.0);
- frame_maxvelocity = autocvar (sv_maxvelocity, 10000.0);
- frame_nostep = autocvar (pm_nostep, FALSE);
- frame_standardphysics = autocvar (pm_standardphysics, FALSE);
- frame_walljump = autocvar (pm_walljump, TRUE);
-
- while (pmove_frame <= endframe)
- {
- if (!getinputstate(pmove_frame))
- {
- // no input from client
- // pmove_frame++;
- break;
- }
-
- if (frame_standardphysics)
- // for testing
- runstandardplayerphysics (ent);
- else
- // for real
- PM_Move (ent);
- pmove_frame++;
- }
-
- // add anything that was applied after (for low packet
- // rate protocols)
- // TODO CEV
- input_angles = view_angles;
-};
-
-//======================================================================
-// PlayerPreDraw
-//
-// Incorporates Pred_UpdateLocalMovement from CSQCTest.
-//----------------------------------------------------------------------
-float() PlayerPreDraw =
-{
- local float viewheight;
-
- if (self.entnum != player_localentnum)
- {
- self.renderflags = 0;
- }
- else
- {
- PlayerRunMovement (self, clientcommandframe);
-
- if (self.origin_z >= player_step_oldz + 6 &&
- self.origin_z < player_step_oldz + 24 &&
- self.velocity_z == 0)
- {
- // evaluate out the remaining old step
- if (player_steptime - time > 0)
- player_step = (player_steptime - time) *
- STEPTIME * player_step;
- else
- player_step = 0;
-
- // work out the new step
- player_step += (player_step_oldz - self.origin_z);
- player_steptime = time + 1 / STEPTIME;
- }
- player_step_oldz = self.origin_z;
-
- // allow the user to move the viewheight down 6 units so
- // it's at +16, where projectiles come from.
- viewheight = autocvar (v_viewheight, 0);
- if (viewheight < -7)
- viewheight = -7;
- else if (viewheight > 7)
- viewheight = 7;
-
- view_origin = self.origin;
- view_origin_z += getstatf (STAT_VIEWHEIGHT) + viewheight;
- viewentity.origin = view_origin;
-
- // correct the view position to compensate for any errors,
- // slowly over time, 0.1 seconds.
- if (pmove_errortime - time > 0)
- {
- dprint ("PlayerPreDraw: pmove error\n");
- view_origin += (pmove_errortime - time) *
- ERRORTIME * pmove_error;
- }
-
- if (player_steptime - time > 0)
- view_origin_z += (player_steptime - time) *
- STEPTIME * player_step;
-
- if (self.lerptime)
- self.lerpfrac = 1 - (time - self.lerptime) * 10;
-
- self.renderflags |= RF_EXTERNALMODEL;
- }
-
- addentity (self);
- return PREDRAW_NEXT;
-};
-
-//======================================================================
-// PlayerRemove
-//----------------------------------------------------------------------
-static void() PlayerRemove =
-{
- if (player_local == self)
- player_local = world;
-
- setmodel (self, "");
- self.oldskin = "";
- self.predraw = __NULL__;
-};
-
-//======================================================================
-// PlayerNew
-//----------------------------------------------------------------------
-void() PlayerNew =
-{
- self.classname = "player";
- self.customphysics = sub_null;
- // MASK_NORMAL ?
- self.drawmask = MASK_ENGINE;
- self.movetype = MOVETYPE_WALK;
- self.predraw = PlayerPreDraw;
- self.removefunc = PlayerRemove;
- self.solid = SOLID_SLIDEBOX;
- setmodel (self, "progs/player.mdl");
-};
-
-//======================================================================
-// PlayerUpdate
-//
-// called from CSQC_Ent_Update for CT_PLAYER entities
-//----------------------------------------------------------------------
-void(float isnew) PlayerUpdate =
-{
- local float f;
-
- f = ReadByte ();
- self.origin_x = ReadCoord ();
- self.origin_y = ReadCoord ();
- self.origin_z = ReadCoord ();
- self.angles_x = ReadShort () / (32767 / 360);
- self.angles_y = ReadShort () / (32767 / 360);
- self.angles_z = ReadShort () / (32767 / 360);
- self.velocity_x = ReadShort ();
- self.velocity_y = ReadShort ();
- self.velocity_z = ReadShort ();
- self.effects = ReadFloat ();
- self.flags = ReadFloat ();
- self.pmove_flags = ReadFloat ();
- self.doublejump_timer = ReadFloat ();
- self.groundboost_timer = ReadFloat ();
-
- if (isnew && !(self.predraw))
- PlayerNew ();
-
- if (intermission)
- {
- // zero out velocity if in intermission -- CEV
- frame_gravity = 0.0f;
- input_movevalues = '0 0 0';
- self.velocity = '0 0 0';
- viewentity.angles = self.angles;
- viewentity.origin = self.origin;
- setorigin (self, self.origin);
- setorigin (viewentity, viewentity.origin);
- return;
- }
-
- if (f != self.frame || isnew)
- {
- self.frame2 = self.frame;
- self.lerptime = time;
- self.frame = f;
- }
-
- if (self.entnum == player_localentnum)
- {
- local vector o, v;
- local float djt, gbt, pmflags, tempflags;
-
- // this is us; save for later
- player_local = self;
- o = self.origin;
- v = self.velocity;
- djt = self.doublejump_timer;
- gbt = self.groundboost_timer;
- tempflags = self.flags;
- pmflags = self.pmove_flags;
-
- // PlayerRunMovement calls ResetPrediction -- CEV
- // PlayerResetPrediction (self);
- PlayerRunMovement (self, servercommandframe + 1);
-
- // TODO CEV ????
- player_doublejump_timer = djt;
- player_groundboost_timer = gbt;
- player_flags = tempflags;
- player_pmflags = pmflags;
- player_org = o;
- player_vel = v;
- player_sequence = servercommandframe;
-
- if (autocvar(cg_noerror, TRUE))
- {
- pmove_error = '0 0 0';
- pmove_errortime = time;
- PlayerResetPrediction (self);
- }
- else
- {
- PlayerRunMovement (self, clientcommandframe);
- o = self.origin;
- // again: PlayerRunMovement calls ResetPrediction
- // PlayerResetPrediction (self);
- PlayerRunMovement (self, clientcommandframe);
-
- if (vlen(o - self.origin) > 64)
- {
- // teleport
- pmove_error = '0 0 0';
- pmove_errortime = time;
- }
- else
- {
- pmove_error = (pmove_errortime - time) *
- ERRORTIME * pmove_error +
- (o - self.origin);
- if (vlen(pmove_error) < 1)
- pmove_error = '0 0 0';
- pmove_errortime = time + 1 / ERRORTIME;
- }
- }
- }
-
- setsize (self, VEC_HULL_MIN, VEC_HULL_MAX);
- self.frameold = self.frame;
- // setorigin (self, self.origin);
-};

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

Diff qc/csqc/csqc_progs.src

diff --git a/qc/csqc/csqc_progs.src b/qc/csqc/csqc_progs.src
deleted file mode 100644
index 3da41be..0000000
--- a/qc/csqc/csqc_progs.src
+++ /dev/null
@@ -1,26 +0,0 @@
-#pragma target fte
-#pragma progs_dat "../../csprogs.dat"
-#pragma noref 1
-
-#define FTE
-#define CSQC
-
-#includelist
-//----------------------------------------------------------------------
-// CSQC defs
-//----------------------------------------------------------------------
-../defs_globalvars.qc // globalvars_t
-../defs_entvars.qc // entvars_t
-csqc_defsbuiltins.qc // curated builtings list
-csqc_defsclient.qc // from Sock's AD CSQC
-csqc_defs.qc // from Sock's AD CSQC
-../defs_classtype.qc // global class list
-
-//----------------------------------------------------------------------
-// movement & client prediction, HUD, entity handling
-//----------------------------------------------------------------------
-../pmove.qc // player movement code
-csqc_player.qc // player handling
-csqc_hudvanilla.qc // HUD
-csqc_entrypoints.qc //
-#endlist

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

Diff qc/custom_mdls.qc

diff --git a/qc/custom_mdls.qc b/qc/custom_mdls.qc
index b86d7f0..ecfc592 100644
--- a/qc/custom_mdls.qc
+++ b/qc/custom_mdls.qc
@@ -2,118 +2,161 @@
// MAPPER-SETTABLE CUSTOM MODELS FOR MONSTERS
//==============================================================================

+//======================================================================
+// fields -- custom models -- dumptruck_ds
+//======================================================================
+
+.string mdl_head;
+.string mdl_body;
+.string mdl_proj; // projectile
+.string mdl_exproj; // explosive projectile
+.float skin_head;
+.float skin_proj; // projectile
+.float skin_exproj; // explosive projectile
+.string mdl_gib1;
+.string mdl_gib2;
+.string mdl_gib3;
+
+.vector mdlsz; // additions by bmFbr for custom bbox
+.vector centeroffset;
+
+//======================================================================
+// forward declarations
+//======================================================================
+
+void(entity e, .string mdl_field, string default_file) precache_model_custom;
+void(entity e, string default_file) precache_head_model;
+void(entity e, string default_file) precache_body_model;
+void(entity e, string default_file) precache_proj_model;
+void(entity e, string default_file) precache_gib1;
+void(entity e, string default_file) precache_gib2;
+void(entity e, string default_file) precache_gib3;
+void(entity e, .string mdl_field, string default_file) precache_model2_custom;
+void(entity e, string default_file) precache_head_model2;
+void(entity e, string default_file) precache_body_model2;
+void(entity e, string default_file) precache_proj_model2;
+void(entity e, string default_file) precache_exproj_model2;
+void(entity e, .string mdl_field, string default_file) model_custom;
+void(entity e, string default_file) body_model;
+// void(entity e, string default_file) head_model;
+void(entity e, string default_file) proj_model;
+
+//------------------------------------------------------------------------------
+
//----------------------------------------------------------------------
// precache_model_custom
//----------------------------------------------------------------------
-void(.string mdl_field, string default_file) precache_model_custom =
+void(entity e, .string mdl_field, string default_file) precache_model_custom =
{
- if (self.mdl_field != "")
- precache_model (self.mdl_field);
+ if (e.mdl_field != "")
+ precache_model (e.mdl_field);
else
precache_model (default_file);
};

//----------------------------------------------------------------------
-void(string default_file) precache_head_model =
+void(entity e, string default_file) precache_head_model =
{
- precache_model_custom (mdl_head, default_file);
+ precache_model_custom (e, mdl_head, default_file);
};

//----------------------------------------------------------------------
-void(string default_file) precache_body_model =
+void(entity e, string default_file) precache_body_model =
{
- precache_model_custom (mdl_body, default_file);
+ precache_model_custom (e, mdl_body, default_file);
};

//----------------------------------------------------------------------
-void(string default_file) precache_proj_model =
+void(entity e, string default_file) precache_proj_model =
{
- precache_model_custom (mdl_proj, default_file);
+ precache_model_custom (e, mdl_proj, default_file);
};

//----------------------------------------------------------------------
-void(string default_file) precache_gib1 =
+void(entity e, string default_file) precache_gib1 =
{
- precache_model_custom (mdl_gib1, default_file);
+ precache_model_custom (e, mdl_gib1, default_file);
};

//----------------------------------------------------------------------
-void(string default_file) precache_gib2 =
+void(entity e, string default_file) precache_gib2 =
{
- precache_model_custom (mdl_gib2, default_file);
+ precache_model_custom (e, mdl_gib2, default_file);
};

//----------------------------------------------------------------------
-void(string default_file) precache_gib3 =
+void(entity e, string default_file) precache_gib3 =
{
- precache_model_custom (mdl_gib3, default_file);
+ precache_model_custom (e, mdl_gib3, default_file);
};

//----------------------------------------------------------------------
// precache_model2_custom
//----------------------------------------------------------------------
-void(.string mdl_field, string default_file) precache_model2_custom =
+void(entity e, .string mdl_field, string default_file) precache_model2_custom =
{
- if (self.mdl_field != "")
- precache_model2 (self.mdl_field);
+ if (e.mdl_field != "")
+ precache_model2 (e.mdl_field);
else
precache_model2 (default_file);
};

//----------------------------------------------------------------------
-void(string default_file) precache_head_model2 =
+void(entity e, string default_file) precache_head_model2 =
{
- precache_model2_custom (mdl_head, default_file);
+ precache_model2_custom (e, mdl_head, default_file);
};

//----------------------------------------------------------------------
-void(string default_file) precache_body_model2 =
+void(entity e, string default_file) precache_body_model2 =
{
- precache_model2_custom (mdl_body, default_file);
+ precache_model2_custom (e, mdl_body, default_file);
};

//----------------------------------------------------------------------
-void(string default_file) precache_proj_model2 =
+void(entity e, string default_file) precache_proj_model2 =
{
- precache_model2_custom (mdl_proj, default_file);
+ precache_model2_custom (e, mdl_proj, default_file);
};

//----------------------------------------------------------------------
-void(string default_file) precache_exproj_model2 =
+void(entity e, string default_file) precache_exproj_model2 =
{
- precache_model2_custom (mdl_exproj, default_file);
+ precache_model2_custom (e, mdl_exproj, default_file);
};

//----------------------------------------------------------------------
// model_custom
//----------------------------------------------------------------------
-void(.string mdl_field, string default_file) model_custom =
+void(entity e, .string mdl_field, string default_file) model_custom =
{
- if (self.mdl_field != "")
+ if (e.mdl_field != "")
{
- setmodel (self, self.mdl_field);
+ setmodel (e, e.mdl_field);
// dprint ("CUSTOM MODEL LOADED\n");
}
else
- setmodel (self, default_file);
+ {
+ setmodel (e, default_file);
+ }
};

//----------------------------------------------------------------------
-void(string default_file) body_model =
+void(entity e, string default_file) body_model =
{
- model_custom (mdl_body, default_file);
+ model_custom (e, mdl_body, default_file);
};

/*
//----------------------------------------------------------------------
-void(string default_file) head_model =
+void(entity e, string default_file) head_model =
{
- model_custom (mdl_head, default_file);
+ model_custom (e, mdl_head, default_file);
};
*/

//----------------------------------------------------------------------
-void(string default_file) proj_model =
+void(entity e, string default_file) proj_model =
{
- model_custom (mdl_proj, default_file);
+ model_custom (e, mdl_proj, default_file);
};

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

Diff qc/custom_snd.qc

diff --git a/qc/custom_snd.qc b/qc/custom_snd.qc
index b03e69c..b0dd7f1 100644
--- a/qc/custom_snd.qc
+++ b/qc/custom_snd.qc
@@ -10,170 +10,233 @@ TODO: iw to add descriptive comments to this file.
========================================================================
*/

+//======================================================================
+// fields -- Custom Monster Sounds -- dumptruck_ds
+//======================================================================
+
+.string snd_death;
+.string snd_pain;
+.string snd_sight;
+.string snd_attack;
+.string snd_hit;
+.string snd_idle;
+.string snd_land;
+.string snd_move;
+.string snd_misc;
+.string snd_misc1;
+.string snd_misc2;
+.string snd_misc3;
+
+//======================================================================
+// forward declarations
+//======================================================================
+
+void(entity e, .string snd_field, string default_file) precache_sound_custom;
+void(entity e, string default_file) precache_sound_attack;
+void(entity e, string default_file) precache_sound_death;
+void(entity e, string default_file) precache_sound_hit;
+void(entity e, string default_file) precache_sound_idle;
+void(entity e, string default_file) precache_sound_land;
+void(entity e, string default_file) precache_sound_misc;
+void(entity e, string default_file) precache_sound_misc1;
+void(entity e, string default_file) precache_sound_misc2;
+void(entity e, string default_file) precache_sound_misc3;
+void(entity e, string default_file) precache_sound_move;
+void(entity e, string default_file) precache_sound_pain;
+void(entity e, string default_file) precache_sound_sight;
+void(entity e, .string snd_field, string default_file) precache_sound2_custom;
+void(entity e, string default_file) precache_sound2_attack;
+void(entity e, string default_file) precache_sound2_death;
+void(entity e, string default_file) precache_sound2_hit;
+void(entity e, string default_file) precache_sound2_idle;
+void(entity e, string default_file) precache_sound2_land;
+void(entity e, string default_file) precache_sound2_misc;
+void(entity e, string default_file) precache_sound2_misc1;
+void(entity e, string default_file) precache_sound2_misc2;
+void(entity e, string default_file) precache_sound2_misc3;
+void(entity e, string default_file) precache_sound2_move;
+void(entity e, string default_file) precache_sound2_pain;
+void(entity e, string default_file) precache_sound2_sight;
+void(.string f, entity e, float c, string d, float v, float att) sound_custom;
+void(entity e, float chan, string def, float vol, float atten) sound_attack;
+void(entity e, float chan, string def, float vol, float atten) sound_death;
+void(entity e, float chan, string def, float vol, float atten) sound_hit;
+void(entity e, float chan, string def, float vol, float atten) sound_idle;
+void(entity e, float chan, string def, float vol, float atten) sound_land;
+void(entity e, float chan, string def, float vol, float atten) sound_misc;
+void(entity e, float chan, string def, float vol, float atten) sound_misc1;
+void(entity e, float chan, string def, float vol, float atten) sound_misc2;
+void(entity e, float chan, string def, float vol, float atten) sound_misc3;
+void(entity e, float chan, string def, float vol, float atten) sound_move;
+void(entity e, float chan, string def, float vol, float atten) sound_pain;
+void(entity e, float chan, string def, float vol, float atten) sound_sight;
+
+//------------------------------------------------------------------------------
+
//----------------------------------------------------------------------
// precache_sound_custom
//----------------------------------------------------------------------
-void(.string snd_field, string default_file) precache_sound_custom =
+void(entity e, .string snd_field, string default_file) precache_sound_custom =
{
- if (self.snd_field != "")
- precache_sound (self.snd_field);
+ if (e.snd_field != "")
+ precache_sound (e.snd_field);
else
precache_sound (default_file);
};

//----------------------------------------------------------------------
-void(string default_file) precache_sound_attack =
+void(entity e, string default_file) precache_sound_attack =
{
- precache_sound_custom (snd_attack, default_file);
+ precache_sound_custom (e, snd_attack, default_file);
};

//----------------------------------------------------------------------
-void(string default_file) precache_sound_death =
+void(entity e, string default_file) precache_sound_death =
{
- precache_sound_custom (snd_death, default_file);
+ precache_sound_custom (e, snd_death, default_file);
};

//----------------------------------------------------------------------
-void(string default_file) precache_sound_hit =
+void(entity e, string default_file) precache_sound_hit =
{
- precache_sound_custom (snd_hit, default_file);
+ precache_sound_custom (e, snd_hit, default_file);
};

//----------------------------------------------------------------------
-void(string default_file) precache_sound_idle =
+void(entity e, string default_file) precache_sound_idle =
{
- precache_sound_custom (snd_idle, default_file);
+ precache_sound_custom (e, snd_idle, default_file);
};

//----------------------------------------------------------------------
-void(string default_file) precache_sound_land =
+void(entity e, string default_file) precache_sound_land =
{
- precache_sound_custom (snd_land, default_file);
+ precache_sound_custom (e, snd_land, default_file);
};

//----------------------------------------------------------------------
-void(string default_file) precache_sound_misc =
+void(entity e, string default_file) precache_sound_misc =
{
- precache_sound_custom (snd_misc, default_file);
+ precache_sound_custom (e, snd_misc, default_file);
};

//----------------------------------------------------------------------
-void(string default_file) precache_sound_misc1 =
+void(entity e, string default_file) precache_sound_misc1 =
{
- precache_sound_custom (snd_misc1, default_file);
+ precache_sound_custom (e, snd_misc1, default_file);
};

//----------------------------------------------------------------------
-void(string default_file) precache_sound_misc2 =
+void(entity e, string default_file) precache_sound_misc2 =
{
- precache_sound_custom (snd_misc2, default_file);
+ precache_sound_custom (e, snd_misc2, default_file);
};

//----------------------------------------------------------------------
-void(string default_file) precache_sound_misc3 =
+void(entity e, string default_file) precache_sound_misc3 =
{
- precache_sound_custom (snd_misc3, default_file);
+ precache_sound_custom (e, snd_misc3, default_file);
};

//----------------------------------------------------------------------
-void(string default_file) precache_sound_move =
+void(entity e, string default_file) precache_sound_move =
{
- precache_sound_custom (snd_move, default_file);
+ precache_sound_custom (e, snd_move, default_file);
};

//----------------------------------------------------------------------
-void(string default_file) precache_sound_pain =
+void(entity e, string default_file) precache_sound_pain =
{
- precache_sound_custom (snd_pain, default_file);
+ precache_sound_custom (e, snd_pain, default_file);
};

//----------------------------------------------------------------------
-void(string default_file) precache_sound_sight =
+void(entity e, string default_file) precache_sound_sight =
{
- precache_sound_custom (snd_sight, default_file);
+ precache_sound_custom (e, snd_sight, default_file);
};

//----------------------------------------------------------------------
// precache_sound2_custom
//----------------------------------------------------------------------
-void(.string snd_field, string default_file) precache_sound2_custom =
+void(entity e, .string snd_field, string default_file) precache_sound2_custom =
{
- if (self.snd_field != "")
- precache_sound2 (self.snd_field);
+ if (e.snd_field != "")
+ precache_sound2 (e.snd_field);
else
precache_sound2 (default_file);
};

//----------------------------------------------------------------------
-void(string default_file) precache_sound2_attack =
+void(entity e, string default_file) precache_sound2_attack =
{
- precache_sound2_custom (snd_attack, default_file);
+ precache_sound2_custom (e, snd_attack, default_file);
};

//----------------------------------------------------------------------
-void(string default_file) precache_sound2_death =
+void(entity e, string default_file) precache_sound2_death =
{
- precache_sound2_custom (snd_death, default_file);
+ precache_sound2_custom (e, snd_death, default_file);
};

//----------------------------------------------------------------------
-void(string default_file) precache_sound2_hit =
+void(entity e, string default_file) precache_sound2_hit =
{
- precache_sound2_custom (snd_hit, default_file);
+ precache_sound2_custom (e, snd_hit, default_file);
};

//----------------------------------------------------------------------
-void(string default_file) precache_sound2_idle =
+void(entity e, string default_file) precache_sound2_idle =
{
- precache_sound2_custom (snd_idle, default_file);
+ precache_sound2_custom (e, snd_idle, default_file);
};

//----------------------------------------------------------------------
-void(string default_file) precache_sound2_land =
+void(entity e, string default_file) precache_sound2_land =
{
- precache_sound2_custom (snd_land, default_file);
+ precache_sound2_custom (e, snd_land, default_file);
};

//----------------------------------------------------------------------
-void(string default_file) precache_sound2_misc =
+void(entity e, string default_file) precache_sound2_misc =
{
- precache_sound2_custom (snd_misc, default_file);
+ precache_sound2_custom (e, snd_misc, default_file);
};

//----------------------------------------------------------------------
-void(string default_file) precache_sound2_misc1 =
+void(entity e, string default_file) precache_sound2_misc1 =
{
- precache_sound2_custom (snd_misc1, default_file);
+ precache_sound2_custom (e, snd_misc1, default_file);
};

//----------------------------------------------------------------------
-void(string default_file) precache_sound2_misc2 =
+void(entity e, string default_file) precache_sound2_misc2 =
{
- precache_sound2_custom (snd_misc2, default_file);
+ precache_sound2_custom (e, snd_misc2, default_file);
};

//----------------------------------------------------------------------
-void(string default_file) precache_sound2_misc3 =
+void(entity e, string default_file) precache_sound2_misc3 =
{
- precache_sound2_custom (snd_misc3, default_file);
+ precache_sound2_custom (e, snd_misc3, default_file);
};

//----------------------------------------------------------------------
-void(string default_file) precache_sound2_move =
+void(entity e, string default_file) precache_sound2_move =
{
- precache_sound2_custom (snd_move, default_file);
+ precache_sound2_custom (e, snd_move, default_file);
};

//----------------------------------------------------------------------
-void(string default_file) precache_sound2_pain =
+void(entity e, string default_file) precache_sound2_pain =
{
- precache_sound2_custom (snd_pain, default_file);
+ precache_sound2_custom (e, snd_pain, default_file);
};

//----------------------------------------------------------------------
-void(string default_file) precache_sound2_sight =
+void(entity e, string default_file) precache_sound2_sight =
{
- precache_sound2_custom (snd_sight, default_file);
+ precache_sound2_custom (e, snd_sight, default_file);
};

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

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

Diff qc/cutscene.qc

diff --git a/qc/cutscene.qc b/qc/cutscene.qc
index f5e7530..c0039bf 100644
--- a/qc/cutscene.qc
+++ b/qc/cutscene.qc
@@ -2,9 +2,40 @@
// cutscene.qc -- Heavily modified for Drake -- Drake version -- dumptruck_ds
//==============================================================================

+// Drake Cutscenes -- Borrowed from Zerstorer.
+
+//======================================================================
+// globals
+//======================================================================
+
+float cutscene; // Set to TRUE during a cutscene.
+float mindex_inviso; // Invisible (null sprite)
+
+//======================================================================
+// fields
+//======================================================================
+
+.float script_count; // dhm - ditto.
+.float script_delay; // dhm - time until next script.
+.float script_time; // dhm - used for script timing.
+
+// .string camera_point; // dhm - target for camera to move to.
+.string focal_point; // dhm - focus point for camera.
+.string script; // dhm - denotes which script to read.
+.string script_num; // dhm - number for info_scripts.
+.string next_script; // dhm - denotes the current script.
+
+//======================================================================
+// forward declarations
+//======================================================================
+
+#if 0
+// TODO CEV void() Cutscene_Think;
void() DHM_CalcMoveDone;
void() move_camera;

+//------------------------------------------------------------------------------
+
//----------------------------------------------------------------------
// more_air -- This resets air capacity and drowning damage.
//----------------------------------------------------------------------
@@ -853,4 +884,5 @@ void() info_script =
return;
};

+#endif
//===========================/ END OF FILE /===========================/

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

Diff qc/defs_builtins.qc

diff --git a/qc/defs_builtins.qc b/qc/defs_builtins.qc
index 2878afd..cf04b72 100644
--- a/qc/defs_builtins.qc
+++ b/qc/defs_builtins.qc
@@ -2,67 +2,276 @@
// BUILTIN FUNCTIONS
//==============================================================================

-void(vector ang) makevectors = #1; // sets v_forward, etc globals
+//======================================================================
+// id1 builtins -- most comments from fteextensions.qc
+//======================================================================
+
+#if defined(CSQC) || defined(SSQC)
+// Takes an angle vector (pitch,yaw,roll) (+x=DOWN). Writes its results
+// into v_forward, v_right, v_up vectors.
+void(vector ang) makevectors = #1;
+
+// Changes e's origin to be equal to o. Also relinks collision state (as
+// well as setting absmin+absmax), which is required after changing .solid
void(entity e, vector o) setorigin = #2;
-void(entity e, string m) setmodel = #3; // set movetype and solid first
+
+// Looks up m in the model precache list, and sets both e.model and
+// e.modelindex to match. BSP models will set e.mins and e.maxs accordingly,
+// other models depend upon the value of sv_gameplayfix_setmodelrealbox -
+// for compatibility you should always call setsize after all pickups or
+// non-bsp models. Also relinks collision state.
+void(entity e, string m) setmodel = #3;
+
+// Sets the e's mins and maxs fields. Also relinks collision state,
+// which sets absmin and absmax too.
void(entity e, vector min, vector max) setsize = #4;
- // #5 was removed
+
+// #5 was removed
+#endif
+
+#ifdef SSQC
+// Trigger a debugging event. FTE will break into the qc debugger.
+// Other engines may crash with a debug execption.
void() breakpoint = #6;
-float() random = #7; // returns 0 - 1
-void(entity e, float chan, string samp, float vol, float atten) sound = #8;
+#endif
+
+#if defined(CSQC) || defined(SSQC)
+// Returns a random value between 0 and 1. Be warned, this builtin can
+// return 1 in most engines, which can break arrays.
+float() random = #7;
+
+// Starts a sound centered upon the given entity.
+// chan is the entity sound channel to use, channel 0 will allow you to
+// mix many samples at once, others will replace the old sample
+// 'samp' must have been precached first
+// if specified, 'speedpct' should normally be around 100 (or =0), 200
+// for double speed or 50 for half speed.
+// If flags is specified, the reliable flag in the channels argument is
+// used for additional channels. Flags should be made from
+// SOUNDFLAG_* constants
+// timeofs should be negative in order to provide a delay before the
+// sound actually starts.
+void(entity e, float chan, string samp, float vol, float atten,
+ optional float speedpct, optional float flags, optional float timeofs)
+ sound = #8;
+
+// Shorten or lengthen a direction vector such that it is only one quake
+// unit long.
vector(vector v) normalize = #9;
+
+// Ends the game with an easily readable error message.
void(string e) error = #10;
+
+// Displays a non-fatal easily readable error message concerning the
+// self entity, including a field dump. self will be removed!
void(string e) objerror = #11;
+
+// Returns the square root of the dotproduct of a vector with itself.
+// Or in other words the length of a distance vector, in quake units.
float(vector v) vlen = #12;
-float(vector v) vectoyaw = #13;
+
+// Given a direction vector, returns the yaw angle in which that
+// direction vector points. If an entity is passed, the yaw angle will
+// be relative to that entity's gravity direction.
+float(vector v, optional entity reference) vectoyaw = #13;
+
+// Adds a brand new entity into the world! Hurrah, you're now a parent!
entity() spawn = #14;
+
+// Destroys the given entity and clears some limited fields (including
+// model, modelindex, solid, classname). Any references to the entity
+// following the call are an error. After two seconds, the entity will
+// be reused, in the interim you can unfortunatly still read its fields
+// to see if the reference is no longer valid.
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
+// Traces a thin line through the world from v1 towards v2.
+// Will not collide with ent, ent.owner, or any entity who's owner
+// field refers to ent.
+// The passed entity will also be used to determine whether to use a
+// capsule trace, the contents that the trace should impact, and
+// a couple of other extra fields that define the trace.
+// There are no side effects beyond the trace_* globals being written.
+// flags&MOVE_NOMONSTERS will not impact on non-bsp entities.
+// flags&MOVE_MISSILE will impact with increased size.
+// flags&MOVE_HITMODEL will impact upon model meshes, instead of their
+// bounding boxes.
+// flags&MOVE_TRIGGERS will also stop on triggers
+// flags&MOVE_EVERYTHING will stop if it hits anything, even non-solid entities.
+// flags&MOVE_LAGGED will backdate entity positions for the purposes of
+// this builtin according to the indicated player ent's latency, to
+// provide lag compensation.
+void(vector v1, vector v2, float flags, entity ent) traceline = #16;
+#endif
+
+#ifdef SSQC
+// Returns one of the player entities. The returned player will
+// change periodically.
+entity() checkclient = #17;
+#endif
+
+#if defined(CSQC) || defined(SSQC)
+// Scan for the next entity with a given field set to the given 'match'
+// value. start should be either world, or the previous entity that
+// was found. Returns world on failure/if there are no more.
+// If you have many many entities then you may find that hashtables will
+// give more performance (but requires extra upkeep).
entity(entity start, .string fld, string match) find = #18;
+
+// Precaches a sound, making it known to clients and loading it from disk.
+// This builtin (strongly) should be called during spawn functions. This
+// builtin must be called for the sound before the sound builtin is called,
+// or it might not even be heard.
string(string s) precache_sound = #19;
+
+// Precaches a model, making it known to clients and loading it from disk
+// if it has a .bsp extension. This builtin (strongly) should be
+// called during spawn functions. This must be called for each model
+// name before setmodel may use that model name.
+// Modelindicies precached in SSQC will always be positive. CSQC precaches
+// will be negative if they are not also on the server.
string(string s) precache_model = #20;
+#endif
+
+#ifdef SSQC
+// Sends a console command (or cvar) to the client, where it will be
+// executed. Different clients support different commands. Do NOT
+// forget the final \n.
+// This builtin is generally considered evil.
void(entity client, string s) stuffcmd = #21;
+#endif
+
+#if defined(CSQC) || defined(SSQC)
+// Finds all entities within a distance of the 'org' specified. One
+// entity is returned directly, while other entities are returned via
+// that entity's .chain field.
entity(vector org, float rad) findradius = #22;
+#endif
+
+#ifdef SSQC
+// NQ: Concatenates all arguments, and prints the messsage on the
+// console of all connected clients.
void(string s) bprint = #23;
+
+// NQ: Concatenates all string arguments, and prints the messsage
+// on the named client's console
void(entity client, string s) sprint = #24;
+#endif
+
+#if defined(CSQC) || defined(SSQC)
+// NQ: Prints the given message on the server's console, but only
+// if the developer cvar is set. Arguments will be concatenated into
+// a single message.
void(string s) dprint = #25;
+
+// Returns a tempstring containing a representation of the given float.
+// Precision depends upon engine.
string(float f) ftos = #26;
+
+// Returns a tempstring containing a representation of the given vector.
+// Precision depends upon engine.
string(vector v) vtos = #27;
-void() coredump = #28; // prints all edicts
-void() traceon = #29; // turns statment trace on
+
+// Writes out a coredump. This contains stack, globals, and field info
+// for all ents. This can be handy for debugging.
+void() coredump = #28;
+
+// Enables tracing. This may be spammy, slow, and stuff. Set debugger 1
+// in order to use fte's qc debugger.
+void() traceon = #29;
+
+// Disables tracing again.
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
+
+// Debugging builtin that prints all fields of the given entity to the console.
+void(entity e) eprint = #31;
+
+// Attempt to walk the entity at a given angle for a given distance.
+// if settraceglobals is set, the trace_* globals will be set, showing
+// the results of the movement.
+// This function will trigger touch events.
+float(float yaw, float dist, optional float settraceglobals) walkmove = #32;
+
+// #33 was removed
+
+// Instantly moves the entity downwards until it hits the ground. If
+// the entity is in solid or would need to drop more than 'pr_droptofloorunits'
+// quake units, its position will be considered invalid and the builtin
+// will abort, returning FALSE, otherwise TRUE.
+float() droptofloor = #34;
+
+// Specifies an auto-animating string that specifies the light intensity
+// for entities using that lightstyle.
+// a is off, z is fully lit. Should be lower case only.
+// rgb will recolour all lights using that lightstyle.
+void(float style, string stylestring, optional vector rgb) lightstyle = #35;
+
+// Rounds the given float up or down to the closest integeral value.
+// X.5 rounds away from 0
+float(float v) rint = #36;
+
+// Rounds the given float downwards, even when negative.
+float(float v) floor = #37;
+
+// Rounds the given float upwards, even when negative.
+float(float v) ceil = #38;
+
+// #39 was removed
+
+// Expensive checks to ensure that the entity is actually sitting on
+// something solid, returns true if it is.
+float(entity e) checkbottom = #40;
+
+// Checks the given point to see what is there. Returns one of the SOLID_*
+// constants. Just because a spot is empty does not mean that the player can
+// stand there due to the size of the player - use tracebox for such tests.
+// old comment: returns a CONTENT_*
+float(vector v) pointcontents = #41;
+
+// #42 was removed
+
+// Removes the sign of the float, making it positive if it is negative.
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; // particles
-void() changeyaw = #49; // turn to ideal_yaw at yaw_speed
- // #50 was removed
-vector(vector v) vectoangles = #51;
+#endif

-//======================================================================
+#ifdef SSQC
+// Returns a direction vector (specifically v_forward on error).
+// This builtin attempts to guess what pitch angle to fire projectiles at
+// for people that don't know about mouselook. Does not affect yaw angles.
+vector(entity e, float speed) aim = #44;
+#endif
+
+#if defined(CSQC) || defined(SSQC)
+// Returns the numeric value of the named cvar
+float(string s) cvar = #45;
+
+// Adds the string to the console command queue. Commands will not be
+// executed immediately, but rather at the start of the following frame.
+void(string s) localcmd = #46;
+
+// Returns the following entity. Skips over removed entities. Returns
+// world when passed the last valid entity.
+entity(entity e) nextent = #47;
+
+// Spawn 'count' particles around 'pos' moving in the direction 'dir',
+// with a palette colour index between 'colour' and 'colour+8'.
+void(vector o, vector d, float color, float count) particle = #48;
+
+// Changes the self.angles_y field towards self.ideal_yaw by up to
+// self.yaw_speed.
+void() changeyaw = #49;
+
+// #50 was removed
+
+// Returns the angles (+x=UP) required to orient an entity to look
+// in the given direction. The 'up' argument is required if you wish
+// to set a roll angle, otherwise it will be limited to just
+// monster-style turning.
+vector(vector fwd, optional vector up) vectoangles = #51;
+#endif
+
+#ifdef SSQC
// 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;
@@ -71,33 +280,72 @@ 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;
-// Writes all 4 bytes of a 32bit integer without truncating to a float
-// first before converting back to an int (unlike WriteLong does, but
-// otherwise equivalent).
-void(float buf, int fl) WriteInt = #0:WriteInt;
-
-// Part of DP_QC_SINCOSSQRTPOW Forgive me father, for I have
-// trigonometry homework.
-// from fteextensions.qc -- CEV
-float(float angle) sin = #60;
-// Part of DP_QC_SINCOSSQRTPOW
-float(float angle) cos = #61;
-// Part of DP_QC_SINCOSSQRTPOW
-float(float value) sqrt = #62;
+#endif

-void(entity ent, entity ignore) tracetoss = #64;
+#if defined(CSQC) || defined(SSQC)
+// Runs lots and lots of fancy logic in order to try to step the entity
+// the specified distance towards its goalentity.
+void(float step) movetogoal = #67;

-// Part of DP_QC_ETOS
-string(entity ent) etos = #65;
+// This builtin does nothing. It was used only as a hint for pak
+// generation.
+string(string s) precache_file = #68;

-void(float step) movetogoal = #67;
-string(string s) precache_file = #68; // no effect except for -copy
+// Sends a copy of the entity's renderable fields to all clients, and
+// REMOVES the entity, preventing further changes. This means it will
+// be unmutable and non-solid.
void(entity e) makestatic = #69;
+#endif
+
+#ifdef SSQC
+// Attempts to change the map to the named map. If 'newmapstartspot' is
+// specified, the state of the current map will be preserved, and the
+// argument will be passed to the next map in the 'startspot' global, and
+// the next map will be loaded from archived state if it was previously
+// visited. If not specified, all archived map states will be purged.
void(string s) changelevel = #70;
- // #71 was removed
-void(string var, string val) cvar_set = #72; // sets cvar.value
+#endif
+
+// #71 was removed
+
+#if defined(CSQC) || defined(SSQC)
+// Instantly sets a cvar to the given string value.
+void(string var, string val) cvar_set = #72;
+
+// Starts playing a sound with no connection to any entity. A sound must
+// be precached during map load in order to be considered valid.
+// Once an ambient sound starts playing it cannot be stopped.
+// Unlike standard sounds, ambient sounds must loop in order to be
+// considered valid (sound markers need to be present in the file).
+// ^^^ information copied from https://quakewiki.org/wiki/ambientsound
+void(vector pos, string samp, float vol, float atten) ambientsound = #74;
+
+// The same as precache_model. This was only used for models in the
+// registered version of Quake. Using precache_model() is preferred.
+// ^^^ information from https://quakewiki.org/wiki/precache_model2
+string(string s) precache_model2 = #75;
+
+// The same as precache_sound. This was only used for sounds in the
+// registered version of Quake. Using precache_sound() is preferred.
+// ^^^ information from https://quakewiki.org/wiki/precache_sound2
+string(string s) precache_sound2 = #76;
+
+// The same as precache_file. Does nothing.
+// ^^^ information from https://quakewiki.org/wiki/precache_file2
+string(string s) precache_file2 = #77;
+#endif
+
+#ifdef SSQC
+// set parm1... to the values at level start for coop respawn
+void(entity e) setspawnparms = #78;
+#endif

//======================================================================
+// id1 builtin overrides
+//======================================================================
+
+#ifdef SSQC
+//----------------------------------------------------------------------
// Centerprint
//
// The following function definitions allow the engine's builtin
@@ -105,15 +353,15 @@ void(string var, string val) cvar_set = #72; // sets cvar.value
// numbers of string arguments. The string that will be printed is the
// concatenation of the string arguments.
//
-// These definitions work because builtin #73 is implemented in such
-// a way that it can accept multiple string arguments in this manner,
-// even though the original QuakeC code didn't take advantage of this
-// fact. A maximum of seven string arguments can be passed because
-// a function is limited to a total of eight arguments (and the first
-// argument is the client). Note that in the original engine, all of
-// the strings for a centerprint message are concatenated into a single
-// 256-char buffer, therefore excessively long messages should be
-// avoided. -- iw
+// These definitions work because builtin #73 is implemented in such a
+// way that it can accept multiple string arguments in this manner, even
+// though the original QuakeC code didn't take advantage of this fact.
+// A maximum of seven string arguments can be passed because a function
+// is limited to a total of eight arguments (and the first argument is
+// the client). Note that in the original engine, all of the strings
+// for a centerprint message are concatenated into a single 256-char
+// buffer, therefore excessively long messages should be avoided. -- iw
+//----------------------------------------------------------------------

.float suppressCenterPrint;

@@ -143,7 +391,7 @@ void(entity client, string s1) centerprint =
sprint(client, s1);
sprint(client, "\n");
}
-}
+};

void(entity client, string s1, string s2) centerprint2 =
{
@@ -160,88 +408,406 @@ void(entity client, string s1, string s2) centerprint2 =
sprint(client, s2);
sprint(client, "\n");
}
-}
+};
+#endif

//======================================================================
+// engine extension builtins
+//======================================================================

-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
+#if defined(CSQC) || defined(SSQC)
+// Part of DP_QC_SINCOSSQRTPOW -- copied from fteextensions.qc -- CEV
+// Forgive me father, for I have trigonometry homework.
+float(float angle) sin = #60;
+float(float angle) cos = #61;
+float(float value) sqrt = #62;
+
+// Part of DP_QC_TRACETOSS -- copied from fteextensions.qc -- CEV
+// Simulates movement of the entity as if it is MOVETYPE_TOSS and
+// starting with it's current state (location, velocity, etc),
+// returns relevant trace_ variables (trace_fraction is always 0,
+// all other values are supported - trace_ent, trace_endpos,
+// trace_plane_normal), does not actually alter the entity.
+// ^^^ text copied from https://quakewiki.org/wiki/DP_QC_TRACETOSS
+void(entity ent, entity ignore) tracetoss = #64;

// Part of FRIK_FILE, FTE_QC_INFOKEY, FTE_STRINGS, QW_ENGINE, ZQ_QC_STRINGS
float(string) stof = #81;

-// Part of DP_QC_TRACEBOX Exactly like traceline, but a box instead
-// of a uselessly thin point. Acceptable sizes are limited by bsp format,
-// q1bsp has strict acceptable size values.
+// Part of DP_QC_TRACEBOX -- copied from fteextensions.qc -- CEV
+// Exactly like traceline, but a box instead of a uselessly thin point.
+// Acceptable sizes are limited by bsp format, q1bsp has strict acceptable
+// size values.
void(vector start, vector mins, vector maxs, vector end, float nomonsters,
entity ent) tracebox = #90;

-// DP_QC_GETLIGHT
+// DP_QC_GETLIGHT -- copied from fteextensions.qc -- CEV
+// Returns the lighting at the requested location (in color),
+// 0-255 range (can exceed 255).
+// ^^^ text copied from https://quakewiki.org/wiki/DP_QC_GETLIGHT
vector(vector org) getlight = #92;

-// Part of DP_QC_MINMAXBOUND Returns the lowest value of its arguments.
+// Part of DP_QC_MINMAXBOUND -- copied from fteextensions.qc -- CEV
+// Returns the lowest value of its arguments.
float(float a, float b, ...) min = #94;
-// Part of DP_QC_MINMAXBOUND Returns the highest value of its arguments.
+// Returns the highest value of its arguments.
float(float a, float b, ...) max = #95;
-// Part of DP_QC_MINMAXBOUND Returns val, unless minimum is higher,
-// or maximum is less.
+// Returns val, unless minimum is higher, or maximum is less.
float(float minimum, float val, float maximum) bound = #96;
-// Part of DP_QC_SINCOSSQRTPOW
+
+// Part of DP_QC_SINCOSSQRTPOW -- copied from fteextensions.qc -- CEV
+// raise value to power exp
float(float value, float exp) pow = #97;

-// Part of DP_QC_FINDFLOAT
-// Equivelent to the find builtin, but instead of comparing strings contents,
+// Part of DP_QC_FINDFLOAT -- copied from fteextensions.qc -- CEV
+// Equivalent to the find builtin, but instead of comparing string contents,
// this builtin compares the raw values. This builtin requires multiple calls
// in order to scan all entities - set start to the previous call's return
// value. world is returned when there are no more entities.
entity(entity start, .__variant fld, __variant match) findfloat = #98;

-// Part of FRIK_FILE, FTE_STRINGS, ZQ_QC_STRINGS
+// Part of FRIK_FILE, FTE_STRINGS, ZQ_QC_STRINGS -- copied from fteextensions.qc
+float(string s) strlen = #114;
+string(string s1, optional string s2, optional string s3, optional string s4,
+ optional string s5, optional string s6, optional string s7,
+ optional string s8) strcat = #115;
+string(string s, float start, float length) substring = #116;
vector(string s) stov = #117;

-// for CSQC interaction -- CEV
-void(float num, float type, .__variant fld) clientstat = #232;
+// Part of FRIK_FILE, FTE_STRINGS, ZQ_QC_STRINGS -- copied from fteextensions.qc
+// Create a semi-permanent copy of a string that only becomes invalid once
+// strunzone is called on the string (instead of when the engine assumes your
+// string has left scope). This builtin has become redundant in FTEQW due to
+// the FTE_QC_PERSISTENTTEMPSTRINGS extension and is now functionally identical
+// to strcat for compatibility with old engines+mods.
+string(string s, ...) strzone = #118;
+
+// Part of FRIK_FILE, FTE_STRINGS, ZQ_QC_STRINGS -- copied from fteextensions.qc
+// Destroys a string that was allocated by strunzone. Further references to the
+// string MAY crash the game. In FTE, this function became redundant and now
+// does nothing.
+void(string s) strunzone = #119;
+#endif
+
+#ifdef CSQC
+// Part of FTE_STRINGS -- copied from fteextensions.qc -- CEV
+// Retrieves the character value at offset 'index'.
+float(string str, float index) str2chr = #222;
+
+// Part of FTE_STRINGS -- copied from fteextensions.qc -- CEV
+// Converts quake chars in the input string amongst different representations.
+// ccase specifies the new case for letters.
+// 0: not changed.
+// 1: forced to lower case.
+// 2: forced to upper case.
+// redalpha and redchars switch between colour ranges.
+// 0: no change.
+// 1: Forced white.
+// 2: Forced red.
+// 3: Forced gold(low) (numbers only).
+// 4: Forced gold (high) (numbers only).
+// 5+6: Forced to white and red alternately.
+// You should not use this builtin in combination with UTF-8.
+string(float ccase, float redalpha, float redchars, string str, ...)
+ strconv = #224;
+#endif
+
+#if defined(CSQC) || defined(SSQC)
+// copied from fteextensions.qc -- CEV
+float(float dividend, float divisor) mod = #245;

// Triggers a touch events between self and every SOLID_TRIGGER entity
// that it is in contact with. This should typically just be the
// triggers touch functions. Also optionally updates the origin of the
// moved entity.
void(optional entity ent, optional vector neworigin) touchtriggers = #279;
+#endif

+#ifdef SSQC
+// copied from fteextensions.qc -- CEV
void(float buf, float fl) WriteFloat = #280;
+#endif
+
+#ifdef CSQC
+// copied from fteextensions.qc -- CEV
+// Forgets all rentities, polygons, and temporary dlights.
+// Resets all view properties to their default values.
+void() clearscene = #300;
+
+// copied from fteextensions.qc -- CEV
+// Walks through all entities effectively doing this:
+// if (ent.drawmask&mask){ if (!ent.predaw()) addentity(ent); }
+// If mask&MASK_DELTA, non-csqc entities, particles, and related effects
+// will also be added to the rentity list.
+// If mask&MASK_STDVIEWMODEL then the default view model will also be added.
+void(float mask) addentities = #301;
+
+// copied from fteextensions.qc -- CEV
+// Copies the entity fields into a new rentity for later rendering via addscene.
+void(entity ent) addentity = #302;
+
+// copied from fteextensions.qc -- CEV
+// Allows you to override default view properties like viewport, fov,
+// and whether the engine hud will be drawn. Different VF_ values have
+// slightly different arguments, some are vectors, some floats.
+float(float property, ...) setproperty = #303;
+
+// copied from fteextensions.qc -- CEV
+// Draws all entities, polygons, and particles on the rentity list (which
+// were added via addentities or addentity), using the various view
+// properties set via setproperty. There is no ordering dependancy.
+// The scene must generally be cleared again before more entities are added,
+// as entities will persist even over to the next frame.
+// You may call this builtin multiple times per frame, but should only be
+// called from CSQC_UpdateView.
+void() renderscene = #304;

-// Part of DP_SV_PRINT Unconditionally print on the local system's
-// console, even in ssqc (doesn't care about the value of the
-// developer cvar).
+// copied from fteextensions.qc -- CEV
+// Forces the engine to load the named image. If trywad is specified,
+// the specified name must any lack path and extension.
+string(string name, optional float trywad) precache_pic = #317;
+
+// copied from fteextensions.qc -- CEV
+// Returns the dimensions of the named image. Images specified with .lmp
+// should give the original .lmp's dimensions even if texture replacements
+// use a different resolution.
+vector(string picname) drawgetimagesize = #318;
+
+// copied from fteextensions.qc -- CEV
+// Tells the engine that the image is no longer needed.
+// The image will appear to be new the next time its needed.
+void(string name) freepic = #319;
+
+// copied from fteextensions.qc -- CEV
+// Draw the given quake character at the given position.
+// If flag&4, the function will consider the char to be a unicode char
+// instead (or display as a ? if outside the 32-127 range).
+// size should normally be something like '8 8 0'.
+// rgb should normally be '1 1 1'
+// alpha normally 1.
+// Software engines may assume the named defaults.
+// Note that ALL text may be rescaled on the X axis due to variable
+// width fonts. The X axis may even be ignored completely.
+float(vector position, float character, vector size, vector rgb,
+ float alpha, optional float drawflag) drawcharacter = #320;
+
+// copied from fteextensions.qc -- CEV
+// Draws the specified string without using any markup at all, even in
+// engines that support it.
+// If UTF-8 is globally enabled in the engine, then that encoding is used
+// (without additional markup), otherwise it is raw quake chars.
+// Software engines may assume a size of '8 8 0', rgb='1 1 1', alpha=1,
+// flag&3=0, but it is not an error to draw out of the screen.
+float(vector position, string text, vector size, vector rgb, float alpha,
+ optional float drawflag) drawrawstring = #321;
+
+// Draws an shader within the given 2d screen box. Software engines may omit
+// support for rgb+alpha, but must support rescaling, and must clip to the
+// screen without crashing. -- copied from fteextensions.qc -- CEV
+float(vector position, string pic, vector size, vector rgb, float alpha, optional float drawflag) drawpic = #322;
+
+// copied from fteextension.qc -- CEV
+// Draws a solid block over the given 2d box, with given colour, alpha,
+// and blend mode (specified via flags).
+// flags&3=0 simple blend.
+// flags&3=1 additive blend
+float(vector position, vector size, vector rgb, float alpha,
+ optional float drawflag) drawfill = #323;
+
+// copied from fteextensions.qc -- CEV
+// Specifies a 2d clipping region (aka: scissor test). 2d draw calls will
+// all be clipped to this 2d box, the area outside will not be modified by
+// any 2d draw call (even 2d polygons).
+void(float x, float y, float width, float height) drawsetcliparea = #324;
+
+// copied from fteextensions.qc -- CEV
+// Reverts the scissor/clip area to the whole screen.
+void(void) drawresetcliparea = #325;
+
+// copied from fteextension.qc -- CEV
+// Draws a string, interpreting markup and recolouring as appropriate.
+float(vector position, string text, vector size, vector rgb, float alpha,
+ float drawflag) drawstring = #326;
+
+// copied from fteextension.qc -- CEV
+// Calculates the width of the screen in virtual pixels. If usecolours is 1,
+// markup that does not affect the string width will be ignored.
+// Will always be decoded as UTF-8 if UTF-8 is globally enabled.
+// If the char size is not specified, '8 8 0' will be assumed.
+float(string text, float usecolours, optional vector fontsize)
+ stringwidth = #327;
+
+// copied from fteextension.qc -- CEV
+// Retrieves the numerical value of the given EV_FLOAT stat. If firstbit
+// and bitcount are specified, retrieves the upper bits of the STAT_ITEMS
+// stat (converted into a float, so there are no VM dependancies).
+float(float stnum, optional float firstbit, optional float bitcount)
+ getstatf = #331;
+
+// copied from fteextension.qc -- CEV
+// Retrieves the value of the given EV_STRING stat, as a tempstring.
+// Older engines may use 4 consecutive integer stats, with a limit of 15
+// chars (yes, really. 15.), but FTE Quake uses a separate namespace for
+// string stats and has a much higher length limit.
+string(float stnum) getstats = #332;
+#endif
+
+#if defined(CSQC) || defined(SSQC)
+// Part of DP_ENT_TRAILEFFECTNUM, FTE_SV_POINTPARTICLES -- from fteextensions.qc
+// Precaches the named particle effect. If your effect name is of the form
+// 'foo.bar' then particles/foo.cfg will be loaded by the client if
+// foo.bar was not already defined.
+// Different engines will have different particle systems, this specifies
+// the QC API only.
+float(string effectname) particleeffectnum = #335;
+
+// Part of FTE_SV_POINTPARTICLES -- copied from fteextensions.qc -- CEV
+// Draws the given effect between the two named points. If ent is not world,
+// distances will be cached in the entity in order to avoid framerate
+// dependancies. The entity is not otherwise used.
+void(float effectnum, entity ent, vector start, vector end)
+ trailparticles = #336;
+
+// Part of FTE_SV_POINTPARTICLES -- copied from fteextensions.qc -- CEV
+// Spawn a load of particles from the given effect at the given point
+// traveling or aiming along the direction specified. The number
+// of particles are scaled by the count argument.
+// For regular particles, the dir vector is multiplied by the 'veladd'
+// property (while orgadd will push the particles along it). Decals
+// will use it as a hint to align to the correct surface. In both
+// cases, it should normally be a unit vector, but other lengths
+// will still work. If it has length 0 then FTE will assume downwards.
+void(float effectnum, vector origin, optional vector dir, optional float count)
+ pointparticles = #337;
+
+// Part of DP_SV_PRINT -- copied from fteextensions.qc -- CEV
+// Unconditionally print on the local system's console, even in ssqc
+// (doesn't care about the value of the developer cvar).
void(string s, ...) print = #339;
+#endif

+#ifdef CSQC
+// copied from fteextensions.qc -- CEV
+// Looks up an input frame from the log, setting the input_* globals
+// accordingly.
+// The sequence number range used for prediction should normally be
+// servercommandframe < sequence <= clientcommandframe.
+// The sequence equal to clientcommandframe will change between input frames.
+float(float inputsequencenum) getinputstate = #345;
+#endif
+
+#if defined(CSQC) || defined(SSQC)
+// goes with SV_RunClientCommand -- copied from fteextensions.qc -- CEV
// Perform the engine's standard player movement prediction upon the given
// entity using the input_* globals to describe movement.
void(entity ent) runstandardplayerphysics = #347;
+#endif
+
+#ifdef CSQC
+// copied from fteextensions.qc -- CEV
+// Look up a player's userinfo, to discover things like their name,
+// topcolor, bottomcolor, skin, team, *ver.
+// Also includes scoreboard info like frags, ping, pl, userid, entertime,
+// as well as voipspeaking and voiploudness.
+string(float playernum, string keyname) getplayerkeyvalue = #348;
+
+// copied from fteextensions.qc -- CEV
+// Returns if the client is currently playing a demo or not
+float() isdemo = #349;
+
+// copied from fteextensions.qc -- CEV
+// Returns if the client is acting as the server (aka: listen server)
+float() isserver = #350;

+// copied from fteextensions.qc -- CEV
+// Sets the position of the view, as far as the audio subsystem is concerned.
+// This should be called once per CSQC_UpdateView as it will otherwise revert
+// to default. For reverbtype, see setup_reverb or treat as 'underwater'.
+void(vector origin, vector forward, vector right, vector up,
+ optional float reverbtype) SetListener = #351;
+
+// copied from fteextensions.qc -- CEV
+// Register the given console command, for easy console use.
+// Console commands that are later used will invoke CSQC_ConsoleCommand.
+void(string cmdname) registercommand = #352;
+#endif
+
+#if defined(CSQC) || defined(SSQC)
+// copied from fteextensions.qc -- CEV
// Look up a key in the server's public serverinfo string
string(string key) serverkey = #354;
+#endif
+
+#ifdef CSQC
+// copied from fteextensions.qc -- CEV
+float() ReadByte = #360;
+float() ReadChar = #361;
+float() ReadShort = #362;
+float() ReadLong = #363;
+float() ReadCoord = #364;
+float() ReadAngle = #365;
+string() ReadString = #366;
+float() ReadFloat = #367;
+float() ReadEntityNum = #368;
+
+// copied from fteextensions.qc -- CEV
+// Specifies a per-modelindex callback to listen for engine-networking
+// entity updates. Such entities are automatically interpolated by
+// the engine (unless flags specifies not to).
+// The various standard entity fields will be overwritten each frame
+// before the updatecallback function is called.
+float(string modelname, float(float isnew) updatecallback, float flags)
+ deltalisten = #371;
+#endif

-// from fteextensions.qc; Part of KRIMZON_SV_PARSECLIENTCOMMAND
+#if defined(CSQC) || defined(SSQC)
+// Part of DP_TE_STANDARDEFFECTBUILTINS, FTE_TE_STANDARDEFFECTBUILTINS
+// copied from fteextensions.qc -- CEV
+void(entity own, vector start, vector end) te_lightning2 = #429;
+
+// Part of KRIMZON_SV_PARSECLIENTCOMMAND -- copied from fteextensions.qc -- CEV
+void(entity e, string s) clientcommand = #440;
float(string s) tokenize = #441;
-// from fteextensions.qc; Part of KRIMZON_SV_PARSECLIENTCOMMAND
string(float n) argv = #442;

-// from fteextensions.qc, all part of DP_QC_ASINACOSATANATAN2TAN -- CEV
+// Part of DP_QC_EDICT_NUM -- copied from fteextensions.qc -- CEV
+entity(float entnum) edict_num = #459;
+
+// Part of DP_QC_ASINACOSATANATAN2TAN -- copied from fteextensions.qc -- CEV
float(float s) asin = #471;
float(float c) acos = #472;
float(float t) atan = #473;
float(float c, float s) atan2 = #474;
float(float a) tan = #475;
+#endif

-// Part of DP_QC_SPRINTF
+#ifdef CSQC
+// copied from fteextensions.qc -- CEV
+// Tokenize a string exactly as the console's tokenizer would do so.
+// The regular tokenize builtin became bastardized for convienient string
+// parsing, which resulted in a large disparity that can be exploited to
+// bypass checks implemented in a naive SV_ParseClientCommand function,
+// therefore you can use this builtin to make sure it exactly matches.
+float(string str) tokenize_console = #514;
+#endif
+
+#if defined(CSQC) || defined(SSQC)
+// Part of DP_QC_SPRINTF -- copied from fteextensions.qc -- CEV
+// Provides the sprintf builtin, which allows for rich formatting along the
+// lines of C's function with the same name. Not to be confused with QC's
+// sprint builtin.
string(string fmt, ...) sprintf = #627;
+#endif

-// Part of FTE_QC_CROSSPRODUCT
+#if defined(CSQC) || defined(SSQC)
+// Part of FTE_QC_CROSSPRODUCT -- copied from fteextensions.qc -- CEV
// Small helper function to calculate the crossproduct of two vectors.
vector(vector v1, vector v2) crossproduct = #0:crossproduct;
+#endif

+#ifdef SSQC
+// Writes all 4 bytes of a 32bit integer without truncating to a float
+// first before converting back to an int (unlike WriteLong does, but
+// otherwise equivalent).
+void(float buf, int fl) WriteInt = #0:WriteInt;
+#endif

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

Diff qc/defs_classtype.qc

diff --git a/qc/defs_classtype.qc b/qc/defs_classtype.qc
deleted file mode 100644
index 4fc2b34..0000000
--- a/qc/defs_classtype.qc
+++ /dev/null
@@ -1,298 +0,0 @@
-//=============================================================================
-// CLASSTYPES -- inspired by the system used in Arcane Dimensions -- CEV
-//=============================================================================
-
-// fields
-.float classgroup; // used to identify some base classes
-.float classtype; // used to identify an entity's type
-
-//----------------------------------------------------------------------
-// classtype list; shared by client & server
-//----------------------------------------------------------------------
-enum
-{
- CT_WORLD, // world entity
-
- // monsters
- CT_PLAYER, // player (client)
-
- // info
- CT_INFO_FOCAL_POINT, // cutscenes
- CT_INFO_INTERMISSION, // id1, end-of-map camera position
- CT_INFO_INTERMISSIONTEXT, // pd3? intermission text ent
- CT_INFO_MONSTER_SPAWNPOINT, // pd3 monster spawnpoint
- CT_INFO_MOVIE_CAMERA, // cutscenes
- CT_INFO_NOTNULL, // id1?
- CT_INFO_NULL, // id1?
- CT_INFO_PLAYER_START, // id1 player start
- CT_INFO_PLAYER_START2, // id1 player start2
- CT_INFO_PLAYER_COOP, // id1 player coop start
- CT_INFO_PLAYER_DEATHMATCH, // id1 player deathmatch start
- CT_INFO_ROTATE, // Hipnotic info_rotate
- CT_INFO_TELEPORT_CHANGEDEST, // Qmaster teleporter changedest
- CT_INFO_TELEPORT_DESTINATION, // id1 teleporters
- CT_INFO_TELEPORT_RANDOM, // teleporters
- CT_INFO_TESTPLAYERSTART, // test player start
-
- // func
- CT_FUNC_BOB, // RennyC func_bob
- CT_FUNC_BOSSGATE, // id1 func_bossgate
- CT_FUNC_BREAKABLE, // AD with mod. by Qmaster, iw, and d_ds
- CT_FUNC_BUTTON, // id1 / pd3 func_button
- CT_FUNC_COUNTER, // Hipnotic func_counter
- CT_FUNC_DOOR, // id1 doors
- CT_FUNC_DOOR_SECRET, // id1 secret door
- CT_FUNC_ELVTR_BUTTON, // Rogue elevator buttons
- CT_FUNC_EPISODEGATE, // id1 func_episodegate
- CT_FUNC_EXPLOBOX, // id1 func_explobox
- CT_FUNC_FALL, // RennyC func_fall
- CT_FUNC_FALL2, // RennyC & whirledtsar func_fall2
- CT_FUNC_ILLUSIONARY, // id1 func_illusionary
- CT_FUNC_LASER, // Rubicon2 func_laser
- CT_FUNC_MONSTER_SPAWNER, // progs_dump monster spawner
- CT_FUNC_MOVEWALL, // Hipnotic rotation
- CT_FUNC_NEW_PLAT, // Rogue / PD3 new_plat
- CT_FUNC_ONCOUNT, // Hipnotic func_oncount
- CT_FUNC_PARTICLEFIELD, // Hipnotic particle field
- CT_FUNC_PLAT, // id1 plats / lifts
- CT_FUNC_ROTATE_DOOR, // Hipnotic rotation
- CT_FUNC_ROTATE_ENTITY, // Hipnotic rotation
- CT_FUNC_ROTATE_TRAIN, // Hipnotic rotation
- CT_FUNC_SHADOW, // pd3 func_shadow
- CT_FUNC_TOGGLEVISIBLEWALL, // pd3(?) togglevisiblewall
- CT_FUNC_TOGGLEWALL, // Hipnotic func_togglewall
- CT_FUNC_TRAIN, // id1 train
- CT_FUNC_WALL, // func_wall
-
- // gibs
- CT_GIB_HEAD_ARMY, // deadstuff
- CT_GIB_HEAD_DEMON, //
- CT_GIB_HEAD_DOG, //
- CT_GIB_HEAD_ENFORCER, //
- CT_GIB_HEAD_HELL_KNIGHT, //
- CT_GIB_HEAD_KNIGHT, //
- CT_GIB_HEAD_OGRE, //
- CT_GIB_HEAD_PLAYER, //
- CT_GIB_HEAD_SHALRATH, //
- CT_GIB_HEAD_SHAMBLER, //
- CT_GIB_HEAD_WIZARD, //
- CT_GIB_MISC_1, //
- CT_GIB_MISC_2, //
- CT_GIB_MISC_3, //
-
- // hazards
- CT_HAZARD_LTRAIL_START, // DOE lightning trail
- CT_HAZARD_LTRAIL_RELAY, // DOE lightning trail
- CT_HAZARD_LTRAIL_END, // DOE lightning trail
- CT_HAZARD_SHOOTER, // trap_shooter
- CT_HAZARD_SPIKESHOOTER, // trap_spikeshooter
- CT_HAZARD_SWITCHED_SHOOTER, // trap_switched_shooter
-
- // items
- CT_ITEM_AMMO_CELLS, // id1 item_cells
- CT_ITEM_AMMO_SPIKES, // id1 item_spikes (nails)
- CT_ITEM_AMMO_ROCKETS, // id1 item_rockets
- CT_ITEM_AMMO_SHELLS, // id1 item_shells
- CT_ITEM_ARMOR_GREEN, // id1 armor1 Green Armor
- CT_ITEM_ARMOR_YELLOW, // id1 armor2 Yellow Armor
- CT_ITEM_ARMOR_RED, // id1 armorInv Red Armor
- CT_ITEM_ARMOR_SHARD, // pd3 armor shards
- CT_ITEM_AXE, // id1 weapon axe
- CT_ITEM_BACKPACK, // id1 backpacks
- CT_ITEM_ENVIROSUIT, // id1 powerup environment suit
- CT_ITEM_GRENADE_LAUNCHER, // id1 weapon grenade launcher
- CT_ITEM_HEALTH, // id1 health
- CT_ITEM_HEALTH_VIAL, // pd3 health vial (5hp bubble)
- CT_ITEM_INVISIBILITY, // id1 powerup ring of shadows
- CT_ITEM_INVULNERABILITY, // id1 powerup pentagram of protection
- CT_ITEM_KEY1, // id1 key1 (silver)
- CT_ITEM_KEY2, // id1 key2 (gold)
- CT_ITEM_KEY_CUSTOM, // pd3 custom keys
- CT_ITEM_LIGHTNING_GUN, // id1 weapon thunderbolt (LG)
- CT_ITEM_NAILGUN, // id1 weapon nailgun (NG)
- CT_ITEM_QUAD, // id1 powerup quad damage
- CT_ITEM_ROCKET_LAUNCHER, // id1 weapon rocket launcher (RL)
- CT_ITEM_RUNE, // id1 rune/sigil
- CT_ITEM_SHOTGUN, // id1 weapon shotgun (SG)
- CT_ITEM_SUPER_NAILGUN, // id1 weapon super nailgun (SNG)
- CT_ITEM_SUPER_SHOTGUN, // id1 weapon super shotgun (SSG)
-
- // lights
- CT_LIGHT, // id1 light
- CT_LIGHT_CANDLE, // light_candle
- CT_LIGHT_FLAME_LARGE_YELLOW, // id1
- CT_LIGHT_FLAME_SMALL_YELLOW, // id1
- CT_LIGHT_FLUORO, // id1 light_fluoro
- CT_LIGHT_FLUOROSPARK, // id1 light_fluorospark
- CT_LIGHT_GLOBE, // id1 light_globe
- CT_LIGHT_SPRITE_FLAME, // pd3 sprite flame
- CT_LIGHT_TORCH_SMALL_WALLTORCH, // id1
-
- // misc
- CT_MISC_AIR_BUBBLES, // id1 air bubbles
- CT_MISC_AMBIENT_COMPHUM, // computer hum
- CT_MISC_AMBIENT_DRIP, // drip sound
- CT_MISC_AMBIENT_DRONE, // drone sound
- CT_MISC_AMBIENT_FBUZZ, // fluoro buzz
- CT_MISC_AMBIENT_GENERAL, // Rubicon Rumble devkit ambient_general
- CT_MISC_AMBIENT_FIRE, // ambient fire sound
- CT_MISC_AMBIENT_LBUZZ, // light buzz
- CT_MISC_AMBIENT_SUCKWIND, // suck wind
- CT_MISC_AMBIENT_SWAMP1, // swamp 1
- CT_MISC_AMBIENT_SWAMP2, // swamp 2
- CT_MISC_AMBIENT_THUNDER, // Zerstorer ambient thunder
- CT_MISC_AMBIENT_WATER1, // ambient water 1
- CT_MISC_AMBIENT_WIND2, // ambient wind 2
- CT_MISC_BOB, // RennyC func_bob
- CT_MISC_EXPLOBOX, // id1 misc_explobox
- CT_MISC_EXPLOBOX2, // id1 misc_explobox2
- CT_MISC_FIREBALL, // id1 misc_fireball
- CT_MISC_INFIGHT, // progs_dump 3 misc_infight
- CT_MISC_MODEL, // misc_model -- Joshua Skelton
- CT_MISC_MODELCANDLE, // model_candle
- CT_MISC_MODELTRAIN, //
- CT_MISC_NOISEMAKER, // pd3 some kind of testing ent?
- CT_MISC_PARTICLES, // Rubicon2 misc_splash
- CT_MISC_PARTICLESPRAY, // custents misc_particlespray
- CT_MISC_PARTICLE_STREAM, // Zerstorer misc_particle_stream
- CT_MISC_PLAY_BFIELD, // pd3 play
- CT_MISC_PLAY_BRLIGHT, // pd3 play
- CT_MISC_PLAY_DIMLIGHT, // pd3 play
- CT_MISC_PLAY_EXPLOSION, // pd3 play
- CT_MISC_PLAY_GIBS, // pd3 play
- CT_MISC_PLAY_LAVASPLASH, // pd3 play
- CT_MISC_PLAY_MFLASH, // pd3 play muzzleflash
- CT_MISC_PLAY_SOUND, // pd3 play_sound
- CT_MISC_PLAY_SOUND_TRIGGERED, // pd3 play_sound
- CT_MISC_ROTATE_OBJECT, // Hipnotic rotation
- CT_MISC_SHADOWCONTROLLER, // pd3 shadows
- CT_MISC_SPARKS, // misc_sparks
- CT_MISC_VIEWTHING, // id1?
- CT_MISC_TELE_FOG, // pd3 play
- CT_MISC_TELEPORTTRAIN, // id1 teleport train
-
- // monsters
- CT_MONSTER_BOSS_CHTHON, // id1 chthon
- CT_MONSTER_BOSS_CHTHON2, // pd3 killable chthon
- CT_MONSTER_BOSS_OLDONE, // id1 shub
- CT_MONSTER_BOSS_OLDONE2, // pd3 killable shub
- CT_MONSTER_DEATHKNIGHT, // id1 hell knight / death knight
- CT_MONSTER_DOG, // id1 dog / pupper
- CT_MONSTER_ENFORCER, // id1 enforcer
- CT_MONSTER_FIEND, // id1 demon1 / fiend / jumpy friend
- CT_MONSTER_FISH, // id1 fishies
- CT_MONSTER_GRUNT, // id1 army / grunt / soldier
- CT_MONSTER_KNIGHT, // id1 knights
- CT_MONSTER_OGRE, // id1 ogres
- CT_MONSTER_OGRE_MARKSMAN, // id1 ogre marksman
- CT_MONSTER_SCRAG, // id1 wizard / scrag
- CT_MONSTER_SHAMBLER, // id1 shambler
- CT_MONSTER_VORE, // id1 shalrath / vore
- CT_MONSTER_ZOMBIE, // id1 zombie
-
- // paths
- CT_PATH_CORNER, // id1 path_corner
- CT_PATH_ROTATE, // Hipnotic rotation
-
- // projectiles
- CT_PROJECTILE_BULLET, // id1 shotgun pellets
- CT_PROJECTILE_FLAK, // pd3 flak projectile
- CT_PROJECTILE_GRENADE, // id1 grenade projectile
- CT_PROJECTILE_HKNIGHT, // id1 hell / death knight magic
- CT_PROJECTILE_LASERBEAM, // id1 laser projectile
- CT_PROJECTILE_LAVABALL, // id1 lava balls (chthon projectile)
- CT_PROJECTILE_MINIGRENADE, // DOE mini grenades
- CT_PROJECTILE_MULTIGRENADE, // DOE multi grenades (spawns the mini)
- CT_PROJECTILE_ROCKET, // id1 rocket projectile
- CT_PROJECTILE_SPIKE, // id1 nail/spike projectile
- CT_PROJECTILE_VOREBALL, // id1 vore projectile
- CT_PROJECTILE_WIZARDMISSILE, // id1 Wizard (Scrag) missile
- CT_PROJECTILE_ZOMBIECHUNK, // id1 zombie gib projectile
-
- // targets
- CT_TARGET_AUTOSAVE, // target_autosave from copper
- CT_TARGET_FOGBLEND, // fog
- CT_TARGET_SETCOUNT, //
- CT_TARGET_SETSTATE, //
- CT_TARGET_TEXTSTORY, // progs_dump textstory
- CT_TARGET_TEXTSTORY_HELPER, // textstory helper subclass
-
- // triggers
- CT_TRIGGER_CAMERA, // cutscenes
- CT_TRIGGER_CAMERA_POINT, // cutscenes
- CT_TRIGGER_CDTRACK, // progs_dump 3 cd track trigger
- CT_TRIGGER_CHANGELEVEL, // id1 change level trigger
- CT_TRIGGER_CHANGEMUSIC, // jleww via changemusic.rar
- CT_TRIGGER_CHANGETARGET, // change an entity's target field
- CT_TRIGGER_COUNTER, // id1 trigger_counter
- CT_TRIGGER_CVARSET, // was in cutscene.qc; from Drake?
- CT_TRIGGER_EVERYTHING, // progs_dump 3; unknown prior source
- CT_TRIGGER_FILTER, //
- CT_TRIGGER_FOG, // fog
- CT_TRIGGER_FOGBLEND, // fog
- CT_TRIGGER_HEAL, // custents trigger_heal by TGR
- CT_TRIGGER_HURT, // Hipnotic trigger_hurt
- CT_TRIGGER_LADDER, // rubicon2 ladders
- CT_TRIGGER_LOOK, // trigger_onlookat by NullPointPaladin
- CT_TRIGGER_MONSTERFACE, // progs_dump 3 monsterface
- CT_TRIGGER_MONSTERJUMP, // id1 trigger_monsterjump
- CT_TRIGGER_MULTIPLE, // id1 trigger_multiple
- CT_TRIGGER_ONCE, // id1 trigger_once
- CT_TRIGGER_ONLYREGISTERED, // id1 registered content trigger
- CT_TRIGGER_PUSH, // id1 push/wind brush
- CT_TRIGGER_PUSH_CUSTOM, // progs_dump push custom
- CT_TRIGGER_RELAY, // id1 trigger_relay
- CT_TRIGGER_SECRET, // id1 secret trigger
- CT_TRIGGER_SETGRAVITY, // Hipnotic gravity trigger
- CT_TRIGGER_SETSKILL, // id1 setskill trigger
- CT_TRIGGER_SHAKE, // ground-shake trigger
- CT_TRIGGER_TAKE_WEAPON, // take_weapon
- CT_TRIGGER_TELEPORT, // id1 teleporters
- CT_TRIGGER_TEXTSTORY, // progs_dump textstory
- CT_TRIGGER_USEKEY, // originally based on Hipnotic code
- CT_TRIGGER_VOID, // necros' trigger_void, modified
-
- // temp entities
- CT_TEMP_ANIM_CONTROLLER, // animation controller
- CT_TEMP_BUBBLES, // air bubble
- CT_TEMP_DELAYEDUSE, // delayed sub_usetargets
- CT_TEMP_DOOR_TRIGGER, // id1 doors
- CT_TEMP_EXPLOSION, // id1 explosions (BecomeExplosion)
- CT_TEMP_FALL2_HELPER, // RennyC & whirledtsar fall2
- CT_TEMP_FIREBALL, // created by misc_fireball
- CT_TEMP_FOG_CONTROLLER, // pd3 fog
- CT_TEMP_KEYDEF, // pd3 custom key definition
- CT_TEMP_LASER_HELPER, // Rubicon2 func_laser
- CT_TEMP_NEWPLAT_TRIGGER, // pd3 newplats
- CT_TEMP_PLAT_TRIGGER, // id1 plats
- CT_TEMP_ROTATE_CONTROLLER, // rotation controller
- CT_TEMP_SPARK, // misc_sparks
- CT_TEMP_WIZARDSPELL // id1 wizard spell (spawns missiles)
-};
-
-//----------------------------------------------------------------------
-// classgroups, defined as needed; I did not want to do this -- CEV
-// go no higher than 24 bits (according to the FTEQCC manual) -- CEV
-// current count: 18 -- CEV
-//----------------------------------------------------------------------
-enumflags
-{
- CG_ENTITY, // base entity
- CG_TEMPENTITY, // temporary entities
- CG_MAPENTITY, // entities with spawn functions
- CG_FUNC, // func_*
- CG_FUNC_ROTATE, // rotation objects
- CG_ITEM, // items
- CG_ITEM_ARMOR, // armor pickups
- CG_ITEM_AMMO, // ammunition boxes
- CG_ITEM_HEALTH, // health pickups
- CG_ITEM_KEY, // keys
- CG_ITEM_POWERUP, // powerups
- CG_ITEM_WEAPON, // weapon pickups
- CG_MONSTER, //
- CG_MONSTER_FLY, //
- CG_MONSTER_SWIM, //
- CG_PROJECTILE, // missiles & projectiles
- CG_TRIGGER, // trigger_*
- CG_HAZARD_LTRAIL // DOE lightning trail
-};

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

Diff qc/defs_const.qc

diff --git a/qc/defs_const.qc b/qc/defs_const.qc
new file mode 100644
index 0000000..7ec3fc0
--- /dev/null
+++ b/qc/defs_const.qc
@@ -0,0 +1,268 @@
+//==============================================================================
+// Global Program Constants
+//==============================================================================
+
+//======================================================================
+// constants
+//======================================================================
+
+// inspired by Copper
+const string version = "\n\"Dog\" mode for FTE\nversion 0.1b";
+
+const float FALSE = 0; //
+const float TRUE = 1;
+const float NEGATIVE = -1;
+
+const float FL_FLY = 1; // standard id1 .flags follow
+const float FL_SWIM = 2;
+const float FL_CLIENT = 8; // set for all client edicts
+const float FL_INWATER = 16; // for enter / leave water splash
+const float FL_MONSTER = 32;
+const float FL_GODMODE = 64; // player cheat
+const float FL_NOTARGET = 128; // player cheat
+const float FL_ITEM = 256; // extra wide size for bonus items
+const float FL_ONGROUND = 512; // standing on something
+const float FL_PARTIALGROUND = 1024; // not all corners are valid
+const float FL_WATERJUMP = 2048; // player jumping out of water
+const float FL_JUMPRELEASED = 4096; // for jump debouncing
+const float FL_NOSELECT = 8192; // ignored by entity selector
+const float FL_NOCENTERPRINT = 65536; // don't centerprint entity's message
+ // field when its targets are used
+
+const float MOVETYPE_NONE = 0; // .movetype values; never moves
+// const float MOVETYPE_ANGLENOCLIP = 1;
+// const float MOVETYPE_ANGLECLIP = 2;
+const float MOVETYPE_WALK = 3; // players only
+const float MOVETYPE_STEP = 4; // discrete, not real time unless fall
+const float MOVETYPE_FLY = 5;
+const float MOVETYPE_TOSS = 6; // gravity
+const float MOVETYPE_PUSH = 7; // no clip to world, push and crush
+const float MOVETYPE_NOCLIP = 8;
+const float MOVETYPE_FLYMISSILE = 9; // fly with extra size against monsters
+const float MOVETYPE_BOUNCE = 10; // standard bounce
+const float MOVETYPE_BOUNCEMISSILE = 11;// bounce with extra size
+
+const float SOLID_NOT = 0; // .solid values; no interaction
+const float SOLID_TRIGGER = 1; // touch on edge, but not blocking
+const float SOLID_BBOX = 2; // touch on edge, block
+const float SOLID_SLIDEBOX = 3; // touch on edge, but not an onground
+const float SOLID_BSP = 4; // bsp clip, touch on edge, block
+
+// the following block from fteextensions.qc was originally ifdef CSQC;
+// I've removed that check because these are just constants -- CEV
+const float STAT_HEALTH = 0; // Player's health.
+// This is the modelindex of the current viewmodel (renamed from the
+// original name 'STAT_WEAPON' due to confusions).
+const float STAT_WEAPONMODELI = 2;
+const float STAT_AMMO = 3; // player.currentammo
+const float STAT_ARMOR = 4;
+const float STAT_WEAPONFRAME = 5;
+const float STAT_SHELLS = 6;
+const float STAT_NAILS = 7;
+const float STAT_ROCKETS = 8;
+const float STAT_CELLS = 9;
+const float STAT_ACTIVEWEAPON = 10; // player.weapon
+const float STAT_TOTALSECRETS = 11;
+const float STAT_TOTALMONSTERS = 12; // required by Hipnotic code
+const float STAT_FOUNDSECRETS = 13;
+const float STAT_KILLEDMONSTERS = 14;
+// self.items | (self.items2<<23).
+// In order to decode this stat properly, you need to use
+// getstatbits(STAT_ITEMS,0,23) to read self.items, and
+// getstatbits(STAT_ITEMS,23,11) to read self.items2 or
+// getstatbits(STAT_ITEMS,28,4) to read the visible part
+// of serverflags, whichever is applicable.
+const float STAT_ITEMS = 15;
+const float STAT_VIEWHEIGHT = 16; // player.view_ofs_z
+// This stat contains the number of the entity in the server's .view2 field.
+const float STAT_VIEW2 = 20;
+// Scales fov and sensitiity. Part of DP_VIEWZOOM.
+const float STAT_VIEWZOOM = 21;
+const float STAT_IDEALPITCH = 25;
+const float STAT_PUNCHANGLE_X = 26;
+const float STAT_PUNCHANGLE_Y = 27;
+const float STAT_PUNCHANGLE_Z = 28;
+// Custom user stats start here (lower values are reserved for engine use).
+// const float STAT_USER = 32;
+
+const float IT_AXE = 4096; // .items flag values
+const float IT_SHOTGUN = 1; // this is pretty much maxed out at
+const float IT_SUPER_SHOTGUN = 2; // 23 values already -- CEV
+const float IT_NAILGUN = 4;
+const float IT_SUPER_NAILGUN = 8;
+const float IT_GRENADE_LAUNCHER = 16;
+const float IT_ROCKET_LAUNCHER = 32;
+const float IT_LIGHTNING = 64;
+const float IT_EXTRA_WEAPON = 128;
+const float IT_SHELLS = 256;
+const float IT_NAILS = 512;
+const float IT_ROCKETS = 1024;
+const float IT_CELLS = 2048;
+const float IT_ARMOR1 = 8192;
+const float IT_ARMOR2 = 16384;
+const float IT_ARMOR3 = 32768;
+const float IT_SUPERHEALTH = 65536;
+const float IT_KEY1 = 131072;
+const float IT_KEY2 = 262144;
+const float IT_INVISIBILITY = 524288;
+const float IT_INVULNERABILITY = 1048576;
+const float IT_SUIT = 2097152;
+const float IT_QUAD = 4194304;
+
+const float SERVERFLAGS_RUNE1 = 32; //
+const float SERVERFLAGS_RUNE2 = 64; //
+const float SERVERFLAGS_RUNE3 = 128; //
+const float SERVERFLAGS_RUNE4 = 256; //
+
+const float CONTENT_EMPTY = -1; // values returned by pointcontents ()
+const float CONTENT_SOLID = -2;
+const float CONTENT_WATER = -3;
+const float CONTENT_SLIME = -4;
+const float CONTENT_LAVA = -5;
+const float CONTENT_SKY = -6;
+
+const vector VEC_ORIGIN = '0 0 0'; // origin & null vector value
+
+const vector VEC_HULL_MIN = '-16 -16 -24';
+const vector VEC_HULL_MAX = '16 16 32'; // Quake standard HULL1
+const vector VEC_HULL_SIZE = '32 32 56';
+const vector VEC_HULL2_MIN = '-32 -32 -24';
+const vector VEC_HULL2_MAX = '32 32 64';// Quake standard HULL2
+const vector VEC_HULL2_SIZE = '64 64 88';
+
+ // common protocol bytes
+const float SVC_UPDATESTAT = 3; // required by Hipnotic code
+const float SVC_SETVIEWPORT = 5; // Camera Hip. Drake devkit dumptruck_ds
+const float SVC_SETVIEWANGLES = 10; // Camera Hip. Drake devkit dumptruck_ds
+const float SVC_TEMPENTITY = 23;
+const float SVC_KILLEDMONSTER = 27;
+const float SVC_FOUNDSECRET = 28;
+const float SVC_INTERMISSION = 30;
+const float SVC_FINALE = 31;
+const float SVC_CDTRACK = 32;
+const float SVC_SELLSCREEN = 33;
+const float SVC_CUTSCENE = 34; // Hipnotic Drake devkit -- dumptruck_ds
+
+const float TE_SPIKE = 0; // temporary entity protocol bytes
+const float TE_SUPERSPIKE = 1;
+const float TE_GUNSHOT = 2;
+const float TE_EXPLOSION = 3;
+const float TE_TAREXPLOSION = 4;
+const float TE_LIGHTNING1 = 5;
+const float TE_LIGHTNING2 = 6;
+const float TE_WIZSPIKE = 7;
+const float TE_KNIGHTSPIKE = 8;
+const float TE_LIGHTNING3 = 9;
+const float TE_LAVASPLASH = 10;
+const float TE_TELEPORT = 11;
+const float TE_EXPLOSION2 = 12; // from doe -- dumptruck_ds
+
+const float CHAN_AUTO = 0; // sound channels; 0 never overrides
+const float CHAN_WEAPON = 1; // 1-7 always override a sound on that
+const float CHAN_VOICE = 2; // channel
+const float CHAN_ITEM = 3;
+const float CHAN_BODY = 4;
+const float CHAN_FEET = 5; // dedicated channel for steps -- CEV
+
+const float ATTN_NONE = 0; // sound attenuation; no attenuation
+const float ATTN_NORM = 1; // standard attenuation
+const float ATTN_IDLE = 2; // extra attenuation
+const float ATTN_STATIC = 3; // even more attn. (good for torches)
+
+const float EF_BRIGHTFIELD = 1; // entity .effects values
+const float EF_MUZZLEFLASH = 2;
+const float EF_BRIGHTLIGHT = 4;
+const float EF_DIMLIGHT = 8;
+
+const float MSG_BROADCAST = 0; // net message dest.; unreliable to all
+const float MSG_ONE = 1; // reliable to one (msg_entity)
+const float MSG_ALL = 2; // reliable to all
+const float MSG_INIT = 3; // write to the init string
+// The byte(s) will be written into the multicast buffer for more
+// selective sending. Messages sent this way will never be split across
+// packets, and using this for csqc-only messages will not break protocol
+// translation.
+const float MSG_MULTICAST = 4;
+const float MSG_ENTITY = 5; // used only in 'SendEntity' functions
+
+const float TRIGGER_CENTERPRINTALL = 1048576; // program-wide spawnflags
+const float SPAWN_SILENTLY = 2097152;
+
+const float MOVE_NORMAL = 0; // trace flags;
+const float MOVE_NOMONSTERS = 1; // ignore all non-solid_bsp entities
+const float MOVE_MISSILE = 2; // bbox of +/- 15 against FL_MONSTER
+const float MOVE_HITMODEL = 4; // impact mesh instead of bbox
+const float MOVE_TRIGGERS = 16; // impact only triggers
+const float MOVE_EVERYTHING = 32; // solids & triggers & non-solid ents
+
+const float DEAD_NO = 0; // .deadflag values
+const float DEAD_DYING = 1;
+const float DEAD_DEAD = 2;
+const float DEAD_RESPAWNABLE = 3;
+
+const float DAMAGE_NO = 0; // .takedamage values
+const float DAMAGE_YES = 1;
+const float DAMAGE_AIM = 2;
+
+const float EV_VOID = 0; // variable types
+const float EV_STRING = 1;
+const float EV_FLOAT = 2;
+const float EV_VECTOR = 3;
+const float EV_ENTITY = 4;
+const float EV_FIELD = 5;
+const float EV_FUNCTION = 6;
+const float EV_POINTER = 7;
+const float EV_INTEGER = 8;
+
+#ifdef CSQC
+//----------------------------------------------------------------------
+// Valid as a return value from the predraw function. Returning this will
+// simply move on to the next entity without the autoadd behaviour, so can
+// be used for particle/invisible/special entites, or entities that were
+// explicitly drawn with addentity.
+//----------------------------------------------------------------------
+const float PREDRAW_NEXT = 1;
+
+//----------------------------------------------------------------------
+// These constants are only used in CSQC_UpdateView
+//----------------------------------------------------------------------
+const float MASK_ENGINE = 1;
+const float MASK_VIEWMODEL = 2;
+const float MASK_NORMAL = 4;
+
+//----------------------------------------------------------------------
+const float VF_MIN = 1;
+const float VF_SIZE = 4;
+const float VF_ORIGIN = 11;
+const float VF_ORIGIN_X = 12;
+const float VF_ORIGIN_Y = 13;
+const float VF_ORIGIN_Z = 14;
+const float VF_ANGLES = 15;
+const float VF_ANGLES_X = 16;
+const float VF_ANGLES_Y = 17;
+const float VF_ANGLES_Z = 18;
+const float VF_DRAWWORLD = 19;
+const float VF_DRAWENGINESBAR = 20;
+const float VF_DRAWCROSSHAIR = 21;
+const float VF_CL_VIEWANGLES = 33;
+const float VF_CL_VIEWANGLES_X = 34;
+const float VF_CL_VIEWANGLES_Y = 35;
+const float VF_CL_VIEWANGLES_Z = 36;
+const float VF_VIEWENTITY = 206;
+
+enumflags {
+ RF_VIEWMODEL,
+ RF_EXTERNALMODEL,
+ RF_DEPTHHACK,
+ RF_ADDITIVE,
+ RF_USEAXIS,
+ RF_NOSHADOW
+};
+#endif
+
+// TODO CEV move the definitions below
+
+const float RANGE_MELEE = 0; // range values; see ai_range ()
+const float RANGE_NEAR = 1;
+const float RANGE_MID = 2;
+const float RANGE_FAR = 3;

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

Diff qc/defs_ctypes.qc

diff --git a/qc/defs_ctypes.qc b/qc/defs_ctypes.qc
new file mode 100644
index 0000000..5269bf6
--- /dev/null
+++ b/qc/defs_ctypes.qc
@@ -0,0 +1,300 @@
+//=============================================================================
+// CLASSTYPES -- inspired by the system used in Arcane Dimensions -- CEV
+//=============================================================================
+
+//======================================================================
+// fields
+//======================================================================
+
+.float classgroup; // used to identify base classes
+.float classtype; // used to identify an entity's type
+
+//----------------------------------------------------------------------
+// classtype list; shared by client & server
+//----------------------------------------------------------------------
+enum
+{
+ CT_WORLD, // world entity
+
+ // monsters
+ CT_PLAYER, // player (client)
+
+ // info
+ CT_INFO_FOCAL_POINT, // cutscenes
+ CT_INFO_INTERMISSION, // id1, end-of-map camera position
+ CT_INFO_INTERMISSIONTEXT, // pd3? intermission text ent
+ CT_INFO_MONSTER_SPAWNPOINT, // pd3 monster spawnpoint
+ CT_INFO_MOVIE_CAMERA, // cutscenes
+ CT_INFO_NOTNULL, // id1?
+ CT_INFO_NULL, // id1?
+ CT_INFO_PLAYER_START, // id1 player start
+ CT_INFO_PLAYER_START2, // id1 player start2
+ CT_INFO_PLAYER_COOP, // id1 player coop start
+ CT_INFO_PLAYER_DEATHMATCH, // id1 player deathmatch start
+ CT_INFO_ROTATE, // Hipnotic info_rotate
+ CT_INFO_TELEPORT_CHANGEDEST, // Qmaster teleporter changedest
+ CT_INFO_TELEPORT_DESTINATION, // id1 teleporters
+ CT_INFO_TELEPORT_RANDOM, // teleporters
+ CT_INFO_TESTPLAYERSTART, // test player start
+
+ // func
+ CT_FUNC_BOB, // RennyC func_bob
+ CT_FUNC_BOSSGATE, // id1 func_bossgate
+ CT_FUNC_BREAKABLE, // AD with mod. by Qmaster, iw, and d_ds
+ CT_FUNC_BUTTON, // id1 / pd3 func_button
+ CT_FUNC_COUNTER, // Hipnotic func_counter
+ CT_FUNC_DOOR, // id1 doors
+ CT_FUNC_DOOR_SECRET, // id1 secret door
+ CT_FUNC_ELVTR_BUTTON, // Rogue elevator buttons
+ CT_FUNC_EPISODEGATE, // id1 func_episodegate
+ CT_FUNC_EXPLOBOX, // id1 func_explobox
+ CT_FUNC_FALL, // RennyC func_fall
+ CT_FUNC_FALL2, // RennyC & whirledtsar func_fall2
+ CT_FUNC_ILLUSIONARY, // id1 func_illusionary
+ CT_FUNC_LASER, // Rubicon2 func_laser
+ CT_FUNC_MONSTER_SPAWNER, // progs_dump monster spawner
+ CT_FUNC_MOVEWALL, // Hipnotic rotation
+ CT_FUNC_NEW_PLAT, // Rogue / PD3 new_plat
+ CT_FUNC_ONCOUNT, // Hipnotic func_oncount
+ CT_FUNC_PARTICLEFIELD, // Hipnotic particle field
+ CT_FUNC_PLAT, // id1 plats / lifts
+ CT_FUNC_ROTATE_DOOR, // Hipnotic rotation
+ CT_FUNC_ROTATE_ENTITY, // Hipnotic rotation
+ CT_FUNC_ROTATE_TRAIN, // Hipnotic rotation
+ CT_FUNC_SHADOW, // pd3 func_shadow
+ CT_FUNC_TOGGLEVISIBLEWALL, // pd3(?) togglevisiblewall
+ CT_FUNC_TOGGLEWALL, // Hipnotic func_togglewall
+ CT_FUNC_TRAIN, // id1 train
+ CT_FUNC_WALL, // func_wall
+
+ // gibs
+ CT_GIB_HEAD_ARMY, // deadstuff
+ CT_GIB_HEAD_DEMON, //
+ CT_GIB_HEAD_DOG, //
+ CT_GIB_HEAD_ENFORCER, //
+ CT_GIB_HEAD_HELL_KNIGHT, //
+ CT_GIB_HEAD_KNIGHT, //
+ CT_GIB_HEAD_OGRE, //
+ CT_GIB_HEAD_PLAYER, //
+ CT_GIB_HEAD_SHALRATH, //
+ CT_GIB_HEAD_SHAMBLER, //
+ CT_GIB_HEAD_WIZARD, //
+ CT_GIB_MISC_1, //
+ CT_GIB_MISC_2, //
+ CT_GIB_MISC_3, //
+
+ // hazards
+ CT_HAZARD_LTRAIL_START, // DOE lightning trail
+ CT_HAZARD_LTRAIL_RELAY, // DOE lightning trail
+ CT_HAZARD_LTRAIL_END, // DOE lightning trail
+ CT_HAZARD_SHOOTER, // trap_shooter
+ CT_HAZARD_SPIKESHOOTER, // trap_spikeshooter
+ CT_HAZARD_SWITCHED_SHOOTER, // trap_switched_shooter
+
+ // items
+ CT_ITEM_AMMO_CELLS, // id1 item_cells
+ CT_ITEM_AMMO_SPIKES, // id1 item_spikes (nails)
+ CT_ITEM_AMMO_ROCKETS, // id1 item_rockets
+ CT_ITEM_AMMO_SHELLS, // id1 item_shells
+ CT_ITEM_ARMOR_GREEN, // id1 armor1 Green Armor
+ CT_ITEM_ARMOR_YELLOW, // id1 armor2 Yellow Armor
+ CT_ITEM_ARMOR_RED, // id1 armorInv Red Armor
+ CT_ITEM_ARMOR_SHARD, // pd3 armor shards
+ CT_ITEM_AXE, // id1 weapon axe
+ CT_ITEM_BACKPACK, // id1 backpacks
+ CT_ITEM_ENVIROSUIT, // id1 powerup environment suit
+ CT_ITEM_GRENADE_LAUNCHER, // id1 weapon grenade launcher
+ CT_ITEM_HEALTH, // id1 health
+ CT_ITEM_HEALTH_VIAL, // pd3 health vial (5hp bubble)
+ CT_ITEM_INVISIBILITY, // id1 powerup ring of shadows
+ CT_ITEM_INVULNERABILITY, // id1 powerup pentagram of protection
+ CT_ITEM_KEY1, // id1 key1 (silver)
+ CT_ITEM_KEY2, // id1 key2 (gold)
+ CT_ITEM_KEY_CUSTOM, // pd3 custom keys
+ CT_ITEM_LIGHTNING_GUN, // id1 weapon thunderbolt (LG)
+ CT_ITEM_NAILGUN, // id1 weapon nailgun (NG)
+ CT_ITEM_QUAD, // id1 powerup quad damage
+ CT_ITEM_ROCKET_LAUNCHER, // id1 weapon rocket launcher (RL)
+ CT_ITEM_RUNE, // id1 rune/sigil
+ CT_ITEM_SHOTGUN, // id1 weapon shotgun (SG)
+ CT_ITEM_SUPER_NAILGUN, // id1 weapon super nailgun (SNG)
+ CT_ITEM_SUPER_SHOTGUN, // id1 weapon super shotgun (SSG)
+
+ // lights
+ CT_LIGHT, // id1 light
+ CT_LIGHT_CANDLE, // light_candle
+ CT_LIGHT_FLAME_LARGE_YELLOW, // id1
+ CT_LIGHT_FLAME_SMALL_YELLOW, // id1
+ CT_LIGHT_FLAME_SMALL_WHITE, // id1
+ CT_LIGHT_FLUORO, // id1 light_fluoro
+ CT_LIGHT_FLUOROSPARK, // id1 light_fluorospark
+ CT_LIGHT_GLOBE, // id1 light_globe
+ CT_LIGHT_SPRITE_FLAME, // pd3 sprite flame
+ CT_LIGHT_TORCH_SMALL_WALLTORCH, // id1
+
+ // misc
+ CT_MISC_AIR_BUBBLES, // id1 air bubbles
+ CT_MISC_AMBIENT_COMPHUM, // computer hum
+ CT_MISC_AMBIENT_DRIP, // drip sound
+ CT_MISC_AMBIENT_DRONE, // drone sound
+ CT_MISC_AMBIENT_FBUZZ, // fluoro buzz
+ CT_MISC_AMBIENT_GENERAL, // Rubicon Rumble devkit ambient_general
+ CT_MISC_AMBIENT_FIRE, // ambient fire sound
+ CT_MISC_AMBIENT_LBUZZ, // light buzz
+ CT_MISC_AMBIENT_SUCKWIND, // suck wind
+ CT_MISC_AMBIENT_SWAMP1, // swamp 1
+ CT_MISC_AMBIENT_SWAMP2, // swamp 2
+ CT_MISC_AMBIENT_THUNDER, // Zerstorer ambient thunder
+ CT_MISC_AMBIENT_WATER1, // ambient water 1
+ CT_MISC_AMBIENT_WIND2, // ambient wind 2
+ CT_MISC_BOB, // RennyC func_bob
+ CT_MISC_EXPLOBOX, // id1 misc_explobox
+ CT_MISC_EXPLOBOX2, // id1 misc_explobox2
+ CT_MISC_FIREBALL, // id1 misc_fireball
+ CT_MISC_INFIGHT, // progs_dump 3 misc_infight
+ CT_MISC_MODEL, // misc_model -- Joshua Skelton
+ CT_MISC_MODELCANDLE, // model_candle
+ CT_MISC_MODELTRAIN, //
+ CT_MISC_NOISEMAKER, // pd3 some kind of testing ent?
+ CT_MISC_PARTICLES, // Rubicon2 misc_splash
+ CT_MISC_PARTICLESPRAY, // custents misc_particlespray
+ CT_MISC_PARTICLE_STREAM, // Zerstorer misc_particle_stream
+ CT_MISC_PLAY_BFIELD, // pd3 play
+ CT_MISC_PLAY_BRLIGHT, // pd3 play
+ CT_MISC_PLAY_DIMLIGHT, // pd3 play
+ CT_MISC_PLAY_EXPLOSION, // pd3 play
+ CT_MISC_PLAY_GIBS, // pd3 play
+ CT_MISC_PLAY_LAVASPLASH, // pd3 play
+ CT_MISC_PLAY_MFLASH, // pd3 play muzzleflash
+ CT_MISC_PLAY_SOUND, // pd3 play_sound
+ CT_MISC_PLAY_SOUND_TRIGGERED, // pd3 play_sound
+ CT_MISC_ROTATE_OBJECT, // Hipnotic rotation
+ CT_MISC_SHADOWCONTROLLER, // pd3 shadows
+ CT_MISC_SPARKS, // misc_sparks
+ CT_MISC_VIEWTHING, // id1?
+ CT_MISC_TELE_FOG, // pd3 play
+ CT_MISC_TELEPORTTRAIN, // id1 teleport train
+
+ // monsters
+ CT_MONSTER_BOSS_CHTHON, // id1 chthon
+ CT_MONSTER_BOSS_CHTHON2, // pd3 killable chthon
+ CT_MONSTER_BOSS_OLDONE, // id1 shub
+ CT_MONSTER_BOSS_OLDONE2, // pd3 killable shub
+ CT_MONSTER_DEATHKNIGHT, // id1 hell knight / death knight
+ CT_MONSTER_DOG, // id1 dog / pupper
+ CT_MONSTER_ENFORCER, // id1 enforcer
+ CT_MONSTER_FIEND, // id1 demon1 / fiend / jumpy friend
+ CT_MONSTER_FISH, // id1 fishies
+ CT_MONSTER_GRUNT, // id1 army / grunt / soldier
+ CT_MONSTER_KNIGHT, // id1 knights
+ CT_MONSTER_OGRE, // id1 ogres
+ CT_MONSTER_OGRE_MARKSMAN, // id1 ogre marksman
+ CT_MONSTER_SCRAG, // id1 wizard / scrag
+ CT_MONSTER_SHAMBLER, // id1 shambler
+ CT_MONSTER_VORE, // id1 shalrath / vore
+ CT_MONSTER_ZOMBIE, // id1 zombie
+
+ // paths
+ CT_PATH_CORNER, // id1 path_corner
+ CT_PATH_ROTATE, // Hipnotic rotation
+
+ // projectiles
+ CT_PROJECTILE_BULLET, // id1 shotgun pellets
+ CT_PROJECTILE_FIREBALL, // created by misc_fireball
+ CT_PROJECTILE_FLAK, // pd3 flak projectile
+ CT_PROJECTILE_GRENADE, // id1 grenade projectile
+ CT_PROJECTILE_HKNIGHT, // id1 hell / death knight magic
+ CT_PROJECTILE_LASERBEAM, // id1 laser projectile
+ CT_PROJECTILE_LAVABALL, // id1 lava balls (chthon projectile)
+ CT_PROJECTILE_MINIGRENADE, // DOE mini grenades
+ CT_PROJECTILE_MULTIGRENADE, // DOE multi grenades (spawns the mini)
+ CT_PROJECTILE_ROCKET, // id1 rocket projectile
+ CT_PROJECTILE_SPIKE, // id1 nail/spike projectile
+ CT_PROJECTILE_VOREBALL, // id1 vore projectile
+ CT_PROJECTILE_WIZARDMISSILE, // id1 Wizard (Scrag) missile
+ CT_PROJECTILE_ZOMBIECHUNK, // id1 zombie gib projectile
+
+ // targets
+ CT_TARGET_AUTOSAVE, // target_autosave from copper
+ CT_TARGET_FOGBLEND, // fog
+ CT_TARGET_SETCOUNT, //
+ CT_TARGET_SETSTATE, //
+ CT_TARGET_TEXTSTORY, // progs_dump textstory
+ CT_TARGET_TEXTSTORY_HELPER, // textstory helper subclass
+
+ // triggers
+ CT_TRIGGER_CAMERA, // cutscenes
+ CT_TRIGGER_CAMERA_POINT, // cutscenes
+ CT_TRIGGER_CDTRACK, // progs_dump 3 cd track trigger
+ CT_TRIGGER_CHANGELEVEL, // id1 change level trigger
+ CT_TRIGGER_CHANGEMUSIC, // jleww via changemusic.rar
+ CT_TRIGGER_CHANGETARGET, // change an entity's target field
+ CT_TRIGGER_COUNTER, // id1 trigger_counter
+ CT_TRIGGER_CVARSET, // was in cutscene.qc; from Drake?
+ CT_TRIGGER_EVERYTHING, // progs_dump 3; unknown prior source
+ CT_TRIGGER_FILTER, //
+ CT_TRIGGER_FOG, // fog
+ CT_TRIGGER_FOGBLEND, // fog
+ CT_TRIGGER_HEAL, // custents trigger_heal by TGR
+ CT_TRIGGER_HURT, // Hipnotic trigger_hurt
+ CT_TRIGGER_LADDER, // rubicon2 ladders
+ CT_TRIGGER_LOOK, // trigger_onlookat by NullPointPaladin
+ CT_TRIGGER_MONSTERFACE, // progs_dump 3 monsterface
+ CT_TRIGGER_MONSTERJUMP, // id1 trigger_monsterjump
+ CT_TRIGGER_MULTIPLE, // id1 trigger_multiple
+ CT_TRIGGER_ONCE, // id1 trigger_once
+ CT_TRIGGER_ONLYREGISTERED, // id1 registered content trigger
+ CT_TRIGGER_PUSH, // id1 push/wind brush
+ CT_TRIGGER_PUSH_CUSTOM, // progs_dump push custom
+ CT_TRIGGER_RELAY, // id1 trigger_relay
+ CT_TRIGGER_SECRET, // id1 secret trigger
+ CT_TRIGGER_SETGRAVITY, // Hipnotic gravity trigger
+ CT_TRIGGER_SETSKILL, // id1 setskill trigger
+ CT_TRIGGER_SHAKE, // ground-shake trigger
+ CT_TRIGGER_TAKE_WEAPON, // take_weapon
+ CT_TRIGGER_TELEPORT, // id1 teleporters
+ CT_TRIGGER_TEXTSTORY, // progs_dump textstory
+ CT_TRIGGER_USEKEY, // originally based on Hipnotic code
+ CT_TRIGGER_VOID, // necros' trigger_void, modified
+
+ // temp entities
+ CT_TEMP_ANIM_CONTROLLER, // animation controller
+ CT_TEMP_BUBBLES, // air bubble
+ CT_TEMP_DELAYEDUSE, // delayed sub_usetargets
+ CT_TEMP_DOOR_TRIGGER, // id1 doors
+ CT_TEMP_EXPLOSION, // id1 explosions (BecomeExplosion)
+ CT_TEMP_FALL2_HELPER, // RennyC & whirledtsar fall2
+ CT_TEMP_FOG_CONTROLLER, // pd3 fog
+ CT_TEMP_KEYDEF, // pd3 custom key definition
+ CT_TEMP_LASER_HELPER, // Rubicon2 func_laser
+ CT_TEMP_NEWPLAT_TRIGGER, // pd3 newplats
+ CT_TEMP_PLAT_TRIGGER, // id1 plats
+ CT_TEMP_ROTATE_CONTROLLER, // rotation controller
+ CT_TEMP_SPARK, // misc_sparks
+ CT_TEMP_WIZARDSPELL // id1 wizard spell (spawns missiles)
+};
+
+//----------------------------------------------------------------------
+// classgroups, defined as needed; I did not want to do this -- CEV
+// go no higher than 24 bits (according to the FTEQCC manual) -- CEV
+// current count: 16 -- CEV
+//----------------------------------------------------------------------
+enumflags
+{
+ CG_TEMPENTITY, // temporary entities
+ CG_MAPENTITY, // mapper-placeable entities
+ CG_FUNC, // func_*
+ CG_FUNC_ROTATE, // rotation objects
+ CG_ITEM, // items
+ CG_ITEM_ARMOR, // armor pickups
+ CG_ITEM_AMMO, // ammunition boxes
+ CG_ITEM_HEALTH, // health pickups
+ CG_ITEM_KEY, // keys
+ CG_ITEM_POWERUP, // powerups
+ CG_ITEM_WEAPON, // weapon pickups
+ CG_MONSTER, //
+ CG_MONSTER_FLY, //
+ CG_MONSTER_SWIM, //
+ CG_PROJECTILE, // missiles & projectiles
+ CG_TRIGGER // trigger_*
+};

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

Diff qc/defs_entvars.qc

diff --git a/qc/defs_entvars.qc b/qc/defs_entvars.qc
deleted file mode 100644
index 8fdc4a8..0000000
--- a/qc/defs_entvars.qc
+++ /dev/null
@@ -1,115 +0,0 @@
-//==============================================================================
-// 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; // *** only some of the time -- CEV
-.vector oldorigin; // ***
-.vector velocity;
-.vector angles;
-.vector avelocity;
-
-.vector punchangle; // temp angle adjust from dmg or recoil
-
-.string classname; // spawn function
-.string model;
-.float frame;
-.float skin;
-.float effects;
-
-.vector mins, maxs; // bounding box extents relative to org
-.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
- // next three comments from AD
-.float takedamage; // Check by many functions for damage
-.entity chain; // Can be overwritten by find command
-.float deadflag; // Used by client functions
-
-.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; // Make an entity instantly turn
-.vector v_angle; // view / targeting angle for players
-.float idealpitch; // calc pitch angle for lookup up slopes
-
-.string netname;
-
-.entity enemy; // current entity enemy
-
-.float flags; // FL bitflag operations
-
-.float colormap;
-.float team;
-
-.float max_health; // players maximum health is stored here
-
-.float teleport_time; // teleport exit +back timer
-
-.float armortype; // save this fraction of incoming damage
-.float armorvalue;
-
-.float waterlevel; // 0: none, 1: feet, 2: waist, 3: eyes
-.float watertype; // a contents value
-
-.float ideal_yaw; // ideal direction for entity to face
-.float yaw_speed; // speed (in degrees) turning towards
-
-.entity aiment;
-
-.entity goalentity; // a movetarget or an enemy
-
-.float spawnflags; // mostly custom options for each entity
-
-.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; // 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
-//================================================

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

Diff qc/defs_fields.qc

diff --git a/qc/defs_fields.qc b/qc/defs_fields.qc
new file mode 100644
index 0000000..4bbf6e9
--- /dev/null
+++ b/qc/defs_fields.qc
@@ -0,0 +1,115 @@
+//==============================================================================
+// 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; // *** only some of the time -- CEV
+.vector oldorigin; // ***
+.vector velocity;
+.vector angles;
+.vector avelocity;
+
+.vector punchangle; // temp angle adjust from dmg or recoil
+
+.string classname; // spawn function
+.string model;
+.float frame;
+.float skin;
+.float effects;
+
+.vector mins, maxs; // bounding box extents relative to org
+.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
+ // next three comments from AD
+.float takedamage; // Check by many functions for damage
+.entity chain; // Can be overwritten by find command
+.float deadflag; // Used by client functions
+
+.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; // Make an entity instantly turn
+.vector v_angle; // view / targeting angle for players
+.float idealpitch; // calc pitch angle for lookup up slopes
+
+.string netname;
+
+.entity enemy; // current entity enemy
+
+.float flags; // FL bitflag operations
+
+.float colormap;
+.float team;
+
+.float max_health; // players maximum health is stored here
+
+.float teleport_time; // teleport exit +back timer
+
+.float armortype; // save this fraction of incoming damage
+.float armorvalue;
+
+.float waterlevel; // 0: none, 1: feet, 2: waist, 3: eyes
+.float watertype; // a contents value
+
+.float ideal_yaw; // ideal direction for entity to face
+.float yaw_speed; // speed (in degrees) turning towards
+
+.entity aiment;
+
+.entity goalentity; // a movetarget or an enemy
+
+.float spawnflags; // mostly custom options for each entity
+
+.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; // 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
+//======================================================================

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

Diff qc/defs_globals.qc

diff --git a/qc/defs_globals.qc b/qc/defs_globals.qc
new file mode 100644
index 0000000..ae35d5c
--- /dev/null
+++ b/qc/defs_globals.qc
@@ -0,0 +1,84 @@
+//==============================================================================
+// SOURCE FOR GLOBALVARS_T C STRUCTURE
+//==============================================================================
+
+//======================================================================
+// system globals
+//======================================================================
+entity self;
+entity other;
+entity world;
+float time;
+float frametime;
+
+// 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.
+float force_retouch;
+
+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 // comments below copied from AD
+float trace_allsolid; // both start and end were in a solid
+float trace_startsolid; // the start point was in a solid
+float trace_fraction; // how much of the vector (% from 0 to 1
+ // was traced before it hit something
+vector trace_endpos; // the final position
+vector trace_plane_normal; // the normal of the surface it hit
+float trace_plane_dist; // used for angled surfaces (?)
+entity trace_ent; // the entity it hit (world if nothing)
+float trace_inopen; // if some portion of the trace is
+ // in the air
+float trace_inwater; // if some portion of the trace is
+ // in water
+
+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. set 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
+//======================================================================

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

Diff qc/defs_globalvars.qc

diff --git a/qc/defs_globalvars.qc b/qc/defs_globalvars.qc
deleted file mode 100644
index dbfc510..0000000
--- a/qc/defs_globalvars.qc
+++ /dev/null
@@ -1,84 +0,0 @@
-//==============================================================================
-// SOURCE FOR GLOBALVARS_T C STRUCTURE
-//==============================================================================
-
-//======================================================================
-// system globals
-//======================================================================
-entity self;
-entity other;
-entity world;
-float time;
-float frametime;
-
-// 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.
-float force_retouch;
-
-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 // comments below copied from AD
-float trace_allsolid; // both start and end were in a solid
-float trace_startsolid; // the start point was in a solid
-float trace_fraction; // how much of the vector (% from 0 to 1
- // was traced before it hit something
-vector trace_endpos; // the final position
-vector trace_plane_normal; // the normal of the surface it hit
-float trace_plane_dist; // used for angled surfaces (?)
-entity trace_ent; // the entity it hit (world if nothing)
-float trace_inopen; // if some portion of the trace is
- // in the air
-float trace_inwater; // if some portion of the trace is
- // in water
-
-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. set 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
-//================================================

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

Diff qc/defs_misc.qc

diff --git a/qc/defs_misc.qc b/qc/defs_misc.qc
deleted file mode 100644
index 58881ca..0000000
--- a/qc/defs_misc.qc
+++ /dev/null
@@ -1,569 +0,0 @@
-//==============================================================================
-// VARS NOT REFERENCED BY C CODE
-//==============================================================================
-
-//======================================================================
-// Constants
-//======================================================================
-
-// inspired by Copper
-const string version = "\n\"Dog\" mode for FTE\nversion 0.1a";
-
-// constants
-const float FALSE = 0;
-const float TRUE = 1;
-const float NEGATIVE = -1;
-
-// worldtype values
-const float WORLDTYPE_MEDIEVAL = 0;
-const float WORLDTYPE_METAL = 1;
-const float WORLDTYPE_BASE = 2;
-
-// edict.flags
-const float FL_FLY = 1;
-const float FL_SWIM = 2;
-const float FL_CLIENT = 8; // set for all client edicts
-const float FL_INWATER = 16; // for enter / leave water splash
-const float FL_MONSTER = 32;
-const float FL_GODMODE = 64; // player cheat
-const float FL_NOTARGET = 128; // player cheat
-const float FL_ITEM = 256; // extra wide size for bonus items
-const float FL_ONGROUND = 512; // standing on something
-const float FL_PARTIALGROUND = 1024; // not all corners are valid
-const float FL_WATERJUMP = 2048; // player jumping out of water
-const float FL_JUMPRELEASED = 4096; // for jump debouncing
-const float FL_NOCENTERPRINT = 65536; // don't centerprint entity's message
- // field when its targets are used
-// edict.movetype values
-const float MOVETYPE_NONE = 0; // never moves
-// float MOVETYPE_ANGLENOCLIP = 1;
-// float MOVETYPE_ANGLECLIP = 2;
-const float MOVETYPE_WALK = 3; // players only
-const float MOVETYPE_STEP = 4; // discrete, not real time unless fall
-const float MOVETYPE_FLY = 5;
-const float MOVETYPE_TOSS = 6; // gravity
-const float MOVETYPE_PUSH = 7; // no clip to world, push and crush
-const float MOVETYPE_NOCLIP = 8;
-const float MOVETYPE_FLYMISSILE = 9; // fly with extra size against monsters
-const float MOVETYPE_BOUNCE = 10;
-const float MOVETYPE_BOUNCEMISSILE = 11; // bounce with extra size
-
-// edict.solid values
-const float SOLID_NOT = 0; // no interaction with other objects
-const float SOLID_TRIGGER = 1; // touch on edge, but not blocking
-const float SOLID_BBOX = 2; // touch on edge, block
-const float SOLID_SLIDEBOX = 3; // touch on edge, but not an onground
-const float SOLID_BSP = 4; // bsp clip, touch on edge, block
-
-// range values
-const float RANGE_MELEE = 0;
-const float RANGE_NEAR = 1;
-const float RANGE_MID = 2;
-const float RANGE_FAR = 3;
-
-// deadflag values
-const float DEAD_NO = 0;
-const float DEAD_DYING = 1;
-const float DEAD_DEAD = 2;
-const float DEAD_RESPAWNABLE = 3;
-
-// takedamage values
-const float DAMAGE_NO = 0;
-const float DAMAGE_YES = 1;
-const float DAMAGE_AIM = 2;
-
-// items
-const float IT_AXE = 4096;
-const float IT_SHOTGUN = 1;
-const float IT_SUPER_SHOTGUN = 2;
-const float IT_NAILGUN = 4;
-const float IT_SUPER_NAILGUN = 8;
-const float IT_GRENADE_LAUNCHER = 16;
-const float IT_ROCKET_LAUNCHER = 32;
-const float IT_LIGHTNING = 64;
-const float IT_EXTRA_WEAPON = 128;
-
-const float IT_SHELLS = 256;
-const float IT_NAILS = 512;
-const float IT_ROCKETS = 1024;
-const float IT_CELLS = 2048;
-
-const float IT_ARMOR1 = 8192;
-const float IT_ARMOR2 = 16384;
-const float IT_ARMOR3 = 32768;
-const float IT_SUPERHEALTH = 65536;
-
-const float IT_KEY1 = 131072;
-const float IT_KEY2 = 262144;
-
-const float IT_INVISIBILITY = 524288;
-const float IT_INVULNERABILITY = 1048576;
-const float IT_SUIT = 2097152;
-const float IT_QUAD = 4194304;
-
-// point content values
-const float CONTENT_EMPTY = -1;
-const float CONTENT_SOLID = -2;
-const float CONTENT_WATER = -3;
-const float CONTENT_SLIME = -4;
-const float CONTENT_LAVA = -5;
-const float CONTENT_SKY = -6;
-
-const vector VEC_ORIGIN = '0 0 0';
-// Player
-const vector VEC_HULL_MIN = '-16 -16 -24';
-const vector VEC_HULL_MAX = '16 16 32';
-const vector VEC_HULL_SIZE = '32 32 56';
-// Ogres, Shalrath, Demon, Shambler
-const vector VEC_HULL2_MIN = '-32 -32 -24';
-const vector VEC_HULL2_MAX = '32 32 64';
-const vector VEC_HULL2_SIZE = '64 64 88';
-
-// protocol bytes
-const float SVC_UPDATESTAT = 3; // required by Hipnotic code
-const float SVC_SETVIEWPORT = 5; // Camera Hip. Drake devkit dumptruck_ds
-const float SVC_SETVIEWANGLES = 10; // Camera Hip. Drake devkit dumptruck_ds
-const float SVC_TEMPENTITY = 23;
-const float SVC_KILLEDMONSTER = 27;
-const float SVC_FOUNDSECRET = 28;
-const float SVC_INTERMISSION = 30;
-const float SVC_FINALE = 31;
-const float SVC_CDTRACK = 32;
-const float SVC_SELLSCREEN = 33;
-const float SVC_CUTSCENE = 34; // Hipnotic Drake devkit -- dumptruck_ds
-
-const float TE_SPIKE = 0;
-const float TE_SUPERSPIKE = 1;
-const float TE_GUNSHOT = 2;
-const float TE_EXPLOSION = 3;
-const float TE_TAREXPLOSION = 4;
-const float TE_LIGHTNING1 = 5;
-const float TE_LIGHTNING2 = 6;
-const float TE_WIZSPIKE = 7;
-const float TE_KNIGHTSPIKE = 8;
-const float TE_LIGHTNING3 = 9;
-const float TE_LAVASPLASH = 10;
-const float TE_TELEPORT = 11;
-const float TE_EXPLOSION2 = 12; // from doe -- dumptruck_ds
-
-// sound channels: channel 0 never willingly overrides, other channels
-// (1-7) always override a playing sound on that channel
-const float CHAN_AUTO = 0;
-const float CHAN_WEAPON = 1;
-const float CHAN_VOICE = 2;
-const float CHAN_ITEM = 3;
-const float CHAN_BODY = 4;
-const float CHAN_FEET = 5; // dedicated channel for steps -- CEV
-
-const float ATTN_NONE = 0;
-const float ATTN_NORM = 1;
-const float ATTN_IDLE = 2;
-const float ATTN_STATIC = 3;
-
-// update types
-const float UPDATE_GENERAL = 0;
-const float UPDATE_STATIC = 1;
-const float UPDATE_BINARY = 2;
-const float UPDATE_TEMP = 3;
-
-// entity effects
-const float EF_BRIGHTFIELD = 1;
-const float EF_MUZZLEFLASH = 2;
-const float EF_BRIGHTLIGHT = 4;
-const float EF_DIMLIGHT = 8;
-
-// messages
-const float MSG_BROADCAST = 0; // unreliable to all
-const float MSG_ONE = 1; // reliable to one (msg_entity)
-const float MSG_ALL = 2; // reliable to all
-const float MSG_INIT = 3; // write to the init string
-// The byte(s) will be written into the multicast buffer for more
-// selective sending. Messages sent this way will never be split across
-// packets, and using this for csqc-only messages will not break protocol
-// translation.
-const float MSG_MULTICAST = 4;
-// The byte(s) will be written into the entity buffer. This is a special
-// value used only inside 'SendEntity' functions.
-const float MSG_ENTITY = 5;
-
-// entity state
-const float STATE_ACTIVE = 0;
-const float STATE_INACTIVE = 1;
-const float STATE_INVISIBLE = 8;
-
-// known_release values -- iw
-const float KNOWN_RELEASE_NOT = 0;
-const float KNOWN_RELEASE_ID1 = 1;
-const float KNOWN_RELEASE_FUNC_MAPJAMX = 2;
-
-const float EV_VOID = 0;
-const float EV_STRING = 1;
-const float EV_FLOAT = 2;
-const float EV_VECTOR = 3;
-const float EV_ENTITY = 4;
-const float EV_FIELD = 5;
-const float EV_FUNCTION = 6;
-const float EV_POINTER = 7;
-const float EV_INTEGER = 8;
-
-// program-wide spawnflags
-const float SPAWN_SILENTLY = 2097152;
-const float TRIGGER_CENTERPRINTALL = 1048576;
-
-// traceline / tracebox flags from fteextensions.qc -- CEV
-const float MOVE_NORMAL = 0;
-// The trace will ignore all non-solid_bsp entities.
-const float MOVE_NOMONSTERS = 1;
-// The trace will use a bbox size of +/- 15 against entities with FL_MONSTER
-const float MOVE_MISSILE = 2;
-// Traces will impact the actual mesh of the model instead of merely their
-// bounding box. Should generally only be used for tracelines. Note that
-// this flag is unreliable as an object can animate through projectiles.
-// The bounding box MUST be set to completely encompass the entity or those
-// extra areas will be non-solid (leaving a hole for things to go through).
-const float MOVE_HITMODEL = 4;
-// This trace type will impact only triggers. It will ignore non-solid entities.
-const float MOVE_TRIGGERS = 16;
-// This type of trace will hit solids and triggers alike. Even non-solid
-// entities.
-const float MOVE_EVERYTHING = 32;
-
-//======================================================================
-// globals
-//======================================================================
-
-// latched globals - re-set every StartFrame
-float skill;
-float frame_airstep;
-float frame_bigcoords;
-float frame_clrun;
-float frame_gravity;
-float frame_maxvelocity;
-float frame_nostep;
-float frame_standardphysics;
-float frame_walljump;
-
-// per-map settings
-float known_release; // ID for a release, values above -- iw
-
-float framecount;
-float movedist;
-float gameover; // set when a rule exits
-
-entity activator; // entity that activated trigger/brush
-entity damage_attacker; // set by T_Damage
-
-nosave float cleanUpClientStuff;
-nosave float gamestarted;
-
-string string_null; // null string
-
-//======================================================================
-// world fields (FIXME: make globals)
-//======================================================================
-.string wad;
-.string map;
-.float worldtype; // 0=medieval 1=metal 2=base
-.float skip_id1_overrides;
-.string killtarget;
-
-//======================================================================
-// quakeed fields
-//======================================================================
-.float light_lev; // not used ingame, parsed by light util
-.float style;
-
-//======================================================================
-// monster ai
-//======================================================================
-// TODO CEV rework into do_damage and do_destroy
-.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;
-
-//======================================================================
-// player only fields
-//======================================================================
-.float walkframe;
-
-.float attack_finished;
-.float pain_finished;
-
-.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 rad_time;
-.float fly_sound;
-
-.float axhitme;
-
-// 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 show_hostile;
-
-.float jump_flag; // player jump flag
-.float swim_flag; // player swimming sound flag
-.float air_finished; // when time > air_finished, drown
-.float bubble_count; // keeps track of the number of bubbles
-.string deathtype; // keeps track of how the player died
-
-//======================================================================
-// object stuff
-//======================================================================
-.string mdl;
-.vector mangle; // angle at start
-.string origmodel; // switchables brushes (added by bmFbr)
-.float t_length, t_width;
-
-//======================================================================
-// doors, etc
-//======================================================================
-.float wait; // time from firing to restarting
-.float delay; // time from activation to firing
-.entity trigger_field; // TODO CEV: cutscene, shambler
-.string noise4;
-.float dmg; // damage done by door when hit
-
-//======================================================================
-// monsters
-//======================================================================
-.float pausetime;
-.entity movetarget;
-.float infight_mode;
-
-// projectiles
-.float homing;
-.float projexpl;
-.float proj_speed_mod;
-.float proj_basespeed;
-
-//======================================================================
-// misc
-//======================================================================
-.float cnt; // misc flag
-
-//======================================================================
-// subs
-//======================================================================
-.vector finaldest, finalangle;
-
-//======================================================================
-// triggers
-//======================================================================
-.float count; // for counting triggers
-
-//======================================================================
-// plats / doors / buttons
-//======================================================================
-.float state;
-
-//======================================================================
-// fog // progs_dump
-//======================================================================
-.vector fog_color, fog_color2;
-.float fog_density, fog_density2;
-.float skyfog_density, skyfog_density2;
-.entity fogblend_entity;
-.float distance;
-
-//======================================================================
-// sounds
-//======================================================================
-.float waitmin /*, waitmax*/;
-// .float distance;
-.float volume;
-
-//======================================================================
-// support for item_key_custom -- iw
-//======================================================================
-.string keyname;
-.float customkeys;
-
-//======================================================================
-// variables for enhanced triggering from Custents -- dumptruck_ds
-//======================================================================
-.string target2; // second target's name
-.string target3; // third target's name
-.string target4; // fourth target's name
-.string targetname2; // second name
-.string targetname3; // third name
-.string targetname4; // fourth name
-.string killtarget2; // second target to kill
-string lastnameused; // the targetname that was last used
- // to trigger somthing
-
-//======================================================================
-// misc pd_additions
-//======================================================================
-.float reset_items; // dumptruck_ds
-.float spawn_angry; // dumptruck_ds
-.string mdl_debris; // dumptruck_ds
-.float keep_ammo; // dumptruck_ds
-.string obit_name; // dumptruck_ds
-.string obit_method; // dumptruck_ds
-.float damage_mod; // dumptruck_ds
-
-/*==============================================================================
- combat.qc
-==============================================================================*/
-// .float is_waiting; // Supa, triggers, wait until activated
- // before we can trigger?
-.float gravity; // from custdefs.qc by way of Hipnotic
-const float STAT_TOTALMONSTERS = 12; // required by Hipnotic code
-
-// dumptruck_ds from Rogue eod defs
-
-/*============================================================================
- johnfitz new defs from Rubicon2
-============================================================================*/
-const float BREAKABLE_NO_MONSTERS = 1;
-
-.float wantedgravity; // thanks Spike!
-// .float ladder_step_finished; // footsteps on ladder -- dumptruck_ds
-
-// TODO CEV keep these
-.float alpha; // translucency in supported engines
-.vector pos1; // used by some func_ classes; vector
-.vector pos2; // fields seem to cause problems.
-
-// TODO CEV check these
-.float pain_threshold; // dumptruck_ds
-.string pain_target; // dumptruck_ds
-.float color; // Hipnotic
-.float megahealth_rottime; // dumptruck_ds
-.float sight_trigger; // dumptruck_ds
-.float keep_ammo; // dumptruck_ds
-.float berserk; // dumptruck_ds
-nosave float *world_sounds; // via Spike fun times! nosave=noclobber
-
-// Drake Cutscenes -- Borrowed from Zerstorer.
-.string script; // dhm - denotes which script to read.
-.string next_script; // dhm - denotes the current script.
-.string script_num; // dhm - number for info_scripts.
-// .string camera_point; // dhm - target for camera to move to.
-.string focal_point; // dhm - focus point for camera.
-.float script_delay; // dhm - time until next script.
-.float script_time; // dhm - used for script timing.
-.float script_count; // dhm - ditto.
-// cutscene.qc - - -
-void() Cutscene_Think;
-float cutscene; // Set to TRUE during a cutscene.
-float mindex_inviso; // Invisible (null sprite)
-
-// Custom Monster Sounds START -- dumptruck_ds
-.string snd_death;
-.string snd_pain;
-.string snd_sight;
-.string snd_attack;
-.string snd_hit;
-.string snd_idle;
-.string snd_land;
-.string snd_move;
-.string snd_misc;
-.string snd_misc1;
-.string snd_misc2;
-.string snd_misc3;
-// Custom Monster Sounds END -- dumptruck_ds
-
-// Custom Model Start -- dumptruck_ds
-.string mdl_head;
-.string mdl_body;
-.string mdl_proj;
-.string mdl_exproj;
-.float skin_head;
-.float skin_proj;
-.float skin_exproj;
-.string mdl_gib1;
-.string mdl_gib2;
-.string mdl_gib3;
-// addition by bmFbr for custom model bounding box definition
-.vector mdlsz, centeroffset;
-// Custom Model End -- dumptruck_ds
-
-.float drop_item; // key DropStuff
-
-// entity state
-.float estate;
-.float prevstate;
-
-.string include;
-.string type;
-
-.float last_setstate_frame = light_lev;
-.entity last_setstate = aiment;
-
-const float I_AM_TURRET = 262144; // dumptruck_ds
-
-// TODO CEV
-.vector cust_avelocity;
-
-// cshift controller
-.entity csfcontroller;
-
-.vector csf_color;
-.float csf_density;
-
-.float fade_amt;
-
-// TODO CEV shadows
-.float switchshadstyle;
-.float shadowoff;
-// .entity shadowcontroller;
-
-// worldspawn default mdls
-.string h_vial_mdl;
-.string h_25_mdl;
-.string h_15_mdl;
-.string h_mega_mdl;
-
-.string s_sm_mdl;
-.string s_lg_mdl;
-
-.string n_sm_mdl;
-.string n_lg_mdl;
-
-.string r_sm_mdl;
-.string r_lg_mdl;
-
-.string c_sm_mdl;
-.string c_lg_mdl;
-
-.string a_shr_mdl;
-.string a_grn_mdl;
-.string a_ylw_mdl;
-.string a_red_mdl;
-
-.entity infight_activator;
-
-#ifdef SSQC
-// TODO CEV
-// Called by the engine whenever an entity needs to be (re)sent to a client's
-// csprogs, either because SendFlags was set or because data was lost. Must
-// write its data to the MSG_ENTITY buffer. Will be called at the engine's
-// leasure.
-.float(entity playerent, float changedflags) SendEntity;
-// Indicates that something in the entity has been changed, and that it needs
-// to be updated to all players that can see it. The engine will clear it at
-// some point, with the cleared bits appearing in the 'changedflags' argument
-// of the SendEntity method.
-.float SendFlags;
-#endif
-
-#ifdef SSQC
-// Set by the engine before calls to spawn functions, and is most easily
-// parsed with the tokenize builtin. This allows you to handle halflife's
-// multiple-fields-with-the-same-name (or target-specific fields).
-__unused var string __fullspawndata;
-#endif

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

Diff qc/entrypoints.qc

diff --git a/qc/entrypoints.qc b/qc/entrypoints.qc
deleted file mode 100644
index 64c4961..0000000
--- a/qc/entrypoints.qc
+++ /dev/null
@@ -1,638 +0,0 @@
-//==============================================================================
-// server-side entrypoints; inspired by Nuclide's server/entry.qc -- CEV
-//==============================================================================
-
-//======================================================================
-// globals
-//======================================================================
-float intermission_running;
-float intermission_exittime;
-entity used_exit;
-string nextmap;
-
-//======================================================================
-// Helper functions - map & game rules
-//======================================================================
-
-//----------------------------------------------------------------------
-// NextLevel -- go to the next level for deathmatch
-// only called if a time or frag limit has expired
-//----------------------------------------------------------------------
-void() NextLevel =
-{
- local trigger_changelevel t_level;
-
- if (mapname == "start")
- {
- if (!cvar ("registered"))
- {
- mapname = "e1m1";
- }
- else if (!(serverflags & 1))
- {
- mapname = "e1m1";
- serverflags = serverflags | 1;
- }
- else if (!(serverflags & 2))
- {
- mapname = "e2m1";
- serverflags = serverflags | 2;
- }
- else if (!(serverflags & 4))
- {
- mapname = "e3m1";
- serverflags = serverflags | 4;
- }
- else if (!(serverflags & 8))
- {
- mapname = "e4m1";
- serverflags = serverflags - 7;
- }
-
- t_level = spawn (trigger_changelevel, map:mapname);
- }
- else
- {
- // find a trigger changelevel
- local entity e;
- e = findfloat (world, classtype, CT_TRIGGER_CHANGELEVEL);
- t_level = (trigger_changelevel)e;
-
- // go back to start if no trigger_changelevel
- if (!t_level)
- t_level = spawn (trigger_changelevel, map:"start");
- }
-
- nextmap = t_level.map;
- gameover = TRUE;
-
- if (t_level.nextthink < time)
- t_level.nextthink = time + 0.1;
-};
-
-//----------------------------------------------------------------------
-// CheckRules -- Exit deathmatch games upon conditions; 'self' is client
-//----------------------------------------------------------------------
-void() CheckRules =
-{
- // someone else quit the game already
- if (gameover)
- return;
-
- local float timelimit = cvar ("timelimit") * 60;
- local float fraglimit = cvar ("fraglimit");
-
- // 1998-07-27 Timelimit/Fraglimit fix by Maddes
- if (deathmatch && timelimit && time >= timelimit)
- {
- NextLevel ();
- return;
- }
-
- // 1998-07-27 Timelimit/Fraglimit fix by Maddes
- if (deathmatch && fraglimit && self.frags >= fraglimit)
- {
- NextLevel ();
- return;
- }
-};
-
-//======================================================================
-// Helper functions - intermission handling
-//======================================================================
-
-//----------------------------------------------------------------------
-void(string message) ShowIntermissionMessage =
-{
- WriteByte (MSG_ALL, SVC_FINALE);
- WriteString (MSG_ALL, message);
-};
-
-//----------------------------------------------------------------------
-void() StartMessageIntermission =
-{
- WriteByte (MSG_ALL, SVC_CDTRACK);
- WriteByte (MSG_ALL, 2);
- WriteByte (MSG_ALL, 3);
-};
-
-//----------------------------------------------------------------------
-void() Episode1End =
-{
- StartMessageIntermission ();
-
- if (!cvar("registered"))
- {
- ShowIntermissionMessage ("As the corpse of the monstrous "
- "entity\nChthon sinks back into the lava whence\n"
- "it rose, you grip the Rune of Earth\n"
- "Magic tightly. Now that you have\n"
- "conquered the Dimension of the Doomed,\n"
- "realm of Earth Magic, you are ready to\n"
- "complete your task in the other three\n"
- "haunted lands of Quake. Or are you? If\n"
- "you don't register Quake, you'll never\n"
- "know what awaits you in the Realm of\n"
- "Black Magic, the Netherworld, and the\nElder World!");
- }
- else
- {
- ShowIntermissionMessage ("As the corpse of the monstrous"
- "entity\nChthon sinks back into the lava whence\n"
- "it rose, you grip the Rune of Earth\n"
- "Magic tightly. Now that you have\n"
- "conquered the Dimension of the Doomed,\n"
- "realm of Earth Magic, you are ready to\n"
- "complete your task. A Rune of magic\n"
- "power lies at the end of each haunted\n"
- "land of Quake. Go forth, seek the\n"
- "totality of the four Runes!");
- }
-};
-
-//----------------------------------------------------------------------
-void() Episode2End =
-{
- StartMessageIntermission ();
-
- ShowIntermissionMessage ("The Rune of Black Magic throbs evilly in\n"
- "your hand and whispers dark thoughts\n"
- "into your brain. You learn the inmost\n"
- "lore of the Hell-Mother; Shub-Niggurath!\n"
- "You now know that she is behind all the\n"
- "terrible plotting which has led to so\n"
- "much death and horror. But she is not\n"
- "inviolate! Armed with this Rune, you\n"
- "realize that once all four Runes are\n"
- "combined, the gate to Shub-Niggurath's\n"
- "Pit will open, and you can face the\n"
- "Witch-Goddess herself in her frightful\n"
- "otherworld cathedral.");
-};
-
-//----------------------------------------------------------------------
-void() Episode3End =
-{
- StartMessageIntermission ();
-
- ShowIntermissionMessage ("The charred viscera of diabolic horrors\n"
- "bubble viscously as you seize the Rune\n"
- "of Hell Magic. Its heat scorches your\n"
- "hand, and its terrible secrets blight\n"
- "your mind. Gathering the shreds of your\n"
- "courage, you shake the devil's shackles\n"
- "from your soul, and become ever more\n"
- "hard and determined to destroy the\n"
- "hideous creatures whose mere existence\n"
- "threatens the souls and psyches of all\n"
- "the population of Earth.");
-
-};
-
-//----------------------------------------------------------------------
-void() Episode4End =
-{
- StartMessageIntermission ();
-
- ShowIntermissionMessage ("Despite the awful might of the Elder\n"
- "World, you have achieved the Rune of\n"
- "Elder Magic, capstone of all types of\n"
- "arcane wisdom. Beyond good and evil,\n"
- "beyond life and death, the Rune\n"
- "pulsates, heavy with import. Patient and\n"
- "potent, the Elder Being Shub-Niggurath\n"
- "weaves her dire plans to clear off all\n"
- "life from the Earth, and bring her own\n"
- "foul offspring to our world! For all the\n"
- "dwellers in these nightmare dimensions\n"
- "are her descendants! Once all Runes of\n"
- "magic power are united, the energy\n"
- "behind them will blast open the Gateway\n"
- "to Shub-Niggurath, and you can travel\n"
- "there to foil the Hell-Mother's plots\nin person.");
-};
-
-//----------------------------------------------------------------------
-float() RunId1Intermissions =
-{
- if (world.skip_id1_overrides == 0)
- {
- if (world.model == "maps/e1m7.bsp")
- {
- Episode1End ();
- return 1;
- }
- else if (world.model == "maps/e2m6.bsp")
- {
- Episode2End ();
- return 1;
- }
- else if (world.model == "maps/e3m6.bsp")
- {
- Episode3End ();
- return 1;
- }
- else if (world.model == "maps/e4m7.bsp")
- {
- Episode4End ();
- return 1;
- }
- }
- return 0;
-};
-
-//----------------------------------------------------------------------
-// FindIntermission -- Returns the entity to view from
-//----------------------------------------------------------------------
-entity() FindIntermission =
-{
- local entity spot;
- local float cyc;
-
- // look for info_intermission first
- spot = findfloat (world, ::classtype, CT_INFO_INTERMISSION);
- if (spot)
- { // pick a random one
- cyc = random() * 4;
- while (cyc > 1)
- {
- spot = findfloat (spot, ::classtype,
- CT_INFO_INTERMISSION);
- if (!spot)
- spot = findfloat (spot, ::classtype,
- CT_INFO_INTERMISSION);
- cyc = cyc - 1;
- }
- return spot;
- }
-
- // then look for the start position
- spot = findfloat (world, classtype, CT_INFO_PLAYER_START);
- if (spot)
- return spot;
-
- // testinfo_player_start is only found in regioned levels
- spot = findfloat (world, classtype, CT_INFO_TESTPLAYERSTART);
- if (spot)
- return spot;
-
- objerror ("FindIntermission: no spot");
-
- // just to suppress the compiler warning
- return world;
-};
-
-//----------------------------------------------------------------------
-void() GotoNextMap =
-{
- if (cvar("samelevel"))
- // if samelevel is set, stay on same level
- changelevel (mapname);
- else
- changelevel (nextmap);
-};
-
-//----------------------------------------------------------------------
-float(float start) ShowIntermissionTextEntity =
-{
- if (!(used_exit.spawnflags & 2))
- {
- local entity end_message;
- for (end_message = world; (end_message = findfloat
- (end_message, ::classtype, CT_INFO_INTERMISSIONTEXT)); )
- {
- if (end_message.cnt == (intermission_running - 1))
- {
- if (start == 1)
- StartMessageIntermission ();
- ShowIntermissionMessage (end_message.message);
- return 1;
- }
- }
- }
- return 0;
-};
-
-//----------------------------------------------------------------------
-void() ExitIntermission =
-{
- // skip any text in deathmatch
- if (deathmatch)
- {
- GotoNextMap ();
- return;
- }
-
- intermission_exittime = time + 1;
- intermission_running = intermission_running + 1;
-
- // run some text if at the end of an episode
- if (intermission_running == 2)
- {
- if (RunId1Intermissions() == 1)
- {
- return;
- }
- else
- {
- if (used_exit.message != "")
- {
- // favor message on changelevel
- StartMessageIntermission ();
- ShowIntermissionMessage (used_exit.message);
- return;
- }
- if (ShowIntermissionTextEntity(1))
- {
- return;
- }
- }
-
- GotoNextMap ();
- }
-
- if (intermission_running == 3)
- {
- if (!cvar("registered"))
- {
- // shareware episode has been completed,
- // go to sell screen
- WriteByte (MSG_ALL, SVC_SELLSCREEN);
- return;
- }
- if (ShowIntermissionTextEntity(0))
- {
- return;
- }
- if ((serverflags&15) == 15)
- {
- ShowIntermissionMessage ("Now, you have all four Runes."
- " You sense\ntremendous invisible forces moving"
- " to\nunseal ancient barriers."
- " Shub-Niggurath\nhad hoped to use the Runes"
- " Herself to\nclear off the Earth, but now"
- " instead,\nyou will use them to enter her"
- " home and\nconfront her as an avatar of"
- " avenging\nEarth-life. If you defeat her,"
- " you will\nbe remembered forever as the"
- " savior of\nthe planet. If she conquers,"
- " it will be\nas if you had never been born.");
- return;
- }
- }
-
- if (intermission_running > 3)
- {
- if (ShowIntermissionTextEntity(0))
- {
- return;
- }
- }
-
- GotoNextMap ();
-};
-
-//----------------------------------------------------------------------
-// IntermissionThink
-// When the player presses attack or jump, change to the next level
-// 'self' in this context is the client/player
-//----------------------------------------------------------------------
-void() IntermissionThink =
-{
- // full send -- CEV
- // self.fixangle = TRUE;
- self.velocity = '0 0 0';
- self.SendFlags = 0xffffff;
-
- if (time < intermission_exittime)
- return;
-
- if (!self.button0 && !self.button1 && !self.button2)
- return;
-
- ExitIntermission ();
-};
-
-//======================================================================
-// REAL entrypoints (the following functions are called by the engine)
-//======================================================================
-
-//----------------------------------------------------------------------
-// ClientConnect
-// called when a player connects to a server; the client may not have
-// fully spawned yet (according to Nuclide's comments). self in this
-// context refers to the connecting client. -- CEV
-//----------------------------------------------------------------------
-void() ClientConnect =
-{
- // a client connecting during an intermission can cause problems
- if (intermission_running)
- ExitIntermission ();
-
- if (self.classname != "player")
- // run the player spawn function, initializing 'self'
- // as a player object -- CEV
- spawnfunc_player ();
-
- bprint (self.netname);
- bprint (" entered the game\n");
-};
-
-//----------------------------------------------------------------------
-// ClientDisconnect
-// called when a player disconnects from a server; the client will be
-// removed after this function, so 'self' in this context is the player
-// and any fields of self can be accessed. -- CEV
-//----------------------------------------------------------------------
-void() ClientDisconnect =
-{
- // if the level end trigger has been activated, just return
- // since they aren't *really* leaving
- if (gameover)
- return;
-
- // let everyone else know
- bprint (self.netname);
- bprint (" left the game with ");
- bprint (ftos(self.frags));
- bprint (" frags\n");
- sound (self, CHAN_BODY, "player/tornoff2.wav", 1, ATTN_NONE);
-
- if (self.classtype == CT_PLAYER)
- ((player)self).set_suicide_frame ();
- else
- dprint ("ClientDisconnect: ERROR! Encountered a non-player!\n");
-};
-
-//----------------------------------------------------------------------
-// ClientKill -- Player entered the suicide command; 'self' is the client
-//----------------------------------------------------------------------
-void() ClientKill =
-{
- // 1998-07-27 Suicide during intermission fix by Zhenga start
- // not allowed during intermission
- if ((intermission_running) && ((coop) || (deathmatch)))
- return;
- // 1998-07-27 Suicide during intermission fix by Zhenga end
-
- bprint (self.netname);
- bprint (" suicides\n");
-
- if (self.classtype == CT_PLAYER)
- {
- ((player)self).set_suicide_frame ();
- self.modelindex = modelindex_player;
- // extra penalty
- self.frags = self.frags - 2;
- ((player)self).init_respawn ();
- }
- else
- {
- dprint ("ClientKill: ERROR! suicide from a non-player!\n");
- }
-};
-
-//----------------------------------------------------------------------
-void() SetNewParms =
-{
- parm2 = 100; // self.health
- parm3 = 0; // self.armorvalue
- parm5 = 0; // self.ammo_nails
- parm6 = 0; // self.ammo_rockets
- parm7 = 0; // self.ammo_cells
- parm9 = 0; // self.armortype * 100
-
- // "reset_items 2" makes the player start with only the axe -- iw
- if (world.reset_items == 2)
- {
- parm1 = IT_AXE; // self.items
- parm4 = 0; // self.ammo_shells
- parm8 = IT_AXE; // self.weapon
- }
- else
- {
- parm1 = IT_AXE | IT_SHOTGUN; // self.items
- parm4 = 25; // self.ammo_shells
- parm8 = IT_SHOTGUN; // self.weapon
- }
-};
-
-//----------------------------------------------------------------------
-void() SetChangeParms =
-{
- if (self.health <= 0)
- {
- SetNewParms ();
- return;
- }
-
- // remove items
- self.items = self.items - (self.items &
- (IT_KEY1 | IT_KEY2 | IT_INVISIBILITY | IT_INVULNERABILITY
- | IT_SUIT | IT_QUAD)
- );
-
- // cap super health
- if (self.health > 100)
- self.health = 100;
- if (self.health < 50)
- self.health = 50;
- parm1 = self.items;
- parm2 = self.health;
- parm3 = self.armorvalue;
- if (self.ammo_shells < 25)
- parm4 = 25;
- else
- parm4 = self.ammo_shells;
- parm5 = self.ammo_nails;
- parm6 = self.ammo_rockets;
- parm7 = self.ammo_cells;
- parm8 = self.weapon;
- parm9 = self.armortype * 100;
-};
-
-//----------------------------------------------------------------------
-// PutClientInServer -- called each time a player is spawned
-// according to Nuclide: player has fully connected and loaded in.
-// 'self' is the player/client, parmX are populated with data carried
-// over from previous levels for this specific client. -- CEV
-//----------------------------------------------------------------------
-void() PutClientInServer =
-{
- if (self.classname == "player")
- dprint ("PutClientInServer: classname already player!\n");
-};
-
-//----------------------------------------------------------------------
-// PlayerPreThink -- Called every frame before physics are run
-//----------------------------------------------------------------------
-void() PlayerPreThink =
-{
- if (intermission_running)
- {
- // otherwise a button could be missed between the think tics
- IntermissionThink ();
- return;
- }
-
- if (self.view_ofs == '0 0 0')
- {
- // Check for cutscene stuff.
- Cutscene_Think ();
- // intermission or finale
- return;
- }
-
- // Check map / gametype rules, change to next level if requested -- CEV
- CheckRules ();
-
- // call prethink on the player after double checking classtype -- CEV
- if (self.classtype == CT_PLAYER)
- ((player)self).prethink ();
-};
-
-//----------------------------------------------------------------------
-// SV_RunClientCommand -- Called every frame to run physics
-//----------------------------------------------------------------------
-void() SV_RunClientCommand =
-{
- // should match the one used by csqc.
- if (frame_standardphysics)
- // for testing -- CEV
- runstandardplayerphysics (self);
- else
- // for real. See pmove.qc -- CEV
- PM_Move (self);
-};
-
-//----------------------------------------------------------------------
-// PlayerPostThink -- Called every frame after physics are run
-//----------------------------------------------------------------------
-void() PlayerPostThink =
-{
- if (intermission_running)
- return;
-
- // call postthink on the player after double checking classtype -- CEV
- if (self.classtype == CT_PLAYER)
- ((player)self).postthink ();
-};
-
-// TODO CEV based on code from Nuclide SDK
-/*
-void(void() spawnfunc) CheckSpawn =
-{
- if (spawnfunc)
- {
- // dprint (sprintf("CheckSpawn: creating %s\n",
- // self.classname));
- spawnfunc ();
- }
- else
- {
- // print (sprintf("CheckSpawn: cannot find entity class %s\n",
- // self.classname));
- remove (self);
- }
-};
-*/

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

Diff qc/fteqcc.ini

diff --git a/qc/fteqcc.ini b/qc/fteqcc.ini
index 9c62c09..a639295 100644
--- a/qc/fteqcc.ini
+++ b/qc/fteqcc.ini
@@ -1,8 +1,8 @@
-optimisation t off # c = a*b is performed in one operation rather than two, and can
+optimisation t on # c = a*b is performed in one operation rather than two, and can
# cause older decompilers to fail.
-optimisation i off # if (!a) was traditionally compiled in two statements. This optimisation
+optimisation i on # if (!a) was traditionally compiled in two statements. This optimisation
# does it in one, but can cause some decompilers to get confused.
-optimisation p off # In the original qcc, function parameters were specified as a vector
+optimisation p on # In the original qcc, function parameters were specified as a vector
# store even for floats. This fixes that.
optimisation c default # This optimisation strips out the names of constants (but not strings)
# from your progs, resulting in smaller files. It makes decompilers

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

Diff qc/func/bob.qc

diff --git a/qc/func/bob.qc b/qc/func/bob.qc
index 451c64b..d77a853 100644
--- a/qc/func/bob.qc
+++ b/qc/func/bob.qc
@@ -2,204 +2,210 @@
// func_bob -- code attributed to RennyC
//==============================================================================

-// constants
-const float BOB_STYLE_START_OFF = 1; // start off
-const float BOB_COLLISION = 2; // Collision for misc_bob
-const float BOB_NONSOLID = 4; // Non solid for func_bob
+//======================================================================
+// Constants
+//======================================================================
+
+const float BOB_STYLE_START_OFF = 1; // start off
+const float BOB_COLLISION = 2; // Collision for misc_bob
+const float BOB_NONSOLID = 4; // Non solid for func_bob
+
+//======================================================================
+// fields
+//======================================================================
+.float bsporigin; // bmodel origins are 0,0,0; check first
+.float waitmin2;
+
+//======================================================================
+// forward declarations
+//======================================================================
+
+// base_func_bob
+void() base_func_bob_on;
+void() base_func_bob_off;
+void() base_func_bob_think_timer;
+void(entity e) base_func_bob_init;
+strip void() base_func_bob;
+
+// func_bob
+void(entity e) func_bob_init;
+void() func_bob;
+
+// misc_bob
+void(entity e) misc_bob_init;
+void() misc_bob;

//------------------------------------------------------------------------------
-class base_func_bob: base_func
-{
- // class fields
- float attack_timer;
- float bsporigin; // All bmodel origins are 0,0,0 check this first
- float count;
- float distance;
- float height;
- float waitmin2;

- //--------------------------------------------------------------
- virtual void(string fieldname, string fieldvalue) init_field =
- {
- switch (fieldname)
- {
- case "attack_timer":
- attack_timer = stof (fieldvalue);
- break;
- case "bsporigin":
- bsporigin = stof (fieldvalue);
- break;
- case "count":
- count = stof (fieldvalue);
- break;
- case "distance":
- distance = stof (fieldvalue);
- break;
- case "height":
- height = stof (fieldvalue);
- break;
- case "waitmin2":
- waitmin2 = stof (fieldvalue);
- break;
- default:
- super::init_field (fieldname, fieldvalue);
- }
- };
+//----------------------------------------------------------------------
+// class base_func_bob: base_func
+// {

//--------------------------------------------------------------
- nonvirtual void() bob_on =
+ void() base_func_bob_on =
{
// This may have been called by a "use" function, so don't
// allow it to be called repeatedly -- iw
- this.interaction_flags |= DISABLE_USE;
+ self.use = sub_null;

- if (this.bsporigin)
+ if (self.bsporigin)
{
- this.movetype = MOVETYPE_PUSH;
- this.solid = SOLID_BSP;
+ self.movetype = MOVETYPE_PUSH;
+ self.solid = SOLID_BSP;
}
else
{
- this.movetype = MOVETYPE_FLY;
- this.solid = SOLID_BBOX;
+ self.movetype = MOVETYPE_FLY;
+ self.solid = SOLID_BBOX;
// Reset any onground flags
- this.flags = 0;
+ self.flags = 0;
}

- if (this.spawnflags & BOB_NONSOLID)
- this.solid = SOLID_NOT;
+ if (self.spawnflags & BOB_NONSOLID)
+ self.solid = SOLID_NOT;

- setmodel (this, this.mdl);
- setsize (this, this.mins , this.maxs);
+ setmodel (self, self.mdl);
+ setsize (self, self.mins , self.maxs);

- if (this.bsporigin)
- this.nextthink = this.ltime + 0.1 + this.delay;
+ self.think = base_func_bob_think_timer;
+
+ if (self.bsporigin)
+ self.nextthink = self.ltime + 0.1 + self.delay;
else
- this.nextthink = time + 0.1 + this.delay;
+ self.nextthink = time + 0.1 + self.delay;
};

//--------------------------------------------------------------
- nonvirtual void() bob_off =
+ void() base_func_bob_off =
{
- if (this.bsporigin)
+ if (self.bsporigin)
{
- this.movetype = MOVETYPE_PUSH;
- this.solid = SOLID_BSP;
+ self.movetype = MOVETYPE_PUSH;
+ self.solid = SOLID_BSP;
}
else
{
- this.movetype = MOVETYPE_FLY;
- this.solid = SOLID_BBOX;
+ self.movetype = MOVETYPE_FLY;
+ self.solid = SOLID_BBOX;
}

- if (this.spawnflags & BOB_NONSOLID)
- this.solid = SOLID_NOT;
+ if (self.spawnflags & BOB_NONSOLID)
+ self.solid = SOLID_NOT;
+
+ setmodel (self, self.mdl);
+ setsize (self, self.mins , self.maxs);
+ self.velocity = '0 0 0';

- setmodel (this, this.mdl);
- setsize (this, this.mins , this.maxs);
- this.velocity = '0 0 0';
+ if (self.style & BOB_STYLE_START_OFF)
+ self.use = base_func_bob_on;
};

//--------------------------------------------------------------
// was bob_timer -- CEV
//--------------------------------------------------------------
- virtual void() do_think =
+ void() base_func_bob_think_timer =
{
- if (this.bsporigin)
- this.nextthink = this.ltime + 0.1;
+ self.think = base_func_bob_think_timer;
+
+ if (self.bsporigin)
+ self.nextthink = self.ltime + 0.1;
else
- this.nextthink = time + 0.1;
+ self.nextthink = time + 0.1;

// Has the cycle completed?
- if (this.attack_timer < time)
+ // changed from self.attack_timer to .attack_finished -- CEV
+ if (self.attack_finished < time)
{
// Setup bob cycle and half way point for slowdown
- this.attack_timer = time + this.count;
- this.distance = time + (this.count * 0.5);
+ self.attack_finished = time + self.count;
+ self.distance = time + (self.count * 0.5);
// Flip direction of bmodel bob
- this.lefty = 1 - this.lefty;
- if (this.lefty < 1)
- this.t_length = this.height;
+ self.lefty = 1 - self.lefty;
+ if (self.lefty < 1)
+ self.t_length = self.height;
else
- this.t_length = -this.height;
+ self.t_length = -self.height;

// Always reset velocity and flags
- this.velocity = '0 0 0';
- this.flags = 0;
+ self.velocity = '0 0 0';
+ self.flags = 0;
}

// Is the direction set?
// This is a block condition to prevent the bmodel moving
- if (this.lefty != -1)
+ if (self.lefty != -1)
{
// Slow down velocity (gradually)
- if (this.distance < time)
+ if (self.distance < time)
{
- this.velocity = this.velocity * this.waitmin2;
+ self.velocity = self.velocity * self.waitmin2;
}
else
{
// Speed up velocity (linear/exponentially)
- this.t_length = this.t_length * this.waitmin;
- this.velocity += this.movedir * this.t_length;
+ self.t_length = self.t_length * self.waitmin;
+ self.velocity += self.movedir * self.t_length;
}
}
};

//--------------------------------------------------------------
- virtual void(entity caller) do_use =
+ void(entity e) base_func_bob_init =
{
- if (this.style & BOB_STYLE_START_OFF)
- this.bob_on ();
- };
+ base_func_init (e);

- //--------------------------------------------------------------
- nonvirtual void() bob_init =
- {
- this.spawnflags |= BOB_COLLISION;
- if (this.spawnflags & BOB_NONSOLID)
- this.spawnflags &= ~BOB_COLLISION;
+ e.spawnflags |= BOB_COLLISION;
+ if (e.spawnflags & BOB_NONSOLID)
+ e.spawnflags &= ~BOB_COLLISION;

// Using a custom model?
- if (this.mdl == "")
+ if (e.mdl == "")
{
- this.bsporigin = TRUE;
- this.mdl = this.model;
+ e.bsporigin = TRUE;
+ e.mdl = e.model;
}
else
{
- this.bsporigin = FALSE;
- this.modelindex = 0;
- this.model = "";
+ e.bsporigin = FALSE;
+ e.modelindex = 0;
+ e.model = "";
}

- sub_setmovedir ();
- this.movedir = normalize (this.movedir);
+ sub_setmovedir (e);
+ e.movedir = normalize (e.movedir);

- if (this.height <= 0)
+ if (e.height <= 0)
// Direction intensity
- this.height = 8;
- if (this.count < 1)
+ e.height = 8;
+ if (e.count < 1)
// Direction switch timer
- this.count = 2;
- if (this.waitmin <= 0)
+ e.count = 2;
+ if (e.waitmin <= 0)
// Speed up
- this.waitmin = 1;
- if (this.waitmin2 <= 0)
+ e.waitmin = 1;
+ if (e.waitmin2 <= 0)
// Slow down
- this.waitmin2 = 0.75;
- if (this.delay < 0)
- this.delay = random() + random() + random();
-
- this.interaction_flags &= ~DISABLE_USE;
+ e.waitmin2 = 0.75;
+ if (e.delay < 0)
+ e.delay = random() + random() + random();

// added style key 1 for start off -- dumptruck_ds
- if (this.style & BOB_STYLE_START_OFF)
- bob_off ();
+ if (e.style & BOB_STYLE_START_OFF)
+ sub_runvoidas (e, base_func_bob_off);
else
- bob_on ();
+ sub_runvoidas (e, base_func_bob_on);
};
-};
+
+ //--------------------------------------------------------------
+ strip void() base_func_bob =
+ {
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ base_func_bob_init (self);
+ };
+// };

/*QUAKED func_bob (0 .5 .8) X X X X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
A SOLID bmodel that gently moves back and forth
@@ -222,20 +228,27 @@ STARTOFF : Starts off and waits for trigger - DISABLED, Ripped out ESTATE System
-------- NOTES --------
A SOLID bmodel that gently moves back and forth
*/
-class func_bob: base_func_bob
-{
+//----------------------------------------------------------------------
+// class func_bob: base_func_bob
+// {
//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) func_bob_init =
{
- bob_init ();
+ e.classname = "func_bob";
+ e.classtype = CT_FUNC_BOB;
+ base_func_bob_init (e);
};

//--------------------------------------------------------------
void() func_bob =
{
- this.classtype = CT_FUNC_BOB;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ func_bob_init (self);
};
-};
+// };

/*QUAKED misc_bob (0 0.5 0.8) (-8 -8 -8) (8 8 8) X BOB_COLLISION BOB_NONSOLID X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
{
@@ -243,21 +256,30 @@ class func_bob: base_func_bob
}
Same as func_bob but uses a custom model instead of a brush. Use the mdl key to set the path of the model.
*/
-class misc_bob: base_func_bob
-{
+//----------------------------------------------------------------------
+// class misc_bob: base_func_bob
+// {
//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) misc_bob_init =
{
- if (this.mdl == "")
- this.mdl = string_null;
- precache_model (this.mdl);
+ e.classname = "misc_bob";
+ e.classtype = CT_MISC_BOB;

- bob_init ();
+ if (e.mdl == "")
+ e.mdl = __NULL__;
+
+ precache_model (e.mdl);
+
+ base_func_bob_init (e);
};

//--------------------------------------------------------------
void() misc_bob =
{
- this.classtype = CT_MISC_BOB;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ misc_bob_init (self);
};
-};
+// };

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

Diff qc/func/bossgate.qc

diff --git a/qc/func/bossgate.qc b/qc/func/bossgate.qc
index 2161c1c..0dddf4f 100644
--- a/qc/func/bossgate.qc
+++ b/qc/func/bossgate.qc
@@ -2,18 +2,39 @@
// func_bossgate
//==============================================================================

-// constants
+//======================================================================
+// Constants
+//======================================================================
+
// For func_episodegate and func_bossgate appear when player has all runes
const float BOSSGATE_REVERSE = 16;

+//======================================================================
+// forward declarations
+//======================================================================
+
+// func_bossgate
+void(entity e) func_bossgate_init;
+void() func_bossgate;
+
+//------------------------------------------------------------------------------
+
/*QUAKED func_bossgate (0 .5 .8) ? X X X X REVERSE_FUNCTIONALITY
This bmodel appears unless players have all of the episode sigils.
*/
-class func_bossgate: base_func_wall
-{
- virtual void() init_spawned =
+//----------------------------------------------------------------------
+// class func_bossgate: base_func_wall
+// {
+ //--------------------------------------------------------------
+ void(entity e) func_bossgate_init =
{
- if (this.spawnflags & BOSSGATE_REVERSE)
+ e.classname = "func_bossgate";
+ e.classtype = CT_FUNC_BOSSGATE;
+
+ // will set use -- CEV
+ base_func_wall_init (e);
+
+ if (e.spawnflags & BOSSGATE_REVERSE)
{
if (!((serverflags & 15) == 15))
{
@@ -27,16 +48,21 @@ class func_bossgate: base_func_wall
// all episodes completed
return;
}
- this.angles = '0 0 0';
+
+ e.angles = '0 0 0';
// so it doesn't get pushed by anything
- this.movetype = MOVETYPE_PUSH;
- this.solid = SOLID_BSP;
- setmodel (this, this.model);
+ e.movetype = MOVETYPE_PUSH;
+ e.solid = SOLID_BSP;
+ setmodel (e, e.model);
};

//--------------------------------------------------------------
void() func_bossgate =
{
- this.classtype = CT_FUNC_BOSSGATE;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ func_bossgate_init (self);
};
-};
+// };

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

Diff qc/func/breakable.qc

diff --git a/qc/func/breakable.qc b/qc/func/breakable.qc
index 895e5ef..1252387 100644
--- a/qc/func/breakable.qc
+++ b/qc/func/breakable.qc
@@ -2,28 +2,62 @@
// func_breakable -- AD breakable code modified by Qmaster, iw, and dumptruck_ds
//==============================================================================

+//======================================================================
// constants
+//======================================================================
+
const float BREAKABLE_NO_MONSTERS = 1;
const float BREAK_EXPLODE = 2;
const float BREAK_CUSTOM = 4;

+const float BREAKABLE_NO_MONSTERS = 1;
+
+//======================================================================
+// fields
+//======================================================================
+
+.float brk_obj_count1;
+.float brk_obj_count2;
+.float brk_obj_count3;
+.float brk_obj_count4;
+.float brk_obj_count5;
+
+.string break_template1;
+.string break_template2;
+.string break_template3;
+.string break_template4;
+.string break_template5;
+
+.string mdl_debris; // dumptruck_ds
+
+//======================================================================
+// forward declarations
+//======================================================================
+
+// base_breakable
+void() sub_dislodge_resting_entities;
+void(string templatename) base_breakable_template_single_debris;
+void() base_breakable_single_debris;
+void() base_breakable_make_templates_debris;
+void() base_breakable_make_debris;
+void() base_breakable_die;
+void() base_breakable_destroy;
+void() base_breakable_use;
+void(entity e) base_breakable_template_setup;
+void(entity e) base_breakable_init;
+void() base_breakable;
+
+// func_breakable
+void(entity e) func_breakable_init;
+void() func_breakable;
+
//------------------------------------------------------------------------------
-// base breakable class; used by func_breakable (below), func_fall2
-//------------------------------------------------------------------------------
-class base_breakable: base_func
-{
- // class fields
- string break_template1;
- string break_template2;
- string break_template3;
- string break_template4;
- string break_template5;
- float brk_obj_count1;
- float brk_obj_count2;
- float brk_obj_count3;
- float brk_obj_count4;
- float brk_obj_count5;

+//----------------------------------------------------------------------
+// base breakable class; used by func_breakable (below), func_fall2
+//----------------------------------------------------------------------
+// class base_breakable: base_func
+// {
//--------------------------------------------------------------
// SUB_DislodgeRestingEntities
// This clears the FL_ONGROUND flag from any entities that are on
@@ -34,76 +68,36 @@ class base_breakable: base_func
// intended to be called in the case where self is going to be
// removed, to ensure that other entities are not left floating. -- iw
//--------------------------------------------------------------
- virtual void() sub_dislodgerestingentities =
+ void() sub_dislodge_resting_entities =
{
local entity e;

e = nextent (world);
while (e && e != world)
{
- if ((e.flags & FL_ONGROUND) && e.groundentity == this)
+ if ((e.flags & FL_ONGROUND) && e.groundentity == self)
e.flags = e.flags - (e.flags & FL_ONGROUND);
e = nextent (e);
}
};

//--------------------------------------------------------------
- virtual void(string fieldname, string fieldvalue) init_field =
- {
- switch (fieldname)
- {
- case "break_template1":
- this.break_template1 = fieldvalue;
- break;
- case "break_template2":
- this.break_template2 = fieldvalue;
- break;
- case "break_template3":
- this.break_template3 = fieldvalue;
- break;
- case "break_template4":
- this.break_template4 = fieldvalue;
- break;
- case "break_template5":
- this.break_template5 = fieldvalue;
- break;
- case "brk_obj_count1":
- this.brk_obj_count1 = stof (fieldvalue);
- break;
- case "brk_obj_count2":
- this.brk_obj_count2 = stof (fieldvalue);
- break;
- case "brk_obj_count3":
- this.brk_obj_count3 = stof (fieldvalue);
- break;
- case "brk_obj_count4":
- this.brk_obj_count4 = stof (fieldvalue);
- break;
- case "brk_obj_count5":
- this.brk_obj_count5 = stof (fieldvalue);
- break;
- default:
- super::init_field (fieldname, fieldvalue);
- }
- };
-
- //--------------------------------------------------------------
- virtual void(string templatename) template_single_debris =
+ void(string templatename) base_breakable_template_single_debris =
{
local entity new;

new = spawn ();
new.model = templatename;
- new.origin_x = (this.maxs_x - this.mins_x) *
- random() + this.mins_x;
- new.origin_y = (this.maxs_y - this.mins_y) *
- random() + this.mins_y;
- new.origin_z = (this.maxs_z - this.mins_z) *
- random() + this.mins_z;
+ new.origin_x = (self.maxs_x - self.mins_x) *
+ random() + self.mins_x;
+ new.origin_y = (self.maxs_y - self.mins_y) *
+ random() + self.mins_y;
+ new.origin_z = (self.maxs_z - self.mins_z) *
+ random() + self.mins_z;
// dumptruck_ds
setmodel (new, new.model);
setsize (new, '0 0 0', '0 0 0');
- new.velocity = VelocityForDamage (this.health * 2);
+ new.velocity = velocity_for_damage (self.health * 2);
new.movetype = MOVETYPE_BOUNCE;
new.solid = SOLID_NOT;
new.avelocity_x = random() * 600;
@@ -116,17 +110,17 @@ class base_breakable: base_func
};

//--------------------------------------------------------------
- virtual void() single_debris =
+ void() base_breakable_single_debris =
{
local entity new;

new = spawn ();
- new.origin_x = (this.maxs_x - this.mins_x) *
- random() + this.mins_x;
- new.origin_y = (this.maxs_y - this.mins_y) *
- random() + this.mins_y;
- new.origin_z = (this.maxs_z - this.mins_z) *
- random() + this.mins_z;
+ new.origin_x = (self.maxs_x - self.mins_x) *
+ random() + self.mins_x;
+ new.origin_y = (self.maxs_y - self.mins_y) *
+ random() + self.mins_y;
+ new.origin_z = (self.maxs_z - self.mins_z) *
+ random() + self.mins_z;

// this was originally just an mdl from Rubicon2, now you set
// custom model via spawnflag or use the builtin from
@@ -134,9 +128,9 @@ class base_breakable: base_func
// setmodel (new, "progs/debris.mdl");

// dumptruck_ds
- setmodel (new, this.mdl_debris);
+ setmodel (new, self.mdl_debris);
setsize (new, '0 0 0', '0 0 0');
- new.velocity = VelocityForDamage (this.health * 2);
+ new.velocity = velocity_for_damage (self.health * 2);
new.movetype = MOVETYPE_BOUNCE;
new.solid = SOLID_NOT;
new.avelocity_x = random() * 600;
@@ -159,9 +153,9 @@ class base_breakable: base_func
//
// this was originally a large block of individual if
// statements in the form of:
- // if (this.style == 1)
+ // if (self.style == 1)
// new.skin = 1;
- // if (this.style == 2)
+ // if (self.style == 2)
// new.skin = 2;
// and so on, up until 31. As far as I can tell new.skin
// was always set to the same value as this.style. So I've
@@ -169,16 +163,16 @@ class base_breakable: base_func
// New debris skins start at 3 and continue through 31
// according to comments left by dumptruck_ds -- CEV

- if (this.style > 0 && this.style <= 31)
+ if (self.style > 0 && self.style <= 31)
{
- new.skin = this.style;
+ new.skin = self.style;
}
};

//--------------------------------------------------------------
// template system from Qmaster -- dumptruck_ds
//--------------------------------------------------------------
- nonvirtual void() make_breakable_templates_debris =
+ void() base_breakable_make_templates_debris =
{
local float count = 0;
local string break_template = "";
@@ -188,24 +182,24 @@ class base_breakable: base_func
switch (i)
{
case 1:
- break_template = this.break_template1;
- count = this.brk_obj_count1;
+ break_template = self.break_template1;
+ count = self.brk_obj_count1;
break;
case 2:
- break_template = this.break_template2;
- count = this.brk_obj_count2;
+ break_template = self.break_template2;
+ count = self.brk_obj_count2;
break;
case 3:
- break_template = this.break_template3;
- count = this.brk_obj_count3;
+ break_template = self.break_template3;
+ count = self.brk_obj_count3;
break;
case 4:
- break_template = this.break_template4;
- count = this.brk_obj_count4;
+ break_template = self.break_template4;
+ count = self.brk_obj_count4;
break;
case 5:
- break_template = this.break_template5;
- count = this.brk_obj_count5;
+ break_template = self.break_template5;
+ count = self.brk_obj_count5;
break;
}

@@ -213,7 +207,8 @@ class base_breakable: base_func
{
for (float j = 0; j < count; j++)
{
- template_single_debris (break_template);
+ base_breakable_template_single_debris
+ (break_template);
}
}

@@ -227,17 +222,17 @@ class base_breakable: base_func
//==============================================================

//--------------------------------------------------------------
- nonvirtual void() make_breakable_debris =
+ void() base_breakable_make_debris =
{
- for (float i = 0; i < this.cnt; i++)
- single_debris ();
+ for (float i = 0; i < self.cnt; i++)
+ base_breakable_single_debris ();
};

//--------------------------------------------------------------
// dumptruck_ds -- set the spawnflag for cosmetic explosion
// effect; use "dmg" value to hurt the player
//--------------------------------------------------------------
- virtual void() breakable_die =
+ void() base_breakable_die =
{
// what is this brace doing here? -- TODO CEV
{
@@ -247,101 +242,115 @@ class base_breakable: base_func
local entity ent;

ent = spawn ();
- ent.origin = ((this.absmin + this.absmax) * 0.5);
+ ent.origin = ((self.absmin + self.absmax) * 0.5);
setsize (ent, '0 0 0', '0 0 0');
ent.solid = SOLID_NOT;
ent.think = sub_remove;
// ent.ltime = time;
ent.nextthink = time + 60;

- sound (ent, CHAN_AUTO, this.noise1, 1, ATTN_NORM);
- // remove (this);
+ sound (ent, CHAN_AUTO, self.noise1, 1, ATTN_NORM);
+ // remove (self);
}

// this is to ensure that any debris from another
// func_breakable which is resting on top of this
// func_breakable is not left floating in mid-air
// after this entity is removed -- iw
- sub_dislodgerestingentities ();
+ sub_dislodge_resting_entities ();

- if (this.spawnflags & BREAK_EXPLODE)
+ if (self.spawnflags & BREAK_EXPLODE)
{
- if (this.spawnflags & BREAK_CUSTOM)
- make_breakable_templates_debris ();
+ if (self.spawnflags & BREAK_CUSTOM)
+ base_breakable_make_templates_debris ();
else
- make_breakable_debris ();
+ base_breakable_make_debris ();

// to let us use noise2
- // TODO CEV func_explobox::explode_silent ();
- this.takedamage = DAMAGE_NO;
- this.origin = ((this.absmin + this.absmax) * 0.5);
- this.t_radiusdamage2 (this, this, this.dmg, world);
- base_explosion::write_explosion (this.origin);
- spawn (base_explosion, origin: this.origin);
+ // func_explobox_explode_silent ();
+ self.takedamage = DAMAGE_NO;
+ self.origin = ((self.absmin + self.absmax) * 0.5);
+ t_radiusdamage2 (self, self, self.dmg, world);
+ write_explosion (self.origin);
+ spawn_base_explosion (self.origin);

// this is broken as of 1.1.0 no custom explosion
// sound for now -- dumptruck_ds
- // sound (this, CHAN_VOICE, this.noise2, 1, ATTN_NORM);
- remove (this);
+ // sound (self, CHAN_VOICE, self.noise2, 1, ATTN_NORM);
+ remove (self);
}
else
{
- this.origin = ((this.absmin + this.absmax) * 0.5);
- setorigin (this, this.origin);
- base_item::drop_stuff (this);
- if (this.spawnflags & BREAK_CUSTOM)
+ self.origin = ((self.absmin + self.absmax) * 0.5);
+ setorigin (self, self.origin);
+ if (self.drop_item)
+ base_item_drop_stuff (self);
+ if (self.spawnflags & BREAK_CUSTOM)
{
- if (this.switchshadstyle)
- lightstyle(this.switchshadstyle, "m");
- make_breakable_templates_debris ();
- if (this)
- remove (this);
+ if (self.switchshadstyle)
+ lightstyle (self.switchshadstyle, "m");
+ base_breakable_make_templates_debris ();
+ if (self)
+ remove (self);
}
else
{
- if (this.switchshadstyle)
- lightstyle(this.switchshadstyle, "m");
- make_breakable_debris ();
- if (this)
- remove (this);
+ if (self.switchshadstyle)
+ lightstyle (self.switchshadstyle, "m");
+ base_breakable_make_debris ();
+ if (self)
+ remove (self);
}
}
};

//--------------------------------------------------------------
- virtual void() do_destroy =
+ void() base_breakable_destroy =
{
activator = damage_attacker;
sub_usetargets ();
- breakable_die ();
+ base_breakable_die ();
};

//--------------------------------------------------------------
- virtual void(entity caller) do_use =
+ void() base_breakable_use =
{
- if (this.targetname == __NULL__ || this.targetname == "")
+ if (self.targetname == __NULL__ || self.targetname == "")
return;

- activator = caller;
+ activator = other;
sub_usetargets ();
- breakable_die ();
+ base_breakable_die ();
};

//--------------------------------------------------------------
- nonvirtual void() break_template_setup =
+ void(entity e) base_breakable_template_setup =
{
- if (this.break_template1 != "")
- precache_model (this.break_template1);
- if (this.break_template2 != "")
- precache_model (this.break_template2);
- if (this.break_template3 != "")
- precache_model (this.break_template3);
- if (this.break_template4 != "")
- precache_model (this.break_template4);
- if (this.break_template5 != "")
- precache_model (this.break_template5);
+ if (e.break_template1 != "")
+ precache_model (e.break_template1);
+ if (e.break_template2 != "")
+ precache_model (e.break_template2);
+ if (e.break_template3 != "")
+ precache_model (e.break_template3);
+ if (e.break_template4 != "")
+ precache_model (e.break_template4);
+ if (e.break_template5 != "")
+ precache_model (e.break_template5);
};
-};
+
+ //--------------------------------------------------------------
+ void(entity e) base_breakable_init =
+ {
+ base_func_init (e);
+ base_breakable_template_setup (e);
+ };
+
+ //--------------------------------------------------------------
+ strip void() base_breakable =
+ {
+ base_breakable_init (self);
+ };
+// };

/*QUAKED func_breakable (0 .5 .8) ? NO_MONSTERS X X X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY

@@ -407,121 +416,133 @@ brk_obj_count3(integer) : "Template 3 spawn count"
brk_obj_count4(integer) : "Template 4 spawn count"
brk_obj_count5(integer) : "Template 5 spawn count"
*/
-class func_breakable: base_breakable
-{
+//----------------------------------------------------------------------
+// class func_breakable: base_breakable
+// {
//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) func_breakable_init =
{
- break_template_setup ();
+ e.classname = "func_breakable";
+ e.classtype = CT_FUNC_BREAKABLE;

- this.solid = SOLID_BSP;
- this.movetype = MOVETYPE_PUSH;
- setmodel (this, this.model);
- this.mdl_debris = "progs/debris.mdl";
- precache_model (this.mdl_debris);
+ base_breakable_init (e);
+
+ e.solid = SOLID_BSP;
+ e.movetype = MOVETYPE_PUSH;
+ setmodel (e, e.model);
+ e.mdl_debris = "progs/debris.mdl";
+ precache_model (e.mdl_debris);
precache_sound ("blob/hit1.wav");

- if (this.noise1 != "")
- precache_sound (this.noise1);
+ if (e.noise1 != "")
+ precache_sound (e.noise1);

// adding new default sounds for "simple" breakables in 1.2.0
// -- dumptruck_ds

// here's genreic metal breaking
- if (this.style == 0 || this.style == 11 ||
- this.style == 12 || this.style == 17 ||
- this.style == 18 || this.style == 19 ||
- this.style == 24 || this.style == 31)
+ if (e.style == 0 || e.style == 11 ||
+ e.style == 12 || e.style == 17 ||
+ e.style == 18 || e.style == 19 ||
+ e.style == 24 || e.style == 31)
{
- if !(this.noise1)
+ if !(e.noise1)
{
precache_sound ("break/metal2.wav");
- this.noise1 = "break/metal2.wav";
+ e.noise1 = "break/metal2.wav";
}
}

- if (this.style == 3 || this.style == 4 || this.style == 5)
+ if (e.style == 3 || e.style == 4 || e.style == 5)
{
- if !(this.noise1)
+ if !(e.noise1)
{
precache_sound ("break/wood1.wav");
precache_sound ("break/wood2.wav");
// wood only randomized
if (random() > 0.6)
- this.noise1 = "break/wood1.wav";
+ e.noise1 = "break/wood1.wav";
else
- this.noise1 = "break/wood2.wav";
+ e.noise1 = "break/wood2.wav";
}
}

// glass sounds -- this is more of a shattering sound anyway
- if (this.style == 6 || this.style == 7 || this.style == 8 ||
- this.style == 9 || this.style == 10)
+ if (e.style == 6 || e.style == 7 || e.style == 8 ||
+ e.style == 9 || e.style == 10)
{
- if !(this.noise1)
+ if !(e.noise1)
{
precache_sound ("break/metal1.wav");
- this.noise1 = "break/metal1.wav";
+ e.noise1 = "break/metal1.wav";
}
}

- if (this.style == 1 || this.style == 2 ||
- this.style == 13 || this.style == 14 ||
- this.style == 15 || this.style == 16 ||
- this.style == 20 || this.style == 21 ||
- this.style == 22 || this.style == 23)
+ if (e.style == 1 || e.style == 2 ||
+ e.style == 13 || e.style == 14 ||
+ e.style == 15 || e.style == 16 ||
+ e.style == 20 || e.style == 21 ||
+ e.style == 22 || e.style == 23)
{
- if !(this.noise1)
+ if !(e.noise1)
{
precache_sound ("break/stones1.wav");
precache_sound ("break/bricks1.wav");
// wood only randomized
if (random() > 0.6)
- this.noise1 = "break/bricks1.wav";
+ e.noise1 = "break/bricks1.wav";
else
- this.noise1 = "break/stones1.wav";
+ e.noise1 = "break/stones1.wav";
}
}

- if (this.style == 25 || this.style == 26 ||
- this.style == 27 || this.style == 28 ||
- this.style == 29 || this.style == 30)
+ if (e.style == 25 || e.style == 26 ||
+ e.style == 27 || e.style == 28 ||
+ e.style == 29 || e.style == 30)
{
- if !(this.noise1)
+ if !(e.noise1)
{
precache_sound ("break/stones1.wav");
precache_sound ("break/bricks1.wav");
// wood only randomized
if (random() > 0.6)
- this.noise1 = "break/stones1.wav";
+ e.noise1 = "break/stones1.wav";
else
- this.noise1 = "break/bricks1.wav";
+ e.noise1 = "break/bricks1.wav";
}
// else
// {
- // (this.noise1 = "blob/hit1.wav");
+ // (e.noise1 = "blob/hit1.wav");
// }
}

- if (!this.health)
- this.health = 20;
- if (!this.cnt)
+ if (!e.health)
+ e.health = 20;
+ if (!e.cnt)
// was 6 dumptruck_ds
- this.cnt = 5;
+ e.cnt = 5;

- if (this.targetname == __NULL__ || this.targetname == "")
+ if (e.targetname != "" && e.targetname != __NULL__)
+ {
+ e.use = base_breakable_use;
+ }
+ else
{
- this.takedamage = DAMAGE_YES;
- this.th_die = this.do_destroy;
+ e.takedamage = DAMAGE_YES;
+ e.destroy = base_breakable_destroy;
}

- if (this.switchshadstyle)
- lightstyle (this.switchshadstyle, "a");
+ if (e.switchshadstyle)
+ lightstyle (e.switchshadstyle, "a");
};

//--------------------------------------------------------------
void() func_breakable =
{
- this.classtype = CT_FUNC_BREAKABLE;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ func_breakable_init (self);
};
-};
+// };

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

Diff qc/func/brush.qc

diff --git a/qc/func/brush.qc b/qc/func/brush.qc
index 208f115..55a1de6 100644
--- a/qc/func/brush.qc
+++ b/qc/func/brush.qc
@@ -2,16 +2,14 @@
// func_brush
//==============================================================================

-// this is on hold and not in progs.src
+//----------------------------------------------------------------------
// crashes in QS at the moment Jaycie is looking into it
+//----------------------------------------------------------------------

-// fields
-/*
-.float solidstate;
-.float visiblestate;
-*/
-
+//======================================================================
// constants
+//======================================================================
+
const float BRUSH_START_INVISIBLE = 1;
const float BRUSH_START_NONSOLID = 2;
const float BRUSH_START_ALTFRAMES = 4;
@@ -19,6 +17,16 @@ const float BRUSH_TOGGLE_VISIBILITY = 8;
const float BRUSH_TOGGLE_SOLIDITY = 16;
const float BRUSH_TOGGLE_FRAMES = 32;

+//======================================================================
+// fields
+//======================================================================
+
+/*
+.float solidstate;
+.float visiblestate;
+*/
+
+#if 0
//----------------------------------------------------------------------
void() func_brush_use =
{
@@ -89,3 +97,4 @@ void() func_brush =
else
self.frame = 0;
};
+#endif

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

Diff qc/func/button.qc

diff --git a/qc/func/button.qc b/qc/func/button.qc
index 5eddda2..5ad1a03 100644
--- a/qc/func/button.qc
+++ b/qc/func/button.qc
@@ -2,6 +2,26 @@
// func_button -- button and multiple button
//==============================================================================

+//======================================================================
+// forward declarations
+//======================================================================
+
+// func_button
+void() func_button_think_wait;
+void() func_button_think_done;
+void() func_button_think_return;
+void() func_button_blocked;
+void() func_button_fire;
+void() func_button_destroy;
+void() func_button_use;
+void() func_button_touch;
+void(entity b) func_button_lock;
+void(entity b, float dontresetstate) func_button_unlock;
+void(entity e) func_button_init;
+void() func_button;
+
+//------------------------------------------------------------------------------
+
/*QUAKED func_button (0 .5 .8) ? X X X X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
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.

@@ -17,119 +37,108 @@ When a button is touched, it moves some distance in the direction of it's angle,
2) metallic click
3) in-out
*/
-class func_button: base_func
-{
- float lip;
- /*
- vector pos1;
- vector pos2;
- */
-
- //--------------------------------------------------------------
- virtual void(string fieldname, string fieldvalue) init_field =
- {
- switch (fieldname)
- {
- case "lip":
- lip = stof (fieldvalue);
- break;
- default:
- super::init_field (fieldname, fieldvalue);
- }
- };
-
+//----------------------------------------------------------------------
+// class func_button: base_func
+// {
//--------------------------------------------------------------
- nonvirtual void() button_wait =
+ void() func_button_think_wait =
{
- this.state = FUNC_STATE_TOP;
- this.nextthink = this.ltime + this.wait;
- activator = this.enemy;
+ self.state = FUNC_STATE_TOP;
+ self.think = func_button_think_return;
+ self.nextthink = self.ltime + self.wait;
+ activator = self.enemy;
// use alternate textures
- this.frame = 1;
+ self.frame = 1;

- if (this.estate != STATE_ACTIVE)
+ if (self.estate != STATE_ACTIVE)
return;

sub_usetargets ();
};

//--------------------------------------------------------------
- nonvirtual void() button_done =
+ void() func_button_think_done =
{
- this.state = FUNC_STATE_BOTTOM;
+ self.state = FUNC_STATE_BOTTOM;
};

//--------------------------------------------------------------
- nonvirtual void() button_fire =
+ void() func_button_think_return =
{
- if (this.estate != STATE_ACTIVE)
+ if (self.estate != STATE_ACTIVE)
return;

- if (this.state == FUNC_STATE_UP || this.state == FUNC_STATE_TOP)
- return;
+ self.state = FUNC_STATE_DOWN;
+ sub_calcmove (self, self.pos1, self.speed,
+ func_button_think_done);
+ // use normal textures
+ self.frame = 0;

- sound (this, CHAN_VOICE, this.noise, 1, ATTN_NORM);
+ if (self.health)
+ // can be shot again
+ self.takedamage = DAMAGE_YES;
+ };

- this.state = FUNC_STATE_UP;
- calc_move (this.pos2, this.speed, button_wait);
+ //--------------------------------------------------------------
+ void() func_button_blocked =
+ {
+ // do nothing, just don't ome all the way back out
};

//--------------------------------------------------------------
- virtual void() do_destroy =
+ void() func_button_fire =
{
- if (this.estate != STATE_ACTIVE)
+ if (self.estate != STATE_ACTIVE)
return;

- this.enemy = damage_attacker;
- this.health = this.max_health;
- // wil be reset upon return
- this.takedamage = DAMAGE_NO;
+ if (self.state == FUNC_STATE_UP || self.state == FUNC_STATE_TOP)
+ return;
+
+ sound (self, CHAN_VOICE, self.noise, 1, ATTN_NORM);

- button_fire ();
+ self.state = FUNC_STATE_UP;
+ sub_calcmove (self, self.pos2, self.speed,
+ func_button_think_wait);
};

//--------------------------------------------------------------
- // was button_return -- CEV
- //--------------------------------------------------------------
- virtual void() do_think =
+ void() func_button_destroy =
{
- if (this.estate != STATE_ACTIVE)
+ if (self.estate != STATE_ACTIVE)
return;

- this.state = FUNC_STATE_DOWN;
- calc_move (this.pos1, this.speed, this.button_done);
- // use normal textures
- this.frame = 0;
+ self.enemy = damage_attacker;
+ self.health = self.max_health;
+ // wil be reset upon return
+ self.takedamage = DAMAGE_NO;

- if (this.health)
- // can be shot again
- this.takedamage = DAMAGE_YES;
+ func_button_fire ();
};

//--------------------------------------------------------------
- virtual void(entity caller) do_use =
+ void() func_button_use =
{
- this.enemy = activator;
- button_fire ();
+ self.enemy = activator;
+ func_button_fire ();
};

//--------------------------------------------------------------
- virtual void(entity toucher) do_touch =
+ void() func_button_touch =
{
- if (this.health)
+ if (self.health)
return;

- if (toucher.classtype != CT_PLAYER)
+ if (other.classtype != CT_PLAYER)
return;

- this.enemy = toucher;
- button_fire ();
+ self.enemy = other;
+ func_button_fire ();
};

//--------------------------------------------------------------
// adapted from Copper, thanks Lunaran -- modified again by CEV
//--------------------------------------------------------------
- nonvirtual void(func_button b) button_lock =
+ void(entity b) func_button_lock =
{
if (b.estate == STATE_INACTIVE)
return;
@@ -143,12 +152,12 @@ class func_button: base_func
b.takedamage = DAMAGE_NO;

b.state = FUNC_STATE_UP;
- b.calc_move (b.pos2, b.speed, b.button_wait);
+ sub_calcmove (b, b.pos2, b.speed, func_button_think_wait);
b.estate = STATE_INACTIVE;
};

//--------------------------------------------------------------
- nonvirtual void(func_button b, float dontresetstate) button_unlock =
+ void(entity b, float dontresetstate) func_button_unlock =
{
if (b.estate == STATE_ACTIVE)
return;
@@ -165,69 +174,85 @@ class func_button: base_func
// use normal textures
b.frame = 0;
b.state = FUNC_STATE_DOWN;
- b.calc_move (b.pos1, b.speed, b.button_done);
+ sub_calcmove (b, b.pos1, b.speed,
+ func_button_think_done);
}

b.estate = STATE_ACTIVE;
};

//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) func_button_init =
{
- if (this.sounds == 0)
+ e.classname = "func_button";
+ e.classtype = CT_FUNC_BUTTON;
+ e.blocked = func_button_blocked;
+ e.use = func_button_use;
+
+ base_func_init (e);
+
+ if (e.sounds == 0)
{
precache_sound ("buttons/airbut1.wav");
- this.noise = "buttons/airbut1.wav";
+ e.noise = "buttons/airbut1.wav";
}

- if (this.sounds == 1)
+ if (e.sounds == 1)
{
precache_sound ("buttons/switch21.wav");
- this.noise = "buttons/switch21.wav";
+ e.noise = "buttons/switch21.wav";
}

- if (this.sounds == 2)
+ if (e.sounds == 2)
{
precache_sound ("buttons/switch02.wav");
- this.noise = "buttons/switch02.wav";
+ e.noise = "buttons/switch02.wav";
}

- if (this.sounds == 3)
+ if (e.sounds == 3)
{
precache_sound ("buttons/switch04.wav");
- this.noise = "buttons/switch04.wav";
+ e.noise = "buttons/switch04.wav";
}

- sub_setmovedir ();
+ sub_setmovedir (e);

- this.movetype = MOVETYPE_PUSH;
- this.solid = SOLID_BSP;
- setmodel (this, this.model);
+ e.movetype = MOVETYPE_PUSH;
+ e.solid = SOLID_BSP;
+ setmodel (e, e.model);

- if (this.health)
+ if (e.health)
+ {
+ e.max_health = e.health;
+ e.takedamage = DAMAGE_YES;
+ e.destroy = func_button_destroy;
+ }
+ else
{
- this.max_health = this.health;
- this.takedamage = DAMAGE_YES;
- this.th_die = this.do_destroy;
+ e.touch = func_button_touch;
}

- if (!this.speed)
- this.speed = 40;
- if (!this.wait)
- this.wait = 1;
- if (!this.lip)
- this.lip = 4;
+ if (!e.speed)
+ e.speed = 40;
+ if (!e.wait)
+ e.wait = 1;
+ if (!e.lip)
+ e.lip = 4;

- this.state = FUNC_STATE_BOTTOM;
+ e.state = FUNC_STATE_BOTTOM;

- this.pos1 = this.origin;
- this.pos2 = this.pos1 + this.movedir *
- (fabs(this.movedir * this.size) - this.lip);
+ e.pos1 = e.origin;
+ e.pos2 = e.pos1 + e.movedir *
+ (fabs(e.movedir * e.size) - e.lip);
};

//--------------------------------------------------------------
void() func_button =
{
- this.classtype = CT_FUNC_BUTTON;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ func_button_init (self);
};
-};
+// };

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

Diff qc/func/counter.qc

diff --git a/qc/func/counter.qc b/qc/func/counter.qc
index 93f0060..7bf6a39 100644
--- a/qc/func/counter.qc
+++ b/qc/func/counter.qc
@@ -8,7 +8,10 @@
// All rights reserved.
// Distributed (unsupported) on 3.12.97

+//======================================================================
// constants
+//======================================================================
+
const float COUNTER_TOGGLE = 1;
const float COUNTER_LOOP = 2;
const float COUNTER_STEP = 4;
@@ -17,6 +20,26 @@ const float COUNTER_RANDOM = 16;
const float COUNTER_FINISHCOUNT = 32;
const float COUNTER_START_ON = 64;

+//======================================================================
+// forward declarations
+//======================================================================
+
+// func_counter
+void() func_counter_think_starton;
+void() func_counter_think;
+void() func_counter_use_on;
+void() func_counter_use_off;
+float(entity e) func_counter_getcount;
+void(entity e) func_counter_init;
+void() func_counter;
+
+// func_oncount
+void() func_oncount_use;
+void(entity e) func_oncount_init;
+void() func_oncount;
+
+//------------------------------------------------------------------------------
+
/*QUAKED func_counter (0 0 0.5) (0 0 0) (32 32 32) TOGGLE LOOP STEP RESET RANDOM FINISHCOUNT START_ON X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
TOGGLE causes the counter to switch between an on and off state
each time the counter is triggered.
@@ -44,177 +67,150 @@ it specifies how high to count before reseting to zero. Default is 10.

"delay" how much time to wait before firing after being switched on.
*/
-class func_counter: base_func
-{
- float count;
- float counter_on;
-
+//----------------------------------------------------------------------
+// class func_counter: base_func
+// {
//--------------------------------------------------------------
- virtual void(string fieldname, string fieldvalue) init_field =
+ void() func_counter_think_starton =
{
- switch (fieldname)
- {
- case "count":
- count = stof (fieldvalue);
- break;
- default:
- super::init_field (fieldname, fieldvalue);
- }
+ activator = world;
+ func_counter_use_off ();
};

//--------------------------------------------------------------
- virtual void() do_think =
+ void() func_counter_think =
{
- if (this.spawnflags & COUNTER_START_ON && other != this &&
- counter_on == TRUE)
+ // was counter_think -- CEV
+ self.cnt = self.cnt + 1;
+ if (self.spawnflags & COUNTER_RANDOM)
{
- // was counter_start_on_think -- CEV
- // fix func_counter and func_oncount handling of
- // activator -- iw
- // to ensure it's not a random entity -- iw
- activator = world;
- counter_off_use ();
+ self.state = random () * self.count;
+ self.state = floor (self.state) + 1;
}
else
{
- // was counter_think -- CEV
- this.cnt = this.cnt + 1;
- if (this.spawnflags & COUNTER_RANDOM)
- {
- this.state = random() * this.count;
- this.state = floor(this.state) + 1;
- }
- else
- {
- this.state = this.cnt;
- }
-
- // fix func_counter and func_oncount handling of
- // activator -- iw
- // activator = other;
- activator = this.enemy;
- sub_usetargets ();
- this.nextthink = time + this.wait;
-
- if (this.spawnflags & COUNTER_STEP)
- {
- counter_on_use ();
- }
-
- if (this.cnt >= this.count)
- {
- this.cnt = 0;
- if ((aflag) || !(spawnflags & COUNTER_LOOP))
- if (this.spawnflags & COUNTER_TOGGLE)
- counter_on_use ();
- else
- remove (this);
- }
+ self.state = self.cnt;
+ }
+
+ // fix func_counter and func_oncount handling of activator -- iw
+ // activator = other;
+ activator = self.enemy;
+ sub_usetargets ();
+ self.nextthink = time + self.wait;
+
+ if (self.spawnflags & COUNTER_STEP)
+ {
+ func_counter_use_on ();
+ }
+
+ if (self.cnt >= self.count)
+ {
+ self.cnt = 0;
+ if ((self.aflag) || !(self.spawnflags & COUNTER_LOOP))
+ if (self.spawnflags & COUNTER_TOGGLE)
+ func_counter_use_on ();
+ else
+ remove (self);
}
};

//--------------------------------------------------------------
- nonvirtual void() counter_on_use =
+ void() func_counter_use_on =
{
- if ((this.cnt != 0) && (this.spawnflags & COUNTER_FINISHCOUNT))
+ if ((self.cnt != 0) && (self.spawnflags & COUNTER_FINISHCOUNT))
{
- this.aflag = TRUE;
+ self.aflag = TRUE;
return;
}

- this.counter_on = TRUE;
- this.interaction_flags |= DISABLE_THINK;
- this.aflag = FALSE;
+ self.use = func_counter_use_off;
+ self.think = sub_null;
+ self.aflag = FALSE;
};

//--------------------------------------------------------------
- nonvirtual void() counter_off_use =
+ void() func_counter_use_off =
{
- this.aflag = FALSE;
+ self.aflag = FALSE;
// make sure to toggle -- CEV
- if (this.spawnflags & COUNTER_TOGGLE || this.counter_on == TRUE)
- {
- this.counter_on = FALSE;
- }
+ if (self.spawnflags & COUNTER_TOGGLE)
+ self.use = func_counter_use_on;
+ else
+ self.use = sub_null;

- if (this.spawnflags & COUNTER_RESET)
+ if (self.spawnflags & COUNTER_RESET)
{
- this.cnt = 0;
- this.state = 0;
+ self.cnt = 0;
+ self.state = 0;
}

// fix func_counter and func_oncount handling of activator -- iw
- this.enemy = activator;
- this.interaction_flags &= ~DISABLE_THINK;
+ self.enemy = activator;
+ self.think = func_counter_think;

// fix "delay" making func_counter not work -- iw
- // if (this.delay)
- if (this.pausetime)
- {
+ // if (self.delay)
+ if (self.pausetime)
// fix "delay" making func_counter not work -- iw
- // this.nextthink = time + this.delay;
- this.nextthink = time + this.pausetime;
- }
+ // self.nextthink = time + self.delay;
+ self.nextthink = time + self.pausetime;
else
- {
- dprint ("func_counter::counter_off_use: calling "
- "do_think...\n");
- this.do_think ();
- }
- };
-
- //--------------------------------------------------------------
- virtual void(entity caller) do_use =
- {
- if (counter_on)
- counter_off_use ();
- else
- if (this.spawnflags & COUNTER_TOGGLE)
- counter_on_use ();
+ func_counter_think ();
};

//--------------------------------------------------------------
- static float(entity ent) getcount =
+ float(entity e) func_counter_getcount =
{
- if (ent.classtype == CT_FUNC_COUNTER)
- return ent.state;
+ if (e.classtype == CT_FUNC_COUNTER)
+ return e.state;

return 0;
};

//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) func_counter_init =
{
- if (!this.wait)
- this.wait = 1;
+ e.classname = "counter";
+ e.classtype = CT_FUNC_COUNTER;

- this.count = floor (this.count);
- if (this.count <= 0)
- this.count = 10;
+ base_func_init (e);
+
+ if (!e.wait)
+ e.wait = 1;
+
+ e.count = floor (e.count);
+ if (e.count <= 0)
+ e.count = 10;

// fix "delay" making func_counter not work -- iw
- this.pausetime = this.delay;
- this.delay = 0;
- this.cnt = 0;
- this.state = 0;
+ e.pausetime = e.delay;
+ e.delay = 0;
+ e.cnt = 0;
+ e.state = 0;

- this.counter_on = TRUE;
- this.interaction_flags |= DISABLE_THINK;
+ e.use = func_counter_use_off;

- if (this.spawnflags & COUNTER_START_ON)
+ if (e.spawnflags & COUNTER_START_ON)
+ {
+ e.think = func_counter_think_starton;
+ e.nextthink = time + 0.1;
+ }
+ else
{
- this.interaction_flags &= ~DISABLE_THINK;
- this.nextthink = time + 0.1;
+ e.think = sub_null;
}
};

//--------------------------------------------------------------
void() func_counter =
{
- this.classname = "counter";
- this.classtype = CT_FUNC_COUNTER;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ func_counter_init (self);
};
-};
+// };

/*QUAKED func_oncount (0 0 0.5) (0 0 0) (16 16 16)
Must be used as the target for func_counter. When the counter
@@ -224,27 +220,13 @@ reaches the value set by count, func_oncount triggers its targets.

"delay" how much time to wait before firing after being triggered.
*/
-class func_oncount: base_func
-{
- float count;
-
- //--------------------------------------------------------------
- virtual void(string fieldname, string fieldvalue) init_field =
- {
- switch (fieldname)
- {
- case "count":
- count = stof (fieldvalue);
- break;
- default:
- super::init_field (fieldname, fieldvalue);
- }
- };
-
+//----------------------------------------------------------------------
+// class func_oncount: base_func
+// {
//--------------------------------------------------------------
- virtual void(entity caller) do_use =
+ void() func_oncount_use =
{
- if (func_counter::getcount(caller) == this.count)
+ if (func_counter_getcount(other) == self.count)
{
// fix func_counter and func_oncount handling
// of activator -- iw
@@ -254,18 +236,28 @@ class func_oncount: base_func
};

//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) func_oncount_init =
{
- this.count = floor (this.count);
+ e.classname = "oncount";
+ e.classtype = CT_FUNC_ONCOUNT;
+
+ base_func_init (e);
+
+ e.count = floor (e.count);
+ if (e.count <= 0)
+ e.count = 1;

- if (this.count <= 0)
- this.count = 1;
+ e.think = sub_null;
+ e.use = func_oncount_use;
};

//--------------------------------------------------------------
void() func_oncount =
{
- this.classname = "oncount";
- this.classtype = CT_FUNC_ONCOUNT;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ func_oncount_init (self);
};
-};
+// };

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

Diff qc/func/door.qc

diff --git a/qc/func/door.qc b/qc/func/door.qc
index 7f9519c..e72cc57 100644
--- a/qc/func/door.qc
+++ b/qc/func/door.qc
@@ -12,46 +12,113 @@
// prev/next link connects to __NULL__ or back to self/this.
//----------------------------------------------------------------------

+//======================================================================
// constants
-const float DOOR_START_OPEN = 1;
+//======================================================================
+
+const float DOOR_START_OPEN = 1; // spawnflags
const float DOOR_DONT_LINK = 4;
const float DOOR_GOLD_KEY = 8;
const float DOOR_SILVER_KEY = 16;
const float DOOR_TOGGLE = 32;
const float DOOR_DOOM_STYLE_UNLOCK = 64;

+//======================================================================
+// fields
+//======================================================================
+
+.float last_setstate_frame = light_lev;
+.entity last_setstate = aiment;
+
+//======================================================================
+// forward declarations
+//======================================================================
+
+// temp_door_trigger
+void() temp_door_trigger_touch;
+entity(entity own, vector nmins, vector nmaxs) spawn_temp_door_trigger;
+void(entity e) temp_door_trigger_init;
+strip void() temp_door_trigger;
+
+// func_door
+float(entity e1, entity e2) func_door_entities_touching;
+void() func_door_blocked;
+void() func_door_hit_top;
+void() func_door_hit_bottom;
+void() func_door_think_go_down;
+void() func_door_think_go_up;
+void() func_door_group_go_down;
+void() func_door_group_go_up;
+void() func_door_fire;
+void() func_door_use;
+void() func_door_destroy;
+void() func_door_unlock;
+void() func_door_touch;
+void(entity e, float closealldoors) func_door_estate_lock;
+void(entity e, float openalldoors) func_door_estate_unlock;
+void() func_door_think_link;
+void(entity e) func_door_init;
+void() func_door;
+
//------------------------------------------------------------------------------
-class temp_door_trigger: base_tempentity
-{
- base_mapentity primary_door;

+//----------------------------------------------------------------------
+// class temp_door_trigger: base_tempentity
+// {
//--------------------------------------------------------------
- virtual void(entity toucher) do_touch =
+ void() temp_door_trigger_touch =
{
- if (toucher.health <= 0)
+ // don't trigger on projectiles -- CEV
+ if (other.classgroup & CG_PROJECTILE)
+ return;
+
+ if (other.health <= 0)
return;

- if (toucher.movetype == MOVETYPE_NOCLIP)
+ if (other.movetype == MOVETYPE_NOCLIP)
// from copper -- dumptruck_ds
return;

- if (time < this.attack_finished)
+ if (time < self.attack_finished)
return;

- this.attack_finished = time + 1;
+ self.attack_finished = time + 1;

- if (this.primary_door)
- primary_door.do_use (toucher);
+ activator = other;
+
+ if (self.owner)
+ sub_runvoidas (self.owner, func_door_use);
};

//--------------------------------------------------------------
- void() temp_door_trigger =
+ entity(entity own, vector nmins, vector nmaxs)
+ spawn_temp_door_trigger =
{
- this.classtype = CT_TEMP_DOOR_TRIGGER;
- this.movetype = MOVETYPE_NONE;
- this.solid = SOLID_TRIGGER;
+ local entity e = spawn ();
+ e.owner = own;
+ setsize (e, nmins, nmaxs);
+ temp_door_trigger_init (e);
+ return e;
};
-};
+
+ //--------------------------------------------------------------
+ void(entity e) temp_door_trigger_init =
+ {
+ e.classtype = CT_TEMP_DOOR_TRIGGER;
+ e.movetype = MOVETYPE_NONE;
+ e.solid = SOLID_TRIGGER;
+
+ base_tempentity_init (e);
+
+ e.touch = temp_door_trigger_touch;
+ };
+
+ //--------------------------------------------------------------
+ strip void() temp_door_trigger =
+ {
+ temp_door_trigger_init (self);
+ };
+// };

/*QUAKED func_door (0 .5 .8) ? START_OPEN x DOOR_DONT_LINK GOLD_KEY SILVER_KEY TOGGLE X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY

@@ -84,35 +151,11 @@ Key doors are always wait -1.
3) stone chain
4) screechy metal
*/
-class func_door: base_func
-{
- float is_primary;
- float lip;
- float need_link;
- /*
- vector pos1;
- vector pos2;
- */
- temp_door_trigger area_trig;
- func_door prev_door;
- func_door next_door;
- misc_shadowcontroller shadow;
-
- //--------------------------------------------------------------
- virtual void(string fieldname, string fieldvalue) init_field =
- {
- switch (fieldname)
- {
- case "lip":
- lip = stof (fieldvalue);
- break;
- default:
- super::init_field (fieldname, fieldvalue);
- }
- };
-
+//----------------------------------------------------------------------
+// class func_door: base_func
+// {
//--------------------------------------------------------------
- static float (entity e1, entity e2) entities_touching =
+ float(entity e1, entity e2) func_door_entities_touching =
{
if (e1.mins_x > e2.maxs_x)
return FALSE;
@@ -134,120 +177,146 @@ class func_door: base_func
//--------------------------------------------------------------

//--------------------------------------------------------------
- virtual void(entity blocker) do_blocked =
+ void() func_door_blocked =
{
- this.t_damage2 (blocker, this, this, this.dmg);
+ // TODO CEV
+ dprint ("entering func_door_blocked...\n");
+ // don't block on projectiles -- CEV
+ if (other.classgroup & CG_PROJECTILE)
+ return;
+
+ t_damage2 (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 (this.wait >= 0)
+ if (self.wait >= 0)
{
- if (this.state == FUNC_STATE_DOWN)
- door_go_up ();
+ if (self.state == FUNC_STATE_DOWN)
+ func_door_think_go_up ();
else
- door_go_down ();
+ func_door_think_go_down ();
}
};

//--------------------------------------------------------------
- nonvirtual void() door_hit_top =
+ void() func_door_hit_top =
{
- sound (this, CHAN_VOICE, noise1, 1, ATTN_NORM);
- this.state = FUNC_STATE_TOP;
- if (this.spawnflags & DOOR_TOGGLE)
+ sound (self, CHAN_VOICE, self.noise1, 1, ATTN_NORM);
+ self.state = FUNC_STATE_TOP;
+ if (self.spawnflags & DOOR_TOGGLE)
// don't come down automatically
return;

- this.nextthink = this.ltime + this.wait;
+ self.think = func_door_think_go_down;
+ self.nextthink = self.ltime + self.wait;
};

//--------------------------------------------------------------
- nonvirtual void() door_hit_bottom =
+ void() func_door_hit_bottom =
{
- sound (this, CHAN_VOICE, this.noise1, 1, ATTN_NORM);
- this.state = FUNC_STATE_BOTTOM;
+ sound (self, CHAN_VOICE, self.noise1, 1, ATTN_NORM);
+ self.state = FUNC_STATE_BOTTOM;
};

//--------------------------------------------------------------
- nonvirtual void() door_go_down =
+ void() func_door_think_go_down =
{
- sound (this, CHAN_VOICE, noise2, 1, ATTN_NORM);
- if (this.max_health)
+ sound (self, CHAN_VOICE, self.noise2, 1, ATTN_NORM);
+ if (self.max_health)
{
- this.takedamage = DAMAGE_YES;
- this.health = this.max_health;
+ self.takedamage = DAMAGE_YES;
+ self.health = self.max_health;
}

- this.state = FUNC_STATE_DOWN;
- calc_move (this.pos1, this.speed, door_hit_bottom);
+ self.state = FUNC_STATE_DOWN;
+ sub_calcmove (self, self.pos1, self.speed,
+ func_door_hit_bottom);

- if (this.switchshadstyle && this.shadow)
+ if (self.switchshadstyle && self.shadowcontroller)
{
- if (this.spawnflags & DOOR_START_OPEN)
+ if (self.spawnflags & DOOR_START_OPEN)
{
- shadow.fade_out ();
- shadow.shadowoff = 1;
+ sub_runvoidas (self.shadowcontroller,
+ misc_shadowcontroller_fade_out);
+ self.shadowcontroller.shadowoff = 1;
}
else
{
- shadow.fade_in ();
- shadow.shadowoff = 0;
+ sub_runvoidas (self.shadowcontroller,
+ misc_shadowcontroller_fade_in);
+ self.shadowcontroller.shadowoff = 0;
}
}
};

//--------------------------------------------------------------
- nonvirtual void() door_go_up =
+ void() func_door_think_go_up =
{
- if (this.state == FUNC_STATE_UP)
+ if (self.state == FUNC_STATE_UP)
// allready going up
return;

- if (this.state == FUNC_STATE_TOP)
+ if (self.state == FUNC_STATE_TOP)
{
// reset top wait time
- this.nextthink = this.ltime + this.wait;
+ self.nextthink = self.ltime + self.wait;
return;
}

- sound (this, CHAN_VOICE, this.noise2, 1, ATTN_NORM);
- this.state = FUNC_STATE_UP;
- calc_move (this.pos2, this.speed, door_hit_top);
+ sound (self, CHAN_VOICE, self.noise2, 1, ATTN_NORM);
+ self.state = FUNC_STATE_UP;
+ sub_calcmove (self, self.pos2, self.speed, func_door_hit_top);

sub_usetargets ();

- if (this.switchshadstyle && this.shadow)
+ if (self.switchshadstyle && self.shadowcontroller)
{
- if (this.spawnflags & DOOR_START_OPEN)
+ if (self.spawnflags & DOOR_START_OPEN)
{
- shadow.fade_in ();
- shadow.shadowoff = 0;
+ sub_runvoidas (self.shadowcontroller,
+ misc_shadowcontroller_fade_in);
+ self.shadowcontroller.shadowoff = 0;
}
else
{
- shadow.fade_out ();
- shadow.shadowoff = 1;
+ sub_runvoidas (self.shadowcontroller,
+ misc_shadowcontroller_fade_out);
+ self.shadowcontroller.shadowoff = 1;
}
}
};

//--------------------------------------------------------------
- nonvirtual void() door_group_go_down =
+ void() func_door_group_go_down =
{
- door_go_down ();
+ local entity oself, starte;
+ oself = starte = self;
+
+ do
+ {
+ func_door_think_go_down ();
+ self = self.enemy;
+ }
+ while ((self != starte) && (self != world));

- if (next_door && next_door != this && next_door != world)
- next_door.door_group_go_down ();
+ self = oself;
};

//--------------------------------------------------------------
- nonvirtual void() door_group_go_up =
+ void() func_door_group_go_up =
{
- door_go_up ();
+ local entity oself, starte;
+ oself = starte = self;
+
+ do
+ {
+ func_door_think_go_up ();
+ self = self.enemy;
+ }
+ while ((self != starte) && (self != world));

- if (next_door && next_door != this && next_door != world)
- next_door.door_group_go_up ();
+ self = oself;
};

//--------------------------------------------------------------
@@ -255,84 +324,60 @@ class func_door: base_func
//--------------------------------------------------------------

//--------------------------------------------------------------
- // door_fire gets very confused if it's not static -- CEV
- //--------------------------------------------------------------
- static void(func_door d) door_fire =
+ void() func_door_fire =
{
- if (d.is_primary == FALSE)
- objerror ("door_fire: called on non-primary door\n");
+ if (self.owner != self)
+ objerror ("func_door_fire: self.owner != self\n");

- if (d.estate != STATE_ACTIVE)
+ if (self.estate != STATE_ACTIVE)
return;

// noise4 is now played in keylock_try_to_unlock -- iw

// no more message
- d.message = "";
+ self.message = "";

- if (d.spawnflags & DOOR_TOGGLE)
+ if (self.spawnflags & DOOR_TOGGLE)
{
- if (d.state == FUNC_STATE_UP ||
- d.state == FUNC_STATE_TOP)
+ if (self.state == FUNC_STATE_UP ||
+ self.state == FUNC_STATE_TOP)
{
- d.door_group_go_down ();
+ func_door_group_go_down ();
return;
}
}

// trigger all paired doors
- d.door_group_go_up ();
- };
-
- //--------------------------------------------------------------
- virtual void() do_think =
- {
- if (this.need_link == TRUE)
- this.link_doors ();
- else
- this.door_go_down ();
+ func_door_group_go_up ();
};

//--------------------------------------------------------------
- virtual void(entity caller) do_use =
+ void() func_door_use =
{
- if (this.is_primary == FALSE)
- {
- /*
- dprint ("func_door::do_use: called use on a "
- "non-primary door\n");
- */
- if (prev_door && prev_door != this)
- prev_door.do_use (caller);
- return;
- }
+ local entity oself = self;

- // door message are for touch only
- local func_door next = this;
- do
- {
- next.message = "";
- next = next.next_door;
- }
- while (next && next != this && next != world);
+ // door messages are for touch only
+ self.message = "";
+ if (self.enemy)
+ self.enemy.message = "";
+ self.owner.message = "";

- door_fire (this);
+ self = self.owner;
+ func_door_fire ();
+ self = oself;
};

//--------------------------------------------------------------
- virtual void() do_destroy =
+ void() func_door_destroy =
{
- if (this.is_primary == FALSE)
- {
- if (prev_door && prev_door != this)
- prev_door.do_destroy ();
- return;
- }
+ local entity oself = self;

- this.health = this.max_health;
+ self = self.owner;
+ self.health = self.max_health;
// will be reset upon return
- this.takedamage = DAMAGE_NO;
- do_use (other);
+ self.takedamage = DAMAGE_NO;
+ func_door_use ();
+ self = oself;
};

//--------------------------------------------------------------
@@ -345,57 +390,50 @@ class func_door: base_func
// to the new keylock_try_to_unlock function. This code was
// previously part of the door_touch function. -- iw
//--------------------------------------------------------------
- nonvirtual void() door_unlock =
+ void() func_door_unlock =
{
- if (!(this.spawnflags & DOOR_DOOM_STYLE_UNLOCK))
+ if (!(self.spawnflags & DOOR_DOOM_STYLE_UNLOCK))
{
// door has been unlocked, don't allow player to
// touch / activate it again
- local func_door next = this;
+ local entity n = self;
do
{
- next.interaction_flags |= DISABLE_TOUCH;
- next = next.next_door;
+ n.touch = sub_null;
+ n = n.enemy;
}
- while (next && next != this && next != world);
+ while (n && n != self && n != world);
}
- do_use (other);
+
+ func_door_use ();
};

//--------------------------------------------------------------
// door_touch -- Prints messages and opens key doors
//--------------------------------------------------------------
- virtual void(entity toucher) do_touch =
+ void() func_door_touch =
{
- // find the primary door -- CEV
- if (this.is_primary == FALSE)
- {
- if (prev_door && prev_door != this)
- prev_door.do_touch (toucher);
- return;
- }
-
// from Copper -- dumptruck_ds
- if (sub_checkvalidtouch(toucher) == FALSE)
+ if (sub_checkvalidtouch(other) == FALSE)
return;

- if (this.attack_finished > time)
+ if (self.owner.attack_finished > time)
return;

- this.attack_finished = time + 2;
+ self.owner.attack_finished = time + 2;

- if (this.message != __NULL__ && this.message != "")
+ if (self.owner.message != __NULL__ && self.owner.message != "")
{
- centerprint (toucher, this.message);
- sound (toucher, CHAN_VOICE, "misc/talk.wav",
+ centerprint (other, self.owner.message);
+ sound (other, CHAN_VOICE, "misc/talk.wav",
1, ATTN_NORM);
}

// key door stuff
- if (!keylock_has_key_set(this))
+ if (!keylock_has_key_set(self))
return;

- keylock_try_to_unlock (toucher, "", door_unlock);
+ keylock_try_to_unlock (other, "", func_door_unlock);
};

//--------------------------------------------------------------
@@ -403,118 +441,101 @@ class func_door: base_func
//--------------------------------------------------------------

//--------------------------------------------------------------
- nonvirtual void(func_door d, float closealldoors) estate_lock =
+ void(entity e, float closealldoors) func_door_estate_lock =
{
- if (d.is_primary == FALSE)
- {
- d.prev_door.estate_lock (d.prev_door, closealldoors);
- return;
- }
-
- local func_door next;
-
- if (d.estate == STATE_INACTIVE)
+ if (e.owner.estate == STATE_INACTIVE)
return;

// blocks linked doors from updating the same owner repeatedly
- if (d.last_setstate == this &&
- d.last_setstate_frame == framecount)
+ if (e.owner.last_setstate == self &&
+ e.owner.last_setstate_frame == framecount)
{
return;
}

- d.estate = STATE_INACTIVE;
- d.last_setstate = this;
- d.last_setstate_frame = framecount;
- d.prevstate = d.state;
+ local entity oself, next;
+ oself = self;
+ self = e.owner;

- next = d.next_door;
- do
- {
- next.estate = STATE_INACTIVE;
- next = next.next_door;
- }
- while (next && next != d && next != world);
+ self.estate = STATE_INACTIVE;

- if (d.state == FUNC_STATE_UP || d.state == FUNC_STATE_TOP)
+ self.last_setstate = oself;
+ self.last_setstate_frame = framecount;
+
+ self.prevstate = self.estate;
+
+ if (self.state == FUNC_STATE_UP || self.state == FUNC_STATE_TOP)
{
// don't close wait -1 nor toggleable doors...
- // ...unless the trigger_setstate has a "Close all"
- // spawnflag on
- if (!(d.wait == -1 ||
- (d.spawnflags & DOOR_TOGGLE)) || closealldoors)
+ // ...unless the trigger_setstate has a "Close all
+ // doors" spawnflag on
+ if (!(self.wait == -1 ||
+ (self.spawnflags & DOOR_TOGGLE)) ||
+ closealldoors)
{
- d.door_group_go_down ();
+ func_door_group_go_down ();
}
}

- if (d.max_health)
+ if (self.max_health)
{
- next = d;
+ next = self;
do
{
next.takedamage = DAMAGE_NO;
- next = next.next_door;
+ next = next.enemy;
}
- while (next && next != d && next != world);
+ while ((next != self) && (next != world));
}
+
+ self = oself;
};

//--------------------------------------------------------------
- nonvirtual void(func_door d, float openalldoors) estate_unlock =
+ void(entity e, float openalldoors) func_door_estate_unlock =
{
- if (d.is_primary == FALSE)
- {
- d.prev_door.estate_unlock (d.prev_door, openalldoors);
- return;
- }
-
- local func_door next;
-
- if (d.estate == STATE_ACTIVE)
+ if (e.owner.estate == STATE_ACTIVE)
return;

// blocks linked doors from updating the same owner repeatedly
- if (d.last_setstate == this &&
- d.last_setstate_frame == framecount)
+ if (e.owner.last_setstate == self &&
+ e.owner.last_setstate_frame == framecount)
{
return;
}

- d.last_setstate = this;
- d.last_setstate_frame = framecount;
+ local entity oself, next;
+ oself = self;
+ self = e.owner;
+
+ self.last_setstate = oself;
+ self.last_setstate_frame = framecount;

- if (d.prevstate == FUNC_STATE_UP ||
- d.prevstate == FUNC_STATE_TOP)
+ if (self.prevstate == FUNC_STATE_UP ||
+ self.prevstate == FUNC_STATE_TOP)
{
- if ((d.wait == -1 || (d.spawnflags & DOOR_TOGGLE)) &&
+ if ((self.wait == -1 ||
+ (self.spawnflags & DOOR_TOGGLE)) &&
openalldoors)
{
- d.door_group_go_up ();
+ func_door_group_go_up ();
}
}

- if (d.max_health)
+ if (self.max_health)
{
- next = d;
+ next = self;
do
{
next.health = next.max_health;
next.takedamage = DAMAGE_YES;
- next = next.next_door;
+ next = next.enemy;
}
- while (next && next != d && next != world);
+ while ((next != self) && (next != world));
}

- d.estate = STATE_ACTIVE;
-
- next = d.next_door;
- do
- {
- next.estate = STATE_ACTIVE;
- next = next.next_door;
- }
- while (next && next != d && next != world);
+ self.estate = STATE_ACTIVE;
+ self = oself;
};

//--------------------------------------------------------------
@@ -522,269 +543,251 @@ class func_door: base_func
//--------------------------------------------------------------

//--------------------------------------------------------------
- static temp_door_trigger(func_door d, vector fmins, vector fmaxs)
- spawn_field =
- {
- local temp_door_trigger trigger;
-
- trigger = spawn (temp_door_trigger, primary_door: d);
- setsize (trigger, fmins - '60 60 8', fmaxs + '60 60 8');
- return trigger;
- };
-
- //--------------------------------------------------------------
// LinkDoors
//--------------------------------------------------------------
- nonvirtual void() link_doors =
+ void() func_door_think_link =
{
// current, next, previous
- local func_door cur, n, p;
+ local entity t, starte;
local vector cmins, cmaxs;

- if (this.is_primary == -1)
- {
- this.is_primary = TRUE;
- this.need_link = FALSE;
- }
- else
- {
- // we've already been initialized by a previous
- // link_doors pass
- this.need_link = FALSE;
+ if (self.enemy)
+ // already linked by another door
return;
- }

- if (this.spawnflags & DOOR_DONT_LINK)
+ if (self.spawnflags & DOOR_DONT_LINK)
{
// don't want to link this door
- next_door = prev_door = this;
+ self.owner = self.enemy = self;
return;
}

- cmins = this.mins;
- cmaxs = this.maxs;
- cur = n = p = this;
+ cmins = self.mins;
+ cmaxs = self.maxs;
+
+ starte = t = self;

while (1)
{
- // overwrite primary door parameters
- if (cur && cur != this && cur != world)
- {
- if (cur.health)
- this.health = cur.health;
+ // master door
+ self.owner = starte;

- if (cur.targetname && cur.targetname != "")
- this.targetname = cur.targetname;
+ if (self.health)
+ starte.health = self.health;
+ if (self.targetname != "")
+ starte.targetname = self.targetname;
+ if (self.message != "")
+ starte.message = self.message;
+
+ t = findfloat (t, classtype, CT_FUNC_DOOR);

- if (cur.message && cur.message != "")
- this.message = cur.message;
- }
+ if (!t)
+ {
+ // make the chain a loop
+ self.enemy = starte;

- // cast to func_door -- CEV
- n = (func_door)findfloat (n, ::classtype, CT_FUNC_DOOR);
+ // shootable, fired, or key doors just needed
+ // the owner/enemy links, they don't spawn a
+ // field
+ self = self.owner;

- if (n == __NULL__ || n == this || n == world)
- {
- // terminate the chain
- cur.prev_door = p;
- cur.next_door = __NULL__;
-
- // shootable, fired, or key doors just
- // needed the prev/next links, they
- // don't spawn a field
- if (this.health)
- break;
- if (this.targetname && this.targetname != "")
- break;
- if (keylock_has_key_set(this))
- break;
+ if (self.health)
+ return;
+ if (self.targetname != "")
+ return;
+ if (keylock_has_key_set(self))
+ return;

// create area trigger
- area_trig = spawn_field (this, cmins, cmaxs);
- break;
+ self.owner.trigger_field =
+ spawn_temp_door_trigger (self,
+ cmins - '60 60 8',
+ cmaxs + '60 60 8');
+ return;
}

- if (entities_touching(cur, n))
+ if (func_door_entities_touching(self, t))
{
- if (n.next_door)
- objerror ("func_door::link_doors: "
- "cross connected doors\n");
-
- n.is_primary = FALSE;
- cur.need_link = FALSE;
- cur.prev_door = p;
- cur.next_door = n;
-
- p = cur;
- cur = n;
-
- if (n.mins_x < cmins_x)
- cmins_x = n.mins_x;
- if (n.mins_y < cmins_y)
- cmins_y = n.mins_y;
- if (n.mins_z < cmins_z)
- cmins_z = n.mins_z;
- if (n.maxs_x > cmaxs_x)
- cmaxs_x = n.maxs_x;
- if (n.maxs_y > cmaxs_y)
- cmaxs_y = n.maxs_y;
- if (n.maxs_z > cmaxs_z)
- cmaxs_z = n.maxs_z;
+ if (t.enemy)
+ objerror ("func_door_link: "
+ "cross-connected doors!\n");
+
+ 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;
}
}
};

//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) func_door_init =
{
local string default_noise1;
local string default_noise2;

- // start by declaring is_primary to be uninitialized;
- // it'll be set later for real during link_doors -- CEV
- this.is_primary = -1;
-
- // instead of setting touch to sub_null -- CEV
- this.interaction_flags &= ~DISABLE_TOUCH;
+ e.classname = "func_door";
+ e.classtype = CT_FUNC_DOOR;
+ base_func_init (e);

// this.noise3 and this.noise4 can now be overridden by
// the mapper, but will be set to default values in
// keylock_init if necessary -- iw
- keylock_init ();
+ keylock_init (e);

- // this.noise1 and this.noise2 can now be overridden by
+ // e.noise1 and e.noise2 can now be overridden by
// the mapper -- iw
default_noise1 = "misc/null.wav";
default_noise2 = "misc/null.wav";

- if (this.sounds == 1)
+ if (e.sounds == 1)
{
default_noise1 = "doors/drclos4.wav";
default_noise2 = "doors/doormv1.wav";
}
- else if (this.sounds == 2)
+ else if (e.sounds == 2)
{
default_noise1 = "doors/hydro2.wav";
default_noise2 = "doors/hydro1.wav";
}
- else if (this.sounds == 3)
+ else if (e.sounds == 3)
{
default_noise1 = "doors/stndr2.wav";
default_noise2 = "doors/stndr1.wav";
}
- else if (this.sounds == 4)
+ else if (e.sounds == 4)
{
default_noise1 = "doors/ddoor2.wav";
default_noise2 = "doors/ddoor1.wav";
}

- if (this.noise1 == __NULL__ || this.noise1 == "")
- this.noise1 = default_noise1;
- if (this.noise1 == __NULL__ || this.noise2 == "")
- this.noise2 = default_noise2;
+ if (e.noise1 == __NULL__ || e.noise1 == "")
+ e.noise1 = default_noise1;
+ if (e.noise1 == __NULL__ || e.noise2 == "")
+ e.noise2 = default_noise2;
+
+ precache_sound (e.noise1);
+ precache_sound (e.noise2);

- precache_sound (this.noise1);
- precache_sound (this.noise2);
+ sub_setmovedir (e);

- sub_setmovedir ();
+ e.max_health = e.health;
+ e.solid = SOLID_BSP;
+ e.movetype = MOVETYPE_PUSH;
+ setorigin (e, e.origin);
+ setmodel (e, e.model);

- this.max_health = this.health;
- this.solid = SOLID_BSP;
- this.movetype = MOVETYPE_PUSH;
- setorigin (this, this.origin);
- setmodel (this, this.model);
+ e.blocked = func_door_blocked;
+ e.use = func_door_use;

- if (this.spawnflags & DOOR_SILVER_KEY)
+ if (e.spawnflags & DOOR_SILVER_KEY)
{
- keylock_set_silver_key ();
+ keylock_set_silver_key (e);

- if (this.keyname != "")
+ if (e.keyname != "")
{
- this.netname = this.keyname;
- this.keyname = "";
+ e.netname = e.keyname;
+ e.keyname = "";
}
}

- if (this.spawnflags & DOOR_GOLD_KEY)
+ if (e.spawnflags & DOOR_GOLD_KEY)
{
- keylock_set_gold_key ();
+ keylock_set_gold_key (e);

- if (this.keyname != "")
+ if (e.keyname != "")
{
- this.netname = this.keyname;
- this.keyname = "";
+ e.netname = e.keyname;
+ e.keyname = "";
}
}

// support for item_key_custom -- iw
- if (this.keyname != "")
+ if (e.keyname != "")
{
- keylock_set_custom_key (this.keyname);
- // this should not be referenced again
- this.keyname = "";
+ keylock_set_custom_key (e, e.keyname);
+ // e should not be referenced again
+ e.keyname = "";
}

- if (!this.speed)
- this.speed = 100;
- if (!this.wait)
- this.wait = 3;
- if (!this.lip)
- this.lip = 8;
- if (!this.dmg)
- this.dmg = 2;
+ if (!e.speed)
+ e.speed = 100;
+ if (!e.wait)
+ e.wait = 3;
+ if (!e.lip)
+ e.lip = 8;
+ if (!e.dmg)
+ e.dmg = 2;

- this.pos1 = this.origin;
- this.pos2 = this.pos1 + this.movedir *
- (fabs(this.movedir * this.size) - this.lip);
+ e.pos1 = e.origin;
+ e.pos2 = e.pos1 + e.movedir *
+ (fabs(e.movedir * e.size) - e.lip);

// DOOR_START_OPEN is to allow an entity to be lighted in
// the closed position but spawn in the open position
- if (this.spawnflags & DOOR_START_OPEN)
+ if (e.spawnflags & DOOR_START_OPEN)
{
- setorigin (this, this.pos2);
- this.pos2 = this.pos1;
- this.pos1 = this.origin;
+ setorigin (e, e.pos2);
+ e.pos2 = e.pos1;
+ e.pos1 = e.origin;
}

- this.state = FUNC_STATE_BOTTOM;
+ e.state = FUNC_STATE_BOTTOM;

- if (this.health)
+ if (e.health)
{
- this.takedamage = DAMAGE_YES;
- this.th_die = this.do_destroy;
+ e.takedamage = DAMAGE_YES;
+ e.destroy = func_door_destroy;
}

- if (this.spawnflags & DOOR_DOOM_STYLE_UNLOCK)
- this.cnt = 1;
+ if (e.spawnflags & DOOR_DOOM_STYLE_UNLOCK)
+ e.cnt = 1;

- if (keylock_has_key_set(this))
+ if (keylock_has_key_set(e))
{
- if (!(this.spawnflags & DOOR_DOOM_STYLE_UNLOCK))
+ if (!(e.spawnflags & DOOR_DOOM_STYLE_UNLOCK))
{
- this.wait = -1;
+ e.wait = -1;
}
}

+ e.touch = func_door_touch;
+
// LinkDoors can't be done until all of the doors have
// been spawned, so the sizes can be detected properly.
- this.need_link = TRUE;
- this.nextthink = this.ltime + 0.1;
+ e.think = func_door_think_link;
+ e.nextthink = e.ltime + 0.1;

// creates a shadow controller entity for the door if it
// has switchable shadows
- if (this.switchshadstyle)
+ if (e.switchshadstyle)
{
// forgive me for using the ternary operator -- CEV
- this.shadow = spawn (misc_shadowcontroller,
- switchshadstyle: this.switchshadstyle,
- speed: vlen (pos2 - pos1) / speed,
- spawnflags: spawnflags & DOOR_START_OPEN ? 1:0);
+ e.shadowcontroller = spawn_misc_shadowcontroller (
+ e, e.switchshadstyle,
+ vlen (e.pos2 - e.pos1) / e.speed,
+ e.spawnflags & DOOR_START_OPEN ? 1 : 0);
}
};

//--------------------------------------------------------------
void() func_door =
{
- this.classtype = CT_FUNC_DOOR;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ func_door_init (self);
};
-};
+// };

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

Diff qc/func/door_secret.qc

diff --git a/qc/func/door_secret.qc b/qc/func/door_secret.qc
index 7d7ba3b..11419fb 100644
--- a/qc/func/door_secret.qc
+++ b/qc/func/door_secret.qc
@@ -2,13 +2,32 @@
// func_door_secret -- SECRET DOORS
//==============================================================================

+//======================================================================
// constants
+//======================================================================
+
const float SECRET_OPEN_ONCE = 1; // stays open
const float SECRET_1ST_LEFT = 2; // 1st move is left of arrow
const float SECRET_1ST_DOWN = 4; // 1st move is down from arrow
const float SECRET_NO_SHOOT = 8; // only opened by trigger
const float SECRET_YES_SHOOT = 16; // shootable even if targeted

+//======================================================================
+// forward declarations
+//======================================================================
+
+// func_door_secret
+void() func_door_secret_blocked;
+void(entity attacker, float damage) func_door_secret_pain;
+void() func_door_secret_destroy;
+void() func_door_secret_think;
+void() func_door_secret_touch;
+void() func_door_secret_use;
+void(entity e) func_door_secret_init;
+void() func_door_secret;
+
+//------------------------------------------------------------------------------
+
/*QUAKED func_door_secret (0 .5 .8) ? open_once 1st_left 1st_down no_shoot always_shoot X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY

Basic secret door. Slides back, then to the side. Angle determines direction.
@@ -26,243 +45,260 @@ If a secret door has a targetname, it will only be opened by it's botton or trig
2) metal
3) base
*/
-class func_door_secret: base_func
-{
- float door_state;
- vector dest1;
- vector dest2;
-
+//----------------------------------------------------------------------
+// class func_door_secret: base_func
+// {
//--------------------------------------------------------------
- virtual void(entity blocker) do_blocked =
+ void() func_door_secret_blocked =
{
- if (time < this.attack_finished)
+ if (time < self.attack_finished)
return;

- this.attack_finished = time + 0.5;
- this.t_damage2 (blocker, this, this, this.dmg);
+ self.attack_finished = time + 0.5;
+ t_damage2 (other, self, self, self.dmg);
};

//--------------------------------------------------------------
- virtual void(entity attacker, float damage) do_damage =
+ void(entity attacker, float damage) func_door_secret_pain =
{
- if (this.takedamage == DAMAGE_YES)
- this.do_use (other);
+ if (self.takedamage == DAMAGE_YES)
+ func_door_secret_use ();
};

//--------------------------------------------------------------
- virtual void() do_destroy =
+ void() func_door_secret_destroy =
{
- if (this.takedamage == DAMAGE_YES)
- this.do_use (other);
+ if (self.takedamage == DAMAGE_YES)
+ func_door_secret_use ();
};

//--------------------------------------------------------------
- virtual void() do_think =
+ void() func_door_secret_think =
{
- switch (this.door_state)
+ switch (self.state)
{
case 1:
// fd_secret_move1: Wait after first movement
- this.nextthink = this.ltime + 1.0;
- sound (this, CHAN_VOICE, this.noise3,
+ self.nextthink = self.ltime + 1.0;
+ sound (self, CHAN_VOICE, self.noise3,
1, ATTN_NORM);
break;
case 2:
// fd_secret_move2: move sideways w/sound
- sound (this, CHAN_VOICE, this.noise2,
+ sound (self, CHAN_VOICE, self.noise2,
1, ATTN_NORM);
- calc_move (this.dest2, this.speed, this.think);
+ sub_calcmove (self, self.pos2, self.speed,
+ func_door_secret_think);
break;
case 3:
// fd_secret_move3: wait until time to go back
- sound (this, CHAN_VOICE, this.noise3,
+ sound (self, CHAN_VOICE, self.noise3,
1, ATTN_NORM);
- if (!(this.spawnflags & SECRET_OPEN_ONCE))
- this.nextthink = this.ltime + this.wait;
+ if (!(self.spawnflags & SECRET_OPEN_ONCE))
+ self.nextthink = self.ltime + self.wait;
break;
case 4:
// fd_secret_move4: move backward...
- sound (this, CHAN_VOICE, this.noise2,
+ sound (self, CHAN_VOICE, self.noise2,
1, ATTN_NORM);
- calc_move (this.dest1, this.speed, this.think);
+ sub_calcmove (self, self.pos1, self.speed,
+ func_door_secret_think);
break;
case 5:
// fd_secret_move5: wait 1 second...
- this.nextthink = this.ltime + 1.0;
- sound (this, CHAN_VOICE, this.noise3,
+ self.nextthink = self.ltime + 1.0;
+ sound (self, CHAN_VOICE, self.noise3,
1, ATTN_NORM);
break;
case 6:
// fd_secret_move6
- sound (this, CHAN_VOICE, this.noise2,
+ sound (self, CHAN_VOICE, self.noise2,
1, ATTN_NORM);
- calc_move (this.oldorigin, this.speed,
- this.think);
+ sub_calcmove (self, self.oldorigin, self.speed,
+ func_door_secret_think);
break;
case 7:
// fd_secret_done
- if (!this.targetname ||
- this.spawnflags & SECRET_YES_SHOOT)
+ if (!self.targetname ||
+ self.spawnflags & SECRET_YES_SHOOT)
{
- this.health = 10000;
- this.takedamage = DAMAGE_YES;
+ self.health = 10000;
+ self.takedamage = DAMAGE_YES;
+ self.pain = sub_nullpain;
}

- sound (this, CHAN_VOICE, this.noise3,
+ sound (self, CHAN_VOICE, self.noise3,
1, ATTN_NORM);
break;
default:
- dprint (sprintf("func_door_secret::do_think: "
- "unhandled door_state %f!\n",
- this.door_state));
+ dprint (sprintf("func_door_secret_think: "
+ "unhandled state %f!\n",
+ self.state));
}

- if (this.door_state < 4 ||
- !(this.spawnflags & SECRET_OPEN_ONCE))
+ if (self.state < 4 ||
+ !(self.spawnflags & SECRET_OPEN_ONCE))
{
- this.door_state++;
+ self.state++;
}
};

//--------------------------------------------------------------
// secret_touch - ouch; Prints messages
//--------------------------------------------------------------
- virtual void(entity toucher) do_touch =
+ void() func_door_secret_touch =
{
// from Copper -- dumptruck_ds
- if (sub_checkvalidtouch(toucher) == FALSE)
+ if (sub_checkvalidtouch(other) == FALSE)
return;

- if (this.attack_finished > time)
+ if (self.attack_finished > time)
return;

- this.attack_finished = time + 2;
+ self.attack_finished = time + 2;

- if (this.message != "")
+ if (self.message != "")
{
- centerprint (toucher, this.message);
- sound (toucher, CHAN_BODY, "misc/talk.wav",
+ centerprint (other, self.message);
+ sound (other, CHAN_BODY, "misc/talk.wav",
1, ATTN_NORM);
}
};

//--------------------------------------------------------------
- virtual void(entity caller) do_use =
+ void() func_door_secret_use =
{
local float temp;

- this.health = 10000;
+ self.health = 10000;

// exit if still moving around...
- if (this.origin != this.oldorigin)
+ if (self.origin != self.oldorigin)
return;

// no more message
- this.message = string_null;
+ self.message = __NULL__;

// fire all targets / killtargets
sub_usetargets ();

- if (!(this.spawnflags & SECRET_NO_SHOOT))
- this.takedamage = DAMAGE_NO;
+ if (!(self.spawnflags & SECRET_NO_SHOOT))
+ {
+ self.pain = sub_nullpain;
+ self.takedamage = DAMAGE_NO;
+ }

- this.velocity = '0 0 0';
+ self.velocity = '0 0 0';

// Make a sound, wait a little...
- sound (this, CHAN_VOICE, this.noise1, 1, ATTN_NORM);
- this.nextthink = this.ltime + 0.1;
+ sound (self, CHAN_VOICE, self.noise1, 1, ATTN_NORM);
+ self.nextthink = self.ltime + 0.1;

// 1 or -1
- temp = 1 - (this.spawnflags & SECRET_1ST_LEFT);
- makevectors (this.mangle);
+ temp = 1 - (self.spawnflags & SECRET_1ST_LEFT);
+ makevectors (self.mangle);

- if (!this.t_width)
+ if (!self.t_width)
{
- if (this.spawnflags & SECRET_1ST_DOWN)
- this.t_width = fabs (v_up * this.size);
+ if (self.spawnflags & SECRET_1ST_DOWN)
+ self.t_width = fabs (v_up * self.size);
else
- this.t_width = fabs (v_right * this.size);
+ self.t_width = fabs (v_right * self.size);
}

- if (!this.t_length)
- this.t_length = fabs (v_forward * this.size);
+ if (!self.t_length)
+ self.t_length = fabs (v_forward * self.size);

- if (this.spawnflags & SECRET_1ST_DOWN)
- this.dest1 = this.origin - v_up * this.t_width;
+ if (self.spawnflags & SECRET_1ST_DOWN)
+ self.pos1 = self.origin - v_up * self.t_width;
else
- this.dest1 = this.origin + v_right *
- (this.t_width * temp);
-
- this.dest2 = this.dest1 + v_forward * this.t_length;
- this.door_state = 1;
- calc_move (this.dest1, this.speed, this.think);
- sound (this, CHAN_VOICE, this.noise2, 1, ATTN_NORM);
+ self.pos1 = self.origin + v_right *
+ (self.t_width * temp);
+
+ self.pos2 = self.pos1 + v_forward * self.t_length;
+ self.state = 1;
+ sub_calcmove (self, self.pos1, self.speed,
+ func_door_secret_think);
+ sound (self, CHAN_VOICE, self.noise2, 1, ATTN_NORM);
};

//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) func_door_secret_init =
{
- if (this.sounds == 0)
- this.sounds = 3;
+ e.classname = "func_door_secret";
+ e.classtype = CT_FUNC_DOOR_SECRET;
+ base_func_init (e);
+
+ if (e.sounds == 0)
+ e.sounds = 3;

- if (this.sounds == 1)
+ if (e.sounds == 1)
{
precache_sound ("doors/latch2.wav");
precache_sound ("doors/winch2.wav");
precache_sound ("doors/drclos4.wav");
- this.noise1 = "doors/latch2.wav";
- this.noise2 = "doors/winch2.wav";
- this.noise3 = "doors/drclos4.wav";
+ e.noise1 = "doors/latch2.wav";
+ e.noise2 = "doors/winch2.wav";
+ e.noise3 = "doors/drclos4.wav";
}

- if (this.sounds == 2)
+ if (e.sounds == 2)
{
precache_sound ("doors/airdoor1.wav");
precache_sound ("doors/airdoor2.wav");
- this.noise2 = "doors/airdoor1.wav";
- this.noise1 = "doors/airdoor2.wav";
- this.noise3 = "doors/airdoor2.wav";
+ e.noise2 = "doors/airdoor1.wav";
+ e.noise1 = "doors/airdoor2.wav";
+ e.noise3 = "doors/airdoor2.wav";
}

- if (this.sounds == 3)
+ if (e.sounds == 3)
{
precache_sound ("doors/basesec1.wav");
precache_sound ("doors/basesec2.wav");
- this.noise2 = "doors/basesec1.wav";
- this.noise1 = "doors/basesec2.wav";
- this.noise3 = "doors/basesec2.wav";
+ e.noise2 = "doors/basesec1.wav";
+ e.noise1 = "doors/basesec2.wav";
+ e.noise3 = "doors/basesec2.wav";
}

- if (!this.dmg)
- this.dmg = 2;
+ if (!e.dmg)
+ e.dmg = 2;

// Magic formula...
- this.speed = 50;
- this.mangle = this.angles;
- this.angles = '0 0 0';
- this.solid = SOLID_BSP;
- this.movetype = MOVETYPE_PUSH;
- setmodel (this, this.model);
- setorigin (this, this.origin);
-
- if (!this.targetname || this.spawnflags & SECRET_YES_SHOOT)
+ e.speed = 50;
+ e.mangle = e.angles;
+ e.angles = '0 0 0';
+ e.solid = SOLID_BSP;
+ e.movetype = MOVETYPE_PUSH;
+ setmodel (e, e.model);
+ setorigin (e, e.origin);
+
+ e.blocked = func_door_secret_blocked;
+ e.think = func_door_secret_think;
+ e.touch = func_door_secret_touch;
+ e.use = func_door_secret_use;
+
+ if (!e.targetname || e.spawnflags & SECRET_YES_SHOOT)
{
- this.health = 10000;
- this.takedamage = DAMAGE_YES;
- this.th_die = this.do_destroy;
+ e.health = 10000;
+ e.takedamage = DAMAGE_YES;
+ e.pain = func_door_secret_pain;
+ e.destroy = func_door_secret_destroy;
}

- this.oldorigin = this.origin;
+ e.oldorigin = e.origin;

- if (!this.wait)
+ if (!e.wait)
// 5 seconds before closing
- this.wait = 5;
+ e.wait = 5;
};

//--------------------------------------------------------------
void() func_door_secret =
{
- // this.classname = "door";
- this.classtype = CT_FUNC_DOOR_SECRET;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ func_door_secret_init (self);
};
-};
+// };

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

Diff qc/func/elvtr_button.qc

diff --git a/qc/func/elvtr_button.qc b/qc/func/elvtr_button.qc
index ad9198a..3f1feab 100644
--- a/qc/func/elvtr_button.qc
+++ b/qc/func/elvtr_button.qc
@@ -6,11 +6,35 @@
// pmack
// sept 96

+//======================================================================
+// constants
+//======================================================================
+
+const float BUTTON_ELVTR_DOWN = 1;
+
+//======================================================================
// globals
+//======================================================================
+
float elv_butn_dir;

-// constants
-const float BUTTON_ELVTR_DOWN = 1;
+//======================================================================
+// forward declarations
+//======================================================================
+
+// func_elvtr_button
+void() func_elvtr_button_wait;
+void() func_elvtr_button_done;
+void() func_elvtr_button_return;
+void() func_elvtr_button_fire;
+void() func_elvtr_button_blocked;
+void() func_elvtr_button_destroy;
+void() func_elvtr_button_touch;
+void() func_elvtr_button_use;
+void(entity e) func_elvtr_button_init;
+void() func_elvtr_button;
+
+//------------------------------------------------------------------------------

/*QUAKED func_elvtr_button (0 .5 .8) ? ELVTR_DOWN X X X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY

@@ -33,169 +57,171 @@ When a button is touched, it moves some distance in the direction of it's angle,
2) metallic click
3) in-out
*/
-class func_elvtr_button: base_func
-{
- float lip;
- /*
- vector pos1;
- vector pos2;
- */
-
- //--------------------------------------------------------------
- virtual void(string fieldname, string fieldvalue) init_field =
- {
- switch (fieldname)
- {
- case "lip":
- lip = stof (fieldvalue);
- break;
- default:
- super::init_field (fieldname, fieldvalue);
- }
- };
-
+//----------------------------------------------------------------------
+// class func_elvtr_button: base_func
+// {
//--------------------------------------------------------------
- nonvirtual void() elvtr_button_wait =
+ void() func_elvtr_button_wait =
{
- elv_butn_dir = 0;
- if (this.spawnflags & BUTTON_ELVTR_DOWN)
+ // elv_butn_dir = 0;
+ if (self.spawnflags & BUTTON_ELVTR_DOWN)
elv_butn_dir = -1;
else
elv_butn_dir = 1;

- this.state = FUNC_STATE_TOP;
- this.nextthink = this.ltime + this.wait;
- activator = this.enemy;
+ self.state = FUNC_STATE_TOP;
+ activator = self.enemy;
sub_usetargets ();
// use alternate textures
- this.frame = 1;
+ self.frame = 1;
+
+ // schedule next action
+ self.think = func_elvtr_button_return;
+ self.nextthink = self.ltime + self.wait;
};

//--------------------------------------------------------------
- nonvirtual void() elvtr_button_done =
+ void() func_elvtr_button_done =
{
- this.state = FUNC_STATE_BOTTOM;
+ self.state = FUNC_STATE_BOTTOM;
};

//--------------------------------------------------------------
- nonvirtual void() elvtr_button_fire =
+ void() func_elvtr_button_return =
{
- if (this.state == FUNC_STATE_UP || this.state == FUNC_STATE_TOP)
- return;
+ self.state = FUNC_STATE_DOWN;
+ sub_calcmove (self, self.pos1, self.speed,
+ func_elvtr_button_done);

- sound (this, CHAN_VOICE, this.noise, 1, ATTN_NORM);
+ // use normal textures
+ self.frame = 0;

- this.state = FUNC_STATE_UP;
- calc_move (this.pos2, this.speed, elvtr_button_wait);
+ if (self.health)
+ // can be shot again
+ self.takedamage = DAMAGE_YES;
};

//--------------------------------------------------------------
- virtual void(entity blocker) do_blocked =
+ void() func_elvtr_button_fire =
{
- // do nothing, just don't ome all the way back out
+ if (self.state == FUNC_STATE_UP || self.state == FUNC_STATE_TOP)
+ return;
+
+ sound (self, CHAN_VOICE, self.noise, 1, ATTN_NORM);
+
+ self.state = FUNC_STATE_UP;
+ sub_calcmove (self, self.pos2, self.speed,
+ func_elvtr_button_wait);
};

//--------------------------------------------------------------
- virtual void() do_destroy =
+ void() func_elvtr_button_blocked =
{
- this.enemy = damage_attacker;
- this.health = this.max_health;
- // wil be reset upon return
- this.takedamage = DAMAGE_NO;
- elvtr_button_fire ();
+ // do nothing, just don't come all the way back out
};

//--------------------------------------------------------------
- // was elvtr_button_return -- CEV
- //--------------------------------------------------------------
- virtual void() do_think =
+ void() func_elvtr_button_destroy =
{
- this.state = FUNC_STATE_DOWN;
- calc_move (this.pos1, this.speed, elvtr_button_done);
- // use normal textures
- this.frame = 0;
- if (this.health)
- // can be shot again
- this.takedamage = DAMAGE_YES;
+ self.enemy = damage_attacker;
+ self.health = self.max_health;
+ // wil be reset upon return
+ self.takedamage = DAMAGE_NO;
+ func_elvtr_button_fire ();
};

//--------------------------------------------------------------
- virtual void(entity toucher) do_touch =
+ void() func_elvtr_button_touch =
{
- if (this.health > 0)
- return;
+ // if (self.health > 0)
+ // return;

- if (toucher.classtype != CT_PLAYER)
+ if (other.classtype != CT_PLAYER)
return;

- this.enemy = toucher;
- elvtr_button_fire ();
+ self.enemy = other;
+ func_elvtr_button_fire ();
};

//--------------------------------------------------------------
- virtual void(entity caller) do_use =
+ void() func_elvtr_button_use =
{
- this.enemy = activator;
- elvtr_button_fire ();
+ self.enemy = activator;
+ func_elvtr_button_fire ();
};

//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) func_elvtr_button_init =
{
- if (this.sounds == 0)
+ e.classname = "func_elvtr_button";
+ e.classtype = CT_FUNC_ELVTR_BUTTON;
+ base_func_init (e);
+
+ if (e.sounds == 0)
{
precache_sound ("buttons/airbut1.wav");
- this.noise = "buttons/airbut1.wav";
+ e.noise = "buttons/airbut1.wav";
}

- if (this.sounds == 1)
+ if (e.sounds == 1)
{
precache_sound ("buttons/switch21.wav");
- this.noise = "buttons/switch21.wav";
+ e.noise = "buttons/switch21.wav";
}

- if (this.sounds == 2)
+ if (e.sounds == 2)
{
precache_sound ("buttons/switch02.wav");
- this.noise = "buttons/switch02.wav";
+ e.noise = "buttons/switch02.wav";
}

- if (this.sounds == 3)
+ if (e.sounds == 3)
{
precache_sound ("buttons/switch04.wav");
- this.noise = "buttons/switch04.wav";
+ e.noise = "buttons/switch04.wav";
}

- sub_setmovedir ();
+ sub_setmovedir (e);

- this.movetype = MOVETYPE_PUSH;
- this.solid = SOLID_BSP;
- setmodel (this, this.model);
+ e.movetype = MOVETYPE_PUSH;
+ e.solid = SOLID_BSP;
+ setmodel (e, e.model);

- if (this.health)
+ e.blocked = func_elvtr_button_blocked;
+ e.use = func_elvtr_button_use;
+
+ if (e.health)
+ {
+ e.max_health = e.health;
+ e.takedamage = DAMAGE_YES;
+ e.destroy = func_elvtr_button_destroy;
+ }
+ else
{
- this.max_health = this.health;
- this.takedamage = DAMAGE_YES;
- this.th_die = this.do_destroy;
+ e.touch = func_elvtr_button_touch;
}

- if (!this.speed)
- this.speed = 40;
- if (!this.wait)
- this.wait = 1;
- if (!this.lip)
- this.lip = 4;
+ if (!e.speed)
+ e.speed = 40;
+ if (!e.wait)
+ e.wait = 1;
+ if (!e.lip)
+ e.lip = 4;

- this.state = FUNC_STATE_BOTTOM;
+ e.state = FUNC_STATE_BOTTOM;

- this.pos1 = this.origin;
- this.pos2 = this.pos1 + this.movedir *
- (fabs(this.movedir * this.size) - this.lip);
+ e.pos1 = e.origin;
+ e.pos2 = e.pos1 + e.movedir *
+ (fabs(e.movedir * e.size) - e.lip);
};

//--------------------------------------------------------------
void() func_elvtr_button =
{
- this.classtype = CT_FUNC_ELVTR_BUTTON;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ func_elvtr_button_init (self);
};
-};
+// };

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

Diff qc/func/episodegate.qc

diff --git a/qc/func/episodegate.qc b/qc/func/episodegate.qc
index a785374..f74f93f 100644
--- a/qc/func/episodegate.qc
+++ b/qc/func/episodegate.qc
@@ -2,42 +2,65 @@
// func_episodegate
//==============================================================================

+//======================================================================
// constants
+//======================================================================
+
// For func_episodegate and func_bossgate appear when player has all runes
const float EPISODEGATE_REVERSE = 16;

+//======================================================================
+// forward declarations
+//======================================================================
+
+// func_episodegate
+void(entity e) func_episodegate_init;
+void() func_episodegate;
+
+//------------------------------------------------------------------------------
+
/*QUAKED func_episodegate (0 .5 .8) ? E1 E2 E3 E4 REVERSE_FUNCTIONALITY
This bmodel will appear if the episode has allready been completed, so players can't reenter it.
*/
-class func_episodegate: base_func_wall
-{
+//----------------------------------------------------------------------
+// class func_episodegate: base_func_wall
+// {
//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) func_episodegate_init =
{
- if (this.spawnflags & EPISODEGATE_REVERSE)
+ e.classname = "func_episodegate";
+ e.classtype = CT_FUNC_EPISODEGATE;
+ base_func_wall_init (e);
+
+ if (e.spawnflags & EPISODEGATE_REVERSE)
{
// this is to avoid a possible issue with sigil_touch2
- this.spawnflags = this.spawnflags - EPISODEGATE_REVERSE;
- if (serverflags & this.spawnflags)
+ e.spawnflags = e.spawnflags - EPISODEGATE_REVERSE;
+ if (serverflags & e.spawnflags)
// Haven't gotten rune yet
return;
}
else
{
- if (!(serverflags & this.spawnflags))
+ if (!(serverflags & e.spawnflags))
// can still enter episode
return;
}
- this.angles = '0 0 0';
+
+ e.angles = '0 0 0';
// so it doesn't get pushed by anything
- this.movetype = MOVETYPE_PUSH;
- this.solid = SOLID_BSP;
- setmodel (this, this.model);
+ e.movetype = MOVETYPE_PUSH;
+ e.solid = SOLID_BSP;
+ setmodel (e, e.model);
};

//--------------------------------------------------------------
void() func_episodegate =
{
- this.classtype = CT_FUNC_EPISODEGATE;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ func_episodegate_init (self);
};
-};
+// };

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

Diff qc/func/explobox.qc

diff --git a/qc/func/explobox.qc b/qc/func/explobox.qc
index e7fa7eb..a2fc3d8 100644
--- a/qc/func/explobox.qc
+++ b/qc/func/explobox.qc
@@ -2,6 +2,19 @@
// func_explobox -- selections from Rubicon 2 qc by john fitzgibbons
//==============================================================================

+//======================================================================
+// forward declarations
+//======================================================================
+
+// func_explobox
+void() func_explobox_explode_silent;
+void() func_explobox_destroy;
+// void() func_explobox_think =
+void(entity e) func_explobox_init;
+void() func_explobox;
+
+//------------------------------------------------------------------------------
+
/*QUAKED func_explobox (0 .5 .8) ? START_OFF X X X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY

An exploding brush entity. Works just like misc_explobox.
@@ -13,57 +26,67 @@ Keys:
"dmg" default 100

*/
-class func_explobox: base_func
-{
+//----------------------------------------------------------------------
+// class func_explobox: base_func
+// {
//--------------------------------------------------------------
- nonvirtual void() explode_silent =
+ void() func_explobox_explode_silent =
{
- this.takedamage = DAMAGE_NO;
- this.origin = ((this.absmin + this.absmax) * 0.5);
- this.classname = "explo_box";
- this.t_radiusdamage2 (this, this, this.dmg, world);
- base_explosion::write_explosion (this.origin);
+ self.takedamage = DAMAGE_NO;
+ self.origin = ((self.absmin + self.absmax) * 0.5);
+ t_radiusdamage2 (self, self, self.dmg, world);
+ write_explosion (self.origin);
// BecomeExplosion
- spawn (base_explosion, origin: this.origin);
- remove (this);
+ spawn_base_explosion (self.origin);
+ remove (self);
};

//--------------------------------------------------------------
- virtual void() do_destroy =
+ void() func_explobox_destroy =
{
// for some reason, time + 0.2 doesn't work
- this.nextthink = 0.2;
+ self.think = func_explobox_explode_silent;
+ self.nextthink = 0.2;
};

//--------------------------------------------------------------
- virtual void() do_think =
+ /*
+ void() func_explobox_think =
{
// sound (this, CHAN_VOICE, "weapons/r_exp3.wav", 1, ATTN_NORM);
- this.explode_silent ();
+ func_explobox_explode_silent ();
};
+ */

//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) func_explobox_init =
{
- this.solid = SOLID_BSP;
- this.movetype = MOVETYPE_PUSH;
- setmodel (this, this.model);
+ e.classname = "func_explobox";
+ e.classtype = CT_FUNC_EXPLOBOX;
+ base_func_init (e);
+
+ e.solid = SOLID_BSP;
+ e.movetype = MOVETYPE_PUSH;
+ setmodel (e, e.model);
precache_sound ("weapons/r_exp3.wav");

- if (!this.health)
- this.health = 20;
+ if (!e.health)
+ e.health = 20;

- if (!this.dmg)
- this.dmg = 100;
+ if (!e.dmg)
+ e.dmg = 100;

- // TODO CEV
- this.th_die = this.do_destroy;
- this.takedamage = DAMAGE_AIM;
+ e.destroy = func_explobox_destroy;
+ e.takedamage = DAMAGE_AIM;
};

//--------------------------------------------------------------
void() func_explobox =
{
- this.classtype = CT_FUNC_EXPLOBOX;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ func_explobox_init (self);
};
-};
+// };

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

Diff qc/func/fall.qc

diff --git a/qc/func/fall.qc b/qc/func/fall.qc
index 9154c55..0f4db43 100644
--- a/qc/func/fall.qc
+++ b/qc/func/fall.qc
@@ -8,10 +8,26 @@
// wait = wait this long before falling
//==============================================================================

+//======================================================================
// constants
+//======================================================================
+
const float FUNCFADE_DONT_FADE = 1;
const float FUNCFADE_SILENT = 2;

+//======================================================================
+// forward declarations
+//======================================================================
+
+// func_fall
+void() func_fall_think;
+void() func_fall_touch;
+void() func_fall_use;
+void(entity e) func_fall_init;
+void() func_fall;
+
+//------------------------------------------------------------------------------
+
/*QUAKED func_fall (0 .5 .8) ? DONT_FADE X X X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
A brush that drops and fades away when touched and/or triggered.
Add some spice to your jumping puzzles or other scripted sequences!
@@ -23,99 +39,110 @@ Use the DONT_FADE spawnflag if desired.

Falling brush upon touch
*/
-class func_fall: base_func
-{
+//----------------------------------------------------------------------
+// class func_fall: base_func
+// {
//--------------------------------------------------------------
- virtual void() do_think =
+ void() func_fall_think =
{
- if (this.cnt == TRUE && this.attack_finished < time)
+ if (self.cnt == TRUE && self.attack_finished < time)
{
- this.solid = SOLID_BBOX;
- // this.solid = SOLID_NOT;
- this.movetype = MOVETYPE_TOSS;
+ self.solid = SOLID_BBOX;
+ self.movetype = MOVETYPE_TOSS;

- if (!(this.spawnflags & FUNCFADE_DONT_FADE))
+ if (!(self.spawnflags & FUNCFADE_DONT_FADE))
{
- if (this.alpha > 0.1)
+ if (self.alpha > 0.1)
{
- this.alpha = this.alpha - 0.03;
+ self.alpha = self.alpha - 0.03;
}
else
{
- remove (this);
+ remove (self);
return;
}
}
}
- this.nextthink = time + 0.1;
+ self.nextthink = time + 0.1;
};

//--------------------------------------------------------------
- virtual void(entity toucher) do_touch =
+ void() func_fall_touch =
{
- if (toucher.classtype == CT_PLAYER)
+ if (other.classtype == CT_PLAYER)
{
- if (!(toucher.flags & FL_ONGROUND))
- toucher.flags = toucher.flags | FL_ONGROUND;
+ if (!(other.flags & FL_ONGROUND))
+ other.flags = other.flags | FL_ONGROUND;
}
- else if (toucher.flags & FL_MONSTER)
+ else if (other.flags & FL_MONSTER)
{
- t_damage2 (toucher, this, toucher, 50000);
+ t_damage2 (other, self, other, 50000);
}
else
{
return;
}

- if (this.cnt == TRUE)
+ if (self.cnt == TRUE)
return;

- this.attack_finished = time + this.wait;
- this.cnt = TRUE;
+ self.attack_finished = time + self.wait;
+ self.cnt = TRUE;

- if (!(this.spawnflags & FUNCFADE_SILENT))
+ if (!(self.spawnflags & FUNCFADE_SILENT))
{
- if (this.noise != "")
- sound (this, CHAN_AUTO, this.noise,
+ if (self.noise != "")
+ sound (self, CHAN_AUTO, self.noise,
1, ATTN_NORM);
else
- sound (this, CHAN_AUTO, "buttons/switch21.wav",
+ sound (self, CHAN_AUTO, "buttons/switch21.wav",
1, ATTN_NORM);
}
};

//--------------------------------------------------------------
- virtual void(entity caller) do_use =
+ void() func_fall_use =
{
// thanks again RennyC for help on revisions --dumptruck_ds
- this.attack_finished = time + this.wait;
- this.cnt = TRUE;
+ self.attack_finished = time + self.wait;
+ self.cnt = TRUE;

- if (this.noise != "")
- sound (this, CHAN_AUTO, this.noise, 1, ATTN_NORM);
+ if (self.noise != "")
+ sound (self, CHAN_AUTO, self.noise, 1, ATTN_NORM);
else
- sound (this, CHAN_AUTO, "buttons/switch21.wav",
+ sound (self, CHAN_AUTO, "buttons/switch21.wav",
1, ATTN_NORM);
};

//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) func_fall_init =
{
+ e.classname = "func_fall";
+ e.classtype = CT_FUNC_FALL;
+ base_func_init (e);
+
precache_sound ("buttons/switch21.wav");
- if (this.noise != "")
- precache_sound (this.noise);
-
- this.alpha = 1;
- this.cnt = FALSE;
- this.solid = SOLID_BSP;
- this.movetype = MOVETYPE_PUSH;
- this.nextthink = time;
- setmodel (this, this.model);
+ if (e.noise != "")
+ precache_sound (e.noise);
+
+ e.alpha = 1;
+ e.cnt = FALSE;
+ e.solid = SOLID_BSP;
+ e.movetype = MOVETYPE_PUSH;
+ e.use = func_fall_use;
+ e.touch = func_fall_touch;
+ e.think = func_fall_think;
+ e.nextthink = time;
+ setmodel (e, e.model);
};

//--------------------------------------------------------------
void() func_fall =
{
- this.classtype = CT_FUNC_FALL;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ func_fall_init (self);
};
-};
+// };

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

Diff qc/func/fall2.qc

diff --git a/qc/func/fall2.qc b/qc/func/fall2.qc
index 4a35ec7..85eac25 100644
--- a/qc/func/fall2.qc
+++ b/qc/func/fall2.qc
@@ -2,42 +2,88 @@
// func_fall2 -- code attributed to RennyC & whirledtsar
//==============================================================================

+//======================================================================
// constants
+//======================================================================
+
const float FALL2_PLAYER_TRIGGERED = 1;
const float FALL2_MONSTER_TRIGGERED = 2;
const float FALL2_BREAKABLE = 8; // VR
// const float FALL2_SOLID = 16; // VR

+//======================================================================
+// forward declarations
+//======================================================================
+
+// temp_fall2_field
+void() temp_fall2_field_touch;
+entity(entity own, vector nmins, vector nmaxs) spawn_temp_fall2_field;
+void(entity e) temp_fall2_field_init;
+strip void() temp_fall2_field;
+
+// func_fall2
+void() func_fall2_think;
+void() func_fall2_touch;
+void() func_fall2_use;
+void(entity e) func_fall2_breakable_fields;
+void(entity e) func_fall2_init;
+void() func_fall2;
+
//------------------------------------------------------------------------------
-class temp_fall2_helper: base_tempentity
-{
+
+//----------------------------------------------------------------------
+// class temp_fall2_field: base_tempentity
+// {
//--------------------------------------------------------------
- virtual void(entity toucher) do_touch =
+ void() temp_fall2_field_touch =
{
- if (toucher.flags & FL_FLY)
+ if (other.flags & FL_FLY)
// flying monsters shouldn't trigger falling platforms
return;

- if (toucher.flags & FL_MONSTER &&
- owner.classtype == CT_FUNC_FALL2)
+ if (other.flags & FL_MONSTER)
{
- dprint ("temp_fall2_helper: inside field_touch\n");
- local func_fall2 ff2;
- ff2 = (func_fall2)owner;
- ff2.thinkuse = TRUE;
- ff2.nextthink = ff2.ltime + 0.1;
- // TODO CEV
- // ff2.nextthink = ff2.owner.ltime + 0.1;
- remove (this);
+ if (!self.owner)
+ {
+ dprint ("temp_fall2_field_touch: no owner!\n");
+ remove (self);
+ return;
+ }
+
+ self.owner.think = func_fall2_use;
+ self.owner.nextthink = self.owner.ltime + 0.1;
+ remove (self);
}
};

- void() temp_fall2_helper =
+ //--------------------------------------------------------------
+ entity(entity own, vector nmins, vector nmaxs) spawn_temp_fall2_field =
+ {
+ local entity e = spawn ();
+ e.owner = own;
+ setsize (e, nmins, nmaxs);
+ setorigin (e, own.origin);
+ setmodel (e, own.model);
+ temp_fall2_field_init (e);
+ return e;
+ };
+
+ //--------------------------------------------------------------
+ void(entity e) temp_fall2_field_init =
+ {
+ e.classname = "temp_fall2_field";
+ e.classtype = CT_TEMP_FALL2_HELPER;
+ base_tempentity_init (e);
+ e.solid = SOLID_TRIGGER;
+ e.touch = temp_fall2_field_touch;
+ };
+
+ //--------------------------------------------------------------
+ strip void() temp_fall2_field =
{
- this.classtype = CT_TEMP_FALL2_HELPER;
- this.solid = SOLID_TRIGGER;
+ temp_fall2_field_init (self);
};
-};
+// };

/*QUAKED func_fall2 (0 .5 .8) ? X X X X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
Falling brush by RennyC with additions from whirledtsar
@@ -61,202 +107,164 @@ Default behavior allows anyone to activate func_fall2 on touch ONLY

Able to .target other entities, including other func_fall2s
*/
-class func_fall2: base_breakable
-{
- // class fields
- float count;
- float lip;
- float thinkuse;
- /*
- vector pos1;
- vector pos2;
- */
-
- // class fields: linker entity
- temp_fall2_helper fall2_helper;
-
+//----------------------------------------------------------------------
+// class func_fall2: base_breakable
+// {
//--------------------------------------------------------------
- virtual void(string fieldname, string fieldvalue) init_field =
+ void() func_fall2_think =
{
- switch (fieldname)
- {
- case "count":
- count = stof (fieldvalue);
- break;
- case "lip":
- lip = stof (fieldvalue);
- break;
- default:
- super::init_field (fieldname, fieldvalue);
- }
- };
-
- //--------------------------------------------------------------
- virtual void() do_think =
- {
- if (this.thinkuse == TRUE)
- {
- this.do_use (other);
- return;
- }
// turn off quake engine splash sound
- this.waterlevel = this.watertype = 0;
+ self.waterlevel = self.watertype = 0;

- if (this.attack_finished < time)
+ if (self.attack_finished < time)
{
- if (this.target != __NULL__ && this.target != "")
+ if (self.target != __NULL__ && self.target != "")
sub_useandforgettargets ();


// removed FALL_SOLID behavior -- dumptruck_ds
- this.solid = SOLID_NOT;
+ self.solid = SOLID_NOT;

- if (this.pos1 != '0 0 0')
+ if (self.pos1 != '0 0 0')
// apply stored avelocity vector values
- this.avelocity = this.pos1;
+ self.avelocity = self.pos1;

- if (this.pos2 && !this.velocity)
+ if (self.pos2 && !self.velocity)
// Add velocity movement
- this.velocity = this.pos2;
+ self.velocity = self.pos2;

- if (this.cnt > 0)
+ if (self.cnt > 0)
{
// cnt over 0
- if (this.cnt >= 2)
+ if (self.cnt >= 2)
{
- this.movetype = MOVETYPE_BOUNCE;
- if (this.velocity_z < this.lip)
- this.velocity_z = this.lip;
+ self.movetype = MOVETYPE_BOUNCE;
+ if (self.velocity_z < self.lip)
+ self.velocity_z = self.lip;
}
else
{
// cnt is 1
- this.movetype = MOVETYPE_NOCLIP;
- if (this.velocity_z > this.lip)
- this.velocity_z -= this.speed *
+ self.movetype = MOVETYPE_NOCLIP;
+ if (self.velocity_z > self.lip)
+ self.velocity_z -= self.speed *
(frametime * 100);
else
- this.velocity_z = this.lip;
+ self.velocity_z = self.lip;
}
}
else
{
// default behavior (cnt is 0)
- this.movetype = MOVETYPE_TOSS;
- if (this.velocity_z < this.lip)
- this.velocity_z = this.lip;
+ self.movetype = MOVETYPE_TOSS;
+ if (self.velocity_z < self.lip)
+ self.velocity_z = self.lip;
}

- if (this.pain_finished != -1)
+ if (self.pain_finished != -1)
{
- if (this.alpha > 0.1)
- // TODO CEV fall2 was fading too fast
- // so I've doubled the time; thinking
- // too often?
- this.alpha -= this.pain_finished * 0.5;
+ if (self.alpha > 0.1)
+ self.alpha -= self.pain_finished;
else
{
- if (this.noise2 != __NULL__ &&
- this.noise2 != "")
+ if (self.noise2 != __NULL__ &&
+ self.noise2 != "")
{
- sound (this, CHAN_AUTO,
- this.noise2,
+ sound (self, CHAN_AUTO,
+ self.noise2,
1, ATTN_NORM);
}
- remove (this);
+ remove (self);
return;
}
}

- if (this.flags & FL_ONGROUND &&
- this.spawnflags & FALL2_BREAKABLE)
+ if (self.flags & FL_ONGROUND &&
+ self.spawnflags & FALL2_BREAKABLE)
{
// VR
// aka BREAKABLE_NO_MONSTERS
- this.spawnflags(-)1;
+ self.spawnflags(-)1;
// aka BREAK_EXPLODE
- this.spawnflags(-)2;
+ self.spawnflags(-)2;
// because of how debris origin is calculated
- this.mins = this.absmin;
- this.maxs = this.absmax;
+ self.mins = self.absmin;
+ self.maxs = self.absmax;
// debris gets velocity from health
- this.health = this.lip * 0.1;
+ self.health = self.lip * 0.1;
// func_breakable uses cnt for quantity of
// debris to spawn
- this.cnt = this.count;
- // removes this
- breakable_die ();
+ self.cnt = self.count;
+ // removes self
+ base_breakable_die ();
return;
}
}

- this.nextthink = this.ltime + 0.1;
+ self.nextthink = self.ltime + 0.1;
};

//--------------------------------------------------------------
- virtual void(entity toucher) do_touch =
+ void() func_fall2_touch =
{
- if (this.targetname != __NULL__ && this.targetname != "")
- return;
-
- if (!toucher.takedamage)
+ if (!other.takedamage)
return;

- if (toucher.classtype != CT_PLAYER)
+ if (other.classtype != CT_PLAYER)
// player activated only
return;

- if (this.spawnflags & FALL2_MONSTER_TRIGGERED)
+ if (self.spawnflags & FALL2_MONSTER_TRIGGERED)
// disable on monster only, also fixes weird issue
return;

- this.thinkuse = FALSE;
- this.nextthink = this.ltime + 0.1;
- this.attack_finished = time + this.wait;
+ self.think = func_fall2_think;
+ self.nextthink = self.ltime + 0.1;
+ self.attack_finished = time + self.wait;

- // if (this.spawnflags & FALL_SOLID)
+ // if (self.spawnflags & FALL_SOLID)
// {
// // VR
- // setsize (this, this.mins, this.maxs);
- // this.solid = SOLID_BBOX;
+ // setsize (self, self.mins, self.maxs);
+ // self.solid = SOLID_BBOX;
// }
// else
// {
- // this.solid = SOLID_NOT;
+ // self.solid = SOLID_NOT;
// }

- if (this.noise != __NULL__ && this.noise != "")
- sound (this, CHAN_AUTO, this.noise, 1, ATTN_NORM);
+ if (self.noise != __NULL__ && self.noise != "")
+ sound (self, CHAN_AUTO, self.noise, 1, ATTN_NORM);

- // disable touch, only do this once!
- this.interaction_flags |= DISABLE_TOUCH;
+ // disable touch, only do self once!
+ self.touch = sub_null;

- if (this.fall2_helper)
- remove (this.fall2_helper);
+ if (self.trigger_field)
+ remove (self.trigger_field);
};

//--------------------------------------------------------------
- virtual void(entity caller) do_use =
+ void() func_fall2_use =
{
- this.thinkuse = FALSE;
- this.nextthink = this.ltime + 0.1;
+ self.think = func_fall2_think;
+ self.nextthink = self.ltime + 0.1;
// disable touch when used
- this.interaction_flags |= DISABLE_TOUCH;
+ self.touch = sub_null;

- // if (this.spawnflags & FALL_SOLID)
+ // if (self.spawnflags & FALL_SOLID)
// {
// // VR
- // setsize (this, this.mins, this.maxs);
- // this.solid = SOLID_BBOX;
+ // setsize (self, self.mins, self.maxs);
+ // self.solid = SOLID_BBOX;
// }
// else
// {
- // this.solid = SOLID_NOT;
+ // self.solid = SOLID_NOT;
// }

- this.attack_finished = time + this.wait;
- if (this.noise != __NULL__ && this.noise != "")
- sound (this, CHAN_AUTO, this.noise, 1, ATTN_NORM);
+ self.attack_finished = time + self.wait;
+ if (self.noise != __NULL__ && self.noise != "")
+ sound (self, CHAN_AUTO, self.noise, 1, ATTN_NORM);
};

// You may have to modify your multi_touch(); command in triggers.qc
@@ -265,147 +273,154 @@ class func_fall2: base_breakable
// occurs. Default behavior is player only.

//--------------------------------------------------------------
- nonvirtual void fall_break_fields ()
+ void(entity e) func_fall2_breakable_fields =
{
- break_template_setup ();
+ base_breakable_template_setup (e);

- this.mdl_debris = "progs/debris.mdl";
- precache_model (this.mdl_debris);
+ e.mdl_debris = "progs/debris.mdl";
+ precache_model (e.mdl_debris);

- if (this.noise1 != "")
- precache_sound (this.noise1);
+ if (e.noise1 != "")
+ precache_sound (e.noise1);

// adding new default sounds for "simple" breakables in 1.2.0
// -- dumptruck_ds

// here's generic metal breaking
- if (this.style == 0 || this.style == 11 ||
- this.style == 12 || this.style == 17 ||
- this.style == 18 || this.style == 19 ||
- this.style == 24 || this.style == 31)
+ if (e.style == 0 || e.style == 11 ||
+ e.style == 12 || e.style == 17 ||
+ e.style == 18 || e.style == 19 ||
+ e.style == 24 || e.style == 31)
{
- if !(this.noise1)
+ if !(e.noise1)
{
precache_sound ("break/metal2.wav");
- this.noise1 = "break/metal2.wav";
+ e.noise1 = "break/metal2.wav";
}
}

- if (this.style == 3 || this.style == 4 || this.style == 5)
+ if (e.style == 3 || e.style == 4 || e.style == 5)
{
- if !(this.noise1)
+ if !(e.noise1)
{
precache_sound ("break/wood1.wav");
precache_sound ("break/wood2.wav");
// wood only randomized
if (random() > 0.6)
- this.noise1 = "break/wood1.wav";
+ e.noise1 = "break/wood1.wav";
else
- this.noise1 = "break/wood2.wav";
+ e.noise1 = "break/wood2.wav";
}
}

- // glass sounds -- this is more of a shattering sound anyway
- if (this.style == 6 || this.style == 7 || this.style == 8 ||
- this.style == 9 || this.style == 10)
+ // glass sounds -- e is more of a shattering sound anyway
+ if (e.style == 6 || e.style == 7 || e.style == 8 ||
+ e.style == 9 || e.style == 10)
{
- if !(this.noise1)
+ if !(e.noise1)
{
precache_sound ("break/metal1.wav");
- this.noise1 = "break/metal1.wav";
+ e.noise1 = "break/metal1.wav";
}
}

- if (this.style == 1 || this.style == 2 ||
- this.style == 13 || this.style == 14 ||
- this.style == 15 || this.style == 16 ||
- this.style == 20 || this.style == 21 ||
- this.style == 22 || this.style == 23)
+ if (e.style == 1 || e.style == 2 ||
+ e.style == 13 || e.style == 14 ||
+ e.style == 15 || e.style == 16 ||
+ e.style == 20 || e.style == 21 ||
+ e.style == 22 || e.style == 23)
{
- if !(this.noise1)
+ if !(e.noise1)
{
precache_sound ("break/bricks1.wav");
- this.noise1 = "break/bricks1.wav";
+ e.noise1 = "break/bricks1.wav";
}
}

- if (this.style == 25 || this.style == 26 ||
- this.style == 27 || this.style == 28 ||
- this.style == 29 || this.style == 30)
+ if (e.style == 25 || e.style == 26 ||
+ e.style == 27 || e.style == 28 ||
+ e.style == 29 || e.style == 30)
{
- if !(this.noise1)
+ if !(e.noise1)
{
precache_sound ("break/stones1.wav");
- this.noise1 = "break/stones1.wav";
+ e.noise1 = "break/stones1.wav";
}
}

- if (!this.health)
- this.health = 20;
- if (!this.count)
+ if (!e.health)
+ e.health = 20;
+ if (!e.count)
// was 6 dumptruck_ds
- this.count = 5;
+ e.count = 5;
};

//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) func_fall2_init =
{
+ e.classname = "func_fall2";
+ e.classtype = CT_FUNC_FALL2;
+ base_breakable_init (e);
+
// This is a hack to have monsters be able to trigger it
// by fake touch - Thanks to Nahuel

// Don't spawn on player only or if I'm a targetable
- if (!(this.spawnflags & FALL2_PLAYER_TRIGGERED) &&
- !(this.targetname))
+ if (!(e.spawnflags & FALL2_PLAYER_TRIGGERED) &&
+ !(e.targetname))
{
- // Link 'em
- // modified to use a helper class -- CEV
- this.fall2_helper = spawn (temp_fall2_helper,
- owner: this);
- setsize (this.fall2_helper, this.absmin,
- this.absmax + '0 0 8');
- setorigin (this.fall2_helper, this.origin);
- setmodel (this.fall2_helper, this.model);
+ // Link 'em -- modified to use a helper class -- CEV
+ e.trigger_field = spawn_temp_fall2_field (e,
+ e.absmin, e.absmax + '0 0 8');
}

- if (this.noise != __NULL__ && this.noise != "")
- precache_sound (this.noise);
- if (this.noise2 != __NULL__ && this.noise2 != "")
- precache_sound (this.noise2);
+ if (e.noise != __NULL__ && e.noise != "")
+ precache_sound (e.noise);
+ if (e.noise2 != __NULL__ && e.noise2 != "")
+ precache_sound (e.noise2);
+
+ e.alpha = 1.0;
+ e.solid = SOLID_BSP;
+ e.movetype = MOVETYPE_PUSH;

- this.interaction_flags &= ~DISABLE_TOUCH;
- this.alpha = 1.0;
- this.solid = SOLID_BSP;
- this.movetype = MOVETYPE_PUSH;
+ if (!e.pain_finished)
+ e.pain_finished = 0.01;

- if (!this.pain_finished)
- this.pain_finished = 0.01;
+ if (!e.targetname)
+ // .touch in this instance is for players only
+ e.touch = func_fall2_touch;

- if (!this.speed)
- this.speed = 10;
- if (!this.lip)
- this.lip = -800;
+ if (!e.speed)
+ e.speed = 10;
+ if (!e.lip)
+ e.lip = -800;

- if (this.avelocity != '0 0 0')
+ if (e.avelocity != '0 0 0')
{
// store it
- this.pos1 = this.avelocity;
- this.avelocity = '0 0 0';
+ e.pos1 = e.avelocity;
+ e.avelocity = '0 0 0';
}

- if (this.spawnflags & FALL2_BREAKABLE)
+ if (e.spawnflags & FALL2_BREAKABLE)
{
// VR
// dont fade if set to break
- this.pain_finished = -1;
- fall_break_fields ();
+ e.pain_finished = -1;
+ func_fall2_breakable_fields (e);
}

- setmodel (this, this.model);
+ e.use = func_fall2_use;
+ setmodel (e, e.model);
};

//--------------------------------------------------------------
void() func_fall2 =
{
- this.classtype = CT_FUNC_FALL2;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ func_fall2_init (self);
};
-};
+// };

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

Diff qc/func/illusionary.qc

diff --git a/qc/func/illusionary.qc b/qc/func/illusionary.qc
index edff2f4..1fd2bcf 100644
--- a/qc/func/illusionary.qc
+++ b/qc/func/illusionary.qc
@@ -2,22 +2,43 @@
// func_illusionary
//==============================================================================

+//======================================================================
+// forward declarations
+//======================================================================
+
+// func_illusionary
+void(entity e) func_illusionary_init;
+void() func_illusionary;
+
+//------------------------------------------------------------------------------
+
/*QUAKED func_illusionary (0 .5 .8) ? X X X X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
A simple entity that looks solid but lets you walk through it.
*/
-class func_illusionary: base_func
-{
- virtual void() init_spawned =
+//----------------------------------------------------------------------
+// class func_illusionary: base_func
+// {
+ //--------------------------------------------------------------
+ void(entity e) func_illusionary_init =
{
- this.angles = '0 0 0';
- this.movetype = MOVETYPE_NONE;
- this.solid = SOLID_NOT;
- setmodel (this, this.model);
- makestatic (this);
+ e.classname = "func_illusionary";
+ e.classtype = CT_FUNC_ILLUSIONARY;
+ base_func_init (e);
+
+ e.angles = '0 0 0';
+ e.movetype = MOVETYPE_NONE;
+ e.solid = SOLID_NOT;
+ setmodel (e, e.model);
+ makestatic (e);
};

+ //--------------------------------------------------------------
void() func_illusionary =
{
- this.classtype = CT_FUNC_ILLUSIONARY;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ func_illusionary_init (self);
};
-};
+// };

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

Diff qc/func/laser.qc

diff --git a/qc/func/laser.qc b/qc/func/laser.qc
index 2db0e60..484be85 100644
--- a/qc/func/laser.qc
+++ b/qc/func/laser.qc
@@ -2,35 +2,77 @@
// func_laser -- selections from Rubicon 2 qc by john fitzgibbons
//==============================================================================

+//======================================================================
// constants
+//======================================================================
+
const float LASER_START_OFF = 1;
const float LASER_SOLID = 2;

+//======================================================================
+// forward declarations
+//======================================================================
+
+// temp_laser_helper
+void() temp_laser_helper_think;
+entity(entity own, float newalpha) spawn_temp_laser_helper;
+void(entity e) temp_laser_helper_init;
+strip void() temp_laser_helper;
+
+// func_laser
+void() func_laser_touch;
+void() func_laser_use;
+void(entity e) func_laser_init;
+void() func_laser;
+
//------------------------------------------------------------------------------
-class temp_laser_helper: base_tempentity
-{
+
+//----------------------------------------------------------------------
+// class temp_laser_helper: base_tempentity
+// {
//--------------------------------------------------------------
- virtual void() do_think =
+ void() temp_laser_helper_think =
{
- if (!this.owner || this.owner.classtype != CT_FUNC_LASER)
+ if (!self.owner || self.owner.classtype != CT_FUNC_LASER)
{
- remove (this);
+ remove (self);
return;
}

- if (!(this.owner.spawnflags & LASER_START_OFF))
- this.owner.alpha = this.alpha * 0.8 +
- this.alpha * random() * 0.4;
+ if (!(self.owner.spawnflags & LASER_START_OFF))
+ self.owner.alpha = self.alpha * 0.8 +
+ self.alpha * random() * 0.4;

- this.nextthink = time + 0.05;
+ self.nextthink = time + 0.05;
};

- void() temp_laser_helper =
+ //--------------------------------------------------------------
+ entity(entity own, float newalpha) spawn_temp_laser_helper =
{
- this.classtype = CT_TEMP_LASER_HELPER;
- this.nextthink = 0.05;
+ local entity e = spawn ();
+ e.owner = own;
+ e.alpha = newalpha;
+ temp_laser_helper_init (e);
+ return e;
};
-};
+
+ //--------------------------------------------------------------
+ void(entity e) temp_laser_helper_init =
+ {
+ e.classname = "temp_laser_helper";
+ e.classtype = CT_TEMP_LASER_HELPER;
+ base_tempentity_init (e);
+
+ e.think = temp_laser_helper_think;
+ e.nextthink = 0.05;
+ };
+
+ //--------------------------------------------------------------
+ strip void() temp_laser_helper =
+ {
+ temp_laser_helper_init (self);
+ };
+// };

/*QUAKED func_laser (0 .5 .8) ? LASER_START_OFF LASER_SOLID X X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY

@@ -51,126 +93,120 @@ Keys:
"message2" message to display when deactivated

*/
-class func_laser: base_func
-{
- string message2;
-
- //--------------------------------------------------------------
- virtual void(string fieldname, string fieldvalue) init_field =
- {
- switch (fieldname)
- {
- case "message2":
- message2 = fieldvalue;
- break;
- default:
- super::init_field (fieldname, fieldvalue);
- }
- };
-
+//----------------------------------------------------------------------
+// class func_laser: base_func
+// {
//--------------------------------------------------------------
- virtual void(entity toucher) do_touch =
+ void() func_laser_touch =
{
// from Copper -- dumptruck_ds
- if (toucher.movetype == MOVETYPE_NOCLIP)
+ if (other.movetype == MOVETYPE_NOCLIP)
return;

- if (toucher.takedamage && this.attack_finished < time)
+ if (other.takedamage && self.attack_finished < time)
{
- t_damage2 (toucher, this, this, this.dmg);
- this.attack_finished = time + 0.1;
+ t_damage2 (other, self, self, self.dmg);
+ self.attack_finished = time + 0.1;
}

};

//--------------------------------------------------------------
- virtual void(entity caller) do_use =
+ void() func_laser_use =
{
- if (this.spawnflags & LASER_START_OFF)
+ if (self.spawnflags & LASER_START_OFF)
{
- setorigin (this, '0 0 0');
- this.spawnflags = this.spawnflags - LASER_START_OFF;
+ setorigin (self, '0 0 0');
+ self.spawnflags = self.spawnflags - LASER_START_OFF;

// changed for progs_dump: the laser sound is now
- // emitted from the func_laser itthis instead of
+ // emitted from the func_laser itself instead of
// from the activator -- iw
- sound (this, CHAN_VOICE, this.noise, 1, ATTN_NORM);
+ sound (self, CHAN_VOICE, self.noise, 1, ATTN_NORM);

if (activator.classtype == CT_PLAYER &&
- this.message != "")
+ self.message != "")
{
- centerprint (activator, this.message);
+ centerprint (activator, self.message);
}
}
else
{
// changed for progs_dump: the laser sound is now
- // emitted from the func_laser itthis instead of
+ // emitted from the func_laser itself instead of
// from the activator -- iw
- sound (this, CHAN_VOICE, this.noise1, 1, ATTN_NORM);
+ sound (self, CHAN_VOICE, self.noise1, 1, ATTN_NORM);

- setorigin (this, '0 0 9000');
- this.spawnflags = this.spawnflags + LASER_START_OFF;
+ setorigin (self, '0 0 9000');
+ self.spawnflags = self.spawnflags + LASER_START_OFF;

if (activator.classtype == CT_PLAYER &&
- this.message2 != "")
+ self.message2 != "")
{
- centerprint (activator, this.message2);
+ centerprint (activator, self.message2);
}
}
};

//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) func_laser_init =
{
- local entity helper;
+ e.classname = "func_laser";
+ e.classtype = CT_FUNC_LASER;
+ base_func_init (e);

- setmodel (this, this.model);
+ setmodel (e, e.model);

precache_sound ("buttons/switch02.wav");
precache_sound ("buttons/switch04.wav");

- if (this.spawnflags & LASER_SOLID)
+ if (e.spawnflags & LASER_SOLID)
{
// so you can shoot between lasers in a single bmodel
- this.solid = SOLID_BSP;
+ e.solid = SOLID_BSP;
// required becuase of SOLID_BSP
- this.movetype = MOVETYPE_PUSH;
+ e.movetype = MOVETYPE_PUSH;
}
else
{
- this.solid = SOLID_TRIGGER;
- this.movetype = MOVETYPE_NONE;
+ e.solid = SOLID_TRIGGER;
+ e.movetype = MOVETYPE_NONE;
}

- if (!this.alpha)
- this.alpha = 0.5;
+ if (!e.alpha)
+ e.alpha = 0.5;

- if (!this.dmg)
- this.dmg = 1;
+ if (!e.dmg)
+ e.dmg = 1;

- if (this.spawnflags & LASER_START_OFF)
- setorigin (this, '0 0 9000');
+ e.touch = func_laser_touch;
+ e.use = func_laser_use;

- if (this.noise != "")
- precache_sound (this.noise);
+ if (e.spawnflags & LASER_START_OFF)
+ setorigin (e, '0 0 9000');
+
+ if (e.noise != "")
+ precache_sound (e.noise);
else
- this.noise = "buttons/switch02.wav";
+ e.noise = "buttons/switch02.wav";

- if (this.noise1 != "")
- precache_sound (this.noise1);
+ if (e.noise1 != "")
+ precache_sound (e.noise1);
else
- this.noise1 = "buttons/switch04.wav";
+ e.noise1 = "buttons/switch04.wav";

// spawn a second entity to handle alpha changes, since
// MOVETYPE_PUSH doesn't support think functions
- helper = spawn (temp_laser_helper, alpha: this.alpha,
- owner: this);
+ spawn_temp_laser_helper (e, e.alpha);
};

//--------------------------------------------------------------
void() func_laser =
{
- this.classtype = CT_FUNC_LASER;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ func_laser_init (self);
};
-};
+// };

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

Diff qc/func/new_plat.qc

diff --git a/qc/func/new_plat.qc b/qc/func/new_plat.qc
index c3e5292..070a26f 100644
--- a/qc/func/new_plat.qc
+++ b/qc/func/new_plat.qc
@@ -6,101 +6,190 @@
// pmack
// september 1996

-// constants / TYPES
-const float NEWPLAT_DN_N_WAIT = 1;
+//======================================================================
+// constants
+//======================================================================
+
+const float NEWPLAT_DN_N_WAIT = 1; // spawnflags
const float NEWPLAT_PLT_TOGGLE = 2;
const float NEWPLAT_ELEVATOR = 4;
const float NEWPLAT_START_AT_TOP = 8;
const float NEWPLAT_PLAT2 = 16;
const float NEWPLAT_PLAT2_BOTTOM = 32;

+//======================================================================
+// forward declarations
+//======================================================================
+
+// temp_new_plat_trigger
+void() temp_new_plat_trigger_touch;
+entity(entity own) spawn_temp_new_plat_trigger;
+void(entity e) temp_new_plat_trigger_init;
+strip void() temp_new_plat_trigger;
+
+// func_new_plat
+void() func_new_plat_downandwait_hit_top; // down and wait style
+void() func_new_plat_downandwait_hit_bottom;
+void() func_new_plat_downandwait_go_down;
+void() func_new_plat_downandwait_go_up;
+void() func_new_plat_downandwait_blocked;
+void() func_new_plat_downandwait_use;
+void() func_new_plat_toggle_hit_top; // toggle style
+void() func_new_plat_toggle_hit_bottom;
+void() func_new_plat_toggle_go_down;
+void() func_new_plat_toggle_go_up;
+void() func_new_plat_toggle_blocked;
+void() func_new_plat_toggle_use;
+void() func_new_plat_elvtr_stop; // DoE elevator style
+void() func_new_plat_elvtr_go;
+void() func_new_plat_elvtr_blocked;
+void() func_new_plat_elvtr_use;
+void() func_new_plat_plat2_hit_top; // plat2 style
+void() func_new_plat_plat2_hit_bottom;
+void() func_new_plat_plat2_go_down;
+void() func_new_plat_plat2_go_up;
+void() func_new_plat_plat2_use;
+void() func_new_plat_plat2_blocked;
+void(entity e) func_new_plat_init; // initialization & spawn function
+void() func_new_plat;
+
//------------------------------------------------------------------------------
-class temp_newplat_trigger: base_tempentity
-{
+
+//----------------------------------------------------------------------
+// class temp_new_plat_trigger: base_tempentity
+// {
//--------------------------------------------------------------
- virtual void(entity toucher) do_touch =
+ // plat2_center_touch
+ //--------------------------------------------------------------
+ void() temp_new_plat_trigger_touch =
{
- local float otherState;
- local vector platPosition;
+ local float other_state;
+ local vector plat_position;

// from Copper -- dumptruck_ds
- if (sub_checkvalidtouch(toucher) == FALSE)
+ if (sub_checkvalidtouch(other) == FALSE)
return;

- if (this.enemy.classtype != CT_FUNC_NEW_PLAT)
+ if (!self.owner)
+ {
+ remove (self);
return;
+ }

- // at this point "this" is the trigger, "this.enemy" is
- // the plat, and "other" is the player.
+ if (self.owner.classtype != CT_FUNC_NEW_PLAT)
+ return;

- // cast enemy to func_new_plat -- CEV
- local func_new_plat fp = (func_new_plat)this.enemy;
+ // at this point "self" is the trigger, "self.owner" is
+ // the plat, and "other" is the player.

- if ((fp.plat2LastMove + 2) > time)
+ if ((self.owner.invincible_time + 2) > time)
return;

- if (fp.state > 4)
+ if (self.owner.state > 4)
// disabled.
return;

- if (fp.plat2GoTo > FUNC_STATE_BOTTOM)
+ if (self.owner.jump_flag > FUNC_STATE_BOTTOM)
{
- if (fp.plat2GoTime < time)
+ if (self.owner.super_time < time)
{
- if (fp.plat2GoTo == FUNC_STATE_UP)
- fp.plat2_go_up ();
+ if (self.owner.jump_flag == FUNC_STATE_UP)
+ sub_runvoidas (self.owner,
+ func_new_plat_plat2_go_up);
else
- fp.plat2_go_down ();
+ sub_runvoidas (self.owner,
+ func_new_plat_plat2_go_down);

- fp.plat2GoTo = 0;
+ self.owner.jump_flag = 0;
}
return;
}

- if (fp.state > FUNC_STATE_BOTTOM)
+ if (self.owner.state > FUNC_STATE_BOTTOM)
// STATE_UP or STATE_DOWN
return;

- platPosition = (fp.absmax + fp.absmin) * 0.5;
+ plat_position = (self.owner.absmax + self.owner.absmin) * 0.5;

- if (fp.state == FUNC_STATE_TOP)
+ if (self.owner.state == FUNC_STATE_TOP)
{
- otherState = FUNC_STATE_TOP;
- if (platPosition_z > other.origin_z)
- otherState = FUNC_STATE_BOTTOM;
+ other_state = FUNC_STATE_TOP;
+ if (plat_position_z > other.origin_z)
+ other_state = FUNC_STATE_BOTTOM;
}
else
{
- otherState = FUNC_STATE_BOTTOM;
- if ((other.origin_z - platPosition_z) > fp.height)
- otherState = FUNC_STATE_TOP;
+ other_state = FUNC_STATE_BOTTOM;
+ if ((other.origin_z - plat_position_z) >
+ self.owner.height)
+ {
+ other_state = FUNC_STATE_TOP;
+ }
}

- if (fp.state == otherState)
+ if (self.owner.state == other_state)
{
- fp.plat2Called = 0;
- fp.plat2GoTime = time + 0.5;
+ self.owner.cnt = 0;
+ self.owner.super_time = time + 0.5;
}
else
{
- fp.plat2GoTime = time + 0.1;
- fp.plat2Called = 1;
+ self.owner.super_time = time + 0.1;
+ self.owner.cnt = 1;
}

- if (fp.state == FUNC_STATE_BOTTOM)
- fp.plat2GoTo = FUNC_STATE_UP;
- else if (fp.state == FUNC_STATE_TOP)
- fp.plat2GoTo = FUNC_STATE_DOWN;
+ if (self.owner.state == FUNC_STATE_BOTTOM)
+ self.owner.jump_flag = FUNC_STATE_UP;
+ else if (self.owner.state == FUNC_STATE_TOP)
+ self.owner.jump_flag = FUNC_STATE_DOWN;
};

//--------------------------------------------------------------
- void() temp_newplat_trigger =
+ entity(entity own) spawn_temp_new_plat_trigger =
{
- this.classtype = CT_TEMP_NEWPLAT_TRIGGER;
- this.movetype = MOVETYPE_NONE;
- this.solid = SOLID_TRIGGER;
+ local entity e = spawn ();
+ e.owner = own;
+ temp_new_plat_trigger_init (e);
+ return e;
};
-};
+
+ //--------------------------------------------------------------
+ void(entity e) temp_new_plat_trigger_init =
+ {
+ e.classname = "temp_new_plat_trigger";
+ e.classtype = CT_TEMP_NEWPLAT_TRIGGER;
+ base_tempentity_init (e);
+ e.touch = temp_new_plat_trigger_touch;
+ e.movetype = MOVETYPE_NONE;
+ e.solid = SOLID_TRIGGER;
+
+ local vector tmin = e.owner.mins + '25 25 0';
+ local vector tmax = e.owner.maxs - '25 25 -8';
+ tmin_z = tmax_z - (e.owner.pos1_z - e.owner.pos2_z + 8);
+
+ if (e.owner.spawnflags & PLAT_LOW_TRIGGER)
+ tmax_z = tmin_z + 8;
+
+ if (e.owner.size_x <= 50)
+ {
+ tmin_x = (e.owner.mins_x + e.owner.maxs_x) / 2;
+ tmax_x = tmin_x + 1;
+ }
+ if (e.owner.size_y <= 50)
+ {
+ tmin_y = (e.owner.mins_y + e.owner.maxs_y) / 2;
+ tmax_y = tmin_y + 1;
+ }
+
+ setsize (e, tmin, tmax);
+ };
+
+ //--------------------------------------------------------------
+ strip void() temp_new_plat_trigger =
+ {
+ temp_new_plat_trigger_init (self);
+ };
+// };

/*QUAKED func_new_plat (0 .5 .8) ? DN_N_WAIT PLT_TOGGLE ELEVATOR START_AT_TOP PLAT2 P2_BOTTOM X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY

@@ -137,92 +226,68 @@ Set "sounds" to one of the following:
1) base fast
2) chain slow
*/
-class func_new_plat: base_func
-{
- // class fields for progs_dump plat2 (& Rogue multifloor elevator)
- float height;
- float plat2Called;
- float plat2LastMove;
- float plat2GoTime;
- float plat2GoTo;
- float elevatorLastUse;
- float elevatorOnFloor;
- float elevatorToFloor;
-
- /*
- vector pos1;
- vector pos2;
- */
- vector pos_top;
- vector pos_bottom;
-
- virtual void(string fieldname, string fieldvalue) init_field =
- {
- switch (fieldname)
- {
- case "height":
- this.height = stof (fieldvalue);
- break;
- default:
- super::init_field (fieldname, fieldvalue);
- }
- };
-
+//----------------------------------------------------------------------
+// class func_new_plat: base_func
+// {
//==============================================================
// down N and wait code
//==============================================================

//--------------------------------------------------------------
- nonvirtual void() dn_and_wait_hit_top =
+ void() func_new_plat_downandwait_hit_top =
{
- sound (this, CHAN_VOICE, this.noise1, 1, ATTN_NORM);
- this.state = FUNC_STATE_TOP;
+ sound (self, CHAN_VOICE, self.noise1, 1, ATTN_NORM);
+ self.state = FUNC_STATE_TOP;
};

//--------------------------------------------------------------
- nonvirtual void() dn_and_wait_hit_bottom =
+ void() func_new_plat_downandwait_hit_bottom =
{
- sound (this, CHAN_VOICE, this.noise1, 1, ATTN_NORM);
- this.state = FUNC_STATE_BOTTOM;
- this.nextthink = this.ltime + this.health;
+ sound (self, CHAN_VOICE, self.noise1, 1, ATTN_NORM);
+ self.state = FUNC_STATE_BOTTOM;
+ self.think = func_new_plat_downandwait_go_up;
+ self.nextthink = self.ltime + self.health;
};

//--------------------------------------------------------------
- nonvirtual void() dn_and_wait_go_down =
+ void() func_new_plat_downandwait_go_down =
{
- sound (this, CHAN_VOICE, this.noise, 1, ATTN_NORM);
- this.state = FUNC_STATE_DOWN;
- calc_move (this.pos2, this.speed, dn_and_wait_hit_bottom);
+ sound (self, CHAN_VOICE, self.noise, 1, ATTN_NORM);
+ self.state = FUNC_STATE_DOWN;
+ sub_calcmove (self, self.pos2, self.speed,
+ func_new_plat_downandwait_hit_bottom);
};

//--------------------------------------------------------------
- nonvirtual void() dn_and_wait_go_up =
+ void() func_new_plat_downandwait_go_up =
{
- sound (this, CHAN_VOICE, this.noise, 1, ATTN_NORM);
- this.state = FUNC_STATE_UP;
- calc_move (this.pos1, this.speed, dn_and_wait_hit_top);
+ sound (self, CHAN_VOICE, self.noise, 1, ATTN_NORM);
+ self.state = FUNC_STATE_UP;
+ sub_calcmove (self, self.pos1, self.speed,
+ func_new_plat_downandwait_hit_top);
};

//--------------------------------------------------------------
- nonvirtual void(entity blocker) dn_and_wait_crush =
+ void() func_new_plat_downandwait_blocked =
{
- this.t_damage2 (blocker, this, this, 1);
+ t_damage2 (other, self, self, 1);

- if (this.state == FUNC_STATE_UP)
- dn_and_wait_go_down ();
- else if (this.state == FUNC_STATE_DOWN)
- dn_and_wait_go_up ();
+ if (self.state == FUNC_STATE_UP)
+ func_new_plat_downandwait_go_down ();
+ else if (self.state == FUNC_STATE_DOWN)
+ func_new_plat_downandwait_go_up ();
else
- objerror ("plat_new_crush: bad this.state\n");
+ objerror ("func_new_plat_downandwait_blocked: "
+ "bad self.state\n");
};

//--------------------------------------------------------------
- nonvirtual void() dn_and_wait_use =
+ void() func_new_plat_downandwait_use =
{
- if (this.state != FUNC_STATE_TOP)
+ if (self.state != FUNC_STATE_TOP)
return;

- dn_and_wait_go_down ();
+ func_new_plat_downandwait_go_down ();
};

//==============================================================
@@ -230,303 +295,271 @@ class func_new_plat: base_func
//==============================================================

//--------------------------------------------------------------
- nonvirtual void() toggle_hit_top =
+ void() func_new_plat_toggle_hit_top =
{
- sound (this, CHAN_VOICE, this.noise1, 1, ATTN_NORM);
- this.state = FUNC_STATE_TOP;
+ sound (self, CHAN_VOICE, self.noise1, 1, ATTN_NORM);
+ self.state = FUNC_STATE_TOP;
};

//--------------------------------------------------------------
- nonvirtual void() toggle_hit_bottom =
+ void() func_new_plat_toggle_hit_bottom =
{
- sound (this, CHAN_VOICE, this.noise1, 1, ATTN_NORM);
- this.state = FUNC_STATE_BOTTOM;
+ sound (self, CHAN_VOICE, self.noise1, 1, ATTN_NORM);
+ self.state = FUNC_STATE_BOTTOM;
};

//--------------------------------------------------------------
- nonvirtual void() toggle_go_down =
+ void() func_new_plat_toggle_go_down =
{
- sound (this, CHAN_VOICE, this.noise, 1, ATTN_NORM);
- this.state = FUNC_STATE_DOWN;
- calc_move (this.pos2, this.speed, toggle_hit_bottom);
+ sound (self, CHAN_VOICE, self.noise, 1, ATTN_NORM);
+ self.state = FUNC_STATE_DOWN;
+ sub_calcmove (self, self.pos2, self.speed,
+ func_new_plat_toggle_hit_bottom);
};

//--------------------------------------------------------------
- nonvirtual void() toggle_go_up =
+ void() func_new_plat_toggle_go_up =
{
- sound (this, CHAN_VOICE, this.noise, 1, ATTN_NORM);
- this.state = FUNC_STATE_UP;
- calc_move (this.pos1, this.speed, toggle_hit_top);
+ sound (self, CHAN_VOICE, self.noise, 1, ATTN_NORM);
+ self.state = FUNC_STATE_UP;
+ sub_calcmove (self, self.pos1, self.speed,
+ func_new_plat_toggle_hit_top);
};

//--------------------------------------------------------------
- nonvirtual void(entity blocker) toggle_crush =
+ void() func_new_plat_toggle_blocked =
{
- this.t_damage2 (blocker, this, this, 1);
+ t_damage2 (other, self, self, 1);

- if (this.state == FUNC_STATE_UP)
- toggle_go_down ();
- else if (this.state == FUNC_STATE_DOWN)
- toggle_go_up ();
+ if (self.state == FUNC_STATE_UP)
+ func_new_plat_toggle_go_down ();
+ else if (self.state == FUNC_STATE_DOWN)
+ func_new_plat_toggle_go_up ();
else
- objerror ("plat_new_crush: bad this.state\n");
+ objerror ("func_new_plat_toggle_blocked: "
+ "bad self.state\n");
};

//--------------------------------------------------------------
- nonvirtual void() toggle_use =
+ void() func_new_plat_toggle_use =
{
- if (this.state == FUNC_STATE_TOP)
- toggle_go_down ();
- else if (this.state == FUNC_STATE_BOTTOM)
- toggle_go_up ();
+ if (self.state == FUNC_STATE_TOP)
+ func_new_plat_toggle_go_down ();
+ else if (self.state == FUNC_STATE_BOTTOM)
+ func_new_plat_toggle_go_up ();
};

//==============================================================
// elvtr type code
+ // reusing fields; old -> current -- CEV
+ // elevatorDestination -> finaldest (will be rewritten by calcmove)
+ // elevatorLastUsed -> rad_time
+ // elevatorOnFloor -> style
+ // elevatorToFloor -> style2
//==============================================================

//--------------------------------------------------------------
- nonvirtual void() elvtr_stop =
+ void() func_new_plat_elvtr_stop =
{
- this.elevatorOnFloor = this.elevatorToFloor;
- sound (this, CHAN_VOICE, this.noise1, 1, ATTN_NORM);
- this.state = FUNC_STATE_BOTTOM;
- this.elevatorLastUse = time;
- /*
- // a messy testing print -- CEV
- dprint (sprintf("func_new_plat: elvtr_stop, origin: %v\n",
- this.origin));
- */
+ self.style = self.style2;
+ sound (self, CHAN_VOICE, self.noise1, 1, ATTN_NORM);
+ self.state = FUNC_STATE_BOTTOM;
+ self.rad_time = time;
};

//--------------------------------------------------------------
- nonvirtual void() elvtr_go =
+ void() func_new_plat_elvtr_go =
{
- // another messy testing dprint -- CEV
- /*
- dprint (sprintf("elvtr_go: pos_bottom %v, pos_bottom_z %g, "
- "origin %v, on floor %g, to floor %g\n",
- this.pos_bottom,
- this.pos_bottom_z,
- this.origin,
- this.elevatorOnFloor,
- this.elevatorToFloor));
- */
-
- sound (this, CHAN_VOICE, this.noise, 1, ATTN_NORM);
- this.state = FUNC_STATE_UP;
-
- // TODO CEV for some reason vector class fields are behaving
- // weirdly here. Addressing x y and z directly works but
- // reading from or assigning a whole vector doesn't. I'm
- // using an in-place vector created from parts of pos_bottom
- // below in place of the previous elevatorDestination vector
- // for this reason. This is incredibly annoying. -- CEV
- this.calc_move ([this.pos_bottom_x, this.pos_bottom_y,
- this.pos_bottom_z +
- (this.height * this.elevatorToFloor)],
- this.speed, this.elvtr_stop);
- this.elevatorLastUse = time;
+ self.finaldest = self.pos2;
+ self.finaldest_z = self.pos2_z +
+ (self.height * self.style2);
+ sound (self, CHAN_VOICE, self.noise, 1, ATTN_NORM);
+ self.state = FUNC_STATE_UP;
+ sub_calcmove (self, self.finaldest, self.speed,
+ func_new_plat_elvtr_stop);
+ self.rad_time = time;
};

//--------------------------------------------------------------
- nonvirtual void(entity blocker) elvtr_crush =
+ void() func_new_plat_elvtr_blocked =
{
local float tmp;

- // T_Damage (other, this, this, 1);
+ // T_Damage (other, self, self, 1);

// the elevator is changing direction, so swap the floor
// it's coming from and the floor it's going to -- iw
- tmp = this.elevatorOnFloor;
- this.elevatorOnFloor = this.elevatorToFloor;
- this.elevatorToFloor = tmp;
+ tmp = self.style;
+ self.style = self.style2;
+ self.style2 = tmp;

- elvtr_go ();
+ func_new_plat_elvtr_go ();
};

//--------------------------------------------------------------
// elvtr_use -- elevator use function
- // this = plat, other = elevator button, other.enemy = player
+ // self = plat, other = elevator button, other.enemy = player
//--------------------------------------------------------------
- nonvirtual void(entity button) elvtr_use =
+ void() func_new_plat_elvtr_use =
{
// the original DoE code allowed an elevator to be activated
// again when it was in the process of moving between floors
// (assuming the wait period was over); this resulted in
// sometimes unintuitive behavior, so, the following test
// prevents this -- iw
- if (this.elevatorToFloor != this.elevatorOnFloor)
+ if (self.style2 != self.style)
return;

// the original DoE code had a hard-coded two second wait
// period; this has been changed for progs_dump so that
// this.wait is used instead -- iw
- if ((this.elevatorLastUse + this.wait) > time)
+ if ((self.rad_time + self.wait) > time)
return;

- local float tempDist, elvPos, btnPos;
+ local float temp_dist, elvPos, btnPos;

- this.elevatorLastUse = time;
+ self.rad_time = time;

if (elv_butn_dir == 0)
return;

- elvPos = (this.absmin_z + this.absmax_z) * 0.5;
- btnPos = (button.absmin_z + button.absmax_z) * 0.5;
+ elvPos = (self.absmin_z + self.absmax_z) * 0.5;
+ btnPos = (other.absmin_z + other.absmax_z) * 0.5;

if (elvPos > btnPos)
{
- tempDist = (elvPos - btnPos) / this.height;
- tempDist = ceil (tempDist);
- this.elevatorToFloor = this.elevatorOnFloor - tempDist;
- elvtr_go ();
+ temp_dist = (elvPos - btnPos) / self.height;
+ temp_dist = ceil (temp_dist);
+ self.style2 = self.style - temp_dist;
+ func_new_plat_elvtr_go ();
return;
}
else
{
- tempDist = btnPos - elvPos;
- if (tempDist > this.height)
+ temp_dist = btnPos - elvPos;
+ if (temp_dist > self.height)
{
- tempDist = tempDist / this.height;
- tempDist = floor (tempDist);
- this.elevatorToFloor = this.elevatorOnFloor +
- tempDist;
- elvtr_go ();
+ temp_dist = temp_dist / self.height;
+ temp_dist = floor (temp_dist);
+ self.style2 = self.style +
+ temp_dist;
+ func_new_plat_elvtr_go ();
return;
}
}

if (elv_butn_dir == -1)
{
- if (this.elevatorOnFloor > 0)
+ if (self.style > 0)
{
- this.elevatorToFloor = this.elevatorOnFloor - 1;
- elvtr_go ();
+ self.style2 = self.style - 1;
+ func_new_plat_elvtr_go ();
}
}
else if (elv_butn_dir == 1)
{
- if (this.elevatorOnFloor < (this.cnt - 1))
+ if (self.style < (self.cnt - 1))
{
- this.elevatorToFloor = this.elevatorOnFloor + 1;
- elvtr_go ();
+ self.style2 = self.style + 1;
+ func_new_plat_elvtr_go ();
}
}
};

//==============================================================
// PLAT2 type code
+ // reusing fields; old -> current -- CEV
+ // plat2Called -> cnt
+ // plat2LastMove -> invincible_time
+ // plat2GoTime -> super_time
+ // plat2GoTo -> jump_flag
//==============================================================

//--------------------------------------------------------------
- nonvirtual void() plat2_spawn_inside_trigger =
- {
- local temp_newplat_trigger trigger;
- local vector tmin, tmax;
-
- // middle trigger
- trigger = spawn (temp_newplat_trigger, enemy: this);
-
- tmin = this.mins + '25 25 0';
- tmax = this.maxs - '25 25 -8';
- tmin_z = tmax_z - (this.pos1_z - this.pos2_z + 8);
-
- if (this.spawnflags & PLAT_LOW_TRIGGER)
- tmax_z = tmin_z + 8;
-
- if (this.size_x <= 50)
- {
- tmin_x = (this.mins_x + this.maxs_x) / 2;
- tmax_x = tmin_x + 1;
- }
- if (this.size_y <= 50)
- {
- tmin_y = (this.mins_y + this.maxs_y) / 2;
- tmax_y = tmin_y + 1;
- }
-
- setsize (trigger, tmin, tmax);
- };
-
- //--------------------------------------------------------------
- nonvirtual void() plat2_hit_top =
+ void() func_new_plat_plat2_hit_top =
{
- sound (this, CHAN_VOICE, this.noise1, 1, ATTN_NORM);
- this.state = FUNC_STATE_TOP;
+ sound (self, CHAN_VOICE, self.noise1, 1, ATTN_NORM);
+ self.state = FUNC_STATE_TOP;

- this.plat2LastMove = time;
- if (this.plat2Called == 1)
+ self.invincible_time = time;
+ if (self.cnt == 1)
{
// allow immediate move
- this.plat2LastMove = 0;
- this.plat2Called = 0;
- this.nextthink = this.ltime + 1.5;
+ self.invincible_time = 0;
+ self.cnt = 0;
+ self.think = func_new_plat_plat2_go_down;
+ self.nextthink = self.ltime + 1.5;
}
- else if (!(this.spawnflags & NEWPLAT_START_AT_TOP))
+ else if (!(self.spawnflags & NEWPLAT_START_AT_TOP))
{
- this.plat2Called = 0;
- this.nextthink = this.ltime + this.delay;
+ self.cnt = 0;
+ self.think = func_new_plat_plat2_go_down;
+ self.nextthink = self.ltime + self.delay;
}
};

//--------------------------------------------------------------
- nonvirtual void() plat2_hit_bottom =
+ void() func_new_plat_plat2_hit_bottom =
{
- sound (this, CHAN_VOICE, this.noise1, 1, ATTN_NORM);
- this.state = FUNC_STATE_BOTTOM;
+ sound (self, CHAN_VOICE, self.noise1, 1, ATTN_NORM);
+ self.state = FUNC_STATE_BOTTOM;

- this.plat2LastMove = time;
- if (this.plat2Called == 1)
+ self.invincible_time = time;
+ if (self.cnt == 1)
{
// allow immediate move
- this.plat2LastMove = 0;
- this.plat2Called = 0;
- this.nextthink = this.ltime + 1.5;
+ self.invincible_time = 0;
+ self.cnt = 0;
+ self.think = func_new_plat_plat2_go_up;
+ self.nextthink = self.ltime + 1.5;
}
- else if (this.spawnflags & NEWPLAT_START_AT_TOP)
+ else if (self.spawnflags & NEWPLAT_START_AT_TOP)
{
- this.plat2Called = 0;
- this.nextthink = this.ltime + this.delay;
+ self.cnt = 0;
+ self.think = func_new_plat_plat2_go_up;
+ self.nextthink = self.ltime + self.delay;
}
};

//--------------------------------------------------------------
- nonvirtual void() plat2_go_down =
+ void() func_new_plat_plat2_go_down =
{
- sound (this, CHAN_VOICE, this.noise, 1, ATTN_NORM);
- this.state = FUNC_STATE_DOWN;
- calc_move (this.pos2, this.speed, this.plat2_hit_bottom);
+ sound (self, CHAN_VOICE, self.noise, 1, ATTN_NORM);
+ self.state = FUNC_STATE_DOWN;
+ sub_calcmove (self, self.pos2, self.speed,
+ func_new_plat_plat2_hit_bottom);
};

//--------------------------------------------------------------
- nonvirtual void() plat2_go_up =
+ void() func_new_plat_plat2_go_up =
{
- sound (this, CHAN_VOICE, this.noise, 1, ATTN_NORM);
- this.state = FUNC_STATE_UP;
- calc_move (this.pos1, this.speed, this.plat2_hit_top);
+ sound (self, CHAN_VOICE, self.noise, 1, ATTN_NORM);
+ self.state = FUNC_STATE_UP;
+ sub_calcmove (self, self.pos1, self.speed,
+ func_new_plat_plat2_hit_top);
};

//--------------------------------------------------------------
- nonvirtual void() plat2_use =
+ void() func_new_plat_plat2_use =
{
- if (this.state > 4)
- this.state = this.state - 10;
+ if (self.state > 4)
+ self.state = self.state - 10;

- this.interaction_flags |= DISABLE_USE;
+ self.use = sub_null;
};

//--------------------------------------------------------------
- nonvirtual void(entity blocker) plat2_crush =
+ void() func_new_plat_plat2_blocked =
{
- this.t_damage2 (blocker, this, this, 1);
+ t_damage2 (other, self, self, 1);

- if (this.state == FUNC_STATE_UP)
- plat2_go_down ();
- else if (this.state == FUNC_STATE_DOWN)
- plat2_go_up ();
+ if (self.state == FUNC_STATE_UP)
+ func_new_plat_plat2_go_down ();
+ else if (self.state == FUNC_STATE_DOWN)
+ func_new_plat_plat2_go_up ();
else
- objerror ("plat2_crush: bad this.state\n");
+ objerror ("func_new_plat_plat2_blocked: "
+ "bad self.state\n");
};

//==============================================================
@@ -534,245 +567,208 @@ class func_new_plat: base_func
//==============================================================

//--------------------------------------------------------------
- virtual void(entity blocker) do_blocked =
+ void(entity e) func_new_plat_init =
{
- if (this.spawnflags & NEWPLAT_DN_N_WAIT)
- this.dn_and_wait_crush (blocker);
- else if (this.spawnflags & NEWPLAT_PLT_TOGGLE)
- this.toggle_crush (blocker);
- else if (this.spawnflags & NEWPLAT_ELEVATOR)
- this.elvtr_crush (blocker);
- else if (this.spawnflags & NEWPLAT_PLAT2)
- this.plat2_crush (blocker);
- else
- dprint ("func_new_plat::do_blocked - check flags\n");
- };
-
- //--------------------------------------------------------------
- virtual void() do_think =
- {
- if (this.spawnflags & NEWPLAT_DN_N_WAIT)
- {
- if (this.state == FUNC_STATE_BOTTOM)
- this.dn_and_wait_go_up ();
- }
- else if (this.spawnflags & NEWPLAT_PLAT2)
- {
- if (this.state == FUNC_STATE_TOP)
- this.plat2_go_down ();
- else if (this.state == FUNC_STATE_BOTTOM)
- this.plat2_go_up ();
- }
- else
- {
- dprint ("func_new_plat::do_think: unhandled spawnflag "
- "in think function!\n");
- }
- };
+ e.classname = "plat";
+ e.classtype = CT_FUNC_NEW_PLAT;
+ base_func_init (e);

- //--------------------------------------------------------------
- virtual void(entity caller) do_use =
- {
- if (this.spawnflags & NEWPLAT_DN_N_WAIT)
- this.dn_and_wait_use ();
- else if (this.spawnflags & NEWPLAT_PLT_TOGGLE)
- this.toggle_use ();
- else if (this.spawnflags & NEWPLAT_ELEVATOR)
- this.elvtr_use (caller);
- else if (this.spawnflags & NEWPLAT_PLAT2)
- if (this.targetname != "")
- this.plat2_use ();
- else
- dprint ("func_new_plat::do_use: invalid spawnflags\n");
- };
-
- //--------------------------------------------------------------
- virtual void() init_spawned =
- {
// local entity t;
- local float negativeHeight;
-
- negativeHeight = 0;
+ local float negative_height = 0;

- this.pos_top = '0 0 0';
- this.pos_bottom = '0 0 0';
+ if (!e.t_length)
+ e.t_length = 80;
+ if (!e.t_width)
+ e.t_width = 10;

- if (!this.t_length)
- this.t_length = 80;
- if (!this.t_width)
- this.t_width = 10;
-
- if (this.sounds == 0)
- this.sounds = 2;
+ if (e.sounds == 0)
+ e.sounds = 2;

// FIX THIS TO LOAD A GENERIC PLAT SOUND

- if (this.sounds == 1)
+ if (e.sounds == 1)
{
- if (!this.noise || this.noise == "")
- this.noise = "plats/plat1.wav";
- if (!this.noise1 || this.noise1 == "")
- this.noise1 = "plats/plat2.wav";
+ if (!e.noise || e.noise == "")
+ e.noise = "plats/plat1.wav";
+ if (!e.noise1 || e.noise1 == "")
+ e.noise1 = "plats/plat2.wav";
}
- else if (this.sounds == 2)
+ else if (e.sounds == 2)
{
- if (!this.noise || this.noise == "")
- this.noise = "plats/medplat1.wav";
- if (!this.noise1 || this.noise1 == "")
- this.noise1 = "plats/medplat2.wav";
+ if (!e.noise || e.noise == "")
+ e.noise = "plats/medplat1.wav";
+ if (!e.noise1 || e.noise1 == "")
+ e.noise1 = "plats/medplat2.wav";
}
- else if (this.sounds == 3)
+ else if (e.sounds == 3)
{
// base door sound
- if (!this.noise || this.noise == "")
- this.noise = "doors/hydro1.wav";
- if (!this.noise1 || this.noise1 == "")
- this.noise1 = "doors/hydro2.wav";
+ if (!e.noise || e.noise == "")
+ e.noise = "doors/hydro1.wav";
+ if (!e.noise1 || e.noise1 == "")
+ e.noise1 = "doors/hydro2.wav";
}
- else if (this.sounds == 4)
+ else if (e.sounds == 4)
{
// func_train sounds
- if (!this.noise || this.noise == "")
- this.noise = "plats/train1.wav";
- if (!this.noise1 || this.noise1 == "")
- this.noise1 = "plats/train2.wav";
+ if (!e.noise || e.noise == "")
+ e.noise = "plats/train1.wav";
+ if (!e.noise1 || e.noise1 == "")
+ e.noise1 = "plats/train2.wav";
}
else
{
- if (!this.noise || this.noise == "")
- this.noise = "misc/null.wav";
- if (!this.noise1 || this.noise1 == "")
- this.noise1 = "misc/null.wav";
+ if (!e.noise || e.noise == "")
+ e.noise = "misc/null.wav";
+ if (!e.noise1 || e.noise1 == "")
+ e.noise1 = "misc/null.wav";
}

- precache_sound (this.noise);
- precache_sound (this.noise1);
+ precache_sound (e.noise);
+ precache_sound (e.noise1);

- this.mangle = this.angles;
- this.angles = '0 0 0';
+ e.mangle = e.angles;
+ e.angles = '0 0 0';

- this.classname = "plat";
- this.solid = SOLID_BSP;
- this.movetype = MOVETYPE_PUSH;
- setorigin (this, this.origin);
- setmodel (this, this.model);
- setsize (this, this.mins , this.maxs);
+ e.solid = SOLID_BSP;
+ e.movetype = MOVETYPE_PUSH;
+ setorigin (e, e.origin);
+ setmodel (e, e.model);
+ setsize (e, e.mins , e.maxs);

- if (!this.speed)
- this.speed = 150;
+ if (!e.speed)
+ e.speed = 150;

// pos1 is the top position, pos2 is the bottom
- this.pos1 = this.origin;
- this.pos2 = this.origin;
+ e.pos1 = e.origin;
+ e.pos2 = e.origin;

- if (this.height < 0)
+ if (e.height < 0)
{
- negativeHeight = 1;
- this.height = 0 - this.height;
+ negative_height = 1;
+ e.height = 0 - e.height;
}

- if (this.height)
+ if (e.height)
{
- this.pos2_z = this.origin_z - this.height;
+ e.pos2_z = e.origin_z - e.height;
}
else
{
- negativeHeight = 1;
- this.height = this.size_z - 8;
- this.pos2_z = this.origin_z - this.height;
+ negative_height = 1;
+ e.height = e.size_z - 8;
+ e.pos2_z = e.origin_z - e.height;
}

- if (this.spawnflags & NEWPLAT_DN_N_WAIT)
+ if (e.spawnflags & NEWPLAT_DN_N_WAIT)
{
- if (negativeHeight == 1)
+ e.blocked = func_new_plat_downandwait_blocked;
+ e.use = func_new_plat_downandwait_use;
+
+ if (negative_height == 1)
{
- this.state = FUNC_STATE_BOTTOM;
- setorigin (this, pos2);
+ e.state = FUNC_STATE_BOTTOM;
+ setorigin (e, e.pos2);
}
else
{
- this.state = FUNC_STATE_TOP;
+ e.state = FUNC_STATE_TOP;
}

- if (!this.health)
- this.health = 5;
+ if (!e.health)
+ e.health = 5;
}
- else if (this.spawnflags & NEWPLAT_PLT_TOGGLE)
+ else if (e.spawnflags & NEWPLAT_PLT_TOGGLE)
{
- if (negativeHeight == 1)
+ e.blocked = func_new_plat_toggle_blocked;
+ e.use = func_new_plat_toggle_use;
+
+ if (negative_height == 1)
{
- setorigin (this, pos2);
- this.state = FUNC_STATE_BOTTOM;
+ setorigin (e, e.pos2);
+ e.state = FUNC_STATE_BOTTOM;
}
else
{
- this.state = FUNC_STATE_TOP;
+ e.state = FUNC_STATE_TOP;
}
}
- else if (this.spawnflags & NEWPLAT_ELEVATOR)
+ else if (e.spawnflags & NEWPLAT_ELEVATOR)
{
- this.elevatorLastUse = 0;
+ e.rad_time = 0;

- // allow the mapper to set this.wait, but don't
+ // allow the mapper to set e.wait, but don't
// allow a negative wait period -- iw
- if (this.wait < 0)
- this.wait = 0;
+ if (e.wait < 0)
+ e.wait = 0;

- if (this.spawnflags & NEWPLAT_START_AT_TOP)
+ if (e.spawnflags & NEWPLAT_START_AT_TOP)
{
- this.pos_top = this.origin;
- this.pos_bottom = this.origin;
- this.pos_bottom_z = this.origin_z -
- (this.height * (this.cnt - 1));
- this.elevatorOnFloor = this.cnt - 1;
- this.elevatorToFloor = this.elevatorOnFloor;
+ e.pos1 = e.origin;
+ e.pos2 = e.origin;
+ e.pos2_z = e.origin_z -
+ (e.height * (e.cnt - 1));
+ e.style = e.cnt - 1;
+ e.style2 = e.style;
}
else
{
- this.pos_top = this.origin;
- this.pos_bottom = this.origin;
- this.pos_top_z = this.origin_z +
- (this.height * (this.cnt - 1));
- this.elevatorOnFloor = 0;
- this.elevatorToFloor = this.elevatorOnFloor;
+ e.pos1 = e.origin;
+ e.pos2 = e.origin;
+ e.pos1_z = e.origin_z +
+ (e.height * (e.cnt - 1));
+ e.style = 0;
+ e.style2 = e.style;
}
+
+ e.blocked = func_new_plat_elvtr_blocked;
+ e.use = func_new_plat_elvtr_use;
}
- else if (this.spawnflags & NEWPLAT_PLAT2)
+ else if (e.spawnflags & NEWPLAT_PLAT2)
{
- // the "start moving" trigger
- plat2_spawn_inside_trigger ();
- this.plat2Called = 0;
- this.plat2LastMove = 0;
- this.plat2GoTo = 0;
- this.plat2GoTime = 0;
+ e.cnt = 0;
+ e.invincible_time = 0;
+ e.jump_flag = 0;
+ e.super_time = 0;

- if (!this.delay)
- this.delay = 3;
+ e.blocked = func_new_plat_plat2_blocked;

- if (negativeHeight == 1)
+ if (!e.delay)
+ e.delay = 3;
+
+ if (negative_height == 1)
{
- this.state = FUNC_STATE_BOTTOM;
+ e.state = FUNC_STATE_BOTTOM;
// make sure START_AT_TOP isn't set.
// We need that...
- this.spawnflags = NEWPLAT_PLAT2;
- setorigin (this, this.pos2);
+ e.spawnflags = NEWPLAT_PLAT2;
+ setorigin (e, e.pos2);
}
else
{
// default position is top.
- this.spawnflags = this.spawnflags |
- NEWPLAT_START_AT_TOP;
- this.state = FUNC_STATE_TOP;
+ e.spawnflags |= NEWPLAT_START_AT_TOP;
+ e.state = FUNC_STATE_TOP;
+ }
+
+ if (e.targetname != "")
+ {
+ e.use = func_new_plat_plat2_use;
+ e.state = e.state + 10;
}

- if (this.targetname != "")
- this.state = this.state + 10;
+ // the "start moving" trigger
+ e.trigger_field = spawn_temp_new_plat_trigger (e);
}
};

//--------------------------------------------------------------
void() func_new_plat =
{
- this.classtype = CT_FUNC_NEW_PLAT;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ func_new_plat_init (self);
};
-};
+// };

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

Diff qc/func/particlefield.qc

diff --git a/qc/func/particlefield.qc b/qc/func/particlefield.qc
index df16f34..caa0f8b 100644
--- a/qc/func/particlefield.qc
+++ b/qc/func/particlefield.qc
@@ -8,10 +8,27 @@
// All rights reserved.
// Distributed (unsupported) on 3.12.97

+//======================================================================
// constants
+//======================================================================
+
// float PARTICLEFIELD_START_OFF = 1;
const float PARTICLEFIELD_USE_COUNT = 1;

+//======================================================================
+// forward declaration
+//======================================================================
+
+// func_particlefield
+void() func_particlefield_xz;
+void() func_particlefield_yz;
+void() func_particlefield_xy;
+void() func_particlefield_touch;
+void(entity e) func_particlefield_init;
+void() func_particlefield;
+
+//------------------------------------------------------------------------------
+
/*QUAKED func_particlefield (0 .5 .8) ? USE_COUNT X X X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY

Creates a brief particle flash roughly the size of the defining
@@ -27,44 +44,31 @@ to trigger.
"noise" is the sound to play when triggered. Do not use a looping sound here.
"dmg" is the amount of damage to cause when touched.
*/
-class func_particlefield: base_func
-{
- vector dest;
- vector dest1;
- vector dest2;
-
- float count;
- float field_direction;
-
- //--------------------------------------------------------------
- virtual void(string fieldname, string fieldvalue) init_field =
+//----------------------------------------------------------------------
+// class func_particlefield: base_func
+// {
+ //--------------------------------------------------------------
+ void() func_particlefield_xz =
{
- switch (fieldname)
+ if ((self.spawnflags & PARTICLEFIELD_USE_COUNT) &&
+ (func_counter_getcount(other) != self.cnt))
{
- case "count":
- count = stof (fieldvalue);
- break;
- default:
- super::init_field (fieldname, fieldvalue);
+ return;
}
- };

- //--------------------------------------------------------------
- nonvirtual void() particlefield_xz =
- {
local vector pos = '0 0 0';
local vector start;
local vector end;

/*
- dprint ("func_particlefield::particlefield_xz: entering\n");
+ dprint ("func_particlefield_xz: entering\n");
*/

- this.ltime = time + 0.25;
+ self.ltime = time + 0.25;

- if (this.noise != "")
+ if (self.noise != "")
{
- sound (this, CHAN_VOICE, this.noise, 1, ATTN_NORM);
+ sound (self, CHAN_VOICE, self.noise, 1, ATTN_NORM);
}

// Only show particles if client is visible.
@@ -72,8 +76,8 @@ class func_particlefield: base_func
if (!checkclient())
return;

- start = this.dest1 + this.origin;
- end = this.dest2 + this.origin;
+ start = self.pos1 + self.origin;
+ end = self.pos2 + self.origin;
pos_y = start_y;
pos_z = start_z;

@@ -82,7 +86,7 @@ class func_particlefield: base_func
pos_x = start_x;
while (pos_x <= end_x)
{
- particle (pos, '0 0 0', this.color, this.count);
+ particle (pos, '0 0 0', self.color, self.count);
pos_x = pos_x + 16;
}
pos_z = pos_z + 16;
@@ -90,22 +94,28 @@ class func_particlefield: base_func
};

//--------------------------------------------------------------
- nonvirtual void() particlefield_yz =
+ void() func_particlefield_yz =
{
+ if ((self.spawnflags & PARTICLEFIELD_USE_COUNT) &&
+ (func_counter_getcount(other) != self.cnt))
+ {
+ return;
+ }
+
local vector pos = '0 0 0';
local vector start;
local vector end;

/*
- dprint (sprintf("func_particlefield::particlefield_yz: "
- "entering, dest1 %v, dest2 %v\n", dest1, dest2));
+ dprint (sprintf("func_particlefield_yz: "
+ "entering, pos1 %v, pos2 %v\n", self.pos1, self.pos2));
*/

- this.ltime = time + 0.25;
+ self.ltime = time + 0.25;

- if (this.noise != "")
+ if (self.noise != "")
{
- sound (this, CHAN_VOICE, this.noise, 1, ATTN_NORM);
+ sound (self, CHAN_VOICE, self.noise, 1, ATTN_NORM);
}

// Only show particles if client is visible.
@@ -113,8 +123,8 @@ class func_particlefield: base_func
if (!checkclient())
return;

- start = this.dest1 + this.origin;
- end = this.dest2 + this.origin;
+ start = self.pos1 + self.origin;
+ end = self.pos2 + self.origin;
pos_x = start_x;
pos_z = start_z;

@@ -123,7 +133,7 @@ class func_particlefield: base_func
pos_y = start_y;
while (pos_y < end_y)
{
- particle (pos, '0 0 0', this.color, this.count);
+ particle (pos, '0 0 0', self.color, self.count);
pos_y = pos_y + 16;
}
pos_z = pos_z + 16;
@@ -131,21 +141,27 @@ class func_particlefield: base_func
};

//--------------------------------------------------------------
- nonvirtual void() particlefield_xy =
+ void() func_particlefield_xy =
{
+ if ((self.spawnflags & PARTICLEFIELD_USE_COUNT) &&
+ (func_counter_getcount(other) != self.cnt))
+ {
+ return;
+ }
+
local vector pos;
local vector start;
local vector end;

/*
- dprint ("func_particlefield::particlefield_xy: entering\n");
+ dprint ("func_particlefield_xy: entering\n");
*/

- this.ltime = time + 0.25;
+ self.ltime = time + 0.25;

- if (this.noise != "")
+ if (self.noise != "")
{
- sound (this, CHAN_VOICE, this.noise, 1, ATTN_NORM);
+ sound (self, CHAN_VOICE, self.noise, 1, ATTN_NORM);
}

// Only show particles if client is visible.
@@ -153,8 +169,8 @@ class func_particlefield: base_func
if (!checkclient())
return;

- start = this.dest1 + this.origin;
- end = this.dest2 + this.origin;
+ start = self.pos1 + self.origin;
+ end = self.pos2 + self.origin;
pos_x = start_x;
pos_z = start_z;

@@ -163,7 +179,7 @@ class func_particlefield: base_func
pos_y = start_y;
while (pos_y < end_y)
{
- particle (pos, '0 0 0', this.color, this.count);
+ particle (pos, '0 0 0', self.color, self.count);
pos_y = pos_y + 16;
}
pos_x = pos_x + 16;
@@ -171,105 +187,87 @@ class func_particlefield: base_func
};

//--------------------------------------------------------------
- virtual void(entity toucher) do_touch =
+ void() func_particlefield_touch =
{
- if (!this.dmg)
+ if (!self.dmg)
return;

- if (time > this.ltime)
+ if (time > self.ltime)
return;

- if (time < this.attack_finished)
+ if (time < self.attack_finished)
return;

- this.attack_finished = time + 0.5;
- t_damage2 (toucher, this, this, this.dmg);
+ self.attack_finished = time + 0.5;
+ t_damage2 (other, self, self, self.dmg);
};

//--------------------------------------------------------------
- virtual void(entity caller) do_use =
+ void(entity e) func_particlefield_init =
{
- if ((this.spawnflags & PARTICLEFIELD_USE_COUNT) &&
- func_counter::getcount(caller) != this.cnt)
+ e.classname = "particlefield";
+ e.classtype = CT_FUNC_PARTICLEFIELD;
+ base_func_init (e);
+
+ if (!e.color)
+ e.color = 192;
+
+ if (e.count == 0)
+ e.count = 2;
+
+ e.solid = SOLID_NOT;
+ e.movetype = MOVETYPE_NONE;
+ setmodel (e, e.model);
+ e.model = __NULL__;
+
+ e.origin = (e.mins + e.maxs) * 0.5;
+ setorigin (e, e.origin);
+ e.finaldest = e.maxs - e.mins - '16 16 16';
+ e.pos1 = e.mins + '8 8 8' - e.origin;
+ e.pos2 = e.maxs + '7.9 7.9 7.9' - e.origin;
+ setsize (e, e.mins, e.maxs);
+ e.touch = func_particlefield_touch;
+
+ if (e.finaldest_x > e.finaldest_z)
{
- /*
- dprint (sprintf("func_particlefield::do_use: "
- "returning early, getcount(other) %s, "
- "this.cnt %s\n", func_counter::getcount(other),
- this.cnt));
- */
- return;
- }
-
- if (this.field_direction == 1)
- this.particlefield_xy ();
- else if (this.field_direction == 2)
- this.particlefield_yz ();
- else if (this.field_direction == 3)
- this.particlefield_xz ();
- else
- dprint ("func_particlefield::do_use: invalid field "
- "direction!\n");
- };
-
- //--------------------------------------------------------------
- virtual void() init_spawned =
- {
- if (!this.color)
- this.color = 192;
-
- if (this.count == 0)
- this.count = 2;
-
- this.classname = "particlefield";
- this.solid = SOLID_NOT;
- this.movetype = MOVETYPE_NONE;
- setmodel (this, this.model);
- this.model = string_null;
-
- this.origin = (this.mins + this.maxs) * 0.5;
- setorigin (this, this.origin);
- this.dest = this.maxs - this.mins - '16 16 16';
- this.dest1 = this.mins + '8 8 8' - this.origin;
- this.dest2 = this.maxs + '7.9 7.9 7.9' - this.origin;
- setsize (this, this.mins, this.maxs);
-
- if (dest_x > dest_z)
- {
- if (dest_y > dest_z)
+ if (e.finaldest_y > e.finaldest_z)
{
- field_direction = 1;
- dest1_z = (dest1_z + dest2_z) / 2;
+ e.use = func_particlefield_xy;
+ e.pos1_z = (e.pos1_z + e.pos2_z) / 2;
}
else
{
- field_direction = 3;
- dest1_y = (dest1_y + dest2_y) / 2;
+ e.use = func_particlefield_xz;
+ e.pos1_y = (e.pos1_y + e.pos2_y) / 2;
}
}
else
{
- if (dest_y > dest_x)
+ if (e.finaldest_y > e.finaldest_x)
{
- field_direction = 2;
- dest1_x = (dest1_x + dest2_x) / 2;
+ e.use = func_particlefield_yz;
+ e.pos1_x = (e.pos1_x + e.pos2_x) / 2;
}
else
{
- field_direction = 3;
- dest1_y = (dest1_y + dest2_y) / 2;
+ e.use = func_particlefield_xz;
+ e.pos1_y = (e.pos1_y + e.pos2_y) / 2;
}
}

- if (this.noise != "")
- precache_sound (this.noise);
+ if (e.noise != "")
+ precache_sound (e.noise);

- this.ltime = time;
+ e.ltime = time;
};

//--------------------------------------------------------------
void() func_particlefield =
{
- this.classtype = CT_FUNC_PARTICLEFIELD;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ func_particlefield_init (self);
};
-};
+// };

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

Diff qc/func/plat.qc

diff --git a/qc/func/plat.qc b/qc/func/plat.qc
index ef1b6d6..9bc7bb6 100644
--- a/qc/func/plat.qc
+++ b/qc/func/plat.qc
@@ -2,100 +2,107 @@
// func_plat -- was plats.qc
//==============================================================================

+//======================================================================
// constants
+//======================================================================
+
const float PLAT_LOW_TRIGGER = 1;

+//======================================================================
+// forward declarations
+//======================================================================
+
+// temp_plat_trigger
+void() temp_plat_trigger_touch;
+entity(entity own) spawn_temp_plat_trigger;
+void(entity e) temp_plat_trigger_init;
+strip void() temp_plat_trigger;
+
+// func_plat
+void() func_plat_hit_top;
+void() func_plat_hit_bottom;
+void() func_plat_go_down;
+void() func_plat_go_up;
+void() func_plat_blocked;
+void() func_plat_use;
+void(entity e) func_plat_init;
+void() func_plat;
+
//------------------------------------------------------------------------------
-class temp_plat_trigger: base_tempentity
-{
+
+//----------------------------------------------------------------------
+// class temp_plat_trigger: base_tempentity
+// {
//--------------------------------------------------------------
- virtual void(entity toucher) do_touch =
+ void() temp_plat_trigger_touch =
{
// from Copper -- dumptruck_ds
- if (sub_checkvalidtouch(toucher) == FALSE)
+ if (sub_checkvalidtouch(other) == FALSE)
return;

- if (this.enemy.classtype != CT_FUNC_PLAT)
+ if (self.owner.classtype != CT_FUNC_PLAT)
return;

- // cast to func_plat -- CEV
- local func_plat fp = (func_plat)this.enemy;
-
- if (fp.state == FUNC_STATE_BOTTOM)
- fp.plat_go_up ();
- else if (fp.state == FUNC_STATE_TOP)
+ if (self.owner.state == FUNC_STATE_BOTTOM)
+ sub_runvoidas (self.owner, func_plat_go_up);
+ else if (self.owner.state == FUNC_STATE_TOP)
// delay going down
- fp.nextthink = fp.ltime + 1;
+ self.owner.nextthink = self.owner.ltime + 1;
};

- /*
- //--------------------------------------------------------------
- // this doesn't seem to be called from anywhere -- CEV
//--------------------------------------------------------------
- nonvirtual void() plat_outside_touch =
+ entity(entity own) spawn_temp_plat_trigger =
{
- // from Copper -- dumptruck_ds
- if (sub_checkvalidtouch(other) == FALSE)
- return;
-
- if (this.enemy.classtype != CT_FUNC_PLAT)
- return;
-
- // dprint ("plat_outside_touch\n");
-
- // cast to func_plat -- CEV
- local func_plat fp = (func_plat)this.enemy;
-
- if (fp.state == FUNC_STATE_TOP)
- fp.plat_go_down ();
+ local entity e = spawn ();
+ e.owner = own;
+ temp_plat_trigger_init (e);
+ return e;
};
- */

//--------------------------------------------------------------
- void() temp_plat_trigger =
+ void(entity e) temp_plat_trigger_init =
{
- this.classtype = CT_TEMP_PLAT_TRIGGER;
- this.movetype = MOVETYPE_NONE;
- this.solid = SOLID_TRIGGER;
+ e.classname = "temp_plat_trigger";
+ e.classtype = CT_TEMP_PLAT_TRIGGER;
+ base_tempentity_init (e);
+
+ e.movetype = MOVETYPE_NONE;
+ e.solid = SOLID_TRIGGER;
+ e.touch = temp_plat_trigger_touch;

- if (!this.enemy)
- objerror ("temp_plat_trigger has no linked plat!\n");
+ if (!e.owner)
+ objerror ("temp_plat_trigger_init: no linked plat!\n");

- if (this.enemy.classtype != CT_FUNC_PLAT)
+ if (e.owner.classtype != CT_FUNC_PLAT)
return;

- // cast to func_plat -- CEV
- local func_plat fp = (func_plat)this.enemy;
-
- // local vector tmin = fp.mins + '25 25 0';
- // local vector tmax = fp.maxs - '25 25 -8';
- local vector tmax = [fp.maxs_x - 25, fp.maxs_y - 25,
- fp.maxs_z - -8];
- local vector tmin = [fp.mins_x + 25, fp.mins_y + 25,
- tmax_z - (fp.pos1_z - fp.pos2_z + 8)];
- // tmin_z = tmax_z - (fp.pos1_z - fp.pos2_z + 8);
- if (fp.spawnflags & PLAT_LOW_TRIGGER)
+ local vector tmin = e.owner.mins + '25 25 0';
+ local vector tmax = e.owner.maxs - '25 25 -8';
+ tmin_z = tmax_z - (e.owner.pos1_z - e.owner.pos2_z + 8);
+ if (e.owner.spawnflags & PLAT_LOW_TRIGGER)
tmax_z = tmin_z + 8;

- if (fp.size_x <= 50)
+ if (e.owner.size_x <= 50)
{
- tmin_x = (fp.mins_x + fp.maxs_x) / 2;
+ tmin_x = (e.owner.mins_x + e.owner.maxs_x) / 2;
tmax_x = tmin_x + 1;
}

- if (fp.size_y <= 50)
+ if (e.owner.size_y <= 50)
{
- tmin_y = (fp.mins_y + fp.maxs_y) / 2;
+ tmin_y = (e.owner.mins_y + e.owner.maxs_y) / 2;
tmax_y = tmin_y + 1;
}

- setsize (this, tmin, tmax);
+ setsize (e, tmin, tmax);
+ };

- // TODO CEV this next line is here because class field
- // vectors are busted (why?)
- // setorigin (this, fp.pos2);
+ //--------------------------------------------------------------
+ strip void() temp_plat_trigger =
+ {
+ temp_plat_trigger_init (self);
};
-};
+// };

/*QUAKED func_plat (0 .5 .8) ? PLAT_LOW_TRIGGER X X X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY

@@ -110,207 +117,155 @@ Set "sounds" to one of the following:
1) base fast
2) chain slow
*/
-class func_plat: base_func
-{
- // class fields
- float height;
- /*
- vector pos1; // top position
- vector pos2; // bottom position
- */
-
- //--------------------------------------------------------------
- virtual void(string fieldname, string fieldvalue) init_field =
- {
- switch (fieldname)
- {
- case "height":
- this.height = stof (fieldvalue);
- break;
- default:
- super::init_field (fieldname, fieldvalue);
- }
- };
-
- //--------------------------------------------------------------
- /*
- nonvirtual void() plat_spawn_inside_trigger =
- {
- local entity trigger;
- local vector tmin, tmax;
-
- // middle trigger
- trigger = spawn (temp_plat_trigger, enemy: this);
-
- tmax = this.maxs - '25 25 -8';
- tmin = this.mins + '25 25 0';
- tmin.z = tmax.z - (this.pos1.z - this.pos2.z + 8);
- if (this.spawnflags & PLAT_LOW_TRIGGER)
- tmax = [tmax_x, tmax_y, tmin_z + 8];
-
- if (this.size_x <= 50)
- {
- tmin.x = (this.mins.x + this.maxs.x) / 2;
- tmax.x = tmin.x + 1;
- }
-
- if (this.size_y <= 50)
- {
- tmin.y = (this.mins.y + this.maxs.y) / 2;
- tmax.y = tmin.y + 1;
- }
-
- setsize (trigger, tmin, tmax);
- };
- */
-
+//----------------------------------------------------------------------
+// class func_plat: base_func
+// {
//--------------------------------------------------------------
- nonvirtual void() plat_hit_top =
+ void() func_plat_hit_top =
{
- sound (this, CHAN_VOICE, this.noise1, 1, ATTN_NORM);
- this.state = FUNC_STATE_TOP;
- this.nextthink = this.ltime + 3;
+ sound (self, CHAN_VOICE, self.noise1, 1, ATTN_NORM);
+ self.state = FUNC_STATE_TOP;
+ self.think = func_plat_go_down;
+ self.nextthink = self.ltime + 3;
};

//--------------------------------------------------------------
- nonvirtual void() plat_hit_bottom =
+ void() func_plat_hit_bottom =
{
- sound (this, CHAN_VOICE, this.noise1, 1, ATTN_NORM);
- this.state = FUNC_STATE_BOTTOM;
+ sound (self, CHAN_VOICE, self.noise1, 1, ATTN_NORM);
+ self.state = FUNC_STATE_BOTTOM;
};

//--------------------------------------------------------------
- nonvirtual void() plat_go_down =
+ void() func_plat_go_down =
{
- sound (this, CHAN_VOICE, this.noise, 1, ATTN_NORM);
- this.state = FUNC_STATE_DOWN;
- calc_move (this.pos2, this.speed, plat_hit_bottom);
+ sound (self, CHAN_VOICE, self.noise, 1, ATTN_NORM);
+ self.state = FUNC_STATE_DOWN;
+ sub_calcmove (self, self.pos2, self.speed,
+ func_plat_hit_bottom);
};

//--------------------------------------------------------------
- nonvirtual void() plat_go_up =
+ void() func_plat_go_up =
{
- sound (this, CHAN_VOICE, this.noise, 1, ATTN_NORM);
- this.state = FUNC_STATE_UP;
- calc_move (this.pos1, this.speed, plat_hit_top);
+ sound (self, CHAN_VOICE, self.noise, 1, ATTN_NORM);
+ self.state = FUNC_STATE_UP;
+ sub_calcmove (self, self.pos1, self.speed, func_plat_hit_top);
};

//--------------------------------------------------------------
- virtual void(entity blocker) do_blocked =
+ void() func_plat_blocked =
{
- this.t_damage2 (blocker, this, this, 1);
+ t_damage2 (other, self, self, 1);

- if (this.state == FUNC_STATE_UP)
- plat_go_down ();
- else if (this.state == FUNC_STATE_DOWN)
- plat_go_up ();
+ if (self.state == FUNC_STATE_UP)
+ func_plat_go_down ();
+ else if (self.state == FUNC_STATE_DOWN)
+ func_plat_go_up ();
else
- objerror ("plat_crush: bad this.state\n");
- };
-
- //--------------------------------------------------------------
- virtual void() do_think =
- {
- if (this.state == FUNC_STATE_TOP)
- this.plat_go_down ();
+ objerror ("func_plat_blocked: bad self.state\n");
};

//--------------------------------------------------------------
- virtual void(entity caller) do_use =
+ void() func_plat_use =
{
- if (this.interaction_flags & DISABLE_USE)
- return;
+ self.use = sub_null;

- if (this.targetname != "")
+ if (self.targetname != "")
{
- this.interaction_flags |= DISABLE_USE;
- if (this.state != FUNC_STATE_UP)
- objerror ("plat_use: not in up state");
- plat_go_down ();
+ if (self.state != FUNC_STATE_UP)
+ objerror ("func_plat_use: not in up state\n");
+ func_plat_go_down ();
}
else
{
- if (this.think)
- // allready activated
+ if (self.think)
+ // already activated
return;

- plat_go_down ();
+ func_plat_go_down ();
}
};

//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) func_plat_init =
{
- this.interaction_flags = 0;
+ e.classname = "plat";
+ e.classtype = CT_FUNC_PLAT;
+ base_func_init (e);

- if (!this.t_length)
- this.t_length = 80;
- if (!this.t_width)
- this.t_width = 10;
+ if (!e.t_length)
+ e.t_length = 80;
+ if (!e.t_width)
+ e.t_width = 10;

- if (this.sounds == 0)
- this.sounds = 2;
- // FIX THIS TO LOAD A GENERIC PLAT SOUND
+ if (e.sounds == 0)
+ e.sounds = 2;

- if (this.sounds == 1)
+ // FIX THIS TO LOAD A GENERIC PLAT SOUND
+ if (e.sounds == 1)
{
precache_sound ("plats/plat1.wav");
precache_sound ("plats/plat2.wav");
- this.noise = "plats/plat1.wav";
- this.noise1 = "plats/plat2.wav";
+ e.noise = "plats/plat1.wav";
+ e.noise1 = "plats/plat2.wav";
}

- if (this.sounds == 2)
+ if (e.sounds == 2)
{
precache_sound ("plats/medplat1.wav");
precache_sound ("plats/medplat2.wav");
- this.noise = "plats/medplat1.wav";
- this.noise1 = "plats/medplat2.wav";
+ e.noise = "plats/medplat1.wav";
+ e.noise1 = "plats/medplat2.wav";
}

- this.mangle = this.angles;
- this.angles = '0 0 0';
+ e.mangle = e.angles;
+ e.angles = '0 0 0';

- this.classname = "plat";
- this.solid = SOLID_BSP;
- this.movetype = MOVETYPE_PUSH;
- setorigin (this, this.origin);
- setmodel (this, this.model);
- setsize (this, this.mins , this.maxs);
+ e.solid = SOLID_BSP;
+ e.movetype = MOVETYPE_PUSH;
+ setorigin (e, e.origin);
+ setmodel (e, e.model);
+ setsize (e, e.mins , e.maxs);

- if (!this.speed)
- this.speed = 150;
+ e.blocked = func_plat_blocked;
+ e.use = func_plat_use;
+
+ if (!e.speed)
+ e.speed = 150;

// pos1 is the top position, pos2 is the bottom
- this.pos1 = [this.origin_x, this.origin_y, this.origin_z];
- if (this.height)
- this.pos2 = [this.origin_x, this.origin_y,
- this.origin_z - this.height];
+ e.pos1 = e.origin;
+ e.pos2 = e.origin;
+ if (e.height)
+ e.pos2_z = e.origin_z - e.height;
else
- this.pos2 = [this.origin_x, this.origin_y,
- this.origin_z - this.size_z + 8];
+ e.pos2_z = e.origin_z - e.size_z + 8;

- dprint (sprintf("func_plat::init_spawned: pos1 %v, pos2 %v, "
- "origin %v\n", this.pos1, this.pos2, this.origin));
+ dprint (sprintf("func_plat_init: pos1 %v, pos2 %v, "
+ "origin %v\n", e.pos1, e.pos2, e.origin));

// the "start moving" trigger
- // plat_spawn_inside_trigger ();
- spawn (temp_plat_trigger, enemy: this);
+ spawn_temp_plat_trigger (e);

- if (this.targetname != "")
+ if (e.targetname != "")
{
- this.state = FUNC_STATE_UP;
+ e.state = FUNC_STATE_UP;
}
else
{
- setorigin (this, this.pos2);
- this.state = FUNC_STATE_BOTTOM;
+ setorigin (e, e.pos2);
+ e.state = FUNC_STATE_BOTTOM;
}
};

//--------------------------------------------------------------
void() func_plat =
{
- this.classtype = CT_FUNC_PLAT;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ func_plat_init (self);
};
-};
+// };

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

Diff qc/func/rotate.qc

diff --git a/qc/func/rotate.qc b/qc/func/rotate.qc
index ad22433..da460b1 100644
--- a/qc/func/rotate.qc
+++ b/qc/func/rotate.qc
@@ -2,15 +2,18 @@
// func_movewall, func_rotate_door, func_rotate_entity, func_rotate_train
//==============================================================================

-//======================================================================
+//----------------------------------------------------------------------
// Rotate QuickC program
// By Jim Dose' 10/17/96
// Copyright (c)1996 Hipnotic Interactive, Inc.
// All rights reserved.
// Distributed (unsupported) on 3.12.97
-//======================================================================
+//----------------------------------------------------------------------

+//======================================================================
// constants
+//======================================================================
+
const float ROTATE_STATE_ACTIVE = 0;
const float ROTATE_STATE_INACTIVE = 1;
const float ROTATE_STATE_SPEEDINGUP = 2;
@@ -48,67 +51,88 @@ const float MOVEWALL_VISIBLE = 1; // spawnflags for func_movewall
const float MOVEWALL_TOUCH = 2;
const float MOVEWALL_NONBLOCKING = 4;

-//------------------------------------------------------------------------------
-class base_rotate: base_func
-{
- // class fields
- float duration;
- float endtime;
- float rotate_type;
+//======================================================================
+// fields
+//======================================================================

- vector finalangle;
- vector neworigin;
- vector rotate;
+.float duration;
+.float endtime;
+.float rotate_type;

- vector dest;
- vector dest1;
- vector dest2;
+.vector neworigin;
+.vector rotate;

- string event;
- string group;
- string path;
+.string event;
+.string group;
+.string path;

- //--------------------------------------------------------------
- virtual void(string fieldname, string fieldvalue) init_field =
- {
- switch (fieldname)
- {
- case "duration":
- duration = stof (fieldvalue);
- break;
- case "endtime":
- endtime = stof (fieldvalue);
- break;
- case "rotate_type":
- rotate_type = stof (fieldvalue);
- break;
- case "finalangle":
- finalangle = stov (fieldvalue);
- break;
- case "neworigin":
- neworigin = stov (fieldvalue);
- break;
- case "rotate":
- rotate = stov (fieldvalue);
- break;
- case "event":
- event = fieldvalue;
- break;
- case "group":
- group = fieldvalue;
- break;
- case "path":
- path = fieldvalue;
- break;
- default:
- super::init_field (fieldname, fieldvalue);
- }
- };
+//======================================================================
+// forward declarations
+//======================================================================

+// base_rotate
+vector(vector ang) base_rotate_normalizeangles;
+void() base_rotate_targets;
+void() base_rotate_targets_final;
+void() base_rotate_set_target_origin;
+void() base_rotate_link_targets;
+void(float amount) base_rotate_set_damage_on_targets;
+void(entity e) base_rotate_init;
+strip void() base_rotate;
+
+// rotate_object
+void(entity e) rotate_object_init
+void() rotate_object;
+
+// func_rotate_entity
+void() func_rotate_entity_firstthink;
+void() func_rotate_entity_think;
+void() func_rotate_entity_use;
+void(entity e) func_rotate_entity_init;
+void() func_rotate_entity;
+
+// path_rotate
+void(entity e) path_rotate_init;
+void() path_rotate;
+
+// func_rotate_train
+void() func_rotate_train_think_wait;
+void() func_rotate_train_think_stop;
+void() func_rotate_train_think_next;
+void() func_rotate_train_think_find;
+void() func_rotate_train_think;
+void() func_rotate_train_use;
+void(entity e) func_rotate_train_init;
+void() func_rotate_train;
+
+// rotate_train
+void() rotate_train;
+
+// func_movewall
+void() func_movewall_touch;
+void() func_movewall_blocked;
+void() func_movewall_think;
+void(entity e) func_movewall_init;
+void() func_movewall;
+
+// func_rotate_door
+void() func_rotate_door_reversedirection;
+void() func_rotate_door_group_reversedirection;
+void() func_rotate_door_think;
+void() func_rotate_door_think2;
+void() func_rotate_door_use;
+void(entity e) func_rotate_door_init;
+void() func_rotate_door;
+
+//------------------------------------------------------------------------------
+
+//----------------------------------------------------------------------
+// class base_rotate: base_func
+// {
//--------------------------------------------------------------
// SUB_NormalizeAngles
//--------------------------------------------------------------
- static vector(vector ang) normalizeangles =
+ vector(vector ang) base_rotate_normalizeangles =
{
while (ang_x > 360)
ang_x = ang_x - 360;
@@ -127,241 +151,235 @@ class base_rotate: base_func
};

//--------------------------------------------------------------
- nonvirtual void() rotate_targets =
+ void() base_rotate_targets =
{
local vector org, vx, vy, vz;
- local entity ent;
- local base_rotate rot;
+ local entity e;

- makevectors (this.angles);
+ makevectors (self.angles);

- ent = find (world, ::targetname, this.target);
+ e = find (world, targetname, self.target);

- while (ent)
+ while (e)
{
- if (!(ent.classgroup & CG_FUNC_ROTATE))
+ if (!(e.classgroup & CG_FUNC_ROTATE))
{
- dprint (sprintf("rotate_targets: found "
+ dprint (sprintf("base_rotate_targets: found "
"unhandled class %s, targetname %s\n",
- ent.classname, ent.targetname));
- ent = find (ent, ::targetname, this.target);
+ e.classname, e.targetname));
+ e = find (e, targetname, self.target);
continue;
}

- // cast to base_rotate -- CEV
- rot = (base_rotate)ent;
-
- if (rot.rotate_type == ROTATE_OBJECT_SETORIGIN)
+ if (e.rotate_type == ROTATE_OBJECT_SETORIGIN)
{
- org = rot.oldorigin;
+ org = e.oldorigin;
vx = (v_forward * org_x);
vy = (v_right * org_y);
vy = vy * -1;
vz = (v_up * org_z);
- rot.neworigin = vx + vy + vz;
- setorigin (rot, rot.neworigin + this.origin);
+ e.neworigin = vx + vy + vz;
+ setorigin (e, e.neworigin + self.origin);
}
- else if (rot.rotate_type == ROTATE_OBJECT_ROTATE)
+ else if (e.rotate_type == ROTATE_OBJECT_ROTATE)
{
- rot.angles = this.angles;
- org = rot.oldorigin;
+ e.angles = self.angles;
+ org = e.oldorigin;
vx = (v_forward * org_x);
vy = (v_right * org_y);
vy = vy * -1;
vz = (v_up * org_z);
- rot.neworigin = vx + vy + vz;
- setorigin (rot, rot.neworigin + this.origin);
+ e.neworigin = vx + vy + vz;
+ setorigin (e, e.neworigin + self.origin);
}
else
{
- org = rot.oldorigin;
+ org = e.oldorigin;
vx = (v_forward * org_x);
vy = (v_right * org_y);
vy = vy * -1;
vz = (v_up * org_z);
- rot.neworigin = vx + vy + vz;
- rot.neworigin = this.origin - this.oldorigin +
- (rot.neworigin - rot.oldorigin);
- rot.velocity = (rot.neworigin - rot.origin) * 25;
+ e.neworigin = vx + vy + vz;
+ e.neworigin = self.origin - self.oldorigin +
+ (e.neworigin - e.oldorigin);
+ e.velocity = (e.neworigin - e.origin) * 25;
}
- ent = find (ent, ::targetname, this.target);
+ e = find (e, targetname, self.target);
}
};

//--------------------------------------------------------------
- nonvirtual void() rotate_targets_final =
+ void() base_rotate_targets_final =
{
- local entity ent;
- local base_rotate rot;
+ local entity e;

- ent = find (world, ::targetname, this.target);
+ e = find (world, targetname, self.target);

- while (ent)
+ while (e)
{
- if (!(ent.classgroup & CG_FUNC_ROTATE))
+ if (!(e.classgroup & CG_FUNC_ROTATE))
{
- dprint (sprintf("rotate_targets_final: found "
- "unhandled class %s, targetname %s\n",
- ent.classname, ent.targetname));
- ent = find (ent, ::targetname, this.target);
+ dprint (sprintf("base_rotate_targets_final: "
+ "found unhandled class %s, "
+ "targetname %s\n",
+ e.classname, e.targetname));
+ e = find (e, targetname, self.target);
continue;
}

- // cast to base_rotate -- CEV
- rot = (base_rotate)ent;
+ e.velocity = '0 0 0';

- rot.velocity = '0 0 0';
- if (rot.rotate_type == ROTATE_OBJECT_ROTATE)
- {
- rot.angles = this.angles;
- }
+ if (e.rotate_type == ROTATE_OBJECT_ROTATE)
+ e.angles = self.angles;

- ent = find (ent, ::targetname, this.target);
+ e = find (e, targetname, self.target);
}
};

//--------------------------------------------------------------
- nonvirtual void() set_target_origin =
+ void() base_rotate_set_target_origin =
{
- local entity ent;
- local base_rotate rot;
+ local entity e;

- ent = find (world, ::targetname, this.target);
+ e = find (world, targetname, self.target);

- while (ent)
+ while (e)
{
- if (!(ent.classgroup & CG_FUNC_ROTATE))
+ if (!(e.classgroup & CG_FUNC_ROTATE))
{
- dprint (sprintf("rotate_targets_final: found "
- "unhandled class %s, targetname %s\n",
- ent.classname, ent.targetname));
- ent = find (ent, ::targetname, this.target);
+ dprint (sprintf("base_rotate_set_target_origin"
+ ": found unhandled class %s, "
+ "targetname %s\n",
+ e.classname, e.targetname));
+ e = find (e, targetname, self.target);
continue;
}

- // cast to base_rotate -- CEV
- rot = (base_rotate)ent;
-
- if (rot.rotate_type == ROTATE_OBJECT_MOVEWALL)
+ if (e.rotate_type == ROTATE_OBJECT_MOVEWALL)
{
- setorigin (rot, this.origin - this.oldorigin +
- (rot.neworigin - rot.oldorigin));
+ setorigin (e, self.origin - self.oldorigin +
+ (e.neworigin - e.oldorigin));
}
else
{
- setorigin (rot, rot.neworigin + this.origin);
+ setorigin (e, e.neworigin + self.origin);
}

- ent = find (ent, ::targetname, this.target);
+ e = find (e, targetname, self.target);
}
};

//--------------------------------------------------------------
- nonvirtual void() link_rotate_targets =
+ void() base_rotate_link_targets =
{
- local base_rotate rot;
- local entity ent;
+ local entity e;
local vector tempvec;

- this.oldorigin = this.origin;
- ent = find (world, ::targetname, this.target);
+ self.oldorigin = self.origin;
+ e = find (world, targetname, self.target);

- while (ent)
+ while (e)
{
- if (ent.classtype == CT_MISC_ROTATE_OBJECT)
+ if (e.classtype == CT_MISC_ROTATE_OBJECT)
{
- // cast to base_rotate -- CEV
- rot = (base_rotate)ent;
- rot.rotate_type = ROTATE_OBJECT_ROTATE;
- rot.oldorigin = rot.origin - this.oldorigin;
- rot.neworigin = rot.origin - this.oldorigin;
- rot.owner = this;
+ e.rotate_type = ROTATE_OBJECT_ROTATE;
+ e.oldorigin = e.origin - self.oldorigin;
+ e.neworigin = e.origin - self.oldorigin;
+ e.owner = self;
}
- else if (ent.classtype == CT_FUNC_MOVEWALL)
+ else if (e.classtype == CT_FUNC_MOVEWALL)
{
- // cast to base_rotate -- CEV
- rot = (base_rotate)ent;
- rot.rotate_type = ROTATE_OBJECT_MOVEWALL;
- tempvec = (rot.absmin + rot.absmax) * 0.5;
- rot.oldorigin = tempvec - this.oldorigin;
- rot.neworigin = rot.oldorigin;
- rot.owner = this;
+ e.rotate_type = ROTATE_OBJECT_MOVEWALL;
+ tempvec = (e.absmin + e.absmax) * 0.5;
+ e.oldorigin = tempvec - self.oldorigin;
+ e.neworigin = e.oldorigin;
+ e.owner = self;
}
- else if (ent.classgroup & CG_FUNC_ROTATE)
+ else if (e.classgroup & CG_FUNC_ROTATE)
{
- // cast to base_rotate -- CEV
- rot = (base_rotate)ent;
- rot.rotate_type = ROTATE_OBJECT_SETORIGIN;
- rot.oldorigin = rot.origin - this.oldorigin;
- rot.neworigin = rot.origin - this.oldorigin;
+ e.rotate_type = ROTATE_OBJECT_SETORIGIN;
+ e.oldorigin = e.origin - self.oldorigin;
+ e.neworigin = e.origin - self.oldorigin;
}
else
{
- dprint (sprintf("link_rotate_targets: found an "
- "unsupported class %s, targetname %s\n",
- ent.classname, ent.targetname));
+ dprint (sprintf("base_rotate_link_targets: "
+ "found an unsupported class %s, "
+ "targetname %s\n",
+ e.classname, e.targetname));
}
- ent = find (ent, ::targetname, this.target);
+ e = find (e, targetname, self.target);
}
};

//--------------------------------------------------------------
- nonvirtual void(float amount) set_damage_on_targets =
+ void(float amount) base_rotate_set_damage_on_targets =
{
- local entity ent;
+ local entity e;

- ent = find (world, ::targetname, this.target);
+ e = find (world, targetname, self.target);

- while (ent)
+ while (e)
{
- if (ent.classtype == CT_TRIGGER_HURT)
- {
- // cast to trigger_hurt -- CEV
- local trigger_hurt t = (trigger_hurt)ent;
- t.setdamage (t, amount);
- }
- else if (ent.classtype == CT_FUNC_MOVEWALL)
- {
- ent.dmg = amount;
- }
- ent = find (ent, ::targetname, this.target);
+ if (e.classtype == CT_TRIGGER_HURT)
+ trigger_hurt_setdamage (e, amount);
+ else if (e.classtype == CT_FUNC_MOVEWALL)
+ e.dmg = amount;
+
+ e = find (e, targetname, self.target);
}
};

//--------------------------------------------------------------
- void() base_rotate =
+ void(entity e) base_rotate_init =
{
- this.classgroup |= CG_FUNC_ROTATE;
+ e.classgroup |= CG_FUNC_ROTATE;
+
+ base_func_init (e);
};
-};
+
+ //--------------------------------------------------------------
+ strip void() base_rotate =
+ {
+ base_rotate_init (self);
+ };
+// };

/*QUAKED rotate_object (0 .5 .8) ? X X X X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
This defines an object to be rotated. Used as the target of func_rotate_door.
*/
-class rotate_object: base_rotate
-{
+//----------------------------------------------------------------------
+// class rotate_object: base_rotate
+// {
//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) rotate_object_init =
{
- this.solid = SOLID_NOT;
- this.movetype = MOVETYPE_NONE;
- setmodel (this, this.model);
- setsize (this, this.mins, this.maxs);
- this.interaction_flags |= DISABLE_THINK;
+ e.classname = "rotate_object";
+ e.classtype = CT_MISC_ROTATE_OBJECT;
+
+ base_rotate_init (e);
+
+ e.solid = SOLID_NOT;
+ e.movetype = MOVETYPE_NONE;
+ setmodel (e, e.model);
+ setsize (e, e.mins, e.maxs);
+ // e.think = sub_null;
};

//--------------------------------------------------------------
void() rotate_object =
{
- this.classname = "rotate_object";
- this.classtype = CT_MISC_ROTATE_OBJECT;
- };
-};
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;

+ rotate_object_init (self);
+ };
+// };

-//------------------------------------------------------------------------------
+//----------------------------------------------------------------------
// Simple continual rotatation
-//------------------------------------------------------------------------------
+//----------------------------------------------------------------------

/*QUAKED func_rotate_entity (0 .5 .8) (-8 -8 -8) (8 8 8) TOGGLE START_ON X X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY

@@ -378,161 +396,154 @@ If "deathtype" is set with a string, this is the message that will appear when a
"target" is the center of rotation.
"speed" is how long the entity takes to go from standing still to full speed and vice-versa.
*/
-class func_rotate_entity: base_rotate
-{
- float count;
- float firstthink;
-
- //--------------------------------------------------------------
- virtual void(string fieldname, string fieldvalue) init_field =
+//----------------------------------------------------------------------
+// class func_rotate_entity: base_rotate
+// {
+ //--------------------------------------------------------------
+ void() func_rotate_entity_firstthink =
{
- switch (fieldname)
+ base_rotate_link_targets ();
+
+ if (self.spawnflags & ROTATE_ENTITY_START_ON)
+ {
+ self.state = ROTATE_STATE_ACTIVE;
+ self.think = func_rotate_entity_think;
+ self.nextthink = time + 0.02;
+ self.ltime = time;
+ }
+ else
{
- case "count":
- count = stof (fieldvalue);
- break;
- default:
- super::init_field (fieldname, fieldvalue);
+ self.state = ROTATE_STATE_INACTIVE;
+ self.think = sub_null;
}
+
+ self.use = func_rotate_entity_use;
};

//--------------------------------------------------------------
- virtual void() do_think =
+ void() func_rotate_entity_think =
{
- if (this.firstthink)
- {
- // was rotate_entity_firstthink
- this.firstthink = FALSE;
- link_rotate_targets ();
- if (this.spawnflags & ROTATE_ENTITY_START_ON)
- {
- this.state = ROTATE_STATE_ACTIVE;
- this.interaction_flags &= ~DISABLE_THINK;
- this.nextthink = time + 0.02;
- this.ltime = time;
- }
- else
- {
- this.state = ROTATE_STATE_INACTIVE;
- this.interaction_flags |= DISABLE_THINK;
- }
- }
- else
- {
- // was rotate_entity_think -- CEV
- local float t;
+ local float t;

- t = time - this.ltime;
- this.ltime = time;
+ t = time - self.ltime;
+ self.ltime = time;

- if (this.state == ROTATE_STATE_SPEEDINGUP)
- {
- this.count = this.count + this.cnt * t;
- if (this.count > 1)
- this.count = 1;
+ if (self.state == ROTATE_STATE_SPEEDINGUP)
+ {
+ self.count = self.count + self.cnt * t;
+ if (self.count > 1)
+ self.count = 1;

- // get rate of rotation
- t = t * this.count;
- }
- else if (this.state == ROTATE_STATE_SLOWINGDOWN)
+ // get rate of rotation
+ t = t * self.count;
+ }
+ else if (self.state == ROTATE_STATE_SLOWINGDOWN)
+ {
+ self.count = self.count - self.cnt * t;
+ if (self.count < 0)
{
- this.count = this.count - this.cnt * t;
- if (this.count < 0)
- {
- rotate_targets_final ();
- this.state = ROTATE_STATE_INACTIVE;
- this.interaction_flags |= DISABLE_THINK;
- return;
- }
-
- // get rate of rotation
- t = t * this.count;
+ base_rotate_targets_final ();
+ self.state = ROTATE_STATE_INACTIVE;
+ self.think = sub_null;
+ return;
}

- this.angles = this.angles + (this.rotate * t);
- this.angles = normalizeangles (this.angles);
- rotate_targets ();
- this.nextthink = time + 0.02;
+ // get rate of rotation
+ t = t * self.count;
}
+
+ self.angles = self.angles + (self.rotate * t);
+ self.angles = base_rotate_normalizeangles (self.angles);
+ base_rotate_targets ();
+ self.nextthink = time + 0.02;
};

//--------------------------------------------------------------
- virtual void(entity caller) do_use =
+ void() func_rotate_entity_use =
{
// change to alternate textures
- this.frame = 1 - this.frame;
+ self.frame = 1 - self.frame;

- if (this.state == ROTATE_STATE_ACTIVE)
+ if (self.state == ROTATE_STATE_ACTIVE)
{
- if (this.spawnflags & ROTATE_ENTITY_TOGGLE)
+ if (self.spawnflags & ROTATE_ENTITY_TOGGLE)
{
- if (this.speed)
+ if (self.speed)
{
- this.count = 1;
- this.state = ROTATE_STATE_SLOWINGDOWN;
+ self.count = 1;
+ self.state = ROTATE_STATE_SLOWINGDOWN;
}
else
{
- this.state = ROTATE_STATE_INACTIVE;
- this.interaction_flags |= DISABLE_THINK;
+ self.state = ROTATE_STATE_INACTIVE;
+ self.think = sub_null;
}
}
}
- else if (this.state == ROTATE_STATE_INACTIVE)
+ else if (self.state == ROTATE_STATE_INACTIVE)
{
- this.interaction_flags &= ~DISABLE_THINK;
- this.firstthink = FALSE;
- this.nextthink = time + 0.02;
- this.ltime = time;
- if (this.speed)
+ self.think = func_rotate_entity_think;
+ self.nextthink = time + 0.02;
+ self.ltime = time;
+ if (self.speed)
{
- this.count = 0;
- this.state = ROTATE_STATE_SPEEDINGUP;
+ self.count = 0;
+ self.state = ROTATE_STATE_SPEEDINGUP;
}
else
{
- this.state = ROTATE_STATE_ACTIVE;
+ self.state = ROTATE_STATE_ACTIVE;
}
}
- else if (this.state == ROTATE_STATE_SPEEDINGUP)
+ else if (self.state == ROTATE_STATE_SPEEDINGUP)
{
- if (this.spawnflags & ROTATE_ENTITY_TOGGLE)
+ if (self.spawnflags & ROTATE_ENTITY_TOGGLE)
{
- this.state = ROTATE_STATE_SLOWINGDOWN;
+ self.state = ROTATE_STATE_SLOWINGDOWN;
}
}
else
{
- this.state = ROTATE_STATE_SPEEDINGUP;
+ self.state = ROTATE_STATE_SPEEDINGUP;
}
};

- virtual void() init_spawned =
+ //--------------------------------------------------------------
+ void(entity e) func_rotate_entity_init =
{
- this.solid = SOLID_NOT;
- this.movetype = MOVETYPE_NONE;
+ e.classname = "func_rotate_entity";
+ e.classtype = CT_FUNC_ROTATE_ENTITY;
+
+ base_rotate_init (e);

- setmodel (this, this.model);
- setsize (this, this.mins, this.maxs);
+ e.solid = SOLID_NOT;
+ e.movetype = MOVETYPE_NONE;

- if (this.speed != 0)
- this.cnt = 1 / this.speed;
+ setmodel (e, e.model);
+ setsize (e, e.mins, e.maxs);

- this.firstthink = TRUE;
- this.nextthink = time + 0.1;
- this.ltime = time;
+ if (e.speed != 0)
+ e.cnt = 1 / e.speed;
+
+ e.think = func_rotate_entity_firstthink;
+ e.nextthink = time + 0.1;
+ e.ltime = time;
};

//--------------------------------------------------------------
void() func_rotate_entity =
{
- this.classtype = CT_FUNC_ROTATE_ENTITY;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ func_rotate_entity_init (self);
};
-};
+// };

-//------------------------------------------------------------------------------
+//----------------------------------------------------------------------
// Train with rotation functionality
-//------------------------------------------------------------------------------
+//----------------------------------------------------------------------

/*QUAKED path_rotate (0.5 0.3 0) (-8 -8 -8) (8 8 8) ROTATION ANGLES STOP NO_ROTATE DAMAGE MOVETIME SET_DAMAGE
Path for rotate_train.
@@ -555,27 +566,33 @@ class func_rotate_entity: base_rotate
"noise1" contains the name of the sound to play when train moves.
"event" is a target to trigger when train arrives at path_rotate.
*/
-class path_rotate: base_rotate
-{
+//----------------------------------------------------------------------
+// class path_rotate: base_rotate
+// {
//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) path_rotate_init =
{
- if (this.noise != "")
- {
- precache_sound (this.noise);
- }
- if (this.noise1 != "")
- {
- precache_sound (this.noise1);
- }
+ e.classname = "path_rotate";
+ e.classtype = CT_PATH_ROTATE;
+
+ base_rotate_init (e);
+
+ if (e.noise != "")
+ precache_sound (e.noise);
+ if (e.noise1 != "")
+ precache_sound (e.noise1);
};

//--------------------------------------------------------------
void() path_rotate =
{
- this.classtype = CT_PATH_ROTATE;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ path_rotate_init (self);
};
-};
+// };

/*QUAKED func_rotate_train (0 .5 .8) (-8 -8 -8) (8 8 8) X X X X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY

@@ -605,188 +622,159 @@ dmg default 0
sounds
1) ratchet metal
*/
-class func_rotate_train: base_rotate
-{
- base_rotate goal_rotate;
-
+//----------------------------------------------------------------------
+// class func_rotate_train: base_rotate
+// {
//--------------------------------------------------------------
- nonvirtual void() rotate_train_wait =
+ void() func_rotate_train_think_wait =
{
- this.state = ROTATE_STATE_WAIT;
+ self.state = ROTATE_STATE_WAIT;

- if (this.goal_rotate.noise != "")
- {
- sound (this, CHAN_VOICE, this.goal_rotate.noise,
+ if (self.goalentity.noise != "")
+ sound (self, CHAN_VOICE, self.goalentity.noise,
1, ATTN_NORM);
- }
else
- {
- sound (this, CHAN_VOICE, this.noise, 1, ATTN_NORM);
- }
+ sound (self, CHAN_VOICE, self.noise, 1, ATTN_NORM);

- if (this.goal_rotate.spawnflags & PATH_ROTATE_ANGLES)
+ if (self.goalentity.spawnflags & PATH_ROTATE_ANGLES)
{
- this.rotate = '0 0 0';
- this.angles = this.finalangle;
+ self.rotate = '0 0 0';
+ self.angles = self.finalangle;
}

- if (this.goal_rotate.spawnflags & PATH_ROTATE_NO_ROTATE)
- {
- this.rotate = '0 0 0';
- }
+ if (self.goalentity.spawnflags & PATH_ROTATE_NO_ROTATE)
+ self.rotate = '0 0 0';

- this.endtime = this.ltime + this.goal_rotate.wait;
- // TODO CEV
- this.think1 = rotate_train_next;
+ self.endtime = self.ltime + self.goalentity.wait;
+ self.think1 = func_rotate_train_think_next;
};

//--------------------------------------------------------------
- nonvirtual void() rotate_train_stop =
+ void() func_rotate_train_think_stop =
{
- this.state = ROTATE_STATE_STOP;
+ self.state = ROTATE_STATE_STOP;

- if (this.goal_rotate.noise != "")
- {
- sound (this, CHAN_VOICE, this.goal_rotate.noise,
+ if (self.goalentity.noise != "")
+ sound (self, CHAN_VOICE, self.goalentity.noise,
1, ATTN_NORM);
- }
else
- {
- sound (this, CHAN_VOICE, this.noise, 1, ATTN_NORM);
- }
+ sound (self, CHAN_VOICE, self.noise, 1, ATTN_NORM);

- if (this.goal_rotate.spawnflags & PATH_ROTATE_ANGLES)
+ if (self.goalentity.spawnflags & PATH_ROTATE_ANGLES)
{
- this.rotate = '0 0 0';
- this.angles = this.finalangle;
+ self.rotate = '0 0 0';
+ self.angles = self.finalangle;
}

- if (this.goal_rotate.spawnflags & PATH_ROTATE_NO_ROTATE)
- {
- this.rotate = '0 0 0';
- }
+ if (self.goalentity.spawnflags & PATH_ROTATE_NO_ROTATE)
+ self.rotate = '0 0 0';

- this.dmg = 0;
- // TODO CEV
- this.think1 = rotate_train_next;
+ self.dmg = 0;
+ self.think1 = func_rotate_train_think_next;
};

//--------------------------------------------------------------
- nonvirtual void() rotate_train_next =
+ void() func_rotate_train_think_next =
{
- local base_rotate current;
- local base_rotate targ_rotate;
+ local entity current;
local entity targ;
local vector vdestdelta;
local float len, traveltime, div;
local string temp;

- this.state = ROTATE_STATE_NEXT;
+ self.state = ROTATE_STATE_NEXT;

- current = this.goal_rotate;
- targ = find (world, ::targetname, this.path);
+ current = self.goalentity;
+ targ = find (world, targetname, self.path);
if (targ.classtype != CT_PATH_ROTATE)
- objerror ("Next target is not path_rotate");
-
- // cast to path_rotate -- CEV
- targ_rotate = (path_rotate)targ;
-
- if (this.goal_rotate.noise1 != "")
- {
- this.noise1 = this.goal_rotate.noise1;
- }
- sound (this, CHAN_VOICE, this.noise1, 1, ATTN_NORM);
-
- this.goal_rotate = targ_rotate;
- this.path = targ.target;
- if (!this.path )
- objerror ("rotate_train_next: no next target");
-
- if (targ_rotate.spawnflags & PATH_ROTATE_STOP)
- {
- // TODO CEV
- this.think1 = rotate_train_stop;
- }
- else if (targ_rotate.wait)
- {
- // TODO CEV
- this.think1 = rotate_train_wait;
- }
+ objerror ("func_rotate_train_think_next: "
+ "Next target is not path_rotate!\n");
+
+ if (self.goalentity.noise1 != "")
+ self.noise1 = self.goalentity.noise1;
+ sound (self, CHAN_VOICE, self.noise1, 1, ATTN_NORM);
+
+ self.goalentity = targ;
+ self.path = targ.target;
+ if (!self.path )
+ objerror ("func_rotate_train_think_next: "
+ "no next target!\n");
+
+ if (targ.spawnflags & PATH_ROTATE_STOP)
+ self.think1 = func_rotate_train_think_stop;
+ else if (targ.wait)
+ self.think1 = func_rotate_train_think_wait;
else
- {
- // TODO CEV
- this.think1 = rotate_train_next;
- }
+ self.think1 = func_rotate_train_think_next;

if (current.event != "")
{
// Trigger any events that should happen at the corner.
- temp = this.target;
- this.target = current.event;
- this.message = current.message;
+ temp = self.target;
+ self.target = current.event;
+ self.message = current.message;
sub_usetargets ();
- this.target = temp;
- this.message = string_null;
+ self.target = temp;
+ self.message = __NULL__;
}

if (current.spawnflags & PATH_ROTATE_ANGLES)
{
- this.rotate = '0 0 0';
- this.angles = this.finalangle;
+ self.rotate = '0 0 0';
+ self.angles = self.finalangle;
}

if (current.spawnflags & PATH_ROTATE_ROTATION)
{
- this.rotate = current.rotate;
+ self.rotate = current.rotate;
}

if (current.spawnflags & PATH_ROTATE_DAMAGE)
{
- this.dmg = current.dmg;
+ self.dmg = current.dmg;
}

if (current.spawnflags & PATH_ROTATE_SET_DAMAGE)
{
- set_damage_on_targets (current.dmg);
+ base_rotate_set_damage_on_targets (current.dmg);
}

if (current.speed == -1)
{
// Warp to the next path_corner
- setorigin (this, targ_rotate.origin);
- this.endtime = this.ltime + 0.01;
- set_target_origin ();
+ setorigin (self, targ.origin);
+ self.endtime = self.ltime + 0.01;
+ base_rotate_set_target_origin ();

- if (targ_rotate.spawnflags & PATH_ROTATE_ANGLES)
- {
- this.angles = targ_rotate.angles;
- }
+ if (targ.spawnflags & PATH_ROTATE_ANGLES)
+ self.angles = targ.angles;

- this.duration = 1; // 1 / duration
- this.cnt = time; // start time
- this.dest2 = '0 0 0'; // delta
- this.dest1 = this.origin; // original position
- this.finaldest = this.origin;
+ self.duration = 1; // 1 / duration
+ self.cnt = time; // start time
+ self.pos2 = '0 0 0'; // delta
+ self.pos1 = self.origin; // original position
+ self.finaldest = self.origin;
}
else
{
- this.state = ROTATE_STATE_MOVE;
+ self.state = ROTATE_STATE_MOVE;

- this.finaldest = targ_rotate.origin;
- if (this.finaldest == this.origin)
+ self.finaldest = targ.origin;
+ if (self.finaldest == self.origin)
{
- this.velocity = '0 0 0';
- this.endtime = this.ltime + 0.1;
-
- this.duration = 1; // 1 / duration
- this.cnt = time; // start time
- this.dest2 = '0 0 0'; // delta
- this.dest1 = this.origin; // original position
- this.finaldest = this.origin;
+ self.velocity = '0 0 0';
+ self.endtime = self.ltime + 0.1;
+
+ self.duration = 1; // 1 / duration
+ self.cnt = time; // start time
+ self.pos2 = '0 0 0'; // delta
+ self.pos1 = self.origin;// original position
+ self.finaldest = self.origin;
return;
}
+
// set destdelta to the vector needed to move
- vdestdelta = this.finaldest - this.origin;
+ vdestdelta = self.finaldest - self.origin;

// calculate length of vector
len = vlen (vdestdelta);
@@ -799,237 +787,225 @@ class func_rotate_train: base_rotate
{
// check if there's a speed change
if (current.speed > 0)
- this.speed = current.speed;
+ self.speed = current.speed;

- if (!this.speed)
- objerror ("No speed is defined!");
+ if (!self.speed)
+ objerror ("func_rotate_train_think_n"
+ "ext: No speed is defined!\n");

// divide by speed to get time to reach dest
- traveltime = len / this.speed;
+ traveltime = len / self.speed;
}

if (traveltime < 0.1)
{
- this.velocity = '0 0 0';
- this.endtime = this.ltime + 0.1;
- if (targ_rotate.spawnflags & PATH_ROTATE_ANGLES)
- {
- this.angles = targ_rotate.angles;
- }
+ self.velocity = '0 0 0';
+ self.endtime = self.ltime + 0.1;
+ if (targ.spawnflags & PATH_ROTATE_ANGLES)
+ self.angles = targ.angles;
return;
}

// qcc won't take vec/float
div = 1 / traveltime;

- if (targ_rotate.spawnflags & PATH_ROTATE_ANGLES)
+ if (targ.spawnflags & PATH_ROTATE_ANGLES)
{
- finalangle = normalizeangles
- (targ_rotate.angles);
- rotate = (targ_rotate.angles - this.angles) *
- div;
+ self.finalangle = base_rotate_normalizeangles (
+ targ.angles);
+ self.rotate = (targ.angles - self.angles) * div;
}

// set endtime to trigger a think when dest is reached
- this.endtime = this.ltime + traveltime;
+ self.endtime = self.ltime + traveltime;

// scale the destdelta vector by the time spent
// traveling to get velocity
- this.velocity = vdestdelta * div;
+ self.velocity = vdestdelta * div;

- this.duration = div; // 1 / duration
- this.cnt = time; // start time
- this.dest2 = vdestdelta; // delta
- this.dest1 = this.origin; // original position
+ self.duration = div; // 1 / duration
+ self.cnt = time; // start time
+ self.pos2 = vdestdelta; // delta
+ self.pos1 = self.origin; // original position
}
};

//--------------------------------------------------------------
- nonvirtual void() rotate_train_find =
+ void() func_rotate_train_think_find =
{
local entity targ;
- local base_rotate targ_rotate;

- this.state = ROTATE_STATE_FIND;
+ self.state = ROTATE_STATE_FIND;

- link_rotate_targets ();
+ base_rotate_link_targets ();

// the first target is the point of rotation.
// the second target is the path.
- targ = find (world, ::targetname, this.path);
+ targ = find (world, targetname, self.path);
if (targ.classtype != CT_PATH_ROTATE)
- objerror ("Next target is not path_rotate");
-
- // cast to base_rotate -- CEV
- targ_rotate = (base_rotate)targ;
+ objerror ("func_rotate_train_think_find: "
+ "Next target is not path_rotate\n");

// Save the current entity
- this.goal_rotate = targ_rotate;
+ self.goalentity = targ;

- if (targ_rotate.spawnflags & PATH_ROTATE_ANGLES)
+ if (targ.spawnflags & PATH_ROTATE_ANGLES)
{
- this.angles = targ_rotate.angles;
- this.finalangle = normalizeangles (targ_rotate.angles);
+ self.angles = targ.angles;
+ self.finalangle = base_rotate_normalizeangles (
+ targ.angles);
}

- this.path = targ_rotate.target;
- setorigin (this, targ_rotate.origin);
- set_target_origin ();
- rotate_targets_final ();
- this.think1 = rotate_train_next;
+ self.path = targ.target;
+ setorigin (self, targ.origin);
+ base_rotate_set_target_origin ();
+ base_rotate_targets_final ();
+ self.think1 = func_rotate_train_think_next;

- if (!this.targetname)
- {
+ if (!self.targetname)
// not triggered, so start immediately
- this.endtime = this.ltime + 0.1;
- }
+ self.endtime = self.ltime + 0.1;
else
- {
- this.endtime = 0;
- }
+ self.endtime = 0;

- this.duration = 1; // 1 / duration
- this.cnt = time; // start time
- this.dest2 = '0 0 0'; // delta
- this.dest1 = this.origin; // original position
+ self.duration = 1; // 1 / duration
+ self.cnt = time; // start time
+ self.pos2 = '0 0 0'; // delta
+ self.pos1 = self.origin; // original position
};

//--------------------------------------------------------------
// was rotate_train_think
//--------------------------------------------------------------
- virtual void() do_think =
+ void() func_rotate_train_think =
{
local float t, timeelapsed;

- t = time - this.ltime;
- this.ltime = time;
+ t = time - self.ltime;
+ self.ltime = time;

- if ((this.endtime) && (time >= this.endtime))
+ if ((self.endtime) && (time >= self.endtime))
{
- this.endtime = 0;
- if (this.state == ROTATE_STATE_MOVE)
+ self.endtime = 0;
+ if (self.state == ROTATE_STATE_MOVE)
{
- setorigin (this, this.finaldest);
- this.velocity = '0 0 0';
+ setorigin (self, self.finaldest);
+ self.velocity = '0 0 0';
}

- if (this.think1)
- {
- this.think1 ();
- }
+ if (self.think1)
+ self.think1 ();
}
else
{
- timeelapsed = (time - this.cnt) * this.duration;
+ timeelapsed = (time - self.cnt) * self.duration;
if (timeelapsed > 1)
timeelapsed = 1;
- setorigin (this,
- this.dest1 + (this.dest2 * timeelapsed));
+ setorigin (self, self.pos1 + (self.pos2 * timeelapsed));
}

- this.angles = this.angles + (this.rotate * t);
- this.angles = normalizeangles (this.angles);
- rotate_targets ();
+ self.angles = self.angles + (self.rotate * t);
+ self.angles = base_rotate_normalizeangles (self.angles);
+ base_rotate_targets ();

- this.nextthink = time + 0.02;
+ self.nextthink = time + 0.02;
};

//--------------------------------------------------------------
- virtual void(entity caller) do_use =
+ void() func_rotate_train_use =
{
- if (this.think1 != rotate_train_find)
+ if (self.think1 != func_rotate_train_think_find)
{
- if (this.velocity != '0 0 0')
+ if (self.velocity != '0 0 0')
// already activated
return;
- if (this.think1)
- {
- this.think1 ();
- }
+
+ if (self.think1)
+ self.think1 ();
}
};

//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) func_rotate_train_init =
{
- if (!this.speed)
- this.speed = 100;
- if (!this.target)
- objerror ("rotate_train without a target");
+ e.classname = "func_rotate_train";
+ e.classtype = CT_FUNC_ROTATE_TRAIN;
+
+ base_rotate_init (e);
+
+ if (!e.speed)
+ e.speed = 100;
+ if (!e.target)
+ objerror ("func_rotate_train: no target!\n");

- if (!this.noise)
+ if (!e.noise)
{
- if (this.sounds == 0)
- {
- this.noise = "misc/null.wav";
- }
+ if (e.sounds == 0)
+ e.noise = "misc/null.wav";

- if (this.sounds == 1)
- {
- this.noise = "plats/train2.wav";
- }
+ if (e.sounds == 1)
+ e.noise = "plats/train2.wav";
}

- if (!this.noise1)
+ if (!e.noise1)
{
- if (this.sounds == 0)
- {
- this.noise1 = "misc/null.wav";
- }
+ if (e.sounds == 0)
+ e.noise1 = "misc/null.wav";

- if (this.sounds == 1)
- {
- this.noise1 = "plats/train1.wav";
- }
+ if (e.sounds == 1)
+ e.noise1 = "plats/train1.wav";
}

- precache_sound (this.noise);
- precache_sound (this.noise1);
+ precache_sound (e.noise);
+ precache_sound (e.noise1);

- this.cnt = 1;
- this.solid = SOLID_NOT;
- this.movetype = MOVETYPE_STEP;
+ e.cnt = 1;
+ e.solid = SOLID_NOT;
+ e.movetype = MOVETYPE_STEP;
+ e.use = func_rotate_train_use;

- setmodel (this, this.model);
- setsize (this, this.mins, this.maxs);
- setorigin (this, this.origin);
+ setmodel (e, e.model);
+ setsize (e, e.mins, e.maxs);
+ setorigin (e, e.origin);

// start trains on the second frame, to make sure their
// targets have had a chance to spawn
- this.ltime = time;
- this.nextthink = this.ltime + 0.1;
- this.endtime = this.ltime + 0.1;
- // TODO CEV
- // this.think = rotate_train_think;
- this.think1 = rotate_train_find;
- this.state = ROTATE_STATE_FIND;
-
- this.duration = 1; // 1 / duration
- this.cnt = 0.1; // start time
- this.dest2 = '0 0 0'; // delta
- this.dest1 = this.origin; // original position
-
- this.flags = this.flags | FL_ONGROUND;
+ e.ltime = time;
+ e.nextthink = e.ltime + 0.1;
+ e.endtime = e.ltime + 0.1;
+ e.think = func_rotate_train_think;
+ e.think1 = func_rotate_train_think_find;
+ e.state = ROTATE_STATE_FIND;
+
+ e.duration = 1; // 1 / duration
+ e.cnt = 0.1; // start time
+ e.pos2 = '0 0 0'; // delta
+ e.pos1 = e.origin; // original position
+
+ e.flags |= FL_ONGROUND;
};

//--------------------------------------------------------------
void() func_rotate_train =
{
- this.classtype = CT_FUNC_ROTATE_TRAIN;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ func_rotate_train_init (self);
};
-};
+// };

-//------------------------------------------------------------------------------
+//----------------------------------------------------------------------
void() rotate_train =
{
objerror ("rotate_train entities should be changed to "
"rotate_object with\nfunc_rotate_train controllers\n");
};

-
-//------------------------------------------------------------------------------
+//----------------------------------------------------------------------
// Moving clip walls
-//------------------------------------------------------------------------------
+//----------------------------------------------------------------------

/*QUAKED func_movewall (0 .5 .8) ? VISIBLE TOUCH NONBLOCKING X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY

@@ -1043,97 +1019,106 @@ NONBLOCKING makes the brush non-solid. This is useless if VISIBLE is set.

"dmg" specifies the damage to cause when touched or blocked.
*/
-class func_movewall: base_rotate
-{
+//----------------------------------------------------------------------
+// class func_movewall: base_rotate
+// {
//--------------------------------------------------------------
- virtual void(entity toucher) do_touch =
+ void() func_movewall_touch =
{
- if (!(this.spawnflags & MOVEWALL_TOUCH))
- return;
-
- if (time < this.owner.attack_finished)
+ if (time < self.owner.attack_finished)
return;

- if (this.dmg)
+ if (self.dmg)
{
- t_damage2 (toucher, this, this.owner, this.dmg);
- this.owner.attack_finished = time + 0.5;
+ t_damage2 (other, self, self.owner, self.dmg);
+ self.owner.attack_finished = time + 0.5;
}
- else if (this.owner.dmg)
+ else if (self.owner.dmg)
{
- t_damage2 (toucher, this, this.owner, this.owner.dmg);
- this.owner.attack_finished = time + 0.5;
+ t_damage2 (other, self, self.owner, self.owner.dmg);
+ self.owner.attack_finished = time + 0.5;
}
};

//--------------------------------------------------------------
- virtual void(entity blocker) do_blocked =
+ void() func_movewall_blocked =
{
- if (this.solid == SOLID_NOT)
+ if (time < self.owner.attack_finished)
return;

- if (time < this.owner.attack_finished)
- return;
+ self.owner.attack_finished = time + 0.5;

- this.owner.attack_finished = time + 0.5;
+ if (self.owner.classtype == CT_FUNC_ROTATE_DOOR)
+ sub_runvoidas (self.owner,
+ func_rotate_door_group_reversedirection);

- if (this.owner.classtype == CT_FUNC_ROTATE_DOOR)
+ if (self.dmg)
{
- local func_rotate_door fdr;
- fdr = (func_rotate_door)this.owner;
- fdr.rotate_door_group_reversedirection ();
+ t_damage2 (other, self, self.owner, self.dmg);
+ self.owner.attack_finished = time + 0.5;
}
-
- if (this.dmg)
+ else if (self.owner.dmg)
{
- this.t_damage2 (blocker, this, this.owner, this.dmg);
- this.owner.attack_finished = time + 0.5;
- }
- else if (this.owner.dmg)
- {
- this.t_damage2 (blocker, this, this.owner,
- this.owner.dmg);
- this.owner.attack_finished = time + 0.5;
+ t_damage2 (other, self, self.owner, self.owner.dmg);
+ self.owner.attack_finished = time + 0.5;
}
};

//--------------------------------------------------------------
- virtual void() do_think =
+ void() func_movewall_think =
{
- this.ltime = time;
- this.nextthink = time + 0.02;
+ self.ltime = time;
+ self.nextthink = time + 0.02;
};

//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) func_movewall_init =
{
- this.angles = '0 0 0';
- this.movetype = MOVETYPE_PUSH;
+ e.classname = "func_movewall";
+ e.classtype = CT_FUNC_MOVEWALL;
+
+ base_rotate_init (e);
+
+ e.angles = '0 0 0';
+ e.movetype = MOVETYPE_PUSH;

- if (this.spawnflags & MOVEWALL_NONBLOCKING)
- this.solid = SOLID_NOT;
+ if (e.spawnflags & MOVEWALL_NONBLOCKING)
+ {
+ e.solid = SOLID_NOT;
+ }
else
- this.solid = SOLID_BSP;
+ {
+ e.solid = SOLID_BSP;
+ e.blocked = func_movewall_blocked;
+ }
+
+ if (e.spawnflags & MOVEWALL_TOUCH)
+ e.touch = func_movewall_touch;

- setmodel (this,this.model);
+ setmodel (e,e.model);

- if (!(this.spawnflags & MOVEWALL_VISIBLE))
- this.model = string_null;
+ if (!(e.spawnflags & MOVEWALL_VISIBLE))
+ e.model = __NULL__;

- this.nextthink = time + 0.02;
- this.ltime = time;
+ e.think = func_movewall_think;
+ e.nextthink = time + 0.02;
+ e.ltime = time;
};

//--------------------------------------------------------------
void() func_movewall =
{
- this.classtype = CT_FUNC_MOVEWALL;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ func_movewall_init (self);
};
-};
+// };

-//------------------------------------------------------------------------------
+//----------------------------------------------------------------------
// Rotating doors
-//------------------------------------------------------------------------------
+//----------------------------------------------------------------------

/*QUAKED func_rotate_door (0 .5 .8) (-8 -8 -8) (8 8 8) STAYOPEN X X X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY

@@ -1151,263 +1136,248 @@ once door from closing again when it's blocked.
2) metal
3) base
*/
-class func_rotate_door: base_rotate
-{
- float second_think;
-
+//----------------------------------------------------------------------
+// class func_rotate_door: base_rotate
+// {
//--------------------------------------------------------------
- nonvirtual void() rotate_door_reversedirection =
+ void() func_rotate_door_reversedirection =
{
local vector start;

// change to alternate textures
- this.frame = 1 - this.frame;
+ self.frame = 1 - self.frame;

- if (this.state == ROTATE_STATE_CLOSING)
+ if (self.state == ROTATE_STATE_CLOSING)
{
- start = this.dest1;
- this.dest = this.dest2;
- this.state = ROTATE_STATE_OPENING;
+ start = self.pos1;
+ self.finaldest = self.pos2;
+ self.state = ROTATE_STATE_OPENING;
}
else
{
- start = this.dest2;
- this.dest = this.dest1;
- this.state = ROTATE_STATE_CLOSING;
+ start = self.pos2;
+ self.finaldest = self.pos1;
+ self.state = ROTATE_STATE_CLOSING;
}

- sound (this, CHAN_VOICE, this.noise2, 1, ATTN_NORM);
+ sound (self, CHAN_VOICE, self.noise2, 1, ATTN_NORM);

- this.rotate = (this.dest - start) * (1 / this.speed);
- this.interaction_flags &= ~DISABLE_THINK;
- this.second_think = FALSE;
- this.nextthink = time + 0.02;
- this.endtime = time + this.speed - (this.endtime - time);
- this.ltime = time;
+ self.rotate = (self.finaldest - start) * (1 / self.speed);
+ self.think = func_rotate_door_think;
+ self.nextthink = time + 0.02;
+ self.endtime = time + self.speed - (self.endtime - time);
+ self.ltime = time;
};

//--------------------------------------------------------------
- nonvirtual void() rotate_door_group_reversedirection =
+ void() func_rotate_door_group_reversedirection =
{
local string name;
- local entity g_ent;
- local func_rotate_door g_rot;
+ local entity e;

// tell all associated rotaters to reverse direction
- if (this.group != __NULL__ && this.group != "")
+ if (self.group != __NULL__ && self.group != "")
{
- name = this.group;
- g_ent = find (world, func_rotate_door::group, name);
- while (g_ent)
+ name = self.group;
+ e = find (world, group, name);
+ while (e)
{
- if (g_ent.classgroup & CT_FUNC_ROTATE_DOOR)
- {
- // cast to func_rotate_door -- CEV
- g_rot = (func_rotate_door)g_ent;
- g_rot.rotate_door_reversedirection ();
- }
- g_ent = find (this, func_rotate_door::group,
- name);
+ sub_runvoidas (e,
+ func_rotate_door_reversedirection);
+ e = find (self, group, name);
}
}
else
{
- rotate_door_reversedirection ();
+ func_rotate_door_reversedirection ();
}
};

//--------------------------------------------------------------
- virtual void() do_think =
+ void() func_rotate_door_think =
{
- local float t;
+ local float t = time - self.ltime;
+ self.ltime = time;

- if (!this.second_think)
+ if (time < self.endtime)
{
- // was rotate_door_think -- CEV
- t = time - this.ltime;
- this.ltime = time;
-
- if (time < this.endtime)
- {
- this.angles = this.angles + (this.rotate * t);
- rotate_targets ();
- }
- else
- {
- this.angles = this.dest;
- rotate_targets ();
- this.second_think = TRUE;
- this.interaction_flags &= ~DISABLE_THINK;
- }
-
- this.nextthink = time + 0.01;
+ self.angles = self.angles + (self.rotate * t);
+ base_rotate_targets ();
}
else
{
- // was rotate_door_think2 -- CEV
- t = time - this.ltime;
- this.ltime = time;
+ self.angles = self.finaldest;
+ base_rotate_targets ();
+ self.think = func_rotate_door_think2;
+ }

- // change to alternate textures
- this.frame = 1 - this.frame;
- this.angles = this.dest;
+ self.nextthink = time + 0.01;
+ };

- if (this.state == ROTATE_STATE_OPENING)
- {
- this.state = ROTATE_STATE_OPEN;
- }
- else
+ //--------------------------------------------------------------
+ void() func_rotate_door_think2 =
+ {
+ local float t = time - self.ltime;
+ self.ltime = time;
+
+ // change to alternate textures
+ self.frame = 1 - self.frame;
+ self.angles = self.finaldest;
+
+ if (self.state == ROTATE_STATE_OPENING)
+ {
+ self.state = ROTATE_STATE_OPEN;
+ }
+ else
+ {
+ if (self.spawnflags & ROTATE_DOOR_STAYOPEN)
{
- if (this.spawnflags & ROTATE_DOOR_STAYOPEN)
- {
- rotate_door_group_reversedirection ();
- return;
- }
- this.state = ROTATE_STATE_CLOSED;
+ func_rotate_door_group_reversedirection ();
+ return;
}
+ self.state = ROTATE_STATE_CLOSED;
+ }

- sound (this, CHAN_VOICE, this.noise3, 1, ATTN_NORM);
- this.interaction_flags |= DISABLE_THINK;
+ sound (self, CHAN_VOICE, self.noise3, 1, ATTN_NORM);
+ self.think = sub_null;

- rotate_targets_final ();
- }
+ base_rotate_targets_final ();
};

//--------------------------------------------------------------
- virtual void(entity caller) do_use =
+ void() func_rotate_door_use =
{
local vector start;

- if ((this.state != ROTATE_STATE_OPEN) &&
- (this.state != ROTATE_STATE_CLOSED))
+ if ((self.state != ROTATE_STATE_OPEN) &&
+ (self.state != ROTATE_STATE_CLOSED))
{
return;
}

- if (!this.cnt)
+ if (!self.cnt)
{
- this.cnt = 1;
- link_rotate_targets ();
+ self.cnt = 1;
+ base_rotate_link_targets ();
}

// change to alternate textures
- this.frame = 1 - this.frame;
+ self.frame = 1 - self.frame;

- if (this.state == ROTATE_STATE_CLOSED)
+ if (self.state == ROTATE_STATE_CLOSED)
{
- start = this.dest1;
- this.dest = this.dest2;
- this.state = ROTATE_STATE_OPENING;
+ start = self.pos1;
+ self.finaldest = self.pos2;
+ self.state = ROTATE_STATE_OPENING;
}
else
{
- start = this.dest2;
- this.dest = this.dest1;
- this.state = ROTATE_STATE_CLOSING;
+ start = self.pos2;
+ self.finaldest = self.pos1;
+ self.state = ROTATE_STATE_CLOSING;
}

- sound (this, CHAN_VOICE, this.noise2, 1, ATTN_NORM);
+ sound (self, CHAN_VOICE, self.noise2, 1, ATTN_NORM);

- this.rotate = (this.dest - start) * (1 / this.speed);
- this.second_think = FALSE;
- this.interaction_flags &= ~DISABLE_THINK;
- this.nextthink = time + 0.01;
- this.endtime = time + this.speed;
- this.ltime = time;
+ self.rotate = (self.finaldest - start) * (1 / self.speed);
+ self.think = func_rotate_door_think;
+ self.nextthink = time + 0.01;
+ self.endtime = time + self.speed;
+ self.ltime = time;
};

//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) func_rotate_door_init =
{
- if (!this.target)
- {
- objerror ("rotate_door without target.");
- }
+ e.classname = "func_rotate_door";
+ e.classtype = CT_FUNC_ROTATE_DOOR;

- this.dest1 = '0 0 0';
- this.dest2 = this.angles;
- this.angles = this.dest1;
+ base_rotate_init (e);
+
+ if (!e.target)
+ objerror ("func_rotate_door_init: no target!\n");
+
+ e.pos1 = '0 0 0';
+ e.pos2 = e.angles;
+ e.angles = e.pos1;

// default to 2 seconds
- if (!this.speed)
- {
- this.speed = 2;
- }
+ if (!e.speed)
+ e.speed = 2;

- this.cnt = 0;
+ e.cnt = 0;

- if (!this.dmg)
- {
- this.dmg = 2;
- }
- else if (this.dmg < 0)
- {
- this.dmg = 0;
- }
+ if (!e.dmg)
+ e.dmg = 2;
+ else if (e.dmg < 0)
+ e.dmg = 0;

- if (this.sounds == 0)
+ if (e.sounds == 0)
{
// If at least one custom sound is defined, then let's
// ignore the presets and go for the custom sounds,
// otherwise let's use preset #1 by default
- if (this.noise1 == "" && this.noise2 == "" &&
- this.noise3 == "")
+ if (e.noise1 == "" && e.noise2 == "" && e.noise3 == "")
{
- this.sounds = 1;
+ e.sounds = 1;
}
else
{
- if (this.noise1 == "")
- this.noise1 = "misc/null.wav";
- if (this.noise2 == "")
- this.noise2 = "misc/null.wav";
- if (this.noise3 == "")
- this.noise3 = "misc/null.wav";
+ if (e.noise1 == "")
+ e.noise1 = "misc/null.wav";
+ if (e.noise2 == "")
+ e.noise2 = "misc/null.wav";
+ if (e.noise3 == "")
+ e.noise3 = "misc/null.wav";
}
}

- if (this.sounds == 1)
+ if (e.sounds == 1)
{
- this.noise1 = "doors/latch2.wav";
- this.noise2 = "doors/winch2.wav";
- this.noise3 = "doors/drclos4.wav";
+ e.noise1 = "doors/latch2.wav";
+ e.noise2 = "doors/winch2.wav";
+ e.noise3 = "doors/drclos4.wav";
}
- else if (this.sounds == 2)
+ else if (e.sounds == 2)
{
- this.noise2 = "doors/airdoor1.wav";
- this.noise1 = "doors/airdoor2.wav";
- this.noise3 = this.noise1;
+ e.noise2 = "doors/airdoor1.wav";
+ e.noise1 = "doors/airdoor2.wav";
+ e.noise3 = e.noise1;
}
- else if (this.sounds == 3)
+ else if (e.sounds == 3)
{
- this.noise2 = "doors/basesec1.wav";
- this.noise1 = "doors/basesec2.wav";
- this.noise3 = this.noise1;
+ e.noise2 = "doors/basesec1.wav";
+ e.noise1 = "doors/basesec2.wav";
+ e.noise3 = e.noise1;
}
- else if (this.sounds == 4)
+ else if (e.sounds == 4)
{
// added silent option - sounds 4 -- dumptruck_ds
- this.noise1 = this.noise2 = "misc/null.wav";
- this.noise3 = "misc/null.wav";
- }
-
- precache_sound (this.noise1);
- precache_sound (this.noise2);
- precache_sound (this.noise3);
-
- this.solid = SOLID_NOT;
- this.movetype = MOVETYPE_NONE;
- setmodel (this, this.model);
- setorigin (this, this.origin);
- setsize (this, this.mins, this.maxs);
- this.state = ROTATE_STATE_CLOSED;
- this.interaction_flags |= DISABLE_THINK;
- this.second_think = FALSE;
+ e.noise1 = e.noise2 = "misc/null.wav";
+ e.noise3 = "misc/null.wav";
+ }
+
+ precache_sound (e.noise1);
+ precache_sound (e.noise2);
+ precache_sound (e.noise3);
+
+ e.solid = SOLID_NOT;
+ e.movetype = MOVETYPE_NONE;
+ setmodel (e, e.model);
+ setorigin (e, e.origin);
+ setsize (e, e.mins, e.maxs);
+ e.state = ROTATE_STATE_CLOSED;
+ e.use = func_rotate_door_use;
+ e.think = sub_null;
};

//--------------------------------------------------------------
void() func_rotate_door =
{
- this.classtype = CT_FUNC_ROTATE_DOOR;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ func_rotate_door_init (self);
};
-};
+// };

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

Diff qc/func/shadow.qc

diff --git a/qc/func/shadow.qc b/qc/func/shadow.qc
index 30981c7..0da150c 100644
--- a/qc/func/shadow.qc
+++ b/qc/func/shadow.qc
@@ -3,18 +3,40 @@
//==============================================================================

//======================================================================
-// switchable shadow fields
+// constants
+//======================================================================
+
+const float SHADOWCONTROLLER_STARTOFF = 1;
+
+//======================================================================
+// fields
//======================================================================
-/*
+
.float switchshadstyle;
.float shadowoff;
.entity shadowcontroller;
-*/

-// constants
-const float SHADOWCONTROLLER_STARTOFF = 1;
+//======================================================================
+// forward declaration
+//======================================================================
+
+// misc_shadowcontroller
+void() misc_shadowcontroller_fade_out;
+void() misc_shadowcontroller_fade_in;
+void(entity sc, float speed) misc_shadowcontroller_setsteps;
+void() misc_shadowcontroller_use;
+entity(entity own, float sss, float spd, float sflags)
+ spawn_misc_shadowcontroller;
+void(entity e) misc_shadowcontroller_init;
+void() misc_shadowcontroller;
+
+// func_shadow
+void(entity e) func_shadow_init;
+void() func_shadow;

//------------------------------------------------------------------------------
+
+//----------------------------------------------------------------------
// misc_shadowcontroller
//
// Controls switchable shadows on any bmodel entity (except doors).
@@ -25,232 +47,246 @@ const float SHADOWCONTROLLER_STARTOFF = 1;
// speed2: Same as 'speed' but for the fade out animation. If unset it's
// the same value as 'speed'.
// spawnflag 1: target shadow starts as disabled
-//------------------------------------------------------------------------------
-class misc_shadowcontroller: base_mapentity
-{
- float count;
- float fading;
- float speed2;
-
- //--------------------------------------------------------------
- virtual void(string fieldname, string fieldvalue) init_field =
- {
- switch (fieldname)
- {
- case "speed2":
- speed2 = stof (fieldvalue);
- break;
- default:
- super::init_field (fieldname, fieldvalue);
- }
- };
-
+//----------------------------------------------------------------------
+// class misc_shadowcontroller: base_mapentity
+// {
//--------------------------------------------------------------
- nonvirtual void() fade_out =
+ void() misc_shadowcontroller_fade_out =
{
- if (this.count < 0)
- this.count = 0;
- if (this.count > 12)
- this.count = 12;
+ if (self.count < 0)
+ self.count = 0;
+ if (self.count > 12)
+ self.count = 12;

- if (this.fading >= 0)
- this.fading = -1;
+ // was self.fading
+ /*
+ if (self.state >= 0)
+ self.state = -1;
+ */

/*
- dprint (ftos(this.count));
+ dprint (ftos(self.count));
dprint ("\n");
*/

- lightstyle (this.switchshadstyle,
- lightstyle_fade_lookup(this.count));
- this.count = this.count + this.dmg;
- if (this.count > 12)
+ lightstyle (self.switchshadstyle,
+ lightstyle_fade_lookup(self.count));
+ self.count = self.count + self.dmg;
+ if (self.count > 12)
return;

- this.nextthink = time + this.delay;
+ self.think = misc_shadowcontroller_fade_out;
+ self.nextthink = time + self.delay;
};

//--------------------------------------------------------------
- nonvirtual void() fade_in =
+ void() misc_shadowcontroller_fade_in =
{
- if (this.count < 0)
- this.count = 0;
- if (this.count > 12)
- this.count = 12;
+ if (self.count < 0)
+ self.count = 0;
+ if (self.count > 12)
+ self.count = 12;

- if (this.fading <= 0)
- this.fading = 1;
+ // was self.fading
+ /*
+ if (self.state <= 0)
+ self.state = 1;
+ */

/*
- dprint (ftos(this.count));
+ dprint (ftos(self.count));
dprint ("\n");
*/

- lightstyle (this.switchshadstyle,
- lightstyle_fade_lookup(this.count));
- this.count = this.count - this.dmg;
- if (this.count < 0)
+ lightstyle (self.switchshadstyle,
+ lightstyle_fade_lookup(self.count));
+ self.count = self.count - self.dmg;
+ if (self.count < 0)
return;

- this.nextthink = time + this.delay;
+ self.think = misc_shadowcontroller_fade_in;
+ self.nextthink = time + self.delay;
};

//--------------------------------------------------------------
- nonvirtual void(float speed) setsteps =
+ void(entity sc, float speed) misc_shadowcontroller_setsteps =
{
- // this.delay -> time between steps
- // this.dmg -> step size
+ // sc.delay -> time between steps
+ // sc.dmg -> step size
if (speed >= 0.24)
{
- this.delay = (speed / 12);
- this.dmg = 1;
+ sc.delay = (speed / 12);
+ sc.dmg = 1;
}
else if (speed >= 0.12)
{
- this.delay = (speed / 6);
- this.dmg = 2;
+ sc.delay = (speed / 6);
+ sc.dmg = 2;
}
else if (speed >= 0.06)
{
- this.delay = (speed / 3);
- this.dmg = 4;
+ sc.delay = (speed / 3);
+ sc.dmg = 4;
}
else if (speed >= 0.04)
{
- this.delay = (speed / 2);
- this.dmg = 6;
+ sc.delay = (speed / 2);
+ sc.dmg = 6;
}
else
{
- this.delay = 0;
- this.dmg = 12;
+ sc.delay = 0;
+ sc.dmg = 12;
}
};

//--------------------------------------------------------------
- virtual void() do_think =
+ void() misc_shadowcontroller_use =
{
- if (this.fading < 0)
- this.fade_out ();
- else if (this.fading > 0)
- this.fade_in ();
- };
-
- //--------------------------------------------------------------
- virtual void(entity caller) do_use =
- {
- if (this.shadowoff)
+ if (self.shadowoff)
{
/*
dprint ("Fade in:\n");
*/
- setsteps (this.speed);
- fade_in ();
- this.shadowoff = 0;
+ misc_shadowcontroller_setsteps (self, self.speed);
+ misc_shadowcontroller_fade_in ();
+ self.shadowoff = 0;
}
else
{
/*
dprint ("Fade out:\n");
*/
- setsteps (this.speed2);
- fade_out ();
- this.shadowoff = 1;
+ misc_shadowcontroller_setsteps (self, self.speed2);
+ misc_shadowcontroller_fade_out ();
+ self.shadowoff = 1;
}
};

//--------------------------------------------------------------
- virtual void() init_spawned =
+ entity(entity own, float sss, float spd, float sflags)
+ spawn_misc_shadowcontroller =
+ {
+ local entity e = spawn ();
+ e.owner = own;
+ e.switchshadstyle = sss;
+ e.speed = spd;
+ e.spawnflags = sflags;
+ misc_shadowcontroller_init (e);
+ return e;
+ };
+
+ //--------------------------------------------------------------
+ void(entity e) misc_shadowcontroller_init =
{
entity t1;

+ e.classname = "misc_shadowcontroller";
+ e.classtype = CT_MISC_SHADOWCONTROLLER;
+ base_mapentity_init (e);
+
// doesn't search for a target if switchshadstyle is already set
// used for built-in shadow controllers
- if (!this.switchshadstyle)
+ if (!e.switchshadstyle)
{
// we need to find only the first target entity with
// switchable shadows set, since shadow lightstyles
// are bound by targetname
- t1 = find (world, ::targetname2, this.target);
+ t1 = find (world, targetname2, e.target);

while (t1 != world && !t1.switchshadstyle)
{
- t1 = find (t1, ::targetname2, this.target);
+ t1 = find (t1, targetname2, e.target);
}

if (t1 == world)
{
- t1 = find (world, ::targetname, this.target);
+ t1 = find (world, targetname, e.target);

while (t1 != world && !t1.switchshadstyle)
{
- t1 = find (t1, ::targetname,
- this.target);
+ t1 = find (t1, targetname, e.target);
}
}

if (t1 == world)
{
- dprint ("\b[misc_shadowcontroller]\b "
+ dprint ("misc_shadowcontroller_init: "
"_switchableshadow not set in target ");
- dprint (this.target);
+ dprint (e.target);
dprint ("\n");
return;
}

- this.switchshadstyle = t1.switchshadstyle;
+ e.switchshadstyle = t1.switchshadstyle;
}

- this.fading = 0;
+ // was self.fading
+ /*
+ e.state = 0;
+ */

- if (!this.speed)
- this.speed = 0.5;
- if (!this.speed2)
- this.speed2 = this.speed;
+ if (!e.speed)
+ e.speed = 0.5;
+ if (!e.speed2)
+ e.speed2 = e.speed;

- if (this.spawnflags & SHADOWCONTROLLER_STARTOFF)
+ if (e.spawnflags & SHADOWCONTROLLER_STARTOFF)
{
- lightstyle (this.switchshadstyle, "m");
+ lightstyle (e.switchshadstyle, "m");

- this.shadowoff = 1;
- this.count = 12;
+ e.shadowoff = 1;
+ e.count = 12;

- setsteps (this.speed2);
+ misc_shadowcontroller_setsteps (e, e.speed2);
}
else
{
- lightstyle (this.switchshadstyle, "a");
- this.shadowoff = 0;
- this.count = 0;
- setsteps (this.speed);
+ lightstyle (e.switchshadstyle, "a");
+ e.shadowoff = 0;
+ e.count = 0;
+ misc_shadowcontroller_setsteps (e, e.speed);
}
+
+ e.use = misc_shadowcontroller_use;
};

//--------------------------------------------------------------
void() misc_shadowcontroller =
{
- this.classname = "misc_shadowcontroller";
- this.classtype = CT_MISC_SHADOWCONTROLLER;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ misc_shadowcontroller_init (self);
};
-};
+// };

-//------------------------------------------------------------------------------
-class func_shadow: base_func
-{
+//----------------------------------------------------------------------
+// class func_shadow: base_func
+// {
//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) func_shadow_init =
{
- this.angles = '0 0 0';
- this.movetype = MOVETYPE_NONE;
- this.solid = SOLID_NOT;
+ e.classname = "func_shadow";
+ e.classtype = CT_FUNC_SHADOW;
+ base_func_init (e);
+
+ e.angles = '0 0 0';
+ e.movetype = MOVETYPE_NONE;
+ e.solid = SOLID_NOT;

- this.modelindex = 0;
- this.model = "";
+ e.modelindex = 0;
+ e.model = "";
};

//--------------------------------------------------------------
void() func_shadow =
{
- this.classtype = CT_FUNC_SHADOW;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ func_shadow_init (self);
};
-};
+// };

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

Diff qc/func/togglevisiblewall.qc

diff --git a/qc/func/togglevisiblewall.qc b/qc/func/togglevisiblewall.qc
index d29c6e6..df01d45 100644
--- a/qc/func/togglevisiblewall.qc
+++ b/qc/func/togglevisiblewall.qc
@@ -10,62 +10,86 @@
// spawnflag 2: set brush as non-solid
//==============================================================================

+//======================================================================
// constants
+//======================================================================
+
const float TOGGLEVISWALL_STARTOFF = 1;
const float TOGGLEVISWALL_NOTSOLID = 2;

-class func_togglevisiblewall: base_func
-{
+//======================================================================
+// forward declarations
+//======================================================================
+
+// func_togglevisiblewall
+void() func_togglevisiblewall_use;
+void(entity e) func_togglevisiblewall_init;
+void() func_togglevisiblewall;
+
+//------------------------------------------------------------------------------
+
+//----------------------------------------------------------------------
+// class func_togglevisiblewall: base_func
+// {
//--------------------------------------------------------------
- virtual void(entity caller) do_use =
+ void() func_togglevisiblewall_use =
{
- if (!this.state)
+ if (!self.state)
{
- if (!(this.spawnflags & TOGGLEVISWALL_NOTSOLID))
+ if (!(self.spawnflags & TOGGLEVISWALL_NOTSOLID))
{
- this.solid = SOLID_BSP;
- this.movetype = MOVETYPE_PUSH;
+ self.solid = SOLID_BSP;
+ self.movetype = MOVETYPE_PUSH;
}
- setmodel (this, this.origmodel);
- if (this.switchshadstyle)
- lightstyle (this.switchshadstyle, "a");
- this.state = 1;
+ setmodel (self, self.origmodel);
+ if (self.switchshadstyle)
+ lightstyle (self.switchshadstyle, "a");
+ self.state = 1;
}
else
{
- this.solid = SOLID_NOT;
- this.movetype = MOVETYPE_NONE;
- setmodel (this, "");
- if (this.switchshadstyle)
- lightstyle (this.switchshadstyle, "m");
- this.state = 0;
+ self.solid = SOLID_NOT;
+ self.movetype = MOVETYPE_NONE;
+ setmodel (self, "");
+ if (self.switchshadstyle)
+ lightstyle (self.switchshadstyle, "m");
+ self.state = 0;
}
};

//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) func_togglevisiblewall_init =
{
- this.angles = '0 0 0';
+ e.classname = "func_togglevisiblewall";
+ e.classtype = CT_FUNC_TOGGLEVISIBLEWALL;
+ base_func_init (e);
+
+ e.angles = '0 0 0';
+ e.use = func_togglevisiblewall_use;

- this.origmodel = this.model;
+ e.origmodel = e.model;

- if (this.spawnflags & TOGGLEVISWALL_STARTOFF)
- this.state = 1;
+ if (e.spawnflags & TOGGLEVISWALL_STARTOFF)
+ e.state = 1;
else
- this.state = 0;
+ e.state = 0;

- if (this.spawnflags & TOGGLEVISWALL_NOTSOLID)
+ if (e.spawnflags & TOGGLEVISWALL_NOTSOLID)
{
- this.solid = SOLID_NOT;
- this.movetype = MOVETYPE_NONE;
+ e.solid = SOLID_NOT;
+ e.movetype = MOVETYPE_NONE;
}

- this.use ();
+ sub_runvoidas (e, func_togglevisiblewall_use);
};

//--------------------------------------------------------------
void() func_togglevisiblewall =
{
- this.classtype = CT_FUNC_TOGGLEVISIBLEWALL;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ func_togglevisiblewall_init (self);
};
-};
+// };

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

Diff qc/func/togglewall.qc

diff --git a/qc/func/togglewall.qc b/qc/func/togglewall.qc
index fd0f8d0..00f6078 100644
--- a/qc/func/togglewall.qc
+++ b/qc/func/togglewall.qc
@@ -8,9 +8,24 @@
// All rights reserved.
// Distributed (unsupported) on 3.12.97

+//======================================================================
// constants
+//======================================================================
+
const float TOGGLEWALL_START_OFF = 1;

+//======================================================================
+// forward declarations
+//======================================================================
+
+// func_togglewall
+void() func_togglewall_touch;
+void() func_togglewall_use;
+void(entity e) func_togglewall_init;
+void() func_togglewall;
+
+//------------------------------------------------------------------------------
+
/*QUAKED func_togglewall (0 .5 .8) ? TOGGLEWALL_START_OFF X X X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY

Creates a invisible wall that can be toggled on and off.
@@ -21,76 +36,87 @@ TOGGLEWALL_START_OFF wall doesn't block until triggered.
"noise1" is the sound to play when wall is blocking.
"dmg" is the amount of damage to cause when touched.
*/
-class func_togglewall: base_func
-{
+//----------------------------------------------------------------------
+// class func_togglewall: base_func
+// {
//--------------------------------------------------------------
- virtual void(entity toucher) do_touch =
+ void() func_togglewall_touch =
{
- if (!this.dmg)
+ if (!self.dmg)
return;

- if (time < this.attack_finished)
+ if (time < self.attack_finished)
return;

- this.attack_finished = time + 0.5;
- t_damage2 (toucher, this, this, this.dmg);
- sound (this, CHAN_VOICE, this.noise1, 1, ATTN_NORM);
+ self.attack_finished = time + 0.5;
+ t_damage2 (other, self, self, self.dmg);
+ sound (self, CHAN_VOICE, self.noise1, 1, ATTN_NORM);
};

//--------------------------------------------------------------
- virtual void(entity caller) do_use =
+ void() func_togglewall_use =
{
- if (!this.state)
+ if (!self.state)
{
- this.state = 1;
- setorigin (this, this.origin - '8000 8000 8000');
- // sound (this, CHAN_VOICE, this.noise1, 1, ATTN_NORM);
+ self.state = 1;
+ setorigin (self, self.origin - '8000 8000 8000');
+ // sound (self, CHAN_VOICE, self.noise1, 1, ATTN_NORM);
}
else
{
- this.state = 0;
- setorigin (this, this.origin + '8000 8000 8000');
- sound (this, CHAN_VOICE, this.noise, 1, ATTN_NORM);
+ self.state = 0;
+ setorigin (self, self.origin + '8000 8000 8000');
+ sound (self, CHAN_VOICE, self.noise, 1, ATTN_NORM);
}
};

//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) func_togglewall_init =
{
- this.movetype = MOVETYPE_PUSH;
- this.mdl = this.model;
- setmodel (this, this.model);
- setsize (this, this.mins, this.maxs);
- setorigin (this, this.origin);
+ e.classname = "togglewall";
+ e.classtype = CT_FUNC_TOGGLEWALL;
+ base_func_init (e);

- if (!this.noise)
- this.noise = "misc/null.wav";
+ e.movetype = MOVETYPE_PUSH;
+ e.mdl = e.model;
+ setmodel (e, e.model);
+ setsize (e, e.mins, e.maxs);
+ setorigin (e, e.origin);

- if (!this.noise1)
- this.noise1 = "misc/null.wav";
+ e.touch = func_togglewall_touch;
+ e.use = func_togglewall_use;

- precache_sound (this.noise);
- precache_sound (this.noise1);
+ if (!e.noise)
+ e.noise = "misc/null.wav";

- this.solid = SOLID_BSP;
- this.model = string_null;
+ if (!e.noise1)
+ e.noise1 = "misc/null.wav";

- if (this.spawnflags & TOGGLEWALL_START_OFF)
+ precache_sound (e.noise);
+ precache_sound (e.noise1);
+
+ e.solid = SOLID_BSP;
+ e.model = __NULL__;
+
+ if (e.spawnflags & TOGGLEWALL_START_OFF)
{
- this.state = 0;
- setorigin (this, this.origin + '8000 8000 8000');
+ e.state = 0;
+ setorigin (e, e.origin + '8000 8000 8000');
}
else
{
- this.state = 1;
- sound (this, CHAN_VOICE, this.noise1, 1, ATTN_NORM);
+ e.state = 1;
+ sound (e, CHAN_VOICE, e.noise1, 1, ATTN_NORM);
}
};

//--------------------------------------------------------------
void() func_togglewall =
{
- this.classname = "togglewall";
- this.classtype = CT_FUNC_TOGGLEWALL;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ func_togglewall_init (self);
};
-};
+// };

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

Diff qc/func/train.qc

diff --git a/qc/func/train.qc b/qc/func/train.qc
index 7a14969..5168087 100644
--- a/qc/func/train.qc
+++ b/qc/func/train.qc
@@ -2,7 +2,10 @@
// func_train
//==============================================================================

+//======================================================================
// constants
+//======================================================================
+
const float TRAIN_RETRIGGER = 1;
const float TRAIN_MOVEONTRIGGER = 2;
const float TRAIN_STOPONTRIGGER = 4;
@@ -16,47 +19,37 @@ const float TRAIN_NEXT_STOP = 1; // force a stop on the next path_corner
const float TRAIN_NEXT_CONTINUE = 2; // force continue on the next
// path_corner (ignores wait time)

-//------------------------------------------------------------------------------
-class base_func_train: base_func
-{
- float find_think;
- float moving_use;
- float speed2;
+//======================================================================
+// forward declarations
+//======================================================================

- //--------------------------------------------------------------
- virtual void(string fieldname, string fieldvalue) init_field =
- {
- switch (fieldname)
- {
- case "speed2":
- speed2 = stof (fieldvalue);
- break;
- default:
- super::init_field (fieldname, fieldvalue);
- }
- };
+// base_func_train
+void() base_func_train_blocked;
+void() base_func_train_use_stopped;
+void() base_func_train_use_moving;
+void() base_func_train_wait;
+void() base_func_train_next;
+void() base_func_train_find;
+void(entity e) base_func_train_init;
+strip void() base_func_train;

- //--------------------------------------------------------------
- virtual void(entity blocker) do_blocked =
- {
- if (time < this.attack_finished)
- return;
+// func_train
+void(entity e) func_train_init;
+void() func_train;

- this.attack_finished = time + 0.5;
- this.t_damage2 (blocker, this, this, this.dmg);
- };
+//------------------------------------------------------------------------------

+//----------------------------------------------------------------------
+// class base_func_train: base_func
+// {
//--------------------------------------------------------------
- virtual void() do_think =
+ void() base_func_train_blocked =
{
- if (find_think == TRUE)
- {
- this.train_find ();
- }
- else
- {
- this.train_next ();
- }
+ if (time < self.attack_finished)
+ return;
+
+ self.attack_finished = time + 0.5;
+ t_damage2 (other, self, self, self.dmg);
};

//--------------------------------------------------------------
@@ -64,68 +57,59 @@ class base_func_train: base_func
// Makes the train continue on path_corners with wait -1,
// or forces a continue if the "move on trigger" spawnflag is set.
//--------------------------------------------------------------
- virtual void(entity caller) do_use =
+ void() base_func_train_use_stopped =
{
- if (this.moving_use)
+ if (self.spawnflags & TRAIN_MOVEONTRIGGER || self.wait < 0)
{
- //----------------------------------------------
- // Use function for when the train is moving.
- // Forces a stop or an instant continue on the
- // next path_corner depending on the spawnflag set
- //----------------------------------------------
- if (spawnflags & TRAIN_MOVEONTRIGGER || this.wait < 0)
- this.cnt = TRAIN_NEXT_CONTINUE;
- else if (this.spawnflags & TRAIN_STOPONTRIGGER)
- this.cnt = TRAIN_NEXT_STOP;
- return;
- }
-
- if (this.spawnflags & TRAIN_MOVEONTRIGGER || this.wait < 0)
- {
- this.train_next ();
+ base_func_train_next ();
return;
}

// Train has already moved after startup, and has no
// "stop on trigger" flag, so ignore activation.
- if (!this.find_think && this.cnt != TRAIN_NEXT_STOP)
+ if (self.think != base_func_train_find &&
+ self.cnt != TRAIN_NEXT_STOP)
{
return;
}

- train_next ();
+ base_func_train_next ();
};

//--------------------------------------------------------------
- virtual void() train_wait_handlepath = { };
-
- //--------------------------------------------------------------
- virtual void() train_wait_handlepause = { };
-
+ // Use function for when the train is moving.
+ // Forces a stop or an instant continue on the next path_corner
+ // depending on the spawnflag set
//--------------------------------------------------------------
- virtual void() train_wait_handlestop = { };
+ void() base_func_train_use_moving =
+ {
+ if (self.spawnflags & TRAIN_MOVEONTRIGGER || self.wait < 0)
+ self.cnt = TRAIN_NEXT_CONTINUE;
+ else if (self.spawnflags & TRAIN_STOPONTRIGGER)
+ self.cnt = TRAIN_NEXT_STOP;
+ };

//--------------------------------------------------------------
// path_corner has been reached, so decide what to do next
//--------------------------------------------------------------
- nonvirtual void() train_wait =
+ void() base_func_train_wait =
{
local float localtime;

- if (this.movetype == MOVETYPE_PUSH)
- localtime = this.ltime;
+ if (self.movetype == MOVETYPE_PUSH)
+ localtime = self.ltime;
else
localtime = time;

// ready to be re-triggered
- this.moving_use = FALSE;
+ self.use = base_func_train_use_stopped;

// from Copper
// Trains now fire their path_corners' targets on arrival.
// If a player is riding the train, treat them as activator.
activator = nextent (world);

- while (!func_door::entities_touching(this, activator) &&
+ while (!func_door_entities_touching(self, activator) &&
activator.classtype == CT_PLAYER)
{
activator = nextent (activator);
@@ -135,115 +119,125 @@ class base_func_train: base_func
// default to player1 wherever they are
activator = nextent (world);

- if (this.enemy.classgroup & CG_MAPENTITY)
- {
- // was SUB_UseEntTargets -- CEV
- ((base_mapentity)this.enemy).sub_usetargets ();
- }
+ // was SUB_UseEntTargets -- CEV
+ sub_runvoidas (self.enemy, sub_usetargets);

- if (this.enemy.speed)
+ if (self.enemy.speed)
// sets the speed from the current path_corner
- this.speed2 = this.enemy.speed;
+ self.speed2 = self.enemy.speed;
+
+ // oof. -- CEV
+ if (self.classtype == CT_MISC_MODELTRAIN)
+ {
+ if (self.enemy.first_frame)
+ self.first_frame = self.enemy.first_frame;
+ if (self.enemy.last_frame)
+ self.last_frame = self.enemy.last_frame;
+ if (self.enemy.first_frame2)
+ self.first_frame2 = self.enemy.first_frame2;
+ if (self.enemy.last_frame2)
+ self.last_frame2 = self.enemy.last_frame2;
+ if (self.enemy.frtime)
+ self.frtime = self.enemy.frtime;
+ if (self.enemy.frtime2)
+ self.frtime2 = self.enemy.frtime2;
+ if (self.enemy.animtype)
+ self.animtype = self.enemy.animtype;
+ if (self.enemy.animtype2)
+ self.animtype2 = self.enemy.animtype2;
+ if (self.enemy.multiplier)
+ self.multiplier = self.enemy.multiplier;
+ }

- // hook for misc_modeltrain -- CEV
- train_wait_handlepath ();
- this.find_think = FALSE;
+ self.think = base_func_train_next;

// train is moving normally and path_corner has a wait set,
// so pause for that time.
- if (this.wait > 0 && this.cnt == TRAIN_NEXT_WAIT &&
- !(this.spawnflags & TRAIN_RETRIGGER))
+ if (self.wait > 0 && self.cnt == TRAIN_NEXT_WAIT &&
+ !(self.spawnflags & TRAIN_RETRIGGER))
{
- dprint (sprintf("train_wait: pause position, this "
- "wait %g, classname %s, this.noise %s\n",
- this.wait, this.classname, this.noise));
-
// state: stopped
- this.state = 0;
+ self.state = 0;

- // hook for misc_modeltrain -- CEV
- train_wait_handlepause ();
+ // oof -- CEV
+ if (self.classtype == CT_MISC_MODELTRAIN)
+ {
+ sub_runvoidas (self.animcontroller,
+ self.animcontroller.think);
+ }

- // TODO CEV: there's a problem here where modeltrains
- // aren't waiting when they should
- this.nextthink = localtime + this.wait;
+ self.nextthink = localtime + self.wait;

// play stopping sound. If path_corner has a custom
// sound, play that instead
- if (this.enemy.noise != "")
- sound (this, CHAN_WEAPON, this.enemy.noise,
+ if (self.enemy.noise != "")
+ sound (self, CHAN_WEAPON, self.enemy.noise,
1, ATTN_NORM);
else
- sound (this, CHAN_VOICE, this.noise,
+ sound (self, CHAN_VOICE, self.noise,
1, ATTN_NORM);
}
// train is moving normally and path_corner has no wait time,
// or has been forced to move instantly through a triggering.
- else if (this.cnt != TRAIN_NEXT_STOP && !this.wait &&
- !(this.spawnflags & TRAIN_RETRIGGER))
+ else if (self.cnt != TRAIN_NEXT_STOP && !self.wait &&
+ !(self.spawnflags & TRAIN_RETRIGGER))
{
- /*
- // testing dprint -- CEV
- dprint ("train_wait: no wait time\n");
- */
// play "passing by" sound, if any. If path_corner has
// a custom one, play that instead
- if (this.enemy.noise2 != "")
- sound (this, CHAN_WEAPON, this.enemy.noise2,
+ if (self.enemy.noise2 != "")
+ sound (self, CHAN_WEAPON, self.enemy.noise2,
1, ATTN_NORM);
- else if (this.noise2 != "")
- sound (this, CHAN_WEAPON, this.noise2,
+ else if (self.noise2 != "")
+ sound (self, CHAN_WEAPON, self.noise2,
1, ATTN_NORM);

// move instantly
- this.nextthink = -1;
- train_next ();
+ self.nextthink = -1;
+ base_func_train_next ();
}
// path_corner has wait -1, or train has been forced to stop
// through a triggering. Also catches the backwards compatible
// case for the original rubicon2 "retrigger" flag.
else
{
- // testing dprint -- CEV
- dprint ("train_wait: end position\n");
-
// play stopping sound. If path_corner has a custom
// sound, play that instead
- if (this.enemy.noise != "")
- sound (this, CHAN_WEAPON, this.enemy.noise,
+ if (self.enemy.noise != "")
+ sound (self, CHAN_WEAPON, self.enemy.noise,
1, ATTN_NORM);
else
- sound (this, CHAN_VOICE, this.noise,
+ sound (self, CHAN_VOICE, self.noise,
1, ATTN_NORM);

// state: stopped
- this.state = 0;
- // hook for misc_modeltrain -- CEV
- train_wait_handlestop ();
- this.nextthink = -1;
- }
- };
+ self.state = 0;

- //--------------------------------------------------------------
- virtual void(entity targ) train_next_custom = { };
+ // oof -- CEV
+ if (self.classtype == CT_MISC_MODELTRAIN)
+ {
+ sub_runvoidas (self.animcontroller,
+ self.animcontroller.think);
+ }

- //--------------------------------------------------------------
- virtual void() train_next_custom2 = { };
+ self.nextthink = -1;
+ }
+ };

//--------------------------------------------------------------
// searches for the next path_corner and sends the train on its way
//--------------------------------------------------------------
- nonvirtual void() train_next =
+ void() base_func_train_next =
{
local entity targ;
- vector displ = '0 0 0';
+ local vector destang = '0 0 0';
+ local vector displ = '0 0 0';

- targ = find (world, ::targetname, this.target);
+ targ = find (world, targetname, self.target);

- if (!targ || this.target == "")
+ if (!targ || self.target == "")
objerror ("train_next: no next target");

- this.target = targ.target;
+ self.target = targ.target;

if (targ.wait)
{
@@ -253,172 +247,219 @@ class base_func_train: base_func
// moving (no wait), even if the train has a default
// wait time
if (targ.wait == -2)
- this.wait = 0;
+ self.wait = 0;
else
- this.wait = targ.wait;
+ self.wait = targ.wait;
}
else
{
// use train's current wait time otherwise
- this.wait = this.pausetime;
+ self.wait = self.pausetime;
}

- this.enemy = targ;
+ self.enemy = targ;

- sound (this, CHAN_VOICE, this.noise1, 1, ATTN_NORM);
+ sound (self, CHAN_VOICE, self.noise1, 1, ATTN_NORM);

- if (!(!this.wait && this.cnt == TRAIN_NEXT_CONTINUE))
- this.cnt = TRAIN_NEXT_WAIT;
+ if (!(!self.wait && self.cnt == TRAIN_NEXT_CONTINUE))
+ self.cnt = TRAIN_NEXT_WAIT;

// store up any premature triggerings until current
// movement is finished
- this.moving_use = TRUE;
+ self.use = base_func_train_use_moving;

- // hook for modeltrain -- CEV
- train_next_custom (targ);
+ // oof -- CEV
+ if (self.classtype == CT_MISC_MODELTRAIN)
+ {
+ if (!(self.spawnflags & TRAIN_NOROTATE))
+ {
+ destang = vectoangles (
+ targ.origin - self.origin);
+
+ if (self.spawnflags & TRAIN_ROTATEY)
+ {
+ destang_x = self.angles_x;
+ destang_z = self.angles_z;
+ }
+
+ if (self.multiplier > 0)
+ {
+ // TODO CEV
+ sub_calcanglemovecontroller (self,
+ destang,
+ self.speed2 * self.multiplier,
+ sub_null,
+ self.rotatecontroller);
+ }
+ else
+ {
+ self.angles = destang;
+ }
+ }
+ }

- if (!this.state)
- this.state = 1;
+ if (!self.state)
+ {
+ self.state = 1;
+
+ if (self.classtype == CT_MISC_MODELTRAIN &&
+ self.style != TRAIN_STYLE_SINGLEANIM)
+ {
+ sub_runvoidas (self.animcontroller,
+ self.animcontroller.think);
+ }
+ }

// if the TRAIN_CUSTOMALIGN flag is checked then the train
// should align with its path_corners based on the location
// of an "origin" brush added to the train by the mapper
// instead of the mins corner -therektafire
- local float doDisplace;
- if (this.spawnflags & TRAIN_CUSTOMALIGN)
- doDisplace = 0.0;
+ local float do_displace;
+ if (self.spawnflags & TRAIN_CUSTOMALIGN)
+ do_displace = 0.0;
else
- doDisplace = 1.0;
+ do_displace = 1.0;

- if (this.classtype != CT_MISC_MODELTRAIN)
- displ = this.mins;
+ if (self.classtype != CT_MISC_MODELTRAIN)
+ displ = self.mins;

- calc_move (targ.origin - (displ * doDisplace),
- this.speed2, train_wait);
+ sub_calcmove (self, targ.origin - (displ * do_displace),
+ self.speed2, base_func_train_wait);
};

//--------------------------------------------------------------
// searches for the first path_corner after the train entity is
// initialized
//--------------------------------------------------------------
- nonvirtual void() train_find =
+ void() base_func_train_find =
{
local entity targ;
local float localtime;
local vector displ = '0 0 0';

- if (this.movetype == MOVETYPE_PUSH)
- localtime = this.ltime;
+ if (self.movetype == MOVETYPE_PUSH)
+ localtime = self.ltime;
else
localtime = time;

- targ = find (world, ::targetname, this.target);
- this.target = targ.target;
+ targ = find (world, targetname, self.target);
+ self.target = targ.target;

- local float doDisplace;
- if (this.spawnflags & TRAIN_CUSTOMALIGN)
- doDisplace = 0.0;
+ local float do_displace;
+ if (self.spawnflags & TRAIN_CUSTOMALIGN)
+ do_displace = 0.0;
else
- doDisplace = 1.0;
+ do_displace = 1.0;

- if (this.classtype != CT_MISC_MODELTRAIN)
- displ = this.mins;
+ if (self.classtype != CT_MISC_MODELTRAIN)
+ displ = self.mins;

- this.enemy = targ;
- setorigin (this, targ.origin - (displ * doDisplace));
+ self.enemy = targ;
+ setorigin (self, targ.origin - (displ * do_displace));
if (targ.speed)
// uses speed from the 1st path corner if set
- this.speed2 = targ.speed;
+ self.speed2 = targ.speed;

- if (!this.targetname)
+ if (!self.targetname)
{
// not triggered, so start immediately
- this.nextthink = localtime + 0.1;
- this.find_think = FALSE;
+ self.think = base_func_train_next;
+ self.nextthink = localtime + 0.1;
}
};

//--------------------------------------------------------------
- nonvirtual void() train_init =
+ void(entity e) base_func_train_init =
{
- if (!this.speed)
- this.speed = 100;
- if (!this.target)
- objerror ("func_train without a target");
- if (!this.dmg)
- this.dmg = 2;
-
- if (this.spawnflags & TRAIN_STOPONTRIGGER &&
- this.spawnflags & TRAIN_MOVEONTRIGGER)
+ base_func_init (e);
+
+ if (!e.speed)
+ e.speed = 100;
+ if (!e.target)
+ objerror ("base_func_train_init: no target\n");
+ if (!e.dmg)
+ e.dmg = 2;
+
+ if (e.spawnflags & TRAIN_STOPONTRIGGER &&
+ e.spawnflags & TRAIN_MOVEONTRIGGER)
{
- objerror ("func_train: Stop and move on trigger "
- "set at the same time");
+ objerror ("base_func_train_init: Stop and move on "
+ "trigger set at the same time\n");
}

- if (this.sounds == 1)
+ if (e.sounds == 1)
{
- if (this.noise == "")
- this.noise = "plats/train2.wav";
- if (this.noise1 == "")
- this.noise1 = "plats/train1.wav";
+ if (e.noise == "")
+ e.noise = "plats/train2.wav";
+ if (e.noise1 == "")
+ e.noise1 = "plats/train1.wav";
}
- else if (this.sounds == 2)
+ else if (e.sounds == 2)
{
// base door sound
- if (this.noise == "")
- this.noise = "doors/hydro2.wav";
- if (this.noise1 == "")
- this.noise1 = "doors/hydro1.wav";
+ if (e.noise == "")
+ e.noise = "doors/hydro2.wav";
+ if (e.noise1 == "")
+ e.noise1 = "doors/hydro1.wav";
}
else
{
- if (this.noise == "")
- this.noise = "misc/null.wav";
- if (this.noise1 == "")
- this.noise1 = "misc/null.wav";
+ if (e.noise == "")
+ e.noise = "misc/null.wav";
+ if (e.noise1 == "")
+ e.noise1 = "misc/null.wav";
}

// backwards compatibility with previous version
- if (this.noise3 != "")
- this.noise = this.noise3;
- if (this.noise4 != "")
- this.noise1 = this.noise4;
+ if (e.noise3 != "")
+ e.noise = e.noise3;
+ if (e.noise4 != "")
+ e.noise1 = e.noise4;

- precache_sound (this.noise);
- precache_sound (this.noise1);
- if (this.noise2 != "")
- precache_sound (this.noise2);
+ precache_sound (e.noise);
+ precache_sound (e.noise1);
+ if (e.noise2 != "")
+ precache_sound (e.noise2);

- this.cnt = TRAIN_NEXT_WAIT;
+ e.cnt = TRAIN_NEXT_WAIT;

- if (this.spawnflags & TRAIN_NONSOLID)
+ if (e.spawnflags & TRAIN_NONSOLID)
{
- this.solid = SOLID_NOT;
- this.movetype = MOVETYPE_NOCLIP;
+ e.solid = SOLID_NOT;
+ e.movetype = MOVETYPE_NOCLIP;
}
else
{
- this.solid = SOLID_BSP;
- this.movetype = MOVETYPE_PUSH;
+ e.solid = SOLID_BSP;
+ e.movetype = MOVETYPE_PUSH;
}

- setmodel (this, this.model);
- setsize (this, this.mins , this.maxs);
- setorigin (this, this.origin);
+ e.blocked = base_func_train_blocked;
+ e.use = base_func_train_use_stopped;
+
+ setmodel (e, e.model);
+ setsize (e, e.mins , e.maxs);
+ setorigin (e, e.origin);
+
+ e.speed2 = e.speed;

// start trains on the second frame, to make sure their
// targets have had a chance to spawn

- if (this.movetype == MOVETYPE_PUSH)
- this.nextthink = this.ltime + 0.1;
+ e.think = base_func_train_find;
+
+ if (e.movetype == MOVETYPE_PUSH)
+ e.nextthink = e.ltime + 0.1;
else
- this.nextthink = time + 0.1;
+ e.nextthink = time + 0.1;
+ };

- this.moving_use = FALSE;
- this.find_think = TRUE;
- this.speed2 = this.speed;
+ //--------------------------------------------------------------
+ strip void() base_func_train =
+ {
+ base_func_train_init (self);
};
-};
+// };

/*QUAKED func_train (0 .5 .8) ? RETRIGGER
Trains are moving platforms that players can ride.
@@ -435,15 +476,25 @@ sounds
2) base

*/
-class func_train: base_func_train
-{
- virtual void() init_spawned =
+//----------------------------------------------------------------------
+// class func_train: base_func_train
+// {
+ //--------------------------------------------------------------
+ void(entity e) func_train_init =
{
- train_init ();
+ e.classname = "func_train";
+ e.classtype = CT_FUNC_TRAIN;
+
+ base_func_train_init (e);
};

+ //--------------------------------------------------------------
void() func_train =
{
- this.classtype = CT_FUNC_TRAIN;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ func_train_init (self);
};
-};
+// };

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

Diff qc/func/wall.qc

diff --git a/qc/func/wall.qc b/qc/func/wall.qc
index 62d85f5..87d5f6e 100644
--- a/qc/func/wall.qc
+++ b/qc/func/wall.qc
@@ -2,34 +2,78 @@
// func_wall
//==============================================================================

-class base_func_wall: base_func
-{
+//======================================================================
+// forward declarations
+//======================================================================
+
+// base_func_wall
+void() base_func_wall_use;
+void(entity e) base_func_wall_init;
+strip void() base_func_wall;
+
+// func_wall
+void(entity e) func_wall_init;
+void() func_wall;
+
+//------------------------------------------------------------------------------
+
+//----------------------------------------------------------------------
+// class base_func_wall: base_func
+// {
//--------------------------------------------------------------
- virtual void(entity caller) do_use =
+ void() base_func_wall_use =
{
// change to alternate textures
- this.frame = 1 - this.frame;
+ self.frame = 1 - self.frame;
+ };
+
+ //--------------------------------------------------------------
+ void(entity e) base_func_wall_init =
+ {
+ base_func_init (e);
+ e.use = base_func_wall_use;
+ };
+
+ //--------------------------------------------------------------
+ strip void() base_func_wall =
+ {
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ base_func_wall_init (self);
};
-};
+// };

/*QUAKED func_wall (0 .5 .8) ? X X X X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
This is just a solid wall if not inhibitted
*/
-class func_wall: base_func_wall
-{
+//----------------------------------------------------------------------
+// class func_wall: base_func_wall
+// {
//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) func_wall_init =
{
- this.angles = '0 0 0';
+ self.classname = "func_wall";
+ self.classtype = CT_FUNC_WALL;
+ base_func_wall_init (e);
+
+ self.angles = '0 0 0';
// so it doesn't get pushed by anything
- this.movetype = MOVETYPE_PUSH;
- this.solid = SOLID_BSP;
- setmodel (this, this.model);
+ self.movetype = MOVETYPE_PUSH;
+ self.solid = SOLID_BSP;
+ // already set by base_func_wall_init -- CEV
+ // self.use = base_func_wall_use;
+ setmodel (self, self.model);
};

//--------------------------------------------------------------
void() func_wall =
{
- this.classtype = CT_FUNC_WALL;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ func_wall_init (self);
};
-};
+// };

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

Diff qc/gore.qc

diff --git a/qc/gore.qc b/qc/gore.qc
index 4e2f9c4..2f80918 100644
--- a/qc/gore.qc
+++ b/qc/gore.qc
@@ -1,7 +1,9 @@
//==============================================================================
-// WEAPONS.QC
+// gore.qc -- the meaty bits
//==============================================================================

+//------------------------------------------------------------------------------
+
//----------------------------------------------------------------------
vector() wall_velocity =
{
@@ -19,7 +21,7 @@ vector() wall_velocity =
//----------------------------------------------------------------------
// SpawnMeatSpray
//----------------------------------------------------------------------
-void(vector org, vector vel) SpawnMeatSpray =
+void(vector org, vector vel) spawn_meatspray =
{
local entity missile;

@@ -47,7 +49,7 @@ void(vector org, vector vel) SpawnMeatSpray =
//----------------------------------------------------------------------
// SpawnBlood
//----------------------------------------------------------------------
-void(vector org, vector vel, float damage) SpawnBlood =
+void(vector org, vector vel, float damage) spawn_blood =
{
particle (org, vel * 0.1, 73, damage * 2);
};
@@ -60,13 +62,13 @@ void(float damage) spawn_touchblood =
local vector vel;

vel = wall_velocity() * 0.2;
- SpawnBlood (self.origin + vel* 0.01, vel, damage);
+ spawn_blood (self.origin + vel* 0.01, vel, damage);
};

//----------------------------------------------------------------------
// SpawnChunk
//----------------------------------------------------------------------
-void(vector org, vector vel) SpawnChunk =
+void(vector org, vector vel) spawn_chunk =
{
particle (org, vel * 0.02, 0, 10);
};

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

Diff qc/hazards/ltrail.qc

diff --git a/qc/hazards/ltrail.qc b/qc/hazards/ltrail.qc
index e956628..43da3bd 100644
--- a/qc/hazards/ltrail.qc
+++ b/qc/hazards/ltrail.qc
@@ -8,107 +8,114 @@
// sept 96
//======================================================================

+//======================================================================
// constants
+//======================================================================
+
const float LTRAIL_TOGGLE = 1;
const float LTRAIL_ACTIVE = 2;
-const float LTRAIL_THINK_CHAIN = 1;
-const float LTRAIL_THINK_FIRE = 2;
+
+//======================================================================
+// forward declarations
+//======================================================================
+
+// base_hazard_ltrail
+void() base_hazard_ltrail_chain;
+void() base_hazard_ltrail_fire;
+void() base_hazard_ltrail_use;
+void(entity e) base_hazard_ltrail_init;
+strip void() base_hazard_ltrail;
+
+// ltrail_start
+void(entity e) ltrail_start_init;
+void() ltrail_start;
+
+// ltrail_relay
+void(entity e) ltrail_relay_init;
+void() ltrail_relay;
+
+// ltrail_end
+void(entity e) ltrail_end_init;
+void() ltrail_end;

//------------------------------------------------------------------------------
-class base_hazard_ltrail: base_mapentity
-{
- float ltrail_last_used;
- float think_state;

+//----------------------------------------------------------------------
+// class base_hazard_ltrail: base_mapentity
+// {
//--------------------------------------------------------------
- nonvirtual void() ltrail_chain =
+ void() base_hazard_ltrail_chain =
{
sub_usetargets ();
- this.interaction_flags |= DISABLE_THINK;
+ self.think = sub_null;
};

//--------------------------------------------------------------
- nonvirtual void() ltrail_fire =
+ void() base_hazard_ltrail_fire =
{
-
- if (this.classtype != CT_HAZARD_LTRAIL_END)
+ if (self.classtype != CT_HAZARD_LTRAIL_END)
{
local entity targent;

- if (!this.sounds)
- sound (this, CHAN_VOICE, "weapons/lhit.wav",
+ if (!self.sounds)
+ sound (self, CHAN_VOICE, "weapons/lhit.wav",
1, ATTN_NORM);

- targent = find (world, ::targetname, this.target);
+ targent = find (world, targetname, self.target);
WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
WriteByte (MSG_BROADCAST, TE_LIGHTNING2);
- WriteEntity (MSG_BROADCAST, this);
- WriteCoord (MSG_BROADCAST, this.origin_x);
- WriteCoord (MSG_BROADCAST, this.origin_y);
- WriteCoord (MSG_BROADCAST, this.origin_z);
+ WriteEntity (MSG_BROADCAST, self);
+ WriteCoord (MSG_BROADCAST, self.origin_x);
+ WriteCoord (MSG_BROADCAST, self.origin_y);
+ WriteCoord (MSG_BROADCAST, self.origin_z);
WriteCoord (MSG_BROADCAST, targent.origin_x);
WriteCoord (MSG_BROADCAST, targent.origin_y);
WriteCoord (MSG_BROADCAST, targent.origin_z);
- weapon_lightning::lightning_damage (this.origin,
- targent.origin, this, this.currentammo);
+ fire_lightning (self.origin, targent.origin,
+ self, self.currentammo);
}

- if (this.items < time)
+ if (self.items < time)
{
- this.interaction_flags &= ~DISABLE_THINK;
- this.think_state = LTRAIL_THINK_CHAIN;
- this.nextthink = time + this.frags;
+ self.think = base_hazard_ltrail_chain;
+ self.nextthink = time + self.frags;
}
else
{
- this.interaction_flags &= ~DISABLE_THINK;
- this.think_state = LTRAIL_THINK_FIRE;
- this.nextthink = time + 0.05;
- }
- };
-
- //--------------------------------------------------------------
- virtual void() do_think =
- {
- switch (this.think_state)
- {
- case LTRAIL_THINK_CHAIN:
- ltrail_chain ();
- break;
- case LTRAIL_THINK_FIRE:
- ltrail_fire ();
- break;
- default:
- dprint ("base_hazard_ltrail::do_think: "
- "unhandled think state!\n");
+ self.think = base_hazard_ltrail_fire;
+ self.nextthink = time + 0.05;
}
};

//--------------------------------------------------------------
// was ltrail_start_fire
//--------------------------------------------------------------
- virtual void(entity caller) do_use =
+ void() base_hazard_ltrail_use =
{
// if it's a toggle ltrail, we ignore triggers from
// ltrail_end's when toggled off.
- if (this.spawnflags & LTRAIL_TOGGLE)
+ if (self.spawnflags & LTRAIL_TOGGLE)
{
// user is not a lightning trail; change activity state.
- if (caller.classtype != CT_HAZARD_LTRAIL_END)
+ if (other.classtype != CT_HAZARD_LTRAIL_END)
{
- if (this.spawnflags & LTRAIL_ACTIVE)
+ if (self.spawnflags & LTRAIL_ACTIVE)
{
// currently active
- this.spawnflags -= LTRAIL_ACTIVE;
+ // self.spawnflags &= ~LTRAIL_ACTIVE;
+ self.spawnflags = self.spawnflags -
+ LTRAIL_ACTIVE;
return;
}
else
{
// not active
- this.spawnflags += LTRAIL_ACTIVE;
+ // self.spawnflags |= LTRAIL_ACTIVE;
+ self.spawnflags = self.spawnflags +
+ LTRAIL_ACTIVE;
}
}
- else if (!(this.spawnflags & LTRAIL_ACTIVE))
+ else if (!(self.spawnflags & LTRAIL_ACTIVE))
{
// user is lightning trail, but trail has
// been turned off. ignore the message.
@@ -116,31 +123,52 @@ class base_hazard_ltrail: base_mapentity
}
}

- if (this.classtype == CT_HAZARD_LTRAIL_START)
+ if (self.classtype == CT_HAZARD_LTRAIL_START)
{
- this.items = time + this.weapon;
- ltrail_fire ();
- this.ltrail_last_used = time;
+ self.items = time + self.weapon;
+ base_hazard_ltrail_fire ();
+ // using rad_time instead of ltrailLastUsed -- CEV
+ self.rad_time = time;
}
- else if (this.classtype == CT_HAZARD_LTRAIL_START)
+ else if (self.classtype == CT_HAZARD_LTRAIL_RELAY)
{
- this.items = time + this.weapon;
- ltrail_fire ();
+ self.items = time + self.weapon;
+ base_hazard_ltrail_fire ();
}
else
{
- this.interaction_flags &= ~DISABLE_THINK;
- this.think_state = LTRAIL_THINK_CHAIN;
- this.nextthink = time + this.frags;
+ self.think = base_hazard_ltrail_chain;
+ self.nextthink = time + self.frags;
}
};

//--------------------------------------------------------------
- void() base_hazard_ltrail =
+ void(entity e) base_hazard_ltrail_init =
{
- this.classgroup |= CG_HAZARD_LTRAIL;
+ base_mapentity_init (e);
+
+ e.use = base_hazard_ltrail_use;
+
+ precache_sound ("weapons/lhit.wav");
+ e.movetype = MOVETYPE_NONE;
+ e.solid = SOLID_BBOX;
+
+ if (e.currentammo == 0)
+ e.currentammo = 25;
+
+ if (e.weapon == 0)
+ e.weapon = 0.3;
+
+ if (e.frags == 0)
+ e.frags = 0.3;
+ };
+
+ //--------------------------------------------------------------
+ strip void() base_hazard_ltrail =
+ {
+ base_hazard_ltrail_init (self);
};
-};
+// };

/*QUAKED ltrail_start (0 1 0) (-8 -8 -8) (8 8 8) LT_TOGGLE START_ON X X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY

@@ -156,41 +184,38 @@ Default is 0.3 seconds.

Set the LT_TOGGLE checkbox if you want the lightning shooter to continuously fire until triggered again.
*/
-class ltrail_start: base_hazard_ltrail
-{
+//----------------------------------------------------------------------
+// class ltrail_start: base_hazard_ltrail
+// {
//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) ltrail_start_init =
{
- this.ltrail_last_used = time;
-
- precache_sound ("weapons/lhit.wav");
- this.movetype = MOVETYPE_NONE;
- this.solid = SOLID_BBOX;
- this.interaction_flags |= DISABLE_THINK;
-
- if (this.currentammo == 0)
- this.currentammo = 25;
+ e.classname = "ltrail_start";
+ e.classtype = CT_HAZARD_LTRAIL_START;

- if (this.weapon == 0)
- this.weapon = 0.3;
+ base_hazard_ltrail_init (e);

- if (this.frags == 0)
- this.frags = 0.3;
+ // using rad_time instead of ltrailLastUsed -- CEV
+ e.rad_time = time;

- if (this.spawnflags & LTRAIL_ACTIVE)
+ if (e.spawnflags & LTRAIL_ACTIVE)
{
- this.items = time + 99999999;
- this.think_state = LTRAIL_THINK_FIRE;
- this.nextthink = time + 0.1;
+ e.items = time + 99999999;
+ e.think = base_hazard_ltrail_fire;
+ e.nextthink = time + 0.1;
}
};

//--------------------------------------------------------------
void() ltrail_start =
{
- this.classtype = CT_HAZARD_LTRAIL_START;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ ltrail_start_init (self);
};
-};
+// };

/*QUAKED ltrail_relay (0 1 0) (-8 -8 -8) (8 8 8) X X X X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
Relay point of a lightning trail.
@@ -203,32 +228,28 @@ Default is 0.3 seconds.
Set weapon to amount of time to be firing the lightning.
Default is 0.3 seconds.
*/
-class ltrail_relay: base_hazard_ltrail
-{
+//----------------------------------------------------------------------
+// class ltrail_relay: base_hazard_ltrail
+// {
//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) ltrail_relay_init =
{
- precache_sound ("weapons/lhit.wav");
- this.movetype = MOVETYPE_NONE;
- this.solid = SOLID_BBOX;
- this.interaction_flags |= DISABLE_THINK;
-
- if (this.currentammo == 0)
- this.currentammo = 25;
+ e.classname = "ltrail_relay";
+ e.classtype = CT_HAZARD_LTRAIL_RELAY;

- if (this.weapon == 0)
- this.weapon = 0.3;
-
- if (this.frags == 0)
- this.frags = 0.3;
+ base_hazard_ltrail_init (e);
};

//--------------------------------------------------------------
void() ltrail_relay =
{
- this.classtype = CT_HAZARD_LTRAIL_RELAY;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ ltrail_relay_init (self);
};
-};
+// };

/*QUAKED ltrail_end (0 1 0) (-8 -8 -8) (8 8 8) X X X X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
Ending point of a lightning trail.
@@ -237,29 +258,25 @@ Does not fire any lightning.
Set frags to amount of time before next item is triggered.
Default is 0.3 seconds.
*/
-class ltrail_end: base_hazard_ltrail
-{
+//----------------------------------------------------------------------
+// class ltrail_end: base_hazard_ltrail
+// {
//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) ltrail_end_init =
{
- precache_sound ("weapons/lhit.wav");
- this.movetype = MOVETYPE_NONE;
- this.solid = SOLID_BBOX;
- this.interaction_flags |= DISABLE_THINK;
-
- if (this.currentammo == 0)
- this.currentammo = 25;
+ e.classname = "ltrail_end";
+ e.classtype = CT_HAZARD_LTRAIL_END;

- if (this.weapon == 0)
- this.weapon = 0.3;
-
- if (this.frags == 0)
- this.frags = 0.3;
+ base_hazard_ltrail_init (e);
};

//--------------------------------------------------------------
void() ltrail_end =
{
- this.classtype = CT_HAZARD_LTRAIL_END;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ ltrail_end_init (self);
};
-};
+// };

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

Diff qc/hazards/shooter.qc

diff --git a/qc/hazards/shooter.qc b/qc/hazards/shooter.qc
index fd05744..6cfa1e5 100644
--- a/qc/hazards/shooter.qc
+++ b/qc/hazards/shooter.qc
@@ -4,7 +4,10 @@

// MED 11/09/96 added new spawnflags -- taken from hipdefs.qc - dumptruck_ds

+//======================================================================
// constants
+//======================================================================
+
const float SHOOTER_SPAWNFLAG_SUPERSPIKE = 1;
const float SHOOTER_SPAWNFLAG_LASER = 2;
const float SHOOTER_SPAWNFLAG_LAVABALL = 4;
@@ -14,18 +17,44 @@ const float SHOOTER_SPAWNFLAG_GRENADE = 32;
const float SHOOTER_SPAWNFLAG_GIBS = 64;
const float SHOOTER_SPAWNFLAG_SILENT = 128;

+//======================================================================
+// forward declarations
+//======================================================================
+
+// base_hazard_shooter
+void() base_hazard_shooter_think;
+void() base_hazard_shooter_use;
+void(entity e) base_hazard_shooter_init;
+strip void() base_hazard_shooter;
+
+// trap_spikeshooter
+void(entity e) trap_spikeshooter_init;
+void() trap_spikeshooter;
+
+// trap_shooter
+void(entity e) trap_shooter_init;
+void() trap_shooter;
+
+// trap_switched_shooter
+void() trap_switched_shooter_use;
+void(entity e) trap_switched_shooter_init;
+void() trap_switched_shooter;
+
//------------------------------------------------------------------------------
-class base_hazard_shooter: base_mapentity
-{
+
+//----------------------------------------------------------------------
+// class base_hazard_shooter: base_mapentity
+// {
//--------------------------------------------------------------
// shooter_think -- MED 11/01/96 added state capability
//--------------------------------------------------------------
- virtual void() do_think =
+ void() base_hazard_shooter_think =
{
- if (this.state)
- this.do_use (other);
+ if (self.state)
+ // call the use/firing function directly -- CEV
+ base_hazard_shooter_use ();

- this.nextthink = time + this.wait;
+ self.nextthink = time + self.wait;
};

//--------------------------------------------------------------
@@ -33,188 +62,142 @@ class base_hazard_shooter: base_mapentity
// MED 11/09/96 added lava ball and rocket
// dumptruck_ds added voreball and grenades
//--------------------------------------------------------------
- virtual void(entity caller) do_use =
+ void() base_hazard_shooter_use =
{
- if (this.spawnflags & SHOOTER_SPAWNFLAG_LASER)
+ if (self.spawnflags & SHOOTER_SPAWNFLAG_LASER)
{
- if (!(this.spawnflags & SHOOTER_SPAWNFLAG_SILENT))
- sound (this, CHAN_VOICE, "enforcer/enfire.wav",
+ if (!(self.spawnflags & SHOOTER_SPAWNFLAG_SILENT))
+ sound (self, CHAN_VOICE, "enforcer/enfire.wav",
1, ATTN_NORM);

- local vector laser_velocity = normalize (this.movedir);
+ local vector laser_velocity = normalize (self.movedir);
// SetSpeed
- laser_velocity *= min (LASER_SPEED * proj_speed_mod,
- frame_maxvelocity);
+ laser_velocity *= min (
+ LASER_SPEED * self.proj_speed_mod,
+ world_maxvelocity);

// fire_laser
- spawn (projectile_laser,
- owner: this,
- origin: this.origin,
- velocity: laser_velocity,
- homing: this.homing,
- proj_speed_mod: this.proj_speed_mod,
- snd_hit: this.snd_hit,
- mdl_proj: this.mdl_proj,
- skin_proj: this.skin_proj,
- // why? -- CEV
- spawnflags: this.spawnflags);
+ spawn_projectile_laser (self, self.origin,
+ laser_velocity);
}
- else if (this.spawnflags & SHOOTER_SPAWNFLAG_LAVABALL)
+ else if (self.spawnflags & SHOOTER_SPAWNFLAG_LAVABALL)
{
- if (!(this.spawnflags & SHOOTER_SPAWNFLAG_SILENT))
+ if (!(self.spawnflags & SHOOTER_SPAWNFLAG_SILENT))
// dms
- sound (this, CHAN_VOICE, "boss1/throw.wav",
+ sound (self, CHAN_VOICE, "boss1/throw.wav",
1, ATTN_NORM);

- spawn (projectile_lavaball,
- owner: this,
- origin: this.origin,
- velocity: this.movedir * 600,
- // custom spin of projectile - monster_shambler
- avelocity: this.cust_avelocity,
- // ShalMissileTouch
- direct_damage: 40,
- splash_damage: 40,
- // homing parameters
- homing: this.homing,
- enemy: this.enemy,
- proj_basespeed: 600,
- proj_speed_mod: this.proj_speed_mod,
- // custom model & skin
- mdl_proj: this.mdl_proj,
- skin_proj: this.skin_proj);
+ spawn_projectile_lavaball (self, self.origin,
+ self.movedir * 600);
}
- else if (this.spawnflags & SHOOTER_SPAWNFLAG_ROCKET)
+ else if (self.spawnflags & SHOOTER_SPAWNFLAG_ROCKET)
{
- if (!(this.spawnflags & SHOOTER_SPAWNFLAG_SILENT))
- sound (this, CHAN_VOICE, "weapons/sgun1.wav",
+ if (!(self.spawnflags & SHOOTER_SPAWNFLAG_SILENT))
+ sound (self, CHAN_VOICE, "weapons/sgun1.wav",
1, ATTN_NORM);

- spawn (projectile_rocket,
- owner: this,
- origin: this.origin,
- // set rocket speed
- velocity: this.movedir * ROCKET_SPEED,
- homing: this.homing,
- enemy: this.enemy,
- proj_basespeed: ROCKET_SPEED,
- proj_speed_mod: this.proj_speed_mod,
- // custom model & skin
- mdl_proj: this.mdl_proj,
- skin_proj: this.skin_proj);
+ spawn_projectile_rocket (self, self.origin,
+ self.movedir * ROCKET_SPEED,
+ self.proj_basespeed);
}
- else if (this.spawnflags & SHOOTER_SPAWNFLAG_VOREBALL)
+ else if (self.spawnflags & SHOOTER_SPAWNFLAG_VOREBALL)
{
- if (!(this.spawnflags & SHOOTER_SPAWNFLAG_SILENT))
- sound (this, CHAN_VOICE, "shalrath/attack2.wav",
+ if (!(self.spawnflags & SHOOTER_SPAWNFLAG_SILENT))
+ sound (self, CHAN_VOICE, "shalrath/attack2.wav",
1, ATTN_NORM);

- // note that we're not setting homing -- CEV
- spawn (projectile_voreball,
- owner: this,
- origin: this.origin,
- // was 300 (says dms), 600 in PD3 -- CEV
- velocity: this.movedir * VOREBALL_SPEED,
- avelocity: '0 0 400');
+ spawn_projectile_voreball (self, self.origin,
+ self.movedir * VOREBALL_SPEED,
+ self.proj_basespeed);
}
- else if (this.spawnflags & SHOOTER_SPAWNFLAG_GRENADE)
+ else if (self.spawnflags & SHOOTER_SPAWNFLAG_GRENADE)
{
- if (!(this.spawnflags & SHOOTER_SPAWNFLAG_SILENT))
- sound (this, CHAN_VOICE, "weapons/grenade.wav",
+ if (!(self.spawnflags & SHOOTER_SPAWNFLAG_SILENT))
+ sound (self, CHAN_VOICE, "weapons/grenade.wav",
1, ATTN_NORM);
- local vector gnade_velocity = this.movedir * 600 +
+
+ local vector gnade_velocity = self.movedir * 600 +
v_up * 200 + crandom() * v_right * 10 +
crandom() * v_up * 10;
- spawn (projectile_grenade,
- owner: this,
- origin: this.origin,
- velocity: gnade_velocity);
+
+ spawn_projectile_grenade (self, self.origin,
+ gnade_velocity);
}
- else if (this.spawnflags & SHOOTER_SPAWNFLAG_GIBS)
+ else if (self.spawnflags & SHOOTER_SPAWNFLAG_GIBS)
{
- if (!(this.spawnflags & SHOOTER_SPAWNFLAG_SILENT))
- sound (this, CHAN_VOICE, "zombie/z_shot1.wav",
+ if (!(self.spawnflags & SHOOTER_SPAWNFLAG_SILENT))
+ sound (self, CHAN_VOICE, "zombie/z_shot1.wav",
1, ATTN_NORM);
- local vector znade_velocity = this.movedir * 600 +
+
+ local vector znade_velocity = self.movedir * 600 +
v_up * 200 + crandom() * v_right * 10 +
crandom() * v_up * 10;

- spawn (projectile_zombiechunk,
- owner: this,
- origin: this.origin,
- velocity: znade_velocity);
+ spawn_projectile_zombiechunk (self, self.origin,
+ znade_velocity);
}
else
{
- if (!(this.spawnflags & SHOOTER_SPAWNFLAG_SILENT))
+ if (!(self.spawnflags & SHOOTER_SPAWNFLAG_SILENT))
// changed vol fromt 1 to 0.666 -- CEV
- sound (this, CHAN_VOICE, "weapons/spike2.wav",
+ sound (self, CHAN_VOICE, "weapons/spike2.wav",
0.666, ATTN_NORM);

local float damage;

- if (this.spawnflags & SHOOTER_SPAWNFLAG_SUPERSPIKE)
+ if (self.spawnflags & SHOOTER_SPAWNFLAG_SUPERSPIKE)
damage = SPIKE_SUPER_DAMAGE;
else
damage = SPIKE_NORMAL_DAMAGE;

// shooter spikes move at half the speed of
// player spikes -- CEV
- spawn (projectile_spike,
- owner: this,
- origin: this.origin,
- velocity: this.movedir * 500,
- direct_damage: damage,
- // homing fields
- homing: this.homing,
- enemy: this.enemy,
- proj_basespeed: 500,
- proj_speed_mod: this.proj_speed_mod,
- // model fields
- mdl_proj: this.mdl_proj,
- skin_proj: this.skin_proj,
- // sound
- snd_hit: this.snd_hit);
+ spawn_projectile_spike (self, self.origin,
+ self.movedir * 500, damage, 500);
}
};

//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) base_hazard_shooter_init =
{
- if (this.proj_speed_mod <= 0)
- this.proj_speed_mod = 1;
+ base_mapentity_init (e);
+ e.think = base_hazard_shooter_think;
+ e.use = base_hazard_shooter_use;

- sub_setmovedir ();
+ if (e.proj_speed_mod <= 0)
+ e.proj_speed_mod = 1;

- if (this.spawnflags & SHOOTER_SPAWNFLAG_LASER)
+ sub_setmovedir (e);
+
+ if (e.spawnflags & SHOOTER_SPAWNFLAG_LASER)
{
precache_model2 ("progs/laser.mdl");
precache_sound2 ("enforcer/enfire.wav");
precache_sound2 ("enforcer/enfstop.wav");
}
- else if (this.spawnflags & SHOOTER_SPAWNFLAG_LAVABALL)
+ else if (e.spawnflags & SHOOTER_SPAWNFLAG_LAVABALL)
{
precache_model ("progs/lavaball.mdl");
// precache_sound2 ("knight/sword2.wav"); // dms
precache_sound2 ("boss1/throw.wav"); // dms
}
- else if (this.spawnflags & SHOOTER_SPAWNFLAG_ROCKET)
+ else if (e.spawnflags & SHOOTER_SPAWNFLAG_ROCKET)
{
precache_model ("progs/missile.mdl");
precache_sound ("weapons/sgun1.wav");
}
- else if (this.spawnflags & SHOOTER_SPAWNFLAG_VOREBALL)
+ else if (e.spawnflags & SHOOTER_SPAWNFLAG_VOREBALL)
{
precache_model ("progs/v_spike.mdl");
precache_sound ("shalrath/attack2.wav");
}
- else if (this.spawnflags & SHOOTER_SPAWNFLAG_GRENADE)
+ else if (e.spawnflags & SHOOTER_SPAWNFLAG_GRENADE)
{
precache_model ("progs/grenade.mdl");
// grenade launcher
precache_sound ("weapons/grenade.wav");
}
- else if (this.spawnflags & SHOOTER_SPAWNFLAG_GIBS)
+ else if (e.spawnflags & SHOOTER_SPAWNFLAG_GIBS)
{
precache_model ("progs/zom_gib.mdl");
// Zombie gibs
@@ -227,48 +210,75 @@ class base_hazard_shooter: base_mapentity
precache_sound ("weapons/spike2.wav");
}
};
-};
+
+ //--------------------------------------------------------------
+ strip void() base_hazard_shooter =
+ {
+ base_hazard_shooter_init (self);
+ };
+// };

/*QUAKED trap_spikeshooter (0 .5 .8) (-8 -8 -8) (8 8 8) superspike laser lavaball rocket silent X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY

When triggered, fires a spike in the direction set in QuakeEd.
Laser is only for REGISTERED.
*/
-class trap_spikeshooter: base_hazard_shooter
-{
+//----------------------------------------------------------------------
+// class trap_spikeshooter: base_hazard_shooter
+// {
+
+ //--------------------------------------------------------------
+ void(entity e) trap_spikeshooter_init =
+ {
+ e.classname = "trap_spikeshooter";
+ e.classtype = CT_HAZARD_SPIKESHOOTER;
+ base_hazard_shooter_init (e);
+ };
+
//--------------------------------------------------------------
void() trap_spikeshooter =
{
- this.classtype = CT_HAZARD_SPIKESHOOTER;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ trap_spikeshooter_init (self);
};
-};
+// };

/*QUAKED trap_shooter (0 .5 .8) (-8 -8 -8) (8 8 8) superspike laser lavaball rocket silent X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
Continuously fires spikes.
"wait" time between spike (1.0 default)
"nextthink" delay before firing first spike, so multiple shooters can be stagered.
*/
-class trap_shooter: base_hazard_shooter
-{
+//----------------------------------------------------------------------
+// class trap_shooter: base_hazard_shooter
+// {
//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) trap_shooter_init =
{
- super::init_spawned ();
+ e.classname = "trap_shooter";
+ e.classtype = CT_HAZARD_SHOOTER;
+ base_hazard_shooter_init (e);

- if (this.wait == 0)
- this.wait = 1;
+ if (e.wait == 0)
+ e.wait = 1;

// MED 11/01/96 added state capability
- this.state = 1;
- this.nextthink = this.nextthink + this.wait + this.ltime;
+ e.state = 1;
+ e.nextthink = e.nextthink + e.wait + e.ltime;
};

//--------------------------------------------------------------
void() trap_shooter =
{
- this.classtype = CT_HAZARD_SHOOTER;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ trap_shooter_init (self);
};
-};
+// };

//MED 11/01/96 added new function
/*QUAKED trap_switched_shooter (0 .5 .8) (-8 -8 -8) (8 8 8) superspike laser lavaball rocket silent X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
@@ -277,29 +287,39 @@ Continuously fires spikes.
"nextthink" delay before firing first spike, so multiple shooters can be stagered.
"state" 0 initially off, 1 initially on. (0 default)
*/
-class trap_switched_shooter: base_hazard_shooter
-{
+//----------------------------------------------------------------------
+// class trap_switched_shooter: base_hazard_shooter
+// {
//--------------------------------------------------------------
// trap_shooter_use -- MED 11/01/96 added new use function
//--------------------------------------------------------------
- virtual void(entity caller) do_use =
+ void() trap_switched_shooter_use =
{
- this.state = 1 - this.state;
+ self.state = 1 - self.state;
};

//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) trap_switched_shooter_init =
{
- super::init_spawned ();
- if (this.wait == 0)
- this.wait = 1;
+ e.classname = "trap_switched_shooter";
+ e.classtype = CT_HAZARD_SWITCHED_SHOOTER;
+ base_hazard_shooter_init (e);
+ e.use = trap_switched_shooter_use;
+
+ if (e.wait == 0)
+ e.wait = 1;

// MED 11/01/96 added state capability
- this.nextthink = this.nextthink + this.wait + this.ltime;
+ e.nextthink = e.nextthink + e.wait + e.ltime;
};

+ //--------------------------------------------------------------
void() trap_switched_shooter =
{
- this.classtype = CT_HAZARD_SWITCHED_SHOOTER;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ trap_switched_shooter_init (self);
};
-};
+// };

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

Diff qc/info/camera.qc

diff --git a/qc/info/camera.qc b/qc/info/camera.qc
index e34777f..3f002d8 100644
--- a/qc/info/camera.qc
+++ b/qc/info/camera.qc
@@ -2,73 +2,124 @@
// info_movie_camera, info_focal_point -- was in cutscene.qc
//==============================================================================

+//======================================================================
+// forward declarations
+//======================================================================
+
+// info_movie_camera
+void() info_movie_camera_touch;
+entity(entity src, vector org) spawn_info_movie_camera;
+void(entity e) info_movie_camera_init;
+void() info_movie_camera;
+
+// info_focal_point
+entity(entity src, vector org) spawn_info_focal_point;
+void(entity e) info_focal_point_init;
+void() info_focal_point;
+
+//------------------------------------------------------------------------------
+
/*QUAKED info_movie_camera (.5 .5 .5) (-8 -8 -8) (8 8 32) X X X X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
This is the destination marker for a camera. It should have a "targetname"
field with the same value as a camera-trigger's "target" field.
*/
-class info_movie_camera: base_mapentity
-{
+//----------------------------------------------------------------------
+// class info_movie_camera: base_mapentity
+// {
//--------------------------------------------------------------
- virtual void() do_think =
- {
- remove (this);
- };
-
- //--------------------------------------------------------------
- virtual void(entity toucher) do_touch =
+ void() info_movie_camera_touch =
{
local string temps;

- if (toucher.classname != "camera")
+ if (other.classname != "camera")
return;

- temps = this.target;
- this.target = this.message;
+ temps = self.target;
+ self.target = self.message;
sub_usetargets ();
- this.target = temps;
- if (this.cnt)
+ self.target = temps;
+ if (self.cnt)
return;

- this.nextthink = time + 10;
- this.solid = SOLID_NOT;
+ self.nextthink = time + 10;
+ self.solid = SOLID_NOT;
+ };
+
+ //--------------------------------------------------------------
+ entity(entity src, vector org) spawn_info_movie_camera =
+ {
+ local entity e = spawn ();
+ e.owner = src;
+ e.origin = org;
+ info_movie_camera_init (e);
+ return e;
};

//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) info_movie_camera_init =
{
// this does nothing, just serves as a target spot
- /*
- if (vision)
- return;
- */
+ base_mapentity_init (e);
// ...more than a spot in Zer mode.
- // this.use = sub_null;
- this.solid = SOLID_TRIGGER;
- setorigin (this, this.origin);
- setsize (this, '-8 -8 -8', '8 8 8');
+ e.classname = "info_movie_camera";
+ e.classtype = CT_INFO_MOVIE_CAMERA;
+ e.solid = SOLID_TRIGGER;
+ e.think = sub_remove;
+ e.touch = info_movie_camera_touch;
+ // e.use = sub_null;
+ setorigin (e, e.origin);
+ setsize (e, '-8 -8 -8', '8 8 8');
};

//--------------------------------------------------------------
void() info_movie_camera =
{
- this.classtype = CT_INFO_MOVIE_CAMERA;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ info_movie_camera_init (self);
};
-};
+// };

/*QUAKED info_focal_point (.5 .5 .5) (-8 -8 -8) (8 8 32) X X X X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
This is the point that the camera will face. It should have a "targetname"
field with the same value as a camera-trigger's "focal_point" field.
*/
-class info_focal_point: base_mapentity
-{
+//----------------------------------------------------------------------
+// class info_focal_point: base_mapentity
+// {
+ // PM: This entity is kept only for map compatibility reasons.
+ // Otherwise, this entity is redundant. Use 'info_notnull'
+ // instead.
+
+ // just holds a spot for the focal point.
+
+ //--------------------------------------------------------------
+ entity(entity src, vector org) spawn_info_focal_point =
+ {
+ local entity e = spawn ();
+ e.owner = src;
+ e.origin = org;
+ info_focal_point_init (e);
+ return e;
+ };
+
+ //--------------------------------------------------------------
+ void(entity e) info_focal_point_init =
+ {
+ base_mapentity_init (e);
+ e.classname = "info_focal_point";
+ e.classtype = CT_INFO_FOCAL_POINT;
+ };
+
//--------------------------------------------------------------
void() info_focal_point =
{
- // PM: This entity is kept only for map compatibility reasons.
- // Otherwise, this entity is redundant. Use 'info_notnull'
- // instead.
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;

- // just holds a spot for the focal point.
- this.classtype = CT_INFO_FOCAL_POINT;
+ info_focal_point_init (self);
};
-};
+// };

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

Diff qc/info/intermission.qc

diff --git a/qc/info/intermission.qc b/qc/info/intermission.qc
index 06e69dc..d5569a9 100644
--- a/qc/info/intermission.qc
+++ b/qc/info/intermission.qc
@@ -2,35 +2,98 @@
// info_intermission
//==============================================================================

+//======================================================================
+// forward declarations
+//======================================================================
+
+// info_intermission
+entity(entity src, vector org) spawn_info_intermission;
+void(entity e) info_intermission_init;
+void() info_intermission;
+
+// info_intermissiontext
+entity(entity src, vector org, string smsg, float fcnt)
+ spawn_info_intermissiontext;
+void(entity e) info_intermissiontext_init;
+void() info_intermissiontext;
+
+//------------------------------------------------------------------------------
+
/*QUAKED info_intermission (1 0.5 0.5) (-16 -16 -16) (16 16 16) X X X X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY

This is the camera point for the intermission.
Use mangle instead of angle, so you can set pitch or roll as well as yaw. 'pitch roll yaw'
*/
-class info_intermission: base_mapentity
-{
+
+//----------------------------------------------------------------------
+// class info_intermission: base_mapentity
+// {
+ //--------------------------------------------------------------
+ entity(entity src, vector org) spawn_info_intermission =
+ {
+ local entity e = spawn ();
+ e.owner = src;
+ e.origin = org;
+ info_intermission_init (e);
+ return e;
+ };
+
+ //--------------------------------------------------------------
+ void(entity e) info_intermission_init =
+ {
+ base_mapentity_init (e);
+ e.classname = "info_intermission";
+ e.classtype = CT_INFO_INTERMISSION;
+ };
+
//--------------------------------------------------------------
void() info_intermission =
{
- this.classtype = CT_INFO_INTERMISSION;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ info_intermission_init (self);
};
-};
+// };

//----------------------------------------------------------------------
-class info_intermissiontext: base_mapentity
-{
+// class info_intermissiontext: base_mapentity
+// {
//--------------------------------------------------------------
- virtual void() init_spawned =
+ entity(entity src, vector org, string smsg, float fcnt)
+ spawn_info_intermissiontext =
{
- if (this.message == "" || this.cnt == 0)
+ local entity e = spawn ();
+ e.origin = org;
+ e.message = smsg;
+ e.cnt = fcnt;
+ info_intermissiontext_init (e);
+ return e;
+ };
+
+ //--------------------------------------------------------------
+ void(entity e) info_intermissiontext_init =
+ {
+ base_mapentity_init (e);
+ e.classname = "info_intermissiontext";
+ e.classtype = CT_INFO_INTERMISSIONTEXT;
+
+ if (e.message == "" || e.cnt == 0)
{
- objerror ("endscreen lacks required fields");
+ objerror (sprintf("info_intermissiontext_init: "
+ "endscreen lacks required fields: message %s"
+ ", cnt %g\n", e.message, e.cnt));
}
};

//--------------------------------------------------------------
void() info_intermissiontext =
{
- this.classtype = CT_INFO_INTERMISSIONTEXT;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ info_intermissiontext_init (self);
};
-};
+// };

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

Diff qc/info/notnull.qc

diff --git a/qc/info/notnull.qc b/qc/info/notnull.qc
index 89a165f..635beb2 100644
--- a/qc/info/notnull.qc
+++ b/qc/info/notnull.qc
@@ -2,15 +2,50 @@
// info_notnull
//==============================================================================

+//======================================================================
+// forward declarations
+//======================================================================
+
+// info_notnull
+entity(entity src, vector org) spawn_info_notnull;
+void(entity e) info_notnull_init;
+void() info_notnull;
+
+//------------------------------------------------------------------------------
+
/*QUAKED info_notnull (0 0.5 0) (-4 -4 -4) (4 4 4) X X X X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY

Never used in the or
*/
-class info_notnull: base_mapentity
-{
+
+//----------------------------------------------------------------------
+// class info_notnull: base_mapentity
+// {
+ //--------------------------------------------------------------
+ entity(entity src, vector org) spawn_info_notnull =
+ {
+ local entity e = spawn ();
+ e.owner = src;
+ e.origin = org;
+ info_notnull_init (e);
+ return e;
+ };
+
+ //--------------------------------------------------------------
+ void(entity e) info_notnull_init =
+ {
+ base_mapentity_init (e);
+ e.classname = "info_notnull";
+ e.classtype = CT_INFO_NOTNULL;
+ };
+
//--------------------------------------------------------------
void() info_notnull =
{
- this.classtype = CT_INFO_NOTNULL;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ info_notnull_init (self);
};
-};
+// };

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

Diff qc/info/null.qc

diff --git a/qc/info/null.qc b/qc/info/null.qc
index f3f3efa..0fb0430 100644
--- a/qc/info/null.qc
+++ b/qc/info/null.qc
@@ -2,16 +2,51 @@
// info_null
//==============================================================================

+//======================================================================
+// forward declarations
+//======================================================================
+
+// info_null
+entity(entity src, vector org) spawn_info_null;
+void(entity e) info_null_init;
+void() info_null;
+
+//------------------------------------------------------------------------------
+
/*QUAKED info_null (0 0.5 0) (-4 -4 -4) (4 4 4) X X X X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY

Used as a positional target for spotlights, etc.
*/
-class info_null: base_mapentity
-{
+
+//----------------------------------------------------------------------
+// class info_null: base_mapentity
+// {
+ //--------------------------------------------------------------
+ entity(entity src, vector org) spawn_info_null =
+ {
+ local entity e = spawn ();
+ e.owner = src;
+ e.origin = org;
+ info_null_init (e);
+ return e;
+ };
+
+ //--------------------------------------------------------------
+ void(entity e) info_null_init =
+ {
+ base_mapentity_init (e);
+ e.classname = "info_null";
+ e.classtype = CT_INFO_NULL;
+ remove (self);
+ };
+
//--------------------------------------------------------------
void() info_null =
{
- this.classtype = CT_INFO_NULL;
- remove (this);
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ info_null_init (self);
};
-};
+// };

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

Diff qc/info/path_corner.qc

diff --git a/qc/info/path_corner.qc b/qc/info/path_corner.qc
index e6769d3..dc8ff3d 100644
--- a/qc/info/path_corner.qc
+++ b/qc/info/path_corner.qc
@@ -2,150 +2,134 @@
// path_corner
//==============================================================================

-//----------------------------------------------------------------------
-// MOVETARGET CODE
-//
-// The angle of the movetarget effects standing and bowing direction, but
-// has no effect on movement, which always 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
-//----------------------------------------------------------------------
-void() movetarget_f =
-{
- if (!self.targetname)
- objerror ("monster_movetarget: no targetname");
+//======================================================================
+// forward declarations
+//======================================================================

- self.solid = SOLID_TRIGGER;
- self.touch = t_movetarget;
- setsize (self, '-8 -8 -8', '8 8 8');
+void() path_corner_movetarget_touch;
+void(entity e) path_corner_movetarget_init;
+entity(entity src, vector org) spawn_path_corner;
+void(entity e) path_corner_init;
+void() path_corner;

-};
+//------------------------------------------------------------------------------

+/*QUAKED path_corner (0.5 0.3 0) (-8 -8 -8) (8 8 8)
+Monsters will continue walking towards the next target corner.
+*/
//----------------------------------------------------------------------
-// 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)
- // fighting, not following a path
- return;
-
- temp = self;
- self = other;
- other = temp;
-
- if (self.classname == "monster_ogre")
- // play chainsaw drag sound -- sound_custom -- dumptruck_ds
- sound_misc (self, CHAN_VOICE, "ogre/ogdrag.wav", 1, ATTN_IDLE);
-
- // 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)
+// class path_corner: base_mapentity
+// {
+ //--------------------------------------------------------------
+ // t_movetarget
+ //
+ // Something has bumped into a movetarget. If it is a monster
+ // moving towards it, change the next destination and continue.
+ //--------------------------------------------------------------
+ void() path_corner_movetarget_touch =
{
- self.pausetime = time + 999999;
- // TODO CEV
- if (self.classgroup & CG_MONSTER)
- {
- ((base_monster)self).think_stand ();
- }
- else
+ local entity stemp;
+
+ if (other.movetarget != self)
+ return;
+
+ if (other.enemy)
+ // fighting, not following a path
+ return;
+
+ stemp = self;
+ self = other;
+ other = stemp;
+
+ if (self.classtype == CT_MONSTER_OGRE)
+ // chainsaw drag sound -- sound_custom -- dumptruck_ds
+ sound_misc (self, CHAN_VOICE, "ogre/ogdrag.wav",
+ 1, ATTN_IDLE);
+
+ // 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)
{
- dprint (sprintf("t_movetarget: ERROR tried to call "
- "th_stand on classname %s!\n", self.classname));
+ self.pausetime = time + 999999;
+ // TODO CEV
+ /*
+ if (self.classgroup & CG_MONSTER)
+ {
+ self.think_stand ();
+ }
+ else
+ {
+ dprint (sprintf("t_movetarget: ERROR tried "
+ "to call th_stand on classname %s!\n",
+ self.classname));
+ }
+ */
+ return;
}
- return;
- }
-};
+ };

-/*QUAKED path_corner (0.5 0.3 0) (-8 -8 -8) (8 8 8)
-Monsters will continue walking towards the next target corner.
-*/
-class path_corner: base_mapentity
-{
- // support for modeltrain -- CEV
- float first_frame;
- float first_frame2;
- float last_frame;
- float last_frame2;
- float frtime;
- float frtime2;
- float animtype;
- float animtype2;
- float multiplier;
- float speed2;
+ //--------------------------------------------------------------
+ // MOVETARGET CODE
+ //
+ // The angle of the movetarget effects standing and bowing
+ // direction, but has no effect on movement, which always 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
+ //--------------------------------------------------------------
+ void(entity e) path_corner_movetarget_init =
+ {
+ if (!e.targetname)
+ objerror ("path_corner_movetarget_init: no targetname");
+
+ e.solid = SOLID_TRIGGER;
+ e.touch = path_corner_movetarget_touch;
+ setsize (e, '-8 -8 -8', '8 8 8');
+ };

//--------------------------------------------------------------
- virtual void(string fieldname, string fieldvalue) init_field =
+ entity(entity src, vector org) spawn_path_corner =
{
- switch (fieldname)
- {
- case "first_frame":
- first_frame = stof (fieldvalue);
- break;
- case "first_frame2":
- first_frame2 = stof (fieldvalue);
- break;
- case "last_frame":
- last_frame = stof (fieldvalue);
- break;
- case "last_frame2":
- last_frame2 = stof (fieldvalue);
- break;
- case "frtime":
- frtime = stof (fieldvalue);
- break;
- case "frtime2":
- frtime2 = stof (fieldvalue);
- break;
- case "animtype":
- animtype = stof (fieldvalue);
- break;
- case "animtype2":
- animtype2 = stof (fieldvalue);
- break;
- case "multiplier":
- multiplier = stof (fieldvalue);
- break;
- case "speed2":
- speed2 = stof (fieldvalue);
- break;
- default:
- super::init_field (fieldname, fieldvalue);
- }
+ local entity e = spawn ();
+ e.owner = src;
+ e.origin = org;
+ path_corner_init (e);
+ return e;
};

//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) path_corner_init =
{
- if (this.noise != __NULL__ && this.noise != "")
- precache_sound (this.noise);
- if (this.noise2 != __NULL__ && this.noise2 != "")
- precache_sound (this.noise2);
+ base_mapentity_init (e);
+ e.classname = "path_corner";
+ e.classtype = CT_PATH_CORNER;
+
+ if (e.noise != __NULL__ && e.noise != "")
+ precache_sound (e.noise);
+ if (e.noise2 != __NULL__ && e.noise2 != "")
+ precache_sound (e.noise2);

- movetarget_f ();
+ path_corner_movetarget_init (e);
};

//--------------------------------------------------------------
void() path_corner =
{
- this.classtype = CT_PATH_CORNER;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ path_corner_init (self);
};
-};
+// };

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

Diff qc/info/rotate.qc

diff --git a/qc/info/rotate.qc b/qc/info/rotate.qc
index b0b0c54..f1596f4 100644
--- a/qc/info/rotate.qc
+++ b/qc/info/rotate.qc
@@ -10,28 +10,52 @@
// Distributed (unsupported) on 3.12.97
//======================================================================

+//======================================================================
+// forward declarations
+//======================================================================
+
+entity(entity src, vector org) spawn_info_rotate;
+void(entity e) info_rotate_init;
+void() info_rotate;
+
+//------------------------------------------------------------------------------
+
/*QUAKED info_rotate (0 0.5 0) (-4 -4 -4) (4 4 4) X X X X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
Used as the point of rotation for rotatable objects.
*/
-class info_rotate: base_mapentity
-{
+
+//----------------------------------------------------------------------
+// class info_rotate: base_mapentity
+// {
//--------------------------------------------------------------
- virtual void() do_think =
+ entity(entity src, vector org) spawn_info_rotate =
{
- remove (this);
+ local entity e = spawn ();
+ e.owner = src;
+ e.origin = org;
+ info_rotate_init (e);
+ return e;
};

//--------------------------------------------------------------
- virtual void() info_spawned =
+ void(entity e) info_rotate_init =
{
+ base_mapentity_init (e);
+ e.classname = "info_rotate";
+ e.classtype = CT_INFO_ROTATE;
// remove self after a little while, to make sure that
// entities that have targeted it have had a chance to spawn
- this.nextthink = time + 2;
+ e.think = sub_remove;
+ e.nextthink = time + 2;
};

//--------------------------------------------------------------
void() info_rotate =
{
- this.classtype = CT_INFO_ROTATE;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ info_rotate_init (self);
};
-};
+// };

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

Diff qc/info/spawnpoints.qc

diff --git a/qc/info/spawnpoints.qc b/qc/info/spawnpoints.qc
index 648f486..7a5d355 100644
--- a/qc/info/spawnpoints.qc
+++ b/qc/info/spawnpoints.qc
@@ -1,20 +1,81 @@
-//======================================================================
+//==============================================================================
// Player & Monster spawnpoint entities
+//==============================================================================
+
+//======================================================================
+// forward declarations
//======================================================================

+// info_player_start
+entity(entity src, vector org) spawn_info_player_start;
+void(entity e) info_player_start_init;
+void() info_player_start;
+
+// info_player_start2
+entity(entity src, vector org) spawn_info_player_start2;
+void(entity e) info_player_start2_init;
+void() info_player_start2;
+
+// testplayerstart
+entity(entity src, vector org) spawn_testplayerstart;
+void(entity e) testplayerstart_init;
+void() testplayerstart;
+
+// info_player_coop
+entity(entity src, vector org) spawn_info_player_coop;
+void(entity e) info_player_coop_init;
+void() info_player_coop;
+
+// info_monster_spawnpoint
+entity(entity src, vector org) spawn_info_monster_spawnpoint;
+void(entity e) info_monster_spawnpoint_init;
+void() info_monster_spawnpoint;
+
+// info_player_deathmatch
+entity(entity src, vector org) spawn_info_player_deathmatch;
+void(entity e) info_player_deathmatch_init;
+void() info_player_deathmatch;
+
+//------------------------------------------------------------------------------
+
/*QUAKED info_player_start (1 0 0) (-16 -16 -24) (16 16 24) X X X X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
{
model ("progs/player.mdl");
}
The normal starting point for a level.
*/
-class info_player_start: base_mapentity
-{
+
+//----------------------------------------------------------------------
+// class info_player_start: base_mapentity
+// {
+ //--------------------------------------------------------------
+ entity(entity src, vector org) spawn_info_player_start =
+ {
+ local entity e = spawn ();
+ e.owner = src;
+ e.origin = org;
+ info_player_start_init (e);
+ return e;
+ };
+
+ //--------------------------------------------------------------
+ void(entity e) info_player_start_init =
+ {
+ base_mapentity_init (e);
+ e.classname = "info_player_start";
+ e.classtype = CT_INFO_PLAYER_START;
+ };
+
+ //--------------------------------------------------------------
void() info_player_start =
{
- this.classtype = CT_INFO_PLAYER_START;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ info_player_start_init (self);
};
-};
+// };

/*QUAKED info_player_start2 (1 0 0) (-16 -16 -24) (16 16 24) X X X X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
{
@@ -22,24 +83,74 @@ model ("progs/player.mdl");
}
Only used on start map for the return point from an episode.
*/
-class info_player_start2: base_mapentity
-{
+
+//----------------------------------------------------------------------
+// class info_player_start2: base_mapentity
+// {
+ //--------------------------------------------------------------
+ entity(entity src, vector org) spawn_info_player_start2 =
+ {
+ local entity e = spawn ();
+ e.owner = src;
+ e.origin = org;
+ info_player_start2_init (e);
+ return e;
+ };
+
+ //--------------------------------------------------------------
+ void(entity e) info_player_start2_init =
+ {
+ base_mapentity_init (e);
+ e.classname = "info_player_start2";
+ e.classtype = CT_INFO_PLAYER_START2;
+ };
+
+ //--------------------------------------------------------------
void() info_player_start2 =
{
- this.classtype = CT_INFO_PLAYER_START2;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ info_player_start2_init (self);
};
-};
+// };

//----------------------------------------------------------------------
// testplayerstart -- saved out by quaked in region mode
//----------------------------------------------------------------------
-class testplayerstart: base_mapentity
-{
+
+//----------------------------------------------------------------------
+// class testplayerstart: base_mapentity
+// {
+ //--------------------------------------------------------------
+ entity(entity src, vector org) spawn_testplayerstart =
+ {
+ local entity e = spawn ();
+ e.owner = src;
+ e.origin = org;
+ testplayerstart_init (e);
+ return e;
+ };
+
+ //--------------------------------------------------------------
+ void(entity e) testplayerstart_init =
+ {
+ base_mapentity_init (e);
+ e.classname = "testplayerstart";
+ e.classtype = CT_INFO_TESTPLAYERSTART;
+ };
+
+ //--------------------------------------------------------------
void() testplayerstart =
{
- this.classtype = CT_INFO_TESTPLAYERSTART;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ testplayerstart_init (self);
};
-};
+// };

/*QUAKED info_player_coop (1 0 1) (-16 -16 -24) (16 16 24) X X X X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
{
@@ -47,13 +158,38 @@ model ("progs/player.mdl");
}
potential spawning position for coop games
*/
-class info_player_coop: base_mapentity
-{
+
+//----------------------------------------------------------------------
+// class info_player_coop: base_mapentity
+// {
+ //--------------------------------------------------------------
+ entity(entity src, vector org) spawn_info_player_coop =
+ {
+ local entity e = spawn ();
+ e.owner = src;
+ e.origin = org;
+ info_player_coop_init (e);
+ return e;
+ };
+
+ //--------------------------------------------------------------
+ void(entity e) info_player_coop_init =
+ {
+ base_mapentity_init (e);
+ e.classname = "info_player_coop";
+ e.classtype = CT_INFO_PLAYER_COOP;
+ };
+
+ //--------------------------------------------------------------
void() info_player_coop =
{
- this.classtype = CT_INFO_PLAYER_COOP;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ info_player_coop_init (self);
};
-};
+// };

/*QUAKED info_monster_spawnpoint (1 0 1) (-16 -16 -24) (16 16 24) X X X X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
{
@@ -61,13 +197,38 @@ model ("progs/teleport.mdl");
}
spawning position for func_monster_spawner
*/
-class info_monster_spawnpoint: base_mapentity
-{
+
+//----------------------------------------------------------------------
+// class info_monster_spawnpoint: base_mapentity
+// {
+ //--------------------------------------------------------------
+ entity(entity src, vector org) spawn_info_monster_spawnpoint =
+ {
+ local entity e = spawn ();
+ e.owner = src;
+ e.origin = org;
+ info_monster_spawnpoint_init (e);
+ return e;
+ };
+
+ //--------------------------------------------------------------
+ void(entity e) info_monster_spawnpoint_init =
+ {
+ base_mapentity_init (e);
+ e.classname = "info_monster_spawnpoint";
+ e.classtype = CT_INFO_MONSTER_SPAWNPOINT;
+ };
+
+ //--------------------------------------------------------------
void() info_monster_spawnpoint =
{
- this.classtype = CT_INFO_MONSTER_SPAWNPOINT;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ info_monster_spawnpoint_init (self);
};
-};
+// };

/*QUAKED info_player_deathmatch (1 0 1) (-16 -16 -24) (16 16 24) X X X X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
{
@@ -75,19 +236,40 @@ model ("progs/player.mdl");
}
potential spawning position for deathmatch games
*/
-class info_player_deathmatch: base_mapentity
-{
- virtual void() init_spawned =
+
+//----------------------------------------------------------------------
+// class info_player_deathmatch: base_mapentity
+// {
+ //--------------------------------------------------------------
+ entity(entity src, vector org) spawn_info_player_deathmatch =
{
- this.alpha = 0.2;
- this.model = "progs/player.mdl";
+ local entity e = spawn ();
+ e.owner = src;
+ e.origin = org;
+ info_player_deathmatch_init (e);
+ return e;
+ };
+
+ //--------------------------------------------------------------
+ void(entity e) info_player_deathmatch_init =
+ {
+ base_mapentity_init (e);
+ e.classname = "info_player_deathmatch";
+ e.classtype = CT_INFO_PLAYER_DEATHMATCH;
+ e.alpha = 0.2;
+ e.model = "progs/player.mdl";
// $axstnd1 is 17.0 -- CEV
- this.frame = 17.0;
- setmodel (this, this.model);
+ e.frame = 17.0;
+ setmodel (e, e.model);
};

+ //--------------------------------------------------------------
void() info_player_deathmatch =
{
- this.classtype = CT_INFO_PLAYER_DEATHMATCH;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ info_player_deathmatch_init (self);
};
-};
+// };

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

Diff qc/info/teleport_changedest.qc

diff --git a/qc/info/teleport_changedest.qc b/qc/info/teleport_changedest.qc
index 8727b01..cc1023f 100644
--- a/qc/info/teleport_changedest.qc
+++ b/qc/info/teleport_changedest.qc
@@ -2,6 +2,18 @@
// info_teleport_changedest -- by Qmaster, from progs_dump 3
//==============================================================================

+//======================================================================
+// forward declarations
+//======================================================================
+
+void() info_teleport_changedest_use;
+entity(entity src, vector org, string tname, string t, string m)
+ spawn_info_teleport_changedest;
+void(entity e) info_teleport_changedest_init;
+void() info_teleport_changedest;
+
+//------------------------------------------------------------------------------
+
/*QUAKED info_teleport_changedest (0 0.5 0) (-4 -4 -4) (4 4 4) X X X X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
Allows a mapper to change the target of a teleport_trigger. Useful in maps where
the player may fall into a void and the mapper wants to update where they "respawn"
@@ -10,8 +22,11 @@ target = trigger_teleport to change
message = new info_teleport_destination's targetname to switch to
targetname = name of this entity so we can use it
*/
-class info_teleport_changedest: base_mapentity
-{
+
+//----------------------------------------------------------------------
+// class info_teleport_changedest: base_mapentity
+// {
+ //--------------------------------------------------------------
// this is from Qmaster:
//
// "I created an info_teleport_changedest
@@ -28,13 +43,12 @@ class info_teleport_changedest: base_mapentity
//
// looking at vanilla, you would only need to change trig.target to
// match self.message if you were to add this."
-
//--------------------------------------------------------------
- virtual void(entity e) do_use =
+ void() info_teleport_changedest_use =
{
local entity trig;

- trig = find (world, ::targetname, this.target);
+ trig = find (world, targetname, self.target);
if (!trig || trig.classtype != CT_TRIGGER_TELEPORT)
{
dprint ("\b[TELEPORT_DESTCHANGE]\b ");
@@ -42,7 +56,7 @@ class info_teleport_changedest: base_mapentity
return;
}

- trig.goalentity = find (world, ::targetname, this.message);
+ trig.goalentity = find (world, ::targetname, self.message);
if (!trig.goalentity)
{
dprint ("\b[TELEPORT_DESTCHANGE]\b ");
@@ -52,44 +66,65 @@ class info_teleport_changedest: base_mapentity

makevectors (trig.goalentity.mangle);
trig.goalentity.movedir = v_forward;
- // TODO CEV pos1
- /*
trig.goalentity.pos1 = trig.goalentity.origin + 32 *
trig.goalentity.movedir;
- */

// dumptruck_ds see comment above
- trig.target = this.message;
+ trig.target = self.message;
+ };
+
+ //--------------------------------------------------------------
+ entity(entity src, vector org, string tname, string t, string m)
+ spawn_info_teleport_changedest =
+ {
+ local entity e = spawn ();
+ e.owner = src;
+ e.origin = org;
+ e.targetname = tname;
+ e.target = t;
+ e.message = m;
+ info_teleport_changedest_init (e);
+ return e;
};

//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) info_teleport_changedest_init =
{
- if (this.targetname == "")
+ base_mapentity_init (e);
+ e.classname = "info_teleport_changedest";
+ e.classtype = CT_INFO_TELEPORT_CHANGEDEST;
+
+ if (e.targetname == "")
{
dprint ("\b[ERROR]\b info_teleport_changedest ");
dprint ("with no targetname\n");
- remove (this);
+ remove (e);
}

- if (this.target == "")
+ if (e.target == "")
{
dprint ("\b[ERROR]\b info_teleport_changedest ");
dprint ("with no target\n");
- remove (this);
+ remove (e);
}

- if (this.message == "")
+ if (e.message == "")
{
dprint ("\b[ERROR]\b info_teleport_changedest ");
dprint ("with no message set for new destination\n");
- remove (this);
+ remove (e);
}
+
+ e.use = info_teleport_changedest_use;
};

//--------------------------------------------------------------
void() info_teleport_changedest =
{
- this.classtype = CT_INFO_TELEPORT_CHANGEDEST;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ info_teleport_changedest_init (self);
};
-};
+// };

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

Diff qc/info/teleport_destination.qc

diff --git a/qc/info/teleport_destination.qc b/qc/info/teleport_destination.qc
index 0f09f2e..d1d169a 100644
--- a/qc/info/teleport_destination.qc
+++ b/qc/info/teleport_destination.qc
@@ -3,9 +3,21 @@
//==============================================================================

//======================================================================
-// teleporter targets
+// forward declarations
//======================================================================

+// info_teleport_destination
+entity(entity src, vector org, string tname) spawn_info_teleport_destination;
+void(entity e) info_teleport_destination_init;
+void() info_teleport_destination;
+
+// info_teleport_random
+entity(entity src, vector org) spawn_info_teleport_random;
+void(entity e) info_teleport_random_init;
+void() info_teleport_random;
+
+//------------------------------------------------------------------------------
+
/*QUAKED info_teleport_destination (.5 .5 .5) (-8 -8 -8) (8 8 32) X X X X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
{
model ("progs/player.mdl");
@@ -13,39 +25,57 @@ model ("progs/player.mdl");
This is the destination marker for a teleporter. It should have a "targetname"
field with the same value as a teleporter's "target" field.
*/
-class info_teleport_destination: base_mapentity
-{
+
+//----------------------------------------------------------------------
+// class info_teleport_destination: base_mapentity
+// {
//--------------------------------------------------------------
- virtual void() init_spawned =
+ entity(entity src, vector org, string tname)
+ spawn_info_teleport_destination =
{
+ local entity e = spawn ();
+ e.owner = src;
+ e.origin = org;
+ e.targetname = tname;
+ info_teleport_destination_init (e);
+ return e;
+ };
+
+ //--------------------------------------------------------------
+ void(entity e) info_teleport_destination_init =
+ {
+ base_mapentity_init (e);
+ e.classname = "info_teleport_destination";
+ e.classtype = CT_INFO_TELEPORT_DESTINATION;
+
local vector end;

// this does nothing, just serves as a target spot
- this.mangle = this.angles;
- this.angles = '0 0 0';
- this.model = "";
+ e.mangle = e.angles;
+ e.angles = '0 0 0';
+ e.model = "";

// drop teleporter exit to the floor if it's PM_TELEDROP units
// away -- CEV
- end = this.origin + PM_TELEDROP;
- tracebox (this.origin, this.mins, this.maxs, end, FALSE, this);
+ end = e.origin + PM_TELEDROP;
+ tracebox (e.origin, e.mins, e.maxs, end, FALSE, e);
if (trace_allsolid || trace_startsolid || trace_fraction < 1)
{
droptofloor ();
// bump origin so player won't exit into floor -- CEV
// This was '0 0 24' but that was causing issues -- CEV
- this.origin = this.origin + '0 0 27';
+ e.origin = e.origin + '0 0 27';
}
else
{
// instead apply the standard fixed Z offset -- CEV
- this.origin = this.origin + '0 0 27';
+ e.origin = e.origin + '0 0 27';
}

- if (!this.targetname)
- if (this.target != __NULL__ && this.target != "")
+ if (!e.targetname)
+ if (e.target != __NULL__ && e.target != "")
// quake 3 compat -- CEV
- this.targetname = this.target;
+ e.targetname = e.target;
else
objerror ("no targetname");
};
@@ -53,10 +83,13 @@ class info_teleport_destination: base_mapentity
//--------------------------------------------------------------
void() info_teleport_destination =
{
- this.classtype = CT_INFO_TELEPORT_DESTINATION;
- };
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;

-};
+ info_teleport_destination_init (self);
+ };
+// };

/*QUAKED info_teleport_random (.5 .5 .5) (-8 -8 -8) (8 8 32) X X X X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
{
@@ -64,21 +97,41 @@ model ("progs/player.mdl");
}
This is a random destination marker for a teleporter.
*/
-class info_teleport_random: base_mapentity
-{
+
+//----------------------------------------------------------------------
+// class info_teleport_random: base_mapentity
+// {
+ //--------------------------------------------------------------
+ entity(entity src, vector org) spawn_info_teleport_random =
+ {
+ local entity e = spawn ();
+ e.owner = src;
+ e.origin = org;
+ info_teleport_random_init (e);
+ return e;
+ };
+
//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) info_teleport_random_init =
{
+ base_mapentity_init (e);
+ e.classname = "info_teleport_random";
+ e.classtype = CT_INFO_TELEPORT_RANDOM;
+
// this does nothing, just serves as a target spot
- this.mangle = this.angles;
- this.angles = '0 0 0';
- this.model = "";
- this.origin = this.origin + '0 0 27';
+ e.mangle = e.angles;
+ e.angles = '0 0 0';
+ e.model = "";
+ e.origin = e.origin + '0 0 27';
};

//--------------------------------------------------------------
void() info_teleport_random =
{
- this.classtype = CT_INFO_TELEPORT_RANDOM;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ info_teleport_random_init (self);
};
-};
+// };

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

Diff qc/items/ammo.qc

diff --git a/qc/items/ammo.qc b/qc/items/ammo.qc
index e85a47c..cb32cb4 100644
--- a/qc/items/ammo.qc
+++ b/qc/items/ammo.qc
@@ -2,13 +2,13 @@
// AMMO -- was in items.qc
//==============================================================================

+//======================================================================
// constants
+//======================================================================
+
const float WEAPON_BIG2 = 1;

-// fixed ammo respawn time
const float AMMO_RESPAWN_TIME = 30; // ammo respawn time; id1 30s
-
-// ammunition maximums & small / big box contents
const float AMMO_CELLS_SMALL = 6; // id1 6; small box of cells
const float AMMO_CELLS_BIG = 12; // id1 12; large box of cells
const float AMMO_CELLS_MAX = 100; // id1 maximum 100
@@ -22,120 +22,151 @@ const float AMMO_SHELLS_SMALL = 20; // id1 20; small box of shells
const float AMMO_SHELLS_BIG = 40; // id1 40; large box of shells
const float AMMO_SHELLS_MAX = 100; // id1 maximum 100

-// REMOVE the following two functions once PlayerBestWeapon and
-// PlayerSetCurrentAmmo have been refactored -- CEV
-
-void(entity doas, void() f) REMOVEME_CallAsSelf =
-{
- local entity stemp;
+//======================================================================
+// forward declarations
+//======================================================================
+
+// base_item_ammo
+entity(entity src, vector org, float flags, void(entity) initfn)
+ spawn_item_ammo_n;
+void() base_item_ammo_touch;
+void(entity e) base_item_ammo_init;
+strip void() base_item_ammo;
+
+// item_shells
+entity(entity src, vector org, float flags) spawn_item_shells;
+void(entity e) item_shells_init;
+void() item_shells;
+
+// item_spikes
+entity(entity src, vector org, float flags) spawn_item_spikes;
+void(entity e) item_spikes_init;
+void() item_spikes;
+
+// item_rockets
+entity(entity src, vector org, float flags) spawn_item_rockets;
+void(entity e) item_rockets_init;
+void() item_rockets;
+
+// item_cells
+entity(entity src, vector org, float flags) spawn_item_cells;
+void(entity e) item_cells_init;
+void() item_cells;

- stemp = self;
- self = doas;
- f ();
- self = stemp;
-};
-
-float(entity doas, float() f) REMOVEME_CallAsSelfFloat =
-{
- local entity stemp;
- local float fl;
+//------------------------------------------------------------------------------

- stemp = self;
- self = doas;
- fl = f ();
- self = stemp;
- return fl;
-};
+//----------------------------------------------------------------------
+// class base_item_ammo: base_item
+// {
+ //--------------------------------------------------------------
+ entity(entity src, vector org, float flags, void(entity) initfn)
+ spawn_item_ammo_n =
+ {
+ local entity e = spawn ();
+ e.owner = src;
+ e.origin = org;
+ e.spawnflags = flags;
+ initfn (e);
+ return e;
+ };

-//------------------------------------------------------------------------------
-class base_item_ammo: base_item
-{
//--------------------------------------------------------------
// was ammo_touch -- CEV
//--------------------------------------------------------------
- virtual void(entity toucher) do_touch =
+ void() base_item_ammo_touch =
{
local float best = 0;

+ if (sub_checkvalidtouch(other) == FALSE)
+ return;
+
// if the player was using his best weapon, change up to
// the new one if better
- if (toucher.classtype == CT_PLAYER &&
+ if (other.classtype == CT_PLAYER &&
autocvar(cg_autoswitch, TRUE))
{
- ((player)toucher).best_weapon ();
+ best = sub_runfloatas (other, player_best_weapon);
}

// shotgun
- if (this.weapon == 1)
+ if (self.weapon == 1)
{
- if (toucher.ammo_shells >= AMMO_SHELLS_MAX)
+ if (other.ammo_shells >= AMMO_SHELLS_MAX)
return;
- toucher.ammo_shells += this.aflag;
+ other.ammo_shells += self.aflag;
}

// spikes
- if (this.weapon == 2)
+ if (self.weapon == 2)
{
- if (toucher.ammo_nails >= AMMO_NAILS_MAX)
+ if (other.ammo_nails >= AMMO_NAILS_MAX)
return;
- toucher.ammo_nails += this.aflag;
+ other.ammo_nails += self.aflag;
}

// rockets
- if (this.weapon == 3)
+ if (self.weapon == 3)
{
- if (toucher.ammo_rockets >= AMMO_ROCKETS_MAX)
+ if (other.ammo_rockets >= AMMO_ROCKETS_MAX)
return;
- toucher.ammo_rockets += this.aflag;
+ other.ammo_rockets += self.aflag;
}

// cells
- if (this.weapon == 4)
+ if (self.weapon == 4)
{
- if (toucher.ammo_cells >= AMMO_CELLS_MAX)
+ if (other.ammo_cells >= AMMO_CELLS_MAX)
return;
- toucher.ammo_cells += this.aflag;
+ other.ammo_cells += self.aflag;
}

- bound_other_ammo ();
+ bound_entity_ammo (other);

- sprint (toucher, sprintf("You got the %s\n", this.netname));
+ sprint (other, sprintf("You got the %s\n", self.netname));
// ammo touch sound
- sound (toucher, CHAN_ITEM, "weapons/lock4.wav", 1, ATTN_NORM);
- stuffcmd (toucher, "bf\n");
+ sound (other, CHAN_ITEM, "weapons/lock4.wav", 1, ATTN_NORM);
+ stuffcmd (other, "bf\n");

// change to a better weapon if appropriate
- if (toucher.classtype == CT_PLAYER && toucher.weapon == best &&
+ if (other.classtype == CT_PLAYER && other.weapon == best &&
autocvar(cg_autoswitch, TRUE))
{
- // TODO CEV
- toucher.weapon = ((player)toucher).best_weapon ();
- ((player)toucher).set_current_ammo ();
+ other.weapon = sub_runfloatas (other,
+ player_best_weapon);
+ sub_runvoidas (other, player_set_current_ammo);
}

// if changed current ammo, update it
- if (toucher.classtype == CT_PLAYER)
+ if (other.classtype == CT_PLAYER)
{
- // TODO CEV
- ((player)toucher).set_current_ammo ();
+ sub_runvoidas (other, player_set_current_ammo);
}

// remove it in single player, or setup for respawning in DM
- this.solid = SOLID_NOT;
- this.model = string_null;
- check_respawn (this, AMMO_RESPAWN_TIME, AMMO_RESPAWN_TIME);
+ self.solid = SOLID_NOT;
+ self.model = __NULL__;
+ base_item_check_respawn (self,
+ AMMO_RESPAWN_TIME, AMMO_RESPAWN_TIME);

- activator = toucher;
+ activator = other;
// fire all targets / killtargets
sub_usetargets ();
};

//--------------------------------------------------------------
- void() base_item_ammo =
+ void(entity e) base_item_ammo_init =
{
- this.classgroup |= CG_ITEM_AMMO;
+ e.classgroup |= CG_ITEM_AMMO;
+ e.touch = base_item_ammo_touch;
+ base_item_init (e);
};
-};
+
+ //--------------------------------------------------------------
+ strip void() base_item_ammo =
+ {
+ base_item_ammo_init (self);
+ };
+// };

/*QUAKED item_shells (0 .5 .8) (0 0 0) (32 32 32) LARGE_BOX X X X X SPAWN_SILENT TRIGGER_SPAWNED SUSPENDED_IN_AIR NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER RESPAWN_WITH_DM_EFFECTS NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
{
@@ -144,69 +175,79 @@ class base_item_ammo: base_item
Box of 20 shells.
LARGE_BOX is a box of 40 shells.
*/
-class item_shells: base_item_ammo
-{
+//----------------------------------------------------------------------
+// class item_shells: base_item_ammo
+// {
//--------------------------------------------------------------
- virtual void() init_spawned =
+ entity(entity src, vector org, float flags) spawn_item_shells =
{
- if (this.spawnflags & WEAPON_BIG2)
- {
- if (!this.mdl_body && world.s_lg_mdl)
- this.mdl_body = world.s_lg_mdl;
+ return spawn_item_ammo_n (src, org, flags, item_shells_init);
+ };
+
+ //--------------------------------------------------------------
+ void(entity e) item_shells_init =
+ {
+ e.classname = "item_shells";
+ e.classtype = CT_ITEM_AMMO_SHELLS;

+ if (e.spawnflags & WEAPON_BIG2)
+ {
if (world.style)
{
// models courtesy Lunaran -- dumptruck_ds
- precache_body_model ("progs/ammo/m_shell2.mdl");
- body_model ("progs/ammo/m_shell2.mdl");
+ precache_body_model (e,
+ "progs/ammo/m_shell2.mdl");
+ body_model (e, "progs/ammo/m_shell2.mdl");
}
else
{
- precache_body_model ("maps/b_shell1.bsp");
- body_model ("maps/b_shell1.bsp");
+ precache_body_model (e, "maps/b_shell1.bsp");
+ body_model (e, "maps/b_shell1.bsp");
}

- if !(this.particles_offset)
- this.particles_offset = '16 16 16';
- this.aflag = AMMO_SHELLS_BIG;
+ if !(e.particles_offset)
+ e.particles_offset = '16 16 16';
+ e.aflag = AMMO_SHELLS_BIG;
}
else
{
- if (!this.mdl_body && world.s_sm_mdl)
- this.mdl_body = world.s_sm_mdl;
-
if (world.style)
{
// models courtesy Lunaran -- dumptruck_ds
- precache_body_model ("progs/ammo/m_shell1.mdl");
- body_model ("progs/ammo/m_shell1.mdl");
+ precache_body_model (e,
+ "progs/ammo/m_shell1.mdl");
+ body_model (e, "progs/ammo/m_shell1.mdl");
}
else
{
- precache_body_model ("maps/b_shell0.bsp");
- body_model ("maps/b_shell0.bsp");
+ precache_body_model (e, "maps/b_shell0.bsp");
+ body_model (e, "maps/b_shell0.bsp");
}

- if !(this.particles_offset)
- this.particles_offset = '12 12 12';
- this.aflag = AMMO_SHELLS_SMALL;
+ if !(e.particles_offset)
+ e.particles_offset = '12 12 12';
+ e.aflag = AMMO_SHELLS_SMALL;
}

- this.weapon = 1;
- this.netname = "shells";
- this.size_min = '0 0 0';
- this.size_max = '32 32 56';
+ e.weapon = 1;
+ e.netname = "shells";
+ e.pos1 = '0 0 0';
+ e.pos2 = '32 32 56';

// StartItem
- super::init_spawned ();
+ base_item_ammo_init (e);
};

//--------------------------------------------------------------
void() item_shells =
{
- this.classtype = CT_ITEM_AMMO_SHELLS;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ item_shells_init (self);
};
-};
+// };

/*QUAKED item_spikes (0 .5 .8) (0 0 0) (32 32 32) LARGE_BOX X X X X SPAWN_SILENT TRIGGER_SPAWNED SUSPENDED_IN_AIR NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER RESPAWN_WITH_DM_EFFECTS NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
{
@@ -215,136 +256,154 @@ class item_shells: base_item_ammo
Box of 25 nails.
LARGE_BOX is a box of 50 nails.
*/
-class item_spikes: base_item_ammo
-{
+//----------------------------------------------------------------------
+// class item_spikes: base_item_ammo
+// {
//--------------------------------------------------------------
- virtual void() init_spawned =
+ entity(entity src, vector org, float flags) spawn_item_spikes =
{
- if (this.spawnflags & WEAPON_BIG2)
- {
- if (!this.mdl_body && world.n_lg_mdl)
- this.mdl_body = world.n_lg_mdl;
+ return spawn_item_ammo_n (src, org, flags, item_spikes_init);
+ };

+ //--------------------------------------------------------------
+ void(entity e) item_spikes_init =
+ {
+ e.classname = "item_spikes";
+ e.classtype = CT_ITEM_AMMO_SPIKES;
+ if (e.spawnflags & WEAPON_BIG2)
+ {
if (world.style)
{
// models courtesy Lunaran -- dumptruck_ds
- precache_body_model ("progs/ammo/m_nails2.mdl");
- body_model ("progs/ammo/m_nails2.mdl");
+ precache_body_model (e,
+ "progs/ammo/m_nails2.mdl");
+ body_model (e, "progs/ammo/m_nails2.mdl");
}
else
{
- precache_body_model ("maps/b_nail1.bsp");
- body_model ("maps/b_nail1.bsp");
+ precache_body_model (e, "maps/b_nail1.bsp");
+ body_model (e, "maps/b_nail1.bsp");
}

- if !(this.particles_offset)
- this.particles_offset = '16 16 16';
- this.aflag = AMMO_NAILS_BIG;
+ if !(e.particles_offset)
+ e.particles_offset = '16 16 16';
+ e.aflag = AMMO_NAILS_BIG;
}
else
{
- if (!this.mdl_body && world.n_sm_mdl)
- this.mdl_body = world.n_sm_mdl;
-
if (world.style)
{
// models courtesy Lunaran -- dumptruck_ds
- precache_body_model ("progs/ammo/m_nails1.mdl");
- body_model ("progs/ammo/m_nails1.mdl");
+ precache_body_model (e,
+ "progs/ammo/m_nails1.mdl");
+ body_model (e, "progs/ammo/m_nails1.mdl");
}
else
{
- precache_body_model ("maps/b_nail0.bsp");
- body_model ("maps/b_nail0.bsp");
+ precache_body_model (e, "maps/b_nail0.bsp");
+ body_model (e, "maps/b_nail0.bsp");
}

- if !(this.particles_offset)
- this.particles_offset = '12 12 12';
- this.aflag = AMMO_NAILS_SMALL;
+ if !(e.particles_offset)
+ e.particles_offset = '12 12 12';
+ e.aflag = AMMO_NAILS_SMALL;
}
- this.weapon = 2;
- this.netname = "nails";
- this.size_min = '0 0 0';
- this.size_max = '32 32 56';
+ e.weapon = 2;
+ e.netname = "nails";
+ e.pos1 = '0 0 0';
+ e.pos2 = '32 32 56';

// StartItem
- super::init_spawned ();
+ base_item_ammo_init (e);
};

//--------------------------------------------------------------
void() item_spikes =
{
- this.classtype = CT_ITEM_AMMO_SPIKES;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ item_spikes_init (self);
};
-};
+// };

/*QUAKED item_rockets (0 .5 .8) (0 0 0) (32 32 32) LARGE_BOX X X X X SPAWN_SILENT TRIGGER_SPAWNED SUSPENDED_IN_AIR NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER RESPAWN_WITH_DM_EFFECTS NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
{
model ( {{ spawnflags & 1 -> { "path" : "maps/b_rock1.bsp" }, "maps/b_rock0.bsp" }} );
}
*/
-class item_rockets: base_item_ammo
-{
+//----------------------------------------------------------------------
+// class item_rockets: base_item_ammo
+// {
//--------------------------------------------------------------
- virtual void() init_spawned =
+ entity(entity src, vector org, float flags) spawn_item_rockets =
{
- if (this.spawnflags & WEAPON_BIG2)
- {
- if (!this.mdl_body && world.r_lg_mdl)
- this.mdl_body = world.r_lg_mdl;
+ return spawn_item_ammo_n (src, org, flags, item_rockets_init);
+ };

+ //--------------------------------------------------------------
+ void(entity e) item_rockets_init =
+ {
+ e.classname = "item_rockets";
+ e.classtype = CT_ITEM_AMMO_ROCKETS;
+ if (e.spawnflags & WEAPON_BIG2)
+ {
if (world.style)
{
// models courtesy Lunaran -- dumptruck_ds
- precache_body_model ("progs/ammo/m_rock2.mdl");
- body_model ("progs/ammo/m_rock2.mdl");
+ precache_body_model (e,
+ "progs/ammo/m_rock2.mdl");
+ body_model (e, "progs/ammo/m_rock2.mdl");
}
else
{
- precache_body_model ("maps/b_rock1.bsp");
- body_model ("maps/b_rock1.bsp");
+ precache_body_model (e, "maps/b_rock1.bsp");
+ body_model (e, "maps/b_rock1.bsp");
}

- this.particles_offset = '16 8 16';
- this.aflag = AMMO_ROCKETS_BIG;
+ e.particles_offset = '16 8 16';
+ e.aflag = AMMO_ROCKETS_BIG;
}
else
{
- if (!this.mdl_body && world.r_sm_mdl)
- this.mdl_body = world.r_sm_mdl;
-
if (world.style)
{
// models courtesy Lunaran -- dumptruck_ds
- precache_body_model ("progs/ammo/m_rock1.mdl");
- body_model ("progs/ammo/m_rock1.mdl");
+ precache_body_model (e,
+ "progs/ammo/m_rock1.mdl");
+ body_model (e, "progs/ammo/m_rock1.mdl");
}
else
{
- precache_body_model ("maps/b_rock0.bsp");
- body_model ("maps/b_rock0.bsp");
+ precache_body_model (e, "maps/b_rock0.bsp");
+ body_model (e, "maps/b_rock0.bsp");
}

- if !(this.particles_offset)
- this.particles_offset = '8 8 16';
- this.aflag = AMMO_ROCKETS_SMALL;
+ if !(e.particles_offset)
+ e.particles_offset = '8 8 16';
+ e.aflag = AMMO_ROCKETS_SMALL;
}

- this.weapon = 3;
- this.netname = "rockets";
- this.size_min = '0 0 0';
- this.size_max = '32 32 56';
+ e.weapon = 3;
+ e.netname = "rockets";
+ e.pos1 = '0 0 0';
+ e.pos2 = '32 32 56';

// StartItem
- super::init_spawned ();
+ base_item_ammo_init (e);
};

//--------------------------------------------------------------
void() item_rockets =
{
- this.classtype = CT_ITEM_AMMO_ROCKETS;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ item_rockets_init (self);
};
-};
+// };

/*QUAKED item_cells (0 .5 .8) (0 0 0) (32 32 32) LARGE_BOX X X X X SPAWN_SILENT TRIGGER_SPAWNED SUSPENDED_IN_AIR NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER RESPAWN_WITH_DM_EFFECTS NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
{
@@ -353,66 +412,75 @@ class item_rockets: base_item_ammo
Box of 6 cells.
LARGE_BOX is a box of 12 cells.
*/
-class item_cells: base_item_ammo
-{
+//----------------------------------------------------------------------
+// class item_cells: base_item_ammo
+// {
//--------------------------------------------------------------
- virtual void() init_spawned =
+ entity(entity src, vector org, float flags) spawn_item_cells =
{
- if (this.spawnflags & WEAPON_BIG2)
- {
- if (!this.mdl_body && world.c_lg_mdl)
- this.mdl_body = world.c_lg_mdl;
+ return spawn_item_ammo_n (src, org, flags, item_cells_init);
+ };

+ //--------------------------------------------------------------
+ void(entity e) item_cells_init =
+ {
+ e.classname = "item_cells";
+ e.classtype = CT_ITEM_AMMO_CELLS;
+ if (e.spawnflags & WEAPON_BIG2)
+ {
if (world.style)
{
// models courtesy Lunaran -- dumptruck_ds
- precache_body_model ("progs/ammo/m_cells2.mdl");
- body_model ("progs/ammo/m_cells2.mdl");
+ precache_body_model (e,
+ "progs/ammo/m_cells2.mdl");
+ body_model (e, "progs/ammo/m_cells2.mdl");
}
else
{
- precache_body_model ("maps/b_batt1.bsp");
- body_model ("maps/b_batt1.bsp");
+ precache_body_model (e, "maps/b_batt1.bsp");
+ body_model (e, "maps/b_batt1.bsp");
}

- if !(this.particles_offset)
- this.particles_offset = '16 16 16';
- this.aflag = AMMO_CELLS_BIG;
+ if !(e.particles_offset)
+ e.particles_offset = '16 16 16';
+ e.aflag = AMMO_CELLS_BIG;
}
else
{
- if (!this.mdl_body && world.c_sm_mdl)
- this.mdl_body = world.c_sm_mdl;
-
if (world.style)
{
// models courtesy Lunaran -- dumptruck_ds
- precache_body_model ("progs/ammo/m_cells2.mdl");
- body_model ("progs/ammo/m_cells2.mdl");
+ precache_body_model (e,
+ "progs/ammo/m_cells2.mdl");
+ body_model (e, "progs/ammo/m_cells2.mdl");
}
else
{
- precache_body_model ("maps/b_batt0.bsp");
- body_model ("maps/b_batt0.bsp");
+ precache_body_model (e, "maps/b_batt0.bsp");
+ body_model (e, "maps/b_batt0.bsp");
}

- if !(this.particles_offset)
- this.particles_offset = '12 12 12';
- this.aflag = AMMO_CELLS_SMALL;
+ if !(e.particles_offset)
+ e.particles_offset = '12 12 12';
+ e.aflag = AMMO_CELLS_SMALL;
}

- this.weapon = 4;
- this.netname = "cells";
- this.size_min = '0 0 0';
- this.size_max = '32 32 56';
+ e.weapon = 4;
+ e.netname = "cells";
+ e.pos1 = '0 0 0';
+ e.pos2 = '32 32 56';

// StartItem
- super::init_spawned ();
+ base_item_ammo_init (e);
};

//--------------------------------------------------------------
void() item_cells =
{
- this.classtype = CT_ITEM_AMMO_CELLS;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ item_cells_init (self);
};
-};
+// };

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

Diff qc/items/armor.qc

diff --git a/qc/items/armor.qc b/qc/items/armor.qc
index abc6bd6..3642917 100644
--- a/qc/items/armor.qc
+++ b/qc/items/armor.qc
@@ -2,7 +2,10 @@
// armor.qc
//==============================================================================

+//======================================================================
// constants
+//======================================================================
+
const float ARMOR_GREEN_ABSORB = 0.3; // absorb percent; id1 0.3
const float ARMOR_GREEN_AMOUNT = 100; // amount per pickup; id1 100
const float ARMOR_GREEN_MAX = 125; // id1 125
@@ -20,31 +23,81 @@ const float ARMOR_SHARD_AMOUNT = 5; // Q3 5
const float ARMOR_RESPAWN_SP = 30; // id1 30s
const float ARMOR_RESPAWN_DM = 20; // id1 20s

+//======================================================================
+// forward declarations
+//======================================================================
+
+// base_item_armor
+entity(entity src, vector org, vector vel, void(entity) initfn)
+ spawn_item_armor;
+void() base_item_armor_touch;
+void(entity e) base_item_armor_init;
+strip void() base_item_armor;
+
+// item_armor1
+entity(entity src, vector org, vector vel) spawn_item_armor1;
+void(entity e) item_armor1_init;
+void() item_armor1;
+
+// item_armor2
+entity(entity src, vector org, vector vel) spawn_item_armor2;
+void(entity e) item_armor2_init;
+void() item_armor2;
+
+// item_armorInv
+entity(entity src, vector org, vector vel) spawn_item_armorInv;
+void(entity e) item_armorInv_init;
+void() item_armorInv;
+
+// item_armor_shard
+void() item_armor_shard_touch;
+entity(entity src) item_armor_shard_drop;
+entity(entity src, vector org, vector vel) spawn_item_armor_shard;
+void(entity e) item_armor_shard_init;
+void() item_armor_shard;
+
//------------------------------------------------------------------------------
-class base_item_armor: base_item
-{
+
+//----------------------------------------------------------------------
+// class base_item_armor: base_item
+// {
+ //--------------------------------------------------------------
+ entity(entity src, vector org, vector vel, void(entity) init_fn)
+ spawn_item_armor =
+ {
+ local entity e = spawn ();
+ e.owner = src;
+ e.origin = org;
+ e.velocity = vel;
+ init_fn (e);
+ return e;
+ };
+
//--------------------------------------------------------------
// was armor_touch -- CEV
//--------------------------------------------------------------
- virtual void(entity toucher) do_touch =
+ void() base_item_armor_touch =
{
local float type, value, bit;

- if (this.classtype == CT_ITEM_ARMOR_GREEN)
+ if (sub_checkvalidtouch(other) == FALSE)
+ return;
+
+ if (self.classtype == CT_ITEM_ARMOR_GREEN)
{
// green armor
type = ARMOR_GREEN_ABSORB;
value = ARMOR_GREEN_AMOUNT;
bit = IT_ARMOR1;
}
- else if (this.classtype == CT_ITEM_ARMOR_YELLOW)
+ else if (self.classtype == CT_ITEM_ARMOR_YELLOW)
{
// yellow armor
type = ARMOR_YELLOW_ABSORB;
value = ARMOR_YELLOW_AMOUNT;
bit = IT_ARMOR2;
}
- else if (this.classtype == CT_ITEM_ARMOR_RED)
+ else if (self.classtype == CT_ITEM_ARMOR_RED)
{
// red armor
type = ARMOR_RED_ABSORB;
@@ -54,276 +107,345 @@ class base_item_armor: base_item
else
{
dprint (sprintf("base_item_armor::do_touch: unknown "
- "classname %s!\n", this.classname));
+ "classname %s!\n", self.classname));
return;
}

- if (toucher.armortype * toucher.armorvalue >= type * value)
+ if (other.armortype * other.armorvalue >= type * value)
return;

- toucher.armortype = type;
- toucher.armorvalue = value;
+ other.armortype = type;
+ other.armorvalue = value;

- toucher.items = toucher.items - (toucher.items &
+ other.items = other.items - (other.items &
(IT_ARMOR1 | IT_ARMOR2 | IT_ARMOR3)) + bit;

- this.solid = SOLID_NOT;
- this.model = string_null;
- check_respawn (this, ARMOR_RESPAWN_SP, ARMOR_RESPAWN_DM);
+ self.solid = SOLID_NOT;
+ self.model = __NULL__;
+ base_item_check_respawn (self,
+ ARMOR_RESPAWN_SP, ARMOR_RESPAWN_DM);

- if (this.obit_name != __NULL__ && this.obit_name != "")
+ if (self.obit_name != __NULL__ && self.obit_name != "")
// custom armor name
- sprint (toucher, sprintf("You got %s\n",
- this.obit_name));
+ sprint (other, sprintf("You got %s\n",
+ self.obit_name));
else
- sprint(toucher, "You got armor\n");
+ sprint (other, "You got armor\n");

// armor touch sound
// dumptruck_ds custom models and sounds START
- if (this.snd_misc != "")
- sound_misc (toucher, CHAN_ITEM, this.snd_misc,
+ if (self.snd_misc != "")
+ sound_misc (other, CHAN_ITEM, self.snd_misc,
1, ATTN_NORM);
else
- sound_misc (toucher, CHAN_ITEM,"items/armor1.wav",
+ sound_misc (other, CHAN_ITEM,"items/armor1.wav",
1, ATTN_NORM);
// dumptruck_ds custom models and sounds END
- stuffcmd (toucher, "bf\n");

- activator = toucher;
+ stuffcmd (other, "bf\n");
+
+ activator = other;
// fire all targets / killtargets
sub_usetargets ();
};

//--------------------------------------------------------------
- void() base_item_armor =
+ void(entity e) base_item_armor_init =
+ {
+ e.classgroup |= CG_ITEM_ARMOR;
+ base_item_init (e);
+ };
+
+ //--------------------------------------------------------------
+ strip void() base_item_armor =
{
- this.classgroup |= CG_ITEM_ARMOR;
+ base_item_armor_init (self);
};
-};
+// };

/*QUAKED item_armor1 (0 .5 .8) (-16 -16 0) (16 16 32) X X X X X SPAWN_SILENT TRIGGER_SPAWNED SUSPENDED_IN_AIR NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER RESPAWN_WITH_DM_EFFECTS NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
{
model ("progs/armor.mdl");
}
*/
-class item_armor1: base_item_armor
-{
+//----------------------------------------------------------------------
+// class item_armor1: base_item_armor
+// {
//--------------------------------------------------------------
- virtual void() init_spawned =
+ entity(entity src, vector org, vector vel) spawn_item_armor1 =
{
- if (!this.mdl_body && world.a_grn_mdl)
- this.mdl_body = world.a_grn_mdl;
+ return spawn_item_armor (src, org, vel, item_armor1_init);
+ };
+
+ //--------------------------------------------------------------
+ void(entity e) item_armor1_init =
+ {
+ e.classname = "item_armor1";
+ e.classtype = CT_ITEM_ARMOR_GREEN;
+ e.touch = base_item_armor_touch;

// dumptruck_ds custom models and sounds START
- precache_body_model ("progs/armor.mdl");
- // setmodel (this, "progs/armor.mdl");
- body_model ("progs/armor.mdl");
- precache_sound_misc ("items/armor1.wav");
+ precache_body_model (e, "progs/armor.mdl");
+ // setmodel (e, "progs/armor.mdl");
+ body_model (e, "progs/armor.mdl");
+ precache_sound_misc (e, "items/armor1.wav");
// dumptruck_ds custom models and sounds END

- if !(this.skin)
- this.skin = 0;
- this.size_min = '-16 -16 0';
- this.size_max = '16 16 56';
+ if !(e.skin)
+ e.skin = 0;
+ e.pos1 = '-16 -16 0';
+ e.pos2 = '16 16 56';

// StartItem
- super::init_spawned ();
+ base_item_armor_init (e);
};

//--------------------------------------------------------------
void() item_armor1 =
{
- this.classtype = CT_ITEM_ARMOR_GREEN;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ item_armor1_init (self);
};
-};
+// };

/*QUAKED item_armor2 (0 .5 .8) (-16 -16 0) (16 16 32) X X X X X SPAWN_SILENT TRIGGER_SPAWNED SUSPENDED_IN_AIR NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER RESPAWN_WITH_DM_EFFECTS NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
{ model({ "path": ":progs/armor.mdl", "skin": 1 }); }
*/
-class item_armor2: base_item_armor
-{
+//----------------------------------------------------------------------
+// class item_armor2: base_item_armor
+// {
//--------------------------------------------------------------
- virtual void() init_spawned =
+ entity(entity src, vector org, vector vel) spawn_item_armor2 =
{
- if (!this.mdl_body && world.a_ylw_mdl)
- this.mdl_body = world.a_ylw_mdl;
+ return spawn_item_armor (src, org, vel, item_armor2_init);
+ };
+
+ //--------------------------------------------------------------
+ void(entity e) item_armor2_init =
+ {
+ e.classname = "item_armor2";
+ e.classtype = CT_ITEM_ARMOR_YELLOW;
+ e.touch = base_item_armor_touch;

// dumptruck_ds custom models and sounds START
- precache_body_model ("progs/armor.mdl");
- // setmodel (this, "progs/armor.mdl");
- body_model ("progs/armor.mdl");
+ precache_body_model (e, "progs/armor.mdl");
+ // setmodel (e, "progs/armor.mdl");
+ body_model (e, "progs/armor.mdl");
// dumptruck_ds custom models and sounds END

- if !(this.skin)
- this.skin = 1;
- precache_sound_misc ("items/armor1.wav");
- this.size_min = '-16 -16 0';
- this.size_max = '16 16 56';
+ if !(e.skin)
+ e.skin = 1;
+ precache_sound_misc (e, "items/armor1.wav");
+ e.pos1 = '-16 -16 0';
+ e.pos2 = '16 16 56';

// StartItem
- super::init_spawned ();
+ base_item_armor_init (e);
};

//--------------------------------------------------------------
void() item_armor2 =
{
- this.classtype = CT_ITEM_ARMOR_YELLOW;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ item_armor2_init (self);
};
-};
+// };

/*QUAKED item_armorInv (0 .5 .8) (-16 -16 0) (16 16 32) X X X X X SPAWN_SILENT TRIGGER_SPAWNED SUSPENDED_IN_AIR NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER RESPAWN_WITH_DM_EFFECTS NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
{
model({ "path": ":progs/armor.mdl", "skin": 2 });
}
*/
-class item_armorInv: base_item_armor
-{
+//----------------------------------------------------------------------
+// class item_armorInv: base_item_armor
+// {
//--------------------------------------------------------------
- virtual void() init_spawned =
+ entity(entity src, vector org, vector vel) spawn_item_armorInv =
{
- if (!this.mdl_body && world.a_red_mdl)
- this.mdl_body = world.a_red_mdl;
+ return spawn_item_armor (src, org, vel, item_armorInv_init);
+ };
+
+ //--------------------------------------------------------------
+ void(entity e) item_armorInv_init =
+ {
+ e.classname = "item_armorInv";
+ e.classtype = CT_ITEM_ARMOR_RED;
+ e.touch = base_item_armor_touch;

// dumptruck_ds custom models and sounds START
- precache_body_model ("progs/armor.mdl");
- // setmodel (this, "progs/armor.mdl");
- body_model ("progs/armor.mdl");
+ precache_body_model (e, "progs/armor.mdl");
+ // setmodel (e, "progs/armor.mdl");
+ body_model (e, "progs/armor.mdl");
// dumptruck_ds custom models and sounds END

- if !(this.skin)
- this.skin = 2;
- precache_sound_misc ("items/armor1.wav");
- this.size_min = '-16 -16 0';
- this.size_max = '16 16 56';
+ if !(e.skin)
+ e.skin = 2;
+ precache_sound_misc (e, "items/armor1.wav");
+ e.pos1 = '-16 -16 0';
+ e.pos2 = '16 16 56';

// StartItem
- super::init_spawned ();
+ base_item_armor_init (e);
};

//--------------------------------------------------------------
void() item_armorInv =
{
- this.classtype = CT_ITEM_ARMOR_RED;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ item_armorInv_init (self);
};
-};
+// };

//------------------------------------------------------------------------------
// item_armor_shard
//------------------------------------------------------------------------------
-class item_armor_shard: base_item_armor
-{
+// class item_armor_shard: base_item_armor
+// {
//--------------------------------------------------------------
// shard_touch -- this is from RMQ shard_touch
//--------------------------------------------------------------
- virtual void(entity toucher) do_touch =
+ void() item_armor_shard_touch =
{
-
local float bit;

- if ((toucher.items & IT_ARMOR1) || (toucher.items & IT_ARMOR2)
- || (toucher.items & IT_ARMOR3))
+ if (sub_checkvalidtouch(other) == FALSE)
+ return;
+
+ if ((other.items & IT_ARMOR1) || (other.items & IT_ARMOR2)
+ || (other.items & IT_ARMOR3))
{
// has armor
// Supa, check bounds, original armourvalue + 25
- if (toucher.items & IT_ARMOR1 &&
- toucher.armorvalue >= ARMOR_GREEN_MAX)
+ if (other.items & IT_ARMOR1 &&
+ other.armorvalue >= ARMOR_GREEN_MAX)
{
return;
}
- if (toucher.items & IT_ARMOR2 &&
- toucher.armorvalue >= ARMOR_YELLOW_MAX)
+ if (other.items & IT_ARMOR2 &&
+ other.armorvalue >= ARMOR_YELLOW_MAX)
{
return;
}
- if (toucher.items & IT_ARMOR3 &&
- toucher.armorvalue >= ARMOR_RED_MAX)
+ if (other.items & IT_ARMOR3 &&
+ other.armorvalue >= ARMOR_RED_MAX)
{
return;
}

// was 2, RMQ team
- toucher.armorvalue = toucher.armorvalue + 5;
+ other.armorvalue = other.armorvalue +
+ ARMOR_SHARD_AMOUNT;

// Supa, now cap armourvalue to bounds
- if (toucher.items & IT_ARMOR1 &&
- toucher.armorvalue >= ARMOR_GREEN_MAX)
+ if (other.items & IT_ARMOR1 &&
+ other.armorvalue >= ARMOR_GREEN_MAX)
{
- toucher.armorvalue = ARMOR_GREEN_MAX;
+ other.armorvalue = ARMOR_GREEN_MAX;
}
- else if (toucher.items & IT_ARMOR2 &&
- toucher.armorvalue >= ARMOR_YELLOW_MAX)
+ else if (other.items & IT_ARMOR2 &&
+ other.armorvalue >= ARMOR_YELLOW_MAX)
{
- toucher.armorvalue = ARMOR_YELLOW_MAX;
+ other.armorvalue = ARMOR_YELLOW_MAX;
}
- else if (toucher.items & IT_ARMOR3 &&
- toucher.armorvalue >= ARMOR_RED_MAX)
+ else if (other.items & IT_ARMOR3 &&
+ other.armorvalue >= ARMOR_RED_MAX)
{
- toucher.armorvalue = ARMOR_RED_MAX;
+ other.armorvalue = ARMOR_RED_MAX;
}
}
else
{
// shard = Green armor level
- toucher.armortype = ARMOR_GREEN_ABSORB;
- toucher.armorvalue = ARMOR_SHARD_AMOUNT;
+ other.armortype = ARMOR_GREEN_ABSORB;
+ other.armorvalue = ARMOR_SHARD_AMOUNT;
bit = IT_ARMOR1;
- toucher.items = toucher.items - (toucher.items &
+ other.items = other.items - (other.items &
(IT_ARMOR1 | IT_ARMOR2 | IT_ARMOR3)) + bit;
}

- this.solid = SOLID_NOT;
- this.model = string_null;
- check_respawn (this, ARMOR_RESPAWN_SP, ARMOR_RESPAWN_DM);
+ self.solid = SOLID_NOT;
+ self.model = __NULL__;
+ base_item_check_respawn (self,
+ ARMOR_RESPAWN_SP, ARMOR_RESPAWN_DM);

- if (this.obit_name != __NULL__ && this.obit_name != "")
+ if (self.obit_name != __NULL__ && self.obit_name != "")
// custom armor name
- sprint (toucher, sprintf("You got %s\n",
- this.obit_name));
+ sprint (other, sprintf("You got %s\n", self.obit_name));
else
- sprint (toucher, "You got armor\n");
+ sprint (other, "You got armor\n");

// armor touch sound
// dumptruck_ds custom models and sounds START
- if (this.snd_misc != "")
- sound_misc (toucher, CHAN_AUTO, this.snd_misc,
+ if (self.snd_misc != "")
+ sound_misc (other, CHAN_AUTO, self.snd_misc,
1, ATTN_NORM);
else
- sound_misc (toucher, CHAN_AUTO,
+ sound_misc (other, CHAN_AUTO,
"items/armor_shard_q3.wav", 1, ATTN_NORM);

// dumptruck_ds custom models and sounds END
- stuffcmd (toucher, "bf\n");
+ stuffcmd (other, "bf\n");

// fire all targets / killtargets
- activator = toucher;
+ activator = other;
sub_usetargets ();
};

//--------------------------------------------------------------
- virtual void() init_spawned =
+ entity(entity src) item_armor_shard_drop =
+ {
+ local vector vel;
+ vel_x = -100 + (random() * 200);
+ vel_y = -100 + (random() * 200);
+ vel_z = 300;
+ return spawn_item_armor_shard (src, src.origin - '0 0 24', vel);
+ };
+
+ //--------------------------------------------------------------
+ entity(entity src, vector org, vector vel) spawn_item_armor_shard =
{
- if (!this.mdl_body && world.a_shr_mdl)
- this.mdl_body = world.a_shr_mdl;
+ return spawn_item_armor (src, org, vel, item_armor_shard_init);
+ };
+
+ //--------------------------------------------------------------
+ void(entity e) item_armor_shard_init =
+ {
+ e.classname = "item_armor_shard";
+ e.classtype = CT_ITEM_ARMOR_SHARD;
+ e.touch = item_armor_shard_touch;

// dumptruck_ds custom models and sounds START
- precache_body_model ("progs/armshr.mdl");
- // setmodel (this, "progs/armor.mdl");
- body_model ("progs/armshr.mdl");
- precache_sound_misc ("items/armor_shard_q3.wav");
+ precache_body_model (e, "progs/armshr.mdl");
+ // setmodel (e, "progs/armor.mdl");
+ body_model (e, "progs/armshr.mdl");
+ precache_sound_misc (e, "items/armor_shard_q3.wav");
// dumptruck_ds custom models and sounds END

- if !(this.skin)
- this.skin = 0;
- this.size_min = '-16 -16 0';
- this.size_max = '16 16 56';
+ if !(e.skin)
+ e.skin = 0;
+ e.pos1 = '-16 -16 0';
+ e.pos2 = '16 16 56';

// StartItem
- super::init_spawned ();
+ base_item_armor_init (e);
};

//--------------------------------------------------------------
void() item_armor_shard =
{
- this.classtype = CT_ITEM_ARMOR_SHARD;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ item_armor_shard_init (self);
};
-};
+// };

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

Diff qc/items/backpacks.qc

diff --git a/qc/items/backpacks.qc b/qc/items/backpacks.qc
index 9b16e32..2f2936f 100644
--- a/qc/items/backpacks.qc
+++ b/qc/items/backpacks.qc
@@ -2,7 +2,10 @@
// backpacks -- Player Backpacks
//==============================================================================

+//======================================================================
// constants -- dumptruck_ds
+//======================================================================
+
const float BACKPACK_DEFAULT = 1;
const float BACKPACK_SHELLS = 2;
const float BACKPACK_NAILS = 4;
@@ -10,6 +13,19 @@ const float BACKPACK_ROCKETS = 8;
const float BACKPACK_CELLS = 16;
const float BACKPACK_DROPPED = 32;

+//======================================================================
+// forward declarations
+//======================================================================
+
+// item_backpack
+void() item_backpack_touch;
+entity(entity src) item_backpack_drop;
+entity(entity src, vector org, vector vel) spawn_item_backpack;
+void(entity e) item_backpack_init;
+void() item_backpack;
+
+//------------------------------------------------------------------------------
+
// Some of this text is from Drake -- dumptruck_ds

/*QUAKED item_backpack (0 .5 .8) (-16 -16 0) (16 16 72) SHELLS NAILS ROCKETS CELLS X SPAWN_SILENT TRIGGER_SPAWNED SUSPENDED_IN_AIR NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
@@ -39,155 +55,114 @@ and the mapper chooses the rest of the message.
e.g. For 'You got a bunch of rockets!' the netname key would be
'a bunch of rockets!'
*/
-class item_backpack: base_item
-{
- //--------------------------------------------------------------
- // DropBackpack
+//----------------------------------------------------------------------
+// class item_backpack: base_item
+// {
//--------------------------------------------------------------
- static void(vector org, float in_weapon, float in_shells,
- float in_nails, float in_rockets, float in_cells) drop_backpack =
+ void() item_backpack_touch =
{
- local item_backpack pack;
-
- if (!(in_shells + in_nails + in_rockets + in_cells))
+ if (self.spawnflags & BACKPACK_DROPPED)
{
- // nothing in it
- dprint ("item_backpack::drop_backpack: empty pack!\n");
- return;
- }
-
- pack = spawn (item_backpack,
- spawnflags: BACKPACK_DROPPED,
- origin: org - '0 0 24',
- items: in_weapon,
- ammo_shells: in_shells,
- ammo_nails: in_nails,
- ammo_rockets: in_rockets,
- ammo_cells: in_cells);
-
- if (pack.items == IT_AXE)
- pack.netname = "Axe";
- else if (pack.items == IT_SHOTGUN)
- pack.netname = "Shotgun";
- else if (pack.items == IT_SUPER_SHOTGUN)
- pack.netname = "Double-barrelled Shotgun";
- else if (pack.items == IT_NAILGUN)
- pack.netname = "Nailgun";
- else if (pack.items == IT_SUPER_NAILGUN)
- pack.netname = "Super Nailgun";
- else if (pack.items == IT_GRENADE_LAUNCHER)
- pack.netname = "Grenade Launcher";
- else if (pack.items == IT_ROCKET_LAUNCHER)
- pack.netname = "Rocket Launcher";
- else if (pack.items == IT_LIGHTNING)
- pack.netname = "Thunderbolt";
- else
- pack.netname = "";
-
- pack.velocity_z = 300;
- pack.velocity_x = -100 + (random() * 200);
- pack.velocity_y = -100 + (random() * 200);
- };
+ /*
+ if (sub_checkvalidtouch(other) == FALSE)
+ return;
+ */

- //--------------------------------------------------------------
- virtual void(entity toucher) do_touch =
- {
- if (this.spawnflags & BACKPACK_DROPPED)
- {
local string s;
local float acount, best, old, new;
local entity stemp;

// from Copper -- dumptruck_ds
- if (toucher.movetype == MOVETYPE_NOCLIP)
+ if (other.movetype == MOVETYPE_NOCLIP)
return;
- if (toucher.classtype != CT_PLAYER)
+ if (other.classtype != CT_PLAYER)
return;
- if (toucher.health <= 0)
+ if (other.health <= 0)
return;

acount = 0;
- sprint (toucher, "You get ");
+ sprint (other, "You get ");

- if (this.items)
+ if (self.items)
{
- if ((toucher.items & this.items) == 0)
+ if ((other.items & self.items) == 0)
{
acount = 1;
- sprint (toucher, "the ");
- sprint (toucher, this.netname);
+ sprint (other, "the ");
+ sprint (other, self.netname);
}
}

// if the player was using his best weapon, change
// up to the new one if better
- if (toucher.classtype == CT_PLAYER &&
+ if (other.classtype == CT_PLAYER &&
autocvar(cg_autoswitch, TRUE))
{
- best = ((player)toucher).best_weapon ();
+ best = sub_runfloatas (other,
+ player_best_weapon);
}

// change weapons
- toucher.ammo_shells += this.ammo_shells;
- toucher.ammo_nails += this.ammo_nails;
- toucher.ammo_rockets += this.ammo_rockets;
- toucher.ammo_cells += this.ammo_cells;
+ other.ammo_shells += self.ammo_shells;
+ other.ammo_nails += self.ammo_nails;
+ other.ammo_rockets += self.ammo_rockets;
+ other.ammo_cells += self.ammo_cells;

- new = this.items;
+ new = self.items;
if (!new)
- new = toucher.weapon;
- old = toucher.items;
- toucher.items = toucher.items | new;
+ new = other.weapon;
+ old = other.items;
+ other.items = other.items | new;

- bound_other_ammo ();
+ bound_entity_ammo (other);

// hack to fix an issue with custom Grunt, Ogre
// and Enf ammo types. - dumptruck_ds
- // if (this.ammo_shells < 100)
- if (this.ammo_shells)
+ // if (self.ammo_shells < 100)
+ if (self.ammo_shells)
{
if (acount)
- sprint (toucher, ", ");
+ sprint (other, ", ");
acount = 1;
- s = ftos (this.ammo_shells);
- sprint (toucher, s);
- sprint (toucher, " shells");
+ s = ftos (self.ammo_shells);
+ sprint (other, s);
+ sprint (other, " shells");
}
- if (this.ammo_nails)
+ if (self.ammo_nails)
{
if (acount)
- sprint (toucher, ", ");
+ sprint (other, ", ");
acount = 1;
- s = ftos (this.ammo_nails);
- sprint (toucher, s);
- sprint (toucher, " nails");
+ s = ftos (self.ammo_nails);
+ sprint (other, s);
+ sprint (other, " nails");
}
- if (this.ammo_rockets)
+ if (self.ammo_rockets)
{
if (acount)
- sprint (toucher, ", ");
+ sprint (other, ", ");
acount = 1;
- s = ftos (this.ammo_rockets);
- sprint (toucher, s);
- sprint (toucher, " rockets");
+ s = ftos (self.ammo_rockets);
+ sprint (other, s);
+ sprint (other, " rockets");
}
- if (this.ammo_cells)
+ if (self.ammo_cells)
{
if (acount)
- sprint (toucher, ", ");
+ sprint (other, ", ");
acount = 1;
- s = ftos (this.ammo_cells);
- sprint (toucher, s);
- sprint (toucher, " cells");
+ s = ftos (self.ammo_cells);
+ sprint (other, s);
+ sprint (other, " cells");
}

- sprint (toucher, "\n");
+ sprint (other, "\n");
// backpack touch sound
- sound (toucher, CHAN_ITEM, "weapons/lock4.wav",
+ sound (other, CHAN_ITEM, "weapons/lock4.wav",
1, ATTN_NORM);
- stuffcmd (toucher, "bf\n");
+ stuffcmd (other, "bf\n");

- if (toucher.classtype == CT_PLAYER)
+ if (other.classtype == CT_PLAYER)
{
// change to the weapon
// 1997-12-23 Thunderbolt fix by Maddes start
@@ -195,7 +170,7 @@ class item_backpack: base_item
// don't separate between SinglePlayer/Coop
// and Deathmatch
if (!deathmatch)
- this.weapon = new;
+ self.weapon = new;
else
*/
// 1997-12-23 Thunderbolt fix by Maddes end
@@ -206,290 +181,192 @@ class item_backpack: base_item
Deathmatch_Weapon (old, new);
PlayerSetCurrentAmmo ();
*/
- ((player)toucher).set_current_ammo ();
+ sub_runvoidas (other, player_set_current_ammo);
}

- // remove the backpack, change this to the player
- remove (this);
+ // remove the backpack, change self to the player
+ remove (self);
}
else
{
// item_backpack_message -- CEV
- toucher.ammo_shells += this.ammo_shells;
- toucher.ammo_nails += this.ammo_nails;
- toucher.ammo_rockets += this.ammo_rockets;
- toucher.ammo_cells += this.ammo_cells;
+ other.ammo_shells += self.ammo_shells;
+ other.ammo_nails += self.ammo_nails;
+ other.ammo_rockets += self.ammo_rockets;
+ other.ammo_cells += self.ammo_cells;

- if (this.netname != "")
+ if (self.netname != "")
{
- sprint (toucher, "You got ");
- sprint (toucher, this.netname);
- sprint (toucher, "\n");
+ sprint (other, "You got ");
+ sprint (other, self.netname);
+ sprint (other, "\n");
}
else
{
- sprint (toucher, "You got a backpack!\n");
+ sprint (other, "You got a backpack!\n");
}

// backpack touch sound
- // sound (toucher, CHAN_ITEM, "weapons/lock4.wav",
+ // sound (other, CHAN_ITEM, "weapons/lock4.wav",
// 1, ATTN_NORM);
- sound_misc (toucher, CHAN_ITEM, this.snd_misc,
+ sound_misc (other, CHAN_ITEM, self.snd_misc,
1, ATTN_NORM);
- remove (this);
+ remove (self);

- if (toucher.classtype == CT_PLAYER)
+ if (other.classtype == CT_PLAYER)
{
- stuffcmd (toucher, "bf\n");
- bound_other_ammo ();
- ((player)toucher).set_current_ammo ();
+ stuffcmd (other, "bf\n");
+ bound_entity_ammo (other);
+ sub_runvoidas (other, player_set_current_ammo);
}
}
};

//--------------------------------------------------------------
- virtual void() init_spawned =
+ // DropBackpack
+ //--------------------------------------------------------------
+ entity(entity src) item_backpack_drop =
{
- /*
- if (deathmatch)
+ local entity pack = __NULL__;
+ local vector vel;
+
+ if (src.ammo_shells + src.ammo_nails + src.ammo_rockets +
+ src.ammo_cells <= 0)
{
- remove (this);
- return;
+ // nothing in it
+ dprint ("item_backpack_drop: empty pack!\n");
+ return pack;
}
- */

- this.flags = FL_ITEM;
- this.solid = SOLID_TRIGGER;
- this.movetype = MOVETYPE_TOSS;
+ vel_z = 300;
+ vel_x = -100 + (random() * 200);
+ vel_y = -100 + (random() * 200);
+
+ pack = spawn_item_backpack (src, src.origin - '0 0 24', vel);
+
+ if (pack.items == IT_AXE)
+ pack.netname = "Axe";
+ else if (pack.items == IT_SHOTGUN)
+ pack.netname = "Shotgun";
+ else if (pack.items == IT_SUPER_SHOTGUN)
+ pack.netname = "Double-barrelled Shotgun";
+ else if (pack.items == IT_NAILGUN)
+ pack.netname = "Nailgun";
+ else if (pack.items == IT_SUPER_NAILGUN)
+ pack.netname = "Super Nailgun";
+ else if (pack.items == IT_GRENADE_LAUNCHER)
+ pack.netname = "Grenade Launcher";
+ else if (pack.items == IT_ROCKET_LAUNCHER)
+ pack.netname = "Rocket Launcher";
+ else if (pack.items == IT_LIGHTNING)
+ pack.netname = "Thunderbolt";
+ else
+ pack.netname = "";
+
+ return pack;
+ };
+
+ //--------------------------------------------------------------
+ entity(entity src, vector org, vector vel) spawn_item_backpack =
+ {
+ local entity e = spawn ();
+ e.owner = src;
+ e.origin = org;
+ e.spawnflags = BACKPACK_DROPPED,
+ e.items = src.weapon;
+ e.ammo_shells = src.ammo_shells;
+ e.ammo_nails = src.ammo_nails;
+ e.ammo_rockets = src.ammo_rockets;
+ e.ammo_cells = src.ammo_cells;
+ item_backpack_init (e);
+ return e;
+ };

- if !(this.spawnflags)
+ //--------------------------------------------------------------
+ void(entity e) item_backpack_init =
+ {
+ e.classname = "item_backpack";
+ e.classtype = CT_ITEM_BACKPACK;
+ e.touch = item_backpack_touch;
+ e.flags = FL_ITEM;
+ e.solid = SOLID_TRIGGER;
+ e.movetype = MOVETYPE_TOSS;
+
+ if !(e.spawnflags)
{
- objerror ("\bNO SPAWNFLAG SET ON item_backpack");
+ objerror ("\bitem_backpack_init: NO SPAWNFLAG SET "
+ "ON item_backpack");
return;
}

- if (this.spawnflags & BACKPACK_DEFAULT)
+ if (e.spawnflags & BACKPACK_DEFAULT)
{
- this.ammo_shells = 10;
- this.ammo_nails = 12;
- this.ammo_rockets = 2;
- this.ammo_cells = 3;
+ e.ammo_shells = 10;
+ e.ammo_nails = 12;
+ e.ammo_rockets = 2;
+ e.ammo_cells = 3;
}

- if (this.spawnflags & BACKPACK_SHELLS)
+ if (e.spawnflags & BACKPACK_SHELLS)
{
- if !(this.ammo_shells)
- this.ammo_shells = 10;
+ if (!e.ammo_shells)
+ e.ammo_shells = 10;
}
- if (this.spawnflags & BACKPACK_NAILS)
+ if (e.spawnflags & BACKPACK_NAILS)
{
- if !(this.ammo_nails)
- this.ammo_nails = 12;
+ if (!e.ammo_nails)
+ e.ammo_nails = 12;
}
- if (this.spawnflags & BACKPACK_ROCKETS)
+ if (e.spawnflags & BACKPACK_ROCKETS)
{
- if !(this.ammo_rockets)
- this.ammo_rockets = 2;
+ if (!e.ammo_rockets)
+ e.ammo_rockets = 2;
}
- if (this.spawnflags & BACKPACK_CELLS)
+ if (e.spawnflags & BACKPACK_CELLS)
{
- if !(this.ammo_cells)
- this.ammo_cells = 3;
+ if (!e.ammo_cells)
+ e.ammo_cells = 3;
}

// set the custom noise in editor -- dumptruck_ds
- if !(this.snd_misc)
- this.snd_misc = "weapons/lock4.wav";
- precache_sound_misc (this.snd_misc);
+ if (!e.snd_misc)
+ e.snd_misc = "weapons/lock4.wav";
+ precache_sound_misc (e, e.snd_misc);

- if (this.spawnflags & BACKPACK_DROPPED)
+ if (e.spawnflags & BACKPACK_DROPPED)
{
- precache_body_model ("progs/backpack.mdl");
- // setmodel (this, "progs/backpack.mdl");
- body_model ("progs/backpack.mdl");
+ precache_body_model (e, "progs/backpack.mdl");
+ // setmodel (e, "progs/backpack.mdl");
+ body_model (e, "progs/backpack.mdl");
}
else
{
- precache_body_model ("progs/pd_bpack.mdl");
- body_model ("progs/pd_bpack.mdl");
+ precache_body_model (e, "progs/pd_bpack.mdl");
+ body_model (e, "progs/pd_bpack.mdl");
}

- // setmodel (this, "progs/backpack.mdl");
- this.size_min = '-16 -16 0';
- this.size_max = '16 16 56';
+ // setmodel (e, "progs/backpack.mdl");
+ e.pos1 = '-16 -16 0';
+ e.pos2 = '16 16 56';

// StartItem
- if (this.spawnflags & BACKPACK_DROPPED)
+ if (e.spawnflags & BACKPACK_DROPPED)
{
// don't delay, spawn immediately -- CEV
- setsize (this, this.size_min, this.size_max);
- this.item_flags = ITEM_FLAG_REMOVE;
- this.nextthink = time + 120;
+ setsize (e, e.pos1, e.pos2);
+ e.think = sub_remove;
+ e.nextthink = time + 120;
}
else
{
- super::init_spawned ();
+ base_item_init (e);
}
};

//--------------------------------------------------------------
void() item_backpack =
{
- this.classname = "item_backpack";
- this.classtype = CT_ITEM_BACKPACK;
+ item_backpack_init (self);
};

-};
-
-//======================================================================
-// DropStuff -- dumptruck_ds
-// set drops_item on a monster to a number:
-//
-// 1 = Silver Key
-// 2 = Gold Key
-// 3 = Health Vial
-// 4 = Armor Shard
-// 5 = Health Vial & Armor Shard
-// 6 = random combination of 3 Vials and/or Shards
-//======================================================================
-
-//----------------------------------------------------------------------
-void() DropKey1 =
-{
- /*
- TODO CEV
- local entity item;
-
- item = spawn ();
- item.origin = self.origin - '0 0 24';
-
- item.velocity_z = 300;
- item.velocity_x = -100 + (random() * 200);
- item.velocity_y = -100 + (random() * 200);
-
- if (world.worldtype == WORLDTYPE_MEDIEVAL)
- {
- // precache_model ("progs/w_s_key.mdl");
- setmodel (item, "progs/w_s_key.mdl");
- item.noise = "misc/medkey.wav";
- }
- else if (world.worldtype == WORLDTYPE_METAL)
- {
- // precache_model ("progs/m_s_key.mdl");
- setmodel (item, "progs/m_s_key.mdl");
- item.noise = "misc/runekey.wav";
- }
- else if (world.worldtype == WORLDTYPE_BASE)
- {
- // precache_model2 ("progs/b_s_key.mdl");
- setmodel (item, "progs/b_s_key.mdl");
- item.noise = "misc/basekey.wav";
- }
-
- item.netname = SilverKeyName ();
- item.effects = 8;
- item.flags = FL_ITEM;
- item.items = IT_KEY1;
- item.solid = SOLID_TRIGGER;
- item.movetype = MOVETYPE_TOSS;
- setsize (item, '-16 -16 0', '16 16 56');
- item.touch = key_touch;
- */
-};
-
-//----------------------------------------------------------------------
-void() DropKey2 =
-{
- /*
- TODO CEV
- local entity item;
-
- item = spawn ();
- item.origin = self.origin - '0 0 24';
-
- item.velocity_z = 300;
- item.velocity_x = -100 + (random() * 200);
- item.velocity_y = -100 + (random() * 200);
-
- if (world.worldtype == WORLDTYPE_MEDIEVAL)
- {
- // precache_model ("progs/w_s_key.mdl");
- setmodel (item, "progs/w_g_key.mdl");
- item.noise = "misc/medkey.wav";
- }
- else if (world.worldtype == WORLDTYPE_METAL)
- {
- // precache_model ("progs/m_s_key.mdl");
- setmodel (item, "progs/m_g_key.mdl");
- item.noise = "misc/runekey.wav";
- }
- else if (world.worldtype == WORLDTYPE_BASE)
- {
- // precache_model2 ("progs/b_s_key.mdl");
- setmodel (item, "progs/b_g_key.mdl");
- item.noise = "misc/basekey.wav";
- }
- item.netname = GoldKeyName ();
- item.effects = 8;
- item.flags = FL_ITEM;
- item.items = IT_KEY2;
- item.solid = SOLID_TRIGGER;
- item.movetype = MOVETYPE_TOSS;
- setsize (item, '-16 -16 0', '16 16 56');
- item.touch = key_touch;
-*/
-};
-
-//----------------------------------------------------------------------
-void() DropVial =
-{
- /*
- TODO CEV
- local entity item;
-
- item = spawn ();
- item.origin = self.origin - '0 0 24';
-
- item.velocity_z = 300;
- item.velocity_x = -100 + (random() * 200);
- item.velocity_y = -100 + (random() * 200);
-
- setmodel (item, "progs/health/pd_vial.mdl");
- item.solid = SOLID_TRIGGER;
- item.movetype = MOVETYPE_TOSS;
- setsize (item, '-16 -16 0', '16 16 56');
- item.touch = health_touch;
- item.healamount = 5;
- // changed the healtype from 0 (rotten) to 2 (mega) to reflect
- // health vial behavior in item_health_vial -- CEV
- item.healtype = HEALTH_TYPE_MEGA;
- item.noise = "items/r_item1.wav";
-
- StartItem ();
- */
-};
-
-//----------------------------------------------------------------------
-void() DropShard =
-{
- /*
- TODO CEV
- local entity item;
-
- item = spawn ();
- item.origin = self.origin - '0 0 24';
-
- item.velocity_z = 300;
- item.velocity_x = -100 + (random() * 200);
- item.velocity_y = -100 + (random() * 200);
-
- setmodel (item, "progs/armshr.mdl");
- item.solid = SOLID_TRIGGER;
- item.movetype = MOVETYPE_TOSS;
- setsize (item, '-16 -16 0', '16 16 56');
- item.touch = shard_touch;
- item.snd_misc = "dump/armsh1.wav";
-
- StartItem ();
- */
-};
+// };

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

Diff qc/items/health.qc

diff --git a/qc/items/health.qc b/qc/items/health.qc
index dc5de94..d318739 100644
--- a/qc/items/health.qc
+++ b/qc/items/health.qc
@@ -2,7 +2,11 @@
// HEALTH BOXES
//==============================================================================

-// constants flags
+//======================================================================
+// constants
+//======================================================================
+
+// constants spawnflags
const float HEALTH_ROTTEN = 1; // rotten health box
const float HEALTH_MEGA = 2; // megahealth
const float HEALTH_VIAL = 4; // vial (AKA bubble)
@@ -21,6 +25,38 @@ const float HEALTH_RESPAWN_DM = 20; // deathmatch respawn time; id1 20
const float HEALTH_RESPAWN_SP = 30; // singleplayer respawn time; id1 30
const float HEALTH_RESPAWN_MEGA = 125; // fixed mega respawn time; pd3 125

+//======================================================================
+// fields
+//======================================================================
+
+.float healamount;
+.float healtype;
+
+//======================================================================
+// forward declarations
+//======================================================================
+
+// TODO CEV rework the damage system
+float (entity e, float healamount, float ignore) T_Heal;
+
+// base_item_health
+void() base_item_health_touch;
+void(entity e) base_item_health_init;
+strip void() base_item_health;
+
+// item_health
+entity(entity src, vector org, vector vel, float flags) spawn_item_health;
+void(entity e) item_health_init;
+void() item_health;
+
+// item_health_vial
+entity(entity src) item_health_vial_drop;
+entity(entity src, vector org, vector vel) spawn_item_health_vial;
+void(entity e) item_health_vial_init;
+void() item_health_vial;
+
+//------------------------------------------------------------------------------
+
//----------------------------------------------------------------------
// T_Heal: add health to an entity, limiting health to max_health
// "ignore" will ignore max_health limit
@@ -42,71 +78,54 @@ float (entity e, float healamount, float ignore) T_Heal =
return 1;
};

-//------------------------------------------------------------------------------
-class base_item_health: base_item
-{
- // fields
- float healamount;
- float healtype;
-
- //--------------------------------------------------------------
- virtual void(string fieldname, string fieldvalue) init_field =
- {
- switch (fieldname)
- {
- case "healamount":
- healamount = stof (fieldvalue);
- break;
- case "healtype":
- healtype = stof (fieldvalue);
- break;
- default:
- super::init_field (fieldname, fieldvalue);
- }
- };
-
+//----------------------------------------------------------------------
+// class base_item_health: base_item
+// {
//--------------------------------------------------------------
// health_touch
//--------------------------------------------------------------
- virtual void(entity toucher) do_touch =
+ void() base_item_health_touch =
{
+ if (sub_checkvalidtouch(other) == FALSE)
+ return;
+
local float amount;
local string s;
- amount = this.healamount;
+ amount = self.healamount;

- if (this.healtype == HEALTH_TYPE_MEGA)
+ if (self.healtype == HEALTH_TYPE_MEGA)
{
// Megahealth? Ignore max_health...
- if (toucher.health >= 250)
+ if (other.health >= 250)
return;
- if (!T_Heal(toucher, amount, 1))
+ if (!T_Heal(other, amount, 1))
return;
}
else
{
- if (!T_Heal(toucher, amount, 0))
+ if (!T_Heal(other, amount, 0))
return;
}

- sprint (toucher, sprintf("You receive %g health\n", amount));
+ sprint (other, sprintf("You receive %g health\n", amount));

// health touch sound
- // sound (toucher, CHAN_ITEM, this.noise, 1, ATTN_NORM);
+ // sound (other, CHAN_ITEM, self.noise, 1, ATTN_NORM);
// custom sounds -- dumptruck_ds
- sound_misc (toucher, CHAN_AUTO, this.noise, 1, ATTN_NORM);
+ sound_misc (other, CHAN_AUTO, self.noise, 1, ATTN_NORM);

- stuffcmd (toucher, "bf\n");
+ stuffcmd (other, "bf\n");

- this.model = string_null;
- this.solid = SOLID_NOT;
+ self.model = __NULL__;
+ self.solid = SOLID_NOT;

// Megahealth = rot down the player's super health
- if (this.healtype == HEALTH_TYPE_MEGA)
+ if (self.healtype == HEALTH_TYPE_MEGA)
{
// thanks ydrol!!!
- toucher.megahealth_rottime = time + 5;
- toucher.items = toucher.items | IT_SUPERHEALTH;
- this.owner = toucher;
+ other.megahealth_rottime = time + 5;
+ other.items = other.items | IT_SUPERHEALTH;
+ self.owner = other;

// Regarding the deathmatch respawn time below:
// id's original code made the megahealth respawn
@@ -124,26 +143,33 @@ class base_item_health: base_item
// original 20 second delay before the item
// respawned). -- iw

- check_respawn (this, HEALTH_RESPAWN_SP,
+ base_item_check_respawn (self, HEALTH_RESPAWN_SP,
HEALTH_RESPAWN_MEGA);
}
else
{
- check_respawn (this, HEALTH_RESPAWN_SP,
+ base_item_check_respawn (self, HEALTH_RESPAWN_SP,
HEALTH_RESPAWN_DM);
}

// fire all targets / killtargets
- activator = toucher;
+ activator = other;
sub_usetargets ();
};

//--------------------------------------------------------------
- void() base_item_health =
+ void(entity e) base_item_health_init =
{
- this.classgroup |= CG_ITEM_HEALTH;
+ e.classgroup |= CG_ITEM_HEALTH;
+ base_item_init (e);
};
-};
+
+ //--------------------------------------------------------------
+ strip void() base_item_health =
+ {
+ base_item_health_init (self);
+ };
+// };

/*QUAKED item_health (.3 .3 1) (0 0 0) (32 32 32) ROTTEN MEGAHEALTH X X X SPAWN_SILENT TRIGGER_SPAWNED SUSPENDED_IN_AIR NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER RESPAWN_WITH_DM_EFFECTS NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
{
@@ -155,176 +181,213 @@ Rotten box heals 15 points.
Megahealth will add 100 health, then start to
rot the player back down to 100 health after 5 seconds.
*/
-class item_health: base_item_health
-{
+//----------------------------------------------------------------------
+// class item_health: base_item_health
+// {
//--------------------------------------------------------------
- virtual void() init_spawned =
+ entity(entity src, vector org, vector vel, float flags)
+ spawn_item_health =
{
- if (this.spawnflags & HEALTH_ROTTEN)
- {
- if (!this.mdl_body && world.h_15_mdl)
- this.mdl_body = world.h_15_mdl;
+ local entity e = spawn ();
+ e.owner = src;
+ e.origin = org;
+ e.velocity = vel;
+ e.spawnflags = flags;
+ item_health_init (e);
+ return e;
+ };
+
+ //--------------------------------------------------------------
+ void(entity e) item_health_init =
+ {
+ e.classname = "item_health";
+ e.classtype = CT_ITEM_HEALTH;
+ e.touch = base_item_health_touch;

+ if (e.spawnflags & HEALTH_ROTTEN)
+ {
// dumptruck_ds custom health models and sounds START
if (world.style)
{
- // models courtesy Lunaran -- dumptruck_ds
- precache_body_model ("progs/health/m_h15.mdl");
- body_model ("progs/health/m_h15.mdl");
+ precache_body_model (e,
+ "progs/health/m_h15.mdl");
+ body_model (e, "progs/health/m_h15.mdl");
}
else
{
- // setmodel(this, "maps/b_bh10.bsp");
- precache_body_model ("maps/b_bh10.bsp");
- body_model ("maps/b_bh10.bsp");
+ precache_body_model (e, "maps/b_bh10.bsp");
+ body_model (e, "maps/b_bh10.bsp");
}

- // precache_sound("items/r_item1.wav");
- precache_sound_misc("items/r_item1.wav");
- // this.noise = "items/r_item1.wav";
- if !(this.snd_misc)
+ precache_sound_misc (e, "items/r_item1.wav");
+ // e.noise = "items/r_item1.wav";
+ if !(e.snd_misc)
// set the custom noise in editor
// -- dumptruck_ds
- this.snd_misc = "items/r_item1.wav";
- this.noise = this.snd_misc;
+ e.snd_misc = "items/r_item1.wav";
+ e.noise = e.snd_misc;

- // if !(this.healamount)
+ // if !(e.healamount)
// set your custom health amount here
// -- dumptruck_ds

- this.healamount = HEALTH_ROTTEN_AMOUNT;
- this.healtype = HEALTH_TYPE_ROTTEN;
- if !(this.particles_offset)
- this.particles_offset = '16 16 8';
+ e.healamount = HEALTH_ROTTEN_AMOUNT;
+ e.healtype = HEALTH_TYPE_ROTTEN;
+ if !(e.particles_offset)
+ e.particles_offset = '16 16 8';
// dumptruck_ds custom health models and sounds END
}
else
{
- if (this.spawnflags & HEALTH_MEGA)
+ if (e.spawnflags & HEALTH_MEGA)
{
- if (!this.mdl_body && world.h_mega_mdl)
- this.mdl_body = world.h_mega_mdl;
- // precache_model("maps/b_bh100.bsp");
+ // precache_model ("maps/b_bh100.bsp");
if (world.style)
{
// models courtesy Lunaran
// -- dumptruck_ds
- precache_body_model ("progs/health/"
- "m_h100.mdl");
- body_model ("progs/health/m_h100.mdl");
+ precache_body_model (e,
+ "progs/health/m_h100.mdl");
+ body_model (e,
+ "progs/health/m_h100.mdl");
}
else
{
- // setmodel(this, "maps/b_bh100.bsp");
- precache_body_model ("maps/"
- "b_bh100.bsp");
- body_model ("maps/b_bh100.bsp");
+ // setmodel(e, "maps/b_bh100.bsp");
+ precache_body_model (e,
+ "maps/b_bh100.bsp");
+ body_model (e, "maps/b_bh100.bsp");
}

- precache_sound_misc("items/r_item2.wav");
- // this.noise = "items/r_item2.wav";
- if !(this.snd_misc)
+ precache_sound_misc (e, "items/r_item2.wav");
+ // e.noise = "items/r_item2.wav";
+ if !(e.snd_misc)
// set the custom noise in editor
// -- dumptruck_ds
- this.snd_misc = "items/r_item2.wav";
- this.noise = this.snd_misc;
+ e.snd_misc = "items/r_item2.wav";
+ e.noise = e.snd_misc;

- // if !(this.healamount)
+ // if !(e.healamount)
// custom health amount
// -- dumptruck_ds

- this.healamount = HEALTH_MEGA_AMOUNT;
- this.healtype = HEALTH_TYPE_MEGA;
- if !(this.particles_offset)
- this.particles_offset = '16 16 16';
+ e.healamount = HEALTH_MEGA_AMOUNT;
+ e.healtype = HEALTH_TYPE_MEGA;
+ if !(e.particles_offset)
+ e.particles_offset = '16 16 16';
}
else
{
- if (!this.mdl_body && world.h_25_mdl)
- this.mdl_body = world.h_25_mdl;
if (world.style)
{
// models courtesy Lunaran
// -- dumptruck_ds
- precache_body_model ("progs/health/"
- "m_h25.mdl");
- body_model ("progs/health/m_h25.mdl");
+ precache_body_model (e,
+ "progs/health/m_h25.mdl");
+ body_model (e,
+ "progs/health/m_h25.mdl");
}
else
{
- precache_body_model ("maps/b_bh25.bsp");
- body_model ("maps/b_bh25.bsp");
+ precache_body_model (e,
+ "maps/b_bh25.bsp");
+ body_model (e, "maps/b_bh25.bsp");
}
- precache_sound_misc("items/health1.wav");
- if !(this.snd_misc)
+ precache_sound_misc (e, "items/health1.wav");
+ if !(e.snd_misc)
// set custom noise in editor
// -- dumptruck_ds
- this.snd_misc = "items/health1.wav";
- this.noise = this.snd_misc;
+ e.snd_misc = "items/health1.wav";
+ e.noise = e.snd_misc;

- this.healamount = HEALTH_NORMAL_AMOUNT;
- this.healtype = HEALTH_TYPE_NORMAL;
- if !(this.particles_offset)
- this.particles_offset = '16 16 8';
+ e.healamount = HEALTH_NORMAL_AMOUNT;
+ e.healtype = HEALTH_TYPE_NORMAL;
+ if !(e.particles_offset)
+ e.particles_offset = '16 16 8';
// dumptruck_ds custom health models and sounds
}
}

- this.size_min = '0 0 0';
- this.size_max = '32 32 56';
+ e.pos1 = '0 0 0';
+ e.pos2 = '32 32 56';

// StartItem
- super::init_spawned ();
+ base_item_health_init (e);
};

//--------------------------------------------------------------
void() item_health =
{
- this.classtype = CT_ITEM_HEALTH;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ item_health_init (self);
};
-};
+// };

//----------------------------------------------------------------------
// item_health_vial
//----------------------------------------------------------------------
-class item_health_vial: base_item_health
-{
+// class item_health_vial: base_item_health
+// {
//--------------------------------------------------------------
- static void() drop_vial =
+ entity(entity src) item_health_vial_drop =
{
+ local vector vel;
+ vel_x = -100 + (random() * 200);
+ vel_y = -100 + (random() * 200);
+ vel_z = 300;
+ return spawn_item_health_vial (src, src.origin - '0 0 24', vel);
};

//--------------------------------------------------------------
- virtual void() init_spawned =
+ entity(entity src, vector org, vector vel) spawn_item_health_vial =
{
- if (!this.mdl_body && world.h_vial_mdl)
- this.mdl_body = world.h_vial_mdl;
+ local entity e = spawn ();
+ e.owner = src;
+ e.origin = org;
+ e.velocity = vel;
+ item_health_vial_init (e);
+ return e;
+ };
+
+ //--------------------------------------------------------------
+ void(entity e) item_health_vial_init =
+ {
+ e.classname = "item_health_vial";
+ e.classtype = CT_ITEM_HEALTH_VIAL;
+ e.touch = base_item_health_touch;

// model from Hexen 2 -- dumptruck_ds
- precache_body_model ("progs/health/pd_vial.mdl");
- body_model ("progs/health/pd_vial.mdl");
- precache_sound_misc ("items/r_item1.wav");
- if !(this.snd_misc)
+ precache_body_model (e, "progs/health/pd_vial.mdl");
+ body_model (e, "progs/health/pd_vial.mdl");
+ precache_sound_misc (e, "items/r_item1.wav");
+ if !(e.snd_misc)
// set the custom noise in editor -- dumptruck_ds
- this.snd_misc = "items/r_item1.wav";
- this.noise = this.snd_misc;
+ e.snd_misc = "items/r_item1.wav";
+ e.noise = e.snd_misc;

- this.healamount = HEALTH_VIAL_AMOUNT;
+ e.healamount = HEALTH_VIAL_AMOUNT;
// over heal and count down like mega health -- dumptruck_ds
- this.healtype = HEALTH_TYPE_MEGA;
- this.size_min = '-16 -16 0';
- this.size_max = '16 16 56';
+ e.healtype = HEALTH_TYPE_MEGA;
+ e.pos1 = '-16 -16 0';
+ e.pos2 = '16 16 56';

- if !(this.particles_offset)
- this.particles_offset = '0 0 0';
+ if !(e.particles_offset)
+ e.particles_offset = '0 0 0';

// StartItem
- super::init_spawned ();
+ base_item_health_init (e);
};

//--------------------------------------------------------------
void() item_health_vial =
{
- this.classtype = CT_ITEM_HEALTH_VIAL;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ item_health_vial_init (self);
};
-};
+// };

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

Diff qc/items/keys.qc

diff --git a/qc/items/keys.qc b/qc/items/keys.qc
index bd87d3b..9e13577 100644
--- a/qc/items/keys.qc
+++ b/qc/items/keys.qc
@@ -2,27 +2,115 @@
// KEYS
//==============================================================================

-// Globals
+//======================================================================
+// constants
+//======================================================================

// The highest bitflag that will be assigned to a custom key.
-float FINAL_CUSTOM_KEY = 4194304;
+const float FINAL_CUSTOM_KEY = 4194304;
+
+//======================================================================
+// globals
+//======================================================================

// The highest bitflag that has been assigned to a custom key.
float highest_custom_key;

+//======================================================================
+// fields
+//======================================================================
+
+.float customkeys; // support for item_key_custom -- iw
+.string keyname;
+
+//======================================================================
+// forward declarations
+//======================================================================
+
+// temp_keydef
+entity(string key_name) spawn_temp_keydef;
+void(entity e) temp_keydef_init;
+strip void() temp_keydef;
+
+// base_item_key
+string() base_item_key_silvername;
+string() base_item_key_goldname;
+entity(string key_name) base_item_key_find_keydef;
+float(string key_name) base_item_key_customflag;
+float(entity client, float flags, float custom_flags) base_item_key_haskeys;
+void(entity client, float flags, float custom_flags) base_item_key_givekeys;
+void(entity client) base_item_key_giveallkeys;
+void(entity client, float flags, float custom_flags) base_item_key_removekeys;
+void() base_item_key_touch;
+void(entity e) base_item_key_init;
+strip void() base_item_key;
+
+// item_key1
+entity(entity src) item_key1_drop;
+entity(entity src, vector org, vector vel) spawn_item_key1;
+void(entity e) item_key1_init;
+void() item_key1;
+
+// item_key2
+entity(entity src) item_key2_drop;
+entity(entity src, vector org, vector vel) spawn_item_key2;
+void(entity e) item_key2_init;
+void() item_key2;
+
+// item_key_custom
+entity(entity src, vector org, vector vel, string kname) spawn_item_key_custom;
+void(entity e) item_key_custom_init;
+void() item_key_custom;
+
//------------------------------------------------------------------------------
-class temp_keydef: base_tempentity
-{
- void() temp_keydef =
+
+//----------------------------------------------------------------------
+// class temp_keydef: base_tempentity
+// {
+ //--------------------------------------------------------------
+ // SpawnCustomKeyDef
+ //
+ // Spawn and return a new custom_key_def entity which will define
+ // the custom key named key_name.
+ //
+ // The value of the entity's customkeys field will be a bitflag
+ // which has not yet been used to represent a custom key. -- iw
+ //--------------------------------------------------------------
+ entity(string key_name) spawn_temp_keydef =
+ {
+ if (highest_custom_key == FINAL_CUSTOM_KEY)
+ error ("too many custom keys");
+
+ if (highest_custom_key == 0)
+ highest_custom_key = 1;
+ else
+ highest_custom_key = highest_custom_key * 2;
+
+ local entity e = spawn ();
+ e.netname = key_name;
+ e.customkeys = highest_custom_key;
+ temp_keydef_init (e);
+ return e;
+ };
+
+ //--------------------------------------------------------------
+ void(entity e) temp_keydef_init =
{
- this.classname = "custom_key_def";
- this.classtype = CT_TEMP_KEYDEF;
+ base_tempentity_init (e);
+ e.classname = "custom_key_def";
+ e.classtype = CT_TEMP_KEYDEF;
};
-};

-//------------------------------------------------------------------------------
-class base_item_key: base_item
-{
+ //--------------------------------------------------------------
+ strip void() temp_keydef =
+ {
+ temp_keydef_init (self);
+ };
+// };
+
+//----------------------------------------------------------------------
+// class base_item_key: base_item
+// {
//==============================================================
// FUNCTIONS WHICH DEAL WITH KEY ITEM BITFLAGS AND NAMES
//==============================================================
@@ -47,7 +135,7 @@ class base_item_key: base_item
// Return the name that should be used for the silver key as per
// world.worldtype. -- iw
//--------------------------------------------------------------
- static string() silver_key_name =
+ string() base_item_key_silvername =
{
if (world.worldtype == WORLDTYPE_BASE)
return "silver keycard";
@@ -62,7 +150,7 @@ class base_item_key: base_item
// Return the name that should be used for the gold key as per
// world.worldtype. -- iw
//--------------------------------------------------------------
- static string() gold_key_name =
+ string() base_item_key_goldname =
{
if (world.worldtype == WORLDTYPE_BASE)
return "gold keycard";
@@ -81,49 +169,21 @@ class base_item_key: base_item
// customkeys field will be the bitflag that should be used to
// represent the custom key named key_name. -- iw
//--------------------------------------------------------------
- static entity(string key_name) find_custom_keydef =
+ entity(string key_name) base_item_key_find_keydef =
{
local entity keydef;

- keydef = findfloat (world, ::classtype, CT_TEMP_KEYDEF);
+ keydef = findfloat (world, classtype, CT_TEMP_KEYDEF);
while (keydef != world)
{
if (keydef.netname == key_name)
return keydef;
- keydef = findfloat(keydef, ::classtype, CT_TEMP_KEYDEF);
+ keydef = findfloat (keydef, classtype, CT_TEMP_KEYDEF);
}
return world;
};

//--------------------------------------------------------------
- // SpawnCustomKeyDef
- //
- // Spawn and return a new custom_key_def entity which will define
- // the custom key named key_name.
- //
- // The value of the entity's customkeys field will be a bitflag
- // which has not yet been used to represent a custom key. -- iw
- //--------------------------------------------------------------
- static entity(string key_name) spawn_custom_keydef =
- {
- local temp_keydef keydef;
-
- if (highest_custom_key == FINAL_CUSTOM_KEY)
- error ("too many custom keys");
-
- if (highest_custom_key == 0)
- highest_custom_key = 1;
- else
- highest_custom_key = highest_custom_key * 2;
-
- keydef = spawn (temp_keydef,
- netname: key_name,
- customkeys: highest_custom_key);
-
- return keydef;
- };
-
- //--------------------------------------------------------------
// CustomKeyFlag
//
// Return the bitflag that should be used to represent the custom
@@ -135,13 +195,13 @@ class base_item_key: base_item
// anykey_name. Otherwise, return the same bitflag that was
// previously returned for the specified key_name. -- iw
//--------------------------------------------------------------
- static float(string key_name) custom_key_flag =
+ float(string key_name) base_item_key_customflag =
{
- local temp_keydef keydef;
+ local entity keydef;

- keydef = find_custom_keydef (key_name);
+ keydef = base_item_key_find_keydef (key_name);
if (keydef == world)
- keydef = spawn_custom_keydef (key_name);
+ keydef = spawn_temp_keydef (key_name);
return keydef.customkeys;
};

@@ -152,7 +212,8 @@ class base_item_key: base_item
// keys represented by the flags and all of the custom keys
// represented by the custom_flags, otherwise return FALSE. -- iw
//--------------------------------------------------------------
- static float(entity client, float flags, float custom_flags) has_keys =
+ float(entity client, float flags, float custom_flags)
+ base_item_key_haskeys =
{
return (client.items & flags) == flags &&
(client.customkeys & custom_flags) == custom_flags;
@@ -165,7 +226,8 @@ class base_item_key: base_item
// by the item_flags and all of the custom keys represented by the
// customkey_flags. -- iw
//--------------------------------------------------------------
- static void(entity client, float flags, float custom_flags) give_keys =
+ void(entity client, float flags, float custom_flags)
+ base_item_key_givekeys =
{
client.items = client.items | flags;
client.customkeys = client.customkeys | custom_flags;
@@ -178,9 +240,9 @@ class base_item_key: base_item
// all of the custom keys that have been defined for the current
// map. -- iw
//--------------------------------------------------------------
- static void(entity client) give_all_keys =
+ void(entity client) base_item_key_giveallkeys =
{
- give_keys (client, IT_KEY1 | IT_KEY2,
+ base_item_key_givekeys (client, IT_KEY1 | IT_KEY2,
highest_custom_key * 2 - 1);
};

@@ -191,8 +253,8 @@ class base_item_key: base_item
// and all of the custom keys represented by the customkey_flags
// from the specified client's inventory. -- iw
//--------------------------------------------------------------
- static void(entity client, float flags, float custom_flags)
- remove_keys =
+ void(entity client, float flags, float custom_flags)
+ base_item_key_removekeys =
{
client.items = client.items - (client.items & flags);
client.customkeys = client.customkeys -
@@ -207,27 +269,30 @@ class base_item_key: base_item
//--------------------------------------------------------------
// was key_touch -- CEV
//--------------------------------------------------------------
- virtual void(entity toucher) do_touch =
+ void() base_item_key_touch =
{
+ if (sub_checkvalidtouch(other) == FALSE)
+ return;
+
// support for item_key_custom -- iw
- if (has_keys(toucher, this.items, this.customkeys))
+ if (base_item_key_haskeys(other, self.items, self.customkeys))
return;

- sprint (toucher, sprintf("You got the %s\n", this.netname));
+ sprint (other, sprintf("You got the %s\n", self.netname));

- sound (toucher, CHAN_ITEM, this.noise, 1, ATTN_NORM);
- stuffcmd (toucher, "bf\n");
+ sound (other, CHAN_ITEM, self.noise, 1, ATTN_NORM);
+ stuffcmd (other, "bf\n");

// support for item_key_custom -- iw
- give_keys (toucher, this.items, this.customkeys);
+ base_item_key_givekeys (other, self.items, self.customkeys);

if (!coop)
{
- this.solid = SOLID_NOT;
- this.model = string_null;
+ self.solid = SOLID_NOT;
+ self.model = __NULL__;
}

- activator = toucher;
+ activator = other;
// fix key items firing their targets multiple times in coop
// -- iw
// fire all targets / killtargets
@@ -237,48 +302,50 @@ class base_item_key: base_item
//--------------------------------------------------------------
// key_start -- Finish initializing self as a key item. -- iw
//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) base_item_key_init =
{
+ e.classgroup |= CG_ITEM_KEY;
+
// key_setsounds
// support for item_key_custom -- iw
- if (this.noise != "")
+ if (e.noise != "")
{
- precache_sound (this.noise);
+ precache_sound (e.noise);
}
else
{
if (world.worldtype == WORLDTYPE_MEDIEVAL)
{
precache_sound ("misc/medkey.wav");
- this.noise = "misc/medkey.wav";
+ e.noise = "misc/medkey.wav";
}
else if (world.worldtype == WORLDTYPE_METAL)
{
precache_sound ("misc/runekey.wav");
- this.noise = "misc/runekey.wav";
+ e.noise = "misc/runekey.wav";
}
else if (world.worldtype == WORLDTYPE_BASE)
{
precache_sound2 ("misc/basekey.wav");
- this.noise = "misc/basekey.wav";
+ e.noise = "misc/basekey.wav";
}
}

// key_start
- this.particles_offset = '0 0 18';
- this.size_min = '-16 -16 -24';
- this.size_max = '16 16 32';
+ e.particles_offset = '0 0 18';
+ e.pos1 = '-16 -16 -24';
+ e.pos2 = '16 16 32';

// StartItem
- super::init_spawned ();
+ base_item_init (e);
};

//--------------------------------------------------------------
- void() base_item_key =
+ strip void() base_item_key =
{
- this.classgroup |= CG_ITEM_KEY;
+ base_item_key_init (self);
};
-};
+// };

/*QUAKED item_key1 (0 .5 .8) (-16 -16 -24) (16 16 32) X X X X X SPAWN_SILENT TRIGGER_SPAWNED SUSPENDED_IN_AIR NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
{ model("progs/w_s_key.mdl"); }
@@ -288,48 +355,81 @@ In order for keys to work you MUST set your map's worldtype to one of the follow
1: metal
2: base
*/
-class item_key1: base_item_key
-{
+//----------------------------------------------------------------------
+// class item_key1: base_item_key
+// {
+ //--------------------------------------------------------------
+ entity(entity src) item_key1_drop =
+ {
+ local entity e;
+ local vector vel;
+ vel_x = -100 + (random() * 200);
+ vel_y = -100 + (random() * 200);
+ vel_z = 300;
+ e = spawn_item_key1 (src, src.origin - '0 0 24', vel);
+ e.effects = EF_DIMLIGHT;
+ return e;
+ };
+
+ //--------------------------------------------------------------
+ entity(entity src, vector org, vector vel) spawn_item_key1 =
+ {
+ local entity e = spawn ();
+ e.owner = src;
+ e.origin = org;
+ e.velocity = vel;
+ item_key1_init (e);
+ return e;
+ };
+
//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) item_key1_init =
{
+ e.classname = "item_key1";
+ e.classtype = CT_ITEM_KEY1;
+ e.touch = base_item_key_touch;
+
if (world.worldtype == WORLDTYPE_MEDIEVAL)
{
- precache_body_model ("progs/w_s_key.mdl");
- body_model ("progs/w_s_key.mdl");
+ precache_body_model (e, "progs/w_s_key.mdl");
+ body_model (e, "progs/w_s_key.mdl");
}
else if (world.worldtype == WORLDTYPE_METAL)
{
- precache_body_model ("progs/m_s_key.mdl");
- body_model ("progs/m_s_key.mdl");
+ precache_body_model (e, "progs/m_s_key.mdl");
+ body_model (e, "progs/m_s_key.mdl");
}
else if (world.worldtype == WORLDTYPE_BASE)
{
- precache_body_model2 ("progs/b_s_key.mdl");
- body_model ("progs/b_s_key.mdl");
+ precache_body_model2 (e, "progs/b_s_key.mdl");
+ body_model (e, "progs/b_s_key.mdl");
}

- if (this.keyname != "")
- this.netname = this.keyname;
+ if (e.keyname != "")
+ e.netname = e.keyname;
else
- this.netname = silver_key_name ();
+ e.netname = base_item_key_silvername ();

- this.items = IT_KEY1;
+ e.items = IT_KEY1;

// support for item_key_custom -- iw
- this.customkeys = 0; // ignore any mapper-set value
- this.noise = ""; // ignore any mapper-set value
+ e.customkeys = 0; // ignore any mapper-set value
+ e.noise = ""; // ignore any mapper-set value

// key_start
- super::init_spawned ();
+ base_item_key_init (e);
};

//--------------------------------------------------------------
void() item_key1 =
{
- this.classtype = CT_ITEM_KEY1;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ item_key1_init (self);
};
-};
+// };

/*QUAKED item_key2 (0 .5 .8) (-16 -16 -24) (16 16 32) X X X X X SPAWN_SILENT TRIGGER_SPAWNED SUSPENDED_IN_AIR NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
{
@@ -341,48 +441,81 @@ In order for keys to work you MUST set your map's worldtype to one of the follow
1: metal
2: base
*/
-class item_key2: base_item_key
-{
+//----------------------------------------------------------------------
+// class item_key2: base_item_key
+// {
//--------------------------------------------------------------
- virtual void() init_spawned =
+ entity(entity src) item_key2_drop =
{
+ local entity e;
+ local vector vel;
+ vel_x = -100 + (random() * 200);
+ vel_y = -100 + (random() * 200);
+ vel_z = 300;
+ e = spawn_item_key2 (src, src.origin - '0 0 24', vel);
+ e.effects = EF_DIMLIGHT;
+ return e;
+ };
+
+ //--------------------------------------------------------------
+ entity(entity src, vector org, vector vel) spawn_item_key2 =
+ {
+ local entity e = spawn ();
+ e.owner = src;
+ e.origin = org;
+ e.velocity = vel;
+ item_key2_init (e);
+ return e;
+ };
+
+ //--------------------------------------------------------------
+ void(entity e) item_key2_init =
+ {
+ e.classname = "item_key2";
+ e.classtype = CT_ITEM_KEY2;
+ e.touch = base_item_key_touch;
+
if (world.worldtype == WORLDTYPE_MEDIEVAL)
{
- precache_body_model ("progs/w_g_key.mdl");
- body_model ("progs/w_g_key.mdl");
+ precache_body_model (e, "progs/w_g_key.mdl");
+ body_model (e, "progs/w_g_key.mdl");
}
else if (world.worldtype == WORLDTYPE_METAL)
{
- precache_body_model ("progs/m_g_key.mdl");
- body_model ("progs/m_g_key.mdl");
+ precache_body_model (e, "progs/m_g_key.mdl");
+ body_model (e, "progs/m_g_key.mdl");
}
else if (world.worldtype == WORLDTYPE_BASE)
{
- precache_body_model2 ("progs/b_g_key.mdl");
- body_model ("progs/b_g_key.mdl");
+ precache_body_model2 (e, "progs/b_g_key.mdl");
+ body_model (e, "progs/b_g_key.mdl");
}

- if (this.keyname != "")
- this.keyname = "";
+ if (e.keyname != "")
+ e.keyname = "";
else
- this.netname = gold_key_name ();
+ e.netname = base_item_key_goldname ();

- this.items = IT_KEY2;
+ e.items = IT_KEY2;

// support for item_key_custom -- iw
- this.customkeys = 0; // ignore any mapper-set value
- this.noise = ""; // ignore any mapper-set value
+ e.customkeys = 0; // ignore any mapper-set value
+ e.noise = ""; // ignore any mapper-set value

// key_start
- super::init_spawned ();
+ base_item_key_init (e);
};

//--------------------------------------------------------------
void() item_key2 =
{
- this.classtype = CT_ITEM_KEY2;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ item_key2_init (self);
};
-};
+// };

//======================================================================
// item_key_custom is a brand-spanking-new entity class created for
@@ -419,43 +552,65 @@ The behavior of an item_key_custom should be as the player expects
that it will not appear as an icon in the player's status bar when
picked up. This is a limitation of the engine.
*/
-class item_key_custom: base_item_key
-{
+//----------------------------------------------------------------------
+// class item_key_custom: base_item_key
+// {
+ //--------------------------------------------------------------
+ entity(entity src, vector org, vector vel, string kname)
+ spawn_item_key_custom =
+ {
+ local entity e = spawn ();
+ e.owner = src;
+ e.origin = org;
+ e.velocity = vel;
+ e.keyname = kname;
+ item_key_custom_init (e);
+ return e;
+ };
+
//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) item_key_custom_init =
{
- if (this.keyname == "")
+ e.classname = "item_key_custom";
+ e.classtype = CT_ITEM_KEY_CUSTOM;
+ e.touch = base_item_key_touch;
+
+ if (e.keyname == "")
{
objerror ("no keyname specified");
return;
}

- if (this.mdl == "")
+ if (e.mdl == "")
{
objerror ("no mdl specified");
return;
}

- precache_model (this.mdl);
- setmodel (this, this.mdl);
+ precache_model (e.mdl);
+ setmodel (e, e.mdl);
// this should not be referenced again
- this.mdl = "";
+ e.mdl = "";

- this.netname = this.keyname;
+ e.netname = e.keyname;
// this should not be referenced again
- this.keyname = "";
+ e.keyname = "";

// ignore any mapper-set value
- this.items = 0;
- this.customkeys = custom_key_flag (this.netname);
+ e.items = 0;
+ e.customkeys = base_item_key_customflag (e.netname);

// key_start
- super::init_spawned ();
+ base_item_key_init (e);
};

//--------------------------------------------------------------
void() item_key_custom =
{
- this.classtype = CT_ITEM_KEY_CUSTOM;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ item_key_custom_init (self);
};
-};
+// };

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

Diff qc/items/powerups.qc

diff --git a/qc/items/powerups.qc b/qc/items/powerups.qc
index 6e5cb4d..937b8ee 100644
--- a/qc/items/powerups.qc
+++ b/qc/items/powerups.qc
@@ -2,21 +2,57 @@
// items/powerups.qc -- POWERUPS
//==============================================================================

+//======================================================================
+// forward declarations
+//======================================================================
+
+// base_item_powerup
+void() base_item_powerup_touch;
+entity(entity src, vector org, vector vel, void(entity) init_fn)
+ spawn_base_item_powerup;
+void(entity e) base_item_powerup_init;
+strip void() base_item_powerup;
+
+// item_artifact_invulnerability
+entity(entity src, vector org, vector vel) spawn_item_artifact_invulnerability;
+void(entity e) item_artifact_invulnerability_init;
+void() item_artifact_invulnerability;
+
+// item_artifact_envirosuit
+entity(entity src, vector org, vector vel) spawn_item_artifact_envirosuit;
+void(entity e) item_artifact_envirosuit_init;
+void() item_artifact_envirosuit;
+
+// item_artifact_invisibility
+entity(entity src, vector org, vector vel) spawn_item_artifact_invisibility;
+void(entity e) item_artifact_invisibility_init;
+void() item_artifact_invisibility;
+
+// item_artifact_super_damage
+entity(entity src, vector org, vector vel) spawn_item_artifact_super_damage;
+void(entity e) item_artifact_super_damage_init;
+void() item_artifact_super_damage;
+
//------------------------------------------------------------------------------
-class base_item_powerup: base_item
-{
+
+//----------------------------------------------------------------------
+// class base_item_powerup: base_item
+// {
//--------------------------------------------------------------
- virtual void(entity toucher) do_touch =
+ void() base_item_powerup_touch =
{
+ if (sub_checkvalidtouch(other) == FALSE)
+ return;
+
local float delay_sp = 0;
local float delay_dm = 0;

- sprint (toucher, sprintf("You got the %s\n", this.netname));
+ sprint (other, sprintf("You got the %s\n", self.netname));

if (!deathmatch)
{
- if (this.classtype == CT_ITEM_INVULNERABILITY ||
- this.classtype == CT_ITEM_INVISIBILITY)
+ if (self.classtype == CT_ITEM_INVULNERABILITY ||
+ self.classtype == CT_ITEM_INVISIBILITY)
{
delay_sp = 300;
}
@@ -27,8 +63,8 @@ class base_item_powerup: base_item
}
else
{
- if ((this.classtype == CT_ITEM_INVULNERABILITY) ||
- (this.classtype == CT_ITEM_INVISIBILITY))
+ if ((self.classtype == CT_ITEM_INVULNERABILITY) ||
+ (self.classtype == CT_ITEM_INVISIBILITY))
{
delay_dm = time + 60 * 5;
}
@@ -38,201 +74,284 @@ class base_item_powerup: base_item
}
}

- sound (toucher, CHAN_VOICE, this.noise, 1, ATTN_NORM);
- stuffcmd (toucher, "bf\n");
- toucher.items = toucher.items | this.items;
+ sound (other, CHAN_VOICE, self.noise, 1, ATTN_NORM);
+ stuffcmd (other, "bf\n");
+ other.items = other.items | self.items;

// do the apropriate action
- if (this.classtype == CT_ITEM_ENVIROSUIT)
+ if (self.classtype == CT_ITEM_ENVIROSUIT)
{
- toucher.rad_time = 1;
- toucher.radsuit_finished = time + 30;
+ other.rad_time = 1;
+ other.radsuit_finished = time + 30;
}

- if (this.classtype == CT_ITEM_INVULNERABILITY)
+ if (self.classtype == CT_ITEM_INVULNERABILITY)
{
- toucher.invincible_time = 1;
- toucher.invincible_finished = time + 30;
+ other.invincible_time = 1;
+ other.invincible_finished = time + 30;
}
- else if (this.classtype == CT_ITEM_INVISIBILITY)
+ else if (self.classtype == CT_ITEM_INVISIBILITY)
{
- toucher.invisible_time = 1;
- toucher.invisible_finished = time + 30;
+ other.invisible_time = 1;
+ other.invisible_finished = time + 30;
}
- else if (this.classtype == CT_ITEM_QUAD)
+ else if (self.classtype == CT_ITEM_QUAD)
{
- toucher.super_time = 1;
- toucher.super_damage_finished = time + 30;
+ other.super_time = 1;
+ other.super_damage_finished = time + 30;
}

// remove it in single player, or setup for respawning in DM
// Supa, SP respawning items support
- this.mdl = this.model;
- this.solid = SOLID_NOT;
- this.model = string_null;
- check_respawn (this, delay_sp, delay_dm);
+ self.mdl = self.model;
+ self.solid = SOLID_NOT;
+ self.model = __NULL__;
+ base_item_check_respawn (self, delay_sp, delay_dm);

- activator = toucher;
+ activator = other;
// fire all targets / killtargets
sub_usetargets ();
};

//--------------------------------------------------------------
- void() base_item_powerup =
+ entity(entity src, vector org, vector vel, void(entity) init_fn)
+ spawn_base_item_powerup =
+ {
+ local entity e = spawn ();
+ e.owner = src;
+ e.origin = org;
+ e.velocity = vel;
+ init_fn (e);
+ return e;
+ };
+
+ //--------------------------------------------------------------
+ void(entity e) base_item_powerup_init =
+ {
+ self.classgroup |= CG_ITEM_POWERUP;
+ self.touch = base_item_powerup_touch;
+ base_item_init (e);
+ };
+
+ //--------------------------------------------------------------
+ strip void() base_item_powerup =
{
- this.classgroup |= CG_ITEM_POWERUP;
+ base_item_powerup_init (self);
};
-};
+// };

/*QUAKED item_artifact_invulnerability (0 .5 .8) (-16 -16 -24) (16 16 32) X X X X X SPAWN_SILENT TRIGGER_SPAWNED SUSPENDED_IN_AIR NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER RESPAWN_WITH_DM_EFFECTS NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
{ model("progs/invulner.mdl"); }
Pentagram of Protection
Player is invulnerable for 30 seconds
*/
-class item_artifact_invulnerability: base_item_powerup
-{
+//----------------------------------------------------------------------
+// class item_artifact_invulnerability: base_item_powerup
+// {
+ //--------------------------------------------------------------
+ entity(entity src, vector org, vector vel)
+ spawn_item_artifact_invulnerability =
+ {
+ return spawn_base_item_powerup (src, org, vel,
+ item_artifact_invulnerability_init);
+ };
+
//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) item_artifact_invulnerability_init =
{
- // precache_model ("progs/invulner.mdl");
- precache_body_model ("progs/invulner.mdl");
+ e.classname = "item_artifact_invulnerability";
+ e.classtype = CT_ITEM_INVULNERABILITY;
+
+ precache_body_model (e, "progs/invulner.mdl");
precache_sound ("items/protect.wav");
// called in client.qc -- dumptruck_ds
precache_sound ("items/protect2.wav");
// called in combat.qc -- dumptruck_ds
precache_sound ("items/protect3.wav");
- this.noise = "items/protect.wav";
+ e.noise = "items/protect.wav";
// setmodel (this, "progs/invulner.mdl");
- body_model ("progs/invulner.mdl");
- this.netname = "Pentagram of Protection";
- this.items = IT_INVULNERABILITY;
- this.size_min = '-16 -16 -24';
- this.size_max = '16 16 32';
+ body_model (e, "progs/invulner.mdl");
+ e.netname = "Pentagram of Protection";
+ e.items = IT_INVULNERABILITY;
+ e.pos1 = '-16 -16 -24';
+ e.pos2 = '16 16 32';

// t_fog fix for custom models dumptruck_ds
- if !(this.particles_offset)
- this.particles_offset = '0 0 16';
+ if !(e.particles_offset)
+ e.particles_offset = '0 0 16';

// StartItem
- super::init_spawned ();
+ base_item_powerup_init (e);
};

//--------------------------------------------------------------
void() item_artifact_invulnerability =
{
- this.classtype = CT_ITEM_INVULNERABILITY;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ item_artifact_invulnerability_init (self);
};
-};
+// };

/*QUAKED item_artifact_envirosuit (0 .5 .8) (-16 -16 -24) (16 16 32) X X X X X SPAWN_SILENT TRIGGER_SPAWNED SUSPENDED_IN_AIR NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER RESPAWN_WITH_DM_EFFECTS NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
{ model("progs/suit.mdl"); }
Biosuit
Player takes no damage from water or slime for 30 seconds
*/
-class item_artifact_envirosuit: base_item_powerup
-{
+//----------------------------------------------------------------------
+// class item_artifact_envirosuit: base_item_powerup
+// {
+ //--------------------------------------------------------------
+ entity(entity src, vector org, vector vel)
+ spawn_item_artifact_envirosuit =
+ {
+ return spawn_base_item_powerup (src, org, vel,
+ item_artifact_envirosuit_init);
+ };
+
//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) item_artifact_envirosuit_init =
{
- precache_body_model ("progs/suit.mdl");
+ e.classname = "item_artifact_envirosuit";
+ e.classtype = CT_ITEM_ENVIROSUIT;
+
+ precache_body_model (e, "progs/suit.mdl");
precache_sound ("items/suit.wav");
precache_sound ("items/suit2.wav");
- this.noise = "items/suit.wav";
+ e.noise = "items/suit.wav";
// setmodel (this, "progs/suit.mdl");
- body_model ("progs/suit.mdl");
- this.netname = "Biosuit";
- this.items = IT_SUIT;
- this.size_min = '-16 -16 -24';
- this.size_max = '16 16 32';
+ body_model (e, "progs/suit.mdl");
+ e.netname = "Biosuit";
+ e.items = IT_SUIT;
+ e.pos1 = '-16 -16 -24';
+ e.pos2 = '16 16 32';

// t_fog fix for custom models dumptruck_ds
- if !(this.particles_offset)
- this.particles_offset = '0 0 32';
+ if !(e.particles_offset)
+ e.particles_offset = '0 0 32';

// StartItem
- super::init_spawned ();
+ base_item_powerup_init (e);
};

//--------------------------------------------------------------
void() item_artifact_envirosuit =
{
- this.classtype = CT_ITEM_ENVIROSUIT;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ item_artifact_envirosuit_init (self);
};
-};
+// };

/*QUAKED item_artifact_invisibility (0 .5 .8) (-16 -16 -24) (16 16 32) X X X X X SPAWN_SILENT TRIGGER_SPAWNED SUSPENDED_IN_AIR NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER RESPAWN_WITH_DM_EFFECTS NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
{ model("progs/invisibl.mdl"); }
Ring of Shadows
Player is invisible for 30 seconds
*/
-class item_artifact_invisibility: base_item_powerup
-{
+//----------------------------------------------------------------------
+// class item_artifact_invisibility: base_item_powerup
+// {
+ //--------------------------------------------------------------
+ entity(entity src, vector org, vector vel)
+ spawn_item_artifact_invisibility =
+ {
+ return spawn_base_item_powerup (src, org, vel,
+ item_artifact_invisibility_init);
+ };
+
//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) item_artifact_invisibility_init =
{
- precache_body_model ("progs/invisibl.mdl");
+ e.classname = "item_artifact_invisibility";
+ e.classtype = CT_ITEM_INVISIBILITY;
+
+ precache_body_model (e, "progs/invisibl.mdl");
precache_sound ("items/inv1.wav");
precache_sound ("items/inv2.wav");
precache_sound ("items/inv3.wav");
- this.noise = "items/inv1.wav";
+ e.noise = "items/inv1.wav";
// setmodel (this, "progs/invisibl.mdl");
- body_model ("progs/invisibl.mdl");
- this.netname = "Ring of Shadows";
- this.items = IT_INVISIBILITY;
- this.size_min = '-16 -16 -24';
- this.size_max = '16 16 32';
+ body_model (e, "progs/invisibl.mdl");
+ e.netname = "Ring of Shadows";
+ e.items = IT_INVISIBILITY;
+ e.pos1 = '-16 -16 -24';
+ e.pos2 = '16 16 32';

// t_fog fix for custom models dumptruck_ds
- if !(this.particles_offset)
- this.particles_offset = '0 0 0';
+ if !(e.particles_offset)
+ e.particles_offset = '0 0 0';

// StartItem
- super::init_spawned ();
+ base_item_powerup_init (e);
};

//--------------------------------------------------------------
void() item_artifact_invisibility =
{
- this.classtype = CT_ITEM_INVISIBILITY;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ item_artifact_invisibility_init (self);
};
-};
+// };

/*QUAKED item_artifact_super_damage (0 .5 .8) (-16 -16 -24) (16 16 32) X X X X X SPAWN_SILENT TRIGGER_SPAWNED SUSPENDED_IN_AIR NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER RESPAWN_WITH_DM_EFFECTS NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
{ model("progs/quaddama.mdl"); }
Quad Damage
Player does 4x damage for 30 seconds
*/
-class item_artifact_super_damage: base_item_powerup
-{
+//----------------------------------------------------------------------
+// class item_artifact_super_damage: base_item_powerup
+// {
+ //--------------------------------------------------------------
+ entity(entity src, vector org, vector vel)
+ spawn_item_artifact_super_damage =
+ {
+ return spawn_base_item_powerup (src, org, vel,
+ item_artifact_super_damage_init);
+ };
+
//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) item_artifact_super_damage_init =
{
- precache_body_model ("progs/quaddama.mdl");
+ e.classname = "item_artifact_super_damage";
+ e.classtype = CT_ITEM_QUAD;
+
+ precache_body_model (e, "progs/quaddama.mdl");
precache_sound ("items/damage.wav");
precache_sound ("items/damage3.wav");
- this.noise = "items/damage.wav";
+ e.noise = "items/damage.wav";
// setmodel (this, "progs/quaddama.mdl");
- body_model ("progs/quaddama.mdl");
+ body_model (e, "progs/quaddama.mdl");

// custom name -- dumptruck_ds
- if !(this.netname)
- this.netname = "Quad Damage";
+ if !(e.netname)
+ e.netname = "Quad Damage";

- this.items = IT_QUAD;
- this.size_min = '-16 -16 -24';
- this.size_max = '16 16 32';
+ e.items = IT_QUAD;
+ e.pos1 = '-16 -16 -24';
+ e.pos2 = '16 16 32';

// t_fog fix for custom models dumptruck_ds
- if !(this.particles_offset)
- this.particles_offset = '0 0 16';
+ if !(e.particles_offset)
+ e.particles_offset = '0 0 16';

// StartItem
- super::init_spawned ();
+ base_item_powerup_init (e);
};

//--------------------------------------------------------------
void() item_artifact_super_damage =
{
- this.classtype = CT_ITEM_QUAD;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ item_artifact_super_damage_init (self);
};
-};
+// };

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

Diff qc/items/runes.qc

diff --git a/qc/items/runes.qc b/qc/items/runes.qc
index 1ff2f92..ec3409a 100644
--- a/qc/items/runes.qc
+++ b/qc/items/runes.qc
@@ -2,121 +2,144 @@
// END OF LEVEL RUNES
//==============================================================================

+//======================================================================
+// forward declarations
+//======================================================================
+
+void() item_sigil_touch2;
+void() item_sigil_touch;
+entity(entity src, vector org, vector vel, float flags) spawn_item_sigil;
+void(entity e) item_sigil_init;
+void() item_sigil;
+
//------------------------------------------------------------------------------
-class base_item_rune: base_item
+
+/*QUAKED item_sigil (0 .5 .8) (-16 -16 -24) (16 16 32) E1 E2 E3 E4 X SPAWN_SILENT TRIGGER_SPAWNED SUSPENDED_IN_AIR NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
{
+ model ( {{ spawnflags & 1 -> { "path" : "progs/end1.mdl" }, spawnflags & 2 -> { "path" : "progs/end2.mdl" },
+ spawnflags & 4 -> { "path" : "progs/end3.mdl" }, spawnflags & 8 -> { "path" : "progs/end4.mdl" },
+ "progs/end1.mdl" }} );
+}
+End of episode rune. Use in conjuction with func_bossgate and func_episodegate.
+Spawnflag must be set to the appropriate episode.
+Episode 1 - Dimension of the Doomed - Rune of Earth Magic
+Episode 2 - The Realm of Black Magic - Rune of Black Magic
+Episode 3 - The Netherworld - Rune of Hell Magic
+Episode 4 - The Elder World - Run of Elder Magic
+*/
+//----------------------------------------------------------------------
+// class item_sigil: base_item
+// {
//--------------------------------------------------------------
// sigil_touch2 -- replacement for Skill Select Rune hack
// uses info_player_start2 if spawnflag 16 -- dumptruck_ds
//--------------------------------------------------------------
- static void(base_mapentity bme, entity toucher) sigil_touch2 =
+ void() item_sigil_touch2 =
{
- if (toucher.classtype != CT_PLAYER)
+ if (other.classtype != CT_PLAYER)
return;
- if (toucher.health <= 0)
+ if (other.health <= 0)
return;

// centerprint (other, "You got the rune!");

// sound (other, CHAN_ITEM, this.noise, 1, ATTN_NORM);
// stuffcmd (other, "bf\n");
- bme.solid = SOLID_NOT;
- bme.model = string_null;
- serverflags = serverflags | (bme.spawnflags & 16);
+ self.solid = SOLID_NOT;
+ self.model = __NULL__;
+ serverflags = serverflags | (self.spawnflags & 16);
// so rune doors won't find it
- bme.classname = "";
+ self.classname = "";

- activator = toucher;
+ activator = other;
// fire all targets / killtargets
// sub_usetargets ();
};

//--------------------------------------------------------------
- virtual void(entity toucher) do_touch =
+ void() item_sigil_touch =
{
- centerprint (toucher, "You got the rune!");
+ centerprint (other, "You got the rune!");

- sound (toucher, CHAN_ITEM, this.noise, 1, ATTN_NORM);
- stuffcmd (toucher, "bf\n");
- this.solid = SOLID_NOT;
- this.model = string_null;
- serverflags = serverflags | (this.spawnflags & 15);
+ sound (other, CHAN_ITEM, self.noise, 1, ATTN_NORM);
+ stuffcmd (other, "bf\n");
+ self.solid = SOLID_NOT;
+ self.model = __NULL__;
+ serverflags = serverflags | (self.spawnflags & 15);
// so rune doors won't find it
- this.classname = "";
+ self.classname = "";

- activator = toucher;
+ activator = other;
// fire all targets / killtargets
sub_usetargets ();
};

//--------------------------------------------------------------
- void() base_item_rune =
+ entity(entity src, vector org, vector vel, float flags)
+ spawn_item_sigil =
{
- // not enough subclasses for this to be necessary -- CEV
- // this.classgroup |= CG_ITEM_RUNE;
+ local entity e = spawn ();
+ e.owner = src;
+ e.origin = org;
+ e.velocity = vel;
+ e.spawnflags = flags;
+ item_sigil_init (e);
+ return e;
};
-};

-/*QUAKED item_sigil (0 .5 .8) (-16 -16 -24) (16 16 32) E1 E2 E3 E4 X SPAWN_SILENT TRIGGER_SPAWNED SUSPENDED_IN_AIR NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
-{
- model ( {{ spawnflags & 1 -> { "path" : "progs/end1.mdl" }, spawnflags & 2 -> { "path" : "progs/end2.mdl" },
- spawnflags & 4 -> { "path" : "progs/end3.mdl" }, spawnflags & 8 -> { "path" : "progs/end4.mdl" },
- "progs/end1.mdl" }} );
-}
-End of episode rune. Use in conjuction with func_bossgate and func_episodegate.
-Spawnflag must be set to the appropriate episode.
-Episode 1 - Dimension of the Doomed - Rune of Earth Magic
-Episode 2 - The Realm of Black Magic - Rune of Black Magic
-Episode 3 - The Netherworld - Rune of Hell Magic
-Episode 4 - The Elder World - Run of Elder Magic
-*/
-class item_sigil: base_item_rune
-{
//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) item_sigil_init =
{
- if (!this.spawnflags)
+ e.classname = "item_sigil";
+ e.classtype = CT_ITEM_RUNE;
+ e.touch = item_sigil_touch;
+
+ if (!e.spawnflags)
objerror ("no spawnflags");

precache_sound ("misc/runekey.wav");
- this.noise = "misc/runekey.wav";
+ e.noise = "misc/runekey.wav";

- if (this.spawnflags & 1)
+ if (e.spawnflags & 1)
{
precache_model ("progs/end1.mdl");
- setmodel (this, "progs/end1.mdl");
+ setmodel (e, "progs/end1.mdl");
}

- if (this.spawnflags & 2)
+ if (e.spawnflags & 2)
{
precache_model2 ("progs/end2.mdl");
- setmodel (this, "progs/end2.mdl");
+ setmodel (e, "progs/end2.mdl");
}

- if (this.spawnflags & 4)
+ if (e.spawnflags & 4)
{
precache_model2 ("progs/end3.mdl");
- setmodel (this, "progs/end3.mdl");
+ setmodel (e, "progs/end3.mdl");
}

- if (this.spawnflags & 8)
+ if (e.spawnflags & 8)
{
precache_model2 ("progs/end4.mdl");
- setmodel (this, "progs/end4.mdl");
+ setmodel (e, "progs/end4.mdl");
}

- this.size_min = '-16 -16 -24';
- this.size_max = '16 16 32';
+ e.pos1 = '-16 -16 -24';
+ e.pos2 = '16 16 32';

- this.particles_offset = '0 0 18';
+ e.particles_offset = '0 0 18';

// StartItem
- super::init_spawned ();
+ base_item_init (e);
};

//--------------------------------------------------------------
void() item_sigil =
{
- this.classtype = CT_ITEM_RUNE;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ item_sigil_init (self);
};
-};
+// };

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

Diff qc/items/weapons.qc

diff --git a/qc/items/weapons.qc b/qc/items/weapons.qc
index 51ed261..b0cc0a6 100644
--- a/qc/items/weapons.qc
+++ b/qc/items/weapons.qc
@@ -2,7 +2,10 @@
// items/weapons.qc -- weapons
//==============================================================================

+//======================================================================
// constants
+//======================================================================
+
const float AMMO_CELLS_WP = 15; // cells on weapon pickup; id1 15
const float AMMO_NAILS_WP = 30; // nails on weapon pickup; id1 30
const float AMMO_ROCKETS_WP = 5; // rockets on weapon pickup; id1 5
@@ -10,25 +13,83 @@ const float AMMO_SHELLS_WP = 5; // shells on weapon pickup; id1 5

const float WEAPON_RESPAWN_TIME = 30; // as the name suggests; id1 30

+//======================================================================
+// forward declarations
+//======================================================================
+
+void(entity e) bound_entity_ammo;
+float(entity e, float w) rank_for_weapon;
+void(entity e, float old, float new) deathmatch_weapon;
+
+// base_item_weapon
+void() base_item_weapon_touch;
+entity(entity src, vector org, vector vel, void(entity) init_fn)
+ spawn_base_item_weapon;
+void(entity e) base_item_weapon_init;
+strip void() base_item_weapon;
+
+// weapon_axe
+entity(entity src, vector org, vector vel) spawn_weapon_axe;
+void(entity e) weapon_axe_init;
+void() weapon_axe;
+
+// weapon_shotgun
+entity(entity src, vector org, vector vel) spawn_weapon_shotgun;
+void(entity e) weapon_shotgun_init;
+void() weapon_shotgun;
+
+// weapon_supershotgun
+entity(entity src, vector org, vector vel) spawn_weapon_supershotgun;
+void(entity e) weapon_supershotgun_init;
+void() weapon_supershotgun;
+
+// weapon_nailgun
+entity(entity src, vector org, vector vel) spawn_weapon_nailgun;
+void(entity e) weapon_nailgun_init;
+void() weapon_nailgun;
+
+// weapon_supernailgun
+entity(entity src, vector org, vector vel) spawn_weapon_supernailgun;
+void(entity e) weapon_supernailgun_init;
+void() weapon_supernailgun;
+
+// weapon_grenadelauncher
+entity(entity src, vector org, vector vel) spawn_weapon_grenadelauncher;
+void(entity e) weapon_grenadelauncher_init;
+void() weapon_grenadelauncher;
+
+// weapon_rocketlauncher
+entity(entity src, vector org, vector vel) spawn_weapon_rocketlauncher;
+void(entity e) weapon_rocketlauncher_init;
+void() weapon_rocketlauncher;
+
+// weapon_lightning
+void(vector p1, vector p2, entity from, float damage) fire_lightning;
+entity(entity src, vector org, vector vel) spawn_weapon_lightning;
+void(entity e) weapon_lightning_init;
+void() weapon_lightning;
+
+//------------------------------------------------------------------------------
+
//----------------------------------------------------------------------
-void() bound_other_ammo =
+void(entity e) bound_entity_ammo =
{
// these constants are defined in items/ammo.qc -- CEV
- if (other.ammo_shells > AMMO_SHELLS_MAX)
- other.ammo_shells = AMMO_SHELLS_MAX;
- if (other.ammo_nails > AMMO_NAILS_MAX)
- other.ammo_nails = AMMO_NAILS_MAX;
- if (other.ammo_rockets > AMMO_ROCKETS_MAX)
- other.ammo_rockets = AMMO_ROCKETS_MAX;
- if (other.ammo_cells > AMMO_CELLS_MAX)
- other.ammo_cells = AMMO_CELLS_MAX;
+ if (e.ammo_shells > AMMO_SHELLS_MAX)
+ e.ammo_shells = AMMO_SHELLS_MAX;
+ if (e.ammo_nails > AMMO_NAILS_MAX)
+ e.ammo_nails = AMMO_NAILS_MAX;
+ if (e.ammo_rockets > AMMO_ROCKETS_MAX)
+ e.ammo_rockets = AMMO_ROCKETS_MAX;
+ if (e.ammo_cells > AMMO_CELLS_MAX)
+ e.ammo_cells = AMMO_CELLS_MAX;
};

//----------------------------------------------------------------------
-float(float w) RankForWeapon =
+float(entity e, float w) rank_for_weapon =
{
// 1997-12-23 Thunderbolt fix by Maddes recognize waterlevel
- if (self.waterlevel <= WATERLEVEL_FEET && w == IT_LIGHTNING)
+ if (e.waterlevel <= WATERLEVEL_FEET && w == IT_LIGHTNING)
return 1;
if (w == IT_ROCKET_LAUNCHER)
return 2;
@@ -46,50 +107,43 @@ float(float w) RankForWeapon =
};

//----------------------------------------------------------------------
-// Deathmatch_Weapon -- Deathmatch weapon change rules for picking up a weapon
+// deathmatch_weapon -- DM weapon change rules for picking up a weapon
//----------------------------------------------------------------------
-void(float old, float new) Deathmatch_Weapon =
+void(entity e, float old, float new) deathmatch_weapon =
{
local float or, nr;

// change self.weapon if desired
- or = RankForWeapon (self.weapon);
- nr = RankForWeapon (new);
+ or = rank_for_weapon (e, e.weapon);
+ nr = rank_for_weapon (e, new);
if (nr < or)
- self.weapon = new;
+ e.weapon = new;
};

-void(entity doas, float old, float new) REMOVEME_CallAsSelf_DeathmatchWeapon =
-{
- local entity stemp;
-
- stemp = self;
- self = doas;
- Deathmatch_Weapon (old, new);
- self = stemp;
-};
-
-//------------------------------------------------------------------------------
-class base_item_weapon: base_item
-{
+//----------------------------------------------------------------------
+// class base_item_weapon: base_item
+// {
//--------------------------------------------------------------
// weapon_touch
//--------------------------------------------------------------
- virtual void(entity toucher) do_touch =
+ void() base_item_weapon_touch =
{
local float hadammo, best, new, old;
local entity stemp;
local float leave;

- if (!(toucher.flags & FL_CLIENT))
+ if (sub_checkvalidtouch(other) == FALSE)
+ return;
+
+ if (!(other.flags & FL_CLIENT))
return;

// if the player was using his best weapon, change up to the
// new one if better
- if (toucher.classtype == CT_PLAYER &&
+ if (other.classtype == CT_PLAYER &&
autocvar(cg_autoswitch, TRUE))
{
- best = ((player)toucher).best_weapon ();
+ best = sub_runfloatas (other, player_best_weapon);
}

if (deathmatch == 2 || coop)
@@ -97,7 +151,7 @@ class base_item_weapon: base_item
leave = 1;
// fix weapon items never firing their targets in coop or
// "deathmatch 2" -- iw
- activator = toucher;
+ activator = other;
sub_useandforgettargets ();
}
else
@@ -107,88 +161,87 @@ class base_item_weapon: base_item

// johnfitz added for axe, shotgun items
// -- dumptruck_ds from RRP / rubicon2
- if (this.classtype == CT_ITEM_AXE)
+ if (self.classtype == CT_ITEM_AXE)
{
- if (leave && (toucher.items & IT_AXE))
+ if (leave && (other.items & IT_AXE))
return;
new = IT_AXE;
}
- else if (this.classtype == CT_ITEM_SHOTGUN)
+ else if (self.classtype == CT_ITEM_SHOTGUN)
{
- if (leave && (toucher.items & IT_SHOTGUN))
+ if (leave && (other.items & IT_SHOTGUN))
return;
- hadammo = toucher.ammo_shells;
+ hadammo = other.ammo_shells;
new = IT_SHOTGUN;
- toucher.ammo_shells += AMMO_SHELLS_WP;
+ other.ammo_shells += AMMO_SHELLS_WP;
}
- else if (this.classtype == CT_ITEM_NAILGUN)
+ else if (self.classtype == CT_ITEM_NAILGUN)
{
// johnfitz
- if (leave && (toucher.items & IT_NAILGUN))
+ if (leave && (other.items & IT_NAILGUN))
return;
- hadammo = toucher.ammo_nails;
+ hadammo = other.ammo_nails;
new = IT_NAILGUN;
- toucher.ammo_nails += AMMO_NAILS_WP;
+ other.ammo_nails += AMMO_NAILS_WP;
}
- else if (this.classtype == CT_ITEM_SUPER_NAILGUN)
+ else if (self.classtype == CT_ITEM_SUPER_NAILGUN)
{
- if (leave && (toucher.items & IT_SUPER_NAILGUN))
+ if (leave && (other.items & IT_SUPER_NAILGUN))
return;
- hadammo = toucher.ammo_rockets;
+ hadammo = other.ammo_rockets;
new = IT_SUPER_NAILGUN;
- toucher.ammo_nails += AMMO_NAILS_WP;
+ other.ammo_nails += AMMO_NAILS_WP;
}
- else if (this.classtype == CT_ITEM_SUPER_SHOTGUN)
+ else if (self.classtype == CT_ITEM_SUPER_SHOTGUN)
{
- if (leave && (toucher.items & IT_SUPER_SHOTGUN))
+ if (leave && (other.items & IT_SUPER_SHOTGUN))
return;
- hadammo = toucher.ammo_rockets;
+ hadammo = other.ammo_rockets;
new = IT_SUPER_SHOTGUN;
- toucher.ammo_shells += AMMO_SHELLS_WP;
+ other.ammo_shells += AMMO_SHELLS_WP;
}
- else if (this.classtype == CT_ITEM_ROCKET_LAUNCHER)
+ else if (self.classtype == CT_ITEM_ROCKET_LAUNCHER)
{
- if (leave && (toucher.items & IT_ROCKET_LAUNCHER))
+ if (leave && (other.items & IT_ROCKET_LAUNCHER))
return;
- hadammo = toucher.ammo_rockets;
+ hadammo = other.ammo_rockets;
new = IT_ROCKET_LAUNCHER;
- toucher.ammo_rockets += AMMO_ROCKETS_WP;
+ other.ammo_rockets += AMMO_ROCKETS_WP;
}
- else if (this.classtype == CT_ITEM_GRENADE_LAUNCHER)
+ else if (self.classtype == CT_ITEM_GRENADE_LAUNCHER)
{
- if (leave && (toucher.items & IT_GRENADE_LAUNCHER))
+ if (leave && (other.items & IT_GRENADE_LAUNCHER))
return;
- hadammo = toucher.ammo_rockets;
+ hadammo = other.ammo_rockets;
new = IT_GRENADE_LAUNCHER;
- toucher.ammo_rockets += AMMO_ROCKETS_WP;
+ other.ammo_rockets += AMMO_ROCKETS_WP;
}
- else if (this.classtype == CT_ITEM_LIGHTNING_GUN)
+ else if (self.classtype == CT_ITEM_LIGHTNING_GUN)
{
- if (leave && (toucher.items & IT_LIGHTNING))
+ if (leave && (other.items & IT_LIGHTNING))
return;
- hadammo = toucher.ammo_rockets;
+ hadammo = other.ammo_rockets;
new = IT_LIGHTNING;
- toucher.ammo_cells += AMMO_CELLS_WP;
+ other.ammo_cells += AMMO_CELLS_WP;
}
else
{
- objerror ("base_item_weapon::do_touch: "
- "unknown classtype");
+ objerror ("base_item_weapon_touch: unknown classtype");
return;
}

- sprint (toucher, sprintf("You got the %s\n", this.netname));
+ sprint (other, sprintf("You got the %s\n", self.netname));
// weapon touch sound
- sound (toucher, CHAN_ITEM, "weapons/pkup.wav", 1, ATTN_NORM);
- stuffcmd (toucher, "bf\n");
+ sound (other, CHAN_ITEM, "weapons/pkup.wav", 1, ATTN_NORM);
+ stuffcmd (other, "bf\n");

- bound_other_ammo ();
+ bound_entity_ammo (other);

// change to the weapon
- old = toucher.items;
- toucher.items = toucher.items | new;
+ old = other.items;
+ other.items = other.items | new;

- if (toucher.classtype == CT_PLAYER &&
+ if (other.classtype == CT_PLAYER &&
autocvar(cg_autoswitch, TRUE))
{
// 1997-12-23 Thunderbolt fix by Maddes start
@@ -196,12 +249,12 @@ class base_item_weapon: base_item
// don't separate between SinglePlayer/Coop
// and Deathmatch
if (!deathmatch)
- this.weapon = new;
+ self.weapon = new;
else
*/
// 1997-12-23 Thunderbolt fix by Maddes end
- REMOVEME_CallAsSelf_DeathmatchWeapon (toucher, old, new);
- ((player)toucher).set_current_ammo ();
+ deathmatch_weapon (other, old, new);
+ sub_runvoidas (other, player_set_current_ammo);
}

if (leave)
@@ -209,57 +262,92 @@ class base_item_weapon: base_item

// remove it in single player, or setup for respawning
// in deathmatch
- this.model = string_null;
- this.solid = SOLID_NOT;
+ self.model = __NULL__;
+ self.solid = SOLID_NOT;
// Supa, SP respawning items support
- check_respawn (this, WEAPON_RESPAWN_TIME, WEAPON_RESPAWN_TIME);
+ base_item_check_respawn (self,
+ WEAPON_RESPAWN_TIME, WEAPON_RESPAWN_TIME);

- activator = toucher;
+ activator = other;
// fire all targets / killtargets
sub_usetargets ();
};

//--------------------------------------------------------------
- void() base_item_weapon =
+ entity(entity src, vector org, vector vel, void(entity) init_fn)
+ spawn_base_item_weapon =
{
- this.classgroup |= CG_ITEM_WEAPON;
+ local entity e = spawn ();
+ e.owner = src;
+ e.origin = org;
+ e.velocity = vel;
+ init_fn (e);
+ return e;
};
-};

-//=======================================================================
+ //--------------------------------------------------------------
+ void(entity e) base_item_weapon_init =
+ {
+ e.classgroup |= CG_ITEM_WEAPON;
+ e.touch = base_item_weapon_touch;
+ base_item_init (e);
+ };
+
+ //--------------------------------------------------------------
+ strip void() base_item_weapon =
+ {
+ base_item_weapon_init (self);
+ };
+// };
+
+//======================================================================
// Weapon 1: Ranger's Axe -- johnfitz -- dumptruck_ds from RRP and rubicon2
-//=======================================================================
+//======================================================================

/*QUAKED weapon_axe (0 .5 .8) (-16 -16 0) (16 16 32)
Axe
*/
-class weapon_axe: base_item_weapon
-{
+//----------------------------------------------------------------------
+// class weapon_axe: base_item_weapon
+// {
//--------------------------------------------------------------
- virtual void() init_spawned =
+ entity(entity src, vector org, vector vel) spawn_weapon_axe =
{
+ return spawn_base_item_weapon (src, org, vel, weapon_axe_init);
+ };
+
+ //--------------------------------------------------------------
+ void(entity e) weapon_axe_init =
+ {
+ e.classname = "weapon_axe";
+ e.classtype = CT_ITEM_AXE;
+
precache_model ("progs/g_axe.mdl");
- setmodel (this, "progs/g_axe.mdl");
- this.weapon = IT_AXE;
- this.netname = "Axe";
+ setmodel (e, "progs/g_axe.mdl");
+ e.weapon = IT_AXE;
+ e.netname = "Axe";

- this.size_min = '-16 -16 0';
- this.size_max = '16 16 56';
+ e.pos1 = '-16 -16 0';
+ e.pos2 = '16 16 56';

// StartItem
- super::init_spawned ();
+ base_item_weapon_init (e);
};

//--------------------------------------------------------------
void() weapon_axe =
{
- this.classtype = CT_ITEM_AXE;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ weapon_axe_init (self);
};
-};
+// };

-//=======================================================================
+//======================================================================
// Weapon 2: Shotgun -- johnfitz -- dumptruck_ds from RRP and rubicon2
-//=======================================================================
+//======================================================================

/*QUAKED weapon_shotgun (0 .5 .8) (-16 -16 0) (16 16 32) X STYLE_1 STYLE_2 X X SPAWN_SILENT TRIGGER_SPAWNED SUSPENDED_IN_AIR NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER RESPAWN_WITH_DM_EFFECTS NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
{ model("progs/g_shotgn.mdl"); }
@@ -267,210 +355,302 @@ This is a pickup model that should be used when you want a player to spawn with
Single-barrelled Shotgun
Shotgun
*/
-class weapon_shotgun: base_item_weapon
-{
+//----------------------------------------------------------------------
+// class weapon_shotgun: base_item_weapon
+// {
+ //--------------------------------------------------------------
+ entity(entity src, vector org, vector vel) spawn_weapon_shotgun =
+ {
+ return spawn_base_item_weapon (src, org, vel,
+ weapon_shotgun_init);
+ };
+
//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) weapon_shotgun_init =
{
+ e.classname = "weapon_shotgun";
+ e.classtype = CT_ITEM_SHOTGUN;
+
precache_model ("progs/g_shotgu.mdl");
// new shotgun model by Starshipwaters
// - dumptruck_ds - removed 2 older shotguns that used spawnflags
- setmodel (this, "progs/g_shotgu.mdl");
- this.weapon = IT_SHOTGUN;
- this.netname = "Shotgun";
- this.size_min = '-16 -16 0';
- this.size_max = '16 16 56';
+ setmodel (e, "progs/g_shotgu.mdl");
+ e.weapon = IT_SHOTGUN;
+ e.netname = "Shotgun";
+ e.pos1 = '-16 -16 0';
+ e.pos2 = '16 16 56';

// StartItem
- super::init_spawned ();
+ base_item_weapon_init (e);
};

//--------------------------------------------------------------
void() weapon_shotgun =
{
- this.classtype = CT_ITEM_SHOTGUN;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ weapon_shotgun_init (self);
};
-};
+// };

-//=======================================================================
+//======================================================================
// Weapon 3: Super Shotgun
-//=======================================================================
+//======================================================================

/*QUAKED weapon_supershotgun (0 .5 .8) (-16 -16 0) (16 16 32) X X X X X SPAWN_SILENT TRIGGER_SPAWNED SUSPENDED_IN_AIR NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER RESPAWN_WITH_DM_EFFECTS NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
{ model("progs/g_shot.mdl"); }
Double-barrelled Shotgun
*/
-class weapon_supershotgun: base_item_weapon
-{
+//----------------------------------------------------------------------
+// class weapon_supershotgun: base_item_weapon
+// {
+ //--------------------------------------------------------------
+ entity(entity src, vector org, vector vel) spawn_weapon_supershotgun =
+ {
+ return spawn_base_item_weapon (src, org, vel,
+ weapon_supershotgun_init);
+ };
+
//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) weapon_supershotgun_init =
{
+ e.classname = "weapon_supershotgun";
+ e.classtype = CT_ITEM_SUPER_SHOTGUN;
+
precache_model ("progs/g_shot.mdl");
- setmodel (this, "progs/g_shot.mdl");
- this.weapon = IT_SUPER_SHOTGUN;
- this.netname = "Double-barrelled Shotgun";
- this.size_min = '-16 -16 0';
- this.size_max = '16 16 56';
+ setmodel (e, "progs/g_shot.mdl");
+ e.weapon = IT_SUPER_SHOTGUN;
+ e.netname = "Double-barrelled Shotgun";
+ e.pos1 = '-16 -16 0';
+ e.pos2 = '16 16 56';

- this.particles_offset = '0 0 33';
+ e.particles_offset = '0 0 33';

// StartItem
- super::init_spawned ();
+ base_item_weapon_init (e);
};

+ //--------------------------------------------------------------
void() weapon_supershotgun =
{
- this.classtype = CT_ITEM_SUPER_SHOTGUN;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ weapon_supershotgun_init (self);
};
-};
+// };

-//=======================================================================
+//======================================================================
// Weapon 4: Nailgun
-//=======================================================================
+//======================================================================

/*QUAKED weapon_nailgun (0 .5 .8) (-16 -16 0) (16 16 32) X X X X X SPAWN_SILENT TRIGGER_SPAWNED SUSPENDED_IN_AIR NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER RESPAWN_WITH_DM_EFFECTS NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
{ model("progs/g_nail.mdl"); }
Nailgun
*/
-class weapon_nailgun: base_item_weapon
-{
+//----------------------------------------------------------------------
+// class weapon_nailgun: base_item_weapon
+// {
//--------------------------------------------------------------
- virtual void() init_spawned =
+ entity(entity src, vector org, vector vel) spawn_weapon_nailgun =
+ {
+ return spawn_base_item_weapon (src, org, vel,
+ weapon_nailgun_init);
+ };
+
+ //--------------------------------------------------------------
+ void(entity e) weapon_nailgun_init =
{
+ e.classname = "weapon_nailgun";
+ e.classtype = CT_ITEM_NAILGUN;
+
precache_model ("progs/g_nail.mdl");
- setmodel (this, "progs/g_nail.mdl");
- this.weapon = IT_NAILGUN;
- this.netname = "nailgun";
- this.size_min = '-16 -16 0';
- this.size_max = '16 16 56';
+ setmodel (e, "progs/g_nail.mdl");
+ e.weapon = IT_NAILGUN;
+ e.netname = "nailgun";
+ e.pos1 = '-16 -16 0';
+ e.pos2 = '16 16 56';

- this.particles_offset = '0 0 31';
+ e.particles_offset = '0 0 31';

// StartItem
- super::init_spawned ();
+ base_item_weapon_init (e);
};

//--------------------------------------------------------------
void() weapon_nailgun =
{
- this.classtype = CT_ITEM_NAILGUN;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ weapon_nailgun_init (self);
};
-};
+// };

-//=======================================================================
+//======================================================================
// Weapon 5: Super Nailgun
-//=======================================================================
+//======================================================================

/*QUAKED weapon_supernailgun (0 .5 .8) (-16 -16 0) (16 16 32) X X X X X SPAWN_SILENT TRIGGER_SPAWNED SUSPENDED_IN_AIR NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER RESPAWN_WITH_DM_EFFECTS NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
{ model("progs/g_nail2.mdl"); }
Perforator
*/
-class weapon_supernailgun: base_item_weapon
-{
+//----------------------------------------------------------------------
+// class weapon_supernailgun: base_item_weapon
+// {
//--------------------------------------------------------------
- virtual void() init_spawned =
+ entity(entity src, vector org, vector vel) spawn_weapon_supernailgun =
{
+ return spawn_base_item_weapon (src, org, vel,
+ weapon_supernailgun_init);
+ };
+
+ //--------------------------------------------------------------
+ void(entity e) weapon_supernailgun_init =
+ {
+ e.classname = "weapon_supernailgun";
+ e.classtype = CT_ITEM_SUPER_NAILGUN;
+
precache_model ("progs/g_nail2.mdl");
- setmodel (this, "progs/g_nail2.mdl");
- this.weapon = IT_SUPER_NAILGUN;
- this.netname = "Super Nailgun";
- this.size_min = '-16 -16 0';
- this.size_max = '16 16 56';
+ setmodel (e, "progs/g_nail2.mdl");
+ e.weapon = IT_SUPER_NAILGUN;
+ e.netname = "Super Nailgun";
+ e.pos1 = '-16 -16 0';
+ e.pos2 = '16 16 56';

- this.particles_offset = '0 0 34';
+ e.particles_offset = '0 0 34';

// StartItem
- super::init_spawned ();
+ base_item_weapon_init (e);
};

//--------------------------------------------------------------
void() weapon_supernailgun =
{
- this.classtype = CT_ITEM_SUPER_NAILGUN;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ weapon_supernailgun_init (self);
};
-};
+// };

-//=======================================================================
+//======================================================================
// Weapon 6: Grenade Launcher
-//=======================================================================
+//======================================================================

/*QUAKED weapon_grenadelauncher (0 .5 .8) (-16 -16 0) (16 16 32) X X X X X SPAWN_SILENT TRIGGER_SPAWNED SUSPENDED_IN_AIR NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER RESPAWN_WITH_DM_EFFECTS NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
{ model("progs/g_rock.mdl"); }
Grenade Launcher
*/
-class weapon_grenadelauncher: base_item_weapon
-{
+//----------------------------------------------------------------------
+// class weapon_grenadelauncher: base_item_weapon
+// {
//--------------------------------------------------------------
- virtual void() init_spawned =
+ entity(entity src, vector org, vector vel)
+ spawn_weapon_grenadelauncher =
{
+ return spawn_base_item_weapon (src, org, vel,
+ weapon_grenadelauncher_init);
+ };
+
+ //--------------------------------------------------------------
+ void(entity e) weapon_grenadelauncher_init =
+ {
+ e.classname = "weapon_grenadelauncher";
+ e.classtype = CT_ITEM_GRENADE_LAUNCHER;
+
precache_model ("progs/g_rock.mdl");
- setmodel (this, "progs/g_rock.mdl");
- this.weapon = 3;
- this.netname = "Grenade Launcher";
- this.size_min = '-16 -16 0';
- this.size_max = '16 16 56';
+ setmodel (e, "progs/g_rock.mdl");
+ e.weapon = 3;
+ e.netname = "Grenade Launcher";
+ e.pos1 = '-16 -16 0';
+ e.pos2 = '16 16 56';

- this.particles_offset = '0 0 28';
+ e.particles_offset = '0 0 28';

// StartItem
- super::init_spawned ();
+ base_item_weapon_init (e);
};

//--------------------------------------------------------------
void() weapon_grenadelauncher =
{
- this.classtype = CT_ITEM_GRENADE_LAUNCHER;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ weapon_grenadelauncher_init (self);
};
-};
+// };

-//=======================================================================
+//======================================================================
// Weapon 7: Rocket Launcher
-//=======================================================================
+//======================================================================

/*QUAKED weapon_rocketlauncher (0 .5 .8) (-16 -16 0) (16 16 32) X X X X X SPAWN_SILENT TRIGGER_SPAWNED SUSPENDED_IN_AIR NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER RESPAWN_WITH_DM_EFFECTS NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
{ model("progs/g_rock2.mdl"); }
Rocket Launcher
*/
-class weapon_rocketlauncher: base_item_weapon
-{
+//----------------------------------------------------------------------
+// class weapon_rocketlauncher: base_item_weapon
+// {
//--------------------------------------------------------------
- virtual void() init_spawned =
+ entity(entity src, vector org, vector vel) spawn_weapon_rocketlauncher =
{
+ return spawn_base_item_weapon (src, org, vel,
+ weapon_rocketlauncher_init);
+ };
+
+ //--------------------------------------------------------------
+ void(entity e) weapon_rocketlauncher_init =
+ {
+ e.classname = "weapon_rocketlauncher";
+ e.classtype = CT_ITEM_ROCKET_LAUNCHER;
+
precache_model ("progs/g_rock2.mdl");
- setmodel (this, "progs/g_rock2.mdl");
- this.weapon = 3;
- this.netname = "Rocket Launcher";
- this.size_min = '-16 -16 0';
- this.size_max = '16 16 56';
+ setmodel (e, "progs/g_rock2.mdl");
+ e.weapon = 3;
+ e.netname = "Rocket Launcher";
+ e.pos1 = '-16 -16 0';
+ e.pos2 = '16 16 56';

- this.particles_offset = '0 0 32';
+ e.particles_offset = '0 0 32';

// StartItem
- super::init_spawned ();
+ base_item_weapon_init (e);
};

//--------------------------------------------------------------
void() weapon_rocketlauncher =
{
- this.classtype = CT_ITEM_ROCKET_LAUNCHER;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ weapon_rocketlauncher_init (self);
};
-};
+// };

-//=======================================================================
+//======================================================================
// Weapon 8: Lightning Gun
-//=======================================================================
+//======================================================================

/*QUAKED weapon_lightning (0 .5 .8) (-16 -16 0) (16 16 32) X X X X X SPAWN_SILENT TRIGGER_SPAWNED SUSPENDED_IN_AIR NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER RESPAWN_WITH_DM_EFFECTS NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
{ model("progs/g_light.mdl"); }
Thunderbolt
*/
-class weapon_lightning: base_item_weapon
-{
+//----------------------------------------------------------------------
+// class weapon_lightning: base_item_weapon
+// {
//--------------------------------------------------------------
// this is here 'cause LG doesn't create a projectile... -- CEV
//--------------------------------------------------------------
- static void(vector p1, vector p2, base_entity from, float damage)
- lightning_damage =
+ void(vector p1, vector p2, entity from, float damage) fire_lightning =
{
local entity e1, e2;
local vector f;
@@ -488,7 +668,7 @@ class weapon_lightning: base_item_weapon
if (trace_ent.takedamage)
{
particle (trace_endpos, '0 0 100', 225, damage * 4);
- from.t_damage2 (trace_ent, from, from, damage);
+ t_damage2 (trace_ent, from, from, damage);
if (from.classtype == CT_PLAYER)
{
if (other.classtype == CT_PLAYER)
@@ -502,7 +682,7 @@ class weapon_lightning: base_item_weapon
if (trace_ent != e1 && trace_ent.takedamage)
{
particle (trace_endpos, '0 0 100', 225, damage * 4);
- from.t_damage2 (trace_ent, from, from, damage);
+ t_damage2 (trace_ent, from, from, damage);
}
e2 = trace_ent;

@@ -510,29 +690,43 @@ class weapon_lightning: base_item_weapon
if (trace_ent != e1 && trace_ent != e2 && trace_ent.takedamage)
{
particle (trace_endpos, '0 0 100', 225, damage * 4);
- from.t_damage2 (trace_ent, from, from, damage);
+ t_damage2 (trace_ent, from, from, damage);
}
};

//--------------------------------------------------------------
- virtual void() init_spawned =
+ entity(entity src, vector org, vector vel) spawn_weapon_lightning =
+ {
+ return spawn_base_item_weapon (src, org, vel,
+ weapon_lightning_init);
+ };
+
+ //--------------------------------------------------------------
+ void(entity e) weapon_lightning_init =
{
+ e.classname = "weapon_lightning";
+ e.classtype = CT_ITEM_LIGHTNING_GUN;
+
precache_model ("progs/g_light.mdl");
- setmodel (this, "progs/g_light.mdl");
- this.weapon = 3;
- this.netname = "Thunderbolt";
- this.size_min = '-16 -16 0';
- this.size_max = '16 16 56';
+ setmodel (e, "progs/g_light.mdl");
+ e.weapon = 3;
+ e.netname = "Thunderbolt";
+ e.pos1 = '-16 -16 0';
+ e.pos2 = '16 16 56';

- this.particles_offset = '0 0 31';
+ e.particles_offset = '0 0 31';

// StartItem
- super::init_spawned ();
+ base_item_weapon_init (e);
};

//--------------------------------------------------------------
void() weapon_lightning =
{
- this.classtype = CT_ITEM_LIGHTNING_GUN;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ weapon_lightning_init (self);
};
-};
+// };

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

Diff qc/keylock.qc

diff --git a/qc/keylock.qc b/qc/keylock.qc
index d39243a..1662d19 100644
--- a/qc/keylock.qc
+++ b/qc/keylock.qc
@@ -36,6 +36,8 @@ calling these functions must not use these fields for other purposes:
========================================================================
*/

+//------------------------------------------------------------------------------
+
/*
------------------------------------------------------------------------
keylock_init
@@ -52,7 +54,7 @@ already been set:
The default values are determined by world.worldtype. -- iw
------------------------------------------------------------------------
*/
-void() keylock_init =
+void(entity e) keylock_init =
{
local string default_noise3;
local string default_noise4;
@@ -73,13 +75,13 @@ void() keylock_init =
default_noise4 = "doors/meduse.wav";
}

- if (self.noise3 == "")
- self.noise3 = default_noise3;
- if (self.noise4 == "")
- self.noise4 = default_noise4;
+ if (e.noise3 == "")
+ e.noise3 = default_noise3;
+ if (e.noise4 == "")
+ e.noise4 = default_noise4;

- precache_sound (self.noise3);
- precache_sound (self.noise4);
+ precache_sound (e.noise3);
+ precache_sound (e.noise4);
};

//----------------------------------------------------------------------
@@ -88,11 +90,11 @@ void() keylock_init =
// Make it so that the player will need to use the silver key in order to
// unlock self. -- iw
//----------------------------------------------------------------------
-void() keylock_set_silver_key =
+void(entity e) keylock_set_silver_key =
{
- self.items = IT_KEY1;
- self.customkeys = 0; // support for item_key_custom -- iw
- self.netname = base_item_key::silver_key_name ();
+ e.items = IT_KEY1;
+ e.customkeys = 0; // support for item_key_custom -- iw
+ e.netname = base_item_key_silvername ();
};

//----------------------------------------------------------------------
@@ -101,12 +103,12 @@ void() keylock_set_silver_key =
// Make it so that the player will need to use the gold key in order to
// unlock self. -- iw
//----------------------------------------------------------------------
-void() keylock_set_gold_key =
+void(entity e) keylock_set_gold_key =
{
- self.items = IT_KEY2;
+ e.items = IT_KEY2;
// support for item_key_custom -- iw
- self.customkeys = 0;
- self.netname = base_item_key::gold_key_name ();
+ e.customkeys = 0;
+ e.netname = base_item_key_goldname ();
};

//----------------------------------------------------------------------
@@ -117,11 +119,11 @@ void() keylock_set_gold_key =
//
// support for item_key_custom -- iw
//----------------------------------------------------------------------
-void(string key_name) keylock_set_custom_key =
+void(entity e, string key_name) keylock_set_custom_key =
{
- self.items = 0;
- self.customkeys = base_item_key::custom_key_flag (key_name);
- self.netname = key_name;
+ e.items = 0;
+ e.customkeys = base_item_key_customflag (key_name);
+ e.netname = key_name;
};

//----------------------------------------------------------------------
@@ -175,7 +177,7 @@ void(entity client, string custom_message,
local string s;

// support for item_key_custom -- iw
- if (!base_item_key::has_keys (client, self.items, self.customkeys))
+ if (!base_item_key_haskeys (client, self.items, self.customkeys))
{
if (custom_message != "")
centerprint (client, custom_message);
@@ -194,7 +196,7 @@ void(entity client, string custom_message,
else
{
// support for item_key_custom -- iw
- base_item_key::remove_keys(client, self.items, self.customkeys);
+ base_item_key_removekeys (client, self.items, self.customkeys);
s = "You used the ";
}

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

Diff qc/math.qc

diff --git a/qc/math.qc b/qc/math.qc
index 004d720..496c9b8 100644
--- a/qc/math.qc
+++ b/qc/math.qc
@@ -4,12 +4,37 @@
// A collection of helpful math functions.
//==============================================================================

-// Forward declarations
+const float OGRE_DEFAULT_ELEVATION = 30;//TODO CEV remove this
+
+//======================================================================
+// forward declarations
+//======================================================================
+
float(float value, float minValue, float maxValue) clamp;
-float(float a, float b) mod;
+// float(float a, float b) mod; // available as an engine builtin
float(float x) sign;
float(float value, float minValue, float maxValue) wrap;

+float(float a, float b, float mix) lerp;
+vector(vector a, vector b, float mix) lerp_vector;
+float(float a, float b, float mix) lerp_hermite;
+vector(vector a, vector b, float mix) lerp_vector_hermite;
+
+float(float anga, float angb) angledif;
+float(vector ang, vector base_ang, vector offset) is_in_angle;
+
+vector(vector ang) normalize_angles;
+vector(vector ang) normalize_angles180;
+
+float() crandom;
+float(float v) anglemod;
+
+float(float theta) preach_tan;
+float(float y, float x) preach_atan2;
+float(float theta, vector source, vector dest) preach_iterate_elevation;
+
+//------------------------------------------------------------------------------
+
//----------------------------------------------------------------------
// clamp
//
@@ -41,10 +66,12 @@ float(float value, float minValue, float maxValue) clamp =
// b: The divisor
// Returns: The remainder of a divided by n
//----------------------------------------------------------------------
+/*
float(float a, float n) mod =
{
return a - (n * floor(a / n));
};
+*/

//----------------------------------------------------------------------
// sign
@@ -95,7 +122,7 @@ float(float a, float b, float mix) lerp =
};

//----------------------------------------------------------------------
-vector(vector a, vector b, float mix) lerpVector =
+vector(vector a, vector b, float mix) lerp_vector =
{
if (mix <= 0)
return a;
@@ -107,7 +134,7 @@ vector(vector a, vector b, float mix) lerpVector =
//----------------------------------------------------------------------
// for a relaxing lerp: hermite lerp.
//----------------------------------------------------------------------
-float(float a, float b, float mix) lerpHermite =
+float(float a, float b, float mix) lerp_hermite =
{
if (mix <= 0)
return a;
@@ -123,7 +150,7 @@ float(float a, float b, float mix) lerpHermite =
};

//----------------------------------------------------------------------
-vector(vector a, vector b, float mix) lerpVectorHermite =
+vector(vector a, vector b, float mix) lerp_vector_hermite =
{
if (mix <= 0)
return a;
@@ -149,7 +176,7 @@ float(float anga, float angb) angledif =
};

//----------------------------------------------------------------------
-float(vector ang, vector base_ang, vector offset) isInAngle =
+float(vector ang, vector base_ang, vector offset) is_in_angle =
{
if (angledif(ang_x, base_ang_x) > offset_x ||
angledif(ang_y, base_ang_y) > offset_y)
@@ -165,7 +192,7 @@ float(vector ang, vector base_ang, vector offset) isInAngle =
//----------------------------------------------------------------------
// normalizes an angle vector to the 0/+359 range
//----------------------------------------------------------------------
-vector(vector ang) normalizeAngles =
+vector(vector ang) normalize_angles =
{
ang_x = ang_x - floor (ang_x / 360) * 360;
ang_y = ang_y - floor (ang_y / 360) * 360;
@@ -177,7 +204,7 @@ vector(vector ang) normalizeAngles =
//----------------------------------------------------------------------
// normalizes an angle vector to the -180/+179 range
//----------------------------------------------------------------------
-vector(vector ang) normalizeAngles180 =
+vector(vector ang) normalize_angles180 =
{
ang_x = ((ang_x + 180) - floor ((ang_x + 180) / 360) * 360) - 180;
ang_y = ((ang_y + 180) - floor ((ang_y + 180) / 360) * 360) - 180;
@@ -262,7 +289,7 @@ float(float theta, vector source, vector dest) preach_iterate_elevation =
y = vlen (ofs);

// find the coefficients of the quadratic in tan(theta)
- a = 0.5 * frame_gravity * y * y / (GRENADE_SPEED * GRENADE_SPEED);
+ a = 0.5 * world_gravity * y * y / (GRENADE_SPEED * GRENADE_SPEED);
b = -y;
c = a + z;

@@ -282,5 +309,4 @@ float(float theta, vector source, vector dest) preach_iterate_elevation =
theta = theta - 180;
return theta;
};
-
// end Preach tutorial

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

Diff qc/misc/air_bubbles.qc

diff --git a/qc/misc/air_bubbles.qc b/qc/misc/air_bubbles.qc
index 428c060..07ba68c 100644
--- a/qc/misc/air_bubbles.qc
+++ b/qc/misc/air_bubbles.qc
@@ -2,41 +2,50 @@
// air_bubbles
//==============================================================================

+//======================================================================
+// forward declarations
+//======================================================================
+
+// temp_bubbles
+void() temp_bubbles_think;
+void() temp_bubbles_touch;
+void() temp_bubbles_split;
+entity(entity own, vector org, vector v, float fr, float c) spawn_temp_bubbles;
+void(entity e) temp_bubbles_init;
+strip void() temp_bubbles;
+
+// air_bubbles
+void() air_bubbles_think;
+entity(entity own, vector org, float num) spawn_air_bubbles;
+void(entity e) air_bubbles_init;
+void() air_bubbles;
+
//------------------------------------------------------------------------------
-class temp_bubbles: base_tempentity
-{
- float in_water;

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

- // waterlevel isn't being updated now for whatever reason,
- // so do a pointcontents check manually here -- CEV
- if (pointcontents(this.origin) >= CONTENT_SOLID)
- {
- // remove if in open air or a solid -- CEV
- remove (this);
- return;
- }
-
- this.cnt = this.cnt + 1;
+ self.cnt = self.cnt + 1;

- if (this.cnt == 4)
- bubble_split ();
+ if (self.cnt == 4)
+ temp_bubbles_split ();

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

- rnd1 = this.velocity_x + (-10 + (random() * 20));
- rnd2 = this.velocity_y + (-10 + (random() * 20));
- rnd3 = this.velocity_z + 10 + random() * 10;
+ 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;
@@ -53,86 +62,176 @@ class temp_bubbles: base_tempentity
if (rnd3 > 30)
rnd3 = 25;

- this.velocity_x = rnd1;
- this.velocity_y = rnd2;
- this.velocity_z = rnd3;
+ self.velocity_x = rnd1;
+ self.velocity_y = rnd2;
+ self.velocity_z = rnd3;

- this.nextthink = time + 0.5;
+ self.nextthink = time + 0.5;
};

//--------------------------------------------------------------
- virtual void(entity toucher) do_touch =
+ void() temp_bubbles_touch =
{
- if (toucher.classtype == this.classtype)
+ if (other.classtype == self.classtype)
// dprint ("bump");
return;

- remove (this);
+ remove (self);
};

//--------------------------------------------------------------
- virtual void() bubble_split =
+ void() temp_bubbles_split =
{
- local temp_bubbles bubble;
- bubble = spawn (temp_bubbles, frame: 1, cnt: 10,
- origin: this.origin);
- this.frame = 1;
- this.cnt = 10;
+ spawn_temp_bubbles (self, self.origin, self.velocity, 1, 10);
+ self.frame = 1;
+ self.cnt = 10;
+
+ if (self.waterlevel != WATERLEVEL_EYES)
+ remove (self);
};

//--------------------------------------------------------------
- void() temp_bubbles =
+ entity(entity own, vector org, vector v, float fr, float c)
+ spawn_temp_bubbles =
{
- // make bubbles
- setmodel (this, "progs/s_bubble.spr");
- setorigin (this, this.origin);
- this.movetype = MOVETYPE_NOCLIP;
- this.solid = SOLID_NOT;
- this.velocity = '0 0 15';
- this.nextthink = time + 0.5;
+ local entity e = spawn ();
+ e.owner = own;
+ e.origin = org;
+ e.velocity = v;
+ e.frame = fr;
+ e.cnt = c;
+ temp_bubbles_init (e);
+ return e;
+ };
+
+ //--------------------------------------------------------------
+ void(entity e) temp_bubbles_init =
+ {
+ e.classname = "bubble";
+ e.classtype = CT_TEMP_BUBBLES;
+ base_tempentity_init (e);
+
// no touch function when spawning death bubbles -- CEV
- this.classname = "bubble";
- this.classtype = CT_TEMP_BUBBLES;
- this.frame = 0;
- this.cnt = 0;
- setsize (this, '-8 -8 -8', '8 8 8');
+ if (e.owner && e.owner.classtype == CT_PLAYER)
+ e.touch = sub_null;
+ else
+ e.touch = temp_bubbles_touch;
+
+ // make bubbles
+ setmodel (e, "progs/s_bubble.spr");
+ setorigin (e, e.origin);
+ e.movetype = MOVETYPE_NOCLIP;
+ e.solid = SOLID_NOT;
+
+ e.think = temp_bubbles_think;
+ e.nextthink = time + 0.5;
+
+ // e.frame = 0;
+ // e.cnt = 0;
+ setsize (e, '-8 -8 -8', '8 8 8');
};
-};
+
+ //--------------------------------------------------------------
+ strip void() temp_bubbles =
+ {
+ temp_bubbles_init (self);
+ };
+// };

/*QUAKED air_bubbles (0 .5 .8) (-8 -8 -8) (8 8 8) X X X X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY

air bubbles entity

*/
-class air_bubbles: base_mapentity
-{
+//----------------------------------------------------------------------
+// class air_bubbles: base_mapentity
+// {
//--------------------------------------------------------------
// was make_bubbles -- CEV
//--------------------------------------------------------------
- virtual void() do_think =
+ void() air_bubbles_think =
{
- local temp_bubbles bubble;
+ if (self.owner && self.owner.classtype == CT_PLAYER)
+ {
+ // PlayerDeathBubbleSpawn -- CEV
+ if (self.owner.waterlevel != WATERLEVEL_EYES &&
+ self.owner.health > 0)
+ {
+ // remove bubble spawner
+ remove (self);
+ return;
+ }
+
+ spawn_temp_bubbles (self, self.origin, '0 0 15', 0, 0);
+
+ self.air_finished = self.air_finished + 1;
+ if (self.air_finished >= self.count)
+ {
+ remove (self);
+ return;
+ }
+
+ // 1998-08-14 Improved bubble spawn by Maddes start
+ self.nextthink = time + 0.01;
+ // 1998-08-14 Improved bubble spawn by Maddes end
+ return;
+ }
+
+ spawn_temp_bubbles (self, self.origin, '0 0 15', 0, 0);
+ self.nextthink = time + random() + 0.5;
+ };

- bubble = spawn (temp_bubbles, origin: this.origin);
- this.nextthink = time + random() + 0.5;
+ //--------------------------------------------------------------
+ entity(entity own, vector org, float num) spawn_air_bubbles =
+ {
+ local entity e = spawn ();
+ e.owner = own;
+ e.count = num; // bubble_count
+ e.air_finished = 0;
+ setorigin (e, org);
+ air_bubbles_init (e);
+ return e;
};

//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) air_bubbles_init =
{
+ e.classname = "air_bubbles";
+ e.classtype = CT_MISC_AIR_BUBBLES;
+ base_mapentity_init (e);
+
precache_model ("progs/s_bubble.spr");
- this.nextthink = time + 1;
+ e.movetype = MOVETYPE_NONE;
+ e.solid = SOLID_NOT;
+ e.think = air_bubbles_think;
+ if (e.owner && e.owner.classtype == CT_PLAYER)
+ {
+ if (!e.count)
+ e.count = 1;
+
+ // 1998-08-14 Improved bubble spawn by Maddes start
+ e.nextthink = time + 0.01;
+ // 1998-08-14 Improved bubble spawn by Maddes end
+ }
+ else
+ {
+ e.nextthink = time + 1;
+ }
};

//--------------------------------------------------------------
void() air_bubbles =
{
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
if (deathmatch)
{
- remove (this);
+ remove (self);
return;
}

- this.classtype = CT_MISC_AIR_BUBBLES;
+ air_bubbles_init (self);
};
-};
+// };

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

Diff qc/misc/ambient_sound.qc

diff --git a/qc/misc/ambient_sound.qc b/qc/misc/ambient_sound.qc
index 070c118..fb50719 100644
--- a/qc/misc/ambient_sound.qc
+++ b/qc/misc/ambient_sound.qc
@@ -2,7 +2,10 @@
// ambient_sound -- miscellaneous ambient sound entities
//==============================================================================

-// constants
+//======================================================================
+// Constants
+//======================================================================
+
const string SND_AMBIENTCOMPHUM = "ambience/comp1.wav";
const string SND_AMBIENTDRIP = "ambience/drip1.wav";
const string SND_AMBIENTDRONE = "ambience/drone6.wav";
@@ -16,89 +19,180 @@ const string SND_AMBIENTWATER1 = "ambience/water1.wav";
const string SND_AMBIENTWIND2 = "ambience/wind2.wav";
const string SND_AMBIENTHUNDER = "ambience/thunder1.wav";

-class base_ambient_sound: base_mapentity
-{
- //--------------------------------------------------------------
- static void(vector source) ambient_sound_fire =
- {
- precache_sound (SND_AMBIENTFIRE);
- // attenuate fast
- ambientsound (source, SND_AMBIENTFIRE, 0.5, ATTN_STATIC);
- };
+//======================================================================
+// forward declarations
+//======================================================================

- //--------------------------------------------------------------
- static void(vector source) ambient_sound_comphum =
+// base_ambient_sound
+void(vector source) ambient_sound_comphum;
+void(vector source) ambient_sound_drip;
+void(vector source) ambient_sound_drone;
+void(vector source) ambient_sound_fbuzz;
+void(vector source) ambient_sound_fire;
+void(vector source) ambient_sound_lbuzz;
+void(vector source) ambient_sound_suckwind;
+void(vector source) ambient_sound_swamp1;
+void(vector source) ambient_sound_swamp2;
+void(vector source) ambient_sound_water1;
+void(vector source) ambient_sound_wind2;
+void(entity e) base_ambient_sound_init;
+strip void() base_ambient_sound;
+
+// ambient_general
+void(entity e) ambient_general_init
+void() ambient_general;
+
+// FireAmbient
+void(entity e) FireAmbient_init;
+void() FireAmbient;
+
+// ambient_fire
+void(entity e) ambient_fire_init;
+void() ambient_fire;
+
+// ambient_comp_hum
+void(entity e) ambient_comp_hum_init;
+void() ambient_comp_hum;
+
+// ambient_drip
+void(entity e) ambient_drip_init;
+void() ambient_drip;
+
+// ambient_drone
+void(entity e) ambient_drone_init;
+void() ambient_drone;
+
+// ambient_flouro_buzz
+void(entity e) ambient_flouro_buzz_init;
+void() ambient_flouro_buzz;
+
+// ambient_light_buzz
+void(entity e) ambient_light_buzz_init;
+void() ambient_light_buzz;
+
+// ambient_suck_wind
+void(entity e) ambient_suck_wind_init;
+void() ambient_suck_wind;
+
+// ambient_swamp1
+void(entity e) ambient_swamp1_init;
+void() ambient_swamp1;
+
+// ambient_swamp2
+void(entity e) ambient_swamp2_init;
+void() ambient_swamp2;
+
+// ambient_water1
+void(entity e) ambient_water1_init;
+void() ambient_water1;
+
+// ambient_wind2
+void(entity e) ambient_wind2_init;
+void() ambient_wind2;
+
+// ambient_thunder
+void() ambient_thunder_think;
+void(entity e) ambient_thunder_init;
+void() ambient_thunder;
+
+//------------------------------------------------------------------------------
+
+//----------------------------------------------------------------------
+// class base_ambient_sound: base_mapentity
+// {
+ //--------------------------------------------------------------
+ void(vector source) ambient_sound_comphum =
{
precache_sound (SND_AMBIENTCOMPHUM);
ambientsound (source, SND_AMBIENTCOMPHUM, 1, ATTN_STATIC);
};

//--------------------------------------------------------------
- static void(vector source) ambient_sound_drip =
+ void(vector source) ambient_sound_drip =
{
precache_sound (SND_AMBIENTDRIP);
ambientsound (source, SND_AMBIENTDRIP, 0.5, ATTN_STATIC);
};

//--------------------------------------------------------------
- static void(vector source) ambient_sound_drone =
+ void(vector source) ambient_sound_drone =
{
precache_sound (SND_AMBIENTDRONE);
ambientsound (source, SND_AMBIENTDRONE, 0.5, ATTN_STATIC);
};

//--------------------------------------------------------------
- static void(vector source) ambient_sound_fbuzz =
+ void(vector source) ambient_sound_fbuzz =
{
precache_sound (SND_AMBIENTFBUZZ);
ambientsound (source, SND_AMBIENTFBUZZ, 1, ATTN_STATIC);
};

//--------------------------------------------------------------
- static void(vector source) ambient_sound_lbuzz =
+ void(vector source) ambient_sound_fire =
+ {
+ precache_sound (SND_AMBIENTFIRE);
+ // attenuate fast
+ ambientsound (source, SND_AMBIENTFIRE, 0.5, ATTN_STATIC);
+ };
+
+ //--------------------------------------------------------------
+ void(vector source) ambient_sound_lbuzz =
{
precache_sound (SND_AMBIENTLBUZZ);
ambientsound (source, SND_AMBIENTLBUZZ, 0.5, ATTN_STATIC);
};

//--------------------------------------------------------------
- static void(vector source) ambient_sound_suckwind =
+ void(vector source) ambient_sound_suckwind =
{
precache_sound (SND_AMBIENTSWIND);
ambientsound (source, SND_AMBIENTSWIND, 1, ATTN_STATIC);
};

//--------------------------------------------------------------
- static void(vector source) ambient_sound_swamp1 =
+ void(vector source) ambient_sound_swamp1 =
{
precache_sound (SND_AMBIENTSWAMP1);
ambientsound (source, SND_AMBIENTSWAMP1, 0.5, ATTN_STATIC);
};

//--------------------------------------------------------------
- static void(vector source) ambient_sound_swamp2 =
+ void(vector source) ambient_sound_swamp2 =
{
precache_sound (SND_AMBIENTSWAMP1);
ambientsound (source, SND_AMBIENTSWAMP2, 0.5, ATTN_STATIC);
};

//--------------------------------------------------------------
- static void(vector source) ambient_sound_water1 =
+ void(vector source) ambient_sound_water1 =
{
precache_sound (SND_AMBIENTWATER1);
ambientsound (source, SND_AMBIENTWATER1, 1, ATTN_STATIC);
};

//--------------------------------------------------------------
- static void(vector source) ambient_sound_wind2 =
+ void(vector source) ambient_sound_wind2 =
{
precache_sound (SND_AMBIENTWIND2);
ambientsound (source, SND_AMBIENTWIND2, 1, ATTN_STATIC);
};
-};
+
+ //--------------------------------------------------------------
+ void(entity e) base_ambient_sound_init =
+ {
+ base_mapentity_init (e);
+ };
+
+ //--------------------------------------------------------------
+ strip void() base_ambient_sound =
+ {
+ base_ambient_sound_init (self);
+ };
+// };

//======================================================================
-//johnfitz -- ambient_general (this is from Rubicon Rumble dev kit)
+// johnfitz -- ambient_general (this is from Rubicon Rumble dev kit)
//======================================================================

/*QUAKED ambient_general (0.3 0.1 0.6) (-10 -10 -8) (10 10 8) X X X X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
@@ -112,221 +206,324 @@ Keys:

"speed" attenuation, default 3
*/
-class ambient_general: base_mapentity
-{
+//----------------------------------------------------------------------
+// class ambient_general: base_mapentity
+// {
//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) ambient_general_init =
{
+ e.classname = "ambient_general";
+ e.classtype = CT_MISC_AMBIENT_GENERAL;
+
+ base_mapentity_init (e);
+
// dumptruck_ds
- if (!this.noise)
+ if (!e.noise)
{
objerror ("no soundfile set in noise!\n");
- remove (this);
+ remove (e);
return;
}

- precache_sound (this.noise);
+ precache_sound (e.noise);

- if (!this.speed)
- this.speed = ATTN_NORM;
- if (this.speed == 0)
- this.speed = 1;
- if (this.speed == -1)
- // this.speed = 0;
- this.speed = ATTN_NONE;
+ if (!e.speed)
+ e.speed = ATTN_NORM;
+ if (e.speed == 0)
+ e.speed = 1;
+ if (e.speed == -1)
+ // e.speed = 0;
+ e.speed = ATTN_NONE;

- if (!this.volume)
- this.volume = 0.5;
+ if (!e.volume)
+ e.volume = 0.5;

- ambientsound (this.origin, this.noise, this.volume, this.speed);
- remove (this);
+ ambientsound (e.origin, e.noise, e.volume, e.speed);
+ remove (e);
};

//--------------------------------------------------------------
void() ambient_general =
{
- this.classtype = CT_MISC_AMBIENT_GENERAL;
- };
-};
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;

-//======================================================================
+ ambient_general_init (self);
+ };
+// };

/*QUAKED FireAmbient (0.3 0.1 0.6) (-10 -10 -8) (10 10 8)
*/
-class FireAmbient: base_ambient_sound
-{
+//----------------------------------------------------------------------
+// class FireAmbient: base_ambient_sound
+// {
//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) FireAmbient_init =
{
- ambient_sound_fire (this.origin);
+ e.classname = "FireAmbient";
+ e.classtype = CT_MISC_AMBIENT_FIRE;
+
+ base_ambient_sound_init (e);
+
+ ambient_sound_fire (e.origin);
};

//--------------------------------------------------------------
void() FireAmbient =
{
- this.classtype = CT_MISC_AMBIENT_FIRE;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ FireAmbient_init (self);
};
-};
+// };

/*QUAKED ambient_fire (0.3 0.1 0.6) (-10 -10 -8) (10 10 8) X X X X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
ambinet fire sound effects added for consistency
same as FireAmbient
*/
-class ambient_fire: base_ambient_sound
-{
+//----------------------------------------------------------------------
+// class ambient_fire: base_ambient_sound
+// {
//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) ambient_fire_init =
{
- ambient_sound_fire (this.origin);
+ e.classname = "ambient_fire";
+ e.classtype = CT_MISC_AMBIENT_FIRE;
+
+ base_ambient_sound_init (e);
+
+ ambient_sound_fire (e.origin);
};

//--------------------------------------------------------------
void() ambient_fire =
{
- this.classtype = CT_MISC_AMBIENT_FIRE;
- };
-};
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;

-//======================================================================
+ ambient_fire_init (self);
+ };
+// };

/*QUAKED ambient_comp_hum (0.3 0.1 0.6) (-10 -10 -8) (10 10 8) X X X X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
-
*/
-class ambient_comp_hum: base_ambient_sound
-{
+//----------------------------------------------------------------------
+// class ambient_comp_hum: base_ambient_sound
+// {
//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) ambient_comp_hum_init =
{
- ambient_sound_comphum (this.origin);
+ e.classname = "ambient_comp_hum";
+ e.classtype = CT_MISC_AMBIENT_COMPHUM;
+
+ base_ambient_sound_init (e);
+
+ ambient_sound_comphum (e.origin);
};

//--------------------------------------------------------------
void() ambient_comp_hum =
{
- this.classtype = CT_MISC_AMBIENT_COMPHUM;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ ambient_comp_hum_init (self);
};
-};
+// };

/*QUAKED ambient_drip (0.3 0.1 0.6) (-10 -10 -8) (10 10 8) X X X X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
*/
-class ambient_drip: base_ambient_sound
-{
+//----------------------------------------------------------------------
+// class ambient_drip: base_ambient_sound
+// {
//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) ambient_drip_init =
{
- ambient_sound_drip (this.origin);
+ e.classname = "ambient_drip";
+ e.classtype = CT_MISC_AMBIENT_DRIP;
+
+ base_ambient_sound_init (e);
+
+ ambient_sound_drip (e.origin);
};

//--------------------------------------------------------------
void() ambient_drip =
{
- this.classtype = CT_MISC_AMBIENT_DRIP;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ ambient_drip_init (self);
};
-};
+// };

/*QUAKED ambient_drone (0.3 0.1 0.6) (-10 -10 -8) (10 10 8) X X X X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
*/
-class ambient_drone: base_ambient_sound
-{
+//----------------------------------------------------------------------
+// class ambient_drone: base_ambient_sound
+// {
//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) ambient_drone_init =
{
- ambient_sound_drone (this.origin);
+ e.classname = "ambient_drone";
+ e.classtype = CT_MISC_AMBIENT_DRONE;
+
+ base_ambient_sound_init (e);
+
+ ambient_sound_drone (e.origin);
};

//--------------------------------------------------------------
void() ambient_drone =
{
- this.classtype = CT_MISC_AMBIENT_DRONE;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ ambient_drone_init (self);
};
-};
+// };

/*QUAKED ambient_flouro_buzz (0.3 0.1 0.6) (-10 -10 -8) (10 10 8) X X X X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
*/
-class ambient_flouro_buzz: base_ambient_sound
-{
+//----------------------------------------------------------------------
+// class ambient_flouro_buzz: base_ambient_sound
+// {
//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) ambient_flouro_buzz_init =
{
- ambient_sound_fbuzz (this.origin);
+ e.classname = "ambient_flouro_buzz";
+ e.classtype = CT_MISC_AMBIENT_FBUZZ;
+
+ base_ambient_sound_init (e);
+
+ ambient_sound_fbuzz (e.origin);
};

//--------------------------------------------------------------
void() ambient_flouro_buzz =
{
- this.classtype = CT_MISC_AMBIENT_FBUZZ;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ ambient_flouro_buzz_init (self);
};
-};
+// };

/*QUAKED ambient_light_buzz (0.3 0.1 0.6) (-10 -10 -8) (10 10 8) X X X X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
*/
-class ambient_light_buzz: base_ambient_sound
-{
+//----------------------------------------------------------------------
+// class ambient_light_buzz: base_ambient_sound
+// {
//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) ambient_light_buzz_init =
{
- ambient_sound_lbuzz (this.origin);
+ e.classname = "ambient_light_buzz";
+ e.classtype = CT_MISC_AMBIENT_LBUZZ;
+
+ base_ambient_sound_init (e);
+
+ ambient_sound_lbuzz (e.origin);
};

//--------------------------------------------------------------
void() ambient_light_buzz =
{
- this.classtype = CT_MISC_AMBIENT_LBUZZ;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ ambient_light_buzz_init (self);
};
-};
+// };

/*QUAKED ambient_suck_wind (0.3 0.1 0.6) (-10 -10 -8) (10 10 8) X X X X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
*/
-class ambient_suck_wind: base_ambient_sound
-{
+//----------------------------------------------------------------------
+// class ambient_suck_wind: base_ambient_sound
+// {
//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) ambient_suck_wind_init =
{
- ambient_sound_suckwind (this.origin);
+ e.classname = "ambient_suck_wind";
+ e.classtype = CT_MISC_AMBIENT_SUCKWIND;
+
+ base_ambient_sound_init (e);
+
+ ambient_sound_suckwind (e.origin);
};

//--------------------------------------------------------------
void() ambient_suck_wind =
{
- this.classtype = CT_MISC_AMBIENT_SUCKWIND;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ ambient_suck_wind_init (self);
};
-};
+// };

/*QUAKED ambient_swamp1 (0.3 0.1 0.6) (-10 -10 -8) (10 10 8) X X X X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
*/
-class ambient_swamp1: base_ambient_sound
-{
+//----------------------------------------------------------------------
+// class ambient_swamp1: base_ambient_sound
+// {
//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) ambient_swamp1_init =
{
- ambient_sound_swamp1 (this.origin);
+ e.classname = "ambient_swamp1";
+ e.classtype = CT_MISC_AMBIENT_SWAMP1;
+
+ base_ambient_sound_init (e);
+
+ ambient_sound_swamp1 (e.origin);
};

//--------------------------------------------------------------
void() ambient_swamp1 =
{
- this.classtype = CT_MISC_AMBIENT_SWAMP1;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ ambient_swamp1_init (self);
};
-};
+// };

/*QUAKED ambient_swamp2 (0.3 0.1 0.6) (-10 -10 -8) (10 10 8) X X X X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
*/
-class ambient_swamp2: base_ambient_sound
-{
+//----------------------------------------------------------------------
+// class ambient_swamp2: base_ambient_sound
+// {
//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) ambient_swamp2_init =
{
- ambient_sound_swamp2 (this.origin);
+ e.classname = "ambient_swamp2";
+ e.classtype = CT_MISC_AMBIENT_SWAMP2;
+
+ base_ambient_sound_init (e);
+
+ ambient_sound_swamp2 (e.origin);
};

//--------------------------------------------------------------
void() ambient_swamp2 =
{
- this.classtype = CT_MISC_AMBIENT_SWAMP2;
- };
-};
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;

-//======================================================================
+ ambient_swamp2_init (self);
+ };
+// };

/////////////////////////////////////////////////////////////
////////// dumptruck_ds ////////////////////////////////////
@@ -339,37 +536,57 @@ class ambient_swamp2: base_ambient_sound

/*QUAKED ambient_water1 (0.3 0.1 0.6) (-10 -10 -8) (10 10 8) X X X X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
*/
-class ambient_water1: base_ambient_sound
-{
+//----------------------------------------------------------------------
+// class ambient_water1: base_ambient_sound
+// {
//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) ambient_water1_init =
{
- ambient_sound_water1 (this.origin);
+ e.classname = "ambient_water1";
+ e.classtype = CT_MISC_AMBIENT_WATER1;
+
+ base_ambient_sound_init (e);
+
+ ambient_sound_water1 (e.origin);
};

//--------------------------------------------------------------
void() ambient_water1 =
{
- this.classtype = CT_MISC_AMBIENT_WATER1;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ ambient_water1_init (self);
};
-};
+// };

/*QUAKED ambient_wind2 (0.3 0.1 0.6) (-10 -10 -8) (10 10 8) X X X X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
*/
-class ambient_wind2: base_ambient_sound
-{
+//----------------------------------------------------------------------
+// class ambient_wind2: base_ambient_sound
+// {
//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) ambient_wind2_init =
{
- ambient_sound_wind2 (this.origin);
+ e.classname = "ambient_wind2";
+ e.classtype = CT_MISC_AMBIENT_WIND2;
+
+ base_ambient_sound_init (e);
+
+ ambient_sound_wind2 (e.origin);
};

//--------------------------------------------------------------
void() ambient_wind2 =
{
- this.classtype = CT_MISC_AMBIENT_WIND2;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ ambient_wind2_init (self);
};
-};
+// };

/////////////////////////////////////////////////////////////
////////// dumptruck_ds ////////////////////////////////////
@@ -388,34 +605,45 @@ original thumder1.wav included in the game. This is also different than the
other ambient sounds as it plays back randomly as opposed to looping. You
only need one of these in your level. It will play everywhere.
*/
-class ambient_thunder: base_ambient_sound
-{
+//----------------------------------------------------------------------
+// class ambient_thunder: base_ambient_sound
+// {
//--------------------------------------------------------------
- virtual void() do_think =
+ void() ambient_thunder_think =
{
if (random() < 0.5)
- sound (this, CHAN_AUTO, SND_AMBIENTHUNDER,
+ sound (self, CHAN_AUTO, SND_AMBIENTHUNDER,
0.7, ATTN_NONE);
else
- sound (this, CHAN_AUTO, SND_AMBIENTHUNDER,
+ sound (self, CHAN_AUTO, SND_AMBIENTHUNDER,
1, ATTN_NONE);

- this.nextthink = time + 40 * random ();
+ self.nextthink = time + 40 * random ();
};

//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) ambient_thunder_init =
{
+ e.classname = "ambient_thunder";
+ e.classtype = CT_MISC_AMBIENT_THUNDER;
+
+ base_ambient_sound_init (e);
+
// changed from ambient to delayed sound (sounds better)
precache_sound (SND_AMBIENTHUNDER);
// this file in not included in the game
// precache_sound ("ambience/thunder2.wav");
- this.nextthink = time + random ();
+ e.think = ambient_thunder_think;
+ e.nextthink = time + random ();
};

//--------------------------------------------------------------
void() ambient_thunder =
{
- this.classtype = CT_MISC_AMBIENT_THUNDER;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ ambient_thunder_init (self);
};
-};
+// };

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

Diff qc/misc/deadstuff.qc

diff --git a/qc/misc/deadstuff.qc b/qc/misc/deadstuff.qc
index 0fcd5f7..c098a60 100644
--- a/qc/misc/deadstuff.qc
+++ b/qc/misc/deadstuff.qc
@@ -6,440 +6,642 @@
// EfNet IRC #QuakeEd or #Trinity
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

+//======================================================================
+// forward declarations
+//======================================================================
+
+// gib_head_demon
+void(entity e) gib_head_demon_init;
+void() gib_head_demon;
+
+// gib_head_dog
+void(entity e) gib_head_dog_init;
+void() gib_head_dog;
+
+// gib_head_army
+void(entity e) gib_head_army_init;
+void() gib_head_army;
+
+// gib_head_hell_knight
+void(entity e) gib_head_hell_knight_init;
+void() gib_head_hell_knight;
+
+// gib_head_knight
+void(entity e) gib_head_knight_init
+void() gib_head_knight;
+
+// gib_head_enforcer
+void(entity e) gib_head_enforcer_init;
+void() gib_head_enforcer;
+
+// gib_head_ogre
+void(entity e) gib_head_ogre_init;
+void() gib_head_ogre;
+
+// gib_head_player
+void(entity e) gib_head_player_init;
+void() gib_head_player;
+
+// gib_head_shalrath
+void(entity e) gib_head_shalrath_init;
+void() gib_head_shalrath;
+
+// gib_head_shambler
+void(entity e) gib_head_shambler_init;
+void() gib_head_shambler;
+
+// gib_head_wizard
+void(entity e) gib_head_wizard_init;
+void() gib_head_wizard;
+
+// gib_misc_1
+void(entity e) gib_misc_1_init;
+void() gib_misc_1;
+
+// gib_misc_2
+void(entity e) gib_misc_2_init;
+void() gib_misc_2;
+
+// gib_misc_3
+void(entity e) gib_misc_3_init;
+void() gib_misc_3;
+
+//------------------------------------------------------------------------------
+
/*QUAKED gib_head_demon (0 0.5 0.8) (-16 -16 0) (16 16 56) SOLID X X X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
{
model ("progs/h_demon.mdl");
}
*/
-class gib_head_demon: base_mapentity
-{
+//----------------------------------------------------------------------
+// class gib_head_demon: base_mapentity
+// {
//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) gib_head_demon_init =
{
+ e.classname = "gib_head_demon";
+ e.classtype = CT_GIB_HEAD_DEMON;
+
+ base_mapentity_init (e);
+
precache_model ("progs/h_demon.mdl");
- setmodel (this, "progs/h_demon.mdl");
- this.frame = 0;
+ setmodel (e, "progs/h_demon.mdl");
+ e.frame = 0;

- if (this.spawnflags & 1)
+ if (e.spawnflags & 1)
{
- this.solid = SOLID_BBOX;
- setsize (this,'-13.64 -16.77 -0.11','17.44 16.22 30');
+ e.solid = SOLID_BBOX;
+ setsize (e, '-13.64 -16.77 -0.11', '17.44 16.22 30');
}
else
{
- this.solid = SOLID_NOT;
+ e.solid = SOLID_NOT;
}
};

//--------------------------------------------------------------
void() gib_head_demon =
{
- this.classtype = CT_GIB_HEAD_DEMON;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ gib_head_demon_init (self);
};
-};
+// };

/*QUAKED gib_head_dog (0 0.5 0.8) (-16 -16 0) (16 16 56) SOLID X X X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
{
model ("progs/h_dog.mdl");
}
*/
-class gib_head_dog: base_mapentity
-{
+//----------------------------------------------------------------------
+// class gib_head_dog: base_mapentity
+// {
//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) gib_head_dog_init =
{
+ e.classname = "gib_head_dog";
+ e.classtype = CT_GIB_HEAD_DOG;
+
+ base_mapentity_init (e);
+
precache_model ("progs/h_dog.mdl");
- setmodel (this, "progs/h_dog.mdl");
- this.frame = 0; // was 1 -- dumptruck_ds
+ setmodel (e, "progs/h_dog.mdl");
+ e.frame = 0; // was 1 -- dumptruck_ds

- if (this.spawnflags & 1)
+ if (e.spawnflags & 1)
{
- this.solid = SOLID_BBOX;
- setsize (this,'-9.66 -11.89 -0.2','6.57 7.96 13.29');
+ e.solid = SOLID_BBOX;
+ setsize (e, '-9.66 -11.89 -0.2', '6.57 7.96 13.29');
}
else
{
- this.solid = SOLID_NOT;
+ e.solid = SOLID_NOT;
}
};

//--------------------------------------------------------------
void() gib_head_dog =
{
- this.classtype = CT_GIB_HEAD_DOG;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ gib_head_dog_init (self);
};
-};
+// };

/*QUAKED gib_head_army (0 0.5 0.8) (-16 -16 0) (16 16 56) SOLID X X X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
{
model ("progs/h_guard.mdl");
}
*/
-class gib_head_army: base_mapentity
-{
+//----------------------------------------------------------------------
+// class gib_head_army: base_mapentity
+// {
//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) gib_head_army_init =
{
+ e.classname = "gib_head_army";
+ e.classtype = CT_GIB_HEAD_ARMY;
+
+ base_mapentity_init (e);
+
precache_model ("progs/h_guard.mdl");
- setmodel (this, "progs/h_guard.mdl");
- this.frame = 0;
+ setmodel (e, "progs/h_guard.mdl");
+ e.frame = 0;

- if (this.spawnflags & 1)
+ if (e.spawnflags & 1)
{
- this.solid = SOLID_BBOX;
- setsize (this,'-9.67 -8.27 -0.28','4.05 4.8 13.41');
+ e.solid = SOLID_BBOX;
+ setsize (e, '-9.67 -8.27 -0.28', '4.05 4.8 13.41');
}
else
{
- this.solid = SOLID_NOT;
+ e.solid = SOLID_NOT;
}
};

//--------------------------------------------------------------
void() gib_head_army =
{
- this.classtype = CT_GIB_HEAD_ARMY;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ gib_head_army_init (self);
};
-};
+// };

/*QUAKED gib_head_hell_knight (0 0.5 0.8) (-16 -16 0) (16 16 56) SOLID X X X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
{
model ("progs/h_hellkn.mdl");
}*/
-class gib_head_hell_knight: base_mapentity
-{
+//----------------------------------------------------------------------
+// class gib_head_hell_knight: base_mapentity
+// {
//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) gib_head_hell_knight_init =
{
+ e.classname = "gib_head_hell_knight";
+ e.classtype = CT_GIB_HEAD_HELL_KNIGHT;
+
+ base_mapentity_init (e);
+
precache_model ("progs/h_hellkn.mdl");
- setmodel (this, "progs/h_hellkn.mdl");
- this.frame = 0;
+ setmodel (e, "progs/h_hellkn.mdl");
+ e.frame = 0;

- if (this.spawnflags & 1)
+ if (e.spawnflags & 1)
{
- this.solid = SOLID_BBOX;
- setsize (this,'-7.9 -12.97 -0.63','10.55 8.87 21.06');
+ e.solid = SOLID_BBOX;
+ setsize (e, '-7.9 -12.97 -0.63', '10.55 8.87 21.06');
}
else
{
- this.solid = SOLID_NOT;
+ e.solid = SOLID_NOT;
}
};

//--------------------------------------------------------------
void() gib_head_hell_knight =
{
- this.classtype = CT_GIB_HEAD_HELL_KNIGHT;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ gib_head_hell_knight_init (self);
};
-};
+// };

/*QUAKED gib_head_knight (0 0.5 0.8) (-16 -16 0) (16 16 56) SOLID X X X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
{
model ("progs/h_knight.mdl");
}*/
-class gib_head_knight: base_mapentity
-{
+//----------------------------------------------------------------------
+// class gib_head_knight: base_mapentity
+// {
//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) gib_head_knight_init =
{
+ e.classname = "gib_head_knight";
+ e.classtype = CT_GIB_HEAD_KNIGHT;
+
+ base_mapentity_init (e);
+
precache_model ("progs/h_knight.mdl");
- setmodel (this, "progs/h_knight.mdl");
- this.frame = 0;
+ setmodel (e, "progs/h_knight.mdl");
+ e.frame = 0;

- if (this.spawnflags & 1)
+ if (e.spawnflags & 1)
{
- this.solid = SOLID_BBOX;
- setsize (this,'-8.17 -7.47 -0.13','8.36 6.5 30');
+ e.solid = SOLID_BBOX;
+ setsize (e, '-8.17 -7.47 -0.13', '8.36 6.5 30');
}
else
{
- this.solid = SOLID_NOT;
+ e.solid = SOLID_NOT;
}
};

//--------------------------------------------------------------
void() gib_head_knight =
{
- this.classtype = CT_GIB_HEAD_KNIGHT;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ gib_head_knight_init (self);
};
-};
+// };

/*QUAKED gib_head_enforcer (0 0.5 0.8) (-16 -16 0) (16 16 56) SOLID X X X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
{
model ("progs/h_mega.mdl");
}
*/
-class gib_head_enforcer: base_mapentity
-{
+//----------------------------------------------------------------------
+// class gib_head_enforcer: base_mapentity
+// {
//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) gib_head_enforcer_init =
{
+ e.classname = "gib_head_enforcer";
+ e.classtype = CT_GIB_HEAD_ENFORCER;
+
+ base_mapentity_init (e);
+
precache_model ("progs/h_mega.mdl");
- setmodel (this, "progs/h_mega.mdl");
- this.frame = 0;
+ setmodel (e, "progs/h_mega.mdl");
+ e.frame = 0;

- if (this.spawnflags & 1)
+ if (e.spawnflags & 1)
{
- this.solid = SOLID_BBOX;
- setsize (this,'-10.63 -10.23 -0.05','9.27 8.25 30');
+ e.solid = SOLID_BBOX;
+ setsize (e, '-10.63 -10.23 -0.05', '9.27 8.25 30');
}
else
{
- this.solid = SOLID_NOT;
+ e.solid = SOLID_NOT;
}
};

//--------------------------------------------------------------
void() gib_head_enforcer =
{
- this.classtype = CT_GIB_HEAD_ENFORCER;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ gib_head_enforcer_init (self);
};
-};
+// };

/*QUAKED gib_head_ogre (0 0.5 0.8) (-16 -16 0) (16 16 56) SOLID X X X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
{
model ("progs/h_ogre.mdl");
}*/
-class gib_head_ogre: base_mapentity
-{
+//----------------------------------------------------------------------
+// class gib_head_ogre: base_mapentity
+// {
//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) gib_head_ogre_init =
{
+ e.classname = "gib_head_ogre";
+ e.classtype = CT_GIB_HEAD_OGRE;
+
+ base_mapentity_init (e);
+
precache_model ("progs/h_ogre.mdl");
- setmodel (this, "progs/h_ogre.mdl");
- this.frame = 0;
+ setmodel (e, "progs/h_ogre.mdl");
+ e.frame = 0;

- if (this.spawnflags & 1)
+ if (e.spawnflags & 1)
{
- this.solid = SOLID_BBOX;
- setsize (this,'-12.35 -15.7 -0.17','10.67 13.88 30');
+ e.solid = SOLID_BBOX;
+ setsize (e, '-12.35 -15.7 -0.17', '10.67 13.88 30');
}
else
{
- this.solid = SOLID_NOT;
+ e.solid = SOLID_NOT;
}
};

//--------------------------------------------------------------
void() gib_head_ogre =
{
- this.classtype = CT_GIB_HEAD_OGRE;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ gib_head_ogre_init (self);
};
-};
+// };

/*QUAKED gib_head_player (0 0.5 0.8) (-16 -16 0) (16 16 56) SOLID X X X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
{
model ("progs/h_player.mdl");
}*/
-class gib_head_player: base_mapentity
-{
+//----------------------------------------------------------------------
+// class gib_head_player: base_mapentity
+// {
//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) gib_head_player_init =
{
+ e.classname = "gib_head_player";
+ e.classtype = CT_GIB_HEAD_PLAYER;
+
+ base_mapentity_init (e);
+
precache_model ("progs/h_player.mdl");
- setmodel (this, "progs/h_player.mdl");
- this.frame = 0;
+ setmodel (e, "progs/h_player.mdl");
+ e.frame = 0;

- if (this.spawnflags & 1)
+ if (e.spawnflags & 1)
{
- this.solid = SOLID_BBOX;
- setsize (this,'-9.67 -12.38 -2.1','11.49 50.7 30');
+ e.solid = SOLID_BBOX;
+ setsize (e, '-9.67 -12.38 -2.1', '11.49 50.7 30');
}
else
{
- this.solid = SOLID_NOT;
+ e.solid = SOLID_NOT;
}
};

//--------------------------------------------------------------
void() gib_head_player =
{
- this.classtype = CT_GIB_HEAD_PLAYER;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ gib_head_player_init (self);
};
-};
+// };

/*QUAKED gib_head_shalrath (0 0.5 0.8) (-16 -16 0) (16 16 56) SOLID X X X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
{
model ("progs/h_shal.mdl");
}*/
-class gib_head_shalrath: base_mapentity
-{
+//----------------------------------------------------------------------
+// class gib_head_shalrath: base_mapentity
+// {
//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) gib_head_shalrath_init =
{
+ e.classname = "gib_head_shalrath";
+ e.classtype = CT_GIB_HEAD_SHALRATH;
+
+ base_mapentity_init (e);
+
precache_model ("progs/h_shal.mdl");
- setmodel (this, "progs/h_shal.mdl");
- this.frame = 0;
+ setmodel (e, "progs/h_shal.mdl");
+ e.frame = 0;

- if (this.spawnflags & 1)
+ if (e.spawnflags & 1)
{
- this.solid = SOLID_BBOX;
- setsize (this,'-19.85 -19.09 -1.44','13.72 16.8 30');
+ e.solid = SOLID_BBOX;
+ setsize (e, '-19.85 -19.09 -1.44', '13.72 16.8 30');
}
else
{
- this.solid = SOLID_NOT;
+ e.solid = SOLID_NOT;
}
};

//--------------------------------------------------------------
void() gib_head_shalrath =
{
- this.classtype = CT_GIB_HEAD_SHALRATH;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ gib_head_shalrath_init (self);
};
-};
+// };

/*QUAKED gib_head_shambler (0 0.5 0.8) (-16 -16 0) (16 16 56) SOLID X X X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
{
model ("progs/h_shams.mdl");
}*/
-class gib_head_shambler: base_mapentity
-{
+//----------------------------------------------------------------------
+// class gib_head_shambler: base_mapentity
+// {
//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) gib_head_shambler_init =
{
+ e.classname = "gib_head_shambler";
+ e.classtype = CT_GIB_HEAD_SHAMBLER;
+
+ base_mapentity_init (e);
+
precache_model ("progs/h_shams.mdl");
- setmodel (this, "progs/h_shams.mdl");
- this.frame = 0; // was 1, caused an error -- dumptruck_ds
+ setmodel (e, "progs/h_shams.mdl");
+ e.frame = 0; // was 1, caused an error -- dumptruck_ds

- if (this.spawnflags & 1)
+ if (e.spawnflags & 1)
{
- this.solid = SOLID_BBOX;
- setsize (this,'-15.15 -20.638 -0.45','21.44 21.76 30');
+ e.solid = SOLID_BBOX;
+ setsize (e, '-15.15 -20.638 -0.45', '21.44 21.76 30');
}
else
{
- this.solid = SOLID_NOT;
+ e.solid = SOLID_NOT;
}
};

//--------------------------------------------------------------
void() gib_head_shambler =
{
- this.classtype = CT_GIB_HEAD_SHAMBLER;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ gib_head_shambler_init (self);
};
-};
+// };

/*QUAKED gib_head_wizard (0 0.5 0.8) (-16 -16 0) (16 16 56) SOLID X X X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
{
model ("progs/h_wizard.mdl");
}*/
-class gib_head_wizard: base_mapentity
-{
+//----------------------------------------------------------------------
+// class gib_head_wizard: base_mapentity
+// {
//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) gib_head_wizard_init =
{
+ e.classname = "gib_head_wizard";
+ e.classtype = CT_GIB_HEAD_WIZARD;
+
+ base_mapentity_init (e);
+
precache_model ("progs/h_wizard.mdl");
- setmodel (this, "progs/h_wizard.mdl");
- this.frame = 0;
+ setmodel (e, "progs/h_wizard.mdl");
+ e.frame = 0;

- if (this.spawnflags & 1)
+ if (e.spawnflags & 1)
{
- this.solid = SOLID_BBOX;
- setsize (this,'-10.41 -8.66 -0.54','6.52 10.82 30');
+ e.solid = SOLID_BBOX;
+ setsize (e, '-10.41 -8.66 -0.54', '6.52 10.82 30');
}
else
{
- this.solid = SOLID_NOT;
+ e.solid = SOLID_NOT;
}
};

//--------------------------------------------------------------
void() gib_head_wizard =
{
- this.classtype = CT_GIB_HEAD_WIZARD;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ gib_head_wizard_init (self);
};
-};
+// };

/*QUAKED gib_misc_1 (0 0.5 0.8) (-8 -8 -8) (8 8 8) SOLID X X X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
{
model ("progs/gib1.mdl");
}*/
-class gib_misc_1: base_mapentity
-{
+//----------------------------------------------------------------------
+// class gib_misc_1: base_mapentity
+// {
//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) gib_misc_1_init =
{
+ e.classname = "gib_misc_1";
+ e.classtype = CT_GIB_MISC_1;
+
+ base_mapentity_init (e);
+
precache_model ("progs/gib1.mdl");
- setmodel (this, "progs/gib1.mdl");
- this.frame = 0;
+ setmodel (e, "progs/gib1.mdl");
+ e.frame = 0;

- if (this.spawnflags & 1)
+ if (e.spawnflags & 1)
{
- this.solid = SOLID_BBOX;
- setsize (this,'-3.57 -8.06 -3.34','3.69 8.31 30');
+ e.solid = SOLID_BBOX;
+ setsize (e, '-3.57 -8.06 -3.34', '3.69 8.31 30');
}
else
{
- this.solid = SOLID_NOT;
+ e.solid = SOLID_NOT;
}
};

//--------------------------------------------------------------
void() gib_misc_1 =
{
- this.classtype = CT_GIB_MISC_1;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ gib_misc_1_init (self);
};
-};
+// };

/*QUAKED gib_misc_2 (0 0.5 0.8) (-8 -8 -8) (8 8 8) SOLID X X X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
{
model ("progs/gib2.mdl");
}*/
-class gib_misc_2: base_mapentity
-{
+//----------------------------------------------------------------------
+// class gib_misc_2: base_mapentity
+// {
//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) gib_misc_2_init =
{
+ e.classname = "gib_misc_2";
+ e.classtype = CT_GIB_MISC_2;
+
+ base_mapentity_init (e);
+
precache_model ("progs/gib2.mdl");
- setmodel (this, "progs/gib2.mdl");
- this.frame = 0;
+ setmodel (e, "progs/gib2.mdl");
+ e.frame = 0;

- if (this.spawnflags & 1)
+ if (e.spawnflags & 1)
{
- this.solid = SOLID_BBOX;
- setsize (this,'-12.68 -14.83 -6.19','13.53 14.57 30');
+ e.solid = SOLID_BBOX;
+ setsize (e, '-12.68 -14.83 -6.19', '13.53 14.57 30');
}
else
{
- this.solid = SOLID_NOT;
+ e.solid = SOLID_NOT;
}
};

//--------------------------------------------------------------
void() gib_misc_2 =
{
- this.classtype = CT_GIB_MISC_2;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ gib_misc_2_init (self);
};
-};
+// };

/*QUAKED gib_misc_3 (0 0.5 0.8) (-8 -8 -8) (8 8 8) SOLID X X X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
{
model ("progs/gib3.mdl");
}*/
-class gib_misc_3: base_mapentity
-{
+//----------------------------------------------------------------------
+// class gib_misc_3: base_mapentity
+// {
//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) gib_misc_3_init =
{
+ e.classname = "gib_misc_3";
+ e.classtype = CT_GIB_MISC_3;
+
+ base_mapentity_init (e);
+
precache_model ("progs/gib3.mdl");
- setmodel (this, "progs/gib3.mdl");
- this.frame = 0;
+ setmodel (e, "progs/gib3.mdl");
+ e.frame = 0;

- if (this.spawnflags & 1)
+ if (e.spawnflags & 1)
{
- this.solid = SOLID_BBOX;
- setsize (this,'-18.95 -15.92 -3.13','13.17 15.66 30');
+ e.solid = SOLID_BBOX;
+ setsize (e, '-18.95 -15.92 -3.13', '13.17 15.66 30');
}
else
{
- this.solid = SOLID_NOT;
+ e.solid = SOLID_NOT;
}
};

//--------------------------------------------------------------
void() gib_misc_3 =
{
- this.classtype = CT_GIB_MISC_3;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ gib_misc_3_init (self);
};
-};
+// };

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

Diff qc/misc/explobox.qc

diff --git a/qc/misc/explobox.qc b/qc/misc/explobox.qc
index 9666cb6..43dda02 100644
--- a/qc/misc/explobox.qc
+++ b/qc/misc/explobox.qc
@@ -2,25 +2,58 @@
// misc_explobox
//==============================================================================

+//======================================================================
+// forward declarations
+//======================================================================
+
+// base_explobox
+void() base_explobox_destroy;
+void(entity e) base_explobox_init;
+strip void() base_explobox;
+
+// misc_explobox
+void(entity e) misc_explobox_init;
+void() misc_explobox;
+
+// misc_explobox2
+void(entity e) misc_explobox2_init;
+void() misc_explobox2;
+
+//------------------------------------------------------------------------------
+
//----------------------------------------------------------------------
-class base_explobox: base_mapentity
-{
+// class base_explobox: base_mapentity
+// {
//--------------------------------------------------------------
- virtual void() do_destroy =
+ void() base_explobox_destroy =
{
- this.takedamage = DAMAGE_NO;
- this.classname = "explo_box";
- // did say this.owner
- this.t_radiusdamage2 (this, this, 160, world);
- sound (this, CHAN_VOICE, "weapons/r_exp3.wav", 1, ATTN_NORM);
- particle (this.origin, '0 0 0', 75, 255);
-
- this.origin_z = this.origin_z + 32;
+ self.takedamage = DAMAGE_NO;
+ self.classname = "explo_box";
+ // did say self.owner
+ t_radiusdamage2 (self, self, 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
- spawn (base_explosion, origin: this.origin);
- remove (this);
+ spawn_base_explosion (self.origin);
+ remove (self);
};
-};
+
+ //--------------------------------------------------------------
+ void(entity e) base_explobox_init =
+ {
+ e.destroy = base_explobox_destroy;
+ base_mapentity_init (e);
+ };
+
+ //--------------------------------------------------------------
+ void() base_explobox =
+ {
+ base_explobox_init (self);
+ };
+// };

/*QUAKED misc_explobox (0 .5 .8) (0 0 0) (32 32 64) X X X X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
{
@@ -28,42 +61,50 @@ class base_explobox: base_mapentity
}
Explosive box
*/
-class misc_explobox: base_explobox
-{
+//----------------------------------------------------------------------
+// class misc_explobox: base_explobox
+// {
//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) misc_explobox_init =
{
- this.solid = SOLID_BBOX;
- this.movetype = MOVETYPE_NONE;
+ e.classname = "misc_explobox";
+ e.classtype = CT_MISC_EXPLOBOX;
+
+ base_explobox_init (e);
+
+ e.solid = SOLID_BBOX;
+ e.movetype = MOVETYPE_NONE;
precache_model ("maps/b_explob.bsp");
- setmodel (this, "maps/b_explob.bsp");
+ setmodel (e, "maps/b_explob.bsp");
precache_sound ("weapons/r_exp3.wav");
- this.health = 20;
- this.th_die = this.do_destroy;
- this.takedamage = DAMAGE_AIM;
+ e.health = 20;
+ e.takedamage = DAMAGE_AIM;
// 1998-09-16 Sliding/not-jumping on monsters/boxes/players
// fix by Maddes/Kryten
// TODO CEV
- // this.touch = monster_touch;
+ // e.touch = monster_touch;

- this.origin_z = this.origin_z + 2;
- local float oldz = this.origin_z;
+ e.origin_z = e.origin_z + 2;
+ local float oldz = e.origin_z;
droptofloor ();
- if (oldz - this.origin_z > 250)
+ if (oldz - e.origin_z > 250)
{
- dprint ("item fell out of level at ");
- dprint (vtos(this.origin));
- dprint ("\n");
- remove (this);
+ dprint (sprintf("misc_explobox_init: item fell out "
+ "of level at %v\n", e.origin));
+ remove (e);
}
};

//--------------------------------------------------------------
void() misc_explobox =
{
- this.classtype = CT_MISC_EXPLOBOX;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ misc_explobox_init (self);
};
-};
+// };

/*QUAKED misc_explobox2 (0 .5 .8) (0 0 0) (32 32 64) X X X X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
{
@@ -71,39 +112,47 @@ class misc_explobox: base_explobox
}
Smaller explosive box
*/
-class misc_explobox2: base_explobox
-{
+//----------------------------------------------------------------------
+// class misc_explobox2: base_explobox
+// {
//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) misc_explobox2_init =
{
- this.solid = SOLID_BBOX;
- this.movetype = MOVETYPE_NONE;
+ e.classname = "misc_explobox2";
+ e.classtype = CT_MISC_EXPLOBOX2;
+
+ base_explobox_init (e);
+
+ e.solid = SOLID_BBOX;
+ e.movetype = MOVETYPE_NONE;
precache_model2 ("maps/b_exbox2.bsp");
- setmodel (this, "maps/b_exbox2.bsp");
+ setmodel (e, "maps/b_exbox2.bsp");
precache_sound ("weapons/r_exp3.wav");
- this.health = 20;
- this.th_die = this.do_destroy;
- this.takedamage = DAMAGE_AIM;
+ e.health = 20;
+ e.takedamage = DAMAGE_AIM;
// 1998-09-16 Sliding/not-jumping on monsters/boxes/players
// fix by Maddes/Kryten
// TODO CEV
- // this.touch = monster_touch;
+ // e.touch = monster_touch;

- this.origin_z = this.origin_z + 2;
- local float oldz = this.origin_z;
+ e.origin_z = e.origin_z + 2;
+ local float oldz = e.origin_z;
droptofloor ();
- if (oldz - this.origin_z > 250)
+ if (oldz - e.origin_z > 250)
{
- dprint ("item fell out of level at ");
- dprint (vtos(this.origin));
- dprint ("\n");
- remove (this);
+ dprint (sprintf("misc_explobox2_init: item fell out "
+ "of level at %v\n", e.origin));
+ remove (e);
}
};

//--------------------------------------------------------------
void() misc_explobox2 =
{
- this.classtype = CT_MISC_EXPLOBOX2;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ misc_explobox2_init (self);
};
-};
+// };

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

Diff qc/misc/fireball.qc

diff --git a/qc/misc/fireball.qc b/qc/misc/fireball.qc
index d12c9ed..3e38cc4 100644
--- a/qc/misc/fireball.qc
+++ b/qc/misc/fireball.qc
@@ -2,79 +2,70 @@
// misc_fireball
//==============================================================================

-//------------------------------------------------------------------------------
-class temp_fireball: base_tempentity
-{
- //--------------------------------------------------------------
- virtual void() do_think =
- {
- remove (this);
- };
+//======================================================================
+// forward declarations
+//======================================================================

- //--------------------------------------------------------------
- virtual void(entity toucher) do_touch =
- {
- t_damage2 (toucher, this, this, 20);
- remove (this);
- };
+// misc_fireball
+void() misc_fireball_think;
+void(entity e) misc_fireball_init;
+void() misc_fireball;

- //--------------------------------------------------------------
- void() temp_fireball =
- {
- this.classname = "fireball";
- this.classtype = CT_TEMP_FIREBALL;
- this.solid = SOLID_TRIGGER;
- this.movetype = MOVETYPE_TOSS;
- setmodel (this, "progs/lavaball.mdl");
- setsize (this, '0 0 0', '0 0 0');
- setorigin (this, this.origin);
- this.nextthink = time + 5;
- };
-};
+//------------------------------------------------------------------------------

/*QUAKED misc_fireball (0 .5 .8) (-8 -8 -8) (8 8 8) X X X X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
{ model ("progs/lavaball.mdl"); }
Flying lava balls spawner
speed - set vertical speed of fireballs. default 1000.
*/
-class misc_fireball: base_mapentity
-{
+//----------------------------------------------------------------------
+// class misc_fireball: base_mapentity
+// {
//--------------------------------------------------------------
// was fire_fly -- CEV
//--------------------------------------------------------------
- virtual void() do_think =
+ void() misc_fireball_think =
{
- local temp_fireball fireball;
-
- fireball = spawn (temp_fireball,
- velocity: [
- (random() * 100) - 50,
+ spawn_projectile_fireball (self, self.origin,
+ [(random() * 100) - 50,
(random() * 100) - 50,
- this.speed + (random() * 200)],
- origin: this.origin);
+ self.speed + (random() * 200)],
+ FIREBALL_DIRECT_DAMAGE);

- this.nextthink = time + (random() * 5) + 3;
+ self.think = misc_fireball_think;
+ self.nextthink = time + (random() * 5) + 3;
};

//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) misc_fireball_init =
{
+ e.classname = "misc_fireball";
+ e.classtype = CT_MISC_FIREBALL;
+
+ base_mapentity_init (e);
+
precache_model ("progs/lavaball.mdl");
+
+ if (!e.speed)
+ // fixed typo QIP - dumptruck_ds
+ e.speed = FIREBALL_SPEED;
+
+ e.think = misc_fireball_think;
// 1998-08-14 Incorrect setting of nextthink fix
// by Maddes/Lord Sméagol
- // this.nextthink = time + (random() * 5);
- this.nextthink = time + 0.1 + (random() * 5);
+ // e.nextthink = time + (random() * 5);
+ e.nextthink = time + 0.1 + (random() * 5);
// 1998-08-14 Incorrect setting of nextthink fix
// by Maddes/Lord Sméagol
- if (!this.speed)
- // fixed typo QIP - dumptruck_ds
- this.speed = 1000;
};

//--------------------------------------------------------------
void() misc_fireball =
{
- this.classname = "fireball";
- this.classtype = CT_MISC_FIREBALL;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ misc_fireball_init (self);
};
-};
+// };

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

Diff qc/misc/infight.qc

diff --git a/qc/misc/infight.qc b/qc/misc/infight.qc
index 0348fc5..dfee324 100644
--- a/qc/misc/infight.qc
+++ b/qc/misc/infight.qc
@@ -13,14 +13,30 @@
// the infighting sees centerprints triggered by it
//======================================================================

+//======================================================================
// constants
+//======================================================================
+
const float INFIGHT_MUTUAL = 1;
const float INFIGHT_PLAYER_ACTIVATION = 2;

-class misc_infight: base_mapentity
-{
+//======================================================================
+// forward declarations
+//======================================================================
+
+// misc_infight
+void(entity t1, entity t2) misc_infight_make_angry_at;
+void() misc_infight_use;
+void(entity e) misc_infight_init;
+void() misc_infight;
+
+//------------------------------------------------------------------------------
+
+//----------------------------------------------------------------------
+// class misc_infight: base_mapentity
+// {
//--------------------------------------------------------------
- nonvirtual void(entity t1, entity t2) make_angry_at =
+ void(entity t1, entity t2) misc_infight_make_angry_at =
{
// checks if targets are alive
if (t2.health > 0 && t1.health > 0)
@@ -32,49 +48,52 @@ class misc_infight: base_mapentity
// was FoundTargetForEntity (t1) -- CEV
if (t1.classgroup & CG_MONSTER)
{
- ((base_monster)t1).ai_findtarget ();
+ dprint ("misc_infight_make_angry_at: "
+ "TODO CEV!\n");
+ // TODO FIXME CEV
+ // sub_runvoidas (t1, ai_findtarget);
}
else
{
- objerror (sprintf("misc_infight: tried to "
- "make a %s fight a %s!",
+ objerror (sprintf("misc_infight_make_angry_at"
+ ": tried to make a %s fight a %s!",
t1.classname, t2.classname));
}
}
};

//--------------------------------------------------------------
- virtual void(entity caller) do_use =
+ void() misc_infight_use =
{
local entity t1, t2;

- for (t1 = world; (t1 = find (t1, ::targetname, this.target)); )
+ for (t1 = world; (t1 = find (t1, targetname, self.target)); )
{
for (t2 = world;
- (t2 = find (t2, ::targetname, this.target2)); )
+ (t2 = find (t2, targetname, self.target2)); )
{
- // t1 = find(world, ::targetname, this.target);
- // t2 = find(world, ::targetname, this.target2);
+ // t1 = find(world, targetname, self.target);
+ // t2 = find(world, targetname, self.target2);
if (!t1)
{
dprint ("misc_infight_use: Cannot find "
"target, trying targetname2\n");
- t1 = find (world, ::targetname2,
- this.target);
+ t1 = find (world, targetname2,
+ self.target);
}
if (!t1)
{
dprint ("misc_infight_use: Cannot find "
"target, trying targetname3\n");
- t1 = find (world, ::targetname3,
- this.target);
+ t1 = find (world, targetname3,
+ self.target);
}
if (!t1)
{
dprint ("misc_infight_use: Cannot find "
"target, trying targetname4\n");
- t1 = find (world, ::targetname4,
- this.target);
+ t1 = find (world, targetname4,
+ self.target);
}
if (!t1)
{
@@ -86,22 +105,22 @@ class misc_infight: base_mapentity
{
dprint ("misc_infight_use: Cannot find "
"target2 trying targetname2\n");
- t2 = find (world, ::targetname2,
- this.target2);
+ t2 = find (world, targetname2,
+ self.target2);
}
if (!t2)
{
dprint ("misc_infight_use: Cannot find "
"target2 trying targetname3\n");
- t2 = find (world, ::targetname3,
- this.target2);
+ t2 = find (world, targetname3,
+ self.target2);
}
if (!t2)
{
dprint ("misc_infight_use: Cannot find "
"target2 trying targetname4\n");
- t2 = find (world, ::targetname4,
- this.target2);
+ t2 = find (world, targetname4,
+ self.target2);
}
if (!t2)
{
@@ -110,26 +129,38 @@ class misc_infight: base_mapentity
return;
}

- make_angry_at (t1, t2);
+ misc_infight_make_angry_at (t1, t2);

- if (this.spawnflags & INFIGHT_PLAYER_ACTIVATION)
+ if (self.spawnflags & INFIGHT_PLAYER_ACTIVATION)
{
t1.infight_activator = activator;
t2.infight_activator = activator;
}

- if (this.spawnflags & INFIGHT_MUTUAL)
- make_angry_at (t2, t1);
+ if (self.spawnflags & INFIGHT_MUTUAL)
+ misc_infight_make_angry_at (t2, t1);
}
}
};

//--------------------------------------------------------------
- virtual void() init_spawned = { };
+ void(entity e) misc_infight_init =
+ {
+ e.classname = "misc_infight";
+ e.classtype = CT_MISC_INFIGHT;
+
+ base_mapentity_init (e);
+
+ e.use = misc_infight_use;
+ };

//--------------------------------------------------------------
void() misc_infight =
{
- this.classtype = CT_MISC_INFIGHT;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ misc_infight_init (self);
};
-};
+// };

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

Diff qc/misc/light_candle.qc

diff --git a/qc/misc/light_candle.qc b/qc/misc/light_candle.qc
index 40c5180..e5a0c43 100644
--- a/qc/misc/light_candle.qc
+++ b/qc/misc/light_candle.qc
@@ -2,6 +2,21 @@
// light_candle -- was in misc.qc
//==============================================================================

+//======================================================================
+// forward declarations
+//======================================================================
+
+// light_candle
+void(entity e) light_candle_init;
+void() light_candle;
+
+// model_candle
+void() model_candle_think;
+void(entity e) model_candle_init;
+void() model_candle;
+
+//------------------------------------------------------------------------------
+
/*QUAKED light_candle (0 1 0) (-10 -10 -40) (10 10 40) X X X X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
{ model("progs/candle.mdl"); }
==========
@@ -114,48 +129,68 @@ _anglescale => _anglescale
//dumptruck_ds taken from honey (originally from Rogue)
White candle
*/
-class light_candle: base_mapentity
-{
+//----------------------------------------------------------------------
+// class light_candle: base_mapentity
+// {
//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) light_candle_init =
{
+ e.classtype = CT_LIGHT_CANDLE;
+ e.classname = "light_candle";
+
+ base_mapentity_init (e);
+
precache_model ("progs/candle.mdl");
- setmodel (this, "progs/candle.mdl");
- makestatic (this);
+ setmodel (e, "progs/candle.mdl");
+ makestatic (e);
};

//--------------------------------------------------------------
void() light_candle =
{
- this.classtype = CT_LIGHT_CANDLE;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ light_candle_init (self);
};
-};
+// };

-//------------------------------------------------------------------------------
-class model_candle: base_mapentity
-{
+//----------------------------------------------------------------------
+// class model_candle: base_mapentity
+// {
//--------------------------------------------------------------
// was model_candle_think
//--------------------------------------------------------------
- virtual void() do_think =
+ void() model_candle_think =
{
- this.frame = this.frame + 1;
- if (this.frame > 3)
- this.frame = 0;
- this.nextthink = time + 0.1;
+ self.frame = self.frame + 1;
+ if (self.frame > 3)
+ self.frame = 0;
+ self.nextthink = time + 0.1;
};

//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) model_candle_init =
{
+ e.classname = "model_candle";
+ e.classtype = CT_MISC_MODELCANDLE;
+
+ base_mapentity_init (e);
+
precache_model ("progs/candle.mdl");
- setmodel (this, "progs/candle.mdl");
- this.nextthink = time + 0.1;
+ setmodel (e, "progs/candle.mdl");
+ e.think = model_candle_think;
+ e.nextthink = time + 0.1;
};

//--------------------------------------------------------------
void() model_candle =
{
- this.classtype = CT_MISC_MODELCANDLE;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ model_candle_init (self);
};
-};
+// };

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

Diff qc/misc/lights.qc

diff --git a/qc/misc/lights.qc b/qc/misc/lights.qc
index 1edf676..c672379 100644
--- a/qc/misc/lights.qc
+++ b/qc/misc/lights.qc
@@ -2,7 +2,10 @@
// lights.qc taken from c0burn's Slipgate mod -- dumptruck_ds
//==============================================================================

+//======================================================================
// constants
+//======================================================================
+
const float LIGHT_START_OFF = 1;
const float LIGHT_FADE_IN_OUT = 2;
const float LIGHT_SILENT_TORCH = 4; // for silent torch -- dumptruck_ds
@@ -10,6 +13,59 @@ const float LIGHT_SILENT_TORCH = 4; // for silent torch -- dumptruck_ds
const float LIGHT_THINK_FADE_IN = 1;
const float LIGHT_THINK_FADE_OUT = 2;

+//======================================================================
+// forward declarations
+//======================================================================
+
+string(float num) lightstyle_lookup;
+void() setup_lightstyles;
+string(float num) lightstyle_fade_lookup;
+
+// base_light
+void() base_light_think_fade_in;
+void() base_light_think_fade_out;
+void() base_light_use;
+void(entity e) base_light_init;
+strip void() base_light;
+
+// light
+void(entity e) light_init;
+void() light;
+
+// light_fluoro
+void(entity e) light_fluoro_init;
+void() light_fluoro;
+
+// light_fluorospark
+void(entity e) light_fluorospark_init;
+void() light_fluorospark;
+
+// light_globe
+void(entity e) light_globe_init;
+void() light_globe;
+
+// light_torch_small_walltorch
+void(entity e) light_torch_small_walltorch_init;
+void() light_torch_small_walltorch;
+
+// light_flame_large_yellow
+void(entity e) light_flame_large_yellow_init;
+void() light_flame_large_yellow;
+
+// light_flame_small_yellow
+void(entity e) light_flame_small_yellow_init;
+void() light_flame_small_yellow;
+
+// light_flame_small_white
+void(entity e) light_flame_small_white_init;
+void() light_flame_small_white;
+
+// light_sprite_flame
+void(entity e) light_sprite_flame_init;
+void() light_sprite_flame;
+
+//------------------------------------------------------------------------------
+
//----------------------------------------------------------------------
// lightstyle_lookup
//----------------------------------------------------------------------
@@ -113,145 +169,118 @@ string(float num) lightstyle_fade_lookup =
case 12:
return "m";
default:
- error("count out of range\n");
+ error ("count out of range\n");
break;
}
};

-//------------------------------------------------------------------------------
-class base_light: base_mapentity
-{
- float count;
- float style2;
- float think_state;
-
+//----------------------------------------------------------------------
+// class base_light: base_mapentity
+// {
//--------------------------------------------------------------
- virtual void(string fieldname, string fieldvalue) init_field =
+ void() base_light_think_fade_in =
{
- switch (fieldname)
- {
- case "count":
- count = stof (fieldvalue);
- break;
- case "style2":
- style2 = stof (fieldvalue);
- break;
- default:
- super::init_field (fieldname, fieldvalue);
- }
- };
+ if (self.count < 0)
+ self.count = 0;
+ if (self.count > 12)
+ self.count = 12;

- //--------------------------------------------------------------
- virtual void() do_think =
- {
- if (this.think_state == LIGHT_THINK_FADE_IN)
- {
- // light_fade_in
- if (this.count < 0)
- this.count = 0;
- if (this.count > 12)
- this.count = 12;
+ lightstyle (self.style, lightstyle_fade_lookup(self.count));

- lightstyle (this.style,
- lightstyle_fade_lookup(this.count));
+ self.count = self.count + 1;
+ if (self.count > 12)
+ return;

- this.count = this.count + 1;
- if (this.count > 12)
- return;
+ self.think = base_light_think_fade_in;
+ self.nextthink = time + self.speed;
+ };

- this.nextthink = time + this.speed;
- }
- else if (this.think_state == LIGHT_THINK_FADE_OUT)
- {
- // light_fade_out
- if (this.count < 0)
- this.count = 0;
- if (this.count > 12)
- this.count = 12;
+ //--------------------------------------------------------------
+ void() base_light_think_fade_out =
+ {
+ // light_fade_out
+ if (self.count < 0)
+ self.count = 0;
+ if (self.count > 12)
+ self.count = 12;

- lightstyle (this.style,
- lightstyle_fade_lookup(this.count));
+ lightstyle (self.style, lightstyle_fade_lookup(self.count));

- this.count = this.count - 1;
- if (this.count < 0)
- return;
+ self.count = self.count - 1;
+ if (self.count < 0)
+ return;

- this.nextthink = time + this.speed;
- }
- else
- {
- dprint ("base_light::do_think: unhandled "
- "think state!\n");
- }
+ self.think = base_light_think_fade_out;
+ self.nextthink = time + self.speed;
};

//--------------------------------------------------------------
// light_use -- using a light will turn it on and off
//--------------------------------------------------------------
- virtual void(entity caller) do_use =
+ void() base_light_use =
{
- if (this.spawnflags & LIGHT_START_OFF)
+ if (self.spawnflags & LIGHT_START_OFF)
{
- this.spawnflags = this.spawnflags - LIGHT_START_OFF;
- if (this.spawnflags & LIGHT_FADE_IN_OUT && !this.style2)
- {
- this.think_state = LIGHT_THINK_FADE_IN;
- this.do_think ();
- }
+ self.spawnflags = self.spawnflags - LIGHT_START_OFF;
+
+ if (self.spawnflags & LIGHT_FADE_IN_OUT && !self.style2)
+ base_light_think_fade_in ();
else
- {
- lightstyle (this.style,
- lightstyle_lookup(this.style2));
- }
+ lightstyle (self.style,
+ lightstyle_lookup(self.style2));
}
else
{
- this.spawnflags = this.spawnflags + LIGHT_START_OFF;
- if (this.spawnflags & LIGHT_FADE_IN_OUT && !this.style2)
- {
- this.think_state = LIGHT_THINK_FADE_OUT;
- this.do_think ();
- }
+ self.spawnflags = self.spawnflags + LIGHT_START_OFF;
+
+ if (self.spawnflags & LIGHT_FADE_IN_OUT && !self.style2)
+ base_light_think_fade_out ();
else
- {
- lightstyle (this.style, "a");
- }
+ lightstyle (self.style, "a");
}
};

//--------------------------------------------------------------
- nonvirtual void() light_init =
+ void(entity e) base_light_init =
{
+ base_mapentity_init (e);
+
// default speed for fading in/out
- if (this.speed <= 0)
- this.speed = 0.1;
+ if (e.speed <= 0)
+ e.speed = 0.1;

// non-switchable light
- if (!this.targetname)
+ if (!e.targetname)
{
- remove (this);
+ remove (e);
return;
}

- if (this.style < 32)
+ if (e.style < 32)
// return now if this is not a switchable light
// removes one level of indentation below -- CEV
return;

// switchable light
- if (this.spawnflags & LIGHT_START_OFF)
+ e.use = base_light_use;
+ if (e.spawnflags & LIGHT_START_OFF)
{
- this.count = 0;
- lightstyle (this.style, "a");
+ e.count = 0;
+ lightstyle (e.style, "a");
}
else
{
- this.count = 12;
- lightstyle (this.style, lightstyle_lookup(this.style2));
+ e.count = 12;
+ lightstyle (e.style, lightstyle_lookup(e.style2));
}
};
-};

+ //--------------------------------------------------------------
+ strip void() base_light =
+ {
+ base_light_init (self);
+ };
+// };

/*QUAKED light (0 1 0) (-8 -8 -8) (8 8 8) LIGHT_START_OFF LIGHT_FADE_IN_OUT X X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY

@@ -364,20 +393,27 @@ _color => _sunlight_color
_dirt => _sunlight_dirt
_anglescale => _anglescale
*/
-class light: base_light
-{
+//----------------------------------------------------------------------
+// class light: base_light
+// {
//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) light_init =
{
- light_init ();
+ e.classname = "light";
+ e.classtype = CT_LIGHT;
+ base_light_init (e);
};

//--------------------------------------------------------------
void() light =
{
- this.classtype = CT_LIGHT;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ light_init (self);
};
-};
+// };

/*QUAKED light_fluoro (0 1 0) (-8 -8 -8) (8 8 8) LIGHT_START_OFF LIGHT_FADE_IN_OUT X X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY

@@ -385,22 +421,28 @@ Non-displayed light.
Makes steady fluorescent humming sound.
See the "light" entity for a full description.
*/
-class light_fluoro: base_light
-{
+//----------------------------------------------------------------------
+// class light_fluoro: base_light
+// {
//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) light_fluoro_init =
{
- // TODO CEV calling lbuzz directly
- base_ambient_sound::ambient_sound_lbuzz (this.origin);
- light_init ();
+ e.classname = "light_fluoro";
+ e.classtype = CT_LIGHT_FLUORO;
+ ambient_sound_lbuzz (e.origin);
+ base_light_init (e);
};

//--------------------------------------------------------------
void() light_fluoro =
{
- this.classtype = CT_LIGHT_FLUORO;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ light_fluoro_init (self);
};
-};
+// };

/*QUAKED light_fluorospark (0 1 0) (-8 -8 -8) (8 8 8) LIGHT_START_OFF LIGHT_FADE_IN_OUT X X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY

@@ -410,151 +452,230 @@ Can't be toggled.
Default style is 10.
See the "light" entity for a full description.
*/
-class light_fluorospark: base_ambient_sound
-{
+//----------------------------------------------------------------------
+// class light_fluorospark: base_ambient_sound
+// {
//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) light_fluorospark_init =
{
- if (!this.style)
- this.style = 10;
- ambient_sound_fbuzz (this.origin);
- remove (this);
+ e.classname = "light_fluorospark";
+ e.classtype = CT_LIGHT_FLUOROSPARK;
+ base_mapentity_init (e);
+
+ if (!e.style)
+ e.style = 10;
+ ambient_sound_fbuzz (e.origin);
+ remove (e);
};

//--------------------------------------------------------------
void() light_fluorospark =
{
- this.classtype = CT_LIGHT_FLUOROSPARK;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ light_fluorospark_init (self);
};
-};
+// };

/*QUAKED light_globe (0 1 0) (-8 -8 -8) (8 8 8) X X X X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
Sphere globe light.
Can't be toggled.
See the "light" entity for a full description.
*/
-class light_globe: base_light
-{
+//----------------------------------------------------------------------
+// class light_globe: base_light
+// {
//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) light_globe_init =
{
+ e.classname = "light_globe";
+ e.classtype = CT_LIGHT_GLOBE;
+ base_mapentity_init (e);
+
precache_model ("progs/s_light.spr");
- setmodel (this, "progs/s_light.spr");
- makestatic (this);
+ setmodel (e, "progs/s_light.spr");
+ makestatic (e);
};

//--------------------------------------------------------------
void() light_globe =
{
- this.classtype = CT_LIGHT_GLOBE;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ light_globe_init (self);
};
-};
+// };

/*QUAKED light_torch_small_walltorch (0 .5 0) (-10 -10 -20) (10 10 20) X X X X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
{ model ("progs/flame.mdl"); }
Short wall torch
See the "light" entity for a full description.
*/
-class light_torch_small_walltorch: base_ambient_sound
-{
+//----------------------------------------------------------------------
+// class light_torch_small_walltorch: base_ambient_sound
+// {
//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) light_torch_small_walltorch_init =
{
+ e.classname = "light_torch_small_walltorch";
+ e.classtype = CT_LIGHT_TORCH_SMALL_WALLTORCH;
+ base_mapentity_init (e);
+
// precache_model ("progs/flame.mdl");
- precache_body_model ("progs/flame.mdl");
- // setmodel (this, "progs/flame.mdl");
- body_model ("progs/flame.mdl");
+ precache_body_model (e, "progs/flame.mdl");
+ // setmodel (e, "progs/flame.mdl");
+ body_model (e, "progs/flame.mdl");
// for silent torch -- dumptruck_ds
- if !(this.spawnflags && LIGHT_SILENT_TORCH)
- ambient_sound_fire (this.origin);
- makestatic (this);
+ if !(e.spawnflags && LIGHT_SILENT_TORCH)
+ ambient_sound_fire (e.origin);
+ makestatic (e);
};

//--------------------------------------------------------------
void() light_torch_small_walltorch =
{
- this.classtype = CT_LIGHT_TORCH_SMALL_WALLTORCH;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ light_torch_small_walltorch_init (self);
};
-};
+// };

/*QUAKED light_flame_large_yellow (0 1 0) (-10 -10 -12) (12 12 18) X X X X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
{ model ( { "path" : "progs/flame2.mdl", "frame" : 1 } ); }
Large yellow flame
See the "light" entity for a full description.
*/
-class light_flame_large_yellow: base_ambient_sound
-{
+//----------------------------------------------------------------------
+// class light_flame_large_yellow: base_ambient_sound
+// {
//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) light_flame_large_yellow_init =
{
+ e.classname = "light_flame_large_yellow";
+ e.classtype = CT_LIGHT_FLAME_LARGE_YELLOW;
+ base_mapentity_init (e);
+
precache_model ("progs/flame2.mdl");
- setmodel (this, "progs/flame2.mdl");
- this.frame = 1;
- ambient_sound_fire (this.origin);
- makestatic (this);
+ setmodel (e, "progs/flame2.mdl");
+ e.frame = 1;
+ ambient_sound_fire (e.origin);
+ makestatic (e);
};

//--------------------------------------------------------------
void() light_flame_large_yellow =
{
- this.classtype = CT_LIGHT_FLAME_LARGE_YELLOW;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ light_flame_large_yellow_init (self);
};
-};
+// };

/*QUAKED light_flame_small_yellow (0 1 0) (-8 -8 -8) (8 8 8) X X X X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
{ model ("progs/flame2.mdl"); }
Small yellow flame
See the "light" entity for a full description.
*/
-class light_flame_small_yellow: base_ambient_sound
-{
+//----------------------------------------------------------------------
+// class light_flame_small_yellow: base_ambient_sound
+// {
//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) light_flame_small_yellow_init =
{
+ e.classname = "light_flame_small_yellow";
+ e.classtype = CT_LIGHT_FLAME_SMALL_YELLOW;
+ base_mapentity_init (e);
+
precache_model ("progs/flame2.mdl");
- setmodel (this, "progs/flame2.mdl");
- ambient_sound_fire (this.origin);
- makestatic (this);
+ setmodel (e, "progs/flame2.mdl");
+ ambient_sound_fire (e.origin);
+ makestatic (e);
};

+ //--------------------------------------------------------------
void() light_flame_small_yellow =
{
- this.classname = "light_flame_small_yellow";
- this.classtype = CT_LIGHT_FLAME_SMALL_YELLOW;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ light_flame_small_yellow_init (self);
};
-};
+// };

/*QUAKED light_flame_small_white (0 1 0) (-8 -8 -8) (8 8 8) X X X X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
{ model ("progs/flame2.mdl"); }
Left for compatability
Identical to "light_flame_small_yellow"
*/
-class light_flame_small_white: light_flame_small_yellow { };
+//----------------------------------------------------------------------
+// class light_flame_small_white: light_flame_small_yellow
+// {
+ //--------------------------------------------------------------
+ void(entity e) light_flame_small_white_init =
+ {
+ e.classname = "light_flame_small_white";
+ e.classtype = CT_LIGHT_FLAME_SMALL_WHITE;
+ base_mapentity_init (e);
+
+ // same as small_yellow -- CEV
+ precache_model ("progs/flame2.mdl");
+ setmodel (e, "progs/flame2.mdl");
+ ambient_sound_fire (e.origin);
+ makestatic (e);
+ };
+
+ //--------------------------------------------------------------
+ void() light_flame_small_white =
+ {
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ light_flame_small_white_init (self);
+ };
+// };

/*QUAKED light_sprite_flame (0 1 0) (-8 -8 -8) (8 8 8) X X X X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
{ model ("progs/s_flame.spr"); }
Large flame spite*/
-class light_sprite_flame: base_misc_model
-{
+//----------------------------------------------------------------------
+// class light_sprite_flame: base_misc_model
+// {
//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) light_sprite_flame_init =
{
+ e.classname = "light_sprite_flame";
+ e.classtype = CT_LIGHT_SPRITE_FLAME;
+ base_misc_model_init (e);
+
precache_model ("progs/s_flame.spr");
- setmodel (this, "progs/s_flame.spr");
- // TODO CEV was FireAmbient (), now calling
- // ambient_sound_fire directly
- base_ambient_sound::ambient_sound_fire (this.origin);
-
- this.frame = rint (random() * 13);
- this.first_frame = 0;
- this.last_frame = 13;
- this.speed = 0.05;
- this.nextthink = time + 0.1;
+ setmodel (e, "progs/s_flame.spr");
+ ambient_sound_fire (e.origin);
+
+ e.frame = rint (random() * 13);
+ e.first_frame = 0;
+ e.last_frame = 13;
+ e.speed = 0.05;
+ e.think = base_misc_model_think;
+ e.nextthink = time + 0.1;
};

//--------------------------------------------------------------
void() light_sprite_flame =
{
- this.classtype = CT_LIGHT_SPRITE_FLAME;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ light_sprite_flame_init (self);
};
-};
+// };

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

Diff qc/misc/model.qc

diff --git a/qc/misc/model.qc b/qc/misc/model.qc
index 18a8982..e34c690 100644
--- a/qc/misc/model.qc
+++ b/qc/misc/model.qc
@@ -7,7 +7,10 @@
// Edited by: dumptruck_ds to add start and stop animations
//==============================================================================

+//======================================================================
// constants
+//======================================================================
+
const float MISC_MODEL_GRAVITY = 1;
const float MISC_MODEL_SOLID = 2;
const float MISC_MODEL_BACK_AND_FORTH = 4;
@@ -15,108 +18,110 @@ const float MISC_MODEL_ONLY_ONCE = 8;
const float MISC_MODEL_PLAY_COUNT = 16;
const float MISC_MODEL_STARTOFF = 32;

-class base_misc_model: base_mapentity
-{
- // class fields
- float count;
- float first_frame; // The starting frame of the animation
- float last_frame; // The ending frame of the animation
+//======================================================================
+// fields
+//======================================================================

- //--------------------------------------------------------------
- virtual void(string fieldname, string fieldvalue) init_field =
- {
- switch (fieldname)
- {
- case "count":
- count = stof (fieldvalue);
- break;
- case "first_frame":
- first_frame = stof (fieldvalue);
- break;
- case "last_frame":
- last_frame = stof (fieldvalue);
- break;
- default:
- super::init_field (fieldname, fieldvalue);
- }
- };
+.float first_frame; // The starting frame of the animation
+.float last_frame; // The ending frame of the animation
+
+//======================================================================
+// forward declarations
+//======================================================================
+
+// base_misc_model
+void() base_misc_model_think;
+void() base_misc_model_use;
+
+// misc_model
+
+//------------------------------------------------------------------------------

+//----------------------------------------------------------------------
+// class base_misc_model: base_mapentity
+// {
//--------------------------------------------------------------
// misc_model_think -- Handles animation for misc_model entity.
//--------------------------------------------------------------
- virtual void() do_think =
+ void() base_misc_model_think =
{
- this.nextthink = time + fabs (this.speed);
- if (this.estate != STATE_ACTIVE)
+ self.nextthink = time + fabs (self.speed);
+ if (self.estate != STATE_ACTIVE)
return;

- this.frame = this.frame + sign (this.speed);
+ self.frame = self.frame + sign (self.speed);

- if (this.spawnflags & MISC_MODEL_BACK_AND_FORTH
- && this.frame < this.first_frame)
+ if (self.spawnflags & MISC_MODEL_BACK_AND_FORTH &&
+ self.frame < self.first_frame)
{
- this.speed = -1 * this.speed;
- this.frame += 2;
+ self.speed = -1 * self.speed;
+ self.frame += 2;
}
- else if (this.spawnflags & MISC_MODEL_BACK_AND_FORTH
- && this.frame > this.last_frame)
+ else if (self.spawnflags & MISC_MODEL_BACK_AND_FORTH
+ && self.frame > self.last_frame)
{
- this.speed = -1 * this.speed;
- this.frame -= 2;
+ self.speed = -1 * self.speed;
+ self.frame -= 2;
}
else
{
- this.frame = wrap (this.frame, this.first_frame,
- this.last_frame);
+ self.frame = wrap (self.frame, self.first_frame,
+ self.last_frame);
}

- if (this.spawnflags & MISC_MODEL_ONLY_ONCE &&
- this.frame == this.last_frame &&
- this.last_frame != this.first_frame)
+ if (self.spawnflags & MISC_MODEL_ONLY_ONCE &&
+ self.frame == self.last_frame &&
+ self.last_frame != self.first_frame)
{
- this.nextthink = -1;
+ self.nextthink = -1;
}

- if (this.spawnflags & MISC_MODEL_PLAY_COUNT &&
- this.frame == this.last_frame &&
- this.last_frame != this.first_frame)
+ if (self.spawnflags & MISC_MODEL_PLAY_COUNT &&
+ self.frame == self.last_frame &&
+ self.last_frame != self.first_frame)
{
- if !(this.count)
+ if !(self.count)
objerror ("Error: set count to the number of "
" animation cycles!");
- this.cnt = this.cnt + 1;
- dprint (ftos(this.cnt));
+ self.cnt = self.cnt + 1;
+ dprint (ftos(self.cnt));
dprint ("\n");
- if (this.cnt != this.count)
+ if (self.cnt != self.count)
return FALSE;
else
- this.nextthink = -1;
+ self.nextthink = -1;
}
};

//--------------------------------------------------------------
- virtual void(entity caller) do_use =
+ void() base_misc_model_use =
{
- if (this.state == STATE_ACTIVE)
+ if (self.state == STATE_ACTIVE)
{
- if (this.spawnflags & MISC_MODEL_SOLID)
- this.solid = SOLID_NOT;
- this.model = "";
+ if (self.spawnflags & MISC_MODEL_SOLID)
+ self.solid = SOLID_NOT;
+ self.model = "";

- this.state = STATE_INVISIBLE;
- setorigin (this, this.origin);
+ self.state = STATE_INVISIBLE;
+ setorigin (self, self.origin);
}
else
{
- if (this.spawnflags & MISC_MODEL_SOLID)
- this.solid = SOLID_BBOX;
- this.model = this.mdl;
+ if (self.spawnflags & MISC_MODEL_SOLID)
+ self.solid = SOLID_BBOX;
+ self.model = self.mdl;

- this.state = STATE_ACTIVE;
- setorigin (this, this.origin);
+ self.state = STATE_ACTIVE;
+ setorigin (self, self.origin);
}
};
-};
+
+ //--------------------------------------------------------------
+ void(entity e) base_misc_model_init =
+ {
+ base_mapentity_init (e);
+ };
+// };

/*QUAKED misc_model (0 0.5 0.8) (-8 -8 -8) (8 8 8) X X X X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
{
@@ -133,91 +138,100 @@ first_frame: The starting frame of the animation.

last_frame: The last frame of the animation.
*/
-class misc_model: base_misc_model
-{
+//----------------------------------------------------------------------
+// class misc_model: base_misc_model
+// {
//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) misc_model_init =
{
- if (!this.mdl || this.mdl == "")
- objerror ("Model not defined");
+ e.classname = "misc_model";
+ e.classtype = CT_MISC_MODEL;
+ base_misc_model_init (e);

- if (!this.centeroffset)
- this.centeroffset = '0 0 0';
- if (!this.mdlsz)
- this.mdlsz = '32 32 32';
+ if (!e.mdl || e.mdl == "")
+ objerror ("Model not defined");

- this.interaction_flags |= DISABLE_THINK;
+ if (!e.centeroffset)
+ e.centeroffset = '0 0 0';
+ if (!e.mdlsz)
+ e.mdlsz = '32 32 32';

vector vmin, vmax;

- vmin_x = this.centeroffset_x - (this.mdlsz_x / 2);
- vmin_y = this.centeroffset_y - (this.mdlsz_y / 2);
- vmin_z = this.centeroffset_z - (this.mdlsz_z / 2);
+ vmin_x = e.centeroffset_x - (e.mdlsz_x / 2);
+ vmin_y = e.centeroffset_y - (e.mdlsz_y / 2);
+ vmin_z = e.centeroffset_z - (e.mdlsz_z / 2);

- vmax_x = this.centeroffset_x + (this.mdlsz_x / 2);
- vmax_y = this.centeroffset_y + (this.mdlsz_y / 2);
- vmax_z = this.centeroffset_z + (this.mdlsz_z / 2);
+ vmax_x = e.centeroffset_x + (e.mdlsz_x / 2);
+ vmax_y = e.centeroffset_y + (e.mdlsz_y / 2);
+ vmax_z = e.centeroffset_z + (e.mdlsz_z / 2);

- precache_model (this.mdl);
- setmodel (this, this.mdl);
+ precache_model (e.mdl);
+ setmodel (e, e.mdl);

- setsize (this, vmin, vmax);
+ setsize (e, vmin, vmax);

- if (this.spawnflags & MISC_MODEL_SOLID)
- this.solid = SOLID_BBOX;
- else this.solid = SOLID_NOT;
+ if (e.spawnflags & MISC_MODEL_SOLID)
+ e.solid = SOLID_BBOX;
+ else
+ e.solid = SOLID_NOT;

- if (this.spawnflags & MISC_MODEL_GRAVITY)
- this.movetype = MOVETYPE_TOSS;
- else this.movetype = MOVETYPE_NONE;
+ if (e.spawnflags & MISC_MODEL_GRAVITY)
+ e.movetype = MOVETYPE_TOSS;
+ else
+ e.movetype = MOVETYPE_NONE;

- if (!this.frame)
- this.frame = this.first_frame;
+ if (!e.frame)
+ e.frame = e.first_frame;

// Make static (not animate) if not given a frame range, and
// not affected by gravity; also remains active if it has a
// targetname (so it can be killtargeted/toggled)
- if (!this.last_frame &&
- !(this.spawnflags & MISC_MODEL_GRAVITY) &&
- !(this.spawnflags & MISC_MODEL_SOLID) &&
- !this.targetname &&
- !this.targetname2)
- // !(this.spawnflags & MISC_MODEL_DONTMAKESTATIC) &&
+ if (!e.last_frame &&
+ !(e.spawnflags & MISC_MODEL_GRAVITY) &&
+ !(e.spawnflags & MISC_MODEL_SOLID) &&
+ !e.targetname &&
+ !e.targetname2)
+ // !(e.spawnflags & MISC_MODEL_DONTMAKESTATIC) &&
{
- makestatic (this);
+ makestatic (e);
}

// Make static (not animate) if not given a frame range, and
// not affected by gravity
// changed by bmFbr
- // if (!this.last_frame &&
- // !(this.spawnflags & MISC_MODEL_GRAVITY))
+ // if (!e.last_frame &&
+ // !(e.spawnflags & MISC_MODEL_GRAVITY))
// {
- // makestatic(this);
+ // makestatic(e);
// return;
// }

// if it as a custom animation range
- if (this.last_frame)
+ if (e.last_frame)
{
// Default animation speed to 10 fps
- if (!this.speed)
- this.speed = 0.1;
- this.nextthink = time + this.speed;
- this.interaction_flags &= ~DISABLE_THINK;
+ if (!e.speed)
+ e.speed = 0.1;
+ e.think = base_misc_model_think;
+ e.nextthink = time + e.speed;
}

- if (this.spawnflags & MISC_MODEL_STARTOFF)
- this.state = STATE_ACTIVE;
+ if (e.spawnflags & MISC_MODEL_STARTOFF)
+ e.state = STATE_ACTIVE;
else
- this.state = STATE_INVISIBLE;
+ e.state = STATE_INVISIBLE;

- do_use (other);
+ sub_runvoidas (e, base_misc_model_use);
};

//--------------------------------------------------------------
void() misc_model =
{
- this.classtype = CT_MISC_MODEL;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ misc_model_init (self);
};
-};
+// };

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

Diff qc/misc/modeltrain.qc

diff --git a/qc/misc/modeltrain.qc b/qc/misc/modeltrain.qc
index 2f9bd00..1cfee59 100644
--- a/qc/misc/modeltrain.qc
+++ b/qc/misc/modeltrain.qc
@@ -2,118 +2,96 @@
// misc_modeltrain -- was plats.qc
//==============================================================================

+//======================================================================
// constants
+//======================================================================
+
const float TRAIN_STYLE_SINGLEANIM = 1; // modeltrain with one animation

const float TRAIN_ANIMTYPE_FORWARD = 1;
const float TRAIN_ANIMTYPE_BACKFORTH = 2;

-//------------------------------------------------------------------------------
-class base_misc_modeltrain: base_func_train
-{
- // class fields
- float first_frame;
- float first_frame2;
- float last_frame;
- float last_frame2;
- float frtime;
- float frtime2;
- float animtype;
- float animtype2;
- float multiplier;
- float speed2;
-
- vector cmins;
- vector cmaxs;
+//======================================================================
+// fields
+//======================================================================

- //--------------------------------------------------------------
- virtual void(string fieldname, string fieldvalue) init_field =
- {
- switch (fieldname)
- {
- case "cmins":
- cmins = stov (fieldvalue);
- break;
- case "cmaxs":
- cmaxs = stov (fieldvalue);
- break;
- case "first_frame":
- first_frame = stof (fieldvalue);
- break;
- case "first_frame2":
- first_frame2 = stof (fieldvalue);
- break;
- case "last_frame":
- last_frame = stof (fieldvalue);
- break;
- case "last_frame2":
- last_frame2 = stof (fieldvalue);
- break;
- case "frtime":
- frtime = stof (fieldvalue);
- break;
- case "frtime2":
- frtime2 = stof (fieldvalue);
- break;
- case "animtype":
- animtype = stof (fieldvalue);
- break;
- case "animtype2":
- animtype2 = stof (fieldvalue);
- break;
- case "multiplier":
- multiplier = stof (fieldvalue);
- break;
- case "speed2":
- speed2 = stof (fieldvalue);
- break;
- default:
- super::init_field (fieldname, fieldvalue);
- }
- };
-};
+.float first_frame2;
+.float last_frame2;
+.float frtime;
+.float frtime2;
+.float animtype;
+.float animtype2;
+.float multiplier;
+
+.vector cmins;
+.vector cmaxs;
+
+.entity animcontroller;
+.entity rotatecontroller;
+
+//======================================================================
+// forward declarations
+//======================================================================
+
+// temp_anim_controller
+void() temp_anim_controller_think;
+entity(entity own) spawn_temp_anim_controller;
+void(entity e) temp_anim_controller_init;
+strip void() temp_anim_controller;
+
+// temp_rotate_controller
+entity(entity own) spawn_temp_rotate_controller;
+void(entity e) temp_rotate_controller_init;
+strip void() temp_rotate_controller;
+
+// misc_modeltrain
+void(entity e) misc_modeltrain_init;
+void() misc_modeltrain;

//------------------------------------------------------------------------------
-class temp_anim_controller: base_tempentity
-{
- base_misc_modeltrain tr;

+//----------------------------------------------------------------------
+// class temp_anim_controller: base_tempentity
+// {
//--------------------------------------------------------------
- virtual void() do_think =
+ void() temp_anim_controller_think =
{
local float first, last, step, atype, dir, nextframe;

// train just went from stopped to moving or vice-versa,
// and have both animations set
- if (this.state != tr.state &&
- tr.style != TRAIN_STYLE_SINGLEANIM)
+ if (self.state != self.owner.state &&
+ self.owner.style != TRAIN_STYLE_SINGLEANIM)
{
- if (tr.state)
+ if (self.owner.state)
// just started moving
- tr.frame = zeroconvert (tr.first_frame2);
+ self.owner.frame = zeroconvert (
+ self.owner.first_frame2);
else
// just stopped
- tr.frame = zeroconvert (tr.first_frame);
+ self.owner.frame = zeroconvert (
+ self.owner.first_frame);

// reset back/forth status
- tr.distance = 1;
- this.state = tr.state;
+ self.owner.distance = 1;
+ self.state = self.owner.state;
}
else
{
- if (this.state && tr.style != TRAIN_STYLE_SINGLEANIM)
+ if (self.state &&
+ self.owner.style != TRAIN_STYLE_SINGLEANIM)
{
// moving train animation, if set
- first = zeroconvert (tr.first_frame2);
- last = zeroconvert (tr.last_frame2);
- atype = tr.animtype2;
+ first = zeroconvert (self.owner.first_frame2);
+ last = zeroconvert (self.owner.last_frame2);
+ atype = self.owner.animtype2;
}
else
{
// stopped/default train animation
- first = zeroconvert (tr.first_frame);
- last = zeroconvert (tr.last_frame);
- atype = tr.animtype;
+ first = zeroconvert (self.owner.first_frame);
+ last = zeroconvert (self.owner.last_frame);
+ atype = self.owner.animtype;
}

if (first > last)
@@ -124,10 +102,10 @@ class temp_anim_controller: base_tempentity

// back-and-forth is going the other way, so invert
// the step's signal
- if (tr.distance < 0)
+ if (self.owner.distance < 0)
step = step * (-1);

- nextframe = tr.frame + step;
+ nextframe = self.owner.frame + step;

if (atype == TRAIN_ANIMTYPE_BACKFORTH)
{
@@ -136,8 +114,9 @@ class temp_anim_controller: base_tempentity
dir < 0 && (nextframe > first ||
nextframe < last))
{
- nextframe = tr.frame - step;
- tr.distance = tr.distance * (-1);
+ nextframe = self.owner.frame - step;
+ self.owner.distance =
+ self.owner.distance * (-1);
}
}

@@ -146,226 +125,146 @@ class temp_anim_controller: base_tempentity
else
nextframe = wrap (nextframe, last, first);

- tr.frame = nextframe;
+ self.owner.frame = nextframe;
}

- if (this.state || tr.style == TRAIN_STYLE_SINGLEANIM)
- this.nextthink = time + tr.frtime;
+ self.think = temp_anim_controller_think;
+
+ if (self.state || self.owner.style == TRAIN_STYLE_SINGLEANIM)
+ self.nextthink = time + self.owner.frtime;
else
- this.nextthink = time + tr.frtime2;
+ self.nextthink = time + self.owner.frtime2;
};

//--------------------------------------------------------------
- void() temp_anim_controller =
+ entity(entity own) spawn_temp_anim_controller =
{
- this.classname = "animcontroller";
- this.classtype = CT_TEMP_ANIM_CONTROLLER;
- this.state = 0;
+ local entity e = spawn ();
+ e.owner = own;
+ temp_anim_controller_init (e);
+ return e;
};
-};
-
-//------------------------------------------------------------------------------
-class temp_rotate_controller: base_tempentity
-{
- base_misc_modeltrain tr;

//--------------------------------------------------------------
- // SUB_CalcAngleMoveDoneController
- // After rotating, set angle to exact final angle
- //--------------------------------------------------------------
- virtual void() do_think =
+ void(entity e) temp_anim_controller_init =
{
- tr.angles = this.finalangle;
- tr.avelocity = '0 0 0';
- this.nextthink = -1;
- };
-
- //--------------------------------------------------------------
- // SUB_CalcAngleMoveController -- Same as SUB_CalcAngleMove, but
- // using a separate controller entity to not lose track of current
- // think functions.
- //--------------------------------------------------------------
- nonvirtual void(vector destangle, float tspeed) 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 = normalizeAngles180 (destangle - tr.angles);
-
- /*
- dprint3 ("destangle: ", vtos(destangle), "\n");
- dprint3 ("this.angles: ", vtos(this.angles), "\n");
- dprint3 ("destdelta: ", vtos(destdelta), "\n");
- */
-
- // calculate length of vector
- len = vlen (destdelta);
+ e.classname = "animcontroller";
+ e.classtype = CT_TEMP_ANIM_CONTROLLER;
+ e.state = 0;
+ base_tempentity_init (e);

- // divide by speed to get time to reach dest
- traveltime = len / tspeed;
+ if (!e.owner)
+ objerror ("temp_anim_controller_init: no owner!\n");

- // set nextthink to trigger a think when dest is reached
- this.nextthink = time + traveltime;
-
- // scale the destdelta vector by the time spent traveling to
- // get velocity
- tr.avelocity = destdelta * (1 / traveltime);
-
- // Makes sure controller.owner points to self so it can be
- // referenced later in the think function
- this.finalangle = destangle;
+ e.think = temp_anim_controller_think;
+ e.nextthink = time + 0.2;
};

//--------------------------------------------------------------
- void() temp_rotate_controller =
+ strip void() temp_anim_controller =
{
- this.classname = "rotatecontroller";
- this.classtype = CT_TEMP_ROTATE_CONTROLLER;
+ temp_anim_controller_init (self);
};
-};
-
-//------------------------------------------------------------------------------
-class misc_modeltrain: base_misc_modeltrain
-{
- temp_anim_controller animcontroller;
- temp_rotate_controller rotatecontroller;
+// };

+//----------------------------------------------------------------------
+// class temp_rotate_controller: base_tempentity
+// {
//--------------------------------------------------------------
- virtual void() train_wait_handlepath =
+ entity(entity own) spawn_temp_rotate_controller =
{
- // copies the modeltrain animation parameters set in the
- // path_corner, if any
- if (this.enemy.classtype == CT_PATH_CORNER)
- {
- local path_corner path = (path_corner)this.enemy;
- if (path.first_frame)
- this.first_frame = path.first_frame;
- if (path.last_frame)
- this.last_frame = path.last_frame;
- if (path.first_frame2)
- this.first_frame2 = path.first_frame2;
- if (path.last_frame2)
- this.last_frame2 = path.last_frame2;
- if (path.frtime)
- this.frtime = path.frtime;
- if (path.frtime2)
- this.frtime2 = path.frtime2;
- if (path.animtype)
- this.animtype = path.animtype;
- if (path.animtype2)
- this.animtype2 = path.animtype2;
- if (path.multiplier)
- this.multiplier = path.multiplier;
- }
+ local entity e = spawn ();
+ e.owner = own;
+ temp_rotate_controller_init (e);
+ return e;
};

//--------------------------------------------------------------
- virtual void() train_wait_handlepause =
+ void(entity e) temp_rotate_controller_init =
{
- animcontroller.do_think ();
+ e.classname = "rotatecontroller";
+ e.classtype = CT_TEMP_ROTATE_CONTROLLER;
+ base_tempentity_init (e);
};

//--------------------------------------------------------------
- virtual void() train_wait_handlestop =
+ strip void() temp_rotate_controller =
{
- animcontroller.do_think ();
+ temp_rotate_controller_init (self);
};
+// };

+//----------------------------------------------------------------------
+// class misc_modeltrain: base_func_train
+// {
//--------------------------------------------------------------
- virtual void(entity targ) train_next_custom =
+ void(entity e) misc_modeltrain_init =
{
- vector destang = '0 0 0';
-
- if (!(this.spawnflags & TRAIN_NOROTATE))
- {
- destang = vectoangles (targ.origin - this.origin);
-
- if (this.spawnflags & TRAIN_ROTATEY)
- {
- destang_x = this.angles_x;
- destang_z = this.angles_z;
- }
-
- if (this.multiplier > 0)
- rotatecontroller.sub_calcanglemove (destang,
- this.speed2 * this.multiplier);
- else
- this.angles = destang;
- }
+ e.classname = "misc_modeltrain";
+ e.classtype = CT_MISC_MODELTRAIN;

- if (!this.state)
- {
- this.state = 1;
- if (this.style != TRAIN_STYLE_SINGLEANIM)
- animcontroller.do_think ();
- }
- };
-
- //--------------------------------------------------------------
- virtual void() init_spawned =
- {
- precache_model (this.mdl);
- train_init ();
+ precache_model (e.mdl);
+ base_func_train_init (e);

- if (this.spawnflags & TRAIN_NONSOLID)
+ if (e.spawnflags & TRAIN_NONSOLID)
{
- this.solid = SOLID_NOT;
+ e.solid = SOLID_NOT;
}
else
{
- this.solid = SOLID_BBOX;
- if (this.cmins == VEC_ORIGIN)
- this.cmins = '-8 -8 -8';
- if (this.cmaxs == VEC_ORIGIN)
- this.cmaxs = '8 8 8';
+ e.solid = SOLID_BBOX;
+ if (e.cmins == VEC_ORIGIN)
+ e.cmins = '-8 -8 -8';
+ if (e.cmaxs == VEC_ORIGIN)
+ e.cmaxs = '8 8 8';
}

- this.movetype = MOVETYPE_NOCLIP;
- setmodel (this, this.mdl);
- setsize (this, this.cmins , this.cmaxs);
- setorigin (this, this.origin);
+ e.movetype = MOVETYPE_NOCLIP;
+ setmodel (e, e.mdl);
+ setsize (e, e.cmins , e.cmaxs);
+ setorigin (e, e.origin);

- rotatecontroller = spawn (temp_rotate_controller, tr: this);
- animcontroller = spawn (temp_anim_controller, tr: this);
- animcontroller.nextthink = time + 0.2;
+ e.rotatecontroller = spawn_temp_rotate_controller (e);
+ e.animcontroller = spawn_temp_anim_controller (e);

- if (!this.frtime)
- this.frtime = 0.1;
- if (!this.frtime2)
- this.frtime2 = this.frtime;
- if (!this.multiplier)
- this.multiplier = 1;
+ e.distance = 1;
+
+ if (!e.frtime)
+ e.frtime = 0.1;
+ if (!e.frtime2)
+ e.frtime2 = e.frtime;
+ if (!e.multiplier)
+ e.multiplier = 1;

// make sure all first and last frame fields are filled
- if (this.first_frame && !this.last_frame)
- this.last_frame = this.first_frame;
- else if (!this.first_frame && this.last_frame)
- this.first_frame = this.last_frame;
-
- if (this.first_frame2 && !this.last_frame2)
- this.last_frame2 = this.first_frame2;
- else if (!this.first_frame2 && this.last_frame2)
- this.first_frame2 = this.last_frame2;
-
- if (this.first_frame2 == 0)
- this.style = TRAIN_STYLE_SINGLEANIM;
-
- if (!this.animtype)
- this.animtype = TRAIN_ANIMTYPE_FORWARD;
- if (!this.animtype2)
- this.animtype2 = this.animtype;
-
- this.distance = 1;
- this.frame = this.first_frame;
+ if (e.first_frame && !e.last_frame)
+ e.last_frame = e.first_frame;
+ else if (!e.first_frame && e.last_frame)
+ e.first_frame = e.last_frame;
+
+ if (e.first_frame2 && !e.last_frame2)
+ e.last_frame2 = e.first_frame2;
+ else if (!e.first_frame2 && e.last_frame2)
+ e.first_frame2 = e.last_frame2;
+
+ if (e.first_frame2 == 0)
+ e.style = TRAIN_STYLE_SINGLEANIM;
+
+ if (!e.animtype)
+ e.animtype = TRAIN_ANIMTYPE_FORWARD;
+ if (!e.animtype2)
+ e.animtype2 = e.animtype;
+
+ e.frame = e.first_frame;
};

//--------------------------------------------------------------
void() misc_modeltrain =
{
- this.classtype = CT_MISC_MODELTRAIN;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ misc_modeltrain_init (self);
};
-};
+// };

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

Diff qc/misc/noisemaker.qc

diff --git a/qc/misc/noisemaker.qc b/qc/misc/noisemaker.qc
index d252583..018f2ba 100644
--- a/qc/misc/noisemaker.qc
+++ b/qc/misc/noisemaker.qc
@@ -2,28 +2,44 @@
// misc_noisemaker
//==============================================================================

+//======================================================================
+// forward declarations
+//======================================================================
+
+// misc_noisemaker
+void() misc_noisemaker_think;
+void(entity e) misc_noisemaker_init;
+void() misc_noisemaker;
+
+//------------------------------------------------------------------------------
+
/*QUAKED misc_noisemaker (1 0.5 0) (-10 -10 -10) (10 10 10) X X X X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY

For optimzation testing, starts a lot of sounds.
*/
-class misc_noisemaker: base_mapentity
-{
+//----------------------------------------------------------------------
+// class misc_noisemaker: base_mapentity
+// {
//--------------------------------------------------------------
- virtual void() do_think =
+ void() misc_noisemaker_think =
{
- this.nextthink = time + 0.5;
- sound (this, 1, "enforcer/enfire.wav", 1, ATTN_NORM);
- sound (this, 2, "enforcer/enfstop.wav", 1, ATTN_NORM);
- sound (this, 3, "enforcer/sight1.wav", 1, ATTN_NORM);
- sound (this, 4, "enforcer/sight2.wav", 1, ATTN_NORM);
- sound (this, 5, "enforcer/sight3.wav", 1, ATTN_NORM);
- sound (this, 6, "enforcer/sight4.wav", 1, ATTN_NORM);
- sound (this, 7, "enforcer/pain1.wav", 1, ATTN_NORM);
+ 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);
};

//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) misc_noisemaker_init =
{
+ e.classname = "misc_noisemaker";
+ e.classtype = CT_MISC_NOISEMAKER;
+ base_mapentity_init (e);
+
precache_sound2 ("enforcer/enfire.wav");
precache_sound2 ("enforcer/enfstop.wav");
precache_sound2 ("enforcer/sight1.wav");
@@ -35,12 +51,17 @@ class misc_noisemaker: base_mapentity
precache_sound2 ("enforcer/death1.wav");
precache_sound2 ("enforcer/idle1.wav");

- this.nextthink = time + 0.1 + random ();
+ e.think = misc_noisemaker_think;
+ e.nextthink = time + 0.1 + random ();
};

//--------------------------------------------------------------
void() misc_noisemaker =
{
- this.classtype = CT_MISC_NOISEMAKER;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ misc_noisemaker_init (self);
};
-};
+// };

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

Diff qc/misc/particle_stream.qc

diff --git a/qc/misc/particle_stream.qc b/qc/misc/particle_stream.qc
index 70e13ee..5002fc5 100644
--- a/qc/misc/particle_stream.qc
+++ b/qc/misc/particle_stream.qc
@@ -2,6 +2,20 @@
// misc_particle_stream -- from Zerstrorer mod -- dumptruck_ds
//==============================================================================

+//======================================================================
+// forward declarations
+//======================================================================
+
+// misc_particle_stream
+void(vector start, vector end, float color1, float color2, float pdensity)
+ misc_particle_stream_beam;
+void() misc_particle_stream_think;
+void() misc_particle_stream_use;
+void(entity e) misc_particle_stream_init;
+void() misc_particle_stream;
+
+//------------------------------------------------------------------------------
+
//=START PARTICLE-STREAM================================================

/*QUAKED misc_particle_stream (0 .5 .8) (-8 -8 -8) (8 8 8) X X X X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
@@ -15,11 +29,12 @@ I used the info_notnull, but you should be able to target anything
"cnt" 2nd Color - Mixes particles of both colors
"noise" Sound to play when triggered
*/
-class misc_particle_stream: base_mapentity
-{
+//----------------------------------------------------------------------
+// class misc_particle_stream: base_mapentity
+// {
//--------------------------------------------------------------
- nonvirtual void(vector start, vector end, float color1, float color2,
- float pdensity) particle_beam =
+ void(vector start, vector end, float color1, float color2,
+ float pdensity) misc_particle_stream_beam =
{
local vector spray, next;
local float dist, loop, clr;
@@ -46,11 +61,11 @@ class misc_particle_stream: base_mapentity
//--------------------------------------------------------------
// was particle_stream_start -- CEV
//--------------------------------------------------------------
- virtual void() do_think =
+ void() misc_particle_stream_think =
{
local entity pspot;

- pspot = find (world, ::targetname, this.target);
+ pspot = find (world, targetname, self.target);

if (!pspot)
{
@@ -59,39 +74,49 @@ class misc_particle_stream: base_mapentity
return;
}

- this.enemy = pspot;
+ self.enemy = pspot;
};

//--------------------------------------------------------------
- virtual void(entity caller) do_use =
+ void() misc_particle_stream_use =
{
- sound (this, CHAN_VOICE, this.noise, 1, ATTN_NORM);
+ sound (self, CHAN_VOICE, self.noise, 1, ATTN_NORM);
// was 40 - too many particles for my taste -- dumptruck_ds
- particle_beam (this.origin, this.enemy.origin,
- this.dmg, this.cnt, 15);
+ misc_particle_stream_beam (self.origin, self.enemy.origin,
+ self.dmg, self.cnt, 15);
};

//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) misc_particle_stream_init =
{
- if (!this.target)
- objerror ("misc_particle_stream with not target!");
+ e.classname = "misc_particle_stream";
+ e.classtype = CT_MISC_PARTICLE_STREAM;
+ base_mapentity_init (e);

- if (!this.dmg)
- this.dmg = 73;
- if (!this.cnt)
- this.cnt = this.dmg;
- if (!this.noise)
- this.noise = "misc/null.wav";
+ if (!e.target)
+ objerror ("misc_particle_stream_init: no target!");

- precache_sound (this.noise);
+ if (!e.dmg)
+ e.dmg = 73;
+ if (!e.cnt)
+ e.cnt = e.dmg;
+ if (!e.noise)
+ e.noise = "misc/null.wav";

- this.nextthink = time + 0.2;
+ precache_sound (e.noise);
+
+ e.use = misc_particle_stream_use;
+ e.think = misc_particle_stream_think;
+ e.nextthink = time + 0.2;
};

//--------------------------------------------------------------
void() misc_particle_stream =
{
- this.classtype = CT_MISC_PARTICLE_STREAM;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ misc_particle_stream_init (self);
};
-};
+// };

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

Diff qc/misc/particles.qc

diff --git a/qc/misc/particles.qc b/qc/misc/particles.qc
index d02a5cf..e57898e 100644
--- a/qc/misc/particles.qc
+++ b/qc/misc/particles.qc
@@ -1,12 +1,30 @@
//==============================================================================
// misc_particles AKA misc_splash
// selections from Rubicon 2 qc by john fitzgibbons
-// renamed from misc_splash (Rubcion 2) -- dumptruck_ds
+// renamed from misc_splash (Rubicon 2) -- dumptruck_ds
//==============================================================================

+//======================================================================
// constants
+//======================================================================
+
const float PARTICLES_START_OFF = 1;

+//======================================================================
+// forward declarations
+//======================================================================
+
+// misc_particles
+void() misc_particles_think;
+void() misc_particles_use;
+void(entity e) misc_particles_init;
+void() misc_particles;
+
+// misc_splash
+void() misc_splash;
+
+//------------------------------------------------------------------------------
+
/*QUAKED misc_particles (0 .5 .8) (-8 -8 -8) (8 8 8) PARTICLES_START_OFF X X X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY

Produces a continuous particle splash for waterfalls and other effects
@@ -19,65 +37,91 @@ Produces a continuous particle splash for waterfalls and other effects

"volume" density of particles. (default 10)
*/
-class misc_particles: base_mapentity
-{
+//----------------------------------------------------------------------
+// class misc_particles: base_mapentity
+// {
//--------------------------------------------------------------
// was splash_think -- CEV
//--------------------------------------------------------------
- virtual void() do_think =
+ void() misc_particles_think =
{
local vector vec;
- local float variance;
- variance = vlen(this.movedir) / 2;
- vec_x = this.movedir_x - variance +
- random() * variance * 2;
- vec_y = this.movedir_y - variance +
- random() * variance * 2;
- vec_z = this.movedir_z - variance +
- random() * variance * 2;
- particle (this.origin, vec, this.color, this.volume);
- this.nextthink = time + this.wait;
+ local float variance = vlen (self.movedir) / 2;
+ vec_x = self.movedir_x - variance + random() * variance * 2;
+ vec_y = self.movedir_y - variance + random() * variance * 2;
+ vec_z = self.movedir_z - variance + random() * variance * 2;
+ particle (self.origin, vec, self.color, self.volume);
+ self.think = misc_particles_think;
+ self.nextthink = time + self.wait;
};

//--------------------------------------------------------------
- virtual void(entity caller) do_use =
+ void() misc_particles_use =
{
- if (this.spawnflags & PARTICLES_START_OFF)
+ if (self.spawnflags & PARTICLES_START_OFF)
{
- this.spawnflags = this.spawnflags - PARTICLES_START_OFF;
- this.interaction_flags |= DISABLE_THINK;
+ self.spawnflags = self.spawnflags - PARTICLES_START_OFF;
+ self.think = __NULL__;
}
else
{
- this.spawnflags = this.spawnflags + PARTICLES_START_OFF;
- this.interaction_flags &= ~DISABLE_THINK;
+ self.spawnflags = self.spawnflags + PARTICLES_START_OFF;
+ self.think = misc_particles_think;
+ self.nextthink = time + self.wait;
}
};

//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) misc_particles_init =
{
- if (!this.wait)
- this.wait = 0.1;
+ e.classname = "misc_particles";
+ e.classtype = CT_MISC_PARTICLES;
+ base_mapentity_init (e);
+
+ if (!e.wait)
+ e.wait = 0.1;

- if (!this.movedir)
- this.movedir = '0 0 4';
+ if (!e.movedir)
+ e.movedir = '0 0 4';

- if (!this.volume)
- this.volume = 10;
+ if (!e.volume)
+ e.volume = 10;

- if (this.spawnflags & PARTICLES_START_OFF)
- this.interaction_flags |= DISABLE_THINK;
+ if (e.spawnflags & PARTICLES_START_OFF)
+ {
+ e.think = __NULL__;
+ }
else
- this.interaction_flags &= ~DISABLE_THINK;
+ {
+ e.think = misc_particles_think;
+ e.nextthink = time + e.wait;
+ }

- this.color = this.color * 16;
- this.nextthink = time + this.wait;
+ e.color = e.color * 16;
+ e.use = misc_particles_use;
};

//--------------------------------------------------------------
void() misc_particles =
{
- this.classtype = CT_MISC_PARTICLES;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ misc_particles_init (self);
+ };
+// };
+
+//----------------------------------------------------------------------
+// class misc_splash: misc_particles
+// {
+ //--------------------------------------------------------------
+ void() misc_splash =
+ {
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ misc_particles_init (self);
};
-};
+// };

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

Diff qc/misc/particlespray.qc

diff --git a/qc/misc/particlespray.qc b/qc/misc/particlespray.qc
index cf64807..9d9b593 100644
--- a/qc/misc/particlespray.qc
+++ b/qc/misc/particlespray.qc
@@ -4,6 +4,25 @@
// renamed from func to misc
//==============================================================================

+//======================================================================
+// fields
+//======================================================================
+
+.float endtime;
+.float duration;
+
+//======================================================================
+// forward declarations
+//======================================================================
+
+// misc_particlespray
+void() misc_particlespray_think;
+void() misc_particlespray_use;
+void(entity e) misc_particlespray_init;
+void() misc_particlespray;
+
+//------------------------------------------------------------------------------
+
/*QUAKED misc_particlespray (0 .5 .8) (-8 -8 -8) (8 8 8) X X X X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
Shoots particles either when triggered, or contiuously when not triggered by anything.
"color" is the palette color of the particles
@@ -18,73 +37,68 @@ Shoots particles either when triggered, or contiuously when not triggered by any

"duration" is the amount of time that the it will continue to release particles so that it can release a long stream of particles with only one triggering.
*/
-class misc_particlespray: base_mapentity
-{
- // class fields
- float endtime;
- float duration;
-
+//----------------------------------------------------------------------
+// class misc_particlespray: base_mapentity
+// {
//--------------------------------------------------------------
- virtual void(string fieldname, string fieldvalue) init_field =
+ void() misc_particlespray_think =
{
- switch (fieldname)
- {
- case "duration":
- duration = stof (fieldvalue);
- break;
- default:
- super::init_field (fieldname, fieldvalue);
- }
- };
+ particle (self.origin, self.movedir, self.color, self.count);

- //--------------------------------------------------------------
- virtual void() do_think =
- {
- particle (this.origin, this.movedir, this.color, this.count);
-
- if (!this.targetname || this.endtime > time)
- this.nextthink = time + this.delay;
+ if (!self.targetname || self.endtime > time)
+ self.nextthink = time + self.delay;

- if (this.noise != "")
- sound (this, CHAN_AUTO, this.noise, 1, ATTN_NORM);
+ if (self.noise != "")
+ sound (self, CHAN_AUTO, self.noise, 1, ATTN_NORM);
else
- sound (this, CHAN_AUTO, "misc/null.wav", 1, ATTN_NORM);
+ sound (self, CHAN_AUTO, "misc/null.wav", 1, ATTN_NORM);
};

//--------------------------------------------------------------
- virtual void(entity caller) do_use =
+ void() misc_particlespray_use =
{
- if (this.targetname != __NULL__ && this.targetname != "")
+ if (self.targetname != __NULL__ && self.targetname != "")
return;

- this.endtime = time + this.duration;
- this.do_think ();
+ self.endtime = time + self.duration;
+ misc_particlespray_think ();
};

//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) misc_particlespray_init =
{
- if (!this.color)
- this.color = 47;
+ e.classname = "particlespray";
+ e.classtype = CT_MISC_PARTICLESPRAY;
+ base_mapentity_init (e);

- if (this.count <= 0)
- this.count = 15;
+ if (!e.color)
+ e.color = 47;

- if (this.delay <= 0)
- this.delay = 0.1;
+ if (e.count <= 0)
+ e.count = 15;

- if (this.noise != "")
- precache_sound (this.noise);
+ if (e.delay <= 0)
+ e.delay = 0.1;
+
+ if (e.noise != "")
+ precache_sound (e.noise);
precache_sound ("misc/null.wav");

- if (!this.targetname)
- this.nextthink = time + 0.1 + this.delay;
+ e.think = misc_particlespray_think;
+
+ if (!e.targetname)
+ e.nextthink = time + 0.1 + e.delay;
+ else
+ e.use = misc_particlespray_use;
};

//--------------------------------------------------------------
void() misc_particlespray =
{
- this.classname = "particlespray";
- this.classtype = CT_MISC_PARTICLESPRAY;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ misc_particlespray_init (self);
};
-};
+// };

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

Diff qc/misc/play.qc

diff --git a/qc/misc/play.qc b/qc/misc/play.qc
index 6fd9ca1..ad8b49d 100644
--- a/qc/misc/play.qc
+++ b/qc/misc/play.qc
@@ -9,71 +9,154 @@
// Distributed (unsupported) on 3.12.97
//======================================================================

-class base_play_sound: base_mapentity
-{
+//======================================================================
+// forward declarations
+//======================================================================
+
+// base_play_sound
+void() base_play_sound_think;
+void() base_play_sound_use;
+void(entity e) base_play_sound_init;
+strip void() base_play_sound;
+
+// play_sound_triggered
+void(entity e) play_sound_triggered_init;
+void() play_sound_triggered;
+
+// play_sound
+void(entity e) play_sound_init;
+void() play_sound;
+
+// base_tele_fog
+void() base_tele_fog_use;
+void(entity e) base_tele_fog_init;
+
+// tele_fog
+void(entity e) tele_fog_init;
+void() tele_fog;
+
+// play_tele
+void(entity e) play_tele_init;
+void() play_tele;
+
+// play_explosion
+void() play_explosion_use;
+void(entity e) play_explosion_init;
+void() play_explosion;
+
+// play_lavasplash
+void() play_lavasplash_use;
+void(entity e) play_lavasplash_init;
+void() play_lavasplash;
+
+// base_meat_shower
+void() base_meat_shower_use;
+void(entity e) base_meat_shower_init;
+
+// meat_shower
+void(entity e) meat_shower_init;
+void() meat_shower;
+
+// play_gibs
+void(entity e) play_gibs_init;
+void() play_gibs;
+
+// play_mflash
+void() play_mflash_use;
+void(entity e) play_mflash_init;
+void() play_mflash;
+
+// play_bfield
+void() play_bfield_use
+void(entity e) play_bfield_init;
+void() play_bfield;
+
+// play_brlight
+void() play_brlight_use;
+void(entity e) play_brlight_init;
+void() play_brlight;
+
+// play_dimlight
+void() play_dimlight_use;
+void(entity e) play_dimlight_init;
+void() play_dimlight;
+
+//------------------------------------------------------------------------------
+
+//----------------------------------------------------------------------
+// class base_play_sound: base_mapentity
+// {
//--------------------------------------------------------------
- // was play_sound_think -- CEV
+ // was PlaySoundThink -- CEV
//--------------------------------------------------------------
- virtual void() do_think =
+ void() base_play_sound_think =
{
local float t;
- t = this.wait * random ();
+ t = self.wait * random ();

- if (t < this.delay)
- t = this.delay;
+ if (t < self.delay)
+ t = self.delay;

- this.nextthink = time + t;
- this.do_use (other);
+ self.nextthink = time + t;
+ base_play_sound_use ();
};

//--------------------------------------------------------------
- virtual void(entity caller) do_use =
+ // was play_sound_use -- CEV
+ //--------------------------------------------------------------
+ void() base_play_sound_use =
{
- if (this.spawnflags & 1)
+ if (self.spawnflags & 1)
{
- if (this.state == 0)
+ if (self.state == 0)
{
- this.state = 1;
- sound (this, this.impulse, this.noise,
- this.volume, this.speed);
+ self.state = 1;
+ sound (self, self.impulse, self.noise,
+ self.volume, self.speed);
}
else
{
- this.state = 0;
- sound (this, this.impulse, "misc/null.wav",
- this.volume, this.speed);
+ self.state = 0;
+ sound (self, self.impulse, "misc/null.wav",
+ self.volume, self.speed);
}
}
else
{
- sound (this, this.impulse, this.noise,
- this.volume, this.speed);
+ sound (self, self.impulse, self.noise,
+ self.volume, self.speed);
}
};

//--------------------------------------------------------------
- nonvirtual void() play_sound_init =
+ // was play_sound_triggered -- CEV
+ //--------------------------------------------------------------
+ void(entity e) base_play_sound_init =
{
- precache_sound (this.noise);
+ base_mapentity_init (e);
+
+ precache_sound (e.noise);
precache_sound ("misc/null.wav");
- if (this.volume == 0)
- this.volume = 1;
- if (this.speed == 0)
- this.speed = 1;
- if (this.speed == -1)
- // this.speed = 0;
- this.speed = ATTN_NONE;
- if (this.spawnflags & 1)
- if (this.impulse == 0)
- this.impulse = 7;
+ if (e.volume == 0)
+ e.volume = 1;
+ if (e.speed == 0)
+ e.speed = 1;
+ if (e.speed == -1)
+ // e.speed = 0;
+ e.speed = ATTN_NONE;
+ if (e.spawnflags & 1)
+ if (e.impulse == 0)
+ e.impulse = 7;
+
+ e.use = base_play_sound_use;
};

//--------------------------------------------------------------
- void() base_play_sound =
+ strip void() base_play_sound =
{
- this.interaction_flags |= DISABLE_THINK;
+ base_play_sound_init (self);
};
-};
+// };

/*QUAKED play_sound_triggered (0.3 0.1 0.6) (-8 -8 -8) (8 8 8) toggle
play a sound when it is used
@@ -87,27 +170,36 @@ play a sound when it is used
2 - idle
3 - static
*/
-class play_sound_triggered: base_play_sound
-{
+//----------------------------------------------------------------------
+// class play_sound_triggered: base_play_sound
+// {
//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) play_sound_triggered_init =
{
+ e.classname = "play_sound_triggered";
+ e.classtype = CT_MISC_PLAY_SOUND_TRIGGERED;
+
// dumptruck_ds
- if (!this.noise)
+ if (!e.noise)
{
objerror ("no soundfile set in noise!\n");
- remove (this);
+ remove (e);
return;
}
- play_sound_init ();
+
+ base_play_sound_init (e);
};

//--------------------------------------------------------------
void() play_sound_triggered =
{
- this.classtype = CT_MISC_PLAY_SOUND_TRIGGERED;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ play_sound_triggered_init (self);
};
-};
+// };

/*QUAKED play_sound (0.3 0.1 0.6) (-8 -8 -8) (8 8 8)
play a sound on a periodic basis
@@ -122,53 +214,66 @@ play a sound on a periodic basis
2 - idle
3 - static
*/
-class play_sound: base_play_sound
-{
+//----------------------------------------------------------------------
+// class play_sound: base_play_sound
+// {
//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) play_sound_init =
{
+ e.classname = "play_sound";
+ e.classtype = CT_MISC_PLAY_SOUND;
+
// dumptruck_ds
- if (!this.noise)
+ if (!e.noise)
{
objerror ("no soundfile set in noise!\n");
- remove (this);
+ remove (e);
return;
}

- play_sound_init ();
+ base_play_sound_init (e);

- if (this.wait == 0)
- this.wait = 20;
- if (this.delay == 0)
- this.delay = 2;
+ if (e.wait == 0)
+ e.wait = 20;
+ if (e.delay == 0)
+ e.delay = 2;

- // enable think function
- this.interaction_flags &= ~DISABLE_THINK;
+ local float t = e.wait * random ();
+ if (t < e.delay)
+ t = e.delay;

- local float t = this.wait * random ();
- if (t < this.delay)
- t = this.delay;
-
- this.nextthink = time + t;
+ e.think = base_play_sound_think;
+ e.nextthink = time + t;
};

//--------------------------------------------------------------
void() play_sound =
{
- this.classtype = CT_MISC_PLAY_SOUND;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ play_sound_init (self);
};
-};
+// };

-class base_tele_fog: base_mapentity
-{
+//----------------------------------------------------------------------
+// class base_tele_fog: base_mapentity
+// {
//--------------------------------------------------------------
- virtual void(entity caller) do_use =
+ void() base_tele_fog_use =
{
// thanks Khreathor -- dumptruck_ds
- spawn_tfog (this.origin);
+ spawn_tfog (self.origin);
};

-};
+ //--------------------------------------------------------------
+ void(entity e) base_tele_fog_init =
+ {
+ base_mapentity_init (e);
+ e.use = base_tele_fog_use;
+ };
+// };

/*QUAKED tele_fog (0.3 0.1 0.6) (-10 -10 -8) (10 10 8)

@@ -177,18 +282,28 @@ When triggered, tele_fog shows the teleport particle effects and sounds.
Use this when killtageting an entity if the player can see.

*/
-class tele_fog: base_tele_fog
-{
+//----------------------------------------------------------------------
+// class tele_fog: base_tele_fog
+// {
//--------------------------------------------------------------
- virtual void() init_spawned = { };
+ void(entity e) tele_fog_init =
+ {
+ e.classname = "tele_fog";
+ e.classtype = CT_MISC_TELE_FOG;
+
+ base_tele_fog_init (e);
+ };

//--------------------------------------------------------------
void() tele_fog =
{
- this.classtype = CT_MISC_TELE_FOG;
- };
-};
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;

+ tele_fog_init (self);
+ };
+// };

/*QUAKED play_tele (0.3 0.1 0.6) (-10 -10 -8) (10 10 8)

@@ -198,47 +313,72 @@ Same os tele_fog.
Use this when killtageting an entity if the player can see.

*/
-class play_tele: base_tele_fog
-{
+//----------------------------------------------------------------------
+// class play_tele: base_tele_fog
+// {
//--------------------------------------------------------------
- virtual void() init_spawned = { };
+ void(entity e) play_tele_init =
+ {
+ // same as tele_fog, added for "play_xxxx" consistancy
+ e.classname = "tele_fog";
+ // use same classtype as tele_fog () -- CEV
+ e.classtype = CT_MISC_TELE_FOG;
+
+ base_tele_fog_init (e);
+ };

//--------------------------------------------------------------
void() play_tele =
{
- // same as tele_fog, added for "play_xxxx" consistancy
- this.classname = "tele_fog";
- // use same classtype as tele_fog () -- CEV
- this.classtype = CT_MISC_TELE_FOG;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ play_tele_init (self);
};
-};
+// };

/*QUAKED play_explosion (0.3 0.1 0.6) (-10 -10 -8) (10 10 8)

When triggered, creates a explosion at it's origin. Causes damage.

*/
-class play_explosion: base_mapentity
-{
+//----------------------------------------------------------------------
+// class play_explosion: base_mapentity
+// {
//--------------------------------------------------------------
- virtual void(entity caller) do_use =
+ // was play_explosion_fx -- CEV
+ //--------------------------------------------------------------
+ void() play_explosion_use =
{
// thanks Khreathor -- dumptruck_ds
- t_radiusdamage2 (this, this, 120, world);
- base_explosion::write_explosion (this.origin);
- spawn (base_explosion, origin: this.origin);
- remove (this);
+ t_radiusdamage2 (self, self, 120, world);
+ write_explosion (self.origin);
+ spawn_base_explosion (self.origin);
+ remove (self);
};

//--------------------------------------------------------------
- virtual void() init_spawned = { };
+ void(entity e) play_explosion_init =
+ {
+ e.classname = "play_explosion";
+ e.classtype = CT_MISC_PLAY_EXPLOSION;
+
+ base_mapentity_init (e);
+
+ e.use = play_explosion_use;
+ };

//--------------------------------------------------------------
void() play_explosion =
{
- this.classtype = CT_MISC_PLAY_EXPLOSION;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ play_explosion_init (self);
};
-};
+// };

/*QUAKED play_lavasplash (0.3 0.1 0.6) (-10 -10 -8) (10 10 8)

@@ -247,73 +387,93 @@ When triggered, plays the lavasplash effect from E1M7.
Use noise key for a custom sound.

*/
-class play_lavasplash: base_mapentity
-{
+//----------------------------------------------------------------------
+// class play_lavasplash: base_mapentity
+// {
//--------------------------------------------------------------
- virtual void(entity caller) do_use =
+ void() play_lavasplash_use =
{
// thanks Khreathor -- dumptruck_ds
- if (this.noise != "")
- sound (this, CHAN_AUTO, this.noise, 1, ATTN_NORM);
+ if (self.noise != "")
+ sound (self, CHAN_AUTO, self.noise, 1, ATTN_NORM);
else
- sound (this, CHAN_AUTO, "boss1/out1.wav", 1, ATTN_NORM);
+ sound (self, CHAN_AUTO, "boss1/out1.wav", 1, ATTN_NORM);

WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
WriteByte (MSG_BROADCAST, TE_LAVASPLASH);
- WriteCoord (MSG_BROADCAST, this.origin_x);
- WriteCoord (MSG_BROADCAST, this.origin_y);
- WriteCoord (MSG_BROADCAST, this.origin_z);
+ WriteCoord (MSG_BROADCAST, self.origin_x);
+ WriteCoord (MSG_BROADCAST, self.origin_y);
+ WriteCoord (MSG_BROADCAST, self.origin_z);
};

//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) play_lavasplash_init =
{
- if (this.noise != "")
- precache_sound (this.noise);
+ e.classname = "play_lavasplash";
+ e.classtype = CT_MISC_PLAY_LAVASPLASH;
+
+ base_mapentity_init (e);
+
+ if (e.noise != "")
+ precache_sound (e.noise);

precache_sound("boss1/out1.wav");
+
+ e.use = play_lavasplash_use;
};

//--------------------------------------------------------------
void() play_lavasplash =
{
- this.classtype = CT_MISC_PLAY_LAVASPLASH;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ play_lavasplash_init (self);
};
-};
+// };

-class base_meat_shower: base_mapentity
-{
+//----------------------------------------------------------------------
+// class base_meat_shower: base_mapentity
+// {
//--------------------------------------------------------------
- virtual void(entity caller) do_use =
+ void() base_meat_shower_use =
{
// -- dumptruck_ds -- thanks to Spike for helping with errors
- if (this.style == 1)
+ if (self.style == 1)
{
- ThrowGib ("progs/gib1.mdl", random() * -80);
- ThrowGib ("progs/gib2.mdl", random() * -80);
- ThrowGib ("progs/gib3.mdl", random() * -80);
- ThrowGib ("progs/gib1.mdl", random() * -75);
- ThrowGib ("progs/gib2.mdl", random() * -75);
- ThrowGib ("progs/gib3.mdl", random() * -75);
+ throw_gib ("progs/gib1.mdl", random() * -80);
+ throw_gib ("progs/gib2.mdl", random() * -80);
+ throw_gib ("progs/gib3.mdl", random() * -80);
+ throw_gib ("progs/gib1.mdl", random() * -75);
+ throw_gib ("progs/gib2.mdl", random() * -75);
+ throw_gib ("progs/gib3.mdl", random() * -75);
}
else
{
- ThrowGib ("progs/gib1.mdl", random() * -65);
- ThrowGib ("progs/gib2.mdl", random() * -65);
- ThrowGib ("progs/gib3.mdl", random() * -65);
+ throw_gib ("progs/gib1.mdl", random() * -65);
+ throw_gib ("progs/gib2.mdl", random() * -65);
+ throw_gib ("progs/gib3.mdl", random() * -65);
}

- if (this.fly_sound != 1)
+ if (self.fly_sound != 1)
return;

if (random() < 0.5)
- sound (this, CHAN_VOICE, "player/gib.wav",
+ sound (self, CHAN_VOICE, "player/gib.wav",
1, ATTN_NORM);
else
- sound (this, CHAN_VOICE, "player/udeath.wav",
+ sound (self, CHAN_VOICE, "player/udeath.wav",
1, ATTN_NORM);
};
-};
+
+ //--------------------------------------------------------------
+ void(entity e) base_meat_shower_init =
+ {
+ base_mapentity_init (e);
+ e.use = base_meat_shower_use;
+ };
+// };

/*QUAKED meat_shower (0.3 0.1 0.6) (-10 -10 -8) (10 10 8)

@@ -322,17 +482,28 @@ When triggered, plays a gib effect.
Use style 0 for normal and 1 for extra large. fly_sound 0 is silent, 1 for regular gib sounds.

*/
-class meat_shower: base_meat_shower
-{
+//----------------------------------------------------------------------
+// class meat_shower: base_meat_shower
+// {
//--------------------------------------------------------------
- virtual void() init_spawned = { };
+ void(entity e) meat_shower_init =
+ {
+ e.classname = "meat_shower";
+ e.classtype = CT_MISC_PLAY_GIBS;
+
+ base_meat_shower_init (e);
+ };

//--------------------------------------------------------------
void() meat_shower =
{
- this.classtype = CT_MISC_PLAY_GIBS;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ meat_shower_init (self);
};
-};
+// };

/*QUAKED play_gibs (0.3 0.1 0.6) (-10 -10 -8) (10 10 8)

@@ -341,193 +512,252 @@ When triggered, plays a gib effect. Same as meat_shower.
Use style 0 for normal and 1 for extra large. fly_sound 0 is silent, 1 for regular gib sounds.

*/
-class play_gibs: base_meat_shower
-{
+//----------------------------------------------------------------------
+// class play_gibs: base_meat_shower
+// {
//--------------------------------------------------------------
- virtual void() init_spawned = { };
+ void(entity e) play_gibs_init =
+ {
+ // same as meat_shower, added for "play_xxxx" consistancy
+ e.classname = "play_gibs";
+ e.classtype = CT_MISC_PLAY_GIBS;
+
+ base_meat_shower_init (e);
+ };

//--------------------------------------------------------------
void() play_gibs =
{
- // same as meat_shower, added for "play_xxxx" consistancy
- this.classtype = CT_MISC_PLAY_GIBS;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ play_gibs_init (self);
};
-};
+// };

/*QUAKED play_mflash (0 .5 .8) (-8 -8 -8) (8 8 8)
triggable muzzle flash effect entity
*/
-class play_mflash: base_mapentity
-{
+//----------------------------------------------------------------------
+// class play_mflash: base_mapentity
+// {
//--------------------------------------------------------------
- virtual void(entity caller) do_use =
+ void() play_mflash_use =
{
- this.effects = this.effects | EF_MUZZLEFLASH;
+ self.effects = self.effects | EF_MUZZLEFLASH;

- if (this.noise != "")
- sound (this, CHAN_AUTO, this.noise, 1, ATTN_NORM);
+ if (self.noise != "")
+ sound (self, CHAN_AUTO, self.noise, 1, ATTN_NORM);
};

//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) play_mflash_init =
{
+ e.classname = "play_mflash";
+ e.classtype = CT_MISC_PLAY_MFLASH;
+
+ base_mapentity_init (e);
+
precache_model ("progs/s_null.spr");
- if (this.noise != "")
- precache_sound (this.noise);
+ if (e.noise != "")
+ precache_sound (e.noise);

- setmodel (this, "progs/s_null.spr");
- setorigin (this, this.origin);
- this.movetype = MOVETYPE_NONE;
- this.solid = SOLID_NOT;
- setsize (this, '0 0 0', '0 0 0');
+ setmodel (e, "progs/s_null.spr");
+ setorigin (e, e.origin);
+ e.movetype = MOVETYPE_NONE;
+ e.solid = SOLID_NOT;
+ setsize (e, '0 0 0', '0 0 0');
+
+ e.use = play_mflash_use;
};

//--------------------------------------------------------------
void() play_mflash =
{
- this.classtype = CT_MISC_PLAY_MFLASH;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ play_mflash_init (self);
};
-};
+// };

/*QUAKED play_bfield (0 .5 .8) (-8 -8 -8) (8 8 8)
a triggerable, spherical field of yellow particles
state 1 = start on
*/
-class play_bfield: base_mapentity
-{
+//----------------------------------------------------------------------
+// class play_bfield: base_mapentity
+// {
//--------------------------------------------------------------
- virtual void(entity caller) do_use =
+ void() play_bfield_use =
{
- if (!this.state)
+ if (!self.state)
{
- this.state = 1;
- this.effects = this.effects | EF_BRIGHTFIELD;
- sound (this, CHAN_AUTO, this.noise, 1, ATTN_NORM);
+ self.state = 1;
+ self.effects = self.effects | EF_BRIGHTFIELD;
+ sound (self, CHAN_AUTO, self.noise, 1, ATTN_NORM);
}
else
{
- this.state = 0;
- this.effects = this.effects -
- (this.effects & EF_BRIGHTFIELD);
- sound (this, CHAN_AUTO, this.noise, 1, ATTN_NORM);
+ self.state = 0;
+ self.effects = self.effects -
+ (self.effects & EF_BRIGHTFIELD);
+ sound (self, CHAN_AUTO, self.noise, 1, ATTN_NORM);
}
};

//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) play_bfield_init =
{
- precache_model ("progs/s_null.spr");
- if (this.noise != "")
- precache_sound (this.noise);
+ e.classname = "play_bfield";
+ e.classtype = CT_MISC_PLAY_BFIELD;
+
+ base_mapentity_init (e);

- setmodel (this, "progs/s_null.spr");
- setorigin (this, this.origin);
- this.movetype = MOVETYPE_NONE;
- this.solid = SOLID_NOT;
- setsize (this, '0 0 0', '0 0 0');
- if (this.state)
- this.effects = this.effects | EF_BRIGHTFIELD;
+ precache_model ("progs/s_null.spr");
+ if (e.noise != "")
+ precache_sound (e.noise);
+
+ setmodel (e, "progs/s_null.spr");
+ setorigin (e, e.origin);
+ e.movetype = MOVETYPE_NONE;
+ e.solid = SOLID_NOT;
+ setsize (e, '0 0 0', '0 0 0');
+ if (e.state)
+ e.effects = e.effects | EF_BRIGHTFIELD;
+
+ e.use = play_bfield_use;
};

//--------------------------------------------------------------
void() play_bfield =
{
- this.classtype = CT_MISC_PLAY_BFIELD;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ play_bfield_init (self);
};
-};
+// };

/*QUAKED play_brlight (0 .5 .8) (-8 -8 -8) (8 8 8)
a triggerable bright lighting effect
state 1 = start on
*/
-class play_brlight: base_mapentity
-{
+//----------------------------------------------------------------------
+// class play_brlight: base_mapentity
+// {
//--------------------------------------------------------------
- virtual void(entity caller) do_use =
+ void() play_brlight_use =
{
// dumptruck_ds -- thanks to c0burn
- if (!this.state)
+ if (!self.state)
{
- this.state = 1;
- this.effects = this.effects | EF_BRIGHTLIGHT;
- sound (this, CHAN_AUTO, this.noise, 1, ATTN_NORM);
+ self.state = 1;
+ self.effects = self.effects | EF_BRIGHTLIGHT;
+ sound (self, CHAN_AUTO, self.noise, 1, ATTN_NORM);
}
else
{
- this.state = 0;
- this.effects = this.effects -
- (this.effects & EF_BRIGHTLIGHT);
- sound (this, CHAN_AUTO, this.noise, 1, ATTN_NORM);
+ self.state = 0;
+ self.effects = self.effects -
+ (self.effects & EF_BRIGHTLIGHT);
+ sound (self, CHAN_AUTO, self.noise, 1, ATTN_NORM);
}
};

//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) play_brlight_init =
{
- precache_model ("progs/s_null.spr");
- if (this.noise != "")
- precache_sound (this.noise);
+ e.classname = "play_brlight";
+ e.classtype = CT_MISC_PLAY_BRLIGHT;

- setmodel (this, "progs/s_null.spr");
- setorigin (this, this.origin);
- this.movetype = MOVETYPE_NONE;
- this.solid = SOLID_NOT;
- setsize (this, '0 0 0', '0 0 0');
- if (this.state)
- this.effects = this.effects | EF_BRIGHTLIGHT;
+ base_mapentity_init (e);
+
+ precache_model ("progs/s_null.spr");
+ if (e.noise != "")
+ precache_sound (e.noise);
+
+ setmodel (e, "progs/s_null.spr");
+ setorigin (e, e.origin);
+ e.movetype = MOVETYPE_NONE;
+ e.solid = SOLID_NOT;
+ setsize (e, '0 0 0', '0 0 0');
+ if (e.state)
+ e.effects = e.effects | EF_BRIGHTLIGHT;
+
+ e.use = play_brlight_use;
};

//--------------------------------------------------------------
void() play_brlight =
{
- this.classtype = CT_MISC_PLAY_BRLIGHT;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ play_brlight_init (self);
};
-};
+// };

/*QUAKED play_dimlight (0 .5 .8) (-8 -8 -8) (8 8 8)
a triggerable lighting effect
state 1 = start on
*/
-class play_dimlight: base_mapentity
-{
+//----------------------------------------------------------------------
+// class play_dimlight: base_mapentity
+// {
//--------------------------------------------------------------
- virtual void(entity caller) do_use =
+ void() play_dimlight_use =
{
- if (!this.state)
+ if (!self.state)
{
- this.state = 1;
- this.effects = this.effects | EF_DIMLIGHT;
- sound (this, CHAN_AUTO, this.noise, 1, ATTN_NORM);
+ self.state = 1;
+ self.effects = self.effects | EF_DIMLIGHT;
+ sound (self, CHAN_AUTO, self.noise, 1, ATTN_NORM);
}
else
{
- this.state = 0;
- this.effects = this.effects -
- (this.effects & EF_DIMLIGHT);
- sound (this, CHAN_AUTO, this.noise, 1, ATTN_NORM);
+ self.state = 0;
+ self.effects = self.effects -
+ (self.effects & EF_DIMLIGHT);
+ sound (self, CHAN_AUTO, self.noise, 1, ATTN_NORM);
}
};

//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) play_dimlight_init =
{
- precache_model ("progs/s_null.spr");
- if (this.noise != "")
- precache_sound (this.noise);
+ e.classname = "play_dimlight";
+ e.classtype = CT_MISC_PLAY_DIMLIGHT;
+
+ base_mapentity_init (e);

- setmodel (this, "progs/s_null.spr");
- // setorigin (this, this.origin);
- this.movetype = MOVETYPE_NONE;
- this.solid = SOLID_NOT;
- setsize (this, '0 0 0', '0 0 0');
- if (this.state)
- this.effects = this.effects | EF_DIMLIGHT;
- setorigin (this, this.origin);
+ precache_model ("progs/s_null.spr");
+ if (e.noise != "")
+ precache_sound (e.noise);
+
+ setmodel (e, "progs/s_null.spr");
+ // setorigin (e, e.origin);
+ e.movetype = MOVETYPE_NONE;
+ e.solid = SOLID_NOT;
+ setsize (e, '0 0 0', '0 0 0');
+ if (e.state)
+ e.effects = e.effects | EF_DIMLIGHT;
+ setorigin (e, e.origin);
+
+ e.use = play_dimlight_use;
};

//--------------------------------------------------------------
void() play_dimlight =
{
- this.classtype = CT_MISC_PLAY_DIMLIGHT;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ play_dimlight_init (self);
};
-};
+// };

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

Diff qc/misc/sparks.qc

diff --git a/qc/misc/sparks.qc b/qc/misc/sparks.qc
index 43335b4..96421ab 100644
--- a/qc/misc/sparks.qc
+++ b/qc/misc/sparks.qc
@@ -2,78 +2,117 @@
// misc_sparks -- selections from Rubicon 2 qc by john fitzgibbons
//==============================================================================

+//======================================================================
// constants
+//======================================================================
+
const float MISC_SPARKS_START_OFF = 1;
const float MISC_SPARKS_BLUE = 2;
const float MISC_SPARKS_PALE = 4;

enum
{
- TEMP_SPARK_FADE1,
+ TEMP_SPARK_FADE1, // animation states for temp_spark
TEMP_SPARK_FADE2,
TEMP_SPARK_FADE3,
TEMP_SPARK_FADE4,
- TEMP_SPARK_REMOVE,
- MISC_SPARKS_OFFLIGHT,
- MISC_SPARKS_MAKE
+ TEMP_SPARK_REMOVE
};

+//======================================================================
+// forward declarations
+//======================================================================
+
+// temp_spark
+void() temp_spark_think;
+entity(entity own, vector org, float sflags) spawn_temp_spark;
+void(entity e) temp_spark_init;
+strip void() temp_spark;
+
+// misc_sparks
+void() misc_sparks_think_make;
+void() misc_sparks_think_turnofflight;
+void() misc_sparks_use;
+void(entity e) misc_sparks_init;
+void() misc_sparks;
+
//------------------------------------------------------------------------------
-// temp_spark - an individual spark - from Rubicon2, refactored by CEV
-//------------------------------------------------------------------------------
-class temp_spark: base_tempentity
-{
- float think_state;

+//----------------------------------------------------------------------
+// temp_spark - an individual spark - from Rubicon2, refactored by CEV
+//----------------------------------------------------------------------
+// class temp_spark: base_tempentity
+// {
//--------------------------------------------------------------
- virtual void() do_think =
+ void() temp_spark_think =
{
- if (this.think_state == TEMP_SPARK_REMOVE)
+ if (self.state == TEMP_SPARK_REMOVE)
{
- remove (this);
+ remove (self);
return;
}

- this.alpha -= 0.2;
- this.think_state += 1;
- this.nextthink = time + 0.05;
+ self.alpha -= 0.2;
+ self.state += 1;
+ self.nextthink = time + 0.05;
};

//--------------------------------------------------------------
- void() temp_spark =
+ entity(entity own, vector org, float sflags) spawn_temp_spark =
{
- this.classname = "spark";
- this.classtype = CT_TEMP_SPARK;
-
- this.movetype = MOVETYPE_BOUNCE;
- this.solid = SOLID_TRIGGER;
- this.alpha = 1.0;
- this.gravity = 0.3;
- this.velocity_x = -40 + random() * 80;
- this.velocity_y = -40 + random() * 80;
- this.velocity_z = -40 + random() * 80;
- this.avelocity = '3000 3000 3000';
+ local entity e = spawn ();
+ e.owner = own;
+ e.origin = org;
+ e.spawnflags = sflags;
+ temp_spark_init (e);
+ return e;
+ };
+
+ //--------------------------------------------------------------
+ void(entity e) temp_spark_init =
+ {
+ e.classname = "spark";
+ e.classtype = CT_TEMP_SPARK;
+ // TODO CEV set classgroup directly to save a function call
+ // base_tempentity_init (e);
+ e.classgroup |= CG_TEMPENTITY;
+
+ e.movetype = MOVETYPE_BOUNCE;
+ e.solid = SOLID_TRIGGER;
+ e.alpha = 1.0;
+ e.gravity = 0.3;
+ e.velocity_x = -40 + random() * 80;
+ e.velocity_y = -40 + random() * 80;
+ e.velocity_z = -40 + random() * 80;
+ e.avelocity = '3000 3000 3000';

if (random() < 0.33)
- this.skin = 0;
+ e.skin = 0;
else if (random() < 0.5)
- this.skin = 1;
+ e.skin = 1;
else
- this.skin = 2;
+ e.skin = 2;

- if (this.spawnflags & MISC_SPARKS_PALE)
- this.skin = this.skin + 6;
- else if (this.spawnflags & MISC_SPARKS_BLUE)
- this.skin = this.skin + 3;
+ if (e.spawnflags & MISC_SPARKS_PALE)
+ e.skin = e.skin + 6;
+ else if (e.spawnflags & MISC_SPARKS_BLUE)
+ e.skin = e.skin + 3;

- setmodel (this, "progs/spark.mdl");
- setorigin (this, this.origin);
- setsize (this, '0 0 0', '0 0 0');
+ setmodel (e, "progs/spark.mdl");
+ setorigin (e, e.origin);
+ setsize (e, '0 0 0', '0 0 0');

- this.think_state = TEMP_SPARK_FADE1;
- this.nextthink = time + 0.5 + 1.5 * random();
+ e.state = TEMP_SPARK_FADE1;
+ e.think = temp_spark_think;
+ e.nextthink = time + 0.5 + 1.5 * random();
};
-};
+
+ //--------------------------------------------------------------
+ strip void() temp_spark =
+ {
+ temp_spark_init (self);
+ };
+// };

/*QUAKED misc_sparks (0 .5 .8) (-8 -8 -8) (8 8 8) MISC_SPARKS_START_OFF MISC_SPARKS_BLUE MISC_SPARKS_PALE X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY

@@ -93,106 +132,93 @@ Keys:
0) no sound
1) sparks
*/
-class misc_sparks: base_mapentity
-{
- float think_state;
-
+//----------------------------------------------------------------------
+// class misc_sparks: base_mapentity
+// {
//--------------------------------------------------------------
- virtual void() do_think =
+ void() misc_sparks_think_make =
{
- if (this.think_state == MISC_SPARKS_OFFLIGHT)
+ if (self.spawnflags & MISC_SPARKS_START_OFF)
{
- // was spark_turnofflight -- CEV
- sub_usetargets ();
- this.think_state = MISC_SPARKS_MAKE;
- this.nextthink = time + (random() + 0.5) *
- this.wait - 0.15;
+ self.think = misc_sparks_think_make;
+ self.nextthink = time + 0.1;
+ return;
}
- else if (this.think_state == MISC_SPARKS_MAKE)
+
+ local float i;
+ i = -0.25 * self.cnt + random() * 0.5 * self.cnt;
+ while (i < self.cnt)
{
- // was make_sparks -- CEV
- this.make_sparks ();
+ spawn_temp_spark (self, self.origin, self.spawnflags);
+ i++;
}
+
+ if (self.sounds == 1)
+ if (self.noise != "")
+ sound (self, CHAN_AUTO, self.noise,
+ 1, ATTN_STATIC);
+ else
+ sound (self, CHAN_AUTO, "enforcer/enfstop.wav",
+ 1, ATTN_STATIC);
+
+ sub_usetargets ();
+ self.think = misc_sparks_think_turnofflight;
+ self.nextthink = time + 0.1 + random() * 0.1;
};

//--------------------------------------------------------------
- virtual void(entity caller) do_use =
+ void() misc_sparks_think_turnofflight =
{
-
- if (this.spawnflags & MISC_SPARKS_START_OFF)
- {
- this.interaction_flags &= ~DISABLE_THINK;
- this.nextthink = time + random() * 0.1;
- }
- else
- {
- this.interaction_flags |= DISABLE_THINK;
- }
+ sub_usetargets ();
+ self.think = misc_sparks_think_make;
+ self.nextthink = time + (random() + 0.5) * self.wait - 0.15;
};

//--------------------------------------------------------------
- nonvirtual void() make_sparks =
+ void() misc_sparks_use =
{
- local float i;
- i = -0.25 * this.cnt + random() * 0.5 * this.cnt;
- while (i < this.cnt)
- {
- local temp_spark spark;
- spark = spawn (temp_spark,
- owner: this,
- spawnflags: this.spawnflags,
- origin: this.origin);
-
- i = i + 1;
- }

- if (this.sounds == 1)
- if (this.noise != "")
- sound (this, CHAN_AUTO, this.noise,
- 1, ATTN_STATIC);
- else
- sound (this, CHAN_AUTO, "enforcer/enfstop.wav",
- 1, ATTN_STATIC);
-
- sub_usetargets ();
- this.think_state = MISC_SPARKS_OFFLIGHT;
- this.nextthink = time + 0.1 + random() * 0.1;
+ if (self.spawnflags & MISC_SPARKS_START_OFF)
+ self.spawnflags &= ~MISC_SPARKS_START_OFF;
+ else
+ self.spawnflags |= MISC_SPARKS_START_OFF;
};

//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) misc_sparks_init =
{
+ e.classname = "misc_sparks";
+ e.classtype = CT_MISC_SPARKS;
+ base_mapentity_init (e);
+
precache_model ("progs/spark.mdl");

- if (!this.noise)
+ if (!e.noise)
precache_sound ("dump/spark.wav");
else
- precache_sound (this.noise);
+ precache_sound (e.noise);

- if (!this.movedir)
- this.movedir = '0 0 -30';
+ if (!e.movedir)
+ e.movedir = '0 0 -30';

- if (!this.wait)
- this.wait = 2;
+ if (!e.wait)
+ e.wait = 2;

- if (!this.cnt)
- this.cnt = 15;
+ if (!e.cnt)
+ e.cnt = 15;

- this.think_state = MISC_SPARKS_MAKE;
-
- if (this.spawnflags & MISC_SPARKS_START_OFF)
- {
- this.interaction_flags |= DISABLE_THINK;
- }
- else
- {
- this.nextthink = time + random() * 0.1;
- }
+ e.use = misc_sparks_use;
+ e.think = misc_sparks_think_make;
+ e.nextthink = time + random() * 0.1;
};

//--------------------------------------------------------------
void() misc_sparks =
{
- this.classtype = CT_MISC_SPARKS;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ misc_sparks_init (self);
};
-};
+// };

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

Diff qc/misc/target_autosave.qc

diff --git a/qc/misc/target_autosave.qc b/qc/misc/target_autosave.qc
index bf46132..7bb2ef6 100644
--- a/qc/misc/target_autosave.qc
+++ b/qc/misc/target_autosave.qc
@@ -2,6 +2,19 @@
// target_autosave -- from Copper
//==============================================================================

+//======================================================================
+// forward declarations
+//======================================================================
+
+// target_autosave
+void(entity client, string savename) target_autosave_save;
+void() target_autosave_toggle; // not used? -- CEV
+void() target_autosave_use;
+void(entity e) target_autosave_init;
+void() target_autosave;
+
+//------------------------------------------------------------------------------
+
/*QUAKED target_autosave (1 .0 .5) (-8 -8 -8) (8 8 8)
Saves the game when triggered by a player. Never appears in multiplayer. the bprint tends to stomp any other prints on screen in most quake clients, so use a delayed trigger_relay if you fire this from an important pickup/trigger_counter/something else that puts text on screen more important than the autosave blurb.

@@ -16,12 +29,13 @@ the bprint tends to stomp any other prints on screen in most quake clients, so u
message(string) : "Change save filename" : "auto"
]
*/
-class target_autosave: base_mapentity
-{
+//----------------------------------------------------------------------
+// class target_autosave: base_mapentity
+// {
//--------------------------------------------------------------
// autosave -- was in client.qc
//--------------------------------------------------------------
- nonvirtual void(entity client, string savename) autosave =
+ void(entity client, string savename) target_autosave_save =
{
// autosavename = savename;
stuffcmd (client, "echo Autosaving...; wait; save ");
@@ -30,14 +44,14 @@ class target_autosave: base_mapentity
};

//--------------------------------------------------------------
- nonvirtual void() toggle_autosave =
+ void() target_autosave_toggle =
{
local entity e = world;
local float printed = FALSE;

do
{
- e = findfloat (e, ::classtype, CT_TARGET_AUTOSAVE);
+ e = findfloat (e, classtype, CT_TARGET_AUTOSAVE);
if (!e)
break;

@@ -64,23 +78,15 @@ class target_autosave: base_mapentity
};

//--------------------------------------------------------------
- // was target_autosave_delaythink
- //--------------------------------------------------------------
- virtual void() do_think =
- {
- this.do_use (other);
- };
-
- //--------------------------------------------------------------
- virtual void(entity caller) do_use =
+ void() target_autosave_use =
{
- if (this.estate != STATE_ACTIVE)
+ if (self.estate != STATE_ACTIVE)
return;

- if (this.enemy)
+ if (self.enemy)
{
- activator = this.enemy;
- this.enemy = world;
+ activator = self.enemy;
+ self.enemy = world;
}

if (activator.classtype != CT_PLAYER)
@@ -98,34 +104,43 @@ class target_autosave: base_mapentity
return;
}
*/
- this.enemy = activator;
- this.interaction_flags &= ~DISABLE_THINK;
- this.nextthink = 2;
+ self.enemy = activator;
+ self.think = target_autosave_use;
+ self.nextthink = 2;
return;
}

// sound(activator, CHAN_VOICE, "misc/sav.wav", 0.3, ATTN_NORM);
- autosave (activator, this.message);
+ target_autosave_save (activator, self.message);
};

//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) target_autosave_init =
{
- if (this.message == string_null)
- this.message = "auto";
+ e.classname = "target_autosave";
+ e.classtype = CT_TARGET_AUTOSAVE;
+ base_mapentity_init (e);
+
+ if (e.message == __NULL__ || e.message == "")
+ e.message = "auto";
+
// precache_sound2 ("misc/sav.wav");
- this.interaction_flags |= DISABLE_THINK;
+ e.use = target_autosave_use;
};

//--------------------------------------------------------------
void() target_autosave =
{
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
if (deathmatch || coop)
{
- remove (this);
+ remove (self);
return;
}

- this.classtype = CT_TARGET_AUTOSAVE;
+ target_autosave_init (self);
};
-};
+// };

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

Diff qc/misc/teleporttrain.qc

diff --git a/qc/misc/teleporttrain.qc b/qc/misc/teleporttrain.qc
index a47f301..85fe74c 100644
--- a/qc/misc/teleporttrain.qc
+++ b/qc/misc/teleporttrain.qc
@@ -3,7 +3,10 @@
// Code for the fixed teleporttrain written by c0burn and modified by ZungryWare
//==============================================================================

+//======================================================================
// constants
+//======================================================================
+
enum
{
TELEPORTTRAIN_NEXT,
@@ -11,6 +14,21 @@ enum
TELEPORTTRAIN_FIND
};

+//======================================================================
+// forward declarations
+//======================================================================
+
+// misc_teleporttrain
+void() misc_teleporttrain_calcmove;
+void() misc_teleporttrain_next;
+void() misc_teleporttrain_wait;
+void() misc_teleporttrain_find;
+void() misc_teleporttrain_use;
+void(entity e) misc_teleporttrain_init;
+void() misc_teleporttrain;
+
+//------------------------------------------------------------------------------
+
/*QUAKED misc_teleporttrain (.5 .5 .5) (-16 -16 -16) (16 16 16) X DONT_ROTATE START_ON_WITH_TARGETNAME INVISIBLE X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
{ model("progs/teleport.mdl"); }
This was used for the final boss level in the original game. In progs_dump you can use this as a moving decoration or even target it as a spawn point for a func_monster_spawner. Make sure and select the Don't Rotate spawnflag though or you'll experience a pretty hilarious effect!
@@ -30,203 +48,189 @@ Teleporter target for final boss level. Must target a series of 'path_corner' en
It will position itself on its first target at map load.
If a targetname is set, it must be triggered to start moving, otherwise it will start automatically.
*/
-class misc_teleporttrain: base_mapentity
-{
- float think_state;
-
+//----------------------------------------------------------------------
+// class misc_teleporttrain: base_mapentity
+// {
//--------------------------------------------------------------
- nonvirtual void() teleporttrain_calcmove =
+ void() misc_teleporttrain_calcmove =
{
local vector delta;
local float len, spd;

- if (this.enemy == world)
+ if (self.enemy == world)
{
- dprint ("misc_teleporttrain::teleporttrain_calcmove: "
- "enemy is world!\n");
+ dprint ("misc_teleporttrain_calcmove: enemy is "
+ "world!\n");
return;
}

- delta = (this.enemy.origin + '16 16 16') - this.origin;
+ delta = (self.enemy.origin + '16 16 16') - self.origin;
len = vlen (delta);
- spd = vlen (this.velocity);
- this.think_state = TELEPORTTRAIN_WAIT;
- if (this.ltime)
- this.nextthink = this.ltime + (len / spd);
+ spd = vlen (self.velocity);
+
+ self.think = misc_teleporttrain_wait;
+ if (self.ltime)
+ self.nextthink = self.ltime + (len / spd);
else
- this.nextthink = time + (len / spd);
+ self.nextthink = time + (len / spd);
};

//--------------------------------------------------------------
- nonvirtual void() teleporttrain_next =
+ void() misc_teleporttrain_next =
{
local vector dir;

- setorigin (this, this.enemy.origin + '16 16 16');
+ setorigin (self, self.enemy.origin + '16 16 16');

- if (!this.target)
+ if (!self.target)
{
- this.enemy = world;
+ self.enemy = world;
return;
}

- this.enemy = find (world, ::targetname, this.target);
- if (this.enemy.classtype == CT_PATH_CORNER)
+ self.enemy = find (world, targetname, self.target);
+ if (self.enemy.classtype == CT_PATH_CORNER)
{
- dir = normalize ((this.enemy.origin + '16 16 16') -
- this.origin);
- this.velocity = dir * this.speed;
- this.target = this.enemy.target;
+ dir = normalize ((self.enemy.origin + '16 16 16') -
+ self.origin);
+ self.velocity = dir * self.speed;
+ self.target = self.enemy.target;
}
else
{
- objerror ("misc_teleporttrain::teleporttrain_next: "
- "unable to find target");
- remove (this);
+ objerror ("misc_teleporttrain_next: unable to find "
+ "target\n");
+ remove (self);
return;
}

- teleporttrain_calcmove ();
+ misc_teleporttrain_calcmove ();
};

//--------------------------------------------------------------
- nonvirtual void() teleporttrain_wait =
+ void() misc_teleporttrain_wait =
{
local float wait_time;

- if (this.enemy != world && this.enemy.wait > 0)
- wait_time = this.enemy.wait;
+ if (self.enemy != world && self.enemy.wait > 0)
+ wait_time = self.enemy.wait;
else
wait_time = 0.1;

- this.velocity = '0 0 0';
- this.think_state = TELEPORTTRAIN_NEXT;
- if (this.ltime)
- this.nextthink = this.ltime + wait_time;
+ self.velocity = '0 0 0';
+
+ self.think = misc_teleporttrain_next;
+ if (self.ltime)
+ self.nextthink = self.ltime + wait_time;
else
- this.nextthink = time + wait_time;
+ self.nextthink = time + wait_time;
};

//--------------------------------------------------------------
- nonvirtual void() teleporttrain_find =
+ void() misc_teleporttrain_find =
{
// always start positioned on the first path_corner
- this.enemy = find (world, ::targetname, this.target);
- if (this.enemy.classtype == CT_PATH_CORNER)
+ self.enemy = find (world, targetname, self.target);
+ if (self.enemy.classtype == CT_PATH_CORNER)
{
- setorigin (this, this.enemy.origin + '16 16 16');
+ setorigin (self, self.enemy.origin + '16 16 16');
// if the path_corner has the same target we already
// have, then the train should stop. Fix for dmd8 -- CEV
- if (this.target == this.enemy.target)
+ if (self.target == self.enemy.target)
{
- this.interaction_flags |= DISABLE_THINK;
- this.interaction_flags |= DISABLE_TOUCH;
- this.interaction_flags |= DISABLE_USE;
+ self.think = sub_null;
+ self.touch = sub_null;
+ self.use = sub_null;
return;
}

// now set our target and continue
- this.target = this.enemy.target;
+ self.target = self.enemy.target;
}
else
{
- objerror ("unable to find target\n");
- remove (this);
+ objerror ("misc_teleporttrain_find: unable to find "
+ "target\n");
+ remove (self);
return;
}

- if (this.spawnflags & 4)
+ if (self.spawnflags & 4)
// start immediately even with a targetname
- teleporttrain_next ();
- else if (!this.targetname)
+ misc_teleporttrain_next ();
+ else if (!self.targetname)
// not triggered, so start immediately
- teleporttrain_next ();
+ misc_teleporttrain_next ();
else
- dprint ("misc_teleporttrain::teleporttrain_find: "
- "third state\n");
+ self.use = misc_teleporttrain_use;
};

//--------------------------------------------------------------
- virtual void() do_think =
+ void() misc_teleporttrain_use =
{
- switch (this.think_state)
- {
- case TELEPORTTRAIN_NEXT:
- this.teleporttrain_next ();
- break;
- case TELEPORTTRAIN_WAIT:
- this.teleporttrain_wait ();
- break;
- case TELEPORTTRAIN_FIND:
- this.teleporttrain_find ();
- break;
- default:
- dprint (sprintf("misc_teleporttrain::do_think: "
- "unhandled think state %g\n",
- this.think_state));
- }
+ if (self.velocity == '0 0 0')
+ misc_teleporttrain_next ();
};

//--------------------------------------------------------------
- virtual void(entity caller) do_use =
+ void(entity e) misc_teleporttrain_init =
{
- if (this.spawnflags & 4 || !this.targetname)
- return;
-
- if (this.velocity == '0 0 0')
- teleporttrain_next ();
- };
+ e.classname = "misc_teleporttrain";
+ e.classtype = CT_MISC_TELEPORTTRAIN;
+ base_mapentity_init (e);

- //--------------------------------------------------------------
- virtual void() init_spawned =
- {
- if (!this.target)
+ if (!e.target)
{
- objerror ("misc_teleporttrain has no target");
- remove (this);
+ objerror ("misc_teleporttrain_init: no target!\n");
+ remove (e);
return;
}

- if (this.speed <= 0)
- this.speed = 100;
+ if (e.speed <= 0)
+ e.speed = 100;
+
+ e.cnt = 1;
+ e.solid = SOLID_NOT;
+ e.movetype = MOVETYPE_FLY;

- this.cnt = 1;
- this.solid = SOLID_NOT;
- this.movetype = MOVETYPE_FLY;
// custom custom_mdls -- dumptruck_ds
// precache_model ("progs/teleport.mdl");
- precache_body_model ("progs/teleport.mdl");
+ precache_body_model (e, "progs/teleport.mdl");
// invisble -- dumptruck_ds
precache_model ("progs/s_null.spr");
- if (this.spawnflags & 8)
- body_model ("progs/s_null.spr");
+ if (e.spawnflags & 8)
+ body_model (e, "progs/s_null.spr");
else
- body_model ("progs/teleport.mdl");
+ body_model (e, "progs/teleport.mdl");

- setsize (this, '-16 -16 -16', '16 16 16');
- // setorigin (this, this.origin);
+ setsize (e, '-16 -16 -16', '16 16 16');
+ // setorigin (e, e.origin);

// Causes the ball to spin around like it was
// originally intended to.
- if (!(this.spawnflags & 2))
+ if (!(e.spawnflags & 2))
// don't spin - helpful for invisible
// spawner -- dumptruck_ds
- this.avelocity = '40 80 120';
+ e.avelocity = '40 80 120';

// precache_sound ("misc/null.wav");
- // this.noise = "misc/null.wav";
- // this.noise1 = "misc/null.wav";
+ // e.noise = "misc/null.wav";
+ // e.noise1 = "misc/null.wav";

- this.think_state = TELEPORTTRAIN_FIND;
- if (this.ltime)
- this.nextthink = this.ltime + 0.1;
+ e.think = misc_teleporttrain_find;
+ if (e.ltime)
+ e.nextthink = e.ltime + 0.1;
else
- this.nextthink = time + 0.1;
+ e.nextthink = time + 0.1;
};

//--------------------------------------------------------------
void() misc_teleporttrain =
{
- this.classtype = CT_MISC_TELEPORTTRAIN;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ misc_teleporttrain_init (self);
};
-};
+// };

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

Diff qc/misc/viewthing.qc

diff --git a/qc/misc/viewthing.qc b/qc/misc/viewthing.qc
index 34296a6..76a84fd 100644
--- a/qc/misc/viewthing.qc
+++ b/qc/misc/viewthing.qc
@@ -2,24 +2,44 @@
// viewthing -- was in misc.qc
//~>~<~>~<~>~<~>~<~>~<~>~<~>~<~>~<~>~<~>~<~>~<~>~<~>~<~>~<~>~<~>~<~>~<~>~<~>~<~>

+//======================================================================
+// forward declarations
+//======================================================================
+
+// viewthing
+void(entity e) viewthing_init;
+void() viewthing;
+
+//------------------------------------------------------------------------------
+
/*QUAKED viewthing (0 .5 .8) (-8 -8 -8) (8 8 8)

Just for the debugging level. Don't use
*/
-class viewthing: base_mapentity
-{
+//----------------------------------------------------------------------
+// class viewthing: base_mapentity
+// {
//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) viewthing_init =
{
- this.movetype = MOVETYPE_NONE;
- this.solid = SOLID_NOT;
+ e.classname = "viewthing";
+ e.classtype = CT_MISC_VIEWTHING;
+
+ base_mapentity_init (e);
+
+ e.movetype = MOVETYPE_NONE;
+ e.solid = SOLID_NOT;
precache_model ("progs/player.mdl");
- setmodel (this, "progs/player.mdl");
+ setmodel (e, "progs/player.mdl");
};

//--------------------------------------------------------------
void() viewthing =
{
- this.classtype = CT_MISC_VIEWTHING;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ viewthing_init (self);
};
-};
+// };

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

Diff qc/monsters/playerclient.qc

diff --git a/qc/monsters/playerclient.qc b/qc/monsters/playerclient.qc
index 86ae5aa..baac16c 100644
--- a/qc/monsters/playerclient.qc
+++ b/qc/monsters/playerclient.qc
@@ -9,6 +9,125 @@ float modelindex_eyes;
float modelindex_player;

//======================================================================
+// fields
+//======================================================================
+
+.float axhitme;
+.float fly_sound;
+.float jump_flag; // player jump flag
+.float reset_items; // dumptruck_ds
+.float swim_flag; // player swimming sound flag
+.float walkframe;
+
+.float air_finished; // when time > air_finished, drown
+.float attack_finished;
+.float pain_finished;
+.float invincible_finished;
+.float invisible_finished;
+.float super_damage_finished;
+.float radsuit_finished;
+
+.float damage_time;
+.float invincible_time, invincible_sound;
+.float invisible_time, invisible_sound;
+.float super_time, super_sound;
+.float rad_time;
+.float megahealth_rottime; // dumptruck_ds
+
+// 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 show_hostile;
+
+.string deathtype; // keeps track of how the player died
+
+//======================================================================
+// forward declarations
+//======================================================================
+
+// player
+void() player_impulse_cheat; // impulse commands
+void() player_impulse_quadcheat;
+void() player_impulse_serverflags;
+void() player_impulse_changeweapon;
+void() player_impulse_cycleweapon;
+void() player_impulse_cycleweaponreverse;
+void() player_impulse;
+void() player_superdamage_sound;
+void() player_set_current_ammo; // ammo, weapon firing, attacks
+float() player_best_weapon;
+float() player_check_no_ammo;
+void() player_fire_axe;
+void() player_fire_shotgun;
+void() player_fire_supershotgun;
+void(float offset) player_fire_spikes;
+void() player_fire_superspikes;
+void() player_fire_grenade;
+void() player_fire_rocket;
+void() player_fire_lightning;
+void() player_attack;
+void() player_set_suicide_frame; // pain, damage, death
+void() player_pain_sound;
+void() player_death_sound;
+void() player_dead;
+void() pl_stand1; // thinking & animation frames
+void() pl_run1;
+void() pl_shot1; void() pl_shot2; void() pl_shot3; void() pl_shot4;
+void() pl_shot5; void() pl_shot6;
+void() pl_axe1; void() pl_axe2; void() pl_axe3; void() pl_axe4;
+void() pl_axeb1; void() pl_axeb2; void() pl_axeb3; void() pl_axeb4;
+void() pl_axec1; void() pl_axec2; void() pl_axec3; void() pl_axec4;
+void() pl_axed1; void() pl_axed2; void() pl_axed3; void() pl_axed4;
+void() pl_nail1; void() pl_nail2;
+void() pl_light1; void() pl_light2;
+void() pl_rocket1; void() pl_rocket2; void() pl_rocket3;
+void() pl_rocket4; void() pl_rocket5; void() pl_rocket6;
+void() pl_pain1; void() pl_pain2; void() pl_pain3;
+void() pl_pain4; void() pl_pain5; void() pl_pain6;
+void() pl_axpain1; void() pl_axpain2; void() pl_axpain3;
+void() pl_axpain4; void() pl_axpain5; void() pl_axpain6;
+void() pl_diea1; void() pl_diea2; void() pl_diea3; void() pl_diea4;
+void() pl_diea5; void() pl_diea6; void() pl_diea7; void() pl_diea8;
+void() pl_diea9; void() pl_diea10; void() pl_diea11;
+void() pl_dieb1; void() pl_dieb2; void() pl_dieb3; void() pl_dieb4;
+void() pl_dieb5; void() pl_dieb6; void() pl_dieb7; void() pl_dieb8;
+void() pl_dieb9;
+void() pl_diec1; void() pl_diec2; void() pl_diec3; void() pl_diec4;
+void() pl_diec5; void() pl_diec6; void() pl_diec7; void() pl_diec8;
+void() pl_diec9; void() pl_diec10; void() pl_diec11; void() pl_diec12;
+void() pl_diec13; void() pl_diec14; void() pl_diec15;
+void() pl_died1; void() pl_died2; void() pl_died3; void() pl_died4;
+void() pl_died5; void() pl_died6; void() pl_died7; void() pl_died8;
+void() pl_died9;
+void() pl_diee1; void() pl_diee2; void() pl_diee3; void() pl_diee4;
+void() pl_diee5; void() pl_diee6; void() pl_diee7; void() pl_diee8;
+void() pl_diee9;
+void() player_death_think;
+void() player_prethink_watermove;
+void() player_prethink_waterjump;
+void() player_prethink_jump;
+void() player_prethink;
+void() player_postthink_powerups;
+void() player_postthink;
+float(entity to, float fl) player_sendentity; // object interaction
+void(entity attacker, float damage) player_pain;
+void() player_destroy;
+void() player_touch;
+entity() player_init_selectspawnpoint; // initialization
+void() player_init_level_parms;
+void() player_respawn;
+void(entity e) player_init;
+strip void() player;
+
+// player_dead_axe
+void() player_dead_axe;
+
+// player_dead_face_down
+void() player_dead_face_down;
+
+// player_dead_on_side
+void() player_dead_on_side;
+
+//======================================================================
// frame macros
//======================================================================
$cd id1/models/player_4
@@ -56,12 +175,11 @@ $frame axattb1 axattb2 axattb3 axattb4 axattb5 axattb6
$frame axattc1 axattc2 axattc3 axattc4 axattc5 axattc6
$frame axattd1 axattd2 axattd3 axattd4 axattd5 axattd6

-//------------------------------------------------------------------------------
+//----------------------------------------------------------------------
// Player Class: spawn functions, animation, client handling, etc. -- CEV
-//------------------------------------------------------------------------------
-class player: base_entity
-{
- float dmgtime;
+//----------------------------------------------------------------------
+// class player: entity
+// {

//==============================================================
// Client Input Handling
@@ -70,7 +188,7 @@ class player: base_entity
//--------------------------------------------------------------
// CheatCommand
//--------------------------------------------------------------
- nonvirtual void() cheat_command =
+ void() player_impulse_cheat =
{
// 1998-07-29 Cheats coop fix by Maddes start
// if (deathmatch || coop)
@@ -78,24 +196,24 @@ class player: base_entity
// 1998-07-29 Cheats coop fix by Maddes end
return;

- this.ammo_cells = 200;
- this.ammo_nails = 200;
- this.ammo_rockets = 100;
- this.ammo_shells = 100;
- this.items = this.items | IT_AXE | IT_SHOTGUN |
+ self.ammo_cells = 200;
+ self.ammo_nails = 200;
+ self.ammo_rockets = 100;
+ self.ammo_shells = 100;
+ self.items = self.items | IT_AXE | IT_SHOTGUN |
IT_SUPER_SHOTGUN | IT_NAILGUN | IT_SUPER_NAILGUN |
IT_GRENADE_LAUNCHER | IT_ROCKET_LAUNCHER | IT_LIGHTNING;

// support for item_key_custom -- iw
- base_item_key::give_all_keys (this);
+ base_item_key_giveallkeys (self);

- this.weapon = IT_ROCKET_LAUNCHER;
- this.impulse = 0;
- this.set_current_ammo ();
+ self.weapon = IT_ROCKET_LAUNCHER;
+ self.impulse = 0;
+ player_set_current_ammo ();
};

//--------------------------------------------------------------
- nonvirtual void() quad_cheat =
+ void() player_impulse_quadcheat =
{
// 1998-07-29 Cheats coop fix by Maddes start
// if (deathmatch || coop)
@@ -103,16 +221,16 @@ class player: base_entity
// 1998-07-29 Cheats coop fix by Maddes end
return;

- this.super_time = 1;
- this.super_damage_finished = time + 30;
- this.items = this.items | IT_QUAD;
+ self.super_time = 1;
+ self.super_damage_finished = time + 30;
+ self.items = self.items | IT_QUAD;
dprint ("player::quad_cheat: quad damage\n");
};

//--------------------------------------------------------------
// ServerflagsCommand -- Just for development
//--------------------------------------------------------------
- nonvirtual void() server_flags_command =
+ void() player_impulse_serverflags =
{
// 1998-07-29 Cheats coop fix by Maddes start
if (deathmatch)
@@ -125,145 +243,145 @@ class player: base_entity
//--------------------------------------------------------------
// ChangeWeaponCommand -- was W_ChangeWeapon
//--------------------------------------------------------------
- nonvirtual void() change_weapon =
+ void() player_impulse_changeweapon =
{
local float it, haveammo, fl;

// assign fl to silence a warning -- CEV
fl = IT_AXE;
- it = this.items;
+ it = self.items;
haveammo = TRUE;

- switch (this.impulse)
+ switch (self.impulse)
{
case 1:
fl = IT_AXE;
break;
case 2:
fl = IT_SHOTGUN;
- if (this.ammo_shells < 1)
+ if (self.ammo_shells < 1)
haveammo = FALSE;
break;
case 3:
fl = IT_SUPER_SHOTGUN;
- if (this.ammo_shells < 2)
+ if (self.ammo_shells < 2)
haveammo = FALSE;
break;
case 4:
fl = IT_NAILGUN;
- if (this.ammo_nails < 1)
+ if (self.ammo_nails < 1)
haveammo = FALSE;
break;
case 5:
fl = IT_SUPER_NAILGUN;
- if (this.ammo_nails < 2)
+ if (self.ammo_nails < 2)
haveammo = FALSE;
break;
case 6:
fl = IT_GRENADE_LAUNCHER;
- if (this.ammo_rockets < 1)
+ if (self.ammo_rockets < 1)
haveammo = FALSE;
break;
case 7:
fl = IT_ROCKET_LAUNCHER;
- if (this.ammo_rockets < 1)
+ if (self.ammo_rockets < 1)
haveammo = FALSE;
break;
case 8:
fl = IT_LIGHTNING;
- if (this.ammo_cells < 1)
+ if (self.ammo_cells < 1)
haveammo = FALSE;
break;
default:
dprint (sprintf("player::change_weapon: WARNING"
- " bad impulse: %f\n", this.impulse));
+ " bad impulse: %f\n", self.impulse));
return;
}

- this.impulse = 0;
+ self.impulse = 0;

- if (!(this.items & fl))
+ if (!(self.items & fl))
{
// don't have the weapon or the ammo
- sprint (this, "no weapon.\n");
+ sprint (self, "no weapon.\n");
return;
}

if (haveammo == FALSE)
{
// don't have the ammo
- sprint (this, "not enough ammo.\n");
+ sprint (self, "not enough ammo.\n");
return;
}

// set weapon, set ammo
- this.weapon = fl;
- this.set_current_ammo ();
+ self.weapon = fl;
+ player_set_current_ammo ();
};

//--------------------------------------------------------------
// CycleWeaponCommand -- Go to the next weapon with ammo
//--------------------------------------------------------------
- nonvirtual void() cycle_weapon =
+ void() player_impulse_cycleweapon =
{
local float haveammo;

- this.impulse = 0;
+ self.impulse = 0;

while (1)
{
haveammo = TRUE;

- if (this.weapon == IT_LIGHTNING)
+ if (self.weapon == IT_LIGHTNING)
{
- this.weapon = IT_AXE;
+ self.weapon = IT_AXE;
}
- else if (this.weapon == IT_AXE)
+ else if (self.weapon == IT_AXE)
{
- this.weapon = IT_SHOTGUN;
- if (this.ammo_shells < 1)
+ self.weapon = IT_SHOTGUN;
+ if (self.ammo_shells < 1)
haveammo = FALSE;
}
- else if (this.weapon == IT_SHOTGUN)
+ else if (self.weapon == IT_SHOTGUN)
{
- this.weapon = IT_SUPER_SHOTGUN;
- if (this.ammo_shells < 2)
+ self.weapon = IT_SUPER_SHOTGUN;
+ if (self.ammo_shells < 2)
haveammo = FALSE;
}
- else if (this.weapon == IT_SUPER_SHOTGUN)
+ else if (self.weapon == IT_SUPER_SHOTGUN)
{
- this.weapon = IT_NAILGUN;
- if (this.ammo_nails < 1)
+ self.weapon = IT_NAILGUN;
+ if (self.ammo_nails < 1)
haveammo = FALSE;
}
- else if (this.weapon == IT_NAILGUN)
+ else if (self.weapon == IT_NAILGUN)
{
- this.weapon = IT_SUPER_NAILGUN;
- if (this.ammo_nails < 2)
+ self.weapon = IT_SUPER_NAILGUN;
+ if (self.ammo_nails < 2)
haveammo = FALSE;
}
- else if (this.weapon == IT_SUPER_NAILGUN)
+ else if (self.weapon == IT_SUPER_NAILGUN)
{
- this.weapon = IT_GRENADE_LAUNCHER;
- if (this.ammo_rockets < 1)
+ self.weapon = IT_GRENADE_LAUNCHER;
+ if (self.ammo_rockets < 1)
haveammo = FALSE;
}
- else if (this.weapon == IT_GRENADE_LAUNCHER)
+ else if (self.weapon == IT_GRENADE_LAUNCHER)
{
- this.weapon = IT_ROCKET_LAUNCHER;
- if (this.ammo_rockets < 1)
+ self.weapon = IT_ROCKET_LAUNCHER;
+ if (self.ammo_rockets < 1)
haveammo = FALSE;
}
- else if (this.weapon == IT_ROCKET_LAUNCHER)
+ else if (self.weapon == IT_ROCKET_LAUNCHER)
{
- this.weapon = IT_LIGHTNING;
- if (this.ammo_cells < 1)
+ self.weapon = IT_LIGHTNING;
+ if (self.ammo_cells < 1)
haveammo = FALSE;
}

- if ((this.items & this.weapon) && haveammo == TRUE)
+ if ((self.items & self.weapon) && haveammo == TRUE)
{
- this.set_current_ammo ();
+ player_set_current_ammo ();
return;
}
}
@@ -272,66 +390,66 @@ class player: base_entity
//--------------------------------------------------------------
// CycleWeaponReverseCommand -- Go to the prev weapon with ammo
//--------------------------------------------------------------
- nonvirtual void() cycle_weapon_reverse =
+ void() player_impulse_cycleweaponreverse =
{
local float haveammo;

- this.impulse = 0;
+ self.impulse = 0;

while (1)
{
haveammo = TRUE;

- if (this.weapon == IT_LIGHTNING)
+ if (self.weapon == IT_LIGHTNING)
{
- this.weapon = IT_ROCKET_LAUNCHER;
- if (this.ammo_rockets < 1)
+ self.weapon = IT_ROCKET_LAUNCHER;
+ if (self.ammo_rockets < 1)
haveammo = FALSE;
}
- else if (this.weapon == IT_ROCKET_LAUNCHER)
+ else if (self.weapon == IT_ROCKET_LAUNCHER)
{
- this.weapon = IT_GRENADE_LAUNCHER;
- if (this.ammo_rockets < 1)
+ self.weapon = IT_GRENADE_LAUNCHER;
+ if (self.ammo_rockets < 1)
haveammo = FALSE;
}
- else if (this.weapon == IT_GRENADE_LAUNCHER)
+ else if (self.weapon == IT_GRENADE_LAUNCHER)
{
- this.weapon = IT_SUPER_NAILGUN;
- if (this.ammo_nails < 2)
+ self.weapon = IT_SUPER_NAILGUN;
+ if (self.ammo_nails < 2)
haveammo = FALSE;
}
- else if (this.weapon == IT_SUPER_NAILGUN)
+ else if (self.weapon == IT_SUPER_NAILGUN)
{
- this.weapon = IT_NAILGUN;
- if (this.ammo_nails < 1)
+ self.weapon = IT_NAILGUN;
+ if (self.ammo_nails < 1)
haveammo = FALSE;
}
- else if (this.weapon == IT_NAILGUN)
+ else if (self.weapon == IT_NAILGUN)
{
- this.weapon = IT_SUPER_SHOTGUN;
- if (this.ammo_shells < 2)
+ self.weapon = IT_SUPER_SHOTGUN;
+ if (self.ammo_shells < 2)
haveammo = FALSE;
}
- else if (this.weapon == IT_SUPER_SHOTGUN)
+ else if (self.weapon == IT_SUPER_SHOTGUN)
{
- this.weapon = IT_SHOTGUN;
- if (this.ammo_shells < 1)
+ self.weapon = IT_SHOTGUN;
+ if (self.ammo_shells < 1)
haveammo = FALSE;
}
- else if (this.weapon == IT_SHOTGUN)
+ else if (self.weapon == IT_SHOTGUN)
{
- this.weapon = IT_AXE;
+ self.weapon = IT_AXE;
}
- else if (this.weapon == IT_AXE)
+ else if (self.weapon == IT_AXE)
{
- this.weapon = IT_LIGHTNING;
- if (this.ammo_cells < 1)
+ self.weapon = IT_LIGHTNING;
+ if (self.ammo_cells < 1)
haveammo = FALSE;
}

- if ((this.items & this.weapon) && haveammo == TRUE)
+ if ((self.items & self.weapon) && haveammo == TRUE)
{
- this.set_current_ammo ();
+ player_set_current_ammo ();
return;
}
}
@@ -340,39 +458,39 @@ class player: base_entity
//--------------------------------------------------------------
// ImpulseCommands
//--------------------------------------------------------------
- nonvirtual void() impulse_commands =
+ void() player_impulse =
{
- switch (this.impulse)
+ switch (self.impulse)
{
case 1..8:
- this.change_weapon ();
+ player_impulse_changeweapon ();
return;
case 9:
- this.cheat_command ();
+ player_impulse_cheat ();
break;
case 10:
- this.cycle_weapon ();
+ player_impulse_cycleweapon ();
break;
case 11:
- this.server_flags_command ();
+ player_impulse_serverflags ();
break;
case 12:
- this.cycle_weapon_reverse ();
+ player_impulse_cycleweaponreverse ();
break;
case 100:
// dumptruck_ds version inspired by Copper
- sprint (this, version);
+ sprint (self, version);
break;
case 255:
- this.quad_cheat ();
+ player_impulse_quadcheat ();
break;
default:
- dprint (sprintf("player::impulse_commands: "
- "unknown impulse %g\n", this.impulse));
+ dprint (sprintf("player_impulse: "
+ "unknown impulse %g\n", self.impulse));
break;
}

- this.impulse = 0;
+ self.impulse = 0;
};

//==============================================================
@@ -382,131 +500,132 @@ class player: base_entity
//--------------------------------------------------------------
// SuperDamageSound -- Plays sound if needed
//--------------------------------------------------------------
- nonvirtual void() superdamage_sound =
+ void() player_superdamage_sound =
{
- if (super_damage_finished > time && super_sound < time)
+ if (self.super_damage_finished > time &&
+ self.super_sound < time)
{
- this.super_sound = time + 1;
- sound (this, CHAN_AUTO, "items/damage3.wav",
+ self.super_sound = time + 1;
+ sound (self, CHAN_AUTO, "items/damage3.wav",
1, ATTN_NORM);
}
};

//==============================================================
- // Ammo Handling, Weapon Switching, Attack
+ // Ammo Handling, Weapon Switching, Attack
//==============================================================

//--------------------------------------------------------------
- // set_current_ammo -- was W_SetCurrentAmmo in weapons.qc
+ // player_set_current_ammo -- was W_SetCurrentAmmo in weapons.qc
//--------------------------------------------------------------
- nonvirtual void() set_current_ammo =
+ void() player_set_current_ammo =
{
// get out of any weapon firing states
- this.run1 ();
+ pl_run1 ();

- this.items = this.items - (this.items & (IT_SHELLS | IT_NAILS |
+ self.items = self.items - (self.items & (IT_SHELLS | IT_NAILS |
IT_ROCKETS | IT_CELLS));

- if (this.weapon == IT_AXE)
+ if (self.weapon == IT_AXE)
{
- this.currentammo = 0;
- this.weaponmodel = "progs/v_axe.mdl";
- this.weaponframe = 0;
+ self.currentammo = 0;
+ self.weaponmodel = "progs/v_axe.mdl";
+ self.weaponframe = 0;
}
- else if (this.weapon == IT_SHOTGUN)
+ else if (self.weapon == IT_SHOTGUN)
{
- this.currentammo = this.ammo_shells;
- this.weaponmodel = "progs/v_shot.mdl";
- this.weaponframe = 0;
- this.items = this.items | IT_SHELLS;
+ self.currentammo = self.ammo_shells;
+ self.weaponmodel = "progs/v_shot.mdl";
+ self.weaponframe = 0;
+ self.items = self.items | IT_SHELLS;
}
- else if (this.weapon == IT_SUPER_SHOTGUN)
+ else if (self.weapon == IT_SUPER_SHOTGUN)
{
- this.currentammo = this.ammo_shells;
- this.weaponmodel = "progs/v_shot2.mdl";
- this.weaponframe = 0;
- this.items = this.items | IT_SHELLS;
+ self.currentammo = self.ammo_shells;
+ self.weaponmodel = "progs/v_shot2.mdl";
+ self.weaponframe = 0;
+ self.items = self.items | IT_SHELLS;
}
- else if (this.weapon == IT_NAILGUN)
+ else if (self.weapon == IT_NAILGUN)
{
- this.currentammo = this.ammo_nails;
- this.weaponmodel = "progs/v_nail.mdl";
- this.weaponframe = 0;
- this.items = this.items | IT_NAILS;
+ self.currentammo = self.ammo_nails;
+ self.weaponmodel = "progs/v_nail.mdl";
+ self.weaponframe = 0;
+ self.items = self.items | IT_NAILS;
}
- else if (this.weapon == IT_SUPER_NAILGUN)
+ else if (self.weapon == IT_SUPER_NAILGUN)
{
- this.currentammo = this.ammo_nails;
- this.weaponmodel = "progs/v_nail2.mdl";
- this.weaponframe = 0;
- this.items = this.items | IT_NAILS;
+ self.currentammo = self.ammo_nails;
+ self.weaponmodel = "progs/v_nail2.mdl";
+ self.weaponframe = 0;
+ self.items = self.items | IT_NAILS;
}
- else if (this.weapon == IT_GRENADE_LAUNCHER)
+ else if (self.weapon == IT_GRENADE_LAUNCHER)
{
- this.currentammo = this.ammo_rockets;
- this.weaponmodel = "progs/v_rock.mdl";
- this.weaponframe = 0;
- this.items = this.items | IT_ROCKETS;
+ self.currentammo = self.ammo_rockets;
+ self.weaponmodel = "progs/v_rock.mdl";
+ self.weaponframe = 0;
+ self.items = self.items | IT_ROCKETS;
}
- else if (this.weapon == IT_ROCKET_LAUNCHER)
+ else if (self.weapon == IT_ROCKET_LAUNCHER)
{
- this.currentammo = this.ammo_rockets;
- this.weaponmodel = "progs/v_rock2.mdl";
- this.weaponframe = 0;
- this.items = this.items | IT_ROCKETS;
+ self.currentammo = self.ammo_rockets;
+ self.weaponmodel = "progs/v_rock2.mdl";
+ self.weaponframe = 0;
+ self.items = self.items | IT_ROCKETS;
}
- else if (this.weapon == IT_LIGHTNING)
+ else if (self.weapon == IT_LIGHTNING)
{
- this.currentammo = this.ammo_cells;
- this.weaponmodel = "progs/v_light.mdl";
- this.weaponframe = 0;
- this.items = this.items | IT_CELLS;
+ self.currentammo = self.ammo_cells;
+ self.weaponmodel = "progs/v_light.mdl";
+ self.weaponframe = 0;
+ self.items = self.items | IT_CELLS;
}
else
{
- this.currentammo = 0;
- this.weaponmodel = "";
- this.weaponframe = 0;
+ self.currentammo = 0;
+ self.weaponmodel = "";
+ self.weaponframe = 0;
}
};

//--------------------------------------------------------------
// best_weapon -- was W_BestWeapon in weapons.qc
//--------------------------------------------------------------
- nonvirtual float() best_weapon =
+ float() player_best_weapon =
{
- if (this.waterlevel <= WATERLEVEL_FEET &&
- this.ammo_cells >= 1 && (this.items & IT_LIGHTNING))
+ if (self.waterlevel <= WATERLEVEL_FEET &&
+ self.ammo_cells >= 1 && (self.items & IT_LIGHTNING))
{
return IT_LIGHTNING;
}

- if (this.ammo_nails >= 2 && (this.items & IT_SUPER_NAILGUN))
+ if (self.ammo_nails >= 2 && (self.items & IT_SUPER_NAILGUN))
return IT_SUPER_NAILGUN;

- if (this.ammo_shells >= 2 && (this.items & IT_SUPER_SHOTGUN))
+ if (self.ammo_shells >= 2 && (self.items & IT_SUPER_SHOTGUN))
return IT_SUPER_SHOTGUN;

- if (this.ammo_nails >= 1 && (this.items & IT_NAILGUN))
+ if (self.ammo_nails >= 1 && (self.items & IT_NAILGUN))
return IT_NAILGUN;

- if (this.ammo_shells >= 1 && (this.items & IT_SHOTGUN))
+ if (self.ammo_shells >= 1 && (self.items & IT_SHOTGUN))
return IT_SHOTGUN;

return IT_AXE;
};

//--------------------------------------------------------------
- nonvirtual float() check_no_ammo =
+ float() player_check_no_ammo =
{
- if (this.currentammo > 0)
+ if (self.currentammo > 0)
return TRUE;

- if (this.weapon == IT_AXE)
+ if (self.weapon == IT_AXE)
return TRUE;

- this.weapon = this.best_weapon ();
- this.set_current_ammo ();
+ self.weapon = player_best_weapon ();
+ player_set_current_ammo ();

// drop the weapon down
return FALSE;
@@ -515,14 +634,14 @@ class player: base_entity
//--------------------------------------------------------------
// Weapon 1: W_FireAxe
//--------------------------------------------------------------
- nonvirtual void() fire_axe =
+ void() player_fire_axe =
{
local vector source;
local vector org;

- makevectors (this.v_angle);
- source = this.origin + '0 0 16';
- traceline (source, source + v_forward * 64, FALSE, this);
+ makevectors (self.v_angle);
+ source = self.origin + '0 0 16';
+ traceline (source, source + v_forward * 64, FALSE, self);
if (trace_fraction == 1.0)
return;
org = trace_endpos - v_forward * 4;
@@ -530,13 +649,13 @@ class player: base_entity
if (trace_ent.takedamage)
{
trace_ent.axhitme = 1;
- SpawnBlood (org, '0 0 0', 20);
- t_damage2 (trace_ent, this, this, 20);
+ spawn_blood (org, '0 0 0', 20);
+ t_damage2 (trace_ent, self, self, 20);
}
else
{
// hit wall
- sound (this, CHAN_WEAPON, "player/axhit2.wav",
+ sound (self, CHAN_WEAPON, "player/axhit2.wav",
1, ATTN_NORM);
WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
WriteByte (MSG_BROADCAST, TE_GUNSHOT);
@@ -549,20 +668,21 @@ class player: base_entity
//--------------------------------------------------------------
// Weapon 2: W_FireShotgun
//--------------------------------------------------------------
- nonvirtual void() fire_shotgun =
+ void() player_fire_shotgun =
{
local vector org, dir, vdir;
local float vspeed;

- sound (this, CHAN_WEAPON, "weapons/guncock.wav", 1, ATTN_NORM);
+ sound (self, CHAN_WEAPON, "weapons/guncock.wav", 1, ATTN_NORM);

- this.punchangle_x = -2;
+ self.punchangle_x = -2;

- this.currentammo = this.ammo_shells = this.ammo_shells - 1;
- // dir = aim (this, 100000);
- makevectors (this.v_angle);
+ self.currentammo = self.ammo_shells = self.ammo_shells - 1;
+ // dir = aim (self, 100000);
+ makevectors (self.v_angle);

- org = origin + (v_forward * 10) + (v_right * 0) + (v_up * 8);
+ org = self.origin + (v_forward * 10) + (v_right * 0) +
+ (v_up * 8);
dir = normalize (v_forward * BULLET_SPEED);

// 5 bullets instead of 6 -- CEV
@@ -576,38 +696,36 @@ class player: base_entity
((((i / 10.0) - 0.3) * 0.12) * v_right) +
((((i / 10.0) - 0.3) * 0.12) * v_up);
*/
- vdir *= min (vspeed, frame_maxvelocity);
+ vdir *= min (vspeed, world_maxvelocity);

- spawn (projectile_bullet,
- owner: this,
- origin: org,
- velocity: vdir);
+ spawn_projectile_bullet (self, org, vdir);
}
};

//--------------------------------------------------------------
// Weapon 3: W_FireSuperShotgun
//--------------------------------------------------------------
- nonvirtual void() fire_supershotgun =
+ void() player_fire_supershotgun =
{
local vector org, dir, vdir;
local float vspeed;

- if (this.currentammo == 1)
+ if (self.currentammo == 1)
{
- this.fire_shotgun ();
+ player_fire_shotgun ();
return;
}

- sound (this, CHAN_WEAPON, "weapons/shotgn2.wav", 1, ATTN_NORM);
+ sound (self, CHAN_WEAPON, "weapons/shotgn2.wav", 1, ATTN_NORM);

- this.punchangle_x = -4;
+ self.punchangle_x = -4;

- this.currentammo = this.ammo_shells = this.ammo_shells - 2;
- // dir = aim (this, 100000);
- makevectors (this.v_angle);
+ self.currentammo = self.ammo_shells = self.ammo_shells - 2;
+ // dir = aim (self, 100000);
+ makevectors (self.v_angle);

- org = origin + (v_forward * 10) + (v_right * 0) + (v_up * 8);
+ org = self.origin + (v_forward * 10) + (v_right * 0) +
+ (v_up * 8);
dir = normalize (v_forward * BULLET_SPEED);

// 12 bullets instead of 14 -- CEV
@@ -616,102 +734,94 @@ class player: base_entity
vspeed = crandom () * 10 + BULLET_SPEED;
vdir = dir + (crandom() * 0.14) * v_right +
(crandom() * 0.08) * v_up;
- vdir *= min (vspeed, frame_maxvelocity);
+ vdir *= min (vspeed, world_maxvelocity);

- spawn (projectile_bullet,
- owner: this,
- origin: org,
- velocity: vdir);
+ spawn_projectile_bullet (self, org, vdir);
}
};

//--------------------------------------------------------------
// Weapon 4: W_FireSpikes
//--------------------------------------------------------------
- nonvirtual void(float offset) fire_spikes =
+ void(float offset) player_fire_spikes =
{
local vector dir;

- makevectors (this.v_angle);
+ makevectors (self.v_angle);

- if (this.ammo_nails >= 2 && this.weapon == IT_SUPER_NAILGUN)
+ if (self.ammo_nails >= 2 && self.weapon == IT_SUPER_NAILGUN)
{
- fire_superspikes ();
+ player_fire_superspikes ();
return;
}

- if (this.ammo_nails < 1)
+ if (self.ammo_nails < 1)
{
- this.weapon = this.best_weapon ();
- this.set_current_ammo ();
+ self.weapon = player_best_weapon ();
+ player_set_current_ammo ();
return;
}

- sound (this, CHAN_WEAPON, "weapons/rocket1i.wav", 1, ATTN_NORM);
- this.attack_finished = time + 0.2;
- this.currentammo = this.ammo_nails = this.ammo_nails - 1;
+ sound (self, CHAN_WEAPON, "weapons/rocket1i.wav", 1, ATTN_NORM);
+ self.attack_finished = time + 0.2;
+ self.currentammo = self.ammo_nails = self.ammo_nails - 1;

- dir = aim (this, SPIKE_SPEED);
+ dir = aim (self, SPIKE_SPEED);
// dir = normalize (dir);
// SetSpeed
- dir *= min (SPIKE_SPEED, frame_maxvelocity);
+ dir *= min (SPIKE_SPEED, world_maxvelocity);

- spawn (projectile_spike,
- owner: this,
- // seven Nailgun position fix - thanks to Greenwood
- // -- dumptruck_ds
- origin: this.origin + this.view_ofs + v_up * -8 +
+ // seven Nailgun position fix - thanks to Greenwood
+ // -- dumptruck_ds
+ spawn_projectile_spike (self,
+ self.origin + self.view_ofs + v_up * -8 +
v_right * (offset * 0.5),
- velocity: dir,
- direct_damage: SPIKE_NORMAL_DAMAGE);
+ dir, SPIKE_NORMAL_DAMAGE);

- this.punchangle_x = -2;
+ self.punchangle_x = -2;
};

//--------------------------------------------------------------
// Weapon 5: W_FireSuperSpikes
//--------------------------------------------------------------
- nonvirtual void() fire_superspikes =
+ void() player_fire_superspikes =
{
local vector dir;

- sound (this, CHAN_WEAPON, "weapons/spike2.wav", 1, ATTN_NORM);
- this.attack_finished = time + 0.2;
- this.currentammo = this.ammo_nails = this.ammo_nails - 2;
+ sound (self, CHAN_WEAPON, "weapons/spike2.wav", 1, ATTN_NORM);
+ self.attack_finished = time + 0.2;
+ self.currentammo = self.ammo_nails = self.ammo_nails - 2;

- dir = aim (this, SPIKE_SPEED);
+ dir = aim (self, SPIKE_SPEED);
// dir = normalize (dir);
// SetSpeed
- dir *= min (SPIKE_SPEED, frame_maxvelocity);
+ dir *= min (SPIKE_SPEED, world_maxvelocity);

- spawn (projectile_spike,
- owner: this,
- // seven Nailgun position fix - thanks to Greenwood
- // -- dumptruck_ds
- origin: this.origin + '0 0 16',
- velocity: dir,
- direct_damage: SPIKE_SUPER_DAMAGE);
+ // seven Nailgun position fix - thanks to Greenwood
+ // -- dumptruck_ds
+ spawn_projectile_spike (self, self.origin + '0 0 16',
+ dir, SPIKE_SUPER_DAMAGE);

- this.punchangle_x = -2;
+ self.punchangle_x = -2;
};

//--------------------------------------------------------------
// Weapon 6: W_FireGrenade
//--------------------------------------------------------------
- nonvirtual void() fire_grenade =
+ void() player_fire_grenade =
{
local vector missile_velocity = '0 0 0';

- this.currentammo = this.ammo_rockets = this.ammo_rockets - 1;
+ self.currentammo = self.ammo_rockets = self.ammo_rockets - 1;

- sound (this, CHAN_WEAPON, "weapons/grenade.wav", 1, ATTN_NORM);
+ sound (self, CHAN_WEAPON, "weapons/grenade.wav", 1, ATTN_NORM);

- this.punchangle_x = -2;
+ self.punchangle_x = -2;

// set missile speed
- makevectors (this.v_angle);
+ makevectors (self.v_angle);

- if (this.v_angle_x)
+ if (self.v_angle_x)
{
missile_velocity = v_forward * GRENADE_SPEED +
v_up * 200 + crandom() * v_right * 10 +
@@ -719,84 +829,79 @@ class player: base_entity
}
else
{
- missile_velocity = aim (this, 10000);
+ missile_velocity = aim (self, 10000);
missile_velocity = missile_velocity * GRENADE_SPEED;
missile_velocity_z = 200;
}

- spawn (projectile_grenade,
- owner: this,
- origin: this.origin,
- velocity: missile_velocity);
+ spawn_projectile_grenade (self, self.origin, missile_velocity);
};

//--------------------------------------------------------------
// Weapon 7: W_FireRocket
//--------------------------------------------------------------
- nonvirtual void() fire_rocket =
+ void() player_fire_rocket =
{
local vector missile_velocity = '0 0 0';

- this.currentammo = this.ammo_rockets = this.ammo_rockets - 1;
+ self.currentammo = self.ammo_rockets = self.ammo_rockets - 1;

- sound (this, CHAN_WEAPON, "weapons/sgun1.wav", 1, ATTN_NORM);
+ sound (self, CHAN_WEAPON, "weapons/sgun1.wav", 1, ATTN_NORM);

- this.punchangle_x = -2;
+ self.punchangle_x = -2;

// set missile speed
- makevectors (this.v_angle);
- missile_velocity = aim (this, 1000);
+ makevectors (self.v_angle);
+ missile_velocity = aim (self, 1000);
missile_velocity *= ROCKET_SPEED;

- spawn (projectile_rocket,
- owner: this,
- origin: this.origin + v_forward * 8 + '0 0 16',
- velocity: missile_velocity,
- angles: vectoangles (missile_velocity));
+ spawn_projectile_rocket (self,
+ self.origin + v_forward * 8 + '0 0 16',
+ missile_velocity);
};

//--------------------------------------------------------------
// Weapon 8: W_FireLightning
//--------------------------------------------------------------
- nonvirtual void() fire_lightning =
+ void() player_fire_lightning =
{
- if (this.ammo_cells < 1)
+ if (self.ammo_cells < 1)
{
- this.weapon = this.best_weapon ();
- this.set_current_ammo ();
+ self.weapon = player_best_weapon ();
+ player_set_current_ammo ();
return;
}

// explode if under water
- if (this.waterlevel > WATERLEVEL_FEET)
+ if (self.waterlevel > WATERLEVEL_FEET)
{
- local float cells = this.ammo_cells;
- this.ammo_cells = 0;
- this.set_current_ammo ();
- this.t_radiusdamage2 (this, this, 35 * cells, world);
+ local float cells = self.ammo_cells;
+ self.ammo_cells = 0;
+ player_set_current_ammo ();
+ t_radiusdamage2 (self, self, 35 * cells, world);
return;
}

- if (this.t_width < time)
+ if (self.t_width < time)
{
- sound (this, CHAN_WEAPON, "weapons/lhit.wav",
+ sound (self, CHAN_WEAPON, "weapons/lhit.wav",
1, ATTN_NORM);
- this.t_width = time + 0.6;
+ self.t_width = time + 0.6;
}
- this.punchangle_x = -2;
+ self.punchangle_x = -2;

- this.currentammo = this.ammo_cells = this.ammo_cells - 1;
+ self.currentammo = self.ammo_cells = self.ammo_cells - 1;

// TODO CEV
- // local vector org = this.origin;
- local vector org = this.origin + '0 0 16';
- makevectors (this.v_angle);
+ // local vector org = self.origin;
+ local vector org = self.origin + '0 0 16';
+ makevectors (self.v_angle);

- traceline (org, org + v_forward * 600, TRUE, this);
+ traceline (org, org + v_forward * 600, TRUE, self);

WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
WriteByte (MSG_BROADCAST, TE_LIGHTNING2);
- WriteEntity (MSG_BROADCAST, this);
+ WriteEntity (MSG_BROADCAST, self);
WriteCoord (MSG_BROADCAST, org_x);
WriteCoord (MSG_BROADCAST, org_y);
WriteCoord (MSG_BROADCAST, org_z);
@@ -804,77 +909,77 @@ class player: base_entity
WriteCoord (MSG_BROADCAST, trace_endpos_y);
WriteCoord (MSG_BROADCAST, trace_endpos_z);

- weapon_lightning::lightning_damage (this.origin,
- trace_endpos + v_forward * 4, this, 30);
+ fire_lightning (self.origin, trace_endpos + v_forward * 4,
+ self, 30);
};

//--------------------------------------------------------------
// PlayerAttack -- An attack impulse can be triggered now
//--------------------------------------------------------------
- nonvirtual void() attack =
+ void() player_attack =
{
local float r;

- if (!this.check_no_ammo())
+ if (player_check_no_ammo() == FALSE)
return;

// calculate forward angle for velocity
- makevectors (this.v_angle);
+ makevectors (self.v_angle);
// wake monsters up
- this.show_hostile = time + 1;
+ self.show_hostile = time + 1;

- if (this.weapon == IT_AXE)
+ if (self.weapon == IT_AXE)
{
- sound (this, CHAN_WEAPON, "weapons/ax1.wav",
+ sound (self, CHAN_WEAPON, "weapons/ax1.wav",
1, ATTN_NORM);
r = random ();
if (r < 0.25)
- this.axe1 ();
+ pl_axe1 ();
else if (r < 0.5)
- this.axeb1 ();
+ pl_axeb1 ();
else if (r < 0.75)
- this.axec1 ();
+ pl_axec1 ();
else
- this.axed1 ();
- this.attack_finished = time + 0.5;
+ pl_axed1 ();
+ self.attack_finished = time + 0.5;
}
- else if (this.weapon == IT_SHOTGUN)
+ else if (self.weapon == IT_SHOTGUN)
{
- this.shot1 ();
- this.fire_shotgun ();
- this.attack_finished = time + 0.5;
+ pl_shot1 ();
+ player_fire_shotgun ();
+ self.attack_finished = time + 0.5;
}
- else if (this.weapon == IT_SUPER_SHOTGUN)
+ else if (self.weapon == IT_SUPER_SHOTGUN)
{
- this.shot1 ();
- this.fire_supershotgun ();
- this.attack_finished = time + 0.7;
+ pl_shot1 ();
+ player_fire_supershotgun ();
+ self.attack_finished = time + 0.7;
}
- else if (this.weapon == IT_NAILGUN)
+ else if (self.weapon == IT_NAILGUN)
{
- this.nail1 ();
+ pl_nail1 ();
}
- else if (this.weapon == IT_SUPER_NAILGUN)
+ else if (self.weapon == IT_SUPER_NAILGUN)
{
- this.nail1 ();
+ pl_nail1 ();
}
- else if (this.weapon == IT_GRENADE_LAUNCHER)
+ else if (self.weapon == IT_GRENADE_LAUNCHER)
{
- this.rocket1 ();
- this.fire_grenade ();
- this.attack_finished = time + 0.6;
+ pl_rocket1 ();
+ player_fire_grenade ();
+ self.attack_finished = time + 0.6;
}
- else if (this.weapon == IT_ROCKET_LAUNCHER)
+ else if (self.weapon == IT_ROCKET_LAUNCHER)
{
- this.rocket1 ();
- this.fire_rocket ();
- this.attack_finished = time + 0.8;
+ pl_rocket1 ();
+ player_fire_rocket ();
+ self.attack_finished = time + 0.8;
}
- else if (this.weapon == IT_LIGHTNING)
+ else if (self.weapon == IT_LIGHTNING)
{
- this.light1 ();
- this.attack_finished = time + 0.1;
- sound (this, CHAN_AUTO, "weapons/lstart.wav",
+ pl_light1 ();
+ self.attack_finished = time + 0.1;
+ sound (self, CHAN_AUTO, "weapons/lstart.wav",
1, ATTN_NORM);
}
};
@@ -884,158 +989,161 @@ class player: base_entity
//==============================================================

//--------------------------------------------------------------
- nonvirtual void() set_suicide_frame =
+ void() player_set_suicide_frame =
{
// used by klill command and disconnect command
- if (this.model != "progs/player.mdl")
+ if (self.model != "progs/player.mdl")
// allready gibbed
return;
- this.frame = $deatha11;
- this.solid = SOLID_NOT;
- this.movetype = MOVETYPE_TOSS;
- this.deadflag = DEAD_DEAD;
- this.nextthink = -1;
+ self.frame = $deatha11;
+ self.solid = SOLID_NOT;
+ self.movetype = MOVETYPE_TOSS;
+ self.deadflag = DEAD_DEAD;
+ self.nextthink = -1;
};

//--------------------------------------------------------------
// PainSound
//--------------------------------------------------------------
- nonvirtual void() pain_sound =
+ void() player_pain_sound =
{
local float rs;

- if (this.health < 0)
+ if (self.health < 0)
return;

if (damage_attacker.classname == "teledeath")
{
- sound (this, CHAN_VOICE, "player/teledth1.wav",
+ sound (self, CHAN_VOICE, "player/teledth1.wav",
1, ATTN_NONE);
return;
}

// water pain sounds
- if (this.watertype == CONTENT_WATER &&
- this.waterlevel == WATERLEVEL_EYES)
+ if (self.watertype == CONTENT_WATER &&
+ self.waterlevel == WATERLEVEL_EYES)
{
- PlayerDeathBubbles (1);
+ // PlayerDeathBubbles
+ spawn_air_bubbles (self, self.origin, 1);
if (random() > 0.5)
- sound (this, CHAN_VOICE, "player/drown1.wav",
+ sound (self, CHAN_VOICE, "player/drown1.wav",
1, ATTN_NORM);
else
- sound (this, CHAN_VOICE, "player/drown2.wav",
+ sound (self, CHAN_VOICE, "player/drown2.wav",
1, ATTN_NORM);
return;
}

// slime pain sounds
- if (this.watertype == CONTENT_SLIME)
+ if (self.watertype == CONTENT_SLIME)
{
// FIX ME put in some steam here
// 1998-08-10 Player gulps bubbles when hurt in slime
// by Maddes start
- if (this.waterlevel == WATERLEVEL_EYES)
- PlayerDeathBubbles (1);
+ if (self.waterlevel == WATERLEVEL_EYES)
+ // PlayerDeathBubbles
+ spawn_air_bubbles (self, self.origin, 1);
// 1998-08-10 Player gulps bubbles when hurt in slime
// by Maddes end
if (random() > 0.5)
- sound (this, CHAN_VOICE, "player/lburn1.wav",
+ sound (self, CHAN_VOICE, "player/lburn1.wav",
1, ATTN_NORM);
else
- sound (this, CHAN_VOICE, "player/lburn2.wav",
+ sound (self, CHAN_VOICE, "player/lburn2.wav",
1, ATTN_NORM);
return;
}

- if (this.watertype == CONTENT_LAVA)
+ if (self.watertype == CONTENT_LAVA)
{
if (random() > 0.5)
- sound (this, CHAN_VOICE, "player/lburn1.wav",
+ sound (self, CHAN_VOICE, "player/lburn1.wav",
1, ATTN_NORM);
else
- sound (this, CHAN_VOICE, "player/lburn2.wav",
+ sound (self, CHAN_VOICE, "player/lburn2.wav",
1, ATTN_NORM);
return;
}

- if (this.pain_finished > time)
+ if (self.pain_finished > time)
{
- this.axhitme = 0;
+ self.axhitme = 0;
return;
}

// don't make multiple pain sounds right after each other
- this.pain_finished = time + 0.5;
+ self.pain_finished = time + 0.5;

// ax pain sound
- if (this.axhitme == 1)
+ if (self.axhitme == 1)
{
- this.axhitme = 0;
- sound (this, CHAN_VOICE, "player/axhit1.wav",
+ self.axhitme = 0;
+ sound (self, CHAN_VOICE, "player/axhit1.wav",
1, ATTN_NORM);
return;
}

rs = rint ((random() * 5) + 1);

- this.noise = "";
+ self.noise = "";
if (rs == 1)
- this.noise = "player/pain1.wav";
+ self.noise = "player/pain1.wav";
else if (rs == 2)
- this.noise = "player/pain2.wav";
+ self.noise = "player/pain2.wav";
else if (rs == 3)
- this.noise = "player/pain3.wav";
+ self.noise = "player/pain3.wav";
else if (rs == 4)
- this.noise = "player/pain4.wav";
+ self.noise = "player/pain4.wav";
else if (rs == 5)
- this.noise = "player/pain5.wav";
+ self.noise = "player/pain5.wav";
else
- this.noise = "player/pain6.wav";
+ self.noise = "player/pain6.wav";

- sound (this, CHAN_VOICE, this.noise, 1, ATTN_NORM);
+ sound (self, CHAN_VOICE, self.noise, 1, ATTN_NORM);
return;
};

//--------------------------------------------------------------
// PlayerDeathSound
//--------------------------------------------------------------
- nonvirtual void() death_sound =
+ void() player_death_sound =
{
local float rs;

// water death sounds
- if (this.waterlevel == WATERLEVEL_EYES)
+ if (self.waterlevel == WATERLEVEL_EYES)
{
- PlayerDeathBubbles (20);
- sound (this, CHAN_VOICE, "player/h2odeath.wav",
+ // PlayerDeathBubbles
+ spawn_air_bubbles (self, self.origin, 20);
+ sound (self, CHAN_VOICE, "player/h2odeath.wav",
1, ATTN_NONE);
return;
}

rs = rint ((random() * 4) + 1);
if (rs == 1)
- this.noise = "player/death1.wav";
+ self.noise = "player/death1.wav";
else if (rs == 2)
- this.noise = "player/death2.wav";
+ self.noise = "player/death2.wav";
else if (rs == 3)
- this.noise = "player/death3.wav";
+ self.noise = "player/death3.wav";
else if (rs == 4)
- this.noise = "player/death4.wav";
+ self.noise = "player/death4.wav";
else if (rs == 5)
- this.noise = "player/death5.wav";
+ self.noise = "player/death5.wav";

- sound (this, CHAN_VOICE, this.noise, 1, ATTN_NONE);
+ sound (self, CHAN_VOICE, self.noise, 1, ATTN_NONE);
return;
};

//--------------------------------------------------------------
// PlayerDead -- the player is dead, hold them there
//--------------------------------------------------------------
- nonvirtual void() dead =
+ void() player_dead =
{
- this.nextthink = -1;
+ self.nextthink = -1;
// allow respawn after a certain time
- this.deadflag = DEAD_DEAD;
+ self.deadflag = DEAD_DEAD;
};

//==============================================================
@@ -1045,495 +1153,496 @@ class player: base_entity
//--------------------------------------------------------------
// Player Stand function
//--------------------------------------------------------------
- nonvirtual void() stand1 = [$axstnd1, stand1]
+ void() pl_stand1 = [$axstnd1, pl_stand1]
{
- this.weaponframe = 0;
- if (this.velocity_x || this.velocity_y)
+ self.weaponframe = 0;
+ if (self.velocity_x || self.velocity_y)
{
- this.walkframe = 0;
- this.run1 ();
+ self.walkframe = 0;
+ pl_run1 ();
return;
}

- if (this.weapon == IT_AXE)
+ if (self.weapon == IT_AXE)
{
- if (this.walkframe >= 12)
- this.walkframe = 0;
- this.frame = $axstnd1 + this.walkframe;
+ if (self.walkframe >= 12)
+ self.walkframe = 0;
+ self.frame = $axstnd1 + self.walkframe;
}
else
{
- if (this.walkframe >= 5)
- this.walkframe = 0;
- this.frame = $stand1 + this.walkframe;
+ if (self.walkframe >= 5)
+ self.walkframe = 0;
+ self.frame = $stand1 + self.walkframe;
}
- this.walkframe = this.walkframe + 1;
+ self.walkframe = self.walkframe + 1;
};

//--------------------------------------------------------------
// Player Run function
//--------------------------------------------------------------
- nonvirtual void() run1 = [$rockrun1, run1]
+ void() pl_run1 = [$rockrun1, pl_run1]
{
- this.weaponframe = 0;
- if (!this.velocity_x && !this.velocity_y)
+ self.weaponframe = 0;
+ if (!self.velocity_x && !self.velocity_y)
{
- this.walkframe = 0;
- this.stand1 ();
+ self.walkframe = 0;
+ pl_stand1 ();
return;
}

- if (this.weapon == IT_AXE)
+ if (self.weapon == IT_AXE)
{
- if (this.walkframe == 6)
- this.walkframe = 0;
- this.frame = $axrun1 + this.walkframe;
+ if (self.walkframe == 6)
+ self.walkframe = 0;
+ self.frame = $axrun1 + self.walkframe;
}
else
{
- if (this.walkframe == 6)
- this.walkframe = 0;
- this.frame = this.frame + this.walkframe;
+ if (self.walkframe == 6)
+ self.walkframe = 0;
+ self.frame = self.frame + self.walkframe;
}
- this.walkframe = this.walkframe + 1;
+ self.walkframe = self.walkframe + 1;
};

//--------------------------------------------------------------
// Player Projectile Attack
//--------------------------------------------------------------
- nonvirtual void() shot1 = [$shotatt1, shot2]
+ void() pl_shot1 = [$shotatt1, pl_shot2]
{
- this.weaponframe = 1;
- this.effects = this.effects | EF_MUZZLEFLASH;
+ self.weaponframe = 1;
+ self.effects = self.effects | EF_MUZZLEFLASH;
};
- nonvirtual void() shot2 = [$shotatt2, shot3] { this.weaponframe = 2; };
- nonvirtual void() shot3 = [$shotatt3, shot4] { this.weaponframe = 3; };
- nonvirtual void() shot4 = [$shotatt4, shot5] { this.weaponframe = 4; };
- nonvirtual void() shot5 = [$shotatt5, shot6] { this.weaponframe = 5; };
- nonvirtual void() shot6 = [$shotatt6, run1] { this.weaponframe = 6; };
+ void() pl_shot2 = [$shotatt2, pl_shot3] { self.weaponframe = 2; };
+ void() pl_shot3 = [$shotatt3, pl_shot4] { self.weaponframe = 3; };
+ void() pl_shot4 = [$shotatt4, pl_shot5] { self.weaponframe = 4; };
+ void() pl_shot5 = [$shotatt5, pl_shot6] { self.weaponframe = 5; };
+ void() pl_shot6 = [$shotatt6, pl_run1] { self.weaponframe = 6; };

//--------------------------------------------------------------
// Player Axe Attack A
//--------------------------------------------------------------
- nonvirtual void() axe1 = [$axatt1, axe2] { this.weaponframe = 1; };
- nonvirtual void() axe2 = [$axatt2, axe3] { this.weaponframe = 2; };
- nonvirtual void() axe3 = [$axatt3, axe4]
+ void() pl_axe1 = [$axatt1, pl_axe2] { self.weaponframe = 1; };
+ void() pl_axe2 = [$axatt2, pl_axe3] { self.weaponframe = 2; };
+ void() pl_axe3 = [$axatt3, pl_axe4]
{
- this.weaponframe = 3;
- this.fire_axe ();
+ self.weaponframe = 3;
+ player_fire_axe ();
};
- nonvirtual void() axe4 = [$axatt4, run1] { this.weaponframe = 4; };
+ void() pl_axe4 = [$axatt4, pl_run1] { self.weaponframe = 4; };

//--------------------------------------------------------------
// Player Axe Attack B
//--------------------------------------------------------------
- nonvirtual void() axeb1 = [$axattb1, axeb2] { this.weaponframe = 5; };
- nonvirtual void() axeb2 = [$axattb2, axeb3] { this.weaponframe = 6; };
- nonvirtual void() axeb3 = [$axattb3, axeb4]
+ void() pl_axeb1 = [$axattb1, pl_axeb2] { self.weaponframe = 5; };
+ void() pl_axeb2 = [$axattb2, pl_axeb3] { self.weaponframe = 6; };
+ void() pl_axeb3 = [$axattb3, pl_axeb4]
{
- this.weaponframe = 7;
- this.fire_axe ();
+ self.weaponframe = 7;
+ player_fire_axe ();
};
- nonvirtual void() axeb4 = [$axattb4, run1] { this.weaponframe = 8; };
+ void() pl_axeb4 = [$axattb4, pl_run1] { self.weaponframe = 8; };

//--------------------------------------------------------------
// Player Axe Attack C
//--------------------------------------------------------------
- nonvirtual void() axec1 = [$axattc1, axec2] { this.weaponframe = 1; };
- nonvirtual void() axec2 = [$axattc2, axec3] { this.weaponframe = 2; };
- nonvirtual void() axec3 = [$axattc3, axec4]
+ void() pl_axec1 = [$axattc1, pl_axec2] { self.weaponframe = 1; };
+ void() pl_axec2 = [$axattc2, pl_axec3] { self.weaponframe = 2; };
+ void() pl_axec3 = [$axattc3, pl_axec4]
{
- this.weaponframe = 3;
- this.fire_axe ();
+ self.weaponframe = 3;
+ player_fire_axe ();
};
- nonvirtual void() axec4 = [$axattc4, run1] { this.weaponframe = 4; };
+ void() pl_axec4 = [$axattc4, pl_run1] { self.weaponframe = 4; };

//--------------------------------------------------------------
// Player Axe Attack D
//--------------------------------------------------------------
- nonvirtual void() axed1 = [$axattd1, axed2] { this.weaponframe = 5; };
- nonvirtual void() axed2 = [$axattd2, axed3] { this.weaponframe = 6; };
- nonvirtual void() axed3 = [$axattd3, axed4]
+ void() pl_axed1 = [$axattd1, pl_axed2] { self.weaponframe = 5; };
+ void() pl_axed2 = [$axattd2, pl_axed3] { self.weaponframe = 6; };
+ void() pl_axed3 = [$axattd3, pl_axed4]
{
- this.weaponframe = 7;
- this.fire_axe ();
+ self.weaponframe = 7;
+ player_fire_axe ();
};
- nonvirtual void() axed4 = [$axattd4, run1] { this.weaponframe = 8; };
+ void() pl_axed4 = [$axattd4, pl_run1] { self.weaponframe = 8; };

//--------------------------------------------------------------
// Player Nail Attack
//--------------------------------------------------------------
- nonvirtual void() nail1 = [$nailatt1, nail2]
+ void() pl_nail1 = [$nailatt1, pl_nail2]
{
- this.effects = this.effects | EF_MUZZLEFLASH;
+ self.effects = self.effects | EF_MUZZLEFLASH;

- if (!this.button0)
+ if (!self.button0)
{
- this.run1 ();
+ pl_run1 ();
return;
}

- this.weaponframe = this.weaponframe + 1;
- if (this.weaponframe == 9)
- this.weaponframe = 1;
- this.superdamage_sound ();
- this.fire_spikes (4);
- this.attack_finished = time + 0.2;
+ self.weaponframe = self.weaponframe + 1;
+ if (self.weaponframe == 9)
+ self.weaponframe = 1;
+ player_superdamage_sound ();
+ player_fire_spikes (4);
+ self.attack_finished = time + 0.2;
};
- nonvirtual void() nail2 = [$nailatt2, nail1]
+ void() pl_nail2 = [$nailatt2, pl_nail1]
{
- this.effects = this.effects | EF_MUZZLEFLASH;
+ self.effects = self.effects | EF_MUZZLEFLASH;

- if (!this.button0)
+ if (!self.button0)
{
- this.run1 ();
+ pl_run1 ();
return;
}

- this.weaponframe = this.weaponframe + 1;
- if (this.weaponframe == 9)
- this.weaponframe = 1;
- this.superdamage_sound ();
- this.fire_spikes (-4);
- this.attack_finished = time + 0.2;
+ self.weaponframe = self.weaponframe + 1;
+ if (self.weaponframe == 9)
+ self.weaponframe = 1;
+ player_superdamage_sound ();
+ player_fire_spikes (-4);
+ self.attack_finished = time + 0.2;
};

//--------------------------------------------------------------
// Player LG Attack
//--------------------------------------------------------------
- nonvirtual void() light1 = [$light1, light2]
+ void() pl_light1 = [$light1, pl_light2]
{
- this.effects = this.effects | EF_MUZZLEFLASH;
+ self.effects = self.effects | EF_MUZZLEFLASH;

- if (!this.button0)
+ if (!self.button0)
{
- this.run1 ();
+ pl_run1 ();
return;
}

- this.weaponframe = this.weaponframe + 1;
- if (this.weaponframe == 5)
- this.weaponframe = 1;
- this.superdamage_sound ();
- this.fire_lightning ();
- this.attack_finished = time + 0.2;
+ self.weaponframe = self.weaponframe + 1;
+ if (self.weaponframe == 5)
+ self.weaponframe = 1;
+ player_superdamage_sound ();
+ player_fire_lightning ();
+ self.attack_finished = time + 0.2;
};
- nonvirtual void() light2 = [$light2, light1]
+ void() pl_light2 = [$light2, pl_light1]
{
- this.effects = this.effects | EF_MUZZLEFLASH;
+ self.effects = self.effects | EF_MUZZLEFLASH;

- if (!this.button0)
+ if (!self.button0)
{
- this.run1 ();
+ pl_run1 ();
return;
}

- this.weaponframe = this.weaponframe + 1;
- if (this.weaponframe == 5)
- this.weaponframe = 1;
- this.superdamage_sound ();
- this.fire_lightning ();
- this.attack_finished = time + 0.2;
+ self.weaponframe = self.weaponframe + 1;
+ if (self.weaponframe == 5)
+ self.weaponframe = 1;
+ player_superdamage_sound ();
+ player_fire_lightning ();
+ self.attack_finished = time + 0.2;
};

//--------------------------------------------------------------
// Player Rocket Attack
//--------------------------------------------------------------
- nonvirtual void() rocket1 = [$rockatt1, rocket2]
+ void() pl_rocket1 = [$rockatt1, pl_rocket2]
{
- this.weaponframe = 1;
- this.effects = this.effects | EF_MUZZLEFLASH;
+ self.weaponframe = 1;
+ self.effects = self.effects | EF_MUZZLEFLASH;
};
- nonvirtual void() rocket2 = [$rockatt2, rocket3] { weaponframe = 2; };
- nonvirtual void() rocket3 = [$rockatt3, rocket4] { weaponframe = 3; };
- nonvirtual void() rocket4 = [$rockatt4, rocket5] { weaponframe = 4; };
- nonvirtual void() rocket5 = [$rockatt5, rocket6] { weaponframe = 5; };
- nonvirtual void() rocket6 = [$rockatt6, run1] { weaponframe = 6; };
+ void() pl_rocket2 = [$rockatt2, pl_rocket3] { self.weaponframe = 2; };
+ void() pl_rocket3 = [$rockatt3, pl_rocket4] { self.weaponframe = 3; };
+ void() pl_rocket4 = [$rockatt4, pl_rocket5] { self.weaponframe = 4; };
+ void() pl_rocket5 = [$rockatt5, pl_rocket6] { self.weaponframe = 5; };
+ void() pl_rocket6 = [$rockatt6, pl_run1] { self.weaponframe = 6; };

//--------------------------------------------------------------
// Player Pain state A
//--------------------------------------------------------------
- nonvirtual void() pain1 = [$pain1, pain2]
+ void() pl_pain1 = [$pain1, pl_pain2]
{
- this.pain_sound ();
- this.weaponframe = 0;
+ player_pain_sound ();
+ self.weaponframe = 0;
};
- nonvirtual void() pain2 = [$pain2, pain3] { };
- nonvirtual void() pain3 = [$pain3, pain4] { };
- nonvirtual void() pain4 = [$pain4, pain5] { };
- nonvirtual void() pain5 = [$pain5, pain6] { };
- nonvirtual void() pain6 = [$pain6, run1] { };
+ void() pl_pain2 = [$pain2, pl_pain3] { };
+ void() pl_pain3 = [$pain3, pl_pain4] { };
+ void() pl_pain4 = [$pain4, pl_pain5] { };
+ void() pl_pain5 = [$pain5, pl_pain6] { };
+ void() pl_pain6 = [$pain6, pl_run1] { };

//--------------------------------------------------------------
// Player Axe Pain state A
//--------------------------------------------------------------
- nonvirtual void() axpain1 = [$axpain1, axpain2]
+ void() pl_axpain1 = [$axpain1, pl_axpain2]
{
- this.pain_sound ();
- this.weaponframe = 0;
+ player_pain_sound ();
+ self.weaponframe = 0;
};
- nonvirtual void() axpain2 = [$axpain2, axpain3] {};
- nonvirtual void() axpain3 = [$axpain3, axpain4] {};
- nonvirtual void() axpain4 = [$axpain4, axpain5] {};
- nonvirtual void() axpain5 = [$axpain5, axpain6] {};
- nonvirtual void() axpain6 = [$axpain6, run1] {};
+ void() pl_axpain2 = [$axpain2, pl_axpain3] {};
+ void() pl_axpain3 = [$axpain3, pl_axpain4] {};
+ void() pl_axpain4 = [$axpain4, pl_axpain5] {};
+ void() pl_axpain5 = [$axpain5, pl_axpain6] {};
+ void() pl_axpain6 = [$axpain6, pl_run1] {};

//--------------------------------------------------------------
// Player Death state A
//--------------------------------------------------------------
- nonvirtual void() diea1 = [$deatha1, diea2] {};
- nonvirtual void() diea2 = [$deatha2, diea3] {};
- nonvirtual void() diea3 = [$deatha3, diea4] {};
- nonvirtual void() diea4 = [$deatha4, diea5] {};
- nonvirtual void() diea5 = [$deatha5, diea6] {};
- nonvirtual void() diea6 = [$deatha6, diea7] {};
- nonvirtual void() diea7 = [$deatha7, diea8] {};
- nonvirtual void() diea8 = [$deatha8, diea9] {};
- nonvirtual void() diea9 = [$deatha9, diea10] {};
- nonvirtual void() diea10 = [$deatha10, diea11] {};
- nonvirtual void() diea11 = [$deatha11, diea11] { this.dead (); };
+ void() pl_diea1 = [$deatha1, pl_diea2] {};
+ void() pl_diea2 = [$deatha2, pl_diea3] {};
+ void() pl_diea3 = [$deatha3, pl_diea4] {};
+ void() pl_diea4 = [$deatha4, pl_diea5] {};
+ void() pl_diea5 = [$deatha5, pl_diea6] {};
+ void() pl_diea6 = [$deatha6, pl_diea7] {};
+ void() pl_diea7 = [$deatha7, pl_diea8] {};
+ void() pl_diea8 = [$deatha8, pl_diea9] {};
+ void() pl_diea9 = [$deatha9, pl_diea10] {};
+ void() pl_diea10 = [$deatha10, pl_diea11] {};
+ void() pl_diea11 = [$deatha11, pl_diea11] { player_dead (); };

//--------------------------------------------------------------
// Player Death state B
//--------------------------------------------------------------
- nonvirtual void() dieb1 = [$deathb1, dieb2] {};
- nonvirtual void() dieb2 = [$deathb2, dieb3] {};
- nonvirtual void() dieb3 = [$deathb3, dieb4] {};
- nonvirtual void() dieb4 = [$deathb4, dieb5] {};
- nonvirtual void() dieb5 = [$deathb5, dieb6] {};
- nonvirtual void() dieb6 = [$deathb6, dieb7] {};
- nonvirtual void() dieb7 = [$deathb7, dieb8] {};
- nonvirtual void() dieb8 = [$deathb8, dieb9] {};
- nonvirtual void() dieb9 = [$deathb9, dieb9] { this.dead (); };
+ void() pl_dieb1 = [$deathb1, pl_dieb2] {};
+ void() pl_dieb2 = [$deathb2, pl_dieb3] {};
+ void() pl_dieb3 = [$deathb3, pl_dieb4] {};
+ void() pl_dieb4 = [$deathb4, pl_dieb5] {};
+ void() pl_dieb5 = [$deathb5, pl_dieb6] {};
+ void() pl_dieb6 = [$deathb6, pl_dieb7] {};
+ void() pl_dieb7 = [$deathb7, pl_dieb8] {};
+ void() pl_dieb8 = [$deathb8, pl_dieb9] {};
+ void() pl_dieb9 = [$deathb9, pl_dieb9] { player_dead (); };

//--------------------------------------------------------------
// Player Death state C
//--------------------------------------------------------------
- nonvirtual void() diec1 = [$deathc1, diec2] {};
- nonvirtual void() diec2 = [$deathc2, diec3] {};
- nonvirtual void() diec3 = [$deathc3, diec4] {};
- nonvirtual void() diec4 = [$deathc4, diec5] {};
- nonvirtual void() diec5 = [$deathc5, diec6] {};
- nonvirtual void() diec6 = [$deathc6, diec7] {};
- nonvirtual void() diec7 = [$deathc7, diec8] {};
- nonvirtual void() diec8 = [$deathc8, diec9] {};
- nonvirtual void() diec9 = [$deathc9, diec10] {};
- nonvirtual void() diec10 = [$deathc10, diec11] {};
- nonvirtual void() diec11 = [$deathc11, diec12] {};
- nonvirtual void() diec12 = [$deathc12, diec13] {};
- nonvirtual void() diec13 = [$deathc13, diec14] {};
- nonvirtual void() diec14 = [$deathc14, diec15] {};
- nonvirtual void() diec15 = [$deathc15, diec15] { this.dead (); };
+ void() pl_diec1 = [$deathc1, pl_diec2] {};
+ void() pl_diec2 = [$deathc2, pl_diec3] {};
+ void() pl_diec3 = [$deathc3, pl_diec4] {};
+ void() pl_diec4 = [$deathc4, pl_diec5] {};
+ void() pl_diec5 = [$deathc5, pl_diec6] {};
+ void() pl_diec6 = [$deathc6, pl_diec7] {};
+ void() pl_diec7 = [$deathc7, pl_diec8] {};
+ void() pl_diec8 = [$deathc8, pl_diec9] {};
+ void() pl_diec9 = [$deathc9, pl_diec10] {};
+ void() pl_diec10 = [$deathc10, pl_diec11] {};
+ void() pl_diec11 = [$deathc11, pl_diec12] {};
+ void() pl_diec12 = [$deathc12, pl_diec13] {};
+ void() pl_diec13 = [$deathc13, pl_diec14] {};
+ void() pl_diec14 = [$deathc14, pl_diec15] {};
+ void() pl_diec15 = [$deathc15, pl_diec15] { player_dead (); };

//--------------------------------------------------------------
// Player Death state D
//--------------------------------------------------------------
- nonvirtual void() died1 = [$deathd1, died2] {};
- nonvirtual void() died2 = [$deathd2, died3] {};
- nonvirtual void() died3 = [$deathd3, died4] {};
- nonvirtual void() died4 = [$deathd4, died5] {};
- nonvirtual void() died5 = [$deathd5, died6] {};
- nonvirtual void() died6 = [$deathd6, died7] {};
- nonvirtual void() died7 = [$deathd7, died8] {};
- nonvirtual void() died8 = [$deathd8, died9] {};
- nonvirtual void() died9 = [$deathd9, died9] { this.dead (); };
+ void() pl_died1 = [$deathd1, pl_died2] {};
+ void() pl_died2 = [$deathd2, pl_died3] {};
+ void() pl_died3 = [$deathd3, pl_died4] {};
+ void() pl_died4 = [$deathd4, pl_died5] {};
+ void() pl_died5 = [$deathd5, pl_died6] {};
+ void() pl_died6 = [$deathd6, pl_died7] {};
+ void() pl_died7 = [$deathd7, pl_died8] {};
+ void() pl_died8 = [$deathd8, pl_died9] {};
+ void() pl_died9 = [$deathd9, pl_died9] { player_dead (); };

//--------------------------------------------------------------
// Player Death state E
//--------------------------------------------------------------
- nonvirtual void() diee1 = [$deathe1, diee2] {};
- nonvirtual void() diee2 = [$deathe2, diee3] {};
- nonvirtual void() diee3 = [$deathe3, diee4] {};
- nonvirtual void() diee4 = [$deathe4, diee5] {};
- nonvirtual void() diee5 = [$deathe5, diee6] {};
- nonvirtual void() diee6 = [$deathe6, diee7] {};
- nonvirtual void() diee7 = [$deathe7, diee8] {};
- nonvirtual void() diee8 = [$deathe8, diee9] {};
- nonvirtual void() diee9 = [$deathe9, diee9] { this.dead (); };
+ void() pl_diee1 = [$deathe1, pl_diee2] {};
+ void() pl_diee2 = [$deathe2, pl_diee3] {};
+ void() pl_diee3 = [$deathe3, pl_diee4] {};
+ void() pl_diee4 = [$deathe4, pl_diee5] {};
+ void() pl_diee5 = [$deathe5, pl_diee6] {};
+ void() pl_diee6 = [$deathe6, pl_diee7] {};
+ void() pl_diee7 = [$deathe7, pl_diee8] {};
+ void() pl_diee8 = [$deathe8, pl_diee9] {};
+ void() pl_diee9 = [$deathe9, pl_diee9] { player_dead (); };

//--------------------------------------------------------------
// Player Axe Death state A
//--------------------------------------------------------------
- nonvirtual void() die_ax1 = [$axdeth1, die_ax2] {};
- nonvirtual void() die_ax2 = [$axdeth2, die_ax3] {};
- nonvirtual void() die_ax3 = [$axdeth3, die_ax4] {};
- nonvirtual void() die_ax4 = [$axdeth4, die_ax5] {};
- nonvirtual void() die_ax5 = [$axdeth5, die_ax6] {};
- nonvirtual void() die_ax6 = [$axdeth6, die_ax7] {};
- nonvirtual void() die_ax7 = [$axdeth7, die_ax8] {};
- nonvirtual void() die_ax8 = [$axdeth8, die_ax9] {};
- nonvirtual void() die_ax9 = [$axdeth9, die_ax9] { this.dead (); };
+ void() pl_die_ax1 = [$axdeth1, pl_die_ax2] {};
+ void() pl_die_ax2 = [$axdeth2, pl_die_ax3] {};
+ void() pl_die_ax3 = [$axdeth3, pl_die_ax4] {};
+ void() pl_die_ax4 = [$axdeth4, pl_die_ax5] {};
+ void() pl_die_ax5 = [$axdeth5, pl_die_ax6] {};
+ void() pl_die_ax6 = [$axdeth6, pl_die_ax7] {};
+ void() pl_die_ax7 = [$axdeth7, pl_die_ax8] {};
+ void() pl_die_ax8 = [$axdeth8, pl_die_ax9] {};
+ void() pl_die_ax9 = [$axdeth9, pl_die_ax9] { player_dead (); };

//--------------------------------------------------------------
// PlayerDeathThink -- called from prethink when dead
//--------------------------------------------------------------
- nonvirtual void() think_death =
+ void() player_death_think =
{
local float forward;

- if ((this.flags & FL_ONGROUND))
+ if ((self.flags & FL_ONGROUND))
{
- forward = vlen (this.velocity);
+ forward = vlen (self.velocity);
forward = forward - 20;
if (forward <= 0)
- this.velocity = '0 0 0';
+ self.velocity = '0 0 0';
else
- this.velocity = forward *
- normalize (this.velocity);
+ self.velocity = forward *
+ normalize (self.velocity);
}

// wait for all buttons released
- if (this.deadflag == DEAD_DEAD)
+ if (self.deadflag == DEAD_DEAD)
{
- if (this.button2 || this.button1 || this.button0)
+ if (self.button2 || self.button1 || self.button0)
return;
- this.deadflag = DEAD_RESPAWNABLE;
+ self.deadflag = DEAD_RESPAWNABLE;
return;
}

// wait for any button down
- if (!this.button2 && !this.button1 && !this.button0)
+ if (!self.button2 && !self.button1 && !self.button0)
return;

- this.button0 = 0;
- this.button1 = 0;
- this.button2 = 0;
- this.init_respawn ();
+ self.button0 = 0;
+ self.button1 = 0;
+ self.button2 = 0;
+ player_respawn ();
};

//--------------------------------------------------------------
// WaterMove
//--------------------------------------------------------------
- nonvirtual void() prethink_watermove =
+ void() player_prethink_watermove =
{
- if (this.movetype == MOVETYPE_NOCLIP)
+ if (self.movetype == MOVETYPE_NOCLIP)
{
- this.air_finished = time + 120;
+ self.air_finished = time + 120;
return;
}

- if (this.health < 0)
+ if (self.health < 0)
return;

- if (this.waterlevel != 3)
+ if (self.waterlevel != 3)
{
- if (this.air_finished < time)
- sound (this, CHAN_VOICE, "player/gasp2.wav",
+ if (self.air_finished < time)
+ sound (self, CHAN_VOICE, "player/gasp2.wav",
1, ATTN_NORM);
- else if (this.air_finished < time + 9)
- sound (this, CHAN_VOICE, "player/gasp1.wav",
+ else if (self.air_finished < time + 9)
+ sound (self, CHAN_VOICE, "player/gasp1.wav",
1, ATTN_NORM);
- this.air_finished = time + 12;
- this.dmg = 2;
+ self.air_finished = time + 12;
+ self.dmg = 2;
}
- else if (this.air_finished < time)
+ else if (self.air_finished < time)
{
// drown!
- if (this.pain_finished < time)
+ if (self.pain_finished < time)
{
- this.dmg = this.dmg + 2;
- if (this.dmg > 15)
- this.dmg = 10;
- this.deathtype = "drowning";
- this.t_damage2 (this, world, world, this.dmg);
- this.deathtype = "";
- this.pain_finished = time + 1;
+ self.dmg = self.dmg + 2;
+ if (self.dmg > 15)
+ self.dmg = 10;
+ self.deathtype = "drowning";
+ t_damage2 (self, world, world, self.dmg);
+ self.deathtype = "";
+ self.pain_finished = time + 1;
}
}

- if (!this.waterlevel)
+ if (!self.waterlevel)
{
- if (this.flags & FL_INWATER)
+ if (self.flags & FL_INWATER)
{
// play leave water sound
- sound (this, CHAN_BODY, "misc/outwater.wav",
+ sound (self, CHAN_BODY, "misc/outwater.wav",
1, ATTN_NORM);
- this.flags = this.flags - FL_INWATER;
+ self.flags = self.flags - FL_INWATER;
}
return;
}

- if (this.watertype == CONTENT_LAVA)
+ if (self.watertype == CONTENT_LAVA)
{
// do damage
- if (this.dmgtime < time)
+ if (self.damage_time < time)
{
- if (this.radsuit_finished > time)
- this.dmgtime = time + 1;
+ if (self.radsuit_finished > time)
+ self.damage_time = time + 1;
else
- this.dmgtime = time + 0.2;
+ self.damage_time = time + 0.2;

- this.deathtype = "lava";
- this.t_damage2 (this, world, world,
- 10 * this.waterlevel);
- this.deathtype = "";
+ self.deathtype = "lava";
+ t_damage2 (self, world, world,
+ 10 * self.waterlevel);
+ self.deathtype = "";
}
}
- else if (this.watertype == CONTENT_SLIME)
+ else if (self.watertype == CONTENT_SLIME)
{
// do damage
- if (this.dmgtime < time && this.radsuit_finished < time)
+ if (self.damage_time < time &&
+ self.radsuit_finished < time)
{
- this.dmgtime = time + 1;
- this.deathtype = "slime";
- this.t_damage2 (this, world, world,
- 4 * this.waterlevel);
- this.deathtype = "";
+ self.damage_time = time + 1;
+ self.deathtype = "slime";
+ t_damage2 (self, world, world,
+ 4 * self.waterlevel);
+ self.deathtype = "";
}
}

- if (!(this.flags & FL_INWATER))
+ if (!(self.flags & FL_INWATER))
{
// player enter water sound
- if (this.watertype == CONTENT_LAVA)
- sound (this, CHAN_BODY, "player/inlava.wav",
+ if (self.watertype == CONTENT_LAVA)
+ sound (self, CHAN_BODY, "player/inlava.wav",
1, ATTN_NORM);
- if (this.watertype == CONTENT_WATER)
- sound (this, CHAN_BODY, "player/inh2o.wav",
+ if (self.watertype == CONTENT_WATER)
+ sound (self, CHAN_BODY, "player/inh2o.wav",
1, ATTN_NORM);
- if (this.watertype == CONTENT_SLIME)
- sound (this, CHAN_BODY, "player/slimbrn2.wav",
+ if (self.watertype == CONTENT_SLIME)
+ sound (self, CHAN_BODY, "player/slimbrn2.wav",
1, ATTN_NORM);

- this.flags = this.flags + FL_INWATER;
- this.dmgtime = 0;
+ self.flags = self.flags + FL_INWATER;
+ self.damage_time = 0;
}
};

//--------------------------------------------------------------
// CheckWaterJump -- the legacy standard id1 (?) waterjump
//--------------------------------------------------------------
- nonvirtual void() prethink_waterjump =
+ void() player_prethink_waterjump =
{
// from Copper -- dumptruck_ds
- if (this.movetype == MOVETYPE_NOCLIP)
+ if (self.movetype == MOVETYPE_NOCLIP)
return;

local vector start, end;

// check for a jump-out-of-water
- makevectors (this.angles);
- start = this.origin;
+ makevectors (self.angles);
+ start = self.origin;
start_z = start_z + 8;
v_forward_z = 0;
normalize (v_forward);
end = start + v_forward * 24;
- traceline (start, end, TRUE, this);
+ traceline (start, end, TRUE, self);
if (trace_fraction < 1)
{
// solid at waist
- start_z = start_z + this.maxs_z - 8;
+ start_z = start_z + self.maxs_z - 8;
end = start + v_forward * 24;
- this.movedir = trace_plane_normal * -50;
- traceline (start, end, TRUE, this);
+ self.movedir = trace_plane_normal * -50;
+ traceline (start, end, TRUE, self);
if (trace_fraction == 1)
{
// open at eye level
- this.flags = this.flags | FL_WATERJUMP;
- this.velocity_z = 225;
- this.flags -= this.flags & FL_JUMPRELEASED;
+ self.flags = self.flags | FL_WATERJUMP;
+ self.velocity_z = 225;
+ self.flags -= self.flags & FL_JUMPRELEASED;
// safety net
- this.teleport_time = time + 2;
+ self.teleport_time = time + 2;
return;
}
}
@@ -1542,30 +1651,30 @@ class player: base_entity
//--------------------------------------------------------------
// PlayerJump -- standard legacy id1 jump logic
//--------------------------------------------------------------
- nonvirtual void() prethink_jump =
+ void() player_prethink_jump =
{
- if (this.flags & FL_WATERJUMP)
+ if (self.flags & FL_WATERJUMP)
return;

- if (this.waterlevel >= 2)
+ if (self.waterlevel >= 2)
{
- if (this.watertype == CONTENT_WATER)
- this.velocity_z = 100;
- else if (this.watertype == CONTENT_SLIME)
- this.velocity_z = 80;
+ if (self.watertype == CONTENT_WATER)
+ self.velocity_z = 100;
+ else if (self.watertype == CONTENT_SLIME)
+ self.velocity_z = 80;
else
- this.velocity_z = 50;
+ self.velocity_z = 50;

// play swiming sound
- if (this.swim_flag < time)
+ if (self.swim_flag < time)
{
- this.swim_flag = time + 1;
+ self.swim_flag = time + 1;
if (random() < 0.5)
- sound (this, CHAN_BODY,
+ sound (self, CHAN_BODY,
"misc/water1.wav",
1, ATTN_NORM);
else
- sound (this, CHAN_BODY,
+ sound (self, CHAN_BODY,
"misc/water2.wav",
1, ATTN_NORM);
}
@@ -1573,31 +1682,31 @@ class player: base_entity
}

// refactoring from Copper -- dumptruck_ds
- if (this.movetype != MOVETYPE_NOCLIP)
+ if (self.movetype != MOVETYPE_NOCLIP)
{
- if (!(this.flags & FL_ONGROUND))
+ if (!(self.flags & FL_ONGROUND))
return;
// don't pogo stick
- if ( !(this.flags & FL_JUMPRELEASED) )
+ if ( !(self.flags & FL_JUMPRELEASED) )
return;
// player jumping sound (h00rt)
- sound (this, CHAN_BODY, "player/plyrjmp8.wav",
+ sound (self, CHAN_BODY, "player/plyrjmp8.wav",
1, ATTN_NORM);
}

- this.flags = this.flags - (this.flags & FL_JUMPRELEASED);
+ self.flags = self.flags - (self.flags & FL_JUMPRELEASED);

// don't stairwalk
- this.flags = this.flags - FL_ONGROUND;
+ self.flags = self.flags - FL_ONGROUND;

- this.button2 = 0;
- this.velocity_z = this.velocity_z + 270;
+ self.button2 = 0;
+ self.velocity_z = self.velocity_z + 270;
};

//--------------------------------------------------------------
// Called by PlayerPreThink in entrypoints.qc -- CEV
//--------------------------------------------------------------
- nonvirtual void() prethink =
+ void() player_prethink =
{
local float do_ladder_physics = FALSE;

@@ -1605,290 +1714,284 @@ class player: base_entity
// which check whether the player is dead, so that the
// player's gravity will be correctly updated even if
// they e.g. fell off a ladder because they died -- iw
- if (frame_standardphysics)
+ if (world_standardphysics)
{
- if (this.pmove_flags & PMF_ONLADDER)
+ if (self.pmove_flags & PMF_ONLADDER)
{
do_ladder_physics = TRUE;
// not zero, because zero means "default"
- this.gravity = 0.0000001;
- this.pmove_flags &= ~PMF_ONLADDER;
+ self.gravity = 0.0000001;
+ self.pmove_flags &= ~PMF_ONLADDER;
}
else
{
do_ladder_physics = FALSE;
- this.gravity = this.wantedgravity;
+ self.gravity = self.wantedgravity;
}

// from copper -- dumptruck_ds
- if (this.movetype == MOVETYPE_NOCLIP)
- this.flags |= FL_FLY;
+ if (self.movetype == MOVETYPE_NOCLIP)
+ self.flags |= FL_FLY;
}
else
{
- this.gravity = this.wantedgravity;
+ self.gravity = self.wantedgravity;
}

/*
dprint (sprintf("player::prethink: getlight %v\n",
- getlight (this.origin)));
+ getlight (self.origin)));
*/

// If just spawned in, try to recover previous fog values
// from own client entity, if any
- if (cleanUpClientStuff)
- fog_setFromEnt (this, this);
+ if (clean_up_client_stuff)
+ fog_set_from_ent (self, self);

// WaterMove - needs to run even if doing nonstandard physics
- this.prethink_watermove ();
+ player_prethink_watermove ();

- if (frame_standardphysics)
+ if (world_standardphysics)
{
// run legacy CheckWaterJump if we're doing
// standard physics -- CEV
- if (this.waterlevel == 2)
- this.prethink_waterjump ();
+ if (self.waterlevel == 2)
+ player_prethink_waterjump ();

// johnfitz ladder conditions, added from
// Rubicon2 -- dumptruck_ds
if (do_ladder_physics)
{
- if (this.button2)
+ if (self.button2)
{
// PlayerClimb -- johnfitz
- this.velocity = '0 0 160';
+ self.velocity = '0 0 160';
/*
// no ladder footsteps for now
- if (time > this.ladder_step_finished)
+ if (time > self.ladder_step_finished)
{
// TODO CEV oof
r = random();
if (r > 0.66)
- sound (this, CHAN_BODY,
+ sound (self, CHAN_BODY,
"ladder/metal1.wav",
0.5, ATTN_NORM);
else if (r > 0.33)
- sound (this, CHAN_BODY,
+ sound (self, CHAN_BODY,
"ladder/metal2.wav",
0.5, ATTN_NORM);
else
- sound (this, CHAN_BODY,
+ sound (self, CHAN_BODY,
"ladder/metal3.wav",
0.5, ATTN_NORM);
- this.ladder_step_finished =
+ self.ladder_step_finished =
time + 0.3;
}
*/
}
else
{
- this.flags |= FL_JUMPRELEASED;
- this.velocity = 0.9 * this.velocity;
- this.velocity_z = 0;
+ self.flags |= FL_JUMPRELEASED;
+ self.velocity = 0.9 * self.velocity;
+ self.velocity_z = 0;
}
}
else
{
- if (this.button2)
- this.prethink_jump ();
+ if (self.button2)
+ player_prethink_jump ();
else
- this.flags |= FL_JUMPRELEASED;
+ self.flags |= FL_JUMPRELEASED;
}
}

- if (this.deadflag >= DEAD_DEAD)
+ if (self.deadflag >= DEAD_DEAD)
{
// dead, so run the death think -- CEV
- this.think_death ();
+ player_death_think ();
return;
}

- if (this.deadflag == DEAD_DYING)
+ if (self.deadflag == DEAD_DYING)
// dying, so do nothing
return;

// teleporters can force a non-moving pause time
- if (time < this.pausetime)
- this.velocity = '0 0 0';
+ if (time < self.pausetime)
+ self.velocity = '0 0 0';

- if (time > this.attack_finished && this.currentammo == 0
- && this.weapon != IT_AXE)
- {
- this.weapon = this.best_weapon ();
- this.set_current_ammo ();
- }
-
- // TODO CEV
- if (this.groundboost_timer <= 0 &&
- (this.teleport_time > time - 0.1))
+ if (time > self.attack_finished && self.currentammo == 0
+ && self.weapon != IT_AXE)
{
- this.groundboost_timer = PM_GROUNDBOOST_WINDOW;
+ self.weapon = player_best_weapon ();
+ player_set_current_ammo ();
}
};

//--------------------------------------------------------------
// CheckPowerups -- Check for turning off powerups
//--------------------------------------------------------------
- nonvirtual void() postthink_powerups =
+ void() player_postthink_powerups =
{
- if (this.health <= 0)
+ if (self.health <= 0)
return;

// invisibility
- if (this.invisible_finished)
+ if (self.invisible_finished)
{
// sound and screen flash when items starts to run out
- if (this.invisible_sound < time)
+ if (self.invisible_sound < time)
{
- sound (this, CHAN_AUTO, "items/inv3.wav",
+ sound (self, CHAN_AUTO, "items/inv3.wav",
0.5, ATTN_IDLE);
- invisible_sound = time + ((random() * 3) + 1);
+ self.invisible_sound = time +
+ ((random() * 3) + 1);
}

- if (this.invisible_finished < time + 3)
+ if (self.invisible_finished < time + 3)
{
- if (this.invisible_time == 1)
+ if (self.invisible_time == 1)
{
- sprint (this, "Ring of Shadows magic is"
+ sprint (self, "Ring of Shadows magic is"
" fading\n");
- stuffcmd (this, "bf\n");
- sound (this, CHAN_AUTO,"items/inv2.wav",
+ stuffcmd (self, "bf\n");
+ sound (self, CHAN_AUTO,"items/inv2.wav",
1, ATTN_NORM);
- this.invisible_time = time + 1;
+ self.invisible_time = time + 1;
}

- if (this.invisible_time < time)
+ if (self.invisible_time < time)
{
- this.invisible_time = time + 1;
- stuffcmd (this, "bf\n");
+ self.invisible_time = time + 1;
+ stuffcmd (self, "bf\n");
}
}

- if (this.invisible_finished < time)
+ if (self.invisible_finished < time)
{
// just stopped
- this.items = this.items - IT_INVISIBILITY;
- this.invisible_finished = 0;
- this.invisible_time = 0;
+ self.items = self.items - IT_INVISIBILITY;
+ self.invisible_finished = 0;
+ self.invisible_time = 0;
}

// use the eyes
- this.frame = 0;
- this.modelindex = modelindex_eyes;
+ self.frame = 0;
+ self.modelindex = modelindex_eyes;
}
else
{
// don't use the eyes
- this.modelindex = modelindex_player;
+ self.modelindex = modelindex_player;
}

// invincibility
- if (this.invincible_finished)
+ if (self.invincible_finished)
{
// sound and screen flash when items starts to run out
- if (this.invincible_finished < time + 3)
+ if (self.invincible_finished < time + 3)
{
- if (this.invincible_time == 1)
+ if (self.invincible_time == 1)
{
- sprint (this, "Protection is almost "
+ sprint (self, "Protection is almost "
"burned out\n");
- stuffcmd (this, "bf\n");
- sound (this, CHAN_AUTO,
+ stuffcmd (self, "bf\n");
+ sound (self, CHAN_AUTO,
"items/protect2.wav",
1, ATTN_NORM);
- this.invincible_time = time + 1;
+ self.invincible_time = time + 1;
}

- if (this.invincible_time < time)
+ if (self.invincible_time < time)
{
- this.invincible_time = time + 1;
- stuffcmd (this, "bf\n");
+ self.invincible_time = time + 1;
+ stuffcmd (self, "bf\n");
}
}

- if (this.invincible_finished < time)
+ if (self.invincible_finished < time)
{
// just stopped
- this.items = this.items - IT_INVULNERABILITY;
- this.invincible_time = 0;
- this.invincible_finished = 0;
+ self.items = self.items - IT_INVULNERABILITY;
+ self.invincible_time = 0;
+ self.invincible_finished = 0;
}
- if (this.invincible_finished > time)
- this.effects = this.effects | EF_DIMLIGHT;
+ if (self.invincible_finished > time)
+ self.effects = self.effects | EF_DIMLIGHT;
else
- this.effects -= this.effects & EF_DIMLIGHT;
+ self.effects -= self.effects & EF_DIMLIGHT;
}

// super damage
- if (this.super_damage_finished)
+ if (self.super_damage_finished)
{
// sound and screen flash when items starts to run out
- if (this.super_damage_finished < time + 3)
+ if (self.super_damage_finished < time + 3)
{
- if (this.super_time == 1)
+ if (self.super_time == 1)
{
- sprint (this, "Quad Damage is wearing "
+ sprint (self, "Quad Damage is wearing "
"off\n");
- stuffcmd (this, "bf\n");
- sound (this, CHAN_AUTO,
+ stuffcmd (self, "bf\n");
+ sound (self, CHAN_AUTO,
"items/damage2.wav",
1, ATTN_NORM);
- this.super_time = time + 1;
+ self.super_time = time + 1;
}

- if (this.super_time < time)
+ if (self.super_time < time)
{
- this.super_time = time + 1;
- stuffcmd (this, "bf\n");
+ self.super_time = time + 1;
+ stuffcmd (self, "bf\n");
}
}

- if (this.super_damage_finished < time)
+ if (self.super_damage_finished < time)
{
// just stopped
- this.items = this.items - IT_QUAD;
- this.super_damage_finished = 0;
- this.super_time = 0;
+ self.items = self.items - IT_QUAD;
+ self.super_damage_finished = 0;
+ self.super_time = 0;
}
- if (this.super_damage_finished > time)
- this.effects = this.effects | EF_DIMLIGHT;
+ if (self.super_damage_finished > time)
+ self.effects = self.effects | EF_DIMLIGHT;
else
- this.effects -= this.effects & EF_DIMLIGHT;
+ self.effects -= self.effects & EF_DIMLIGHT;
}

// suit
- if (this.radsuit_finished)
+ if (self.radsuit_finished)
{
// don't drown
- this.air_finished = time + 12;
+ self.air_finished = time + 12;

// sound and screen flash when items starts to run out
- if (this.radsuit_finished < time + 3)
+ if (self.radsuit_finished < time + 3)
{
- if (this.rad_time == 1)
+ if (self.rad_time == 1)
{
- sprint (this, "Air supply in Biosuit "
+ sprint (self, "Air supply in Biosuit "
"expiring\n");
- stuffcmd (this, "bf\n");
- sound (this, CHAN_AUTO,
+ stuffcmd (self, "bf\n");
+ sound (self, CHAN_AUTO,
"items/suit2.wav",
1, ATTN_NORM);
- this.rad_time = time + 1;
+ self.rad_time = time + 1;
}

- if (this.rad_time < time)
+ if (self.rad_time < time)
{
- this.rad_time = time + 1;
- stuffcmd (this, "bf\n");
+ self.rad_time = time + 1;
+ stuffcmd (self, "bf\n");
}
}

- if (this.radsuit_finished < time)
+ if (self.radsuit_finished < time)
{
// just stopped
- this.items = this.items - IT_SUIT;
- this.rad_time = 0;
- this.radsuit_finished = 0;
+ self.items = self.items - IT_SUIT;
+ self.rad_time = 0;
+ self.radsuit_finished = 0;
}
}
};
@@ -1896,77 +1999,77 @@ class player: base_entity
//--------------------------------------------------------------
// Called by PlayerPostThink in entrypoints.qc -- CEV
//--------------------------------------------------------------
- nonvirtual void() postthink =
+ void() player_postthink =
{
- if (this.view_ofs == '0 0 0')
+ if (self.view_ofs == '0 0 0')
// intermission or finale
return;

// full send -- CEV
- this.SendFlags = 0xffffff;
+ self.SendFlags = 0xffffff;

- if (this.deadflag)
+ if (self.deadflag)
return;

// next block was in W_WeaponFrame -- CEV
- if (time >= this.attack_finished)
+ if (time >= self.attack_finished)
{
- if (this.impulse)
- this.impulse_commands ();
+ if (self.impulse)
+ player_impulse ();

- if (this.button0)
+ if (self.button0)
{
- this.superdamage_sound ();
- this.attack ();
+ player_superdamage_sound ();
+ player_attack ();
}
}

// check to see if player landed and play landing sound
- if ((this.jump_flag < -300) && (this.flags & FL_ONGROUND) &&
- (this.health > 0))
+ if ((self.jump_flag < -300) && (self.flags & FL_ONGROUND) &&
+ (self.health > 0))
{
- if (this.watertype == CONTENT_WATER)
- sound (this, CHAN_BODY, "player/h2ojump.wav",
+ if (self.watertype == CONTENT_WATER)
+ sound (self, CHAN_BODY, "player/h2ojump.wav",
1, ATTN_NORM);
- else if (this.jump_flag < -650)
+ else if (self.jump_flag < -650)
{
- this.deathtype = "falling";
- this.t_damage2 (this, world, world, 5);
- this.deathtype = "";
- sound (this, CHAN_VOICE, "player/land2.wav",
+ self.deathtype = "falling";
+ t_damage2 (self, world, world, 5);
+ self.deathtype = "";
+ sound (self, CHAN_VOICE, "player/land2.wav",
1, ATTN_NORM);
}
else
- sound (this, CHAN_VOICE, "player/land.wav",
+ sound (self, CHAN_VOICE, "player/land.wav",
1, ATTN_NORM);

- this.jump_flag = 0;
+ self.jump_flag = 0;
}

- if (!(this.flags & FL_ONGROUND))
- this.jump_flag = this.velocity_z;
+ if (!(self.flags & FL_ONGROUND))
+ self.jump_flag = self.velocity_z;

- // dumptruck_ds -- this replaces item_megahealth_rot in items.qc
- if (this.health > this.max_health)
+ // dumptruck_ds -- self replaces item_megahealth_rot in items.qc
+ if (self.health > self.max_health)
{
- if (this.megahealth_rottime < time)
+ if (self.megahealth_rottime < time)
{
- this.megahealth_rottime = time + 1;
- this.health = this.health - 1;
+ self.megahealth_rottime = time + 1;
+ self.health = self.health - 1;
}
- else if (this.health <= 100)
+ else if (self.health <= 100)
{
// thanks ydrol!!!
- this.items = this.items -
- (this.items & IT_SUPERHEALTH);
+ self.items = self.items -
+ (self.items & IT_SUPERHEALTH);
}
}

- this.postthink_powerups ();
+ player_postthink_powerups ();

// from Copper -- dumptruck_ds
- if (frame_standardphysics && this.movetype != MOVETYPE_NOCLIP)
- this.flags &= ~FL_FLY;
+ if (world_standardphysics && self.movetype != MOVETYPE_NOCLIP)
+ self.flags &= ~FL_FLY;
};

//==============================================================
@@ -1976,103 +2079,100 @@ class player: base_entity
//--------------------------------------------------------------
// SendEntity -- transmit updates from server to client -- CEV
//--------------------------------------------------------------
- virtual float(entity to, float fl) SendEntity =
+ float(entity to, float fl) player_sendentity =
{
WriteByte (MSG_ENTITY, CT_PLAYER);
- WriteByte (MSG_ENTITY, this.frame);
- WriteCoord (MSG_ENTITY, this.origin_x);
- WriteCoord (MSG_ENTITY, this.origin_y);
- WriteCoord (MSG_ENTITY, this.origin_z);
- WriteShort (MSG_ENTITY, this.angles_x * 32767 / 360);
- WriteShort (MSG_ENTITY, this.angles_y * 32767 / 360);
- WriteShort (MSG_ENTITY, this.angles_z * 32767 / 360);
- WriteShort (MSG_ENTITY, this.velocity_x);
- WriteShort (MSG_ENTITY, this.velocity_y);
- WriteShort (MSG_ENTITY, this.velocity_z);
- WriteFloat (MSG_ENTITY, this.effects);
- WriteFloat (MSG_ENTITY, this.flags);
- WriteFloat (MSG_ENTITY, this.pmove_flags);
- WriteFloat (MSG_ENTITY, this.doublejump_timer);
- WriteFloat (MSG_ENTITY, this.groundboost_timer);
+ WriteByte (MSG_ENTITY, self.frame);
+ WriteCoord (MSG_ENTITY, self.origin_x);
+ WriteCoord (MSG_ENTITY, self.origin_y);
+ WriteCoord (MSG_ENTITY, self.origin_z);
+ WriteShort (MSG_ENTITY, self.angles_x * 32767 / 360);
+ WriteShort (MSG_ENTITY, self.angles_y * 32767 / 360);
+ WriteShort (MSG_ENTITY, self.angles_z * 32767 / 360);
+ WriteShort (MSG_ENTITY, self.velocity_x);
+ WriteShort (MSG_ENTITY, self.velocity_y);
+ WriteShort (MSG_ENTITY, self.velocity_z);
+ WriteFloat (MSG_ENTITY, self.effects);
+ WriteFloat (MSG_ENTITY, self.flags);
+ WriteFloat (MSG_ENTITY, self.pmove_flags);
+ WriteFloat (MSG_ENTITY, self.doublejump_timer);
return TRUE;
};

//--------------------------------------------------------------
// player_pain
//--------------------------------------------------------------
- virtual void(entity attacker, float damage) do_damage =
+ void(entity attacker, float damage) player_pain =
{
- if (this.weaponframe)
+ if (self.weaponframe)
return;

- if (this.invisible_finished > time)
+ if (self.invisible_finished > time)
// eyes don't have pain frames
return;

- if (this.weapon == IT_AXE)
- this.axpain1 ();
+ if (self.weapon == IT_AXE)
+ pl_axpain1 ();
else
- this.pain1 ();
+ pl_pain1 ();
};

//--------------------------------------------------------------
// PlayerDie
//--------------------------------------------------------------
- virtual void() do_destroy =
+ void() player_destroy =
{
local float i;

// 1998-07-23 Palette shift when player dies with quad/pentagram
// fix by Maddes start
- // this.items = this.items - (this.items & IT_INVISIBILITY);
- this.items = this.items - (this.items &
+ // self.items = self.items - (self.items & IT_INVISIBILITY);
+ self.items = self.items - (self.items &
(IT_INVISIBILITY | IT_INVULNERABILITY |
IT_SUIT | IT_QUAD));
// 1998-07-23 Palette shift when player dies with quad/pentagram
// fix by Maddes end

// don't die as eyes
- // this.invisible_finished = 0;
- this.invincible_finished = 0;
- this.super_damage_finished = 0;
- this.radsuit_finished = 0;
+ // self.invisible_finished = 0;
+ self.invincible_finished = 0;
+ self.super_damage_finished = 0;
+ self.radsuit_finished = 0;

// 1998-07-23 Glowing corpse of players which had quad/pentagram
// until respawn fix by Maddes
- this.effects = 0;
+ self.effects = 0;

// don't use eyes
- this.modelindex = modelindex_player;
+ self.modelindex = modelindex_player;

if (deathmatch || coop)
- item_backpack::drop_backpack (this.origin, this.weapon,
- this.ammo_shells, this.ammo_nails,
- this.ammo_rockets, this.ammo_cells);
-
- this.weaponmodel = "";
- this.view_ofs = '0 0 -8';
- this.deadflag = DEAD_DYING;
- this.solid = SOLID_NOT;
- this.flags = this.flags - (this.flags & FL_ONGROUND);
- this.movetype = MOVETYPE_TOSS;
+ item_backpack_drop (self);
+
+ self.weaponmodel = "";
+ 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 (this.velocity_z < 10)
- this.velocity_z = this.velocity_z + random() * 300;
+ if (self.velocity_z < 10)
+ self.velocity_z = self.velocity_z + random() * 300;

- if (this.health < -40)
+ if (self.health < -40)
{
- GibPlayer ();
+ gib_player ();
return;
}

- this.death_sound ();
+ player_death_sound ();

- this.angles_x = 0;
- this.angles_z = 0;
+ self.angles_x = 0;
+ self.angles_z = 0;

- if (this.weapon == IT_AXE)
+ if (self.weapon == IT_AXE)
{
- this.die_ax1 ();
+ pl_die_ax1 ();
return;
}

@@ -2081,15 +2181,15 @@ class player: base_entity
i = 1 + floor (random() * 6);

if (i == 1)
- this.diea1 ();
+ pl_diea1 ();
else if (i == 2)
- this.dieb1 ();
+ pl_dieb1 ();
else if (i == 3)
- this.diec1 ();
+ pl_diec1 ();
else if (i == 4)
- this.died1 ();
+ pl_died1 ();
else
- this.diee1 ();
+ pl_diee1 ();
};

//--------------------------------------------------------------
@@ -2098,7 +2198,7 @@ class player: base_entity
// problem. The function below fixes that problem.
// based on code given to Kryten by: Michael Turitzin (MaNiAc)
//--------------------------------------------------------------
- virtual void() touch =
+ void() player_touch =
{
// 1998-09-16 Sliding/not-jumping on monsters/boxes/players
// fix by Maddes/Kryten start
@@ -2111,7 +2211,7 @@ class player: base_entity
return;

if ((!(other.flags & FL_ONGROUND)) &&
- ((other.absmin_z >= this.absmax_z - 2)))
+ ((other.absmin_z >= self.absmax_z - 2)))
{
other.flags = other.flags + FL_ONGROUND;
}
@@ -2129,23 +2229,23 @@ class player: base_entity
//--------------------------------------------------------------
// SelectSpawnPoint -- Returns the entity to spawn at
//--------------------------------------------------------------
- nonvirtual entity() init_select_spawn_point =
+ entity() player_init_selectspawnpoint =
{
local entity spot, thing;
local float pcount;

// testinfo_player_start is only found in regioned levels
- spot = findfloat (world, ::classtype, CT_INFO_TESTPLAYERSTART);
+ spot = findfloat (world, classtype, CT_INFO_TESTPLAYERSTART);
if (spot)
return spot;

// choose a info_player_deathmatch point
if (coop)
{
- lastspawn = findfloat (lastspawn, ::classtype,
+ lastspawn = findfloat (lastspawn, classtype,
CT_INFO_PLAYER_COOP);
if (lastspawn == world)
- lastspawn = findfloat (lastspawn, ::classtype,
+ lastspawn = findfloat (lastspawn, classtype,
CT_INFO_PLAYER_START);
if (lastspawn != world)
return lastspawn;
@@ -2157,7 +2257,7 @@ class player: base_entity
// info_player_deathmatch
while (1)
{
- spot = findfloat (spot, ::classtype,
+ spot = findfloat (spot, classtype,
CT_INFO_PLAYER_DEATHMATCH);
if (spot != world)
{
@@ -2183,22 +2283,22 @@ class player: base_entity
if (serverflags)
{
// return with a rune to start
- spot = findfloat (world, ::classtype,
+ spot = findfloat (world, classtype,
CT_INFO_PLAYER_START2);
if (spot)
return spot;
}

- spot = findfloat (world, ::classtype, CT_INFO_PLAYER_START);
+ spot = findfloat (world, classtype, CT_INFO_PLAYER_START);
if (!spot)
- error ("PutClientInServer: no info_player_start "
- "on level");
+ error ("player_init_selectspawnpoint: "
+ "no info_player_start on level");

return spot;
};

//--------------------------------------------------------------
- nonvirtual void() init_level_parms =
+ void() player_init_level_parms =
{
// Reset the player's inventory if they returned to the
// start map with a rune, or if the mapper set the
@@ -2211,39 +2311,39 @@ class player: base_entity
SetNewParms ();
}

- this.items = parm1;
- this.health = parm2;
- this.armorvalue = parm3;
- this.ammo_shells = parm4;
- this.ammo_nails = parm5;
- this.ammo_rockets = parm6;
- this.ammo_cells = parm7;
- this.weapon = parm8;
- this.armortype = parm9 * 0.01;
+ self.items = parm1;
+ self.health = parm2;
+ self.armorvalue = parm3;
+ self.ammo_shells = parm4;
+ self.ammo_nails = parm5;
+ self.ammo_rockets = parm6;
+ self.ammo_cells = parm7;
+ self.weapon = parm8;
+ self.armortype = parm9 * 0.01;
};

//--------------------------------------------------------------
// respawn -- called by ClientKill and DeadThink
//--------------------------------------------------------------
- nonvirtual void() init_respawn =
+ void() player_respawn =
{
if (coop)
{
// make a copy of the dead body for appearances sake
- CopyToBodyQue (this);
+ CopyToBodyQue (self);
// get the spawn parms as they were at level start
- setspawnparms (this);
+ setspawnparms (self);
// respawn
- this.init_spawned ();
+ player_init (self);
}
else if (deathmatch)
{
// make a copy of the dead body for appearances sake
- CopyToBodyQue (this);
+ CopyToBodyQue (self);
// set default spawn parms
SetNewParms ();
// respawn
- this.init_spawned ();
+ player_init (self);
}
else
{
@@ -2255,119 +2355,122 @@ class player: base_entity
//--------------------------------------------------------------
// most of this was previously in PutClientInServer -- CEV
//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) player_init =
{
local entity spot;

- spot = this.init_select_spawn_point ();
-
- this.health = 100;
- this.takedamage = DAMAGE_AIM;
- this.solid = SOLID_SLIDEBOX;
- // this.solid = SOLID_BBOX;
- this.movetype = MOVETYPE_WALK;
- this.show_hostile = 0;
- this.max_health = 100;
- this.flags = FL_CLIENT;
- this.air_finished = time + 12;
+ spot = player_init_selectspawnpoint ();
+
+ e.classname = "player";
+ e.classtype = CT_PLAYER;
+ e.health = 100;
+ e.takedamage = DAMAGE_AIM;
+ e.solid = SOLID_SLIDEBOX;
+ // e.solid = SOLID_BBOX;
+ e.movetype = MOVETYPE_WALK;
+ e.show_hostile = 0;
+ e.max_health = 100;
+ e.flags = FL_CLIENT;
+ e.air_finished = time + 12;
// initial water damage
- this.dmg = 2;
- this.super_damage_finished = 0;
- this.radsuit_finished = 0;
- this.invisible_finished = 0;
- this.invincible_finished = 0;
- this.effects = 0;
- this.invincible_time = 0;
- this.deathtype = "";
- this.gravity = 0;
- this.wantedgravity = 0;
+ e.dmg = 2;
+ e.super_damage_finished = 0;
+ e.radsuit_finished = 0;
+ e.invisible_finished = 0;
+ e.invincible_finished = 0;
+ e.effects = 0;
+ e.invincible_time = 0;
+ e.deathtype = "";
+ e.gravity = 0;
+ e.wantedgravity = 0;
// support for item_key_custom -- iw
- this.customkeys = 0;
+ e.customkeys = 0;

// Setup cutscene stuff. Legacy code from Zerstorer.
// -- dumptruck_ds
- this.script_count = 2;
- this.script_delay = 1;
- this.script_time = 0;
-
- this.init_level_parms ();
- this.set_current_ammo ();
-
- this.attack_finished = time;
- this.th_pain = this.do_damage;
- this.th_die = this.do_destroy;
- this.deadflag = DEAD_NO;
+ e.script_count = 2;
+ e.script_delay = 1;
+ e.script_time = 0;
+
+ player_init_level_parms ();
+ player_set_current_ammo ();
+
+ e.attack_finished = time;
+ e.pain = player_pain;
+ e.destroy = player_destroy;
+ e.touch = player_touch;
+ e.SendEntity = player_sendentity;
+ e.deadflag = DEAD_NO;
// pausetime is set by teleporters to keep the player
// from moving for a while
- this.pausetime = 0;
+ e.pausetime = 0;

- this.origin = spot.origin + '0 0 1';
- this.angles = spot.angles;
+ e.origin = spot.origin + '0 0 1';
+ e.angles = spot.angles;
// turn this way immediately
- this.fixangle = TRUE;
+ e.fixangle = TRUE;

// fog control.
// Looks if there's any fog values set at the current
// spawn point. If not, looks for those in worldspawn instead
if (spot.fog_density)
- fog_save (this, spot.fog_density, spot.fog_color);
+ fog_save (e, spot.fog_density, spot.fog_color);
else if (world.fog_density)
- fog_save (this, world.fog_density, world.fog_color);
+ fog_save (e, world.fog_density, world.fog_color);

if (spot.skyfog_density)
- skyfog_save (this, spot.skyfog_density);
+ skyfog_save (e, spot.skyfog_density);
else if (world.skyfog_density)
- skyfog_save (this, world.skyfog_density);
+ skyfog_save (e, world.skyfog_density);

// decreased on subsequent frames, used to start some
// fog-related stuff
- cleanUpClientStuff = 2;
+ clean_up_client_stuff = 2;

// oh, this is a hack!
- setmodel (this, "progs/eyes.mdl");
- modelindex_eyes = this.modelindex;
+ setmodel (e, "progs/eyes.mdl");
+ modelindex_eyes = e.modelindex;

// Drake -- dumptruck_ds
- setmodel (this, "progs/s_null.spr");
+ setmodel (e, "progs/s_null.spr");
// Drake -- dumptruck_ds
- // setmodel (this, "progs/null_256.spr");
- mindex_inviso = this.modelindex;
+ // setmodel (e, "progs/null_256.spr");
+ mindex_inviso = e.modelindex;

- setmodel (this, "progs/player.mdl");
- modelindex_player = this.modelindex;
+ setmodel (e, "progs/player.mdl");
+ modelindex_player = e.modelindex;

- setsize (this, VEC_HULL_MIN, VEC_HULL_MAX);
+ setsize (e, VEC_HULL_MIN, VEC_HULL_MAX);

- this.view_ofs = '0 0 22';
+ e.view_ofs = '0 0 22';
// Mod - Xian (May.20.97)
// Bug where player would have velocity from their last kill
- this.velocity = '0 0 0';
+ e.velocity = '0 0 0';
// 1998-07-21 Player moves after respawn fix by Xian

- this.SendFlags = 0xffffff;
+ e.SendFlags = 0xffffff;

- this.stand1 ();
+ // pl_stand1 needs 'self' to be 'e' -- CEV
+ if (self == e)
+ pl_stand1 ();
+ else
+ sub_runvoidas (e, pl_stand1);

if (deathmatch || coop)
{
- makevectors (this.angles);
- spawn_tfog (this.origin + v_forward*20);
+ makevectors (e.angles);
+ spawn_tfog (e.origin + v_forward * 20);
}

- spawn_tdeath (this.origin, this);
+ spawn_tdeath (e.origin, e);
};

//--------------------------------------------------------------
- void() player =
+ strip void() player =
{
- this.classname = "player";
- this.classtype = CT_PLAYER;
-
- // this isn't a subclass of base_mapentity so we need
- // to call init_spawned manually -- CEV
- this.init_spawned ();
+ player_init (self);
};
-};
+// };

//==============================================================================
//==============================================================================
@@ -2378,58 +2481,12 @@ class player: base_entity
//==============================================================================
//==============================================================================

-//----------------------------------------------------------------------
-void() PlayerDeathBubblesSpawn =
-{
- local temp_bubbles bubble;
- if (self.owner.waterlevel != WATERLEVEL_EYES && self.owner.health > 0)
- {
- // 1998-08-14 Improved bubble spawn by Maddes
- // 1998-08-14 Bubblespawner remove fix by Perged start
- // remove bubble spawner
- remove (self);
- // 1998-08-14 Bubblespawner remove fix by Perged end
- return;
- // 1998-08-14 Bubblespawner remove fix by Perged
- }
-
- bubble = spawn (temp_bubbles, origin: self.owner.origin + '0 0 24');
- // 1998-08-14 Improved bubble spawn by Maddes start
- // self.nextthink = time + 0.1;
- self.nextthink = time + 0.01;
- // 1998-08-14 Improved bubble spawn by Maddes end
- self.think = PlayerDeathBubblesSpawn;
- self.air_finished = self.air_finished + 1;
- if (self.air_finished >= self.bubble_count)
- remove (self);
-};
-
-//----------------------------------------------------------------------
-void(float num_bubbles) PlayerDeathBubbles =
-{
- local entity bubble_spawner;
-
- bubble_spawner = spawn ();
- setorigin (bubble_spawner, self.origin);
- bubble_spawner.movetype = MOVETYPE_NONE;
- bubble_spawner.solid = SOLID_NOT;
- // 1998-08-14 Improved bubble spawn by Maddes start
- // bubble_spawner.nextthink = time + 0.1;
- bubble_spawner.nextthink = time + 0.01;
- // 1998-08-14 Improved bubble spawn by Maddes end
- bubble_spawner.think = PlayerDeathBubblesSpawn;
- bubble_spawner.air_finished = 0;
- bubble_spawner.owner = self;
- bubble_spawner.bubble_count = num_bubbles;
- // return; // 1998-08-14 unnecessary by Maddes
-};
-
//==============================================================================
// Player Gibs
//==============================================================================

//----------------------------------------------------------------------
-vector(float dm) VelocityForDamage =
+vector(float dm) velocity_for_damage =
{
local vector v;

@@ -2456,7 +2513,7 @@ vector(float dm) VelocityForDamage =
};

//----------------------------------------------------------------------
-void(string gibname, float dm) ThrowGib =
+void(string gibname, float dm) throw_gib =
{
local entity new;

@@ -2464,7 +2521,7 @@ void(string gibname, float dm) ThrowGib =
new.origin = self.origin;
setmodel (new, gibname);
setsize (new, '0 0 0', '0 0 0');
- new.velocity = VelocityForDamage (dm);
+ new.velocity = velocity_for_damage (dm);
new.movetype = MOVETYPE_BOUNCE;
new.solid = SOLID_NOT;
new.avelocity_x = random() * 600;
@@ -2478,7 +2535,7 @@ void(string gibname, float dm) ThrowGib =
};

//----------------------------------------------------------------------
-void(string gibname, float dm) ThrowHead =
+void(string gibname, float dm) throw_head =
{
setmodel (self, gibname);

@@ -2495,19 +2552,19 @@ void(string gibname, float dm) ThrowHead =
self.solid = SOLID_NOT;
self.view_ofs = '0 0 8';
setsize (self, '-16 -16 0', '16 16 56');
- self.velocity = VelocityForDamage (dm);
+ self.velocity = velocity_for_damage (dm);
self.origin_z = self.origin_z - 24;
self.flags = self.flags - (self.flags & FL_ONGROUND);
self.avelocity = crandom() * '0 600 0';
};

//----------------------------------------------------------------------
-void() GibPlayer =
+void() gib_player =
{
- 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);
+ throw_head ("progs/h_player.mdl", self.health);
+ throw_gib ("progs/gib1.mdl", self.health);
+ throw_gib ("progs/gib2.mdl", self.health);
+ throw_gib ("progs/gib3.mdl", self.health);

self.deadflag = DEAD_DEAD;

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

Diff qc/newflags.qc

diff --git a/qc/newflags.qc b/qc/newflags.qc
index fa19279..01c60fa 100644
--- a/qc/newflags.qc
+++ b/qc/newflags.qc
@@ -53,20 +53,37 @@ affecting the other.
========================================================================
*/

+//======================================================================
+// constants
+//======================================================================
+
// The new spawnflags. (16384 is already used elsewhere.)
const float SPAWNFLAG_NOT_IN_COOP = 4096; // Not in Coop
const float SPAWNFLAG_NOT_IN_SP = 8192; // Not in Single Player
const float SPAWNFLAG_NOT_ON_SKILL2 = 32768; // Not on Hard Only
const float SPAWNFLAG_NOT_ON_SKILL3 = 65536; // Not on Nightmare Only

-// The number of entities inhibited by each of the new spawnflags.
-float total_not_in_coop;
-float total_not_in_sp;
+//======================================================================
+// globals
+//======================================================================
+
+float total_not_in_coop; // the number of entities inhibited by
+float total_not_in_sp; // each of the new spawnflags
float total_not_on_skill2;
float total_not_on_skill3;

-// TRUE if the developer summary has been printed.
-float done_inhibition_summary;
+float done_inhibition_summary; // TRUE if developer summary has been printed
+
+//======================================================================
+// forward declarations
+//======================================================================
+
+void() InitNewSpawnflags;
+float() SUB_Inhibit;
+void(float total, string spawnflag_name) PrintInhibitionTotal;
+void() PrintInhibitionSummary;
+
+//------------------------------------------------------------------------------

//----------------------------------------------------------------------
// InitNewSpawnflags
@@ -90,22 +107,20 @@ void() InitNewSpawnflags =
skill = cvar ("skill");
};

-/*
-------------------------------------------------------------------------
-SUB_Inhibit
-
-This function is intended to be called from the top of every spawn
-function, like this:
-
- if (SUB_Inhibit ())
- return;
-
-If the entity's spawnflags mean that it should be inhibited in the
-current game mode or on the current skill level, this function will
-remove the entity and return TRUE, otherwise this function will take no
-action and return FALSE. -- iw
-------------------------------------------------------------------------
-*/
+//----------------------------------------------------------------------
+// SUB_Inhibit
+//
+// This function is intended to be called from the top of every spawn
+// function, like this:
+//
+// if (SUB_Inhibit ())
+// return;
+//
+// If the entity's spawnflags mean that it should be inhibited in the
+// current game mode or on the current skill level, this function will
+// remove the entity and return TRUE, otherwise this function will take
+// no action and return FALSE. -- iw
+//----------------------------------------------------------------------
float() SUB_Inhibit =
{
if (coop && (self.spawnflags & SPAWNFLAG_NOT_IN_COOP))
@@ -163,21 +178,20 @@ void(float total, string spawnflag_name) PrintInhibitionTotal =
dprint ("' spawnflag\n");
};

-/*
-------------------------------------------------------------------------
-PrintInhibitionSummary
-
-This function is intended to be called from the top of the StartFrame
-function (in world.qc), like this:
-
- if (!done_inhibition_summary)
- PrintInhibitionSummary ();
-
-The engine already logs a developer message about the number of entities
-inhibited by the built-in spawnflags; this function logs a message about
-the number of entities inhibited by the new spawnflags. -- iw
-------------------------------------------------------------------------
-*/
+//----------------------------------------------------------------------
+// PrintInhibitionSummary
+//
+// This function is intended to be called from the top of the StartFrame
+// function (in world.qc), like this:
+//
+// if (!done_inhibition_summary)
+// PrintInhibitionSummary ();
+//
+// The engine already logs a developer message about the number of
+// entities inhibited by the built-in spawnflags; this function logs a
+// message about the number of entities inhibited by the new spawnflags.
+// -- iw
+//----------------------------------------------------------------------
void() PrintInhibitionSummary =
{
dprint (ftos (total_not_in_coop + total_not_in_sp +

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

Diff qc/obituary.qc

diff --git a/qc/obituary.qc b/qc/obituary.qc
index 4dfdcd1..cbd8ce2 100644
--- a/qc/obituary.qc
+++ b/qc/obituary.qc
@@ -2,6 +2,21 @@
// obituary.qc
//==============================================================================

+//======================================================================
+// fields
+//======================================================================
+
+.string obit_name; // dumptruck_ds misc pd additions
+.string obit_method; // dumptruck_ds misc pd additions
+
+//======================================================================
+// forward declarations
+//======================================================================
+
+void(entity targ, entity inflictor, entity attacker) ClientObituary;
+
+//------------------------------------------------------------------------------
+
//----------------------------------------------------------------------
// ClientObituary -- called when a player dies
//----------------------------------------------------------------------
@@ -234,10 +249,10 @@ void(entity targ, entity inflictor, entity attacker) ClientObituary =
{
bprint (" was ");
if !(attacker.obit_method)
- bprint ("killed");
+ bprint ("killed");
else
- // e.g. ripped apart
- bprint (attacker.obit_method);
+ // e.g. ripped apart
+ bprint (attacker.obit_method);
bprint (" by ");
// a bad monster
bprint (attacker.obit_name);
@@ -257,6 +272,7 @@ void(entity targ, entity inflictor, entity attacker) ClientObituary =
bprint (" discovered that lasers are hot\n");
return;
}
+ /* TODO CEV
if ((attacker.solid == SOLID_BSP &&
attacker != world &&
attacker.classname != "togglewall") ||
@@ -266,6 +282,7 @@ void(entity targ, entity inflictor, entity attacker) ClientObituary =
bprint (" was squished\n");
return;
}
+ */
if (attacker.classname == "trap_shooter" ||
attacker.classname == "trap_spikeshooter" ||
attacker.classname == "trap_switched_shooter")

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

Diff qc/pmove.qc

diff --git a/qc/pmove.qc b/qc/pmove.qc
index fbfebb9..53b2a04 100644
--- a/qc/pmove.qc
+++ b/qc/pmove.qc
@@ -10,9 +10,10 @@
// TODO CEV: varied sounds (footsteps, different jump sounds)

//======================================================================
-// globals managed by FTEQW, from fteextensions.qc -- CEV
+// globals
//======================================================================

+// the following are all managed by FTEQW -- CEV
float input_buttons; // buttons pressed by the client
// float input_impulse;
float input_timelength; // frame / tic time
@@ -24,46 +25,33 @@ vector input_movevalues; // movement requested by client
//======================================================================

// note: timers are expensive, require synch between server and client -- CEV
-// .entity groundentity;
+// .entity groundentity; // already defined in entvars_t
.vector groundnormal;
.float pmove_flags; // custom movement flags -- CEV
.float doublejump_timer; // time in which a player can doublejump
-.float groundboost_timer; // time to apply low friction -- CEV
.void() customphysics;

//======================================================================
// pmove constants (could be reworked as cvars, would add overhead) -- CEV
//======================================================================

-// circle jump calculations (in python, probably wrong on my [CEV's] part):
-// 320 * math.sqrt((A * (2 - A * (1 / T))) / (c * (2 - c * (1 / T))))
-// where A = accel (10.0), c = friction (4.0), T = framerate (q3 125, q1 77?)
-// this equation is from the article "Circle-Jump Theory" by injx, found here:
-// https://www.artifexquake.com/?page_id=184
-//
-// Max ground speed for accel 10, friction 6, T 125, w 320 (vq3) is ~409
-// Max ground speed for accel 15, friction 6, T 125, w 320 (CPM) is ~497
-// accel 10.666, friction 6, T 125, wishspeed 320 = 423
-// accel 10.666, friction 6, T 125, wishspeed 360 = 475
-// accel 10.666, friction 6, T 125, wishspeed 380 = 502
-// accel 10.666, friction 6, T 125, wishspeed 400 = 528
-
-// acceleration & friction (cheers for the number of the beast)
-const float PM_AIRACCEL = 6.666f; // 10 in Q1; now 7.5 or 8.0
-const float PM_AIRACCELQ3 = 0.666f; // 1.0 in Q3 ?; now 0.75 or 0.8
-const float PM_AIRACCELFWD = 0.666f; // 1 feels close to Q3 / CPM
-const float PM_AIRACCELBACK = 6.666f; // Air stop speed in Q3? 5.0f?
-const float PM_AIRACCELTURN = 666.0f; // affects +fwd turning radius; 100.0f
-const float PM_BOOSTACCEL = 10.666f; // ground boost accel; 10; 10 + 1.25
+// acceleration & friction
+const float PM_AIRACCEL = 6.0f; // 10 in Q1; now 7.5 or 8.0
+const float PM_AIRACCELQ3 = 0.8f; // 1.0 in Q3 ?; now 0.75 or 0.8
+const float PM_AIRACCELFWD = 0.8f; // 1 feels close to Q3 / CPM
+const float PM_AIRACCELBACK = 5.0f; // Air stop speed in Q3? 5.0f?
+const float PM_AIRACCELBASE = 32.0f; // PM_MAXSPEED / 10.0
+const float PM_AIRACCELTURN = 250.0f; // affects +fwd turning radius; 150.0f
+const float PM_BOOSTACCEL = 10.0f; // ground boost accel; 10; 10 + 1.25
const float PM_BOOSTFRICTION = 1.0f; // ground boost friction; 4 is Q1
-const float PM_GROUNDACCEL = 10.666f; // 10 is Q1, 15 is CPM
+const float PM_GROUNDACCEL = 10.0f; // 10 is Q1, 15 is CPM
const float PM_GROUNDFRICTION = 6.0f; // 4 for Q1, 6 for Q3, 8 for (old?) CPM
const vector PM_GROUNDDIST_V = '0 0 1'; // distance for ground check
const float PM_WATERACCEL = 10.0f; // water acceleration
const float PM_WATERFRICTION = 4.0f; // friction in water

// horizontal speeds (mostly)
-const float PM_BOOSTWISHSPEED = 380.0f; // 320, 400
+const float PM_BOOSTWISHSPEED = 400.0f; // 320, 400
const float PM_CROUCHSPEED = 120.0f; // ???
const float PM_MAXSPEED = 320.0f; // 320 always
const float PM_MAXAIRSPEED = 30.0f; // 30 for Q1 air control
@@ -75,28 +63,29 @@ const float PM_WATERMAXSPEED = 224.0f; // 320 * 0.7
const float PM_WATERSINKSPEED = 60.0f;

// vertical speeds (mostly)
-const float PM_GRAVITY = 800.0f; // unless sv_gravity, scaled by .gravity
+const float PM_GRAVITY = 800.0f; // superseded by world_gravity global
const float PM_JUMPSPEED = 270.0f; // standard jump Z velocity; 90 * 3
-const float PM_DOUBLEJUMPSPEED = 270.0f;// 270 * 1.5 in CPM; 360 here
+const float PM_DOUBLEJUMPSPEED = 270.0f;// 270 * 1.5 in CPM
+const float PM_SHORTJUMPSPEED = 180.0f; // 180 = 90 * 2
+const float PM_SHORTJUMPTHRESH = 340.0f;// shortjump when horiz speed under this
const float PM_STAIRJUMPSPEED = 360.0f; // 360 = 90 * 4
const float PM_TELEJUMPSPEED = 360.0f; // same as STAIRJUMPSPEED
const float PM_WALLJUMPFORCE = 90.0f; // push away from wall
const float PM_WALLJUMPGROUND = 28.0f; // distance from ground to allow WJ (36)
const float PM_WALLJUMPLIMIT = -225.f; // no walljump if Z vel below this
-const float PM_WALLJUMPSPEED = 270.0f; // 225 = 90 * 2.5; wall jump
-const float PM_WALLJUMPDOUBLE = 360.0f; // 315 = 90 * 3.5; wall doublejump
+const float PM_WALLJUMPSPEED = 270.0f; // same as JUMPSPEED
+const float PM_WALLJUMPDOUBLE = 360.0f; // same as STAIRJUMPSPEED

// timing
const float PM_DOUBLEJUMP_WINDOW = 0.4f;// 2 jumps in this time is a double
-const float PM_GROUNDBOOST_WINDOW = 0.4f;// groundboost duration
const float PM_TELEJUMP_WINDOW = 0.4f; // duration to perform a telejump
-const float PM_WALLJUMP_WINDOW = 0.2f; // duration between walljumps
+const float PM_WALLJUMP_WINDOW = 0.3f; // dj timer < this to walljump
const float PM_WALLCLIP_WINDOW = 0.25f; //

// misc
const float PM_MAX_CLIP_PLANES = 5;
const float PM_OVERCLIP = 1.0f; // Quake3's OVERCLIP is 1.001f
-const float PM_ONESIDEDCLIP = -0.001f; // -0.001, -0.01, -0.1
+const float PM_ONESIDEDCLIP = -0.1f; // -0.001, -0.01, -0.1
const float PM_STEPHEIGHT = 18.0f; // 18 for Q1, 22 for later games?
const vector PM_TELEDROP = '0 0 -64'; // drop teleporter exit to floor if
// floor is within this distance
@@ -127,16 +116,22 @@ enumflags
PMF_DOUBLEJUMPED, // entity has doublejumped
PMF_WALLJUMPED, // entity has walljumped
PMF_WATERJUMPED, // entity has waterjumped
- PMF_PRE_MOVE // hint that origin hasn't updated yet
+ PMF_PRE_MOVE, // hint that origin hasn't updated yet
+ PMF_SLIDE_GRAVITY, // slidemove hint to apply gravity
+ PMF_SLIDE_SKIM, // slidemove hint to skim/wallclip
+ PMF_SLIDE_STEP, // slidemove hint to traverse steps
+ PMF_SLIDE_STICKY // slidemove hint to stick to ground
};

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

+float(float maxspeed, float a, float c, float t) PM_MaxCircleGroundSpeed;
+
static void(entity ent) PM_DoTouch;
float() PM_Nudge;
-void(float dogravity, float sticky, float dostep, float doskim) PM_DanceMove;
+void() PM_DanceMove;
void(float dogravity, float sticky, float dostep, float doskim) PM_DanceMoveQ3;
void() PM_CategorizePosition;
void(float friction, float move_time) PM_Friction;
@@ -145,7 +140,7 @@ void(vector wishdir, float wishspeed, float accel, float move_time)
void(vector wishvel, float wishspeed, float accel, float move_time)
PM_AirAccelerate;
void(vector wishdir, float wishspeed, float move_time) PM_AirControl;
-void() PM_Jump;
+void(vector wishdir) PM_Jump;
void() PM_WallJump;
void(vector wishvel, float move_time) PM_WalkAccelerate;
void(vector wishvel, float move_time) PM_SwimAccelerate;
@@ -153,28 +148,43 @@ void(vector wishvel, float scale, float move_time) PM_NoClipAccelerate;
void(float move_time) PM_ManageTimers;
void(entity target) PM_Move;

+//------------------------------------------------------------------------------
+
+//----------------------------------------------------------------------
+// PM_MaxCircleGroundSpeed
+//
+// circle jump calculations (in python, probably wrong on my [CEV's] part):
+// 320 * math.sqrt((A * (2 - A * (1 / T))) / (c * (2 - c * (1 / T))))
+// where A = accel (10.0), c = friction (4.0), T = framerate (q3 125, q1 77?)
+// this equation is from the article "Circle-Jump Theory" by injx, found here:
+// https://www.artifexquake.com/?page_id=184
+//
+// Max ground speed for accel 10, friction 6, T 125, w 320 (vq3) is ~409
+// Max ground speed for accel 15, friction 6, T 125, w 320 (CPM) is ~497
+// accel 10.000, friction 6, T 125, wishspeed 380 = 486
+// accel 10.000, friction 6, T 125, wishspeed 400 = 512
+//----------------------------------------------------------------------
+float(float maxspeed, float a, float f, float t) PM_MaxCircleGroundSpeed =
+{
+ return maxspeed * sqrt ((a * (2.0 - a * (1.0 / t))) /
+ (f * (2.0 - f * (1.0 / t))));
+};
+
//----------------------------------------------------------------------
// PM_DoTouch
//----------------------------------------------------------------------
static void(entity ent) PM_DoTouch =
{
-#ifdef SSQC
- if (ent && (ent.classgroup & CG_ENTITY))
- {
- other = self;
- ((base_entity)ent).touch ();
- return;
- }
-#endif
if (ent && ent.touch != __NULL__)
{
- local entity orig_self;
+ local entity stemp = self;
+ local entity otemp = other;

- orig_self = self;
other = self;
self = ent;
self.touch ();
- self = orig_self;
+ self = stemp;
+ other = otemp;
}
};

@@ -185,6 +195,8 @@ static void(entity ent) PM_DoTouch =
//----------------------------------------------------------------------
float() PM_Nudge =
{
+ dprint ("PM_Nudge: starting function...\n");
+
vector test, org = self.origin;

// check current position.
@@ -234,11 +246,11 @@ float() PM_Nudge =
// improve performance.
//
// Based on code from the Nuclide SDK (presumably by Eukara), specifically
-// the function PMoveCustom_Move found in the file pmove_custom.qc. This
+// the function PMoveCustom_Move found in the file pmove_custom.qc. That
// in turn appears to be based on a similar function in the CSQCTest code
// that comes with FTEQW. -- CEV
//----------------------------------------------------------------------
-void(float dogravity, float sticky, float dostep, float doskim) PM_DanceMove =
+void() PM_DanceMove =
{
vector end, prev_plane, prev_plane2, start_vel;
float f, grav, i, stepsize, time_left;
@@ -249,15 +261,15 @@ void(float dogravity, float sticky, float dostep, float doskim) PM_DanceMove =
f = grav = i = stepsize = 0;
time_left = input_timelength;

- if (dogravity)
+ if (self.pmove_flags & PMF_SLIDE_GRAVITY)
{
if (self.gravity)
grav = self.gravity;
else
grav = 1.0;
- // frame_gravity is set in StartFrame (on the server)
+ // world_gravity is set in world () (on the server)
// or PlayerUpdate (client) -- CEV
- grav *= frame_gravity * time_left;
+ grav *= world_gravity * time_left;
// Half now, half later. Apparently affects framerate
// dependence. -- CEV
self.velocity_z -= grav * 0.5;
@@ -267,12 +279,14 @@ void(float dogravity, float sticky, float dostep, float doskim) PM_DanceMove =

// Borrowing FTEQW's pm_airstep cvar here. If false, don't step up
// while in the air (changes stairs) -- CEV
- if (!(frame_airstep) && !(self.pmove_flags & PMF_ONGROUND))
- dostep = FALSE;
+ if (!(world_airstep) && !(self.pmove_flags & PMF_ONGROUND))
+ {
+ self.pmove_flags &= ~PMF_SLIDE_STEP;
+ }

// no stepping. useful for testing -- CEV
- if (frame_nostep)
- dostep = FALSE;
+ if (world_nostep)
+ self.pmove_flags &= ~PMF_SLIDE_STEP;

// we need to bounce off surfaces (in order to slide along them),
// so we need at 2 attempts -- comment from the Nuclide SDK
@@ -318,7 +332,8 @@ void(float dogravity, float sticky, float dostep, float doskim) PM_DanceMove =
// integrated StepSlideMove from Nuclide / CSQCTest
// only attempt to step if there's time left, stepping was
// requested, and we hit a vertical plane -- CEV
- if (dostep && time_left > 0 && trace_plane_normal_z == 0)
+ if (self.pmove_flags & PMF_SLIDE_STEP && time_left > 0 &&
+ trace_plane_normal_z == 0)
{
// store the entity and plane normal from our
// first move attempt, setup a vec to track
@@ -363,7 +378,9 @@ void(float dogravity, float sticky, float dostep, float doskim) PM_DanceMove =
// forward move didn't hit anything
// third: move down
end = trace_endpos;
- end_z -= stepsize + 1;
+ end_z -= stepsize;
+ // + (self.pmove_flags &
+ // PMF_SLIDE_STICKY ? 16 : 1);
tracebox (trace_endpos, self.mins, self.maxs,
end, FALSE, self);

@@ -394,7 +411,7 @@ void(float dogravity, float sticky, float dostep, float doskim) PM_DanceMove =
touched_ent = trace_ent;

// don't attempt to step again
- dostep = FALSE;
+ self.pmove_flags &= ~PMF_SLIDE_STEP;
}
else
{
@@ -405,15 +422,14 @@ void(float dogravity, float sticky, float dostep, float doskim) PM_DanceMove =
else
{
// forward move hit something
- if (trace_ent && trace_ent.touch)
- touched_ent = trace_ent;
-
if (trace_plane_normal != first_plane &&
trace_plane_normal_z == 0)
{
// hit something different than the
// first move; note that we're not
// restoring the first plane normal
+ if (trace_ent && trace_ent.touch)
+ touched_ent = trace_ent;
time_left -= time_left * trace_fraction;
stepsize = 0;
}
@@ -421,7 +437,7 @@ void(float dogravity, float sticky, float dostep, float doskim) PM_DanceMove =
{
// revert to move before step attempt
PM_DanceMove_RejectStep:
- trace_ent = first_ent;
+ touched_ent = trace_ent = first_ent;
trace_plane_normal = first_plane;
stepsize = 0;
}
@@ -437,6 +453,10 @@ void(float dogravity, float sticky, float dostep, float doskim) PM_DanceMove =
self.groundnormal = trace_plane_normal;
self.flags |= FL_ONGROUND;
self.pmove_flags |= PMF_ONGROUND;
+ #ifdef SSQC
+ // before clipping velocity - CEV
+ self.jump_flag = self.velocity_z;
+ #endif
}
}
else
@@ -453,10 +473,13 @@ void(float dogravity, float sticky, float dostep, float doskim) PM_DanceMove =
if (f < 0)
f *= PM_OVERCLIP;
else
- if (sticky)
- f /= PM_OVERCLIP;
+ if (trace_plane_normal_z > 0.7)
+ if (self.pmove_flags & PMF_SLIDE_STICKY)
+ f /= PM_OVERCLIP;
+ else
+ f *= PM_ONESIDEDCLIP;
else
- f *= PM_ONESIDEDCLIP;
+ f /= PM_OVERCLIP;

self.velocity -= trace_plane_normal * f;

@@ -471,10 +494,13 @@ void(float dogravity, float sticky, float dostep, float doskim) PM_DanceMove =
if (f < 0)
f *= PM_OVERCLIP;
else
- if (sticky)
- f /= PM_OVERCLIP;
+ if (prev_plane_z > 0.7)
+ if (self.pmove_flags & PMF_SLIDE_STICKY)
+ f /= PM_OVERCLIP;
+ else
+ f *= PM_ONESIDEDCLIP;
else
- f *= PM_ONESIDEDCLIP;
+ f /= PM_OVERCLIP;

self.velocity -= prev_plane * f;

@@ -498,8 +524,7 @@ void(float dogravity, float sticky, float dostep, float doskim) PM_DanceMove =
dprint ("PM_DanceMove: triple plane stop\n");
#endif
self.velocity = '0 0 0';
- if (touched_ent && touched_ent.touch)
- PM_DoTouch (touched_ent);
+ PM_DoTouch (touched_ent);

break;
}
@@ -511,8 +536,7 @@ void(float dogravity, float sticky, float dostep, float doskim) PM_DanceMove =
// we've turned against original velocity so zero
// out vel, touch any ents, and stop the loop
self.velocity = '0 0 0';
- if (touched_ent && touched_ent.touch)
- PM_DoTouch (touched_ent);
+ PM_DoTouch (touched_ent);
break;
}

@@ -522,24 +546,48 @@ void(float dogravity, float sticky, float dostep, float doskim) PM_DanceMove =

// touch the saved entity last in case doing so overwrites
// trace_plane_normal -- CEV
- if (touched_ent && touched_ent.touch)
- PM_DoTouch (touched_ent);
+ PM_DoTouch (touched_ent);
}

// wallclip / wall skim timer check
// if doskim is true and velocity is non-zero and we lost speed
// during the move then restore velocity -- CEV
- if (doskim && self.velocity && (vlen(start_vel) > vlen(self.velocity)))
+ if ((self.pmove_flags & PMF_SLIDE_SKIM) && self.velocity)
{
- if (sticky)
- self.velocity = [start_vel_x, start_vel_y,
- min (start_vel_z, self.velocity_z)];
- else
- self.velocity = start_vel;
+ local float speedloss = vlen([start_vel_x, start_vel_y, 0]) -
+ vlen([self.velocity_x, self.velocity_y, 0]);
+
+ if (speedloss > 0)
+ {
+ if (self.pmove_flags & PMF_DOUBLEJUMPED)
+ {
+ #ifdef SSQC
+ dprint (sprintf("PM_DanceMove: "
+ "double skim Z vel %g, loss %g\n",
+ self.velocity_z, speedloss));
+ #endif
+
+ if (speedloss <= PM_RUNSPEED)
+ {
+ self.velocity = start_vel;
+ self.velocity_z = min (start_vel_z,
+ self.velocity_z);
+ }
+ }
+ else if (self.pmove_flags & PMF_SLIDE_STICKY)
+ {
+ self.velocity = [start_vel_x, start_vel_y,
+ min (start_vel_z, self.velocity_z)];
+ }
+ else
+ {
+ self.velocity = start_vel;
+ }
+ }
}

// final gravity check here -- CEV
- if (dogravity)
+ if (self.pmove_flags & PMF_SLIDE_GRAVITY)
self.velocity_z -= grav * 0.5;

// if stepsize is nonzero and we changed from inair to onground then
@@ -554,6 +602,11 @@ void(float dogravity, float sticky, float dostep, float doskim) PM_DanceMove =
}
*/

+ // clear slide hint flags -- CEV
+ self.pmove_flags = self.pmove_flags - (self.pmove_flags &
+ (PMF_SLIDE_GRAVITY | PMF_SLIDE_SKIM | PMF_SLIDE_STEP |
+ PMF_SLIDE_STICKY));
+
// a final call to setorigin to update links -- CEV
setorigin (self, self.origin);
};
@@ -583,9 +636,9 @@ void(float dogravity, float sticky, float dostep, float doskim) PM_DanceMoveQ3 =
grav = self.gravity;
else
grav = 1.0;
- // frame_gravity is set in StartFrame (on the server)
+ // world_gravity is set in world () (on the server)
// or PlayerUpdate (client) -- CEV
- grav = grav * frame_gravity * input_timelength;
+ grav = grav * world_gravity * input_timelength;
// Half now, half later. Apparently affects framerate
// dependence. -- CEV
self.velocity_z -= grav * 0.5;
@@ -593,10 +646,10 @@ void(float dogravity, float sticky, float dostep, float doskim) PM_DanceMoveQ3 =

new_v = start_v = self.velocity;

- if (!(frame_airstep) && !(self.pmove_flags & PMF_ONGROUND))
+ if (!(world_airstep) && !(self.pmove_flags & PMF_ONGROUND))
dostep = FALSE;

- if (frame_nostep)
+ if (world_nostep)
dostep = FALSE;

for (h = 5, time_left = input_timelength; time_left > 0 && h; h--)
@@ -778,10 +831,7 @@ void(float dogravity, float sticky, float dostep, float doskim) PM_DanceMoveQ3 =
}

// touch the saved entity -- CEV
- if (touched_ent && touched_ent.touch != __NULL__)
- {
- PM_DoTouch (touched_ent);
- }
+ PM_DoTouch (touched_ent);

// Quake 3's plane interaction and velocity clipping scheme.
// Solves more interactions than Q1's FlyMove and Nuclide's
@@ -1072,7 +1122,7 @@ void(vector wishvel, float wishspeed, float accel, float move_time)
//----------------------------------------------------------------------
void(vector wishdir, float wishspeed, float move_time) PM_AirControl =
{
- local float speed, zspeed;
+ local float dot, speed, turn, zspeed;

zspeed = self.velocity_z;
self.velocity_z = 0;
@@ -1080,10 +1130,14 @@ void(vector wishdir, float wishspeed, float move_time) PM_AirControl =
speed = vlen (self.velocity);
self.velocity = normalize (self.velocity);

- if ((self.velocity * wishdir) > 0)
+ dot = self.velocity * wishdir;
+
+ if (dot > 0)
{
+ turn = PM_AIRACCELBASE * bound (0, wishspeed / PM_MAXSPEED, 1);
+ turn *= PM_AIRACCELTURN * dot * dot * move_time;
self.velocity = normalize (self.velocity * speed +
- wishdir * PM_AIRACCELTURN);
+ wishdir * turn);
}

self.velocity *= speed;
@@ -1093,7 +1147,7 @@ void(vector wishdir, float wishspeed, float move_time) PM_AirControl =
//----------------------------------------------------------------------
// PM_Jump
//----------------------------------------------------------------------
-void() PM_Jump =
+void(vector wishdir) PM_Jump =
{
// are we already waterjumping, or is jump being held?
if (self.pmove_flags & PMF_WATERJUMPED ||
@@ -1135,8 +1189,7 @@ void() PM_Jump =
// non-additive jump, though it shouldn't matter -- CEV
self.velocity_z = PM_TELEJUMPSPEED;
}
- else if (self.groundnormal && self.groundnormal_z == 1 &&
- self.groundboost_timer > 0)
+ else if (self.groundnormal && self.groundnormal_z == 1)
{
#ifdef SSQC
msg = sprintf ("PM_Jump: stairjump %g, ",
@@ -1159,6 +1212,20 @@ void() PM_Jump =
// set the doublejump flag -- CEV
self.pmove_flags |= PMF_DOUBLEJUMPED;
}
+ else if (input_movevalues_y && input_movevalues_x == 0 &&
+ vlen (self.velocity) <= PM_SHORTJUMPTHRESH)
+ {
+ // short jump with added sideways velocity - a dodge
+ self.velocity_z = 0;
+ self.velocity = wishdir * PM_BOOSTWISHSPEED;
+ // self.velocity = normalize (self.velocity);
+ // self.velocity *= 400;
+ self.velocity_z = PM_SHORTJUMPSPEED;
+
+ #ifdef SSQC
+ msg = sprintf ("PM_Jump: short jump %v ", self.velocity);
+ #endif
+ }
else
{
// normal jump
@@ -1169,9 +1236,9 @@ void() PM_Jump =

// do an additive jump on non-flat ground -- CEV
if (self.groundnormal_z == 1)
- self.velocity_z = min (PM_STAIRJUMPSPEED,
- self.velocity_z += PM_JUMPSPEED);
- // self.velocity_z = PM_JUMPSPEED;
+ // self.velocity_z = min (PM_STAIRJUMPSPEED,
+ // self.velocity_z += PM_JUMPSPEED);
+ self.velocity_z = PM_JUMPSPEED;
else
self.velocity_z += PM_JUMPSPEED;
}
@@ -1196,7 +1263,6 @@ void() PM_Jump =

// timers for all jumps -- CEV
self.doublejump_timer = PM_DOUBLEJUMP_WINDOW;
- self.groundboost_timer = PM_GROUNDBOOST_WINDOW;
};

//----------------------------------------------------------------------
@@ -1220,8 +1286,8 @@ void() PM_WallJump =
}

// mandatory interval between jump and walljump
- if (self.doublejump_timer > (PM_DOUBLEJUMP_WINDOW - PM_WALLJUMP_WINDOW))
- return;
+ // if (self.doublejump_timer <= PM_WALLJUMP_WINDOW)
+ // return;

if (self.velocity_z < PM_WALLJUMPLIMIT)
{
@@ -1235,20 +1301,12 @@ void() PM_WallJump =
return;
}

- // minimum distance from ground to walljump
- local vector end = self.origin;
- end_z -= PM_WALLJUMPGROUND;
- tracebox (self.origin, self.mins, self.maxs, end, TRUE, self);
-
- if (trace_fraction < 1.0f)
- return;
-
// start at STEPHEIGHT + 1 to try and clear any steps -- CEV
- local vector start;
local float f = 0;
- start = self.origin;
- start_z += PM_STEPHEIGHT + 1;
- end = start;
+ local vector start = self.origin;
+ // start_z += PM_STEPHEIGHT + 1;
+ start_z = start_z + 12;
+ local vector end = start;

for (float i = 0; i < 4; i++)
{
@@ -1274,20 +1332,20 @@ void() PM_WallJump =

// this ends up firing *a lot* when hopping through a map
// normally, unfortunately. traceline may be better here -- CEV
- tracebox (start, self.mins, self.maxs, end, TRUE, self);
+ tracebox (start, PM_CROUCH_MIN, PM_CROUCH_MAX, end, TRUE, self);

// in order: we hit something, that something is vaguely
// vertical, we hit it at a speed greater than 0, and
// that something is within 20 (units?) -- CEV
- // If self.velocity * trace_plane_normal is less than zero
- // that means the user is directing their movement *into*
- // the wall instead of away from it. Could be useful later
- // for wallclimbing. -- CEV
if (trace_fraction < 1.0f &&
trace_plane_normal_z <= 0.7f &&
trace_plane_normal_z >= 0 &&
vlen(self.origin - trace_endpos) <= 20)
{
+ // If self.velocity * trace_plane_normal is less than
+ // zero that means the user is directing their movement
+ // *into* the wall instead of away from it. Could be
+ // useful later for vaulting or climbing. -- CEV
f = self.velocity * trace_plane_normal;
if (f >= 0)
{
@@ -1298,8 +1356,8 @@ void() PM_WallJump =
#ifdef SSQC
else
{
- dprint (sprintf("PM_WallJump: wallclimb %f\n",
- f));
+ dprint (sprintf("PM_WallJump: wallclimb "
+ "normalspeed %f\n", f));
}
#endif
}
@@ -1362,7 +1420,7 @@ void(vector wishvel, float move_time) PM_WalkAccelerate =
// situations because we rely on touch()ing the ladder
// trigger to set PMF_ONLADDER and the client doesn't
// know about the trigger brush yet -- TODO CEV
- self.velocity = 0.75 * self.velocity;
+ self.velocity *= 0.75;

if (input_buttons & 2 || self.button2 > 0 ||
input_movevalues_z > 0)
@@ -1392,8 +1450,8 @@ void(vector wishvel, float move_time) PM_WalkAccelerate =
// +jump was pressed
if (self.pmove_flags & PMF_ONGROUND)
// normal jump
- PM_Jump ();
- else if (frame_walljump)
+ PM_Jump (wishdir);
+ else if (world_walljump)
// walljump
PM_WallJump ();
}
@@ -1418,29 +1476,26 @@ void(vector wishvel, float move_time) PM_WalkAccelerate =
accel = PM_GROUNDACCEL;
friction = PM_GROUNDFRICTION;

- if (self.groundboost_timer > 0)
+ if (self.doublejump_timer > 0)
wishspeed = min (wishspeed, PM_BOOSTWISHSPEED);
else
wishspeed = min (wishspeed, PM_MAXSPEED);
}
- else if (!(self.pmove_flags & PMF_STARTGROUND) &&
- self.pmove_flags & PMF_ONGROUND)
+ else if (self.pmove_flags & PMF_ONGROUND)
{
// we're in the second acceleration pass and we've just
// landed. For this one-half acceleration frame set
- // friction to zero and accel to GROUNDACCEL. This
+ // friction to zero and accel to AIRACCELQ3. This
// moment is particularly noticeable on stairs. -- CEV
- // accel = PM_GROUNDACCEL;
- accel = 1.0f;
+ accel = PM_AIRACCELQ3;
friction = 0;

- // an experiment - rewrite input values to direct
- // movement forward in the half-frame after we've
- // just landed. the neverending quest to improve
- // Quake stairs -- CEV
+ // rewrite user input to direct movement along current
+ // velocity in the half-frame after we've just landed.
+ // will only rewrite when neither +fwd or +back is
+ // pressed. the neverending quest to improve stairs. -- CEV
if (input_movevalues_y && input_movevalues_x == 0)
{
- // always be +fwd
input_movevalues_x = fabs (input_movevalues_y);

// we've altered input movevalues so rework wishvel
@@ -1448,11 +1503,19 @@ void(vector wishvel, float move_time) PM_WalkAccelerate =
makevectors ([0, input_angles_y, 0]);
wishvel = v_forward * input_movevalues_x;
wishvel += v_right * input_movevalues_y;
+ // is wishvel now against self.velocity?
+ if (wishvel * self.velocity < 0)
+ {
+ // then movevalues_x should be negative
+ input_movevalues_x = -input_movevalues_x;
+ wishvel = v_forward * input_movevalues_x;
+ wishvel += v_right * input_movevalues_y;
+ }
wishspeed = vlen (wishvel);
wishdir = normalize (wishvel);
}

- if (self.groundboost_timer > 0)
+ if (self.doublejump_timer > 0)
wishspeed = min (wishspeed, PM_BOOSTWISHSPEED);
else
wishspeed = min (wishspeed, PM_MAXSPEED);
@@ -1516,7 +1579,7 @@ void(vector wishvel, float move_time) PM_WalkAccelerate =
if (newspeed < 0)
newspeed = 0;

- self.velocity = self.velocity * (newspeed / speed);
+ self.velocity *= newspeed / speed;
}
}

@@ -1555,6 +1618,7 @@ void(vector wishvel, float move_time) PM_WalkAccelerate =
}

// CPM & PK-style air control, needs to happen after PM_Accelerate
+ // based on code from Nexuiz & Xonotic
if (friction == -1)
{
// inline PM_AirControl
@@ -1564,10 +1628,17 @@ void(vector wishvel, float move_time) PM_WalkAccelerate =
speed = vlen (self.velocity);
self.velocity = normalize (self.velocity);

- if ((self.velocity * wishdir) > 0)
+ // reuse the friction float for dotproduct -- CEV
+ friction = self.velocity * wishdir;
+
+ // reuse the accel var for turning -- CEV
+ accel = PM_AIRACCELBASE * bound (0, wishspeed / PM_MAXSPEED, 1);
+ accel *= PM_AIRACCELTURN * friction * friction * move_time;
+
+ if (friction > 0)
{
self.velocity = normalize (self.velocity * speed +
- wishdir * PM_AIRACCELTURN);
+ wishdir * accel);
}

self.velocity *= speed;
@@ -1694,14 +1765,7 @@ void(float move_time) PM_ManageTimers =
self.doublejump_timer = 0;

if (self.doublejump_timer == 0)
- {
self.pmove_flags &= ~PMF_DOUBLEJUMPED;
- }
-
- if (self.groundboost_timer > 0 && move_time > 0)
- self.groundboost_timer -= move_time;
- else if (self.groundboost_timer < 0)
- self.groundboost_timer = 0;
};

//----------------------------------------------------------------------
@@ -1718,43 +1782,47 @@ void(entity target) PM_Move =
// Nudge player's origin if the server is sending low-precision
// (16 bit?) player coordinates. This can be fixed by setting
// sv_bigcoords to 1 (so the server sends float coords). -- CEV
- if (!frame_bigcoords)
+ if (!world_bigcoords)
PM_Nudge ();

// rework user input, copying something like QuakeSpasm's always run
// feature here. This turns the +speed button into a hold-to-walk
// button when cl_run is 0 (when FTE's always run setting is on).
// -- CEV
- if (frame_clrun == FALSE)
+ if (world_clrun == FALSE)
{
- // local float s = 0;
- for (float i = 0; i < 3; i++)
+ local float m;
+
+ // we care about x and y, not so much z -- CEV
+ if (input_movevalues_x)
{
- // this works, it's just commented out to stop calling
- // autocvar quite so many times. to re-enable change
- // the check against "PM_RUNSPEED" below to "s" -- CEV
+ m = fabs (input_movevalues_x);
+ if (m > 400.0f)
+ input_movevalues_x = PM_WALKSPEED *
+ (input_movevalues_x / m);
+ else if (m == 400.0f)
+ input_movevalues_x = world_clforwardspeed *
+ (input_movevalues_x / m);
/*
- if (i == 0)
- s = autocvar (cl_forwardspeed, PM_RUNSPEED);
- else if (i == 1)
- s = autocvar (cl_sidespeed, PM_RUNSPEED);
- else if (i == 2)
- s = autocvar (cl_upspeed, PM_RUNSPEED);
+ else if (m != 0)
+ input_movevalues_x = PM_RUNSPEED *
+ (input_movevalues_x / m);
*/
- if (fabs(input_movevalues[i]) > 400.0f)
- input_movevalues[i] = PM_WALKSPEED *
- (input_movevalues[i] /
- fabs(input_movevalues[i]));
- else if (fabs(input_movevalues[i]) == 400.0f)
- input_movevalues[i] = PM_RUNSPEED *
- (input_movevalues[i] /
- fabs(input_movevalues[i]));
- // Don't need this, it's already PM_RUNSPEED -- CEV
+ }
+
+ if (input_movevalues_y)
+ {
+ m = fabs (input_movevalues_y);
+ if (m > 400.0f)
+ input_movevalues_y = PM_WALKSPEED *
+ (input_movevalues_y / m);
+ else if (m == 400.0f)
+ input_movevalues_y = world_clsidespeed *
+ (input_movevalues_y / m);
/*
- else if (input_movevalues[i] != 0)
- input_movevalues[i] = PM_RUNSPEED *
- (input_movevalues[i] /
- fabs(input_movevalues[i]));
+ else if (m != 0)
+ input_movevalues_y = PM_RUNSPEED *
+ (input_movevalues_y / m);
*/
}
}
@@ -1770,11 +1838,6 @@ void(entity target) PM_Move =
switch (self.movetype)
{
case MOVETYPE_WALK:
- local float dogravity, doskim, sticky;
-
- doskim = FALSE;
- sticky = FALSE;
-
// signal acceleration functions that we're pre-move
self.pmove_flags |= PMF_PRE_MOVE;

@@ -1782,17 +1845,11 @@ void(entity target) PM_Move =
// framerate dependence. -- CEV
if (self.waterlevel >= WATERLEVEL_WAIST)
{
- // no gravity, velocity-restoring behavior,
- // or sticky clips underwater -- CEV
- dogravity = FALSE;
- doskim = FALSE;
- sticky = FALSE;
-
// figure out wishvel -- CEV
makevectors (input_angles);
- wishvel = v_forward * input_movevalues_x;
- wishvel += v_right * input_movevalues_y;
- wishvel += v_up * input_movevalues_z;
+ wishvel = v_forward * input_movevalues_x +
+ v_right * input_movevalues_y +
+ v_up * input_movevalues_z;

// swim acceleration
PM_SwimAccelerate (wishvel,
@@ -1802,10 +1859,10 @@ void(entity target) PM_Move =
{
// only yaw matters here -- CEV
makevectors ([0, input_angles_y, 0]);
- wishvel = v_forward * input_movevalues_x;
- wishvel += v_right * input_movevalues_y;
- // don't need wishvel_z -- CEV
- // wishvel += v_up * input_movevalues_z;
+ wishvel = v_forward * input_movevalues_x +
+ v_right * input_movevalues_y;
+ // don't need wishvel_z -- CEV
+ // v_up * input_movevalues_z;

PM_WalkAccelerate (wishvel,
input_timelength * 0.5f);
@@ -1813,32 +1870,24 @@ void(entity target) PM_Move =
// WalkAccelerate calls Jump which might
// alter pmove_flags, so do our feature
// checks afterwards -- CEV
- if (self.doublejump_timer <= 0 ||
- self.pmove_flags & PMF_DOUBLEJUMPED ||
- self.pmove_flags & PMF_WALLJUMPED)
- // don't stick to the floor
- sticky = FALSE;
- else
- // we've jumped & haven't doublejumped,
- // so do sticky steps -- CEV
- sticky = TRUE;
-
- // apply gravity only when in the air or on
- // a ramp -- CEV
- #ifdef CSQC
- if (intermission)
- #endif
- #ifdef SSQC
- if (intermission_running)
- #endif
- dogravity = FALSE;
- else if (self.groundnormal &&
+
+ // stick to the ground if we've jumped and
+ // haven't yet doublejumped
+ if (self.doublejump_timer > 0 &&
+ !(self.pmove_flags & PMF_WALLJUMPED) &&
+ !(self.pmove_flags & PMF_DOUBLEJUMPED))
+ {
+ self.pmove_flags |= PMF_SLIDE_STICKY;
+ }
+
+ // apply gravity only when in the air, on
+ // a ramp, or in the 'sticky' state -- CEV
+ if (!(self.pmove_flags & PMF_ONGROUND) ||
+ self.pmove_flags & PMF_SLIDE_STICKY ||
self.groundnormal_z < 1.0f)
- dogravity = TRUE;
- else if (self.pmove_flags & PMF_ONGROUND)
- dogravity = FALSE;
- else
- dogravity = TRUE;
+ {
+ self.pmove_flags |= PMF_SLIDE_GRAVITY;
+ }

// skim / wallclipping checks -- CEV
if (self.doublejump_timer >
@@ -1847,15 +1896,15 @@ void(entity target) PM_Move =
!(self.pmove_flags & PMF_WALLJUMPED) &&
self.teleport_time <= (time - 0.1))
{
- doskim = TRUE;
+ self.pmove_flags |= PMF_SLIDE_SKIM;
}

if (self.pmove_flags & PMF_ONLADDER)
{
// feature set for ladders -- CEV
- dogravity = FALSE;
- doskim = FALSE;
- sticky = FALSE;
+ self.pmove_flags &= ~PMF_SLIDE_GRAVITY;
+ self.pmove_flags &= ~PMF_SLIDE_SKIM;
+ self.pmove_flags &= ~PMF_SLIDE_STICKY;
}
}

@@ -1863,7 +1912,8 @@ void(entity target) PM_Move =
PM_ManageTimers (input_timelength * 0.5f);

// Do the move. Bounce, Rock, Skate, Roll -- CEV
- PM_DanceMove (dogravity, sticky, TRUE, doskim);
+ self.pmove_flags |= PMF_SLIDE_STEP;
+ PM_DanceMove ();

// signal accel functions we're post-move
self.pmove_flags &= ~PMF_PRE_MOVE;
@@ -1894,7 +1944,8 @@ void(entity target) PM_Move =

PM_NoClipAccelerate (wishvel, 1.0f,
input_timelength * 0.5f);
- PM_DanceMove (FALSE, TRUE, TRUE, FALSE);
+ self.pmove_flags |= PMF_SLIDE_STEP;
+ PM_DanceMove ();
PM_NoClipAccelerate (wishvel, 1.0f,
input_timelength * 0.5f);
break;
@@ -1918,9 +1969,7 @@ void(entity target) PM_Move =

// make sure we've touched the ground entity (it might've slipped
// through the slidemove above) -- CEV
- if (self.groundentity && self.groundentity.touch != __NULL__)
- PM_DoTouch (self.groundentity);
+ PM_DoTouch (self.groundentity);

touchtriggers ();
- setorigin (self, self.origin);
};

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

Diff qc/progs.src

diff --git a/qc/progs.src b/qc/progs.src
deleted file mode 100644
index dac8e6f..0000000
--- a/qc/progs.src
+++ /dev/null
@@ -1,213 +0,0 @@
-#pragma target fte
-#pragma progs_dat "../progs.dat"
-#pragma autoproto
-
-#define FTE
-#define SSQC
-
-#includelist
-//----------------------------------------------------------------------
-// defs
-//----------------------------------------------------------------------
-defs_globalvars.qc // id1 globalvars_t
-defs_entvars.qc // id1 entvars_t
-defs_builtins.qc // id1 / FTE builtin functions (& overrides)
-defs_misc.qc // additional
-defs_classtype.qc // global class list
-
-//----------------------------------------------------------------------
-// utility & helper functions
-//----------------------------------------------------------------------
-math.qc // Code by Joshua Skelton + misc
-utility.qc
-newflags.qc // new spawnflags for all entities
-cshift.qc // background color shift controller
-subs.qc // modified targets, triggers and killtargets
-keylock.qc // common code for entities unlockable with keys
-custom_snd.qc // mapper-settable sound FX for monsters - iw
-custom_mdls.qc // mapper-settable models for monsters - iw
-gore.qc // spawnblood etc; TODO CEV need to reformat
-
-//----------------------------------------------------------------------
-// base classes
-//----------------------------------------------------------------------
-base_entities.qc // topmost entity classes (+ damage functions)
-base_func.qc // base func_ classes
-base_item.qc // ammo, armor, health, weapons, etc.
-base_monster.qc // base monster classes (+ monster AI)
-base_projectile.qc // projectiles
-base_trigger.qc // methods & fields for trigger entities
-
-//----------------------------------------------------------------------
-// info entities -- destinations, targets, etc.
-//----------------------------------------------------------------------
-info/camera.qc // was in cutscene.qc
-info/intermission.qc // intermission point entity
-info/null.qc // info_null; was in lights.qc
-info/notnull.qc // info_notnull; was in lights.qc
-info/path_corner.qc // id1 path_corner
-info/rotate.qc // hipnotic info_rotate
-info/spawnpoints.qc // info_player_etc and other spawnpoints
-info/teleport_changedest.qc // Qmaster's info_teleport_changedest
-info/teleport_destination.qc // teleporter endpoints
-
-//----------------------------------------------------------------------
-// projectiles - these were all previously in weapons.qc
-//----------------------------------------------------------------------
-projectiles/bullet.qc // id1 shotguns
-projectiles/flak.qc // pd3 flak
-projectiles/grenade.qc // id1 grenades
-projectiles/hknightspell.qc // id1 Death Knight magic attack
-projectiles/laser.qc // id1 lasers (enforcer, hazards)
-projectiles/lavaball.qc // pd3 lava ball missiles
-projectiles/multigrenade.qc // pd3 & Hipnotic/Rogue multi/mini grenades
-projectiles/rocket.qc // id1 rockets
-projectiles/spike.qc // id1 nails
-projectiles/voreball.qc // id1 vore homing missile
-projectiles/wizardspell.qc // id1 Scrag green magic missile attack
-projectiles/zombiechunk.qc // id1 zombie flesh chunk (traditionally thrown)
-
-//----------------------------------------------------------------------
-// item entities & weapon firing code
-//----------------------------------------------------------------------
-items/ammo.qc // ammo; was in items.qc
-items/armor.qc // armor; was in items.qc
-items/keys.qc // key pickups; contains items.qc and keydata.qc
-items/health.qc // health; was in items.qc
-items/powerups.qc // envirosuit, pent, ring, quad; was in items.qc
-items/runes.qc // end-of-episode runes; was in items.qc
-items/weapons.qc // weapon pickups; was in items.qc
-items/backpacks.qc // backpack code; was in items.qc
-
-//----------------------------------------------------------------------
-// client & player code
-//----------------------------------------------------------------------
-cutscene.qc // Drake version -- dumptruck_ds
-obituary.qc // ClientObituary
-pmove.qc // QC player movement code -- CEV
-
-//----------------------------------------------------------------------
-// monster entities
-//----------------------------------------------------------------------
-monsters/playerclient.qc // player and client handling
-monsters/boss.qc // id1 Chthon
-monsters/boss2.qc // pd3 killable Chthon
-monsters/dog.qc // id1 Doggo
-monsters/demon.qc // id1 Fiend
-monsters/knight.qc // id1 Knight
-monsters/ogre.qc // id1 Ogre
-monsters/shambler.qc // id1 Shambler
-monsters/soldier.qc // id1 Grunt
-monsters/wizard.qc // id1 Scragg / Wizard
-monsters/zombie.qc // modified Ace_Dave's zombies from Rubicon2
-monsters/enforcer.qc // id1 Enforcer (registered)
-monsters/fish.qc // id1 Fish (registered)
-monsters/hknight.qc // id1 Death Knight / Hell Knight (registered)
-monsters/oldone.qc // id1 Shub (registered)
-monsters/oldone2.qc // pd3 killable Shub
-monsters/shalrath.qc // id1 Vore (registered)
-
-//----------------------------------------------------------------------
-// func entities
-//----------------------------------------------------------------------
-func/shadow.qc //
-func/wall.qc // was misc.qc -- CEV
-func/bob.qc // RennyC's stand alone version based on AD
-func/bossgate.qc // was misc.qc -- CEV
-func/breakable.qc // selections from Rubicon2 QC
-func/button.qc
-func/counter.qc // Hipnotic counter; was in hipcount.qc
-func/door.qc // was doors.qc -- CEV
-func/door_secret.qc // was doors.qc -- CEV
-func/elvtr_button.qc // Rogue elevator code (pmack)
-func/episodegate.qc // was misc.qc -- CEV
-func/explobox.qc // selections from Rubicon2 QC
-func/fall.qc // Renny's original version
-func/fall2.qc // Renny's improved version.
-func/illusionary.qc // was misc.qc -- CEV
-func/laser.qc // selections from Rubicon2 QC
-func/monster_spawner.qc // "bot" creation code for func_monster_spawner
-func/new_plat.qc // Rogue MP newplats.qc
-func/plat.qc // was plats.qc -- CEV
-func/particlefield.qc // Hipnotic particlefield and func_togglewall
-func/rotate.qc // from Hipnotic thanks RennyC; was rotate.qc
-func/togglevisiblewall.qc // was misc.qc -- CEV
-func/togglewall.qc // was hippart.qc -- CEV
-func/train.qc // was plats.qc -- CEV
-
-//----------------------------------------------------------------------
-// trigger & target entities
-//----------------------------------------------------------------------
-triggers/multiple.qc // need to add first, subclassed below -- CEV
-triggers/camera.qc // was in cutscene.qc
-triggers/changelevel.qc //
-triggers/changemusic.qc //
-triggers/changetarget.qc
-triggers/counter.qc //
-triggers/cvarset.qc // was in cutscene.qc
-triggers/everything.qc // trigger_everything
-triggers/filter.qc //
-triggers/fog.qc // fog triggers
-triggers/heal.qc // trigger_heal (was in dtmisc.qc) -- CEV
-triggers/hurt.qc //
-triggers/ladder.qc // ladders (from rubicon2) -- CEV
-triggers/look.qc //
-triggers/monsterface.qc //
-triggers/monsterjump.qc //
-triggers/onlyregistered.qc
-triggers/push.qc // wind/push brushes, jumppads -- CEV
-triggers/remove.qc // was in hip_trig.qc; currently disabled -- CEV
-triggers/relay.qc //
-triggers/secret.qc //
-triggers/setcount.qc // target_setcount
-triggers/setgravity.qc // was in hip_trig.qc
-triggers/setskill.qc //
-triggers/setstate.qc // target_setstate
-triggers/shake.qc // triggerable shake from Zer cutscenes
-triggers/take_weapon.qc //
-triggers/teleport.qc // was in triggers.qc -- CEV
-triggers/textstory.qc // textstory (was in misc.qc) -- CEV
-triggers/usekey.qc // was in hip_trig.qc -- CEV
-triggers/void.qc //
-
-//----------------------------------------------------------------------
-// hazards
-//----------------------------------------------------------------------
-hazards/ltrail.qc // from DOE lightnin.qc
-hazards/shooter.qc // was in misc.qc
-
-//----------------------------------------------------------------------
-// miscellaneous entities
-//----------------------------------------------------------------------
-misc/model.qc // Code by Joshua Skelton
-misc/air_bubbles.qc // was in misc.qc -- CEV
-misc/ambient_sound.qc // misc ambient_ entities w/add. by dumptruck_ds
-misc/deadstuff.qc // misc gore from DeadStuff mod
-misc/explobox.qc // was in misc.qc -- CEV
-misc/fireball.qc // was in misc.qc -- CEV
-misc/infight.qc // was in misc.qc -- CEV
-misc/light_candle.qc // was in misc.qc -- CEV
-misc/lights.qc // c0burn's excellent switchable lights
-misc/modeltrain.qc // was in plats.qc -- CEV
-misc/noisemaker.qc // was in misc.qc -- CEV
-misc/particles.qc // selections from Rubicon2 QC; was rubicon2.qc
-misc/particlespray.qc // selections from Rubicon2 QC; was rubicon2.qc
-misc/particle_stream.qc // from Zerstrorer mod -- dumptruck_ds
-misc/play.qc // sound code from Hip & Rubicon Rumble + misc
-misc/sparks.qc // selections from Rubicon2 QC; was rubicon2.qc
-misc/target_autosave.qc // was in misc.qc -- CEV
-misc/teleporttrain.qc // was in plats.qc -- CEV
-misc/viewthing.qc // was in misc.qc -- CEV
-
-//----------------------------------------------------------------------
-// world
-//----------------------------------------------------------------------
-entrypoints.qc // server-side entrypoints
-world.qc // worldspawn
-
-//----------------------------------------------------------------------
-// compatibility spawn functions & misc
-//----------------------------------------------------------------------
-compat_quake3.qc // entrypoints & support for Quake 3 entities
-#endlist
-

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

Diff qc/projectiles/bullet.qc

diff --git a/qc/projectiles/bullet.qc b/qc/projectiles/bullet.qc
index ae67628..7debeec 100644
--- a/qc/projectiles/bullet.qc
+++ b/qc/projectiles/bullet.qc
@@ -5,6 +5,7 @@
//======================================================================
// constants
//======================================================================
+
const float BULLET_DIRECT_DAMAGE = 5; // id1 is 4
// bullets don't splash
const float BULLET_SPEED = 2500.0f; // AD is 2000 units per for player
@@ -16,106 +17,138 @@ const vector BULLET_MAXS = '0 0 0'; //
// fields
//======================================================================

-// based on BDW's Flak Ogre code -- CEV
-.float bulletcount;
+.float bulletcount; // based on BDW's Flak Ogre code -- CEV
+
+//======================================================================
+// forward declarations
+//======================================================================
+
+void() projectile_bullet_think_damage;
+void() projectile_bullet_touch;
+entity(entity src, vector org, vector vel) spawn_projectile_bullet;
+void(entity e) projectile_bullet_init;
+strip void() projectile_bullet;

//------------------------------------------------------------------------------
-class projectile_bullet: base_projectile
-{
+
+//----------------------------------------------------------------------
+// class projectile_bullet: base_projectile
+// {
//--------------------------------------------------------------
- nonvirtual void() think_damage =
+ void() projectile_bullet_think_damage =
{
// get correct gib direction
- this.origin = this.oldenemy.origin + this.oldorigin;
- this.t_damage2 (this.oldenemy, this, this.owner,
- this.oldenemy.bulletcount);
- this.oldenemy.bulletcount = 0;
- remove (this);
+ self.origin = self.oldenemy.origin + self.oldorigin;
+ t_damage2 (self.oldenemy, self, self.owner,
+ self.oldenemy.bulletcount);
+ self.oldenemy.bulletcount = 0;
+ remove (self);
};

//--------------------------------------------------------------
- virtual void(entity toucher) do_touch =
+ void() projectile_bullet_touch =
{
// hit something that bleeds
- if (toucher.takedamage)
+ if (other.takedamage)
{
- spawn_touchblood (this.direct_damage);
+ spawn_touchblood (self.direct_damage);

- if (toucher.bulletcount)
+ if (other.bulletcount)
{
// not the first one
- toucher.bulletcount += this.direct_damage;
- remove (this);
+ other.bulletcount += self.direct_damage;
+ remove (self);
return;
}

// the first one...
- toucher.bulletcount = this.direct_damage;
+ other.bulletcount = self.direct_damage;

// stick around for a little while...
- this.velocity = '0 0 0';
- this.solid = SOLID_NOT;
- this.touch = sub_null;
- this.model = string_null;
+ self.velocity = '0 0 0';
+ self.solid = SOLID_NOT;
+ self.touch = sub_null;
+ self.model = __NULL__;
// displacement from enemy origin (its gonna
// move next frame)
- this.oldorigin = this.origin - toucher.origin;
- this.oldenemy = toucher;
- this.think = this.think_damage;
- this.nextthink = time + 0.05;
+ self.oldorigin = self.origin - other.origin;
+ self.oldenemy = other;
+ self.think = projectile_bullet_think_damage;
+ self.nextthink = time + 0.05;
return;
}

WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
WriteByte (MSG_BROADCAST, TE_GUNSHOT);
- WriteCoord (MSG_BROADCAST, this.origin_x);
- WriteCoord (MSG_BROADCAST, this.origin_y);
- WriteCoord (MSG_BROADCAST, this.origin_z);
+ WriteCoord (MSG_BROADCAST, self.origin_x);
+ WriteCoord (MSG_BROADCAST, self.origin_y);
+ WriteCoord (MSG_BROADCAST, self.origin_z);

- remove (this);
+ remove (self);
};

//--------------------------------------------------------------
- void() projectile_bullet =
+ entity(entity src, vector org, vector vel) spawn_projectile_bullet =
{
- this.classtype = CT_PROJECTILE_BULLET;
- this.movetype = MOVETYPE_FLY;
- this.solid = SOLID_BBOX;
- this.angles = vectoangles (this.velocity);
+ local entity e = spawn();
+ e.owner = src;
+ e.origin = org;
+ e.velocity = vel;
+ projectile_bullet_init (e);
+ return e;
+ };

- if (!this.avelocity)
+ //--------------------------------------------------------------
+ void(entity e) projectile_bullet_init =
+ {
+ base_projectile_init (e);
+
+ e.classname = "projectile_bullet";
+ e.classtype = CT_PROJECTILE_BULLET;
+ e.movetype = MOVETYPE_FLY;
+ e.solid = SOLID_BBOX;
+ e.touch = projectile_bullet_touch;
+ e.angles = vectoangles (e.velocity);
+
+ if (!e.avelocity)
// avelocity from AD is randomized; fixed for now
- this.avelocity = '100 200 0';
+ e.avelocity = '100 200 0';

- if (!this.proj_basespeed)
- this.proj_basespeed = BULLET_SPEED;
+ if (!e.proj_basespeed)
+ e.proj_basespeed = BULLET_SPEED;

- if (!this.direct_damage)
- this.direct_damage = BULLET_DIRECT_DAMAGE;
+ if (!e.direct_damage)
+ e.direct_damage = BULLET_DIRECT_DAMAGE;

// dumptruck_ds
- if (this.mdl_proj && this.mdl_proj != "")
+ if (e.mdl_proj && e.mdl_proj != "")
{
- setmodel (this, this.mdl_proj);
+ setmodel (e, e.mdl_proj);
}
else
{
// AD projectile diamond model
- setmodel (this, "progs/ad/proj_diam2.mdl");
+ setmodel (e, "progs/ad/proj_diam2.mdl");

// full range of sizes (comment from AD)
- this.frame = random () * 15;
+ e.frame = random () * 15;

// Bright colours (comment from AD)
- this.skin = 16 + random () * 7;
+ e.skin = 16 + random () * 7;
}

- if (this.skin_proj)
- this.skin = this.skin_proj;
+ if (e.skin_proj)
+ e.skin = e.skin_proj;

- setsize (this, BULLET_MINS, BULLET_MAXS);
- setorigin (this, this.origin);
- this.think = sub_remove;
- this.nextthink = time + 6;
+ setsize (e, BULLET_MINS, BULLET_MAXS);
+ setorigin (e, e.origin);
+ e.think = sub_remove;
+ e.nextthink = time + 6;
+ };
+
+ //--------------------------------------------------------------
+ strip void() projectile_bullet =
+ {
+ projectile_bullet_init (self);
};
-};
+// };

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

Diff qc/projectiles/fireball.qc

diff --git a/qc/projectiles/fireball.qc b/qc/projectiles/fireball.qc
new file mode 100644
index 0000000..14062f9
--- /dev/null
+++ b/qc/projectiles/fireball.qc
@@ -0,0 +1,85 @@
+//==============================================================================
+// Fireballs - launched by misc_fireball
+//==============================================================================
+
+//======================================================================
+// constants
+//======================================================================
+
+const float FIREBALL_DIRECT_DAMAGE = 20;// 20 in id1
+ // no splash damage
+const float FIREBALL_SPEED = 1000.0f; // base speed appears to be 1000 in id1
+
+//======================================================================
+// forward declarations
+//======================================================================
+
+// projectile_fireball
+void() projectile_fireball_touch;
+entity(entity src, vector org, vector vel, float dmg) spawn_projectile_fireball;
+void(entity e) projectile_fireball_init;
+strip void() projectile_fireball;
+
+//------------------------------------------------------------------------------
+
+//----------------------------------------------------------------------
+// class projectile_fireball: base_projectile
+// {
+ //--------------------------------------------------------------
+ void() projectile_fireball_touch =
+ {
+ t_damage2 (other, self, self, self.direct_damage);
+ remove (self);
+ };
+
+ //--------------------------------------------------------------
+ entity(entity src, vector org, vector vel, float dmg)
+ spawn_projectile_fireball =
+ {
+ local entity e = spawn ();
+ e.owner = src;
+ e.origin = org;
+ e.velocity = vel;
+ projectile_fireball_init (e);
+ return e;
+ };
+
+ //--------------------------------------------------------------
+ void(entity e) projectile_fireball_init =
+ {
+ base_projectile_init (e);
+
+ e.classname = "fireball";
+ e.classtype = CT_PROJECTILE_FIREBALL;
+ e.movetype = MOVETYPE_TOSS;
+ e.solid = SOLID_TRIGGER;
+ e.touch = projectile_fireball_touch;
+ e.angles = vectoangles (e.velocity);
+
+ if (!e.proj_basespeed)
+ e.proj_basespeed = FIREBALL_SPEED;
+
+ if (!e.direct_damage)
+ e.direct_damage = FIREBALL_DIRECT_DAMAGE;
+
+ // dumptruck_ds
+ if (e.mdl_proj && e.mdl_proj != "")
+ setmodel (e, e.mdl_proj);
+ else
+ setmodel (e, "progs/lavaball.mdl");
+
+ if (e.skin_proj)
+ e.skin = e.skin_proj;
+
+ setsize (e, '0 0 0', '0 0 0');
+ setorigin (e, e.origin);
+ e.think = sub_remove;
+ e.nextthink = time + 5;
+ };
+
+ //--------------------------------------------------------------
+ strip void() projectile_fireball =
+ {
+ projectile_fireball_init (self);
+ };
+// };

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

Diff qc/projectiles/flak.qc

diff --git a/qc/projectiles/flak.qc b/qc/projectiles/flak.qc
index ff3f34d..65de88f 100644
--- a/qc/projectiles/flak.qc
+++ b/qc/projectiles/flak.qc
@@ -14,6 +14,8 @@ const float FLAK_SPEED = 800; // speed of BDW's OgreFireFlak
const vector FLAK_MINS = '0 0 0'; // let's not change this -- CEV
const vector FLAK_MAXS = '0 0 0'; //

+const float MONSTER_FLAK_OGRE = 4; // TODO CEV remove
+
//======================================================================
// fields
//======================================================================
@@ -22,125 +24,169 @@ const vector FLAK_MAXS = '0 0 0'; //
// currently only used for flak ogre
.float spikecount;

+//======================================================================
+// forward declarations
+//======================================================================
+
+void() projectile_flak_think_damage;
+void() projectile_flak_touch;
+entity(entity src, vector org, vector vel) spawn_projectile_flak;
+void(entity e) projectile_flak_init;
+strip void() projectile_flak;
+
//------------------------------------------------------------------------------
-class projectile_flak: base_projectile
-{
+
+//----------------------------------------------------------------------
+// class projectile_flak: base_projectile
+// {
//--------------------------------------------------------------
// FlakDoDamage
//--------------------------------------------------------------
- nonvirtual void() think_damage =
+ void() projectile_flak_think_damage =
{
// get correct gib direction
- this.origin = this.oldenemy.origin + this.oldorigin;
- this.t_damage2 (this.oldenemy, this, this.owner,
- this.oldenemy.spikecount);
- this.oldenemy.spikecount = 0;
- remove (this);
+ self.origin = self.oldenemy.origin + self.oldorigin;
+ t_damage2 (self.oldenemy, self, self.owner,
+ self.oldenemy.spikecount);
+ self.oldenemy.spikecount = 0;
+ remove (self);
};

//--------------------------------------------------------------
// FlakTouch
//--------------------------------------------------------------
- virtual void(entity toucher) do_touch =
+ void() projectile_flak_touch =
{
// hit something that bleeds
- if (toucher.takedamage)
+ if (other.takedamage)
{
- spawn_touchblood (this.direct_damage);
+ spawn_touchblood (self.direct_damage);

- sound (this, CHAN_VOICE, "fish/bite.wav", 1, ATTN_NORM);
+ sound (self, CHAN_VOICE, "fish/bite.wav", 1, ATTN_NORM);

- if (toucher.spikecount)
+ if (other.spikecount)
{
// not the first one
- toucher.spikecount += this.direct_damage;
- remove (this);
+ other.spikecount += self.direct_damage;
+ remove (self);
return;
}

// the first one...
- toucher.spikecount = this.direct_damage;
+ other.spikecount = self.direct_damage;

// stick around for a little while...
- this.velocity = '0 0 0';
- this.solid = SOLID_NOT;
- this.touch = sub_null;
- this.model = string_null;
+ self.velocity = '0 0 0';
+ self.solid = SOLID_NOT;
+ self.touch = sub_null;
+ self.model = __NULL__;
// displacement from enemy origin (its gonna
// move next frame)
- this.oldorigin = this.origin - toucher.origin;
- this.oldenemy = toucher;
- this.think = this.think_damage;
- this.nextthink = time + 0.05;
+ self.oldorigin = self.origin - other.origin;
+ self.oldenemy = other;
+ self.think = projectile_flak_think_damage;
+ self.nextthink = time + 0.05;
return;
}

WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
WriteByte (MSG_BROADCAST, TE_SUPERSPIKE);
- WriteCoord (MSG_BROADCAST, this.origin_x);
- WriteCoord (MSG_BROADCAST, this.origin_y);
- WriteCoord (MSG_BROADCAST, this.origin_z);
+ WriteCoord (MSG_BROADCAST, self.origin_x);
+ WriteCoord (MSG_BROADCAST, self.origin_y);
+ WriteCoord (MSG_BROADCAST, self.origin_z);

// bit of a hack
- if (this.spawnflags & MONSTER_FLAK_OGRE)
+ if (self.spawnflags & MONSTER_FLAK_OGRE)
{
- remove (this);
+ remove (self);
return;
}

// gets weaker with each bounce.
// also stops them getting stuck in world.
- this.direct_damage = this.direct_damage - 5;
- if (this.direct_damage <= 0)
+ self.direct_damage = self.direct_damage - 5;
+ if (self.direct_damage <= 0)
{
- remove (this);
+ remove (self);
return;
}

// reduce crazy ricochets
- this.velocity = this.velocity * 0.5;
- this.movetype = MOVETYPE_BOUNCE;
+ self.velocity = self.velocity * 0.5;
+ self.movetype = MOVETYPE_BOUNCE;
};

//--------------------------------------------------------------
- void() projectile_flak =
+ entity(entity src, vector org, vector vel) spawn_projectile_flak =
{
- this.classtype = CT_PROJECTILE_FLAK;
+ local entity e = spawn();
+ e.owner = src;
+ e.enemy = src.enemy;
+ e.origin = org;
+ e.velocity = vel;
+ // parameters for homing
+ e.homing = src.homing;
+ e.proj_speed_mod = src.proj_speed_mod;
+ e.waitmin = src.waitmin;
+ // model, skin, & sounds
+ e.mdl_proj = src.mdl_proj;
+ e.skin_proj = src.skin_proj;
+ e.snd_hit = src.snd_hit;
+
+ projectile_flak_init (e);
+ return e;
+ };
+
+ //--------------------------------------------------------------
+ void(entity e) projectile_flak_init =
+ {
+ base_projectile_init (e);
+
+ e.classname = "projectile_flak";
+ e.classtype = CT_PROJECTILE_FLAK;
// flymissile is a bit too all-seeing for this gun...
- this.movetype = MOVETYPE_FLY;
- this.solid = SOLID_BBOX;
- this.flags = FL_NOSELECT;
- this.angles = vectoangles (this.velocity);
+ e.movetype = MOVETYPE_FLY;
+ e.solid = SOLID_BBOX;
+ e.touch = projectile_flak_touch;
+ e.flags = FL_NOSELECT;
+ e.angles = vectoangles (e.velocity);

- if (!this.proj_basespeed)
- this.proj_basespeed = FLAK_SPEED;
+ if (!e.proj_basespeed)
+ e.proj_basespeed = FLAK_SPEED;

- if (!this.direct_damage)
- this.direct_damage = FLAK_DIRECT_DAMAGE;
+ if (!e.direct_damage)
+ e.direct_damage = FLAK_DIRECT_DAMAGE;

// dumptruck_ds
- if (this.mdl_proj && this.mdl_proj != "")
- setmodel (this, this.mdl_proj);
+ if (e.mdl_proj && e.mdl_proj != "")
+ setmodel (e, e.mdl_proj);
else
- setmodel (this, "progs/spike.mdl");
+ setmodel (e, "progs/spike.mdl");

- // if (this.skin_proj)
- // this.skin = this.skin_proj;
+ // if (e.skin_proj)
+ // e.skin = e.skin_proj;
// else
- this.skin = 0;
+ e.skin = 0;
// dumptruck_ds - end

- if (this.homing > 0)
+ if (e.homing > 0)
{
- setup_homing (proj_basespeed * proj_speed_mod);
+ base_projectile_setup_homing (e,
+ e.proj_basespeed * e.proj_speed_mod);
}
else
{
- this.nextthink = time + 6;
- this.think = sub_remove;
+ e.think = sub_remove;
+ e.nextthink = time + 6;
}

- setsize (this, FLAK_MINS, FLAK_MAXS);
- setorigin (this, this.origin);
+ setsize (e, FLAK_MINS, FLAK_MAXS);
+ setorigin (e, e.origin);
+ };
+
+ //--------------------------------------------------------------
+ strip void() projectile_flak =
+ {
+ projectile_flak_init (self);
};
-};
+// };

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

Diff qc/projectiles/grenade.qc

diff --git a/qc/projectiles/grenade.qc b/qc/projectiles/grenade.qc
index 94f573e..01a36a4 100644
--- a/qc/projectiles/grenade.qc
+++ b/qc/projectiles/grenade.qc
@@ -16,30 +16,40 @@ const float GRENADE_HEALTH = 20; // explodes when dead
const vector GRENADE_MINS = '-8 -8 -8'; // a little more generous -- CEV
const vector GRENADE_MAXS = '8 8 8';

+//======================================================================
+// forward declarations
+//======================================================================
+
+void() projectile_grenade_destroy;
+void() projectile_grenade_think;
+entity(entity src, vector org, vector vel) spawn_projectile_grenade;
+void(entity e) projectile_grenade_init;
+strip void() projectile_grenade;
+
//------------------------------------------------------------------------------
-class projectile_grenade: base_projectile_qcphys
-{
- float count;

+//----------------------------------------------------------------------
+// class projectile_grenade: base_projectile_qcphys
+// {
//--------------------------------------------------------------
- virtual void() do_destroy =
+ void() projectile_grenade_destroy =
{
- dprint (sprintf("projectile_grenade::do_destroy: exploding\n"));
- this.do_think ();
+ dprint (sprintf("projectile_grenade_destroy: exploding\n"));
+ projectile_grenade_think ();
};

//--------------------------------------------------------------
- virtual void() do_think =
+ void() projectile_grenade_think =
{
- if (this.takedamage)
- this.takedamage = DAMAGE_NO;
+ if (self.takedamage)
+ self.takedamage = DAMAGE_NO;

- t_radiusdamage2 (this, this.owner, this.splash_damage, other);
+ t_radiusdamage2 (self, self.owner, self.splash_damage, other);

// BecomeExplosion
- base_explosion::write_explosion (this.origin);
- spawn (base_explosion, origin: this.origin);
- remove (this);
+ write_explosion (self.origin);
+ spawn_base_explosion (self.origin);
+ remove (self);
};

//--------------------------------------------------------------
@@ -72,81 +82,115 @@ class projectile_grenade: base_projectile_qcphys
// grenades deal to any of the original monsters under any
// circumstances. -- iw
//--------------------------------------------------------------
- virtual void(entity toucher) do_touch_explosive =
+ void() projectile_grenade_touch =
{
- if (toucher.takedamage == DAMAGE_AIM)
+ // standard touch check
+ if (base_projectile_check_touch())
+ return;
+
+ if (other.takedamage == DAMAGE_AIM)
{
// see the explanation above -- iw
- if (toucher.size_x > VEC_HULL2_SIZE_x ||
- toucher.size_y > VEC_HULL2_SIZE_y ||
- toucher.size_z > VEC_HULL2_SIZE_z)
+ if (other.size_x > VEC_HULL2_SIZE_x ||
+ other.size_y > VEC_HULL2_SIZE_y ||
+ other.size_z > VEC_HULL2_SIZE_z)
{
// note that the logic for monster_shambler's
// partial immunity to explosions is not
// required because this is only for entities
// which are larger than monster_shambler -- iw
// dmg = this.direct_dmg + random() * 20;
- t_damage2 (toucher, this, this.owner,
- this.direct_damage);
- this.do_think ();
+ t_damage2 (other, self, self.owner,
+ self.direct_damage);
+ projectile_grenade_think ();
return;
}
other = world;
- this.do_think ();
+ projectile_grenade_think ();
return;
}

- if (this.count < time)
+ if (self.count < time)
{
// bounce sound
- sound (this, CHAN_WEAPON, "weapons/bounce.wav",
+ sound (self, CHAN_WEAPON, "weapons/bounce.wav",
1, ATTN_NORM);
}

- this.count = time + 0.02;
- if (this.velocity == '0 0 0')
- this.avelocity = '0 0 0';
+ self.count = time + 0.02;
+ if (self.velocity == '0 0 0')
+ self.avelocity = '0 0 0';
};

//--------------------------------------------------------------
- void() projectile_grenade =
+ entity(entity src, vector org, vector vel) spawn_projectile_grenade =
{
- this.classtype = CT_PROJECTILE_GRENADE;
- this.classname = "grenade";
- this.movetype = MOVETYPE_BOUNCE;
- this.solid = SOLID_BBOX;
- this.explosive = TRUE;
- this.health = GRENADE_HEALTH;
- this.takedamage = DAMAGE_YES;
- this.angles = vectoangles (this.velocity);
+ local entity e = spawn ();
+ e.owner = src;
+ e.origin = org;
+ e.velocity = vel;
+ // damage
+ e.direct_damage = GRENADE_DIRECT_DAMAGE;
+ e.splash_damage = GRENADE_SPLASH_DAMAGE;
+ // model, skin, & sounds
+ e.mdl_proj = src.mdl_proj;
+ e.skin_proj = src.skin_proj;
+ e.snd_hit = src.snd_hit;
+
+ projectile_grenade_init (e);
+ return e;
+ };

- if (!this.avelocity)
- this.avelocity = '300 300 300';
+ //--------------------------------------------------------------
+ void(entity e) projectile_grenade_init =
+ {
+ base_projectile_qcphys_init (e);
+
+ e.classname = "grenade";
+ e.classtype = CT_PROJECTILE_GRENADE;
+ e.movetype = MOVETYPE_BOUNCE;
+ e.solid = SOLID_BBOX;
+ e.destroy = projectile_grenade_destroy;
+ e.touch = projectile_grenade_touch;
+ e.aflag |= PROJECTILE_EXPLOSIVE;
+ e.health = GRENADE_HEALTH;
+ e.takedamage = DAMAGE_YES;
+ e.angles = vectoangles (e.velocity);

- if (!this.proj_basespeed)
- this.proj_basespeed = GRENADE_SPEED;
+ if (!e.avelocity)
+ e.avelocity = '300 300 300';
+
+ if (!e.proj_basespeed)
+ e.proj_basespeed = GRENADE_SPEED;

// default damage for player grenades -- CEV
- if (!this.direct_damage)
- this.direct_damage = GRENADE_DIRECT_DAMAGE;
+ if (!e.direct_damage)
+ e.direct_damage = GRENADE_DIRECT_DAMAGE;

- if (!this.splash_damage)
- this.splash_damage = GRENADE_SPLASH_DAMAGE;
+ if (!e.splash_damage)
+ e.splash_damage = GRENADE_SPLASH_DAMAGE;

- if (this.mdl_proj && this.mdl_proj != "")
- setmodel (this, this.mdl_proj);
+ if (e.mdl_proj && e.mdl_proj != "")
+ setmodel (e, e.mdl_proj);
else
- setmodel (this, "progs/grenade.mdl");
+ setmodel (e, "progs/grenade.mdl");

- if (this.skin_proj)
- this.skin = this.skin_proj;
+ if (e.skin_proj)
+ e.skin = e.skin_proj;
else
- this.skin = 0;
+ e.skin = 0;

- setsize (this, GRENADE_MINS, GRENADE_MAXS);
- setorigin (this, this.origin);
+ setsize (e, GRENADE_MINS, GRENADE_MAXS);
+ setorigin (e, e.origin);

// schedule next think (explosion time)
- this.nextthink = time + 2.5;
+ e.think = projectile_grenade_think;
+ e.nextthink = time + 2.5;
+ };
+
+ //--------------------------------------------------------------
+ strip void() projectile_grenade =
+ {
+ projectile_grenade_init (self);
};
-};
+// };

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

Diff qc/projectiles/hknightspell.qc

diff --git a/qc/projectiles/hknightspell.qc b/qc/projectiles/hknightspell.qc
index a74ed6d..1a4deb7 100644
--- a/qc/projectiles/hknightspell.qc
+++ b/qc/projectiles/hknightspell.qc
@@ -13,62 +13,108 @@ const float HKNSPELL_SPEED = 300; // id1 Death Knight missile is 300ups
const vector HKNSPELL_MINS = '0 0 0'; // let's not change this -- CEV
const vector HKNSPELL_MAXS = '0 0 0'; //

+//======================================================================
+// forward declarations
+//======================================================================
+
+entity(entity src, vector org, vector vel, float offset)
+ spawn_projectile_hknightspell;
+void(entity e) projectile_hknightspell_init;
+strip void() projectile_hknightspell;
+
//------------------------------------------------------------------------------
-class projectile_hknightspell: base_projectile
-{
- float spell_offset;
+
+//----------------------------------------------------------------------
+// class projectile_hknightspell: base_projectile
+// {
+ //--------------------------------------------------------------
+ entity(entity src, vector org, vector vel, float offset)
+ spawn_projectile_hknightspell =
+ {
+ local entity e = spawn ();
+ e.owner = src;
+ e.enemy = src.enemy;
+ e.origin = org;
+ e.velocity = vel;
+ e.projexpl = src.projexpl;
+ // parameters for homing
+ e.homing = src.homing;
+ e.proj_speed_mod = src.proj_speed_mod;
+ e.waitmin = src.waitmin;
+ // model, skin, & sounds
+ e.mdl_proj = src.mdl_proj;
+ e.skin_proj = src.skin_proj;
+ e.snd_hit = src.snd_hit;
+ // unique to this magic missile
+ e.distance = offset;
+
+ projectile_hknightspell_init (e);
+ return e;
+ };

//--------------------------------------------------------------
- void() projectile_hknightspell =
+ void(entity e) projectile_hknightspell_init =
{
- this.classtype = CT_PROJECTILE_HKNIGHT;
- this.classname = "knightspike";
- this.movetype = MOVETYPE_FLYMISSILE;
- this.solid = SOLID_BBOX;
- this.explosive = parse_projexpl (projexpl, spell_offset);
- this.angles = vectoangles (this.velocity);
-
- if (!this.proj_basespeed)
- this.proj_basespeed = HKNSPELL_SPEED;
-
- if (!this.direct_damage)
- if (this.explosive)
- this.direct_damage = HKNSPELL_EXPLOD_DAMAGE;
+ base_projectile_init (e);
+
+ e.classname = "knightspike";
+ e.classtype = CT_PROJECTILE_HKNIGHT;
+ e.movetype = MOVETYPE_FLYMISSILE;
+ e.solid = SOLID_BBOX;
+ e.touch = base_projectile_touch;
+ e.angles = vectoangles (e.velocity);
+
+ if (base_projectile_parse_projexpl(e.projexpl, e.distance))
+ e.aflag |= PROJECTILE_EXPLOSIVE;
+
+ if (!e.proj_basespeed)
+ e.proj_basespeed = HKNSPELL_SPEED;
+
+ if (!e.direct_damage)
+ if (e.aflag & PROJECTILE_EXPLOSIVE)
+ e.direct_damage = HKNSPELL_EXPLOD_DAMAGE;
else
- this.direct_damage = HKNSPELL_DIRECT_DAMAGE;
+ e.direct_damage = HKNSPELL_DIRECT_DAMAGE;

- if (!this.splash_damage)
- if (this.explosive)
- this.splash_damage = HKNSPELL_SPLASH_DAMAGE;
+ if (!e.splash_damage)
+ if (e.aflag & PROJECTILE_EXPLOSIVE)
+ e.splash_damage = HKNSPELL_SPLASH_DAMAGE;
else
- this.splash_damage = 0;
+ e.splash_damage = 0;

// dumptruck_ds custom_mdls
- if (this.mdl_proj != "")
- setmodel (this, this.mdl_proj);
+ if (e.mdl_proj != "")
+ setmodel (e, e.mdl_proj);
else
- if (explosive)
- setmodel (this, "progs/k_spike2.mdl");
+ if (e.aflag & PROJECTILE_EXPLOSIVE)
+ setmodel (e, "progs/k_spike2.mdl");
else
- setmodel (this, "progs/k_spike.mdl");
+ setmodel (e, "progs/k_spike.mdl");

// dumptruck_ds
- if (this.skin_proj)
- this.skin = this.skin_proj;
+ if (e.skin_proj)
+ e.skin = e.skin_proj;
else
- this.skin = 0;
+ e.skin = 0;

- if (this.homing > 0)
+ if (e.homing > 0)
{
- setup_homing (proj_basespeed * proj_speed_mod);
+ base_projectile_setup_homing (e,
+ e.proj_basespeed * e.proj_speed_mod);
}
else
{
- this.think = sub_remove;
- this.nextthink = time + 6;
+ e.think = sub_remove;
+ e.nextthink = time + 6;
}

- setsize (this, HKNSPELL_MINS, HKNSPELL_MAXS);
- setorigin (this, this.origin);
+ setsize (e, HKNSPELL_MINS, HKNSPELL_MAXS);
+ setorigin (e, e.origin);
+ };
+
+ //--------------------------------------------------------------
+ strip void() projectile_hknightspell =
+ {
+ projectile_hknightspell_init (self);
};
-};
+// };

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

Diff qc/projectiles/laser.qc

diff --git a/qc/projectiles/laser.qc b/qc/projectiles/laser.qc
index d37e28b..5412d3b 100644
--- a/qc/projectiles/laser.qc
+++ b/qc/projectiles/laser.qc
@@ -12,21 +12,34 @@ const float LASER_SPEED = 600; // id1 laser speed is 600
const vector LASER_MINS = '0 0 0'; // let's not change this -- CEV
const vector LASER_MAXS = '0 0 0'; //

+//======================================================================
+// forward declarations
+//======================================================================
+
+void() projectile_laser_touch;
+entity(entity src, vector org, vector vel) spawn_projectile_laser;
+void(entity e) projectile_laser_init;
+strip void() projectile_laser;
+
//------------------------------------------------------------------------------
-class projectile_laser: base_projectile
-{
+
+//----------------------------------------------------------------------
+// class projectile_laser: base_projectile
+// {
//--------------------------------------------------------------
- virtual void(entity toucher) do_touch =
+ void() projectile_laser_touch =
{
// dumptruck_ds
- sound_hit (this, CHAN_WEAPON, "enforcer/enfstop.wav",
+ sound_hit (self, CHAN_WEAPON, "enforcer/enfstop.wav",
1, ATTN_STATIC);
- local vector org = this.origin - 8 * normalize (this.velocity);
+ local vector org = self.origin - 8 * normalize (self.velocity);

- if (toucher.health)
+ if (other.health)
{
- SpawnBlood (org, this.velocity * 0.2, direct_damage);
- t_damage2 (toucher, this, this.owner, direct_damage);
+ spawn_blood (org, self.velocity * 0.2,
+ self.direct_damage);
+ t_damage2 (other, self, self.owner,
+ self.direct_damage);
}
else
{
@@ -37,47 +50,79 @@ class projectile_laser: base_projectile
WriteCoord (MSG_BROADCAST, org_z);
}

- remove (this);
+ remove (self);
};

//--------------------------------------------------------------
- void() projectile_laser =
+ entity(entity src, vector org, vector vel) spawn_projectile_laser =
{
- this.classtype = CT_PROJECTILE_LASERBEAM;
- this.movetype = MOVETYPE_FLY;
- this.solid = SOLID_BBOX;
- this.effects = EF_DIMLIGHT;
- this.angles = vectoangles (this.velocity);
+ entity e = spawn ();
+ e.owner = src;
+ e.enemy = src.enemy;
+ e.origin = org;
+ e.velocity = vel;
+ // parameters for homing
+ e.homing = src.homing;
+ e.proj_speed_mod = src.proj_speed_mod;
+ e.waitmin = src.waitmin;
+ // model, skin, & sounds
+ e.mdl_proj = src.mdl_proj;
+ e.skin_proj = src.skin_proj;
+ e.snd_hit = src.snd_hit;

- if (!this.proj_basespeed)
- this.proj_basespeed = LASER_SPEED;
+ projectile_laser_init (e);
+ return e;
+ };

- if (!this.direct_damage)
- this.direct_damage = LASER_DIRECT_DAMAGE;
+ //--------------------------------------------------------------
+ void(entity e) projectile_laser_init =
+ {
+ base_projectile_init (e);
+
+ e.classname = "projectile_laser";
+ e.classtype = CT_PROJECTILE_LASERBEAM;
+ e.movetype = MOVETYPE_FLY;
+ e.solid = SOLID_BBOX;
+ e.touch = projectile_laser_touch;
+ e.effects = EF_DIMLIGHT;
+ e.angles = vectoangles (e.velocity);
+
+ if (!e.proj_basespeed)
+ e.proj_basespeed = LASER_SPEED;
+
+ if (!e.direct_damage)
+ e.direct_damage = LASER_DIRECT_DAMAGE;

// dumptruck_ds
- if (this.mdl_proj != "")
- setmodel (this, this.mdl_proj);
+ if (e.mdl_proj != "")
+ setmodel (e, e.mdl_proj);
else
- setmodel (this, "progs/laser.mdl");
+ setmodel (e, "progs/laser.mdl");

// dumptruck_ds
- if (this.skin_proj)
- this.skin = this.skin_proj;
+ if (e.skin_proj)
+ e.skin = e.skin_proj;
else
- this.skin = 0;
+ e.skin = 0;

- if (this.homing > 0)
+ if (e.homing > 0)
{
- setup_homing (proj_basespeed * proj_speed_mod);
+ base_projectile_setup_homing (e,
+ e.proj_basespeed * e.proj_speed_mod);
}
else
{
- this.nextthink = time + 5;
- this.think = sub_remove;
+ e.nextthink = time + 5;
+ e.think = sub_remove;
}

- setsize (this, LASER_MINS, LASER_MAXS);
- setorigin (this, this.origin);
+ setsize (e, LASER_MINS, LASER_MAXS);
+ setorigin (e, e.origin);
+ };
+
+ //--------------------------------------------------------------
+ strip void() projectile_laser =
+ {
+ projectile_laser_init (self);
};
-};
+// };

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

Diff qc/projectiles/lavaball.qc

diff --git a/qc/projectiles/lavaball.qc b/qc/projectiles/lavaball.qc
index 0cc2962..bff9d75 100644
--- a/qc/projectiles/lavaball.qc
+++ b/qc/projectiles/lavaball.qc
@@ -16,68 +16,108 @@ const float LAVABALL_HEALTH = 100; // much more difficult to destroy
const vector LAVABALL_MINS = '-7 -7 -8';// slightly more generous mins & maxs
const vector LAVABALL_MAXS = '7 7 8';

+//======================================================================
+// forward declarations
+//======================================================================
+
+void() projectile_lavaball_destroy;
+entity(entity src, vector org, vector vel) spawn_projectile_lavaball;
+void(entity e) projectile_lavaball_init;
+strip void() projectile_lavaball;
+
//------------------------------------------------------------------------------
-class projectile_lavaball: base_projectile_qcphys
-{
+
+//----------------------------------------------------------------------
+// class projectile_lavaball: base_projectile_qcphys
+// {
//--------------------------------------------------------------
- virtual void() do_destroy =
+ void() projectile_lavaball_destroy =
{
- // dprint ("projectile_lavaball::do_destroy: exploding...\n");
- this.do_touch_explosive (world);
+ // dprint ("projectile_lavaball_destroy: exploding...\n");
+ self.touch ();
};

//--------------------------------------------------------------
- // Touch is handled by base_projectile -- CEV
- //--------------------------------------------------------------
+ entity(entity src, vector org, vector vel) spawn_projectile_lavaball =
+ {
+ entity e = spawn ();
+ e.owner = src;
+ e.enemy = src.enemy;
+ e.origin = org;
+ e.velocity = vel;
+ e.avelocity = src.cust_avelocity;
+ // parameters for homing
+ e.homing = src.homing;
+ e.proj_speed_mod = src.proj_speed_mod;
+ e.waitmin = src.waitmin;
+ // model, skin, & sounds
+ e.mdl_proj = src.mdl_proj;
+ e.skin_proj = src.skin_proj;
+ e.snd_hit = src.snd_hit;
+
+ projectile_lavaball_init (e);
+ return e;
+ };

//--------------------------------------------------------------
- void() projectile_lavaball =
+ void(entity e) projectile_lavaball_init =
{
- this.classtype = CT_PROJECTILE_LAVABALL;
- this.classname = "lavaball";
- this.movetype = MOVETYPE_FLYMISSILE;
- this.solid = SOLID_BBOX;
- this.explosive = TRUE;
- this.health = LAVABALL_HEALTH;
- this.takedamage = DAMAGE_YES;
- this.angles = vectoangles (this.velocity);
+ base_projectile_qcphys_init (e);
+
+ e.classname = "lavaball";
+ e.classtype = CT_PROJECTILE_LAVABALL;
+ e.movetype = MOVETYPE_FLYMISSILE;
+ e.solid = SOLID_BBOX;
+ e.destroy = projectile_lavaball_destroy;
+ e.touch = base_projectile_touch;
+ e.aflag |= PROJECTILE_EXPLOSIVE;
+ e.health = LAVABALL_HEALTH;
+ e.takedamage = DAMAGE_YES;
+ e.angles = vectoangles (e.velocity);

// trap_shooter sets avelocity to '0 0 400' -- CEV
- if (!this.avelocity)
- this.avelocity = '200 100 300';
+ if (!e.avelocity)
+ e.avelocity = '200 100 300';

- if (!this.proj_basespeed)
- this.proj_basespeed = LAVABALL_SPEED;
+ if (!e.proj_basespeed)
+ e.proj_basespeed = LAVABALL_SPEED;

- if (!this.direct_damage)
- this.direct_damage = LAVABALL_DIRECT_DAMAGE;
+ if (!e.direct_damage)
+ e.direct_damage = LAVABALL_DIRECT_DAMAGE;

- if (!this.splash_damage)
- this.splash_damage = LAVABALL_SPLASH_DAMAGE;
+ if (!e.splash_damage)
+ e.splash_damage = LAVABALL_SPLASH_DAMAGE;

// dumptruck_ds custom_mdls
- if (this.mdl_proj != "")
- setmodel (this, this.mdl_proj);
+ if (e.mdl_proj != "")
+ setmodel (e, e.mdl_proj);
else
- setmodel (this, "progs/lavaball.mdl");
+ setmodel (e, "progs/lavaball.mdl");

// dumptruck_ds
- if (this.skin_proj)
- this.skin = this.skin_proj;
+ if (e.skin_proj)
+ e.skin = e.skin_proj;
else
- this.skin = 0;
+ e.skin = 0;

- if (this.homing > 0)
+ if (e.homing > 0)
{
- setup_homing (proj_basespeed * proj_speed_mod);
+ base_projectile_setup_homing (e,
+ e.proj_basespeed * e.proj_speed_mod);
}
else
{
- this.think = sub_remove;
- this.nextthink = time + 6;
+ e.think = sub_remove;
+ e.nextthink = time + 6;
}

- setsize (this, LAVABALL_MINS, LAVABALL_MAXS);
- setorigin (this, this.origin);
+ setsize (e, LAVABALL_MINS, LAVABALL_MAXS);
+ setorigin (e, e.origin);
+ };
+
+ //--------------------------------------------------------------
+ strip void() projectile_lavaball =
+ {
+ projectile_lavaball_init (self);
};
-};
+// };

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

Diff qc/projectiles/multigrenade.qc

diff --git a/qc/projectiles/multigrenade.qc b/qc/projectiles/multigrenade.qc
index a518443..947c090 100644
--- a/qc/projectiles/multigrenade.qc
+++ b/qc/projectiles/multigrenade.qc
@@ -14,193 +14,286 @@ const vector MININADE_MAXS = '0 0 0';
const vector MULTINADE_MINS = '-8 -8 -8';// a generous grenade size -- CEV
const vector MULTINADE_MAXS = '8 8 8';

+//======================================================================
+// forward declarations
+//======================================================================
+
+// base_doegrenade
+void() projectile_minigrenade_explode;
+
+// projectile_minigrenade
+void() projectile_minigrenade_think;
+void() projectile_minigrenade_touch;
+entity(entity src, vector org, vector vel) spawn_projectile_minigrenade;
+void(entity e) projectile_minigrenade_init;
+strip void() projectile_minigrenade;
+
+// projectile_multigrenade
+void() projectile_multigrenade_destroy;
+void(float offset_angle) projectile_multigrenade_fire;
+void() projectile_multigrenade_think;
+void() projectile_multigrenade_touch;
+entity(entity src, vector org, vector vel) spawn_projectile_multigrenade;
+void(entity e) projectile_multigrenade_init;
+strip void() projectile_multigrenade;
+
//------------------------------------------------------------------------------
-class base_doegrenade: base_projectile
-{
+
+//----------------------------------------------------------------------
+// class base_doegrenade: base_projectile
+// {
//--------------------------------------------------------------
// MiniGrenadeExplode
//--------------------------------------------------------------
- nonvirtual void() minigrenade_explode =
+ void() projectile_minigrenade_explode =
{
- if (this.takedamage)
- this.takedamage = DAMAGE_NO;
+ if (self.takedamage)
+ self.takedamage = DAMAGE_NO;

// removed distinction between player and monster-fired
// minigrenades in favor of a fixed common damage -- CEV
- t_radiusdamage2 (this, this.owner, splash_damage, world);
+ t_radiusdamage2 (self, self.owner, self.splash_damage, world);

// BecomeExplosion
- base_explosion::write_explosion2 (this.origin);
+ write_explosion2 (self.origin);
// TODO CEV what are the following two writes doing?
WriteByte (MSG_BROADCAST, 230);
WriteByte (MSG_BROADCAST, 5);
- spawn (base_explosion, origin: this.origin);
- remove (this);
+ spawn_base_explosion (self.origin);
+ remove (self);
};
-};
+// };

-//------------------------------------------------------------------------------
-class projectile_minigrenade: base_doegrenade
-{
+//----------------------------------------------------------------------
+// class projectile_minigrenade: base_doegrenade
+// {
//--------------------------------------------------------------
- virtual void() do_think =
+ void() projectile_minigrenade_think =
{
- minigrenade_explode ();
+ projectile_minigrenade_explode ();
};

//--------------------------------------------------------------
// MultiGrenadeTouch (modified)
//--------------------------------------------------------------
- virtual void(entity toucher) do_touch_explosive =
+ void() projectile_minigrenade_touch =
{
- if (toucher.takedamage == DAMAGE_AIM)
+ if (base_projectile_check_touch())
+ return;
+
+ if (other.takedamage == DAMAGE_AIM)
{
- minigrenade_explode ();
+ projectile_minigrenade_explode ();
return;
}

// bounce sound
- sound (this, CHAN_WEAPON, "weapons/bounce.wav", 1, ATTN_NORM);
- if (this.velocity == '0 0 0')
- this.avelocity = '0 0 0';
+ sound (self, CHAN_WEAPON, "weapons/bounce.wav", 1, ATTN_NORM);
+ if (self.velocity == '0 0 0')
+ self.avelocity = '0 0 0';
+ };
+
+ //--------------------------------------------------------------
+ entity(entity src, vector org, vector vel)
+ spawn_projectile_minigrenade =
+ {
+ local entity e = spawn ();
+ e.owner = src;
+ e.origin = org;
+ e.velocity = vel;
+ // damage
+ e.splash_damage = MININADE_SPLASH_DAMAGE;
+ // model, skin, & sounds
+ e.mdl_proj = src.mdl_proj;
+ e.skin_proj = src.skin_proj;
+ e.snd_hit = src.snd_hit;
+
+ projectile_minigrenade_init (e);
+ return e;
};

//--------------------------------------------------------------
- void() projectile_minigrenade =
+ void(entity e) projectile_minigrenade_init =
{
- this.classtype = CT_PROJECTILE_MINIGRENADE;
- this.classname = "MiniGrenade";
- this.movetype = MOVETYPE_BOUNCE;
- this.solid = SOLID_BBOX;
- this.explosive = TRUE;
- this.angles = vectoangles (this.velocity);
+ base_projectile_init (e);

- if (!this.avelocity)
- this.avelocity = '300 300 300';
+ e.classname = "MiniGrenade";
+ e.classtype = CT_PROJECTILE_MINIGRENADE;
+ e.movetype = MOVETYPE_BOUNCE;
+ e.solid = SOLID_BBOX;
+ e.think = projectile_minigrenade_think;
+ e.touch = projectile_minigrenade_touch;
+ e.aflag |= PROJECTILE_EXPLOSIVE;
+ e.angles = vectoangles (e.velocity);
+
+ if (!e.avelocity)
+ e.avelocity = '300 300 300';

// reuse grenade speed -- CEV
- // if (!this.proj_basespeed)
- // this.proj_basespeed = GRENADE_SPEED;
+ // if (!e.proj_basespeed)
+ // e.proj_basespeed = GRENADE_SPEED;

- if (!this.splash_damage)
- this.splash_damage = MININADE_SPLASH_DAMAGE;
+ if (!e.splash_damage)
+ e.splash_damage = MININADE_SPLASH_DAMAGE;

- setmodel (this, "progs/mervup.mdl");
- this.skin = 0;
+ setmodel (e, "progs/mervup.mdl");
+ e.skin = 0;

- setsize (this, MININADE_MINS, MININADE_MAXS);
- setorigin (this, this.origin);
+ setsize (e, MININADE_MINS, MININADE_MAXS);
+ setorigin (e, e.origin);

// set missile duration
- this.nextthink = time + 1 + (crandom() * 0.5);
+ e.nextthink = time + 1 + (crandom() * 0.5);
};
-};

-//------------------------------------------------------------------------------
-class projectile_multigrenade: base_doegrenade
-{
//--------------------------------------------------------------
- virtual void() do_destroy =
+ strip void() projectile_minigrenade =
{
- dprint ("projectile_multigrenade::do_destroy: exploding...\n");
- this.minigrenade_explode ();
+ projectile_minigrenade_init (self);
+ };
+// };
+
+//----------------------------------------------------------------------
+// class projectile_multigrenade: base_doegrenade
+// {
+ //--------------------------------------------------------------
+ void() projectile_multigrenade_destroy =
+ {
+ dprint ("projectile_multigrenade_destroy: exploding...\n");
+ projectile_minigrenade_explode ();
};

//--------------------------------------------------------------
// MiniGrenadeLaunch
//--------------------------------------------------------------
- nonvirtual void(float offset_angle) fire_minigrenade =
+ void(float offset_angle) projectile_multigrenade_fire =
{
- local entity missile;
local float temp_rand;
- local vector missile_angle, missile_velocity;
+ local vector mis_angle, mis_vel;

// figure out missile speed
- missile_angle = this.v_angle;
- missile_angle_y = missile_angle_y + offset_angle;
- makevectors (missile_angle);
+ mis_angle = self.v_angle;
+ mis_angle_y = mis_angle_y + offset_angle;
+ makevectors (mis_angle);

// TODO CEV some suspicious fixed values here
- missile_velocity = v_forward * 100 + v_up * 400;
+ mis_vel = v_forward * 100 + v_up * 400;
temp_rand = (crandom() * 60) - 30;
- missile_velocity += temp_rand * v_forward;
+ mis_vel += temp_rand * v_forward;
temp_rand = (crandom() * 40) - 20;
- missile_velocity += temp_rand * v_right;
+ mis_vel += temp_rand * v_right;
temp_rand = (crandom() * 60) - 30;
- missile_velocity += temp_rand * v_up;
+ mis_vel += temp_rand * v_up;

- missile = spawn (projectile_minigrenade,
- owner: this.owner,
- origin: this.origin,
- velocity: missile_velocity);
+ spawn_projectile_minigrenade (self, self.origin, mis_vel);
};

//--------------------------------------------------------------
// MultiGrenadeExplode
//--------------------------------------------------------------
- virtual void() do_think =
+ void() projectile_multigrenade_think =
{
- fire_minigrenade (0);
- fire_minigrenade (72);
- fire_minigrenade (144);
- fire_minigrenade (216);
- fire_minigrenade (288);
+ projectile_multigrenade_fire (0);
+ projectile_multigrenade_fire (72);
+ projectile_multigrenade_fire (144);
+ projectile_multigrenade_fire (216);
+ projectile_multigrenade_fire (288);

- remove (this);
+ remove (self);
};

//--------------------------------------------------------------
// MultiGrenadeTouch (modified)
//--------------------------------------------------------------
- virtual void(entity toucher) do_touch_explosive =
+ void() projectile_multigrenade_touch =
{
- if (toucher.takedamage == DAMAGE_AIM)
+ if (base_projectile_check_touch())
+ return;
+
+ if (other.takedamage == DAMAGE_AIM)
{
// this previously called GrenadeExplode if fired
// by the player or MiniGrenadeExplode if fired
// by anything else. I've changed that. -- CEV
- minigrenade_explode ();
+ projectile_minigrenade_explode ();
return;
}

// bounce sound
- sound (this, CHAN_WEAPON, "weapons/bounce.wav", 1, ATTN_NORM);
- if (this.velocity == '0 0 0')
- this.avelocity = '0 0 0';
+ sound (self, CHAN_WEAPON, "weapons/bounce.wav", 1, ATTN_NORM);
+ if (self.velocity == '0 0 0')
+ self.avelocity = '0 0 0';
+ };
+
+ //--------------------------------------------------------------
+ entity(entity src, vector org, vector vel)
+ spawn_projectile_multigrenade =
+ {
+ local entity e = spawn ();
+ e.owner = src;
+ e.origin = org;
+ e.velocity = vel;
+ // damage
+ e.splash_damage = MULTINADE_SPLASH_DAMAGE;
+ // model, skin, & sounds
+ e.mdl_proj = src.mdl_proj;
+ e.skin_proj = src.skin_proj;
+ e.snd_hit = src.snd_hit;
+
+ projectile_multigrenade_init (e);
+ return e;
};

//--------------------------------------------------------------
- void() projectile_multigrenade =
+ void(entity e) projectile_multigrenade_init =
{
- this.classtype = CT_PROJECTILE_MULTIGRENADE;
- this.classname = "MultiGrenade";
- this.movetype = MOVETYPE_BOUNCE;
- this.solid = SOLID_BBOX;
- this.explosive = TRUE;
- this.health = MULTINADE_HEALTH;
- this.takedamage = DAMAGE_YES;
- this.angles = vectoangles (this.velocity);
-
- if (!this.avelocity)
- this.avelocity = '300 300 300';
+ base_projectile_init (e);
+
+ e.classname = "MultiGrenade";
+ e.classtype = CT_PROJECTILE_MULTIGRENADE;
+ e.movetype = MOVETYPE_BOUNCE;
+ e.solid = SOLID_BBOX;
+ e.destroy = projectile_multigrenade_destroy;
+ e.think = projectile_multigrenade_think;
+ e.touch = projectile_multigrenade_touch;
+ e.aflag |= PROJECTILE_EXPLOSIVE;
+ e.health = MULTINADE_HEALTH;
+ e.takedamage = DAMAGE_YES;
+ e.angles = vectoangles (e.velocity);
+
+ if (!e.avelocity)
+ e.avelocity = '300 300 300';

// reuse grenade speed -- CEV
- if (!this.proj_basespeed)
- this.proj_basespeed = GRENADE_SPEED;
+ if (!e.proj_basespeed)
+ e.proj_basespeed = GRENADE_SPEED;
+
+ if (!e.splash_damage)
+ e.splash_damage = MULTINADE_SPLASH_DAMAGE;

- if (!this.splash_damage)
- this.splash_damage = MULTINADE_SPLASH_DAMAGE;
+ if (e.mdl_proj && e.mdl_proj != "")
+ setmodel (e, e.mdl_proj);
+ else
+ setmodel (e, "progs/mervup.mdl");

- setmodel (this, "progs/mervup.mdl");
- this.skin = 0;
+ if (e.skin_proj)
+ e.skin = e.skin_proj;
+ else
+ e.skin = 0;

- setsize (this, MULTINADE_MINS, MULTINADE_MAXS);
- setorigin (this, this.origin);
+ setsize (e, MULTINADE_MINS, MULTINADE_MAXS);
+ setorigin (e, e.origin);

// set missile duration
- this.nextthink = time + 1;
+ e.nextthink = time + 1;
+ };
+
+ //--------------------------------------------------------------
+ strip void() projectile_multigrenade =
+ {
+ projectile_multigrenade_init (self);
};
-};
+// };

//----------------------------------------------------------------------
// end doe qc -- dumptruck_ds

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

Diff qc/projectiles/rocket.qc

diff --git a/qc/projectiles/rocket.qc b/qc/projectiles/rocket.qc
index 596ffc8..9717bea 100644
--- a/qc/projectiles/rocket.qc
+++ b/qc/projectiles/rocket.qc
@@ -16,65 +16,106 @@ const float ROCKET_HEALTH = 20; // explodes when dead
const vector ROCKET_MINS = '-9 -4 -4'; // slightly more regular bounds
const vector ROCKET_MAXS = '9 4 4';

+//======================================================================
+// forward declarations
+//======================================================================
+
+void() projectile_rocket_destroy;
+entity(entity src, vector org, vector vel, optional float projspeed)
+ spawn_projectile_rocket;
+void(entity e) projectile_rocket_init;
+strip void() projectile_rocket;
+
//------------------------------------------------------------------------------
-class projectile_rocket: base_projectile_qcphys
-{
+
+//----------------------------------------------------------------------
+// class projectile_rocket: base_projectile_qcphys
+// {
//--------------------------------------------------------------
- virtual void() do_destroy =
+ void() projectile_rocket_destroy =
{
- dprint ("projectile_rocket::do_destroy: exploding...\n");
- this.do_touch_explosive (world);
+ dprint ("projectile_rocket_destroy: exploding...\n");
+ base_projectile_touch_explosive ();
};

//--------------------------------------------------------------
- // Touch is handled by base_projectile -- CEV
- //--------------------------------------------------------------
+ entity(entity src, vector org, vector vel, optional float projspeed)
+ spawn_projectile_rocket =
+ {
+ local entity e = spawn ();
+ e.owner = src;
+ e.origin = org;
+ e.velocity = vel;
+ // damage
+ e.direct_damage = ROCKET_DIRECT_DAMAGE;
+ e.splash_damage = ROCKET_SPLASH_DAMAGE;
+ // speed
+ e.proj_basespeed = projspeed;
+ e.proj_speed_mod = src.proj_speed_mod;
+ // model, skin, & sounds
+ e.mdl_proj = src.mdl_proj;
+ e.skin_proj = src.skin_proj;
+ e.snd_hit = src.snd_hit;
+
+ projectile_rocket_init (e);
+ return e;
+ };

//--------------------------------------------------------------
- void() projectile_rocket =
+ void(entity e) projectile_rocket_init =
{
- this.classtype = CT_PROJECTILE_ROCKET;
- this.classname = "missile";
- this.movetype = MOVETYPE_FLYMISSILE;
- this.solid = SOLID_BBOX;
- this.explosive = TRUE;
- this.health = ROCKET_HEALTH;
- this.takedamage = DAMAGE_YES;
- this.angles = vectoangles (this.velocity);
+ base_projectile_qcphys_init (e);

- if (!this.proj_basespeed)
- this.proj_basespeed = ROCKET_SPEED;
+ e.classname = "missile";
+ e.classtype = CT_PROJECTILE_ROCKET;
+ e.movetype = MOVETYPE_FLYMISSILE;
+ e.solid = SOLID_BBOX;
+ e.destroy = projectile_rocket_destroy;
+ e.aflag |= PROJECTILE_EXPLOSIVE;
+ e.health = ROCKET_HEALTH;
+ e.takedamage = DAMAGE_YES;
+ e.angles = vectoangles (e.velocity);

- if (!this.direct_damage)
- this.direct_damage = ROCKET_DIRECT_DAMAGE;
+ if (!e.proj_basespeed)
+ e.proj_basespeed = ROCKET_SPEED;

- if (!this.splash_damage)
- this.splash_damage = ROCKET_SPLASH_DAMAGE;
+ if (!e.direct_damage)
+ e.direct_damage = ROCKET_DIRECT_DAMAGE;
+
+ if (!e.splash_damage)
+ e.splash_damage = ROCKET_SPLASH_DAMAGE;

// dumptruck_ds custom_mdls
- if (this.mdl_proj != "")
- setmodel (this, this.mdl_proj);
+ if (e.mdl_proj != "")
+ setmodel (e, e.mdl_proj);
else
- setmodel (this, "progs/missile.mdl");
+ setmodel (e, "progs/missile.mdl");

// dumptruck_ds
- if (this.skin_proj)
- this.skin = this.skin_proj;
+ if (e.skin_proj)
+ e.skin = e.skin_proj;
else
- this.skin = 0;
+ e.skin = 0;

// homing & missile duration
- if (this.homing > 0)
+ if (e.homing > 0)
{
- setup_homing (proj_basespeed * proj_speed_mod);
+ base_projectile_setup_homing (e,
+ e.proj_basespeed * e.proj_speed_mod);
}
else
{
- this.think = sub_remove;
- this.nextthink = time + 5;
+ e.think = sub_remove;
+ e.nextthink = time + 5;
}

- setsize (this, ROCKET_MINS, ROCKET_MAXS);
- setorigin (this, this.origin);
+ setsize (e, ROCKET_MINS, ROCKET_MAXS);
+ setorigin (e, e.origin);
+ };
+
+ //--------------------------------------------------------------
+ strip void() projectile_rocket =
+ {
+ projectile_rocket_init (self);
};
-};
+// };

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

Diff qc/projectiles/spike.qc

diff --git a/qc/projectiles/spike.qc b/qc/projectiles/spike.qc
index 99e2e66..6de7664 100644
--- a/qc/projectiles/spike.qc
+++ b/qc/projectiles/spike.qc
@@ -15,70 +15,112 @@ const float SPIKE_SPEED = 1000; // id1 player spikes move at 1000ups
const vector SPIKE_MINS = '0 0 0'; // let's not change this -- CEV
const vector SPIKE_MAXS = '0 0 0'; //

+//======================================================================
+// forward declarations
+//======================================================================
+
+entity(entity src, vector org, vector vel, optional float direct,
+ optional float projspeed) spawn_projectile_spike;
+void(entity e) projectile_spike_init;
+strip void() projectile_spike;
+
//------------------------------------------------------------------------------
-class projectile_spike: base_projectile
-{
- //--------------------------------------------------------------
- // Touch is handled by base_projectile -- CEV
+
+//----------------------------------------------------------------------
+// class projectile_spike: base_projectile
+// {
//--------------------------------------------------------------
+ entity(entity src, vector org, vector vel, optional float direct,
+ optional float projspeed) spawn_projectile_spike =
+ {
+ local entity e = spawn();
+ e.owner = src;
+ e.enemy = src.enemy;
+ e.origin = org;
+ e.velocity = vel;
+ e.direct_damage = direct;
+ e.projexpl = src.projexpl;
+ // homing setup
+ e.homing = src.homing;
+ e.proj_basespeed = projspeed;
+ e.proj_speed_mod = src.proj_speed_mod;
+ // model, skin, & sounds
+ e.mdl_proj = src.mdl_proj;
+ e.skin_proj = src.skin_proj;
+ e.snd_hit = src.snd_hit;
+
+ projectile_spike_init (e);
+ return e;
+ };

//--------------------------------------------------------------
- void() projectile_spike =
+ void(entity e) projectile_spike_init =
{
- this.classtype = CT_PROJECTILE_SPIKE;
- this.classname = "spike";
- this.movetype = MOVETYPE_FLYMISSILE;
- this.solid = SOLID_BBOX;
- this.explosive = parse_projexpl (projexpl, 0);
- this.angles = vectoangles (this.velocity);
-
- if (!this.proj_basespeed)
- this.proj_basespeed = SPIKE_SPEED;
-
- if (!this.direct_damage)
- if (this.explosive)
- this.direct_damage = SPIKE_EXPLOD_DAMAGE;
+ base_projectile_init (e);
+
+ e.classname = "spike";
+ e.classtype = CT_PROJECTILE_SPIKE;
+ e.movetype = MOVETYPE_FLYMISSILE;
+ e.solid = SOLID_BBOX;
+ e.touch = base_projectile_touch;
+ if (base_projectile_parse_projexpl(e.projexpl, 0))
+ e.aflag |= PROJECTILE_EXPLOSIVE;
+ e.angles = vectoangles (e.velocity);
+
+ if (!e.proj_basespeed)
+ e.proj_basespeed = SPIKE_SPEED;
+
+ if (!e.direct_damage)
+ if (e.aflag & PROJECTILE_EXPLOSIVE)
+ e.direct_damage = SPIKE_EXPLOD_DAMAGE;
else
- this.direct_damage = SPIKE_NORMAL_DAMAGE;
+ e.direct_damage = SPIKE_NORMAL_DAMAGE;

- if (!this.splash_damage)
- if (this.explosive)
- this.splash_damage = SPIKE_SPLASH_DAMAGE;
+ if (!e.splash_damage)
+ if (e.aflag & PROJECTILE_EXPLOSIVE)
+ e.splash_damage = SPIKE_SPLASH_DAMAGE;
else
- this.splash_damage = 0;
+ e.splash_damage = 0;

// dumptruck_ds custom_mdls
- if (this.mdl_proj != "")
- setmodel (this, this.mdl_proj);
+ if (e.mdl_proj != "")
+ setmodel (e, e.mdl_proj);
else
- // this is kinda wonky -- CEV
- if (this.direct_damage == SPIKE_SUPER_DAMAGE)
+ // e is kinda wonky -- CEV
+ if (e.direct_damage == SPIKE_SUPER_DAMAGE)
// supernail
- setmodel (this, "progs/s_spike.mdl");
- else if (this.direct_damage == SPIKE_DUPER_DAMAGE)
+ setmodel (e, "progs/s_spike.mdl");
+ else if (e.direct_damage == SPIKE_DUPER_DAMAGE)
// superdupernail
- setmodel (this, "progs/lspike.mdl");
+ setmodel (e, "progs/lspike.mdl");
else
// regular nail
- setmodel (this, "progs/spike.mdl");
+ setmodel (e, "progs/spike.mdl");

// dumptruck_ds
- if (this.skin_proj)
- this.skin = this.skin_proj;
+ if (e.skin_proj)
+ e.skin = e.skin_proj;
else
- this.skin = 0;
+ e.skin = 0;

- if (this.homing > 0)
+ if (e.homing > 0)
{
- setup_homing (proj_basespeed * proj_speed_mod);
+ base_projectile_setup_homing (e,
+ e.proj_basespeed * e.proj_speed_mod);
}
else
{
- this.think = sub_remove;
- this.nextthink = time + 6;
+ e.think = sub_remove;
+ e.nextthink = time + 6;
}

- setsize (this, SPIKE_MINS, SPIKE_MAXS);
- setorigin (this, this.origin);
+ setsize (e, SPIKE_MINS, SPIKE_MAXS);
+ setorigin (e, e.origin);
+ };
+
+ //--------------------------------------------------------------
+ strip void() projectile_spike =
+ {
+ projectile_spike_init (self);
};
-};
+// };

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

Diff qc/projectiles/voreball.qc

diff --git a/qc/projectiles/voreball.qc b/qc/projectiles/voreball.qc
index ec4a84f..ccdffbc 100644
--- a/qc/projectiles/voreball.qc
+++ b/qc/projectiles/voreball.qc
@@ -14,85 +14,133 @@ const float VOREBALL_HEALTH = 50; // slightly more difficult to destroy
const vector VOREBALL_MINS = '-16 -16 -16';
const vector VOREBALL_MAXS = '16 16 16';

+//======================================================================
+// forward declarations
+//======================================================================
+
+void() projectile_voreball_destroy;
+void() projectile_voreball_touch;
+entity(entity src, vector org, vector vel, float basespeed)
+ spawn_projectile_voreball;
+void(entity e) projectile_voreball_init;
+strip void() projectile_voreball;
+
//------------------------------------------------------------------------------
-class projectile_voreball: base_projectile_qcphys
-{
+
+//----------------------------------------------------------------------
+// class projectile_voreball: base_projectile_qcphys
+// {
//--------------------------------------------------------------
- virtual void() do_destroy =
+ void() projectile_voreball_destroy =
{
- // dprint ("projectile_lavaball::do_destroy: exploding...\n");
- this.do_touch_explosive (this);
+ // dprint ("projectile_lavaball_destroy: exploding...\n");
+ self.touch ();
};

//--------------------------------------------------------------
// ShalMissileTouch
//--------------------------------------------------------------
- virtual void(entity toucher) do_touch_explosive =
+ void() projectile_voreball_touch =
{
- if (toucher.classtype == CT_MONSTER_ZOMBIE)
- t_damage2 (toucher, this, this, direct_damage);
+ if (base_projectile_check_touch())
+ return;
+
+ if (other.classtype == CT_MONSTER_ZOMBIE)
+ t_damage2 (other, self, self, self.direct_damage);

- if (this.takedamage)
- this.takedamage = DAMAGE_NO;
+ if (self.takedamage)
+ self.takedamage = DAMAGE_NO;

- t_radiusdamage2 (this, this.owner, splash_damage, world);
- sound (this, CHAN_WEAPON, "weapons/r_exp3.wav", 1, ATTN_NORM);
+ t_radiusdamage2 (self, self.owner, self.splash_damage, world);
+ sound (self, CHAN_WEAPON, "weapons/r_exp3.wav", 1, ATTN_NORM);

// BecomeExplosion
- base_explosion::write_explosion (this.origin);
- spawn (base_explosion, origin: this.origin);
- remove (this);
+ write_explosion (self.origin);
+ spawn_base_explosion (self.origin);
+ remove (self);
+ };
+
+ //--------------------------------------------------------------
+ entity(entity src, vector org, vector vel, float basespeed)
+ spawn_projectile_voreball =
+ {
+ local entity e = spawn ();
+ e.owner = src;
+ e.enemy = src.enemy;
+ e.origin = org;
+ e.velocity = vel;
+ e.avelocity = src.cust_avelocity;
+ // speed
+ e.proj_basespeed = basespeed;
+ e.proj_speed_mod = src.proj_speed_mod;
+ // model, skin, & sounds
+ e.mdl_proj = src.mdl_proj;
+ e.skin_proj = src.skin_proj;
+ e.snd_hit = src.snd_hit;
+
+ projectile_voreball_init (e);
+ return e;
};

//--------------------------------------------------------------
- void() projectile_voreball =
+ void(entity e) projectile_voreball_init =
{
- this.classtype = CT_PROJECTILE_VOREBALL;
- this.classname = "voreball";
- this.movetype = MOVETYPE_FLYMISSILE;
- this.solid = SOLID_BBOX;
- this.explosive = TRUE;
- this.health = VOREBALL_HEALTH;
- this.takedamage = DAMAGE_YES;
- this.angles = vectoangles (this.velocity);
+ base_projectile_qcphys_init (e);
+
+ e.classname = "voreball";
+ e.classtype = CT_PROJECTILE_VOREBALL;
+ e.movetype = MOVETYPE_FLYMISSILE;
+ e.solid = SOLID_BBOX;
+ e.touch = projectile_voreball_touch;
+ e.aflag |= PROJECTILE_EXPLOSIVE;
+ e.health = VOREBALL_HEALTH;
+ e.takedamage = DAMAGE_YES;
+ e.angles = vectoangles (e.velocity);

// custom spin on projectile -- dumptruck_ds
- if (!this.avelocity)
- this.avelocity = '300 300 300';
+ if (!e.avelocity)
+ e.avelocity = '300 300 300';

- if (!this.proj_basespeed)
- this.proj_basespeed = VOREBALL_SPEED;
+ if (!e.proj_basespeed)
+ e.proj_basespeed = VOREBALL_SPEED;

- if (!this.direct_damage)
- this.direct_damage = VOREBALL_DIRECT_DAMAGE;
+ if (!e.direct_damage)
+ e.direct_damage = VOREBALL_DIRECT_DAMAGE;

- if (!this.splash_damage)
- this.splash_damage = VOREBALL_SPLASH_DAMAGE;
+ if (!e.splash_damage)
+ e.splash_damage = VOREBALL_SPLASH_DAMAGE;

// dumptruck_ds custom_mdls
- if (this.mdl_proj != "")
- setmodel (this, this.mdl_proj);
+ if (e.mdl_proj != "")
+ setmodel (e, e.mdl_proj);
else
- setmodel (this, "progs/v_spike.mdl");
+ setmodel (e, "progs/v_spike.mdl");

// dumptruck_ds
- if (this.skin_proj)
- this.skin = this.skin_proj;
+ if (e.skin_proj)
+ e.skin = e.skin_proj;
else
- this.skin = 0;
+ e.skin = 0;

- if (this.homing > 0)
+ if (e.homing > 0)
{
- setup_homing (proj_basespeed * proj_speed_mod);
+ base_projectile_setup_homing (e,
+ e.proj_basespeed * e.proj_speed_mod);
}
else
{
// SetSpeed
- this.think = sub_remove;
- this.nextthink = time + 5;
+ e.think = sub_remove;
+ e.nextthink = time + 5;
}

- setsize (this, VOREBALL_MINS, VOREBALL_MAXS);
- setorigin (this, this.origin);
+ setsize (e, VOREBALL_MINS, VOREBALL_MAXS);
+ setorigin (e, e.origin);
+ };
+
+ //--------------------------------------------------------------
+ strip void() projectile_voreball =
+ {
+ projectile_voreball_init (self);
};
-};
+// };

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

Diff qc/projectiles/wizardspell.qc

diff --git a/qc/projectiles/wizardspell.qc b/qc/projectiles/wizardspell.qc
index 3de6b5b..77e9998 100644
--- a/qc/projectiles/wizardspell.qc
+++ b/qc/projectiles/wizardspell.qc
@@ -3,6 +3,13 @@
//==============================================================================

//======================================================================
+// This is a weird one. The Wizard spawns an entity with a think
+// function that then spawns the actual missile. So we're dealing with
+// two temporary entities: the projectile (wizardmissile), and the thing
+// that creates it (wizardspell). -- CEV
+//======================================================================
+
+//======================================================================
// constants
//======================================================================
const float WIZMIS_DIRECT_DAMAGE = 9; // direct damage; 9 is id1
@@ -15,33 +22,46 @@ const vector WIZMIS_MINS = '0 0 0'; // let's not change this -- CEV
const vector WIZMIS_MAXS = '0 0 0'; //

//======================================================================
-// This is a weird one. The Wizard spawns an entity with a think
-// function that then spawns the actual missile. So we're dealing with
-// two temporary entities: the projectile (wizardmissile), and the thing
-// that creates it (wizardspell). -- CEV
+// forward declarations
//======================================================================

+// projectile_wizardmissile
+void() base_wizardmissile_touch;
+entity(entity src, vector org, vector vel, optional float direct,
+ optional float splash) spawn_projectile_wizardmissile;
+void(entity e) projectile_wizardmissile_init;
+strip void() projectile_wizardmissile;
+
+// projectile_wizardspell
+void() projectile_wizardspell_think;
+entity(entity src, vector org, vector mdir, float nt)
+ spawn_projectile_wizardspell;
+void(entity e) projectile_wizardspell_init;
+strip void() projectile_wizardspell;
+
//------------------------------------------------------------------------------
-class projectile_wizardmissile: base_projectile
-{
+
+//----------------------------------------------------------------------
+// class projectile_wizardmissile: base_projectile
+// {
//--------------------------------------------------------------
// adapted from spike_touch -- CEV
//--------------------------------------------------------------
- virtual void(entity toucher) do_touch =
+ void() base_wizardmissile_touch =
{
- if (toucher.takedamage)
+ if (other.takedamage)
{
- spawn_touchblood (direct_damage);
- t_damage2 (toucher, this, this.owner, direct_damage);
+ spawn_touchblood (self.direct_damage);
+ t_damage2 (other, self, self.owner, self.direct_damage);
}
else
{
WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
- if (this.owner.snd_hit != __NULL__ &&
- this.owner.snd_hit != "")
+ if (self.owner.snd_hit != __NULL__ &&
+ self.owner.snd_hit != "")
{
// dumptruck_ds
- sound (this, CHAN_WEAPON, this.owner.snd_hit,
+ sound (self, CHAN_WEAPON, self.owner.snd_hit,
1, ATTN_STATIC);
WriteByte (MSG_BROADCAST, TE_WIZSPIKE);
}
@@ -49,70 +69,105 @@ class projectile_wizardmissile: base_projectile
{
WriteByte (MSG_BROADCAST, TE_WIZSPIKE);
}
- WriteCoord (MSG_BROADCAST, this.origin_x);
- WriteCoord (MSG_BROADCAST, this.origin_y);
- WriteCoord (MSG_BROADCAST, this.origin_z);
+ WriteCoord (MSG_BROADCAST, self.origin_x);
+ WriteCoord (MSG_BROADCAST, self.origin_y);
+ WriteCoord (MSG_BROADCAST, self.origin_z);
}

- remove (this);
+ remove (self);
+ };
+
+ //--------------------------------------------------------------
+ entity(entity src, vector org, vector vel, optional float direct,
+ optional float splash) spawn_projectile_wizardmissile =
+ {
+ local entity e = spawn ();
+ e.owner = src;
+ e.enemy = src.enemy;
+ e.origin = org;
+ e.velocity = vel;
+ e.avelocity = src.cust_avelocity;
+ e.proj_basespeed = src.proj_basespeed;
+ e.proj_speed_mod = src.proj_speed_mod;
+ e.projexpl = src.projexpl;
+ // damage
+ e.direct_damage = direct;
+ e.splash_damage = splash;
+ // model, skin, & sounds
+ e.mdl_proj = src.mdl_proj;
+ e.skin_proj = src.skin_proj;
+ e.snd_hit = src.snd_hit;
+
+ projectile_wizardmissile_init (e);
+ return e;
};

//--------------------------------------------------------------
- void() projectile_wizardmissile =
+ void(entity e) projectile_wizardmissile_init =
{
- this.classtype = CT_PROJECTILE_WIZARDMISSILE;
- this.classname = "wizspike";
- this.movetype = MOVETYPE_FLYMISSILE;
- this.solid = SOLID_BBOX;
- this.explosive = parse_projexpl (this.projexpl, 0);
- this.angles = vectoangles (this.velocity);
-
- if (!this.proj_basespeed)
- this.proj_basespeed = WIZMIS_SPEED;
-
- if (!this.direct_damage)
- if (this.explosive)
- this.direct_damage = WIZMIS_EXPLOD_DAMAGE;
+ base_projectile_init (e);
+
+ e.classname = "wizspike";
+ e.classtype = CT_PROJECTILE_WIZARDMISSILE;
+ e.movetype = MOVETYPE_FLYMISSILE;
+ e.solid = SOLID_BBOX;
+ if (base_projectile_parse_projexpl(e.projexpl, 0))
+ e.aflag |= PROJECTILE_EXPLOSIVE;
+ e.angles = vectoangles (e.velocity);
+
+ if (!e.proj_basespeed)
+ e.proj_basespeed = WIZMIS_SPEED;
+
+ if (!e.direct_damage)
+ if (e.aflag & PROJECTILE_EXPLOSIVE)
+ e.direct_damage = WIZMIS_EXPLOD_DAMAGE;
else
- this.direct_damage = WIZMIS_DIRECT_DAMAGE;
+ e.direct_damage = WIZMIS_DIRECT_DAMAGE;

- if (!this.splash_damage)
- if (this.explosive)
- this.splash_damage = WIZMIS_EXPLOD_DAMAGE;
+ if (!e.splash_damage)
+ if (e.aflag & PROJECTILE_EXPLOSIVE)
+ e.splash_damage = WIZMIS_EXPLOD_DAMAGE;
else
- this.splash_damage = WIZMIS_SPLASH_DAMAGE;
+ e.splash_damage = WIZMIS_SPLASH_DAMAGE;

// dumptruck_ds custom_mdls
- if (this.mdl_proj != "")
- setmodel (this, this.mdl_proj);
+ if (e.mdl_proj != "")
+ setmodel (e, e.mdl_proj);
else
- setmodel (this, "progs/w_spike.mdl");
+ setmodel (e, "progs/w_spike.mdl");

// dumptruck_ds
- if (this.skin_proj)
- this.skin = this.skin_proj;
+ if (e.skin_proj)
+ e.skin = e.skin_proj;
else
- this.skin = 0;
+ e.skin = 0;

- if (this.homing > 0 || this.owner.homing > 0)
+ if (e.homing > 0 || e.owner.homing > 0)
{
- setup_homing (proj_basespeed * proj_speed_mod);
+ base_projectile_setup_homing (e,
+ self.proj_basespeed * self.proj_speed_mod);
}
else
{
// SetSpeed
- this.think = sub_remove;
- this.nextthink = time + 5;
+ e.think = sub_remove;
+ e.nextthink = time + 5;
}

- setsize (this, WIZMIS_MINS, WIZMIS_MAXS);
- setorigin (this, this.origin);
+ setsize (e, WIZMIS_MINS, WIZMIS_MAXS);
+ setorigin (e, e.origin);
};
-};

-//------------------------------------------------------------------------------
-class projectile_wizardspell: base_tempentity
-{
+ //--------------------------------------------------------------
+ strip void() projectile_wizardmissile =
+ {
+ projectile_wizardmissile_init (self);
+ };
+// };
+
+//----------------------------------------------------------------------
+// class projectile_wizardspell: base_tempentity
+// {
//==============================================================
// If the player moves behind cover before the missile is launched,
// launch it at the last visible spot with no velocity leading,
@@ -122,47 +177,73 @@ class projectile_wizardspell: base_tempentity
//--------------------------------------------------------------
// Wizard missile think function
//--------------------------------------------------------------
- virtual void() think =
+ void() projectile_wizardspell_think =
{
// make sure owner still exists -- CEV
- if (!this.owner)
+ if (!self.owner)
{
- remove (this);
+ remove (self);
return;
}

// make sure owner is still alive
- if (this.owner.health > 0)
+ if (self.owner.health > 0)
{
- owner.effects = owner.effects | EF_MUZZLEFLASH;
+ self.owner.effects |= EF_MUZZLEFLASH;

- makevectors (this.enemy.angles);
- local vector dir = normalize ((this.enemy.origin - 13 *
- this.movedir) - this.origin);
+ makevectors (self.enemy.angles);
+ local vector dir = normalize ((self.enemy.origin - 13 *
+ self.movedir) - self.origin);

// SetSpeed (newmis, vec, projspeed);
- dir *= min (this.proj_basespeed * (this.proj_speed_mod ?
- this.proj_speed_mod : 1), frame_maxvelocity);
-
- spawn (projectile_wizardmissile,
- owner: this.owner,
- enemy: this.enemy,
- origin: this.origin,
- velocity: dir,
- proj_basespeed: this.proj_basespeed,
- proj_speed_mod: this.proj_speed_mod,
- projexpl: this.projexpl);
+ dir *= min (self.proj_basespeed * (self.proj_speed_mod ?
+ self.proj_speed_mod : 1), world_maxvelocity);
+
+ spawn_projectile_wizardmissile (self, self.origin, dir);
}

- remove (this);
+ remove (self);
+ };
+
+ //--------------------------------------------------------------
+ entity(entity src, vector org, vector mdir, float nt)
+ spawn_projectile_wizardspell =
+ {
+ local entity e = spawn ();
+ e.owner = src;
+ e.enemy = src.enemy;
+ e.origin = org;
+ e.movedir = mdir;
+ e.proj_basespeed = src.proj_basespeed;
+ e.proj_speed_mod = src.proj_speed_mod;
+ e.projexpl = src.projexpl;
+
+ projectile_wizardspell_init (e);
+
+ e.nextthink = nt;
+ return e;
+ };
+
+ //--------------------------------------------------------------
+ void(entity e) projectile_wizardspell_init =
+ {
+ base_tempentity_init (e);
+
+ e.classname = "projectile_wizardspell";
+ e.classtype = CT_TEMP_WIZARDSPELL;
+ e.think = projectile_wizardspell_think;
+
+ if (!e.proj_basespeed)
+ e.proj_basespeed = WIZMIS_SPEED;
+
+ setsize (e, '0 0 0', '0 0 0');
+ setorigin (e, e.origin);
};

//--------------------------------------------------------------
- void() projectile_wizardspell =
+ strip void() projectile_wizardspell =
{
- this.classtype = CT_TEMP_WIZARDSPELL;
+ projectile_wizardspell_init (self);

- setsize (this, '0 0 0', '0 0 0');
- setorigin (this, this.origin);
};
-};
+// };

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

Diff qc/projectiles/zombiechunk.qc

diff --git a/qc/projectiles/zombiechunk.qc b/qc/projectiles/zombiechunk.qc
index 8af0583..b368b74 100644
--- a/qc/projectiles/zombiechunk.qc
+++ b/qc/projectiles/zombiechunk.qc
@@ -12,66 +12,109 @@ const float ZCHUNK_SPEED = 600; // id1 default 600
const vector ZCHUNK_MINS = '0 0 0'; // let's not change this -- CEV
const vector ZCHUNK_MAXS = '0 0 0'; //

+//======================================================================
+// forward declarations
+//======================================================================
+
+void() projectile_zombiechunk_touch;
+entity(entity src, vector org, vector vel) spawn_projectile_zombiechunk;
+void(entity e) projectile_zombiechunk_init;
+strip void() projectile_zombiechunk;
+
//------------------------------------------------------------------------------
-class projectile_zombiechunk: base_projectile
-{
+
+//----------------------------------------------------------------------
+// class projectile_zombiechunk: base_projectile
+// {
//--------------------------------------------------------------
// ZombieGrenadeTouch
//--------------------------------------------------------------
- virtual void(entity toucher) do_touch =
+ void() projectile_zombiechunk_touch =
{
- if (toucher.takedamage)
+ if (base_projectile_check_touch())
+ return;
+
+ if (other.takedamage)
{
// hardcoded 10 damage -- CEV
- t_damage2 (toucher, this, this.owner, direct_damage);
- sound (this, CHAN_WEAPON, "zombie/z_hit.wav",
+ t_damage2 (other, self, self.owner, self.direct_damage);
+ sound (self, CHAN_WEAPON, "zombie/z_hit.wav",
1, ATTN_NORM);
- remove (this);
+ remove (self);
return;
}

// bounce sound
- sound (this, CHAN_WEAPON, "zombie/z_miss.wav", 1, ATTN_NORM);
- this.velocity = '0 0 0';
- this.avelocity = '0 0 0';
- this.touch = sub_remove;
+ sound (self, CHAN_WEAPON, "zombie/z_miss.wav", 1, ATTN_NORM);
+ self.velocity = '0 0 0';
+ self.avelocity = '0 0 0';
+ self.touch = sub_remove;
};

//--------------------------------------------------------------
- void() projectile_zombiechunk =
+ entity(entity src, vector org, vector vel)
+ spawn_projectile_zombiechunk =
{
- this.classtype = CT_PROJECTILE_ZOMBIECHUNK;
- this.classname = "zgibs";
- this.movetype = MOVETYPE_BOUNCE;
- this.solid = SOLID_BBOX;
- this.angles = vectoangles (this.velocity);
+ local entity e = spawn ();
+ e.owner = src;
+ e.origin = org;
+ e.velocity = vel;
+ e.avelocity = src.cust_avelocity;
+ // damage
+ e.direct_damage = ZCHUNK_DIRECT_DAMAGE;
+ // model, skin, & sounds
+ e.mdl_proj = src.mdl_proj;
+ e.skin_proj = src.skin_proj;
+ e.snd_hit = src.snd_hit;

- if (!this.avelocity)
- this.avelocity = '3000 1000 2000';
+ projectile_zombiechunk_init (e);
+ return e;
+ };

- if (!this.proj_basespeed)
- this.proj_basespeed = ZCHUNK_SPEED;
+ //--------------------------------------------------------------
+ void(entity e) projectile_zombiechunk_init =
+ {
+ base_projectile_init (e);
+
+ e.classname = "zgibs";
+ e.classtype = CT_PROJECTILE_ZOMBIECHUNK;
+ e.movetype = MOVETYPE_BOUNCE;
+ e.solid = SOLID_BBOX;
+ e.touch = projectile_zombiechunk_touch;
+ e.angles = vectoangles (e.velocity);
+
+ if (!e.avelocity)
+ e.avelocity = '3000 1000 2000';
+
+ if (!e.proj_basespeed)
+ e.proj_basespeed = ZCHUNK_SPEED;

- if (!this.direct_damage)
- this.direct_damage = ZCHUNK_DIRECT_DAMAGE;
+ if (!e.direct_damage)
+ e.direct_damage = ZCHUNK_DIRECT_DAMAGE;

// dumptruck_ds custom_mdls
- if (this.mdl_proj != "")
- setmodel (this, this.mdl_proj);
+ if (e.mdl_proj != "")
+ setmodel (e, e.mdl_proj);
else
- setmodel (this, "progs/zom_gib.mdl");
+ setmodel (e, "progs/zom_gib.mdl");

// dumptruck_ds
- if (this.skin_proj)
- this.skin = this.skin_proj;
+ if (e.skin_proj)
+ e.skin = e.skin_proj;
else
- this.skin = 0;
+ e.skin = 0;

- setsize (this, ZCHUNK_MINS, ZCHUNK_MAXS);
- setorigin (this, this.origin);
+ setsize (e, ZCHUNK_MINS, ZCHUNK_MAXS);
+ setorigin (e, e.origin);

// set missile duration
- this.nextthink = time + 2.5;
- this.think = sub_remove;
+ e.nextthink = time + 2.5;
+ e.think = sub_remove;
+ };
+
+ //--------------------------------------------------------------
+ strip void() projectile_zombiechunk =
+ {
+ projectile_zombiechunk_init (self);
};
-};
+// };

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

Diff qc/subs.qc

diff --git a/qc/subs.qc b/qc/subs.qc
index b579de7..73a8f09 100644
--- a/qc/subs.qc
+++ b/qc/subs.qc
@@ -2,6 +2,17 @@
// subs.qc
//==============================================================================

+//======================================================================
+// forward declarations
+//======================================================================
+
+void() sub_null;
+void(entity attacker, float damage) sub_nullpain;
+void() sub_remove;
+void(entity ent, void() thinkst) sub_think;
+
+//------------------------------------------------------------------------------
+
//----------------------------------------------------------------------
void() sub_null =
{
@@ -20,404 +31,15 @@ void() sub_remove =
remove (self);
};

-//==============================================================================
-//==============================================================================
-//==============================================================================
-//==============================================================================
-
-//----------------------------------------------------------------------
-void() DelayThink =
-{
- dprint (sprintf("DelayThink: self classname %s\n", self.classname));
- activator = self.enemy;
- SUB_UseTargets ();
- dprint (sprintf("DelayThink: removing classname %s\n", self.classname));
- remove (self);
-};
-
-void(entity ent, string matchstring) SUB_UseAsSelf =
-{
- local entity stemp, otemp;
-
- stemp = self;
- otemp = other;
- self = ent;
- other = stemp;
- if (self.use != sub_null)
- {
- if (self.use)
- {
- lastnameused = matchstring;
- self.use ();
- }
- }
- self = stemp;
- other = otemp;
-};
-
-/* ### (added targets, killtargets, and targetnames)
-------------------------------------------------------------------------
-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,
-or killtarget2, so some events can remove other triggers.
-
-Search for (string)targetname, targetname2, targetname3, and targetname 4
-in all entities that match (string)self.target, self.target2, self.target3,
-or self.target4 and use their .use function.
-------------------------------------------------------------------------
-*/
-void(string matchstring, .string matchfield) SUB_UseSpecificTarget =
-{
- local entity t, act;
-
- act = activator;
- t = find (world, ::matchfield, matchstring);
- while (t != world)
- {
- /*
- stemp = self;
- otemp = other;
- self = t;
- other = stemp;
- if (self.use != sub_null)
- {
- if (self.use)
- {
- lastnameused = matchstring;
- self.use ();
- }
- }
- self = stemp;
- other = otemp;
- */
- SUB_UseAsSelf (t, matchstring);
- activator = act;
- t = find (t, ::matchfield, matchstring);
- }
-};
-
-//----------------------------------------------------------------------
-void() SUB_UseTargets =
-{
- // local entity t, stemp, otemp, act;
- local entity t;
-
- if (self.estate != STATE_ACTIVE)
- return;
-
- // 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.killtarget2 = self.killtarget2;
- t.target = self.target;
- t.target2 = self.target2;
- t.target3 = self.target3;
- t.target4 = self.target4;
- return;
- }
-
- // print the message
- if (self.message != "" && !(self.flags & FL_NOCENTERPRINT))
- {
- if (self.spawnflags & TRIGGER_CENTERPRINTALL)
- {
- t = find (world, classname, "player");
- while (t)
- {
- centerprint (t, self.message);
- if (!self.noise)
- sound (t, CHAN_VOICE, "misc/talk.wav",
- 1, ATTN_NORM);
- t = find (t, classname, "player");
- }
- }
-
- else if (activator.classname == "player")
- {
- centerprint (activator, self.message);
- if (!self.noise)
- sound (activator, CHAN_VOICE, "misc/talk.wav",
- 1, ATTN_NORM);
- }
- }
-
- // kill the killtarget entities
- if (self.killtarget != "")
- {
- t = find (world, ::targetname, self.killtarget);
- while (t != world)
- {
- if (t.switchshadstyle)
- lightstyle (t.switchshadstyle, "m");
- remove (t);
- t = find (t, ::targetname, self.killtarget);
- }
-
- t = find (world, ::targetname2, self.killtarget);
- while (t != world)
- {
- if (t.switchshadstyle)
- lightstyle (t.switchshadstyle, "m");
- remove (t);
- t = find (t, ::targetname2, self.killtarget);
- }
-
- t = find (world, ::targetname3, self.killtarget);
- while (t != world)
- {
- if (t.switchshadstyle)
- lightstyle (t.switchshadstyle, "m");
- remove (t);
- t = find (t, ::targetname3, self.killtarget);
- }
-
- t = find (world, ::targetname4, self.killtarget);
- while (t != world)
- {
- if (t.switchshadstyle)
- lightstyle (t.switchshadstyle, "m");
- remove (t);
- t = find (t, ::targetname4, self.killtarget);
- }
- }
-
- // kill the killtaget2 entities
- if (self.killtarget2 != "")
- {
- t = find (world, ::targetname, self.killtarget2);
- while (t != world)
- {
- if (t.switchshadstyle)
- lightstyle (t.switchshadstyle, "m");
- remove (t);
- t = find (t, ::targetname, self.killtarget2);
- }
-
- t = find (world, ::targetname2, self.killtarget2);
- while (t != world)
- {
- if (t.switchshadstyle)
- lightstyle (t.switchshadstyle, "m");
- remove (t);
- t = find (t, ::targetname2, self.killtarget2);
- }
-
- t = find (world, ::targetname3, self.killtarget2);
- while (t != world)
- {
- if (t.switchshadstyle)
- lightstyle (t.switchshadstyle, "m");
- remove (t);
- t = find (t, ::targetname3, self.killtarget2);
- }
-
- t = find (world, ::targetname4, self.killtarget2);
- while (t != world)
- {
- if (t.switchshadstyle)
- lightstyle (t.switchshadstyle, "m");
- remove (t);
- t = find (t, ::targetname4, self.killtarget2);
- }
- }
-
- // fire targets; target 1
- if (self.target && self.target != "")
- {
- SUB_UseSpecificTarget (self.target, targetname);
- SUB_UseSpecificTarget (self.target, targetname2);
- SUB_UseSpecificTarget (self.target, targetname3);
- SUB_UseSpecificTarget (self.target, targetname4);
- }
-
- // target 2
- if (self.target2 && self.target2 != "")
- {
- SUB_UseSpecificTarget (self.target2, targetname);
- SUB_UseSpecificTarget (self.target2, targetname2);
- SUB_UseSpecificTarget (self.target2, targetname3);
- SUB_UseSpecificTarget (self.target2, targetname4);
- }
-
- // target 3
- if (self.target3 && self.target3 != "")
- {
- SUB_UseSpecificTarget (self.target3, targetname);
- SUB_UseSpecificTarget (self.target3, targetname2);
- SUB_UseSpecificTarget (self.target3, targetname3);
- SUB_UseSpecificTarget (self.target3, targetname4);
- }
-
- // target 4
- if (self.target4 && self.target4 != "")
- {
- SUB_UseSpecificTarget (self.target4, targetname);
- SUB_UseSpecificTarget (self.target4, targetname2);
- SUB_UseSpecificTarget (self.target4, targetname3);
- SUB_UseSpecificTarget (self.target4, targetname4);
- }
-};
-
-/*
-------------------------------------------------------------------------
-SUB_UseAndForgetTargets
-
-This calls SUB_UseTargets, then clears all of self's fields that cause
-SUB_UseTargets to do things. The intention is that if SUB_UseTargets
-gets called again in the future, it won't do anything. Call this
-function if you want an entity to fire its targets just this once, and
-never again.
-
-Note that this function relies on the fact that SUB_UseTargets has
-already been modified to work around the engine bug involving tests of
-the form 'if (string)', i.e. that the tests in SUB_UseTargets are now of
-the form 'if (string != "")'. -- iw
-------------------------------------------------------------------------
-*/
-void() SUB_UseAndForgetTargets =
-{
- SUB_UseTargets ();
-
- self.delay = 0;
- self.killtarget = "";
- self.killtarget2 = "";
- self.message = "";
- self.target = "";
- self.target2 = "";
- self.target3 = "";
- self.target4 = "";
-};
-
-//----------------------------------------------------------------------
-// SUB_FieldIsTargeted
-//
-// Return TRUE if the "fld" field of this entity is non-empty and matches
-// the target (or target2/3/4 or pain_target) field of any other entity,
-// otherwise return FALSE. -- iw
-//----------------------------------------------------------------------
-float(.string fld) SUB_FieldIsTargeted =
-{
- if (self.fld == "")
- return FALSE;
-
- // the following function calls are staggered to avoid the silly
- // "return value conflict" problem with traditional compilers -- iw
-
- if (find (world, target, self.fld) != world)
- return TRUE;
-
- if (find (world, target2, self.fld) != world)
- return TRUE;
-
- if (find (world, target3, self.fld) != world)
- return TRUE;
-
- if (find (world, target4, self.fld) != world)
- return TRUE;
-
- if (find (world, pain_target, self.fld) != world)
- return TRUE;
-
- return FALSE;
-};
-
-//----------------------------------------------------------------------
-// SUB_IsTargeted
-//
-// Return TRUE if the targetname (or targetname2/3/4) field of this entity
-// is non-empty and matches the target (or target2/3/4 or pain_target)
-// field of any other entity, otherwise return FALSE. -- iw
-//----------------------------------------------------------------------
-float() SUB_IsTargeted =
-{
- // the following function calls are staggered to avoid the silly
- // "return value conflict" problem with traditional compilers -- iw
- if (SUB_FieldIsTargeted (targetname))
- return TRUE;
-
- if (SUB_FieldIsTargeted (targetname2))
- return TRUE;
-
- if (SUB_FieldIsTargeted (targetname3))
- return TRUE;
-
- if (SUB_FieldIsTargeted (targetname4))
- return TRUE;
-
- return FALSE;
-};
-
-//----------------------------------------------------------------------
-// SUB_UsePain -- pain_target //dumptruck_ds
-//----------------------------------------------------------------------
-void() SUB_UsePain =
-{
- if (self.pain_target != "")
- {
- SUB_UseSpecificTarget (self.pain_target, targetname);
- SUB_UseSpecificTarget (self.pain_target, targetname2);
- SUB_UseSpecificTarget (self.pain_target, targetname3);
- SUB_UseSpecificTarget (self.pain_target, targetname4);
- }
- // dumptruck_ds via Discord - thanks Spike, Snaut and QueenJazz
- self.pain_target = "";
-};
-
-//----------------------------------------------------------------------
-// SUB_AttackFinished
-// in nightmare mode, all attack_finished times become 0
-// some monsters refire twice automatically
-//----------------------------------------------------------------------
-void(float normal) SUB_AttackFinished =
-{
- // refire count for nightmare
- self.cnt = 0;
- if (skill != 3)
- self.attack_finished = time + normal;
-};
-
-// TODO CEV
-//----------------------------------------------------------------------
-/*
-void (void() thinkst) SUB_CheckRefire =
-{
- if (skill != 3)
- return;
- if (self.cnt == 1)
- return;
- if (!visible (self.enemy))
- return;
-
- self.cnt = 1;
- self.think = thinkst;
-};
-*/
-
//--------------------------------------------------------------------//
-// SUB_Think -- Drake -- This makes an entity do a think function right now.
+// SUB_Think -- Drake -- This makes an entity do a think function right now.
//--------------------------------------------------------------------//
-void(entity ent, void() thinkst) SUB_Think =
+void(entity ent, void() thinkst) sub_think =
{
- local entity swap;
+ local entity stemp;

- swap = self;
+ stemp = self;
self = ent;
thinkst ();
- self = swap;
+ self = stemp;
};

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

Diff qc/sv_entry.qc

diff --git a/qc/sv_entry.qc b/qc/sv_entry.qc
new file mode 100644
index 0000000..17edf68
--- /dev/null
+++ b/qc/sv_entry.qc
@@ -0,0 +1,903 @@
+//==============================================================================
+// server-side entrypoints; inspired by Nuclide's server/entry.qc -- CEV
+//==============================================================================
+
+//======================================================================
+// globals
+//======================================================================
+
+#ifdef SSQC
+float gameover; // set when a rule exits
+float intermission;
+float intermission_exittime;
+entity used_exit;
+string nextmap;
+
+float skill; // latched, reset on StartFrame
+float framecount;
+
+nosave float clean_up_client_stuff;
+nosave float gamestarted;
+#endif
+
+//======================================================================
+// forward declarations
+//======================================================================
+
+#ifdef SSQC
+// helper functions
+void() NextLevel;
+void() CheckRules;
+void(string message) ShowIntermissionMessage;
+void() StartMessageIntermission;
+void() Episode1End;
+void() Episode2End;
+void() Episode3End;
+void() Episode4End;
+float() RunId1Intermissions;
+entity() FindIntermission;
+void() GotoNextMap;
+float(float start) ShowIntermissionTextEntity;
+void() ExitIntermission;
+void() IntermissionThink;
+void() RestartLoopSounds_think;
+void() RestartLoopSounds;
+
+// proper entrypoints
+void() main;
+void() ClientConnect;
+void() ClientDisconnect;
+void() ClientKill;
+void() SetNewParms;
+void() SetChangeParms;
+void() PutClientInServer;
+void() PlayerPreThink;
+void() SV_RunClientCommand;
+void() PlayerPostThink;
+void() StartFrame;
+// void() EndFrame;
+// void(void() spawnfunc) CheckSpawn;
+#endif
+
+//------------------------------------------------------------------------------
+
+//======================================================================
+// Helper functions - map & game rules
+//======================================================================
+
+#ifdef SSQC
+//----------------------------------------------------------------------
+// NextLevel -- go to the next level for deathmatch
+// only called if a time or frag limit has expired
+//----------------------------------------------------------------------
+void() NextLevel =
+{
+ local entity t_level;
+
+ if (mapname == "start")
+ {
+ if (!cvar ("registered"))
+ {
+ mapname = "e1m1";
+ }
+ else if (!(serverflags & 1))
+ {
+ mapname = "e1m1";
+ serverflags = serverflags | 1;
+ }
+ else if (!(serverflags & 2))
+ {
+ mapname = "e2m1";
+ serverflags = serverflags | 2;
+ }
+ else if (!(serverflags & 4))
+ {
+ mapname = "e3m1";
+ serverflags = serverflags | 4;
+ }
+ else if (!(serverflags & 8))
+ {
+ mapname = "e4m1";
+ serverflags = serverflags - 7;
+ }
+
+ t_level = spawn_trigger_changelevel (self,
+ self.origin, mapname);
+ }
+ else
+ {
+ // find a trigger changelevel
+ t_level = findfloat (world, classtype, CT_TRIGGER_CHANGELEVEL);
+
+ // go back to start if no trigger_changelevel
+ if (!t_level)
+ t_level = spawn_trigger_changelevel (self,
+ self.origin, "start");
+ }
+
+ nextmap = t_level.map;
+ gameover = TRUE;
+
+ if (t_level.nextthink < time)
+ t_level.nextthink = time + 0.1;
+};
+
+//----------------------------------------------------------------------
+// CheckRules -- Exit deathmatch games upon conditions; 'self' is client
+//----------------------------------------------------------------------
+void() CheckRules =
+{
+ // someone else quit the game already
+ if (gameover)
+ return;
+
+ local float timelimit = cvar ("timelimit") * 60;
+ local float fraglimit = cvar ("fraglimit");
+
+ // 1998-07-27 Timelimit/Fraglimit fix by Maddes
+ if (deathmatch && timelimit && time >= timelimit)
+ {
+ NextLevel ();
+ return;
+ }
+
+ // 1998-07-27 Timelimit/Fraglimit fix by Maddes
+ if (deathmatch && fraglimit && self.frags >= fraglimit)
+ {
+ NextLevel ();
+ return;
+ }
+};
+#endif
+
+//======================================================================
+// Helper functions - intermission handling
+//======================================================================
+
+#ifdef SSQC
+//----------------------------------------------------------------------
+void(string message) ShowIntermissionMessage =
+{
+ WriteByte (MSG_ALL, SVC_FINALE);
+ WriteString (MSG_ALL, message);
+};
+
+//----------------------------------------------------------------------
+void() StartMessageIntermission =
+{
+ WriteByte (MSG_ALL, SVC_CDTRACK);
+ WriteByte (MSG_ALL, 2);
+ WriteByte (MSG_ALL, 3);
+};
+
+//----------------------------------------------------------------------
+void() Episode1End =
+{
+ StartMessageIntermission ();
+
+ if (!cvar("registered"))
+ {
+ ShowIntermissionMessage ("As the corpse of the monstrous "
+ "entity\nChthon sinks back into the lava whence\n"
+ "it rose, you grip the Rune of Earth\n"
+ "Magic tightly. Now that you have\n"
+ "conquered the Dimension of the Doomed,\n"
+ "realm of Earth Magic, you are ready to\n"
+ "complete your task in the other three\n"
+ "haunted lands of Quake. Or are you? If\n"
+ "you don't register Quake, you'll never\n"
+ "know what awaits you in the Realm of\n"
+ "Black Magic, the Netherworld, and the\nElder World!");
+ }
+ else
+ {
+ ShowIntermissionMessage ("As the corpse of the monstrous"
+ "entity\nChthon sinks back into the lava whence\n"
+ "it rose, you grip the Rune of Earth\n"
+ "Magic tightly. Now that you have\n"
+ "conquered the Dimension of the Doomed,\n"
+ "realm of Earth Magic, you are ready to\n"
+ "complete your task. A Rune of magic\n"
+ "power lies at the end of each haunted\n"
+ "land of Quake. Go forth, seek the\n"
+ "totality of the four Runes!");
+ }
+};
+
+//----------------------------------------------------------------------
+void() Episode2End =
+{
+ StartMessageIntermission ();
+
+ ShowIntermissionMessage ("The Rune of Black Magic throbs evilly in\n"
+ "your hand and whispers dark thoughts\n"
+ "into your brain. You learn the inmost\n"
+ "lore of the Hell-Mother; Shub-Niggurath!\n"
+ "You now know that she is behind all the\n"
+ "terrible plotting which has led to so\n"
+ "much death and horror. But she is not\n"
+ "inviolate! Armed with this Rune, you\n"
+ "realize that once all four Runes are\n"
+ "combined, the gate to Shub-Niggurath's\n"
+ "Pit will open, and you can face the\n"
+ "Witch-Goddess herself in her frightful\n"
+ "otherworld cathedral.");
+};
+
+//----------------------------------------------------------------------
+void() Episode3End =
+{
+ StartMessageIntermission ();
+
+ ShowIntermissionMessage ("The charred viscera of diabolic horrors\n"
+ "bubble viscously as you seize the Rune\n"
+ "of Hell Magic. Its heat scorches your\n"
+ "hand, and its terrible secrets blight\n"
+ "your mind. Gathering the shreds of your\n"
+ "courage, you shake the devil's shackles\n"
+ "from your soul, and become ever more\n"
+ "hard and determined to destroy the\n"
+ "hideous creatures whose mere existence\n"
+ "threatens the souls and psyches of all\n"
+ "the population of Earth.");
+
+};
+
+//----------------------------------------------------------------------
+void() Episode4End =
+{
+ StartMessageIntermission ();
+
+ ShowIntermissionMessage ("Despite the awful might of the Elder\n"
+ "World, you have achieved the Rune of\n"
+ "Elder Magic, capstone of all types of\n"
+ "arcane wisdom. Beyond good and evil,\n"
+ "beyond life and death, the Rune\n"
+ "pulsates, heavy with import. Patient and\n"
+ "potent, the Elder Being Shub-Niggurath\n"
+ "weaves her dire plans to clear off all\n"
+ "life from the Earth, and bring her own\n"
+ "foul offspring to our world! For all the\n"
+ "dwellers in these nightmare dimensions\n"
+ "are her descendants! Once all Runes of\n"
+ "magic power are united, the energy\n"
+ "behind them will blast open the Gateway\n"
+ "to Shub-Niggurath, and you can travel\n"
+ "there to foil the Hell-Mother's plots\nin person.");
+};
+
+//----------------------------------------------------------------------
+float() RunId1Intermissions =
+{
+ if (world.skip_id1_overrides == 0)
+ {
+ if (world.model == "maps/e1m7.bsp")
+ {
+ Episode1End ();
+ return 1;
+ }
+ else if (world.model == "maps/e2m6.bsp")
+ {
+ Episode2End ();
+ return 1;
+ }
+ else if (world.model == "maps/e3m6.bsp")
+ {
+ Episode3End ();
+ return 1;
+ }
+ else if (world.model == "maps/e4m7.bsp")
+ {
+ Episode4End ();
+ return 1;
+ }
+ }
+ return 0;
+};
+
+//----------------------------------------------------------------------
+// FindIntermission -- Returns the entity to view from
+//----------------------------------------------------------------------
+entity() FindIntermission =
+{
+ local entity spot;
+ local float cyc;
+
+ // look for info_intermission first
+ spot = findfloat (world, classtype, CT_INFO_INTERMISSION);
+ if (spot)
+ { // pick a random one
+ cyc = random() * 4;
+ while (cyc > 1)
+ {
+ spot = findfloat (spot, classtype,
+ CT_INFO_INTERMISSION);
+ if (!spot)
+ spot = findfloat (spot, classtype,
+ CT_INFO_INTERMISSION);
+ cyc = cyc - 1;
+ }
+ return spot;
+ }
+
+ // then look for the start position
+ spot = findfloat (world, classtype, CT_INFO_PLAYER_START);
+ if (spot)
+ return spot;
+
+ // testinfo_player_start is only found in regioned levels
+ spot = findfloat (world, classtype, CT_INFO_TESTPLAYERSTART);
+ if (spot)
+ return spot;
+
+ objerror ("FindIntermission: no spot");
+
+ // just to suppress the compiler warning
+ return world;
+};
+
+//----------------------------------------------------------------------
+void() GotoNextMap =
+{
+ if (cvar("samelevel"))
+ // if samelevel is set, stay on same level
+ changelevel (mapname);
+ else
+ changelevel (nextmap);
+};
+
+//----------------------------------------------------------------------
+float(float start) ShowIntermissionTextEntity =
+{
+ if (!(used_exit.spawnflags & 2))
+ {
+ local entity end_message;
+ for (end_message = world; (end_message = findfloat
+ (end_message, classtype, CT_INFO_INTERMISSIONTEXT)); )
+ {
+ if (end_message.cnt == (intermission - 1))
+ {
+ if (start == 1)
+ StartMessageIntermission ();
+ ShowIntermissionMessage (end_message.message);
+ return 1;
+ }
+ }
+ }
+ return 0;
+};
+
+//----------------------------------------------------------------------
+void() ExitIntermission =
+{
+ // skip any text in deathmatch
+ if (deathmatch)
+ {
+ GotoNextMap ();
+ return;
+ }
+
+ intermission_exittime = time + 1;
+ intermission = intermission + 1;
+
+ // run some text if at the end of an episode
+ if (intermission == 2)
+ {
+ if (RunId1Intermissions() == 1)
+ {
+ return;
+ }
+ else
+ {
+ if (used_exit.message != "")
+ {
+ // favor message on changelevel
+ StartMessageIntermission ();
+ ShowIntermissionMessage (used_exit.message);
+ return;
+ }
+ if (ShowIntermissionTextEntity(1))
+ {
+ return;
+ }
+ }
+
+ GotoNextMap ();
+ }
+
+ if (intermission == 3)
+ {
+ if (!cvar("registered"))
+ {
+ // shareware episode has been completed,
+ // go to sell screen
+ WriteByte (MSG_ALL, SVC_SELLSCREEN);
+ return;
+ }
+ if (ShowIntermissionTextEntity(0))
+ {
+ return;
+ }
+ if ((serverflags & 15) == 15)
+ {
+ ShowIntermissionMessage ("Now, you have all four Runes."
+ " You sense\ntremendous invisible forces moving"
+ " to\nunseal ancient barriers."
+ " Shub-Niggurath\nhad hoped to use the Runes"
+ " Herself to\nclear off the Earth, but now"
+ " instead,\nyou will use them to enter her"
+ " home and\nconfront her as an avatar of"
+ " avenging\nEarth-life. If you defeat her,"
+ " you will\nbe remembered forever as the"
+ " savior of\nthe planet. If she conquers,"
+ " it will be\nas if you had never been born.");
+ return;
+ }
+ }
+
+ if (intermission > 3)
+ {
+ if (ShowIntermissionTextEntity(0))
+ {
+ return;
+ }
+ }
+
+ GotoNextMap ();
+};
+
+//----------------------------------------------------------------------
+// IntermissionThink
+// When the player presses attack or jump, change to the next level
+// 'self' in this context is the client/player
+//----------------------------------------------------------------------
+void() IntermissionThink =
+{
+ // full send -- CEV
+ // self.fixangle = TRUE;
+ self.velocity = '0 0 0';
+ self.SendFlags = 0xffffff;
+
+ if (time < intermission_exittime)
+ return;
+
+ if (!self.button0 && !self.button1 && !self.button2)
+ return;
+
+ ExitIntermission ();
+};
+
+//----------------------------------------------------------------------
+void() RestartLoopSounds_think =
+{
+ sound (self, self.impulse, self.noise, self.volume, self.speed);
+};
+
+//----------------------------------------------------------------------
+void() RestartLoopSounds =
+{
+ entity e;
+ e = find (world, classname, "play_sound_triggered");
+ while (e) {
+ if (e.spawnflags & 3 == 3) {
+ // both "toggle" and "looped" need to be set
+ if (e.state == 1) {
+ e.nextthink = time + 0.1;
+ e.think = RestartLoopSounds_think;
+ }
+ }
+ e = find (e, classname, "play_sound_triggered");
+ }
+};
+#endif
+
+//======================================================================
+// REAL entrypoints (the following functions are called by the engine)
+//======================================================================
+
+#ifdef SSQC
+//----------------------------------------------------------------------
+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");
+};
+
+//----------------------------------------------------------------------
+// ClientConnect
+// called when a player connects to a server; the client may not have
+// fully spawned yet (according to Nuclide's comments). self in this
+// context refers to the connecting client. -- CEV
+//----------------------------------------------------------------------
+void() ClientConnect =
+{
+ // a client connecting during an intermission can cause problems
+ if (intermission)
+ ExitIntermission ();
+
+ if (self.classname != "player")
+ // run the player spawn function, initializing 'self'
+ // as a player object -- CEV
+ player_init (self);
+
+ bprint (self.netname);
+ bprint (" entered the game\n");
+};
+
+//----------------------------------------------------------------------
+// ClientDisconnect
+// called when a player disconnects from a server; the client will be
+// removed after this function, so 'self' in this context is the player
+// and any fields of self can be accessed. -- CEV
+//----------------------------------------------------------------------
+void() ClientDisconnect =
+{
+ // if the level end trigger has been activated, just return
+ // since they aren't *really* leaving
+ if (gameover)
+ return;
+
+ // let everyone else know
+ bprint (self.netname);
+ bprint (" left the game with ");
+ bprint (ftos(self.frags));
+ bprint (" frags\n");
+ sound (self, CHAN_BODY, "player/tornoff2.wav", 1, ATTN_NONE);
+
+ if (self.classtype == CT_PLAYER)
+ player_set_suicide_frame ();
+ else
+ dprint ("ClientDisconnect: ERROR! Encountered a non-player!\n");
+};
+
+//----------------------------------------------------------------------
+// ClientKill -- Player entered the suicide command; 'self' is the client
+//----------------------------------------------------------------------
+void() ClientKill =
+{
+ // 1998-07-27 Suicide during intermission fix by Zhenga start
+ // not allowed during intermission
+ if ((intermission) && ((coop) || (deathmatch)))
+ return;
+ // 1998-07-27 Suicide during intermission fix by Zhenga end
+
+ bprint (self.netname);
+ bprint (" suicides\n");
+
+ if (self.classtype == CT_PLAYER)
+ {
+ player_set_suicide_frame ();
+ self.modelindex = modelindex_player;
+ // extra penalty
+ self.frags = self.frags - 2;
+ player_respawn ();
+ }
+ else
+ {
+ dprint ("ClientKill: ERROR! suicide from a non-player!\n");
+ }
+};
+
+//----------------------------------------------------------------------
+void() SetNewParms =
+{
+ parm2 = 100; // self.health
+ parm3 = 0; // self.armorvalue
+ parm5 = 0; // self.ammo_nails
+ parm6 = 0; // self.ammo_rockets
+ parm7 = 0; // self.ammo_cells
+ parm9 = 0; // self.armortype * 100
+
+ // "reset_items 2" makes the player start with only the axe -- iw
+ if (world.reset_items == 2)
+ {
+ parm1 = IT_AXE; // self.items
+ parm4 = 0; // self.ammo_shells
+ parm8 = IT_AXE; // self.weapon
+ }
+ else
+ {
+ parm1 = IT_AXE | IT_SHOTGUN; // self.items
+ parm4 = 25; // self.ammo_shells
+ parm8 = IT_SHOTGUN; // self.weapon
+ }
+};
+
+//----------------------------------------------------------------------
+void() SetChangeParms =
+{
+ if (self.health <= 0)
+ {
+ SetNewParms ();
+ return;
+ }
+
+ // remove items
+ self.items = self.items - (self.items &
+ (IT_KEY1 | IT_KEY2 | IT_INVISIBILITY | IT_INVULNERABILITY
+ | IT_SUIT | IT_QUAD)
+ );
+
+ // cap super health
+ if (self.health > 100)
+ self.health = 100;
+ if (self.health < 50)
+ self.health = 50;
+ parm1 = self.items;
+ parm2 = self.health;
+ parm3 = self.armorvalue;
+ if (self.ammo_shells < 25)
+ parm4 = 25;
+ else
+ parm4 = self.ammo_shells;
+ parm5 = self.ammo_nails;
+ parm6 = self.ammo_rockets;
+ parm7 = self.ammo_cells;
+ parm8 = self.weapon;
+ parm9 = self.armortype * 100;
+};
+
+//----------------------------------------------------------------------
+// PutClientInServer -- called each time a player is spawned
+// according to Nuclide: player has fully connected and loaded in.
+// 'self' is the player/client, parmX are populated with data carried
+// over from previous levels for this specific client. -- CEV
+//----------------------------------------------------------------------
+void() PutClientInServer =
+{
+ if (self.classname == "player")
+ dprint ("PutClientInServer: classname already player!\n");
+};
+
+//----------------------------------------------------------------------
+// PlayerPreThink -- Called every frame before physics are run
+//----------------------------------------------------------------------
+void() PlayerPreThink =
+{
+ if (intermission)
+ {
+ // otherwise a button could be missed between the think tics
+ IntermissionThink ();
+ return;
+ }
+
+ if (self.view_ofs == '0 0 0')
+ {
+ // Check for cutscene stuff.
+ // TODO CEV Cutscene_Think ();
+ // intermission or finale
+ return;
+ }
+
+ // Check map / gametype rules, change to next level if requested -- CEV
+ CheckRules ();
+
+ // call prethink on the player after double checking classtype -- CEV
+ if (self.classtype == CT_PLAYER)
+ player_prethink ();
+};
+
+//----------------------------------------------------------------------
+// SV_RunClientCommand -- Called every frame to run physics
+//----------------------------------------------------------------------
+void() SV_RunClientCommand =
+{
+ // should match the one used by csqc.
+ if (world_standardphysics)
+ // for testing -- CEV
+ runstandardplayerphysics (self);
+ else
+ // for real. See pmove.qc -- CEV
+ PM_Move (self);
+};
+
+//----------------------------------------------------------------------
+// PlayerPostThink -- Called every frame after physics are run
+//----------------------------------------------------------------------
+void() PlayerPostThink =
+{
+ if (intermission)
+ return;
+
+ // call postthink on the player after double checking classtype -- CEV
+ if (self.classtype == CT_PLAYER)
+ player_postthink ();
+};
+
+//----------------------------------------------------------------------
+void() StartFrame =
+{
+ // new spawnflags for all entities -- iw
+ if (!done_inhibition_summary)
+ PrintInhibitionSummary ();
+
+ // per-frame latched variables -- CEV
+ teamplay = cvar ("teamplay");
+ skill = cvar ("skill");
+
+ framecount = framecount + 1;
+
+ if (clean_up_client_stuff)
+ {
+ clean_up_client_stuff -= 1;
+ RestartLoopSounds ();
+ }
+ else if (!gamestarted && framecount > 2)
+ {
+ if (framecount != 3)
+ clean_up_client_stuff += 2;
+
+ gamestarted = TRUE;
+ }
+};
+
+/*
+// placeholder in case it's necessary -- CEV
+void() EndFrame =
+{
+ dprint ("EndFrame: entering...\n");
+};
+*/
+
+/*
+// placeholder in case it's necessary; based on code from Nuclide SDK -- CEV
+void(void() spawnfunc) CheckSpawn =
+{
+ if (spawnfunc)
+ {
+ // dprint (sprintf("CheckSpawn: creating %s\n",
+ // self.classname));
+ spawnfunc ();
+ }
+ else
+ {
+ // print (sprintf("CheckSpawn: cannot find entity class %s\n",
+ // self.classname));
+ remove (self);
+ }
+};
+*/
+#endif

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

Diff qc/sv_progs.src

diff --git a/qc/sv_progs.src b/qc/sv_progs.src
new file mode 100644
index 0000000..6d42f11
--- /dev/null
+++ b/qc/sv_progs.src
@@ -0,0 +1,216 @@
+#pragma target fte
+#pragma progs_dat "../progs.dat"
+#pragma autoproto
+
+#define FTE
+#define SSQC
+
+#includelist
+//----------------------------------------------------------------------
+// defs
+//----------------------------------------------------------------------
+defs_globals.qc // id1 globalvars_t
+defs_fields.qc // id1 entvars_t
+defs_builtins.qc // id1 / FTE builtin functions (& overrides)
+defs_const.qc // id1 & pd3 common constants
+defs_ctypes.qc // global class list
+
+//----------------------------------------------------------------------
+// utility & helper functions
+//----------------------------------------------------------------------
+math.qc // Code by Joshua Skelton + misc
+utility.qc
+newflags.qc // new spawnflags for all entities
+cshift.qc // background color shift controller
+subs.qc // modified targets, triggers and killtargets
+keylock.qc // common code for entities unlockable with keys
+custom_snd.qc // mapper-settable sound FX for monsters - iw
+custom_mdls.qc // mapper-settable models for monsters - iw
+gore.qc // spawnblood etc; TODO CEV need to reformat
+
+//----------------------------------------------------------------------
+// base classes
+//----------------------------------------------------------------------
+base_entities.qc // topmost entity classes (+ damage functions)
+base_func.qc // base func_ classes
+base_item.qc // ammo, armor, health, weapons, etc.
+base_monster.qc // base monster classes (+ monster AI)
+base_proj.qc // projectiles
+base_trigger.qc // methods & fields for trigger entities
+
+//----------------------------------------------------------------------
+// info entities -- destinations, targets, etc.
+//----------------------------------------------------------------------
+info/camera.qc // was in cutscene.qc
+info/intermission.qc // intermission point entity
+info/null.qc // info_null; was in lights.qc
+info/notnull.qc // info_notnull; was in lights.qc
+info/path_corner.qc // id1 path_corner
+info/rotate.qc // hipnotic info_rotate
+info/spawnpoints.qc // info_player_etc and other spawnpoints
+info/teleport_changedest.qc // Qmaster's info_teleport_changedest
+info/teleport_destination.qc // teleporter endpoints
+
+//----------------------------------------------------------------------
+// projectiles - these were all previously in weapons.qc
+//----------------------------------------------------------------------
+projectiles/bullet.qc // id1 shotguns
+projectiles/fireball.qc // id1 fireball (spawned by misc_fireball)
+projectiles/flak.qc // pd3 flak
+projectiles/grenade.qc // id1 grenades
+projectiles/hknightspell.qc // id1 Death Knight magic attack
+projectiles/laser.qc // id1 lasers (enforcer, hazards)
+projectiles/lavaball.qc // pd3 lava ball missiles
+projectiles/multigrenade.qc // pd3 & Hipnotic/Rogue multi/mini grenades
+projectiles/rocket.qc // id1 rockets
+projectiles/spike.qc // id1 nails
+projectiles/voreball.qc // id1 vore homing missile
+projectiles/wizardspell.qc // id1 Scrag green magic missile attack
+projectiles/zombiechunk.qc // id1 zombie flesh chunk (traditionally thrown)
+
+//----------------------------------------------------------------------
+// item entities & weapon firing code
+//----------------------------------------------------------------------
+items/ammo.qc // ammo; was in items.qc
+items/armor.qc // armor; was in items.qc
+items/keys.qc // key pickups; contains items.qc and keydata.qc
+items/health.qc // health; was in items.qc
+items/powerups.qc // envirosuit, pent, ring, quad; was in items.qc
+items/runes.qc // end-of-episode runes; was in items.qc
+items/weapons.qc // weapon pickups; was in items.qc
+items/backpacks.qc // backpack code; was in items.qc
+
+//----------------------------------------------------------------------
+// client & player code
+//----------------------------------------------------------------------
+cutscene.qc // Drake version -- dumptruck_ds
+obituary.qc // ClientObituary
+pmove.qc // QC player movement code -- CEV
+
+//----------------------------------------------------------------------
+// monster entities
+//----------------------------------------------------------------------
+monsters/playerclient.qc // player and client handling
+/*
+monsters/boss.qc // id1 Chthon
+monsters/boss2.qc // pd3 killable Chthon
+monsters/dog.qc // id1 Doggo
+monsters/demon.qc // id1 Fiend
+monsters/knight.qc // id1 Knight
+monsters/ogre.qc // id1 Ogre
+monsters/shambler.qc // id1 Shambler
+monsters/soldier.qc // id1 Grunt
+monsters/wizard.qc // id1 Scragg / Wizard
+monsters/zombie.qc // modified Ace_Dave's zombies from Rubicon2
+monsters/enforcer.qc // id1 Enforcer (registered)
+monsters/fish.qc // id1 Fish (registered)
+monsters/hknight.qc // id1 Death Knight / Hell Knight (registered)
+monsters/oldone.qc // id1 Shub (registered)
+monsters/oldone2.qc // pd3 killable Shub
+monsters/shalrath.qc // id1 Vore (registered)
+*/
+
+//----------------------------------------------------------------------
+// func entities
+//----------------------------------------------------------------------
+func/shadow.qc //
+func/wall.qc // was misc.qc -- CEV
+func/bob.qc // RennyC's stand alone version based on AD
+func/bossgate.qc // was misc.qc -- CEV
+func/breakable.qc // selections from Rubicon2 QC
+func/brush.qc // currently disabled per comments in the file
+func/button.qc // id1 buttons
+func/counter.qc // Hipnotic counter; was in hipcount.qc
+func/door.qc // was doors.qc -- CEV
+func/door_secret.qc // was doors.qc -- CEV
+func/elvtr_button.qc // Rogue elevator code (pmack)
+func/episodegate.qc // was misc.qc -- CEV
+func/explobox.qc // selections from Rubicon2 QC
+func/fall.qc // Renny's original version
+func/fall2.qc // Renny's improved version.
+func/illusionary.qc // was misc.qc -- CEV
+func/laser.qc // selections from Rubicon2 QC
+// func/monster_spawner.qc // "bot" creation code for func_monster_spawner
+func/new_plat.qc // Rogue MP newplats.qc
+func/plat.qc // was plats.qc -- CEV
+func/particlefield.qc // Hipnotic particlefield
+func/rotate.qc // from Hipnotic thanks RennyC; was rotate.qc
+func/togglevisiblewall.qc // was misc.qc -- CEV
+func/togglewall.qc // was hippart.qc -- CEV
+func/train.qc // was plats.qc -- CEV
+
+//----------------------------------------------------------------------
+// trigger & target entities
+//----------------------------------------------------------------------
+triggers/multiple.qc // need to add first, subclassed below -- CEV
+// triggers/camera.qc // was in cutscene.qc
+triggers/changelevel.qc //
+triggers/changemusic.qc //
+triggers/changetarget.qc //
+triggers/counter.qc //
+triggers/cvarset.qc // was in cutscene.qc
+triggers/everything.qc // trigger_everything
+triggers/filter.qc //
+triggers/fog.qc // fog triggers
+triggers/heal.qc // trigger_heal (was in dtmisc.qc) -- CEV
+triggers/hurt.qc //
+triggers/ladder.qc // ladders (from rubicon2) -- CEV
+triggers/look.qc //
+triggers/monsterface.qc //
+triggers/monsterjump.qc //
+triggers/onlyregistered.qc // id1
+triggers/push.qc // wind/push brushes, jumppads -- CEV
+// triggers/remove.qc // was in hip_trig.qc; currently disabled -- CEV
+triggers/relay.qc //
+triggers/secret.qc //
+triggers/setcount.qc // target_setcount
+triggers/setgravity.qc // was in hip_trig.qc
+triggers/setskill.qc //
+triggers/setstate.qc // target_setstate
+triggers/shake.qc // triggerable shake from Zer cutscenes
+triggers/take_weapon.qc //
+triggers/teleport.qc // was in triggers.qc -- CEV
+triggers/textstory.qc // textstory (was in misc.qc) -- CEV
+triggers/usekey.qc // was in hip_trig.qc -- CEV
+triggers/void.qc // Necros's trigger_void from Lost Chapters
+
+//----------------------------------------------------------------------
+// hazards
+//----------------------------------------------------------------------
+hazards/ltrail.qc // from DOE lightnin.qc
+hazards/shooter.qc // was in misc.qc
+
+//----------------------------------------------------------------------
+// miscellaneous entities
+//----------------------------------------------------------------------
+misc/model.qc // Code by Joshua Skelton
+misc/air_bubbles.qc // was in misc.qc -- CEV
+misc/ambient_sound.qc // misc ambient_ entities w/add. by dumptruck_ds
+misc/deadstuff.qc // misc gore from DeadStuff mod
+misc/explobox.qc // was in misc.qc -- CEV
+misc/fireball.qc // was in misc.qc -- CEV
+misc/infight.qc // was in misc.qc -- CEV
+misc/light_candle.qc // was in misc.qc -- CEV
+misc/lights.qc // c0burn's excellent switchable lights
+misc/modeltrain.qc // was in plats.qc -- CEV
+misc/noisemaker.qc // was in misc.qc -- CEV
+misc/particles.qc // selections from Rubicon2 QC; was rubicon2.qc
+misc/particlespray.qc // selections from Rubicon2 QC; was rubicon2.qc
+misc/particle_stream.qc // from Zerstrorer mod -- dumptruck_ds
+misc/play.qc // sound code from Hip & Rubicon Rumble + misc
+misc/sparks.qc // selections from Rubicon2 QC; was rubicon2.qc
+misc/target_autosave.qc // was in misc.qc -- CEV
+misc/teleporttrain.qc // was in plats.qc -- CEV
+misc/viewthing.qc // was in misc.qc -- CEV
+
+//----------------------------------------------------------------------
+// world
+//----------------------------------------------------------------------
+sv_entry.qc // server-side entrypoints
+world.qc // worldspawn
+
+//----------------------------------------------------------------------
+// compatibility spawn functions & misc
+//----------------------------------------------------------------------
+compat_quake3.qc // entrypoints & support for Quake 3 entities
+#endlist

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

Diff qc/triggers/changelevel.qc

diff --git a/qc/triggers/changelevel.qc b/qc/triggers/changelevel.qc
index 2e58f10..deaf624 100644
--- a/qc/triggers/changelevel.qc
+++ b/qc/triggers/changelevel.qc
@@ -2,24 +2,42 @@
// trigger_changelevel
//==============================================================================

+//======================================================================
// constants
+//======================================================================
+
const float TRIGGER_CHANGELEVEL_EXITOFF = 8; // was DT_EXITOFF

+//======================================================================
+// forward declarations
+//======================================================================
+
+void() trigger_changelevel_think;
+void() trigger_changelevel_touch;
+void() trigger_changelevel_use;
+entity(entity src, vector org, string m) spawn_trigger_changelevel;
+void(entity e) trigger_changelevel_init;
+void() trigger_changelevel;
+
+//------------------------------------------------------------------------------
+
/*QUAKED trigger_changelevel (0.5 0.5 0.5) ? NO_INTERMISSION X X X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY

When the player touches this, he gets sent to the map listed in the "map" variable. Unless the NO_INTERMISSION flag is set, the view will go to the info_intermission spot and display stats.
*/
-class trigger_changelevel: base_trigger
-{
+
+//----------------------------------------------------------------------
+// class trigger_changelevel: base_trigger
+// {
//--------------------------------------------------------------
// was changelevel_execute
//--------------------------------------------------------------
- virtual void() do_think =
+ void() trigger_changelevel_think =
{
- used_exit = this;
+ used_exit = self;
local entity pos;

- intermission_running = 1;
+ intermission = 1;

// enforce a wait time before allowing changelevel
if (deathmatch)
@@ -33,7 +51,7 @@ class trigger_changelevel: base_trigger

pos = FindIntermission ();

- other = findfloat (world, ::classtype, CT_PLAYER);
+ other = findfloat (world, classtype, CT_PLAYER);
while (other != world)
{
other.velocity = '0 0 0';
@@ -47,10 +65,9 @@ class trigger_changelevel: base_trigger
other.movetype = MOVETYPE_NONE;
other.modelindex = 0;
setorigin (other, pos.origin);
- fog_setFromEnt (other, pos);
- // TODO CEV
+ fog_set_from_ent (other, pos);
other.SendFlags = 0xffffff;
- other = findfloat (other, ::classtype, CT_PLAYER);
+ other = findfloat (other, classtype, CT_PLAYER);
}

// Drake -- dumptruck_ds
@@ -58,7 +75,7 @@ class trigger_changelevel: base_trigger
{
// If player was in a cutscene when the level ended,
// restore viewsize.
- pos = find (world, ::classname, "camera");
+ pos = find (world, classname, "camera");
if (pos)
{
local string val;
@@ -72,92 +89,113 @@ class trigger_changelevel: base_trigger
};

//--------------------------------------------------------------
- virtual void(entity toucher) do_touch =
+ void() trigger_changelevel_touch =
{
- if (this.estate != STATE_ACTIVE)
+ if (self.estate != STATE_ACTIVE)
return;

// from Copper -- dumptruck_ds
- if (sub_checkvalidtouch(toucher) == FALSE)
+ if (sub_checkvalidtouch(other) == FALSE)
return;

if ((cvar("noexit") == 1) || ((cvar("noexit") == 2) &&
(mapname != "start")))
{
- t_damage2 (toucher, this, this, 50000);
+ t_damage2 (other, self, self, 50000);
return;
}

if (coop || deathmatch)
{
- bprint (toucher.netname);
+ bprint (other.netname);
bprint (" exited the level\n");
}

- nextmap = this.map;
+ nextmap = self.map;
sub_usetargets ();

- if ((this.spawnflags & 16) && (deathmatch == 0))
+ if ((self.spawnflags & 16) && (deathmatch == 0))
{
// use info_player_start2 -- dumptruck_ds
- base_item_rune::sigil_touch2 (this, toucher);
+ item_sigil_touch2 ();
}

- if ((this.spawnflags & 1) && (deathmatch == 0))
+ if ((self.spawnflags & 1) && (deathmatch == 0))
{
// NO_INTERMISSION
GotoNextMap ();
return;
}

- this.interaction_flags |= DISABLE_TOUCH;
- this.interaction_flags |= DISABLE_USE;
+ self.touch = sub_null;
+ self.use = sub_null;

// we can't move people right now, because touch functions
// are called in the middle of C movement code, so set a
// think time to do it
- this.nextthink = time + 0.1;
+ self.nextthink = time + 0.1;
};

//--------------------------------------------------------------
// trigger_changelevel_use
// dumptruck_ds based on hipnotic blocker_use; was named dt_exit_toggle
//--------------------------------------------------------------
- virtual void(entity caller) do_use =
+ void() trigger_changelevel_use =
{
- if (this.estate != STATE_ACTIVE)
+ if (self.estate != STATE_ACTIVE)
{
- this.is_waiting = 0;
- this.estate = STATE_ACTIVE;
+ self.is_waiting = 0;
+ self.estate = STATE_ACTIVE;
}
else
{
- this.is_waiting = 1;
- this.estate = STATE_INACTIVE;
+ self.is_waiting = 1;
+ self.estate = STATE_INACTIVE;
}
};

//--------------------------------------------------------------
- virtual void() init_spawned =
+ entity(entity src, vector org, string m) spawn_trigger_changelevel =
{
- this.interaction_flags = 0;
+ local entity e = spawn ();
+ e.owner = src;
+ e.origin = org;
+ e.map = m;
+
+ trigger_changelevel_init (e);
+ return e;
+ };
+
+ //--------------------------------------------------------------
+ void(entity e) trigger_changelevel_init =
+ {
+ e.classname = "trigger_changelevel";
+ e.classtype = CT_TRIGGER_CHANGELEVEL;
+ e.think = trigger_changelevel_think;
+ e.touch = trigger_changelevel_touch;
+ e.use = trigger_changelevel_use;

// dumptruck_ds
- if (this.spawnflags & TRIGGER_CHANGELEVEL_EXITOFF)
- this.is_waiting = 1;
+ if (e.spawnflags & TRIGGER_CHANGELEVEL_EXITOFF)
+ e.is_waiting = 1;

- sub_checkwaiting ();
+ sub_checkwaiting (e);

- if (!this.map)
+ if (!e.map)
objerror ("changelevel trigger doesn't have map");

- init_trigger ();
- this.flags = this.flags | FL_NOCENTERPRINT;
+ base_trigger_init (e);
+
+ e.flags |= FL_NOCENTERPRINT;
};

//--------------------------------------------------------------
void() trigger_changelevel =
{
- this.classtype = CT_TRIGGER_CHANGELEVEL;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ trigger_changelevel_init (self);
};
-};
+// };

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

Diff qc/triggers/changemusic.qc

diff --git a/qc/triggers/changemusic.qc b/qc/triggers/changemusic.qc
index a146377..dc0eca4 100644
--- a/qc/triggers/changemusic.qc
+++ b/qc/triggers/changemusic.qc
@@ -2,10 +2,33 @@
// trigger_changemusic, trigger_cdtrack
//==============================================================================

-class base_changemusic: base_trigger
-{
+//======================================================================
+// forward declarations
+//======================================================================
+
+// base_changemusic
+void(float newtrack) base_changemusic_newtrack;
+
+// trigger_changemusic
+void() trigger_changemusic_touch;
+entity(entity src, vector org, vector nmins, vector nmaxs, float newsnd)
+ spawn_trigger_changemusic;
+void(entity e) trigger_changemusic_init;
+void() trigger_changemusic;
+
+// trigger_cdtrack
+void() trigger_cdtrack_use;
+entity(entity src, vector org, float newcount) spawn_trigger_cdtrack;
+void(entity e) trigger_cdtrack_init;
+void() trigger_cdtrack;
+
+//------------------------------------------------------------------------------
+
+//----------------------------------------------------------------------
+// class base_changemusic: base_trigger
+// {
//--------------------------------------------------------------
- nonvirtual void(float newtrack) changemusic =
+ void(float newtrack) base_changemusic_newtrack =
{
// changing the field via a pointer
*world_sounds = newtrack;
@@ -15,46 +38,63 @@ class base_changemusic: base_trigger
// is loaded) will get sent the new cd track's number.

// let everyone currently on the server know.
- WriteByte(MSG_ALL, SVC_CDTRACK);
+ WriteByte (MSG_ALL, SVC_CDTRACK);
// initial track
- WriteByte(MSG_ALL, newtrack);
+ WriteByte (MSG_ALL, newtrack);
// looped track... should generally be set the same as the
// initial track as most engines ignore it entirely so it
// might as well be same for those that care.
- WriteByte(MSG_ALL, newtrack);
+ WriteByte (MSG_ALL, newtrack);
};
-};
+// };

/*QUAKED trigger_changemusic (.5 .5 .5) ? X X X X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
A trigger brush that changes the currently playing music track. The number of the track to play goes in the sounds key (just like worldspawn). */
-class trigger_changemusic: base_changemusic
-{
- virtual void() do_think =
- {
- remove (this);
- };
-
+//----------------------------------------------------------------------
+// class trigger_changemusic: base_changemusic
+// {
//--------------------------------------------------------------
// thanks to jleww via changemusic.rar --dumptruck_ds
//--------------------------------------------------------------
- virtual void(entity toucher) do_touch =
+ void() trigger_changemusic_touch =
{
// from Copper -- dumptruck_ds
- if (sub_checkvalidtouch(toucher) == FALSE)
+ if (sub_checkvalidtouch(other) == FALSE)
return;

- if (!(toucher.flags & FL_CLIENT))
+ if (!(other.flags & FL_CLIENT))
return;

- this.interaction_flags |= DISABLE_TOUCH;
- this.changemusic (this.sounds);
- this.nextthink = (time + 0.1);
+ self.touch = sub_null;
+ base_changemusic_newtrack (self.sounds);
+ self.nextthink = (time + 0.1);
+ };
+
+ //--------------------------------------------------------------
+ entity(entity src, vector org, vector nmins, vector nmaxs,
+ float newsnd) spawn_trigger_changemusic =
+ {
+ local entity e = spawn ();
+ e.owner = src;
+ e.origin = org;
+ e.mins = nmins;
+ e.maxs = nmaxs;
+ e.sounds = newsnd;
+ setorigin (e, org);
+ setsize (e, nmins, nmaxs);
+ trigger_changemusic_init (e);
+ return e;
};

//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) trigger_changemusic_init =
{
- if (!this.sounds)
+ e.classname = "trigger_changemusic";
+ e.classtype = CT_TRIGGER_CHANGEMUSIC;
+ e.think = sub_remove;
+ e.touch = trigger_changemusic_touch;
+
+ if (!e.sounds)
{
// splitting the error string up, FTEQCC does implicit
// string concatenation -- CEV
@@ -63,47 +103,74 @@ class trigger_changemusic: base_changemusic
return;
}

- init_trigger ();
- sub_checkwaiting ();
+ base_trigger_init (e);
+ sub_checkwaiting (e);
};

//--------------------------------------------------------------
void() trigger_changemusic =
{
- this.classtype = CT_TRIGGER_CHANGEMUSIC;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ trigger_changemusic_init (self);
};
-};
+// };

/*QUAKED trigger_cdtrack (.7 .7 .7) X X X X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
A point entity that changes the currently playing music track when triggered. The number of the track to play goes in the count key. e.g. 32 for track32.ogg See manual trigger_changemusic for more information on formats and more.

NOTE: the track number uses the count key here but trigger_changemusic uses the sound key for the same info.
*/
-class trigger_cdtrack: base_changemusic
-{
+//----------------------------------------------------------------------
+// class trigger_cdtrack: base_changemusic
+// {
+ //--------------------------------------------------------------
// point entity version uses count for music track number for
// backwards compatibly in Adoria mod -- dumptruck_ds
- virtual void(entity caller) do_use =
+ //--------------------------------------------------------------
+ void() trigger_cdtrack_use =
+ {
+ base_changemusic_newtrack (self.count);
+ };
+
+ //--------------------------------------------------------------
+ entity(entity src, vector org, float newcount) spawn_trigger_cdtrack =
{
- this.changemusic (this.count);
+ local entity e = spawn ();
+ e.owner = src;
+ e.origin = org;
+ e.count = newcount;
+ setorigin (e, org);
+ trigger_cdtrack_init (e);
+ return e;
};

//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) trigger_cdtrack_init =
{
- if (!this.count)
+ e.classname = "trigger_cdtrack";
+ e.classtype = CT_TRIGGER_CDTRACK;
+ e.use = trigger_cdtrack_use;
+
+ if (!e.count)
{
objerror ("ERROR: trigger_cdtrack needs valid track "
"number in count field");
return;
}

- init_trigger ();
+ base_trigger_init (e);
};

//--------------------------------------------------------------
void() trigger_cdtrack =
{
- this.classtype = CT_TRIGGER_CDTRACK;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ trigger_cdtrack_init (self);
};
-};
+// };

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

Diff qc/triggers/changetarget.qc

diff --git a/qc/triggers/changetarget.qc b/qc/triggers/changetarget.qc
index d91f256..e9505b3 100644
--- a/qc/triggers/changetarget.qc
+++ b/qc/triggers/changetarget.qc
@@ -2,42 +2,80 @@
// trigger_changetarget
//==============================================================================

+//======================================================================
+// forward declarations
+//======================================================================
+
+void() trigger_changetarget_use;
+entity(vector org, vector nmins, vector nmaxs, string newtarg,
+ string newmsg, float newcnt) spawn_trigger_changetarget;
+void(entity e) trigger_changetarget_init;
+void() trigger_changetarget;
+
+//------------------------------------------------------------------------------
+
/*QUAKED trigger_changetarget (.5 .5 .5) ?
Changes an entity's target field

target = entity to change
message = new value for target field
cnt = target field to change, null defaults to target
-
*/
-class trigger_changetarget: base_trigger
-{
+//----------------------------------------------------------------------
+// class trigger_changetarget: base_trigger
+// {
//--------------------------------------------------------------
- virtual void(entity caller) do_use =
+ void() trigger_changetarget_use =
{
- if (this.estate != STATE_ACTIVE)
+ if (self.estate != STATE_ACTIVE)
return;

for (entity e = world;
- (e = find (e, ::targetname, this.target)); )
+ (e = find (e, targetname, self.target)); )
{
- if (!this.cnt || this.cnt == 1)
- e.target = this.message;
- else if (this.cnt == 2)
- e.target2 = this.message;
- else if (this.cnt == 3)
- e.target3 = this.message;
- else if (this.cnt == 4)
- e.target4 = this.message;
+ if (!self.cnt || self.cnt == 1)
+ e.target = self.message;
+ else if (self.cnt == 2)
+ e.target2 = self.message;
+ else if (self.cnt == 3)
+ e.target3 = self.message;
+ else if (self.cnt == 4)
+ e.target4 = self.message;
}
};

//--------------------------------------------------------------
- virtual void() init_spawned = { };
+ entity(vector org, vector nmins, vector nmaxs, string newtarg,
+ string newmsg, float newcnt) spawn_trigger_changetarget =
+ {
+ local entity e = spawn ();
+ e.origin = org;
+ e.mins = nmins;
+ e.maxs = nmaxs;
+ e.target = newtarg;
+ e.message = newmsg;
+ e.cnt = newcnt;
+ setorigin (e, org);
+ setsize (e, nmins, nmaxs);
+ trigger_changetarget_init (e);
+ return e;
+ };
+
+ //--------------------------------------------------------------
+ void(entity e) trigger_changetarget_init =
+ {
+ e.classname = "trigger_changetarget";
+ e.classtype = CT_TRIGGER_CHANGETARGET;
+ e.use = trigger_changetarget_use;
+ };

//--------------------------------------------------------------
void() trigger_changetarget =
{
- this.classtype = CT_TRIGGER_CHANGETARGET;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ trigger_changetarget_init (self);
};
-};
+// };

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

Diff qc/triggers/counter.qc

diff --git a/qc/triggers/counter.qc b/qc/triggers/counter.qc
index 85f0060..978539f 100644
--- a/qc/triggers/counter.qc
+++ b/qc/triggers/counter.qc
@@ -2,9 +2,22 @@
// trigger_counter
//==============================================================================

+//======================================================================
// constants
+//======================================================================
+
const float TRIGGER_COUNTER_NOMESSAGE = 1;

+//======================================================================
+// forward declarations
+//======================================================================
+
+void() trigger_counter_use;
+void(entity e) trigger_counter_init;
+void() trigger_counter;
+
+//------------------------------------------------------------------------------
+
/*QUAKED trigger_counter (.5 .5 .5) ? nomessage X X X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY

Acts as an intermediary for an action that takes multiple inputs.
@@ -13,31 +26,32 @@ If nomessage is not set, t will print "1 more.. " etc when triggered and "sequen

After the counter has been triggered "count" times (default 2), it will fire all of it's targets and remove itself.
*/
-class trigger_counter: base_multiple
-{
+//----------------------------------------------------------------------
+// class trigger_counter: base_multiple
+// {
//--------------------------------------------------------------
- virtual void(entity caller) do_use =
+ void() trigger_counter_use =
{
- if (this.estate != STATE_ACTIVE)
+ if (self.estate != STATE_ACTIVE)
return;

- this.count = this.count - 1;
- if (this.count < 0)
+ self.count -= 1;
+ if (self.count < 0)
return;

- if (this.count != 0)
+ if (self.count != 0)
{
if (activator.classtype == CT_PLAYER &&
- (this.spawnflags &
+ (self.spawnflags &
TRIGGER_COUNTER_NOMESSAGE) == 0)
{
- if (this.count >= 4)
+ if (self.count >= 4)
centerprint (activator,
"There are more to go...");
- else if (this.count == 3)
+ else if (self.count == 3)
centerprint (activator,
"Only 3 more to go...");
- else if (this.count == 2)
+ else if (self.count == 2)
centerprint (activator,
"Only 2 more to go...");
else
@@ -48,27 +62,38 @@ class trigger_counter: base_multiple
}

if (activator.classtype == CT_PLAYER &&
- (this.spawnflags & TRIGGER_COUNTER_NOMESSAGE) == 0)
+ (self.spawnflags & TRIGGER_COUNTER_NOMESSAGE) == 0)
{
centerprint (activator, "Sequence completed!");
}

- this.enemy = activator;
- this.multi_trigger ();
+ self.enemy = activator;
+ base_multiple_fire ();
};

//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) trigger_counter_init =
{
- this.wait = -1;
+ e.classname = "trigger_counter";
+ e.classtype = CT_TRIGGER_COUNTER;
+ e.wait = -1;

- if (!this.count)
- this.count = 2;
+ if (!e.count)
+ e.count = 2;
+
+ e.use = trigger_counter_use;
+
+ // might need to be base_mapentity_init -- CEV
+ base_trigger_init (e);
};

//--------------------------------------------------------------
void() trigger_counter =
{
- this.classtype = CT_TRIGGER_COUNTER;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ trigger_counter_init (self);
};
-};
+// };

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

Diff qc/triggers/cvarset.qc

diff --git a/qc/triggers/cvarset.qc b/qc/triggers/cvarset.qc
index ce398e2..98e0361 100644
--- a/qc/triggers/cvarset.qc
+++ b/qc/triggers/cvarset.qc
@@ -2,69 +2,89 @@
// trigger_cvarset -- Drake version -- dumptruck_ds
//==============================================================================

+//======================================================================
+// forward declarations
+//======================================================================
+
+void() trigger_cvarset_delaythink;
+void() trigger_cvarset_use;
+// void() trigger_cvarset_touch;
+void(entity e) trigger_cvarset_init;
+void() trigger_cvarset;
+
+//------------------------------------------------------------------------------
+
/*QUAKED trigger_cvarset (.5 .5 .5) (-8 -8 -8) (8 8 32)
You can set any CVAR on the server with this trigger. Put the CVAR name
in "netname" and put the value in "message". Useful CVAR's are
sv_gravity, sv_friction, fov, and v_idlescale.
*/
-class trigger_cvarset: base_trigger
-{
+//----------------------------------------------------------------------
+// class trigger_cvarset: base_trigger
+// {
//--------------------------------------------------------------
// was cvarset_delaythink
//--------------------------------------------------------------
- virtual void() do_think =
+ void() trigger_cvarset_delaythink =
{
sub_usetargets ();
};

//--------------------------------------------------------------
- virtual void(entity caller) do_use =
+ void() trigger_cvarset_use =
{
local entity check;

- cvar_set (this.netname, this.message);
+ cvar_set (self.netname, self.message);
bprint ("\n\n\n\n");

- this.classname = "cvar_done";
- check = findfloat (world, ::classtype, CT_PLAYER);
+ self.classname = "cvar_done";
+ check = findfloat (world, classtype, CT_PLAYER);
if (!check)
- check = find (world, ::classname, "camera");
+ check = find (world, classname, "camera");

check.ideal_yaw = -1;

- this.interaction_flags &= ~DISABLE_THINK;
- this.nextthink = time + 0.02;
+ self.think = trigger_cvarset_delaythink;
+ self.nextthink = time + 0.02;
};

//--------------------------------------------------------------
// touch wasn't enabled in the original trigger_cvarset -- CEV
//--------------------------------------------------------------
/*
- virtual void(entity toucher) do_touch =
+ void() trigger_cvarset_touch =
{
- if (this.cnt > time || other.health <= 0 ||
- toucher.classtype != CT_PLAYER)
+ if (self.cnt > time || other.health <= 0 ||
+ other.classtype != CT_PLAYER)
{
return;
}

- this.do_use (toucher);
+ trigger_cvarset_use ();
};
*/

//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) trigger_cvarset_init =
{
- init_trigger ();
- this.interaction_flags |= DISABLE_THINK;
+ if (deathmatch || coop)
+ remove (e);
+
+ e.classname = "trigger_cvarset";
+ e.classtype = CT_TRIGGER_CVARSET;
+ e.think = sub_null;
+ e.use = trigger_cvarset_use;
+ base_trigger_init (e);
};

//--------------------------------------------------------------
void() trigger_cvarset =
{
- if (deathmatch || coop)
- remove (this);
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;

- this.classtype = CT_TRIGGER_CVARSET;
+ trigger_cvarset_init (self);
};
-};
+// };

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

Diff qc/triggers/everything.qc

diff --git a/qc/triggers/everything.qc b/qc/triggers/everything.qc
index cfb09f9..2c0636f 100644
--- a/qc/triggers/everything.qc
+++ b/qc/triggers/everything.qc
@@ -2,39 +2,56 @@
// trigger_everything
//==============================================================================

+//======================================================================
+// forward declarations
+//======================================================================
+
+void() trigger_everything_touch;
+void(entity e) trigger_everything_init;
+void() trigger_everything;
+
//------------------------------------------------------------------------------
+
+//----------------------------------------------------------------------
// trigger_everything
-//------------------------------------------------------------------------------
-class trigger_everything: base_trigger
-{
+//----------------------------------------------------------------------
+// class trigger_everything: base_trigger
+// {
//--------------------------------------------------------------
- virtual void(entity toucher) do_touch =
+ void() trigger_everything_touch =
{
- if (this.estate != STATE_ACTIVE)
+ if (self.estate != STATE_ACTIVE)
return;

- if (time < this.attack_finished)
+ if (time < self.attack_finished)
return;

- activator = toucher;
+ activator = other;

- sub_usetarget (this.target, ::targetname);
+ sub_usetarget (self.target, targetname);

- if (this.wait)
- if (!(this.spawnflags & 1))
- this.attack_finished = time + this.wait;
+ if (self.wait)
+ if (!(self.spawnflags & 1))
+ self.attack_finished = time + self.wait;
};

//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) trigger_everything_init =
{
- init_trigger ();
- sub_checkwaiting ();
+ e.classname = "trigger_everything";
+ e.classtype = CT_TRIGGER_EVERYTHING;
+ base_trigger_init (e);
+ e.touch = trigger_everything_touch;
+ sub_checkwaiting (e);
};

//--------------------------------------------------------------
void() trigger_everything =
{
- this.classtype = CT_TRIGGER_EVERYTHING;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ trigger_everything_init (self);
};
-};
+// };

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

Diff qc/triggers/filter.qc

diff --git a/qc/triggers/filter.qc b/qc/triggers/filter.qc
index debcd82..8ece91d 100644
--- a/qc/triggers/filter.qc
+++ b/qc/triggers/filter.qc
@@ -2,7 +2,10 @@
// trigger_filter
//==============================================================================

+//======================================================================
// constants
+//======================================================================
+
const float FILTER_FIELD_STATE = 0;
const float FILTER_FIELD_HEALTH = 1;
const float FILTER_FIELD_WEAPON = 2;
@@ -28,17 +31,34 @@ const float FILTER_OP_GTE = 4;
const float FILTER_OP_BITMASK_AND = 5;
const float FILTER_OP_BITMASK_OR = 6;

+//======================================================================
+// fields
+//======================================================================
+
+.string include; // trigger_filter
+.string type; // trigger_filter
+
+//======================================================================
+// forward declarations
+//======================================================================
+
+void() trigger_filter_use;
+void(entity e) trigger_filter_init;
+void() trigger_filter;
+
//------------------------------------------------------------------------------
+
+//----------------------------------------------------------------------
// TODO CEV: this needs comments
-//------------------------------------------------------------------------------
-class trigger_filter: base_trigger
-{
+//----------------------------------------------------------------------
+// class trigger_filter: base_trigger
+// {
//--------------------------------------------------------------
- virtual void(entity caller) do_use =
+ void() trigger_filter_use =
{
- this.state = 0;
+ self.state = 0;

- if (this.estate != STATE_ACTIVE)
+ if (self.estate != STATE_ACTIVE)
return;

local entity targ;
@@ -48,12 +68,12 @@ class trigger_filter: base_trigger
targfloat = fieldtype = op = result = 0;
targstring = "";

- if (this.include != "")
+ if (self.include != "")
{
- targ = find (world, ::targetname, this.include);
+ targ = find (world, targetname, self.include);
if (!targ)
- targ = find (world, ::targetname2,
- this.include);
+ targ = find (world, targetname2,
+ self.include);
if (!targ)
return;
}
@@ -62,9 +82,9 @@ class trigger_filter: base_trigger
targ = activator;
}

- op = this.weapon;
+ op = self.weapon;

- switch (this.style)
+ switch (self.style)
{
case FILTER_FIELD_STATE:
fieldtype = FILTER_FIELDTYPE_FLOAT;
@@ -131,42 +151,42 @@ class trigger_filter: base_trigger
{
if (op == FILTER_OP_EQUALS)
{
- if (targfloat == this.count)
+ if (targfloat == self.count)
result = 1;
}
else if (op == FILTER_OP_LT)
{
- if (targfloat < this.count)
+ if (targfloat < self.count)
result = 1;
}
else if (op == FILTER_OP_LTE)
{
- if (targfloat <= this.count)
+ if (targfloat <= self.count)
result = 1;
}
else if (op == FILTER_OP_GT)
{
- if (targfloat > this.count)
+ if (targfloat > self.count)
result = 1;
}
else if (op == FILTER_OP_GTE)
{
- if (targfloat >= this.count)
+ if (targfloat >= self.count)
result = 1;
}
else if (op == FILTER_OP_BITMASK_AND)
{
- if (targfloat & this.count)
+ if (targfloat & self.count)
result = 1;
}
else if (op == FILTER_OP_BITMASK_OR)
{
- if (targfloat | this.count)
+ if (targfloat | self.count)
result = 1;
}
else
{
- if (targfloat == this.count)
+ if (targfloat == self.count)
result = 1;
}
}
@@ -174,28 +194,28 @@ class trigger_filter: base_trigger
{
if (op == FILTER_OP_EQUALS)
{
- if (targfloat == this.aflag)
+ if (targfloat == self.aflag)
result = 1;
}
else if (op == FILTER_OP_BITMASK_AND)
{
- if (targfloat & this.aflag)
+ if (targfloat & self.aflag)
result = 1;
}
else if (op == FILTER_OP_BITMASK_OR)
{
- if (targfloat | this.aflag)
+ if (targfloat | self.aflag)
result = 1;
}
else
{
- if (targfloat == this.aflag)
+ if (targfloat == self.aflag)
result = 1;
}
}
else if (fieldtype == FILTER_FIELDTYPE_STRING)
{
- if (targstring == this.type)
+ if (targstring == self.type)
result = 1;
}
else
@@ -204,34 +224,44 @@ class trigger_filter: base_trigger
return;
}

- if (this.spawnflags & 1)
+ if (self.spawnflags & 1)
// negate
result = 1 - result;

if (result)
{
- this.state = 1;
+ self.state = 1;

// relay activator as owner
- if (this.spawnflags & 2 && activator.owner)
+ if (self.spawnflags & 2 && activator.owner)
activator = activator.owner;

sub_usetargets ();

- if (caller.classtype == CT_TRIGGER_EVERYTHING &&
- caller.spawnflags & 1 && caller.wait)
+ if (other.classtype == CT_TRIGGER_EVERYTHING &&
+ other.spawnflags & 1 && other.wait)
{
- caller.attack_finished = time + caller.wait;
+ other.attack_finished = time + other.wait;
}
}
};

//--------------------------------------------------------------
- virtual void() init_spawned = { };
+ void(entity e) trigger_filter_init =
+ {
+ e.classname = "trigger_filter";
+ e.classtype = CT_TRIGGER_FILTER;
+ e.use = trigger_filter_use;
+ base_trigger_init (e);
+ };

//--------------------------------------------------------------
void() trigger_filter =
{
- this.classtype = CT_TRIGGER_FILTER;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ trigger_filter_init (self);
};
-};
+// };

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

Diff qc/triggers/fog.qc

diff --git a/qc/triggers/fog.qc b/qc/triggers/fog.qc
index a5e8f82..697765e 100644
--- a/qc/triggers/fog.qc
+++ b/qc/triggers/fog.qc
@@ -15,7 +15,10 @@
]
*/

+//======================================================================
// constants
+//======================================================================
+
const float FOG_INTERVAL = 0.04166667; // 1/24;

const float FOGBLEND_ONEWAY = 1;
@@ -23,7 +26,59 @@ const float FOGBLEND_REVERSE = 2;
const float FOGBLEND_ALLCLIENTS = 4;
const float FOGBLEND_BLENDTO = 8;

-//==============================================================================
+//======================================================================
+// fields
+//======================================================================
+
+.vector fog_color, fog_color2; // progs_dump fog
+.float fog_density, fog_density2;
+.float skyfog_density, skyfog_density2;
+.entity fogblend_entity;
+
+//======================================================================
+// forward declarations
+//======================================================================
+
+void(entity client, float density, vector color) fog_save;
+void(entity client) fog_save_to_previous;
+void(entity client, float density) skyfog_save;
+void(entity client) skyfog_save_to_previous;
+void(entity client, entity fogger) fog_set_from_ent;
+void(entity client, float density, vector color) fog_set;
+void(entity client, float density) skyfog_set;
+void(entity client, vector cTo, float dTo, float f) fog_blend_set_fraction;
+void(entity client, float sTo, float f) skyfog_blend_set_fraction;
+
+// base_fog_controller
+void() base_fog_controller_think;
+
+// temp_fog_controller
+entity(entity own, entity nme) spawn_temp_fog_controller;
+void(entity e) temp_fog_controller_init;
+strip void() temp_fog_controller;
+
+// target_fogblend
+void() target_fogblend_use;
+entity(vector org, float sflags, vector fogcolor, float fd, float sfd,
+ float newspeed1, float newspeed2) spawn_target_fogblend;
+void(entity e) target_fogblend_init;
+void() target_fogblend;
+
+// trigger_fogblend
+void() trigger_fogblend_touch;
+entity(vector org, vector nmins, vector nmaxs, vector ang, vector md,
+ float dist) spawn_trigger_fogblend;
+void(entity e) trigger_fogblend_init;
+void() trigger_fogblend;
+
+// trigger_fog
+void() trigger_fog_touch;
+entity(vector org, vector nmins, vector nmaxs, float newspeed, vector newcolor,
+ float fdensity, float sfdensity, float newdelay) spawn_trigger_fog;
+void(entity e) trigger_fog_init;
+void() trigger_fog;
+
+//------------------------------------------------------------------------------

//----------------------------------------------------------------------
// fog_save
@@ -71,7 +126,7 @@ void(entity client) skyfog_save_to_previous =
//----------------------------------------------------------------------
// fog_setFromEnt
//----------------------------------------------------------------------
-void(entity client, entity fogger) fog_setFromEnt =
+void(entity client, entity fogger) fog_set_from_ent =
{
local float density;

@@ -90,7 +145,7 @@ void(entity client, entity fogger) fog_setFromEnt =
fog_set (client, density, fogger.fog_color);
}

- //dprint3 ("skyfog_density: ", ftos(fogger.skyfog_density*100), "\n");
+ // dprint3 ("skyfog_density: ", ftos(fogger.skyfog_density*100), "\n");
if (fogger.skyfog_density)
{
dprint ("setting skyfog\n");
@@ -138,106 +193,103 @@ void(entity client, float density) skyfog_set =
skyfog_save (client, density);
};

-//------------------------------------------------------------------------------
-class base_fog_controller: base_mapentity
+//----------------------------------------------------------------------
+void(entity client, vector cTo, float dTo, float f) fog_blend_set_fraction =
{
- float speed2;
-
- //--------------------------------------------------------------
- nonvirtual void(entity cl, float sTo, float f) skyfog_blendSetFraction =
- {
- local float s;
+ local float d;
+ local vector c;

- s = lerpHermite (cl.skyfog_density2, sTo, f);
+ d = lerp_hermite (client.fog_density2, dTo, f);
+ c = lerp_vector_hermite (client.fog_color2, cTo, f);

- // eprint (cl);
- // dprint3 ("Fraction skyfog density: ", ftos(s), "\n");
+ /*
+ eprint (cl);
+ dprint3 ("fog density: ", ftos(d), "\n");
+ dprint3 ("color: ", vtos(c), "\n");
+ dprint3 ("fraction: ", ftos(f), "\n");
+ */

- skyfog_set (cl, s);
- };
+ fog_set (client, d, c);
+};

- //--------------------------------------------------------------
- nonvirtual void(entity cl, vector cTo, float dTo, float f)
- fog_blendSetFraction =
- {
- local float d;
- local vector c;
+//----------------------------------------------------------------------
+void(entity client, float sTo, float f) skyfog_blend_set_fraction =
+{
+ local float s;

- d = lerpHermite (cl.fog_density2, dTo, f);
- c = lerpVectorHermite (cl.fog_color2, cTo, f);
+ s = lerp_hermite (client.skyfog_density2, sTo, f);

- /*
- eprint (cl);
- dprint3 ("fog density: ", ftos(d), "\n");
- dprint3 ("color: ", vtos(c), "\n");
- dprint3 ("fraction: ", ftos(f), "\n");
- */
+ // eprint (cl);
+ // dprint3 ("Fraction skyfog density: ", ftos(s), "\n");

- fog_set (cl, d, c);
- };
+ skyfog_set (client, s);
+};

+//----------------------------------------------------------------------
+// class base_fog_controller: base_mapentity
+// {
//--------------------------------------------------------------
// fog controller think -- used by both trigger_fog and
// target_fogblend; was fog_blendTimeThink
//--------------------------------------------------------------
- virtual void() do_think =
+ void() base_fog_controller_think =
{
local float f;
local float dTo, sTo;
local vector cTo;

- if (time >= this.pain_finished)
+ if (time >= self.pain_finished)
{
f = 1;
}
else
{
- this.nextthink = time + FOG_INTERVAL;
- if (this.state && this.speed)
- f = 1 - (this.pain_finished - time) /
- this.speed;
- else if (this.speed2)
- f = 1 - (this.pain_finished - time) /
- this.speed2;
+ self.nextthink = time + FOG_INTERVAL;
+ if (self.state && self.speed)
+ f = 1 - (self.pain_finished - time) /
+ self.speed;
+ else if (self.speed2)
+ f = 1 - (self.pain_finished - time) /
+ self.speed2;
else
f = 1;
}

- if (this.state)
+ if (self.state)
{
- dTo = this.fog_density2;
- cTo = this.fog_color2;
- sTo = this.skyfog_density2;
+ dTo = self.fog_density2;
+ cTo = self.fog_color2;
+ sTo = self.skyfog_density2;
}
else
{
- dTo = this.fog_density;
- cTo = this.fog_color;
- sTo = this.skyfog_density;
+ dTo = self.fog_density;
+ cTo = self.fog_color;
+ sTo = self.skyfog_density;
}

- if (this.spawnflags & FOGBLEND_ALLCLIENTS)
+ if (self.spawnflags & FOGBLEND_ALLCLIENTS)
{
entity pl;
pl = nextent (world);
while (pl.flags & FL_CLIENT)
{
- if (pl.fogblend_entity == this)
+ if (pl.fogblend_entity == self)
{
if (dTo && !(pl.fog_density2 == dTo &&
pl.fog_color2 == cTo))
{
- fog_blendSetFraction (pl, cTo,
+ fog_blend_set_fraction (pl, cTo,
zeroconvert(dTo), f);
}

if (sTo)
{
- skyfog_blendSetFraction (pl,
+ skyfog_blend_set_fraction (pl,
zeroconvert(sTo), f);
}

- if (time >= this.pain_finished)
+ if (time >= self.pain_finished)
{
pl.fogblend_entity = world;
}
@@ -248,50 +300,74 @@ class base_fog_controller: base_mapentity
}
else
{
- if (this.enemy.fogblend_entity == this)
+ if (self.enemy.fogblend_entity == self)
{
- if (dTo && !(this.enemy.fog_density2 == dTo &&
- this.enemy.fog_color2 == cTo))
+ if (dTo && !(self.enemy.fog_density2 == dTo &&
+ self.enemy.fog_color2 == cTo))
{
- fog_blendSetFraction (this.enemy, cTo,
- zeroconvert(dTo), f);
+ fog_blend_set_fraction (self.enemy,
+ cTo, zeroconvert(dTo), f);
}

if (sTo)
{
- skyfog_blendSetFraction (this.enemy,
+ skyfog_blend_set_fraction (self.enemy,
zeroconvert(sTo), f);
}

- if (time >= this.pain_finished)
+ if (time >= self.pain_finished)
{
- this.enemy.fogblend_entity = world;
+ self.enemy.fogblend_entity = world;
}
}
}

- if (this.classtype == CT_TEMP_FOG_CONTROLLER)
+ if (self.classtype == CT_TEMP_FOG_CONTROLLER)
{
- if (this.enemy.fogblend_entity != this ||
- time >= this.pain_finished)
+ if (self.enemy.fogblend_entity != self ||
+ time >= self.pain_finished)
{
- remove (this);
+ remove (self);
return;
}
}
};
-};
+// };

-//------------------------------------------------------------------------------
-class temp_fog_controller: base_fog_controller
-{
+//----------------------------------------------------------------------
+// class temp_fog_controller: base_fog_controller
+// {
//--------------------------------------------------------------
- void() temp_fog_controller =
+ entity(entity own, entity nme) spawn_temp_fog_controller =
{
- this.classname = "temp_fog_controller";
- this.classtype = CT_TEMP_FOG_CONTROLLER;
+ local entity e = spawn ();
+ e.owner = own;
+ e.enemy = nme;
+ // speed2 is used when state is 0
+ e.speed2 = own.speed;
+ e.fog_color = own.fog_color;
+ e.fog_density = own.fog_density;
+ e.skyfog_density = own.skyfog_density;
+ e.pain_finished = time + own.delay + own.speed;
+ temp_fog_controller_init (e);
+ return e;
};
-};
+
+ //--------------------------------------------------------------
+ void(entity e) temp_fog_controller_init =
+ {
+ base_tempentity_init (e);
+ e.classname = "temp_fog_controller";
+ e.classtype = CT_TEMP_FOG_CONTROLLER;
+ e.think = base_fog_controller_think;
+ };
+
+ //--------------------------------------------------------------
+ strip void() temp_fog_controller =
+ {
+ temp_fog_controller_init (self);
+ };
+// };

/*QUAKED target_fogblend (.5 .5 .2) (-8 -8 -8) (8 8 8) ONE_WAY REVERSE GLOBAL BLENDTO
Blends the fog for a client. activator's fog will be blended from "fog_color" and "fog_density"
@@ -325,99 +401,113 @@ Activator's fog will be blended over time from start to end values.
speed2(string) : "Time to blend back, if different (-1 for instant)"
]
*/
-class target_fogblend: base_fog_controller
-{
- //--------------------------------------------------------------
- virtual void(string fieldname, string fieldvalue) init_field =
- {
- switch (fieldname)
- {
- case "speed2":
- this.speed2 = stof (fieldvalue);
- break;
- default:
- super::init_field (fieldname, fieldvalue);
- }
- };
-
+// class target_fogblend: base_fog_controller
+// {
//--------------------------------------------------------------
- virtual void(entity caller) do_use =
+ void() target_fogblend_use =
{
- this.enemy = activator;
- if (this.enemy.classtype != CT_PLAYER)
+ self.enemy = activator;
+ if (self.enemy.classtype != CT_PLAYER)
return;

- if (!(this.spawnflags & FOGBLEND_ONEWAY))
- this.state = 1 - this.state;
+ if (!(self.spawnflags & FOGBLEND_ONEWAY))
+ self.state = 1 - self.state;

- if (this.state)
- this.pain_finished = time + this.delay + this.speed;
+ if (self.state)
+ self.pain_finished = time + self.delay + self.speed;
else
- this.pain_finished = time + this.delay + this.speed2;
+ self.pain_finished = time + self.delay + self.speed2;

- if (this.spawnflags & FOGBLEND_ALLCLIENTS)
+ if (self.spawnflags & FOGBLEND_ALLCLIENTS)
{
entity pl;
pl = nextent (world);
while (pl.flags & FL_CLIENT)
{
- if (this.fog_density)
+ if (self.fog_density)
fog_save_to_previous (pl);
- if (this.skyfog_density)
+ if (self.skyfog_density)
skyfog_save_to_previous (pl);

- pl.fogblend_entity = this;
+ pl.fogblend_entity = self;

pl = nextent(pl);
}
}
else
{
- if (this.fog_density)
- fog_save_to_previous (this.enemy);
- if (this.skyfog_density)
- skyfog_save_to_previous (this.enemy);
+ if (self.fog_density)
+ fog_save_to_previous (self.enemy);
+ if (self.skyfog_density)
+ skyfog_save_to_previous (self.enemy);

- this.enemy.fogblend_entity = this;
+ self.enemy.fogblend_entity = self;
}

- this.nextthink = time + this.delay;
+ self.nextthink = time + self.delay;
+ };
+
+ //--------------------------------------------------------------
+ entity(vector org, float sflags, vector fogcolor,
+ float fd, float sfd, float newspeed1, float newspeed2)
+ spawn_target_fogblend =
+ {
+ local entity e = spawn ();
+ e.origin = org;
+ e.spawnflags = sflags;
+ e.fog_color = fogcolor;
+ e.fog_density = fd;
+ e.skyfog_density = sfd;
+ e.speed = newspeed1;
+ e.speed2 = newspeed2;
+ target_fogblend_init (e);
+ return e;
};

//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) target_fogblend_init =
{
- if (!this.fog_density && !this.skyfog_density)
+ base_mapentity_init (e);
+ e.classname = "target_fogblend";
+ e.classtype = CT_TARGET_FOGBLEND;
+ e.think = base_fog_controller_think;
+ e.use = target_fogblend_use;
+
+ if (!e.fog_density && !e.skyfog_density)
{
objerror ("Neither fog density nor skyfog density set");
return;
}

- if (this.spawnflags & FOGBLEND_REVERSE)
- this.state = 1;
+ if (e.spawnflags & FOGBLEND_REVERSE)
+ e.state = 1;
else
- this.state = 0;
+ e.state = 0;

- if (this.spawnflags & FOGBLEND_ONEWAY)
- this.state = 1 - this.state;
+ if (e.spawnflags & FOGBLEND_ONEWAY)
+ e.state = 1 - e.state;

- if (!this.speed)
- this.speed = 1;
- if (!this.speed2)
- this.speed2 = this.speed;
+ if (!e.speed)
+ e.speed = 1;
+ if (!e.speed2)
+ e.speed2 = e.speed;

- if (this.speed == -1)
- this.speed = 0;
- if (this.speed2 == -1)
- this.speed2 = 0;
+ if (e.speed == -1)
+ e.speed = 0;
+ if (e.speed2 == -1)
+ e.speed2 = 0;
};

//--------------------------------------------------------------
void() target_fogblend =
{
- this.classtype = CT_TARGET_FOGBLEND;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ target_fogblend_init (self);
};
-};
+// };

/*QUAKED trigger_fogblend (.5 .5 .2) ?
Acts as a smoothly blending portal between two zones of different fog. Sets the fog for any client passing through it, blending their global fog settings between "fog_color"/"fog_density" and "fog_color2"/"fog_density2" proportional to their position within the trigger.
@@ -442,26 +532,27 @@ Acts as a smoothly blending portal between two zones of different fog. Sets the
angle(integer) : "Axis of motion of blend (points toward end values)"
]
*/
-class trigger_fogblend: base_trigger
-{
+// class trigger_fogblend: base_trigger
+// {
//--------------------------------------------------------------
// fog_blendTouch
//--------------------------------------------------------------
- virtual void(entity toucher) do_touch =
+ void() trigger_fogblend_touch =
{
- if (toucher.classtype != CT_PLAYER)
+ if (other.classtype != CT_PLAYER)
return;

- if (toucher.health <= 0)
+ if (other.health <= 0)
return;

- if (this.estate != STATE_ACTIVE)
+ if (self.estate != STATE_ACTIVE)
return;

// fix for only first client getting a fog change when
// multiple coop clients are touching this at once
- if (time != this.rad_time) // because fog is rad
- if (time < this.attack_finished)
+ if (time != self.rad_time)
+ // because fog is rad
+ if (time < self.attack_finished)
return;

local float f, lerp_density, leaving;
@@ -471,39 +562,39 @@ class trigger_fogblend: base_trigger
local vector dorg, mid, ovel;
local vector lerp_color;

- ent_density = zeroconvert (this.fog_density);
- ent_density2 = zeroconvert (this.fog_density2);
+ ent_density = zeroconvert (self.fog_density);
+ ent_density2 = zeroconvert (self.fog_density2);

- ent_sdensity = zeroconvert (this.skyfog_density);
- ent_sdensity2 = zeroconvert (this.skyfog_density2);
+ ent_sdensity = zeroconvert (self.skyfog_density);
+ ent_sdensity2 = zeroconvert (self.skyfog_density2);

// if you run/fall through a fogblend fast enough you can come
// out the other side partially blended, so check if player will
// exit the trigger bounds before the next touch (same class of
// bug as leaping through lasers in Q2)
- ovel = toucher.velocity * FOG_INTERVAL;
- leaving = ((toucher.absmax_x + ovel_x < this.absmin_x) ||
- (toucher.absmax_y + ovel_y < this.absmin_y) ||
- (toucher.absmax_z + ovel_z < this.absmin_z) ||
- (toucher.absmin_x + ovel_x > this.absmax_x) ||
- (toucher.absmin_y + ovel_y > this.absmax_y) ||
- (toucher.absmin_z + ovel_z > this.absmax_z));
+ ovel = other.velocity * FOG_INTERVAL;
+ leaving = ((other.absmax_x + ovel_x < self.absmin_x) ||
+ (other.absmax_y + ovel_y < self.absmin_y) ||
+ (other.absmax_z + ovel_z < self.absmin_z) ||
+ (other.absmin_x + ovel_x > self.absmax_x) ||
+ (other.absmin_y + ovel_y > self.absmax_y) ||
+ (other.absmin_z + ovel_z > self.absmax_z));

if (leaving)
{
// last chance to set fog correctly, so snap it to the
// final values
- leaving = toucher.velocity * this.movedir;
+ leaving = other.velocity * self.movedir;
if (leaving > 0)
{
lerp_density = ent_density2;
- lerp_color = this.fog_color2;
+ lerp_color = self.fog_color2;
lerp_sdensity = ent_sdensity2;
}
else
{
lerp_density = ent_density;
- lerp_color = this.fog_color;
+ lerp_color = self.fog_color;
lerp_sdensity = ent_sdensity;
}
}
@@ -511,51 +602,76 @@ class trigger_fogblend: base_trigger
{
// in transition, blend proportionally between
// the two fogs
- mid = (this.mins + this.maxs) * 0.5;
- dorg = toucher.origin + toucher.view_ofs - mid;
+ mid = (self.mins + self.maxs) * 0.5;
+ dorg = other.origin + other.view_ofs - mid;

- f = dorg * this.movedir;
- f = (f / this.distance) + 0.5;
+ f = dorg * self.movedir;
+ f = (f / self.distance) + 0.5;

lerp_density = lerp (ent_density, ent_density2, f);
- lerp_color = lerpVector (this.fog_color,
- this.fog_color2, f);
+ lerp_color = lerp_vector (self.fog_color,
+ self.fog_color2, f);
lerp_sdensity = lerp (ent_sdensity, ent_sdensity2, f);
}

- if (this.fog_density || this.fog_density2)
- fog_set (toucher, lerp_density, lerp_color);
- if (this.skyfog_density || this.skyfog_density2)
- skyfog_set (toucher, lerp_sdensity);
+ if (self.fog_density || self.fog_density2)
+ fog_set (other, lerp_density, lerp_color);
+ if (self.skyfog_density || self.skyfog_density2)
+ skyfog_set (other, lerp_sdensity);

- this.rad_time = time;
- this.attack_finished = time + FOG_INTERVAL;
+ self.rad_time = time;
+ self.attack_finished = time + FOG_INTERVAL;

// reset client's fogblend_entity in case it's currently being
// transitioned by another entity
- toucher.fogblend_entity = world;
+ other.fogblend_entity = world;
};

//--------------------------------------------------------------
- virtual void() init_spawned =
+ entity(vector org, vector nmins, vector nmaxs, vector ang, vector md,
+ float dist) spawn_trigger_fogblend =
{
- // InitTrigger (now init_trigger) assumes angle 0 means no angle
- if (this.angles == '0 0 0')
- this.angles = '0 360 0';
+ local entity e = spawn ();
+ e.origin = org;
+ e.mins = nmins;
+ e.maxs = nmaxs;
+ e.angles = ang;
+ e.movedir = md;
+ e.distance = dist;
+ setorigin (e, org);
+ setsize (e, nmins, nmaxs);
+ trigger_fogblend_init (e);
+ return e;
+ };

- init_trigger ();
- this.distance = zeroconvertdefault (this.distance,
- BoundsAngleSize(this.movedir, this.size));
+ //--------------------------------------------------------------
+ void(entity e) trigger_fogblend_init =
+ {
+ e.classname = "trigger_fogblend";
+ e.classtype = CT_TRIGGER_FOGBLEND;
+ e.touch = trigger_fogblend_touch;

- sub_checkwaiting ();
+ // base_trigger_init assumes angle 0 means no angle
+ if (e.angles == '0 0 0')
+ e.angles = '0 360 0';
+
+ base_trigger_init (e);
+ e.distance = zeroconvertdefault (e.distance,
+ bounds_angle_size(e.movedir, e.size));
+
+ sub_checkwaiting (e);
};

//--------------------------------------------------------------
void() trigger_fogblend =
{
- this.classtype = CT_TRIGGER_FOGBLEND;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ trigger_fogblend_init (self);
};
-};
+// };

/*QUAKED trigger_fog (.5 .5 .2) ?
Smoothly blends touching client's currently applied fog to "fog_color" and "fog_density" over time.
@@ -567,67 +683,85 @@ CAVEATS:
- will 'stuffcmd' 2 dozen times per second so try not to make these huge
- a bug in most quake engine ports will reset the eye position smoothing that happens when climbing stairs or riding a plat on every frame that a 'stuffcmd' is sent, so fog transitions during upwards motion will cause noticeable stuttering.
*/
-class trigger_fog: base_trigger
-{
+// class trigger_fog: base_trigger
+// {
//--------------------------------------------------------------
- virtual void(entity toucher) do_touch =
+ void() trigger_fog_touch =
{
- if (this.estate != STATE_ACTIVE)
+ if (self.estate != STATE_ACTIVE)
return;

- if (!(toucher.flags & FL_CLIENT))
+ if (!(other.flags & FL_CLIENT))
return;

- // fog already set to this value
- if (toucher.fog_color == this.fog_color &&
- toucher.fog_density == this.fog_density)
+ // fog already set to self value
+ if (other.fog_color == self.fog_color &&
+ other.fog_density == self.fog_density)
return;

- // transition already occurring from this trigger
- if (toucher.fogblend_entity.owner == this)
+ // transition already occurring from self trigger
+ if (other.fogblend_entity.owner == self)
return;

- if (this.fog_density)
- fog_save_to_previous (toucher);
- if (this.skyfog_density)
- skyfog_save_to_previous (toucher);
-
- // spawn a temp entity to control the transition for this client
- temp_fog_controller controller;
-
- // TODO CEV
- controller = spawn (temp_fog_controller,
- owner: this,
- enemy: toucher,
- // speed2 is used when state is 0
- speed2: this.speed,
- fog_color: this.fog_color,
- fog_density: this.fog_density,
- skyfog_density: this.skyfog_density,
- pain_finished: time + this.delay + this.speed);
- controller.nextthink = time + controller.delay;
- toucher.fogblend_entity = controller;
+ if (self.fog_density)
+ fog_save_to_previous (other);
+ if (self.skyfog_density)
+ skyfog_save_to_previous (other);
+
+ // spawn a temp entity to control the transition for self client
+ local entity tempfog = spawn_temp_fog_controller (self, other);
+ tempfog.nextthink = time + tempfog.delay;
+ other.fogblend_entity = tempfog;
+ };
+
+ //--------------------------------------------------------------
+ entity(vector org, vector nmins, vector nmaxs,
+ float newspeed, vector newcolor, float fdensity,
+ float sfdensity, float newdelay) spawn_trigger_fog =
+ {
+ local entity e = spawn ();
+ e.origin = org;
+ e.mins = nmins;
+ e.maxs = nmaxs;
+ e.speed = newspeed;
+ e.fog_color = newcolor;
+ e.fog_density = fdensity;
+ e.skyfog_density = sfdensity;
+ e.delay = newdelay;
+ setorigin (e, org);
+ setsize (e, nmins, nmaxs);
+ trigger_fog_init (e);
+ return e;
};

//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) trigger_fog_init =
{
- if (!this.fog_density && !this.skyfog_density)
+ e.classname = "trigger_fog";
+ e.classtype = CT_TRIGGER_FOG;
+ e.touch = trigger_fog_touch;
+
+ if (!e.fog_density && !e.skyfog_density)
{
objerror ("Neither fog density nor skyfog density set");
return;
}

- init_trigger ();
- if (!this.speed)
- this.speed = 1;
+ base_trigger_init (e);

- sub_checkwaiting ();
+ if (!e.speed)
+ e.speed = 1;
+
+ sub_checkwaiting (e);
};

//--------------------------------------------------------------
void() trigger_fog =
{
- this.classtype = CT_TRIGGER_FOG;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ trigger_fog_init (self);
};
-};
+// };

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

Diff qc/triggers/heal.qc

diff --git a/qc/triggers/heal.qc b/qc/triggers/heal.qc
index 4b539dc..964643b 100644
--- a/qc/triggers/heal.qc
+++ b/qc/triggers/heal.qc
@@ -4,14 +4,34 @@
// was in dtmisc.qc -- CEV
//==============================================================================

-// global entity fields
-.float heal_timer;
+//======================================================================
+// constants
+//======================================================================

-// Constants for the healing trigger
const float TRIGGER_HEAL_START_ON = 1;
const float TRIGGER_HEAL_PLAYER_ONLY = 2;
const float TRIGGER_HEAL_MONSTER_ONLY = 4;

+//======================================================================
+// fields
+//======================================================================
+
+.float heal_timer;
+.float heal_amount;
+.float health_max;
+
+//======================================================================
+// forward declarations
+//======================================================================
+
+void() trigger_heal_think;
+void() trigger_heal_touch;
+// void() trigger_heal_toggle;
+void(entity e) trigger_heal_init;
+void() trigger_heal;
+
+//------------------------------------------------------------------------------
+
/*QUAKED trigger_heal (.5 .5 .5) ? TRIGGER_HEAL_START_ON TRIGGER_HEAL_PLAYER_ONLY TRIGGER_HEAL_MONSTER_ONLY X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY

Any object touching this will be healed
@@ -26,204 +46,189 @@ speed -- amount to recharge at a time
delay -- time before recharging
message2 -- message to print when exhausted
*/
-class trigger_heal: base_trigger
-{
- // class fields
- float heal_amount;
- float health_max;
- string message2;
-
+//----------------------------------------------------------------------
+// class trigger_heal: base_trigger
+// {
//--------------------------------------------------------------
- virtual void(string fieldname, string fieldvalue) init_field =
+ void() trigger_heal_think =
{
- switch (fieldname)
- {
- case "heal_amount":
- heal_amount = stof (fieldvalue);
- break;
- case "health_max":
- health_max = stof (fieldvalue);
- break;
- case "message2":
- message2 = fieldvalue;
- break;
- default:
- super::init_field (fieldname, fieldvalue);
- }
- };
-
- //--------------------------------------------------------------
- virtual void() do_think =
- {
- if (this.cnt == this.count)
+ if (self.cnt == self.count)
{
dprint ("trigger_heal think: full\n");
- this.interaction_flags |= DISABLE_THINK;
+ self.think = sub_null;
return;
}

- local float recharge_amount = this.speed;
+ local float recharge_amount = self.speed;

- if (this.count < (this.cnt + this.speed))
- recharge_amount = this.count - this.cnt;
+ if (self.count < (self.cnt + self.speed))
+ recharge_amount = self.count - self.cnt;

dprint ("trigger_heal think: [max: ");
- dprint (ftos(this.count));
+ dprint (ftos(self.count));
dprint (", current: ");
- dprint (ftos(this.cnt));
+ dprint (ftos(self.cnt));
dprint (", recharging: ");
dprint (ftos(recharge_amount));
dprint ("]\n");

- this.cnt = this.cnt + recharge_amount;
- this.nextthink = time + this.delay;
+ self.cnt = self.cnt + recharge_amount;
+ self.nextthink = time + self.delay;
};

//--------------------------------------------------------------
- virtual void(entity toucher) do_touch =
+ void() trigger_heal_touch =
{
- if (this.estate != STATE_ACTIVE)
+ if (self.estate != STATE_ACTIVE)
return;

// from Copper -- dumptruck_ds
- if (toucher.movetype == MOVETYPE_NOCLIP)
+ if (other.movetype == MOVETYPE_NOCLIP)
{
return;
}

- if (this.spawnflags & TRIGGER_HEAL_PLAYER_ONLY &&
- toucher.classtype != CT_PLAYER)
+ if (self.spawnflags & TRIGGER_HEAL_PLAYER_ONLY &&
+ other.classtype != CT_PLAYER)
{
return;
}

- if (this.spawnflags & TRIGGER_HEAL_MONSTER_ONLY &&
- !(toucher.flags & FL_MONSTER))
+ if (self.spawnflags & TRIGGER_HEAL_MONSTER_ONLY &&
+ !(other.flags & FL_MONSTER))
{
return;
}

- if (toucher.classtype != CT_PLAYER &&
- !(toucher.flags & FL_MONSTER))
+ if (other.classtype != CT_PLAYER &&
+ !(other.flags & FL_MONSTER))
{
return;
}

- if (toucher.heal_timer > time)
+ if (other.heal_timer > time)
{
return;
}

- if (this.count && this.cnt <= 0)
+ if (self.count && self.cnt <= 0)
{
- if (this.message2 != __NULL__ && this.message2 != "")
- centerprint (toucher, this.message2);
+ if (self.message2 != __NULL__ && self.message2 != "")
+ centerprint (other, self.message2);
return;
}

- if ((toucher.takedamage) && (toucher.health < this.health_max))
+ if ((other.takedamage) && (other.health < self.health_max))
{
- if (this.noise != "")
- sound (this, CHAN_AUTO, this.noise,
+ if (self.noise != "")
+ sound (self, CHAN_AUTO, self.noise,
1, ATTN_NORM);
else
- sound (this, CHAN_AUTO, "items/r_item1.wav",
+ sound (self, CHAN_AUTO, "items/r_item1.wav",
1, ATTN_NORM);

local float calc_healing;

- if ((toucher.health + heal_amount) > health_max)
- calc_healing = health_max - toucher.health;
+ if ((other.health + self.heal_amount) > self.health_max)
+ calc_healing = self.health_max - other.health;
else
- calc_healing = heal_amount;
+ calc_healing = self.heal_amount;

- if (this.count)
+ if (self.count)
{
- if (calc_healing > this.cnt)
- calc_healing = this.cnt;
+ if (calc_healing > self.cnt)
+ calc_healing = self.cnt;

- this.cnt = this.cnt - calc_healing;
+ self.cnt -= calc_healing;

- if (this.delay)
+ if (self.delay)
{
- interaction_flags &= ~DISABLE_THINK;
- this.nextthink = time + this.delay;
+ self.think = trigger_heal_think;
+ self.nextthink = time + self.delay;
}

- dprint (sprintf("trigger_heal::do_touch: "
+ dprint (sprintf("trigger_heal_touch: "
"used [max: %f, current: %f, "
"using: %f]\n",
- this.count, this.cnt, calc_healing));
+ self.count, self.cnt, calc_healing));
}

- if (this.message != __NULL__ && this.message != "")
- centerprint (toucher, this.message);
+ if (self.message != __NULL__ && self.message != "")
+ centerprint (other, self.message);

- T_Heal (toucher, calc_healing, 1);
- toucher.heal_timer = time + this.wait;
+ T_Heal (other, calc_healing, 1);
+ other.heal_timer = time + self.wait;
}
};

- //--------------------------------------------------------------
/*
- nonvirtual void() heal_toggle =
+ //--------------------------------------------------------------
+ void() trigger_heal_toggle =
{
- if (this.interaction_flags & DISABLE_TOUCH)
- this.interaction_flags &= ~DISABLE_TOUCH;
+ if (self.touch)
+ self.touch = sub_null;
else
- this.interaction_flags |= DISABLE_TOUCH;
+ self.touch = trigger_heal_touch;
};
*/

//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) trigger_heal_init =
{
+ e.classname = "trigger_heal";
+ e.classtype = CT_TRIGGER_HEAL;
+
// play custom sound for healing if noise key exists
precache_sound ("items/r_item1.wav");
- if (this.noise != "")
- precache_sound (this.noise);
+ if (e.noise != "")
+ precache_sound (e.noise);

- init_trigger ();
+ base_trigger_init (e);

- if (this.wait == 0)
- this.wait = 1;
+ if (e.wait == 0)
+ e.wait = 1;

- if (this.heal_amount == 0)
- this.heal_amount = 5;
+ if (e.heal_amount == 0)
+ e.heal_amount = 5;

- if (this.health_max == 0)
- this.health_max = 100;
- else if (this.health_max > 250)
- this.health_max = 250;
+ if (e.health_max == 0)
+ e.health_max = 100;
+ else if (e.health_max > 250)
+ e.health_max = 250;

- if (this.count)
+ if (e.count)
{
- this.cnt = this.count;
+ e.cnt = e.count;

- if (this.speed && !this.delay)
- this.delay = 10;
- else if (!this.speed && this.delay)
- this.speed = 5;
+ if (e.speed && !e.delay)
+ e.delay = 10;
+ else if (!e.speed && e.delay)
+ e.speed = 5;
}

/*
- if (this.targetname)
+ if (e.targetname)
{
- this.interaction_flags &= ~DISABLE_USE;
- if (this.spawnflags & TRIGGER_HEAL_START_ON)
- this.interaction_flags &= ~DISABLE_TOUCH;
+ e.use = trigger_heal_toggle;
+ if (e.spawnflags & TRIGGER_HEAL_START_ON)
+ e.touch = trigger_heal_touch;
else
- this.interaction_flags |= DISABLE_TOUCH;
+ e.touch = sub_null;
}
else
*/
+ e.touch = trigger_heal_touch;

- sub_checkwaiting ();
+ sub_checkwaiting (e);
};

//--------------------------------------------------------------
void() trigger_heal =
{
- this.classtype = CT_TRIGGER_HEAL;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ trigger_heal_init (self);
};
-};
+// };

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

Diff qc/triggers/hurt.qc

diff --git a/qc/triggers/hurt.qc b/qc/triggers/hurt.qc
index 36aff9d..9164d04 100644
--- a/qc/triggers/hurt.qc
+++ b/qc/triggers/hurt.qc
@@ -2,67 +2,83 @@
// trigger_hurt -- from hip_rotate.qc by Jim Dose' 10/17/96
//==============================================================================

+//======================================================================
+// fields
+//======================================================================
+
+// 1998-07-03 hurt_touch fix by Robert Field start
+.float hurt_together_time;
+.float hurt_nextthink;
+// 1998-07-03 hurt_touch fix by Robert Field end
+
+//======================================================================
+// forward declarations
+//======================================================================
+
+void(entity e, float amount) trigger_hurt_setdamage;
+// void() trigger_hurt_on;
+void() trigger_hurt_touch;
+void(entity e) trigger_hurt_init;
+void() trigger_hurt;
+
+//------------------------------------------------------------------------------
+
/*QUAKED trigger_hurt (.5 .5 .5) ? X X X X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
Any object touching this will be hurt
set dmg to damage amount
defalt dmg = 5
*/
-class trigger_hurt: base_trigger
-{
- // class fields
- // 1998-07-03 hurt_touch fix by Robert Field start
- float hurt_together_time;
- float hurt_nextthink;
- // 1998-07-03 hurt_touch fix by Robert Field end
-
+//----------------------------------------------------------------------
+// class trigger_hurt: base_trigger
+// {
//--------------------------------------------------------------
- nonvirtual void(entity ent, float amount) setdamage =
+ void(entity e, float amount) trigger_hurt_setdamage =
{
- ent.dmg = amount;
+ e.dmg = amount;

if (!amount)
- ent.solid = SOLID_NOT;
+ e.solid = SOLID_NOT;
else
- ent.solid = SOLID_TRIGGER;
+ e.solid = SOLID_TRIGGER;

- ent.nextthink = -1;
+ e.nextthink = -1;
};

//--------------------------------------------------------------
// 1998-07-03 hurt_touch fix by Robert Field start
/*
- void() hurt_on =
+ void() trigger_hurt_on =
{
- this.solid = SOLID_TRIGGER;
- this.nextthink = -1;
+ self.solid = SOLID_TRIGGER;
+ self.nextthink = -1;
};
*/
// 1998-07-03 hurt_touch fix by Robert Field end

//--------------------------------------------------------------
- virtual void(entity toucher) do_touch =
+ void() trigger_hurt_touch =
{
- if (this.estate != STATE_ACTIVE)
+ if (self.estate != STATE_ACTIVE)
return;

// from Copper -- dumptruck_ds
- if (toucher.movetype == MOVETYPE_NOCLIP)
+ if (other.movetype == MOVETYPE_NOCLIP)
return;

- if (toucher.takedamage && this.nextthink < time)
+ if (other.takedamage && self.nextthink < time)
{
// 1998-07-03 trigger_hurt_touch fix by Robert Field
- // this.solid = SOLID_NOT;
- if (time != this.hurt_together_time)
- if (time < this.hurt_nextthink)
+ // self.solid = SOLID_NOT;
+ if (time != self.hurt_together_time)
+ if (time < self.hurt_nextthink)
return;
// 1998-07-03 hurt_touch fix by Robert Field end
- t_damage2 (toucher, this, this, this.dmg);
+ t_damage2 (other, self, self, self.dmg);
// 1998-07-03 hurt_touch fix by Robert Field start
- // this.think = hurt_on;
- // this.nextthink = time + 1;
- this.hurt_together_time = time;
- this.hurt_nextthink = time + 1;
+ // self.think = hurt_on;
+ // self.nextthink = time + 1;
+ self.hurt_together_time = time;
+ self.hurt_nextthink = time + 1;
// 1998-07-03 trigger_hurt_touch fix by Robert Field end
}

@@ -70,18 +86,27 @@ class trigger_hurt: base_trigger
};

//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) trigger_hurt_init =
{
- init_trigger ();
- if (!this.dmg)
- this.dmg = 5;
+ e.classname = "trigger_hurt";
+ e.classtype = CT_TRIGGER_HURT;
+
+ base_trigger_init (e);
+ e.touch = trigger_hurt_touch;

- sub_checkwaiting ();
+ if (!e.dmg)
+ e.dmg = 5;
+
+ sub_checkwaiting (e);
};

//--------------------------------------------------------------
void() trigger_hurt =
{
- this.classtype = CT_TRIGGER_HURT;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ trigger_hurt_init (self);
};
-};
+// };

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

Diff qc/triggers/ladder.qc

diff --git a/qc/triggers/ladder.qc b/qc/triggers/ladder.qc
index 6f548f5..8ce3bd8 100644
--- a/qc/triggers/ladder.qc
+++ b/qc/triggers/ladder.qc
@@ -2,6 +2,16 @@
// trigger_ladder -- selections from Rubicon 2 qc by john fitzgibbons
//==============================================================================

+//======================================================================
+// forward declarations
+//======================================================================
+
+void() trigger_ladder_touch;
+void(entity e) trigger_ladder_init;
+void() trigger_ladder;
+
+//------------------------------------------------------------------------------
+
/*QUAKED trigger_ladder (.5 .5 .5) ? X X X X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
invisible ladder entity. when player is touching this entity, he can climb by pushing 'jump'

@@ -9,60 +19,67 @@ Keys:

"angle" the direction player must be facing to climb ladder
*/
-class trigger_ladder: base_trigger
-{
+//----------------------------------------------------------------------
+// class trigger_ladder: base_trigger
+// {
//--------------------------------------------------------------
// trigger_ladder_touch
//--------------------------------------------------------------
- virtual void(entity toucher) do_touch =
+ void() trigger_ladder_touch =
{
// from Copper -- dumptruck_ds
- if (sub_checkvalidtouch(toucher) == FALSE)
+ if (sub_checkvalidtouch(other) == FALSE)
return;

// prevent the player "sticking" to a ladder if they are
// standing on the platform at the top of the ladder with
// the bottom of their bounding box flush with the top of
// the trigger -- iw
- if (toucher.absmin_z + 1 >= this.absmax_z - 1)
+ if (other.absmin_z + 1 >= self.absmax_z - 1)
return;

// if the trigger has an angles field, check player's
// facing direction
- if (this.movedir != '0 0 0')
+ if (self.movedir != '0 0 0')
{
- makevectors (toucher.angles);
- if (v_forward * this.movedir < 0)
+ makevectors (other.angles);
+ if (v_forward * self.movedir < 0)
// not facing the right way
return;
}

// changed to PMFLAGS -- CEV
- toucher.pmove_flags |= PMF_ONLADDER;
+ other.pmove_flags |= PMF_ONLADDER;
};

//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) trigger_ladder_init =
{
+ e.classname = "trigger_ladder";
+ e.classtype = CT_TRIGGER_LADDER;
+
// ignore an "up" or "down" angle (doesn't make sense
// for a ladder)
- if (this.angles_y == -1 || this.angles_y == -2)
+ if (e.angles_y == -1 || e.angles_y == -2)
{
- dprint ("WARNING: trigger_ladder ignored bad "
- "'angle' value: ");
- dprint (ftos (this.angles_y));
- dprint ("\n");
+ dprint (sprintf("trigger_ladder_init: ignoring bad "
+ "'angle' value: %g\n", e.angles_y));

- this.angles_y = 0;
+ e.angles_y = 0;
}

- init_trigger ();
- sub_checkwaiting ();
+ base_trigger_init (e);
+ e.touch = trigger_ladder_touch;
+ sub_checkwaiting (e);
};

//--------------------------------------------------------------
void() trigger_ladder =
{
- this.classtype = CT_TRIGGER_LADDER;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ trigger_ladder_init (self);
};
-};
+// };

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

Diff qc/triggers/look.qc

diff --git a/qc/triggers/look.qc b/qc/triggers/look.qc
index 3637f81..ef988e1 100644
--- a/qc/triggers/look.qc
+++ b/qc/triggers/look.qc
@@ -2,6 +2,17 @@
// trigger_look (a.k.a. trigger_onlookat from NullPointPaladin!)
////////////////////////////////////////////////////////////////////////////////

+//======================================================================
+// forward declarations
+//======================================================================
+
+void() trigger_look_use;
+void() trigger_look_touch;
+void(entity e) trigger_look_init;
+void() trigger_look;
+
+//------------------------------------------------------------------------------
+
/*QUAKED trigger_look (.5 .5 .5) ? X X X X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
This will trigger when a player is within the brush trigger and looks directly at a target entity.
Use the first target key for the "looked at entity" and use the subsequent targets (2-4) to trigger other events.
@@ -13,124 +24,131 @@ noise1 = Path to custom sound. Use with sounds key set to 4 (e.g. fish/bite.wav

See manual for complete details. See pd_cutscenes sample map for example
*/
-class trigger_look: base_multiple
-{
+//----------------------------------------------------------------------
+// class trigger_look: base_multiple
+// {
//--------------------------------------------------------------
- virtual void(entity caller) do_use =
+ void() trigger_look_use =
{
- multi_trigger ();
+ base_multiple_fire ();
};

//--------------------------------------------------------------
- virtual void(entity toucher) do_touch =
+ void() trigger_look_touch =
{
// from Copper -- dumptruck_ds
- if (sub_checkvalidtouch(toucher) == FALSE)
+ if (sub_checkvalidtouch(other) == FALSE)
return;

- if (this.nextthink > time)
+ if (self.nextthink > time)
// already been triggered
return;

- // added player view offset to make this more accurate
+ // added player view offset to make self more accurate
// to the player crosshairs
- local vector player_offset = toucher.origin + toucher.view_ofs;
+ local vector player_offset = other.origin + other.view_ofs;

- makevectors (toucher.v_angle);
+ makevectors (other.v_angle);

// using speed to determine the reach of the trace
- if (!this.speed)
- this.speed = 500;
+ if (!self.speed)
+ self.speed = 500;

traceline (player_offset,
- (player_offset + (v_forward * this.speed)),
- FALSE, toucher);
+ (player_offset + (v_forward * self.speed)),
+ FALSE, other);

- if (trace_ent.targetname == this.target)
+ if (trace_ent.targetname == self.target)
{
// Play message if available
- if (this.message != "")
- centerprint (toucher, this.message);
+ if (self.message != "")
+ centerprint (other, self.message);

- // TODO CEV
- /*
- this.use = this.multi_trigger;
- */
+ self.use = trigger_look_use;
sub_usetargets ();

- if (this.noise != "")
- sound (this, CHAN_VOICE, this.noise, 1,
+ if (self.noise != "")
+ sound (self, CHAN_VOICE, self.noise, 1,
ATTN_NORM);
else
- sound (this, CHAN_VOICE, this.noise1, 1,
+ sound (self, CHAN_VOICE, self.noise1, 1,
ATTN_NORM);

// added wait
- if (this.wait > 0)
+ if (self.wait > 0)
{
- this.nextthink = time + this.wait;
+ self.think = base_multiple_think_wait;
+ self.nextthink = time + self.wait;
}
else
{
- // we can't just remove (this) here, because
- // this is a touch function called while C
+ // we can't just remove (self) here, because
+ // self is a touch function called while C
// code is looping through area links...
- this.interaction_flags |= DISABLE_TOUCH;
- this.interaction_flags |= DISABLE_USE;
- this.is_removed = TRUE;
- this.nextthink = time + 0.1;
+ self.think = sub_remove;
+ self.touch = sub_null;
+ self.use = sub_null;
+ self.nextthink = time + 0.1;
}
}
};

//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) trigger_look_init =
{
+ e.classname = "trigger_look";
+ e.classtype = CT_TRIGGER_LOOK;
+
// play all the sounds available for a normal trigger
- if (this.sounds == 0)
+ if (e.sounds == 0)
{
precache_sound ("misc/null.wav");
- this.noise = "misc/null.wav";
+ e.noise = "misc/null.wav";
}
- else if (this.sounds == 1)
+ else if (e.sounds == 1)
{
precache_sound ("misc/secret.wav");
- this.noise = "misc/secret.wav";
+ e.noise = "misc/secret.wav";
}
- else if (this.sounds == 2)
+ else if (e.sounds == 2)
{
precache_sound ("misc/talk.wav");
- this.noise = "misc/talk.wav";
+ e.noise = "misc/talk.wav";
}
- else if (this.sounds == 3)
+ else if (e.sounds == 3)
{
precache_sound ("misc/trigger1.wav");
- this.noise = "misc/trigger1.wav";
+ e.noise = "misc/trigger1.wav";
}
- else if (this.sounds == 4)
+ else if (e.sounds == 4)
{
- if (!this.noise1)
+ if (!e.noise1)
{
// dumptruck_ds
- objerror ("no soundfile set in noise1!\n");
- remove (this);
+ objerror ("trigger_look_init: no soundfile "
+ "set in noise1!\n");
+ remove (e);
return;
}
else
{
- precache_sound (this.noise1);
+ precache_sound (e.noise1);
}
- this.noise = this.noise1;
+ e.noise = e.noise1;
}

- this.is_removed = FALSE;
- init_trigger ();
- sub_checkwaiting ();
+ base_trigger_init (e);
+ e.touch = trigger_look_touch;
+ sub_checkwaiting (e);
};

//--------------------------------------------------------------
void() trigger_look =
{
- this.classtype = CT_TRIGGER_LOOK;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ trigger_look_init (self);
};
-};
+// };

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

Diff qc/triggers/monsterface.qc

diff --git a/qc/triggers/monsterface.qc b/qc/triggers/monsterface.qc
index 4365508..59baf7c 100644
--- a/qc/triggers/monsterface.qc
+++ b/qc/triggers/monsterface.qc
@@ -2,6 +2,17 @@
// trigger_monsterface
//==============================================================================

+//======================================================================
+// forward declarations
+//======================================================================
+
+float(entity targ, entity o) ai_visible_to_other;
+void() trigger_monsterface_touch;
+void(entity e) trigger_monsterface_init;
+void() trigger_monsterface;
+
+//------------------------------------------------------------------------------
+
/*QUAKED trigger_monsterface (.5 .0 .5)
Running monsters that do not see their target and touch this will face in the direction of the trigger's angle instead of the unseen target.
Use this trigger to make monsters leave their sniping spot and execute complex maneuvers.
@@ -11,20 +22,21 @@ Keys:
"targetname" entity name
"wait" time to wait between retriggers
*/
-class trigger_monsterface: base_trigger
-{
+//----------------------------------------------------------------------
+// class trigger_monsterface: base_trigger
+// {
//--------------------------------------------------------------
// visibleToOther - returns 1 if the entity is visible to other,
// even if not infront ()
//--------------------------------------------------------------
- nonvirtual float(entity targ, entity toucher) newai_visible_to_other =
+ float(entity targ, entity o) ai_visible_to_other =
{
local vector spot1, spot2;

- spot1 = toucher.origin + toucher.view_ofs;
+ spot1 = o.origin + o.view_ofs;
spot2 = targ.origin + targ.view_ofs;
// see through other monsters
- traceline (spot1, spot2, TRUE, toucher);
+ traceline (spot1, spot2, TRUE, o);

if (trace_inopen && trace_inwater)
// sight line crossed contents
@@ -37,41 +49,46 @@ class trigger_monsterface: base_trigger
};

//--------------------------------------------------------------
- virtual void(entity toucher) do_touch =
+ void() trigger_monsterface_touch =
{
// only affect ground monsters
- if (toucher.flags &
+ if (other.flags &
(FL_MONSTER | FL_FLY | FL_SWIM) != FL_MONSTER)
return;

- if (!newai_visible_to_other(toucher.enemy, toucher))
+ if (!ai_visible_to_other(other.enemy, other))
{
// enemy is hidden
// don't dodge around, just go straight
- toucher.t_length = time + this.wait + 0.2;
+ other.t_length = time + self.wait + 0.2;
// face where I want
- toucher.ideal_yaw = this.angles_y;
+ other.ideal_yaw = self.angles_y;
}
};

//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) trigger_monsterface_init =
{
- // a bit like InitTrigger below -- CEV
- this.solid = SOLID_TRIGGER;
- // set size and link into world
- setmodel (this, this.model);
- this.movetype = MOVETYPE_NONE;
- this.modelindex = 0;
- this.model = "";
-
- if (this.angles == '0 0 0')
- this.angles = '0 360 0';
+ e.classname = "trigger_monsterface";
+ e.classtype = CT_TRIGGER_MONSTERFACE;
+ e.touch = trigger_monsterface_touch;
+
+ if (e.angles == '0 0 0')
+ e.angles = '0 360 0';
+
+ // trigger_init will alter angles, so save & restore them
+ local vector saveangles = e.angles;
+ base_trigger_init (e);
+ e.angles = saveangles;
};

//--------------------------------------------------------------
void() trigger_monsterface =
{
- this.classtype = CT_TRIGGER_MONSTERFACE;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ trigger_monsterface_init (self);
};
-};
+// };

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

Diff qc/triggers/monsterjump.qc

diff --git a/qc/triggers/monsterjump.qc b/qc/triggers/monsterjump.qc
index 6e0a870..05f756b 100644
--- a/qc/triggers/monsterjump.qc
+++ b/qc/triggers/monsterjump.qc
@@ -2,9 +2,23 @@
// trigger_monsterjump -- id1 monsterjump with additions from progs_dump 3
//==============================================================================

+//======================================================================
// constants
+//======================================================================
+
const float TRIGGER_MONSTERJUMP_STARTOFF = 8;

+//======================================================================
+// forward declarations
+//======================================================================
+
+void() trigger_monsterjump_touch;
+void() trigger_monsterjump_use;
+void(entity e) trigger_monsterjump_init;
+void() trigger_monsterjump;
+
+//------------------------------------------------------------------------------
+
/*QUAKED trigger_monsterjump (.5 .5 .5) ? X X X TRIGGER_MONSTERJUMP_STARTOFF X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY

Walking monsters that touch this will jump in the direction of the
@@ -15,82 +29,76 @@ trigger's angle
If TRIGGER_MONSTERJUMP_STARTOFF flag is set, this makes the trigger inactive. This can
be targeted and toggled off and on.
*/
-class trigger_monsterjump: base_trigger
-{
- // class fields
- float height;
-
- //--------------------------------------------------------------
- virtual void(string fieldname, string fieldvalue) init_field =
- {
- switch (fieldname)
- {
- case "height":
- height = stof (fieldvalue);
- break;
- default:
- super::init_field (fieldname, fieldvalue);
- }
- };
-
+//----------------------------------------------------------------------
+// class trigger_monsterjump: base_trigger
+// {
//--------------------------------------------------------------
- virtual void(entity toucher) do_touch =
+ void() trigger_monsterjump_touch =
{
- if (this.estate != STATE_ACTIVE)
+ if (self.estate != STATE_ACTIVE)
return;

- if (toucher.flags &
+ 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
- toucher.velocity_x = this.movedir_x * this.speed;
- toucher.velocity_y = this.movedir_y * this.speed;
+ other.velocity_x = self.movedir_x * self.speed;
+ other.velocity_y = self.movedir_y * self.speed;

- if (!(toucher.flags & FL_ONGROUND))
+ if (!(other.flags & FL_ONGROUND))
return;

- toucher.flags = toucher.flags - FL_ONGROUND;
+ other.flags = other.flags - FL_ONGROUND;

- toucher.velocity_z = this.height;
+ other.velocity_z = self.height;
};

//--------------------------------------------------------------
// dumptruck_ds was based on hipnotic blocker_use now Alkaline estate
//--------------------------------------------------------------
- virtual void(entity caller) do_use =
+ void() trigger_monsterjump_use =
{
// TODO CEV duplicating some code here between this and
// trigger_push_custom
- if (this.estate != STATE_ACTIVE)
- this.estate = STATE_ACTIVE;
+ if (self.estate != STATE_ACTIVE)
+ self.estate = STATE_ACTIVE;
else
- this.estate = STATE_INACTIVE;
+ self.estate = STATE_INACTIVE;
};

//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) trigger_monsterjump_init =
{
+ e.classname = "trigger_monsterjump";
+ e.classtype = CT_TRIGGER_MONSTERJUMP;
+ e.touch = trigger_monsterjump_touch;
+ e.use = trigger_monsterjump_use;
+
// dumptruck_ds
- if (this.spawnflags & TRIGGER_MONSTERJUMP_STARTOFF)
+ if (e.spawnflags & TRIGGER_MONSTERJUMP_STARTOFF)
{
- this.estate = STATE_INACTIVE;
+ e.estate = STATE_INACTIVE;
}

- if (!this.speed)
- this.speed = 200;
- if (!this.height)
- this.height = 200;
- if (this.angles == '0 0 0')
- this.angles = '0 360 0';
+ if (!e.speed)
+ e.speed = 200;
+ if (!e.height)
+ e.height = 200;
+ if (e.angles == '0 0 0')
+ e.angles = '0 360 0';

- init_trigger ();
- sub_checkwaiting ();
+ base_trigger_init (e);
+ sub_checkwaiting (e);
};

//--------------------------------------------------------------
void() trigger_monsterjump =
{
- this.classtype = CT_TRIGGER_MONSTERJUMP;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ trigger_monsterjump_init (self);
};
-};
+// };

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

Diff qc/triggers/multiple.qc

diff --git a/qc/triggers/multiple.qc b/qc/triggers/multiple.qc
index d29459d..185e492 100644
--- a/qc/triggers/multiple.qc
+++ b/qc/triggers/multiple.qc
@@ -2,28 +2,52 @@
// trigger_multiple, trigger_once
//==============================================================================

+//======================================================================
// constants
+//======================================================================
+
const float TRIGGER_MULTIPLE_NOTOUCH = 1;
// used for Wait for retrigger spawnflag
const float TRIGGER_MULTIPLE_TURNS_OFF = 2;

+//======================================================================
+// forward declarations
+//======================================================================
+
+// base_multiple
+void() base_multiple_think_wait;
+void() base_multiple_fire;
+void() base_multiple_destroy;
+void() base_multiple_touch;
+void() base_multiple_use;
+void(entity e) base_multiple_init;
+strip void() base_multiple;
+
+// trigger_multiple
+void(entity e) trigger_multiple_init;
+void() trigger_multiple;
+
+// trigger_once
+void(entity e) trigger_once_init;
+void() trigger_once;
+
//------------------------------------------------------------------------------
-// generic multiple class
-//------------------------------------------------------------------------------
-class base_multiple: base_trigger
-{
- float is_removed;

+//----------------------------------------------------------------------
+// generic multiple class
+//----------------------------------------------------------------------
+// class base_multiple: base_trigger
+// {
//--------------------------------------------------------------
// the wait time has passed, so set back up for another activation
//--------------------------------------------------------------
- virtual void() multi_wait =
+ void() base_multiple_think_wait =
{
- if (this.max_health)
+ if (self.max_health)
{
- this.health = this.max_health;
- this.takedamage = DAMAGE_YES;
- this.solid = SOLID_BBOX;
+ self.health = self.max_health;
+ self.takedamage = DAMAGE_YES;
+ self.solid = SOLID_BBOX;
}
};

@@ -32,21 +56,17 @@ class base_multiple: base_trigger
// this.enemy should be set to the activator so it can be held
// through a delay so wait for the delay time before firing
//--------------------------------------------------------------
- virtual void() multi_trigger =
+ void() base_multiple_fire =
{
- if (this.nextthink > time)
+ if (self.nextthink > time)
{
// already been triggered
- /*
- dprint ("base_multiple::multi_trigger: already been "
- "triggered\n");
- */
return;
}

- if (this.classtype == CT_TRIGGER_SECRET)
+ if (self.classtype == CT_TRIGGER_SECRET)
{
- if (this.enemy.classtype != CT_PLAYER)
+ if (self.enemy.classtype != CT_PLAYER)
return;
if (cutscene)
// Don't activate in cutscene mode
@@ -55,168 +75,158 @@ class base_multiple: base_trigger
WriteByte (MSG_ALL, SVC_FOUNDSECRET);
}

- if (this.noise != "")
- sound (this, CHAN_VOICE, this.noise, 1, ATTN_NORM);
+ if (self.noise != "")
+ sound (self, CHAN_VOICE, self.noise, 1, ATTN_NORM);

// don't trigger again until reset
- this.takedamage = DAMAGE_NO;
-
- activator = this.enemy;
+ self.takedamage = DAMAGE_NO;

- /*
- dprint ("base_multiple::multi_trigger: firing targets...\n");
- */
+ activator = self.enemy;
sub_usetargets ();

- if (this.wait > 0)
+ if (self.wait > 0)
{
- this.nextthink = time + this.wait;
- if (this.spawnflags & TRIGGER_MULTIPLE_TURNS_OFF)
+ self.think = base_multiple_think_wait;
+ self.nextthink = time + self.wait;
+ if (self.spawnflags & TRIGGER_MULTIPLE_TURNS_OFF)
{
- this.is_waiting = 1;
- sub_checkwaiting ();
+ self.is_waiting = 1;
+ sub_checkwaiting (self);
}
}
else
{
- // we can't just remove (self) here, because this
+ // we can't just remove (self) here, because self
// is a touch function called while C code is looping
// through area links...
- this.is_removed = TRUE;
- this.nextthink = time + 0.1;
+ self.touch = sub_null;
+ self.think = sub_remove;
+ self.nextthink = time + 0.1;
}
};

//--------------------------------------------------------------
// multi_killed; dumptruck_ds
//--------------------------------------------------------------
- virtual void() do_destroy =
+ void() base_multiple_destroy =
{
// Supa, restore health and do nothing if we're still
// waiting to be activated
- if (this.estate != STATE_ACTIVE)
+ if (self.estate != STATE_ACTIVE)
{
- this.health = this.max_health; // nyah nyah~!
- this.takedamage = DAMAGE_YES;
- this.solid = SOLID_BBOX;
+ self.health = self.max_health; // nyah nyah~!
+ self.takedamage = DAMAGE_YES;
+ self.solid = SOLID_BBOX;

return;
}

- this.enemy = damage_attacker;
- this.multi_trigger ();
- };
-
- //--------------------------------------------------------------
- virtual void() do_think =
- {
- if (this.is_removed == TRUE)
- {
- remove (this);
- }
- else
- {
- multi_wait ();
- }
+ self.enemy = damage_attacker;
+ base_multiple_fire ();
};

//--------------------------------------------------------------
// dumptruck_ds
//--------------------------------------------------------------
- virtual void(entity toucher) do_touch =
+ void() base_multiple_touch =
{
- if (this.is_removed == TRUE)
+ if (self.spawnflags & TRIGGER_MULTIPLE_NOTOUCH)
return;

- if (this.spawnflags & TRIGGER_MULTIPLE_NOTOUCH)
- return;
-
- if (toucher.classtype != CT_PLAYER)
+ if (other.classtype != CT_PLAYER)
return;

// from Copper -- dumptruck_ds
- if (toucher.movetype == MOVETYPE_NOCLIP)
+ if (other.movetype == MOVETYPE_NOCLIP)
return;

- if (this.estate != STATE_ACTIVE)
+ if (self.estate != STATE_ACTIVE)
return;

// if the trigger has an angles field, check player's
// facing direction
- if (this.movedir != '0 0 0')
+ if (self.movedir != '0 0 0')
{
- makevectors (toucher.angles);
- if (v_forward * this.movedir < 0)
+ makevectors (other.angles);
+ if (v_forward * self.movedir < 0)
// not facing the right way
return;
}

- this.enemy = toucher;
- this.multi_trigger ();
+ self.enemy = other;
+ base_multiple_fire ();
};

//--------------------------------------------------------------
// dumptruck_ds
//--------------------------------------------------------------
- virtual void(entity caller) do_use =
+ void() base_multiple_use =
{
- if (this.is_removed == TRUE)
- return;
-
- this.enemy = activator;
- this.multi_trigger ();
+ self.enemy = activator;
+ base_multiple_fire ();
};

//--------------------------------------------------------------
- nonvirtual void() multi_init =
+ void(entity e) base_multiple_init =
{
- this.is_removed = FALSE;
-
- if (this.sounds == 1)
+ if (e.sounds == 1)
{
precache_sound ("misc/secret.wav");
- this.noise = "misc/secret.wav";
+ e.noise = "misc/secret.wav";
}
- else if (this.sounds == 2)
+ else if (e.sounds == 2)
{
precache_sound ("misc/talk.wav");
- this.noise = "misc/talk.wav";
+ e.noise = "misc/talk.wav";
}
- else if (this.sounds == 3)
+ else if (e.sounds == 3)
{
precache_sound ("misc/trigger1.wav");
- this.noise = "misc/trigger1.wav";
+ e.noise = "misc/trigger1.wav";
}

- if (!this.wait)
+ if (!e.wait)
{
- this.wait = 0.2;
+ e.wait = 0.2;
}
- else if (this.wait < 0 &&
- (this.spawnflags & TRIGGER_MULTIPLE_TURNS_OFF))
+ else if (e.wait < 0 &&
+ (e.spawnflags & TRIGGER_MULTIPLE_TURNS_OFF))
{
- objerror ("Wait for retrigger and negative wait don't"
- " make sense");
+ objerror ("base_multiple_init: wait for retrigger "
+ "and negative wait don't make sense\n");
}

- init_trigger ();
+ e.use = base_multiple_use;

- if (this.health)
+ base_trigger_init (e);
+
+ if (e.health)
{
- if (this.spawnflags & TRIGGER_MULTIPLE_NOTOUCH)
- objerror ("health and notouch don't make "
- "sense\n");
- this.max_health = this.health;
- this.th_die = this.do_destroy;
- this.takedamage = DAMAGE_YES;
- this.solid = SOLID_BBOX;
+ if (e.spawnflags & TRIGGER_MULTIPLE_NOTOUCH)
+ objerror ("base_multiple_init: health "
+ "and notouch don't make sense\n");
+ e.max_health = e.health;
+ e.destroy = base_multiple_destroy;
+ e.takedamage = DAMAGE_YES;
+ e.solid = SOLID_BBOX;
// make sure it links into the world
- setorigin (this, this.origin);
+ setorigin (e, e.origin);
+ }
+ else
+ {
+ if (!(e.spawnflags & TRIGGER_MULTIPLE_NOTOUCH))
+ e.touch = base_multiple_touch;
}

- sub_checkwaiting ();
+ sub_checkwaiting (e);
};
-};
+
+ //--------------------------------------------------------------
+ strip void() base_multiple =
+ {
+ base_multiple_init (self);
+ };
+// };

/*QUAKED trigger_multiple (.5 .5 .5) ? notouch WAIT_FOR_RETRIGGER X X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY

@@ -233,20 +243,27 @@ sounds
set "message" to text string
"is_waiting" : If set to 1, this trigger will do nothing until another trigger activates it
*/
-class trigger_multiple: base_multiple
-{
+//----------------------------------------------------------------------
+// class trigger_multiple: base_multiple
+// {
//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) trigger_multiple_init =
{
- this.multi_init ();
+ e.classname = "trigger_multiple";
+ e.classtype = CT_TRIGGER_MULTIPLE;
+ base_multiple_init (e);
};

//--------------------------------------------------------------
void() trigger_multiple =
{
- this.classtype = CT_TRIGGER_MULTIPLE;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ trigger_multiple_init (self);
};
-};
+// };

/*QUAKED trigger_once (.5 .5 .5) ? notouch X X X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY

@@ -261,17 +278,25 @@ sounds
3) large switch
set "message" to text string
*/
-class trigger_once: base_multiple
-{
+//----------------------------------------------------------------------
+// class trigger_once: base_multiple
+// {
//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) trigger_once_init =
{
- this.wait = -1;
- this.multi_init ();
+ e.classname = "trigger_once";
+ e.classtype = CT_TRIGGER_ONCE;
+ e.wait = -1;
+ base_multiple_init (e);
};

+ //--------------------------------------------------------------
void() trigger_once =
{
- this.classtype = CT_TRIGGER_ONCE;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ trigger_once_init (self);
};
-};
+// };

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

Diff qc/triggers/onlyregistered.qc

diff --git a/qc/triggers/onlyregistered.qc b/qc/triggers/onlyregistered.qc
index 60e6c36..95e8cad 100644
--- a/qc/triggers/onlyregistered.qc
+++ b/qc/triggers/onlyregistered.qc
@@ -2,51 +2,73 @@
// trigger_onlyregistered -- ONLY REGISTERED TRIGGERS
//==============================================================================

+//======================================================================
+// forward declarations
+//======================================================================
+
+void() trigger_onlyregistered_touch;
+void(entity e) trigger_onlyregistered_init;
+void() trigger_onlyregistered;
+
+//------------------------------------------------------------------------------
+
/*QUAKED trigger_onlyregistered (.5 .5 .5) ?
Only fires if playing the registered version, otherwise prints the message
*/
-class trigger_onlyregistered: base_trigger
-{
+//----------------------------------------------------------------------
+// class trigger_onlyregistered: base_trigger
+// {
//--------------------------------------------------------------
- virtual void(entity toucher) do_touch =
+ void() trigger_onlyregistered_touch =
{
// from Copper -- dumptruck_ds
- if (sub_checkvalidtouch(toucher) == FALSE)
+ if (sub_checkvalidtouch(other) == FALSE)
return;

- if (this.attack_finished > time)
+ if (self.attack_finished > time)
return;

- this.attack_finished = time + 2;
+ self.attack_finished = time + 2;

if (cvar("registered"))
{
- this.message = "";
+ self.message = "";
sub_usetargets ();
- remove (this);
+ // changed to sub_remove -- CEV
+ // remove (self);
+ self.think = sub_remove;
+ self.nextthink = time + 0.1;
}
else
{
- if (this.message != "")
+ if (self.message != "")
{
- centerprint (toucher, this.message);
- sound (toucher, CHAN_BODY, "misc/talk.wav",
+ centerprint (other, self.message);
+ sound (other, CHAN_BODY, "misc/talk.wav",
1, ATTN_NORM);
}
}
};

//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) trigger_onlyregistered_init =
{
+ e.classname = "trigger_onlyregistered";
+ e.classtype = CT_TRIGGER_ONLYREGISTERED;
+ e.touch = trigger_onlyregistered_touch;
+
precache_sound ("misc/talk.wav");
- init_trigger ();
- sub_checkwaiting ();
+ base_trigger_init (e);
+ sub_checkwaiting (e);
};

//--------------------------------------------------------------
void() trigger_onlyregistered =
{
- this.classtype = CT_TRIGGER_ONLYREGISTERED;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ trigger_onlyregistered_init (self);
};
-};
+// };

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

Diff qc/triggers/push.qc

diff --git a/qc/triggers/push.qc b/qc/triggers/push.qc
index 4864ccc..995f4cd 100644
--- a/qc/triggers/push.qc
+++ b/qc/triggers/push.qc
@@ -2,12 +2,38 @@
// trigger_push -- id1 with additions by dumptruck_ds & CEV
////////////////////////////////////////////////////////////////////////////////

+//======================================================================
// constants
+//======================================================================
+
const float TRIGGER_PUSH_ONCE = 1; // only trigger once
const float TRIGGER_PUSH_STARTOFF = 8; // trigger will start off
const float TRIGGER_PUSH_SILENT = 16; // push silently
const float TRIGGER_PUSH_NOISE = 32; // use custom sound via noise key/value

+//======================================================================
+// forward declarations
+//======================================================================
+
+vector(float a, float b, float c) solve_quadratic;
+
+// base_trigger_push
+vector(vector org, entity tgt, float ht) base_trigger_push_calculatevelocity;
+void() base_trigger_push_findtarget;
+void() base_trigger_push_touch;
+
+// trigger_push
+// void() trigger_push_use;
+void(entity e) trigger_push_init;
+void() trigger_push;
+
+// trigger_push_custom
+void() trigger_push_custom_use;
+void(entity e) trigger_push_custom_init;
+void() trigger_push_custom;
+
+//------------------------------------------------------------------------------
+
//----------------------------------------------------------------------
// solve_quadratic -- from Nexuiz source code; original can be found at
// https://github.com/smlinux/nexuiz/blob/master/data/qcsrc/common/util.qc
@@ -67,25 +93,9 @@ vector(float a, float b, float c) solve_quadratic =
return v;
};

-//------------------------------------------------------------------------------
-class base_trigger_push: base_trigger
-{
- // class fields
- float height;
-
- //--------------------------------------------------------------
- virtual void(string fieldname, string fieldvalue) init_field =
- {
- switch (fieldname)
- {
- case "height":
- height = stof (fieldvalue);
- break;
- default:
- super::init_field (fieldname, fieldvalue);
- }
- };
-
+//----------------------------------------------------------------------
+// class base_trigger_push: base_trigger
+// {
//--------------------------------------------------------------
// trigger_push_calculatevelocity
//
@@ -103,7 +113,8 @@ class base_trigger_push: base_trigger
// copied from Nexuiz source code; original can be found here:
// github.com/smlinux/nexuiz/blob/master/data/qcsrc/server/t_jumppads.qc
//--------------------------------------------------------------
- nonvirtual vector(vector org, entity tgt, float ht) calculatevelocity =
+ vector(vector org, entity tgt, float ht)
+ base_trigger_push_calculatevelocity =
{
local float sdist, zdist, vs, vz, jumpheight;
local vector sdir, torg;
@@ -143,7 +154,7 @@ class base_trigger_push: base_trigger
*/

// push him so high... NOTE: sqrt(positive)!
- vz = sqrt (2 * frame_gravity * jumpheight);
+ vz = sqrt (2 * world_gravity * jumpheight);

// we start with downwards velocity only if it's a downjump
// and the jump apex should be outside the jump!
@@ -152,7 +163,7 @@ class base_trigger_push: base_trigger
vz = -vz;

// equation "z(ti) = zdist"
- solution = solve_quadratic (0.5 * frame_gravity, -vz, zdist);
+ solution = solve_quadratic (0.5 * world_gravity, -vz, zdist);
// ALWAYS solvable because jumpheight >= zdist
if (!solution_z)
// just in case it is not solvable due to roundoff
@@ -208,124 +219,133 @@ class base_trigger_push: base_trigger
};

//--------------------------------------------------------------
- nonvirtual void() findtarget =
+ void() base_trigger_push_findtarget =
{
- this.enemy = find (world, ::targetname, this.target);
- if (this.enemy)
+ self.enemy = find (world, targetname, self.target);
+ if (self.enemy)
{
local vector org;
- org = (this.absmin + this.absmax) * 0.5;
- org_z = this.absmax_z - -24; // - PL_MIN_z;
- this.movedir = this.calculatevelocity (org,
- this.enemy, this.height);
+ org = (self.absmin + self.absmax) * 0.5;
+ org_z = self.absmax_z - -24; // - PL_MIN_z;
+ self.movedir = base_trigger_push_calculatevelocity (
+ org, self.enemy, self.height);
}
};

//--------------------------------------------------------------
- virtual void(entity toucher) do_touch =
+ void() base_trigger_push_touch =
{
- if (this.estate != STATE_ACTIVE)
+ if (self.estate != STATE_ACTIVE)
return;

// from Copper -- dumptruck_ds
- if (toucher.movetype == MOVETYPE_NOCLIP)
+ if (other.movetype == MOVETYPE_NOCLIP)
return;

// try to find target again if necessary
- if (this.target && (!this.enemy))
- this.findtarget ();
+ if (self.target && (!self.enemy))
+ base_trigger_push_findtarget ();

// we have a target, set movedir accordingly
- if (this.target && this.enemy)
- this.movedir = this.calculatevelocity (toucher.origin,
- this.enemy, this.height);
+ if (self.target && self.enemy)
+ self.movedir = base_trigger_push_calculatevelocity (
+ other.origin, self.enemy, self.height);

- if (toucher.classtype == CT_PROJECTILE_GRENADE)
+ if (other.classtype == CT_PROJECTILE_GRENADE)
{
- if (this.target && this.enemy)
- toucher.velocity = this.movedir;
+ if (self.target && self.enemy)
+ other.velocity = self.movedir;
else
- toucher.velocity = speed * movedir * 10;
+ other.velocity = self.speed * self.movedir * 10;
}
- else if (toucher.health > 0)
+ else if (other.health > 0)
{
- if (this.target && this.enemy)
- toucher.velocity = movedir;
+ if (self.target && self.enemy)
+ other.velocity = self.movedir;
else
- toucher.velocity = speed * movedir * 10;
+ other.velocity = self.speed * self.movedir * 10;

- if (toucher.classtype == CT_PLAYER &&
- !(this.spawnflags & TRIGGER_PUSH_SILENT))
+ if (other.classtype == CT_PLAYER &&
+ !(self.spawnflags & TRIGGER_PUSH_SILENT))
{
- if (toucher.fly_sound < time)
+ if (other.fly_sound < time)
{
- if (!(this.spawnflags &
+ if (!(self.spawnflags &
TRIGGER_PUSH_NOISE))
{
- toucher.fly_sound = time + 1.5;
- sound (toucher, CHAN_AUTO,
+ other.fly_sound = time + 1.5;
+ sound (other, CHAN_AUTO,
"ambience/windfly.wav",
1, ATTN_NORM);
}
else
{
- toucher.fly_sound = time + 1.5;
- sound (toucher, CHAN_AUTO,
- this.noise,
+ other.fly_sound = time + 1.5;
+ sound (other, CHAN_AUTO,
+ self.noise,
1, ATTN_NORM);
}
}
}
}

- if (this.spawnflags & TRIGGER_PUSH_ONCE)
- remove (this);
+ if (self.spawnflags & TRIGGER_PUSH_ONCE)
+ remove (self);
};
-};
+// };

/*QUAKED trigger_push (.5 .5 .5) ? TRIGGER_PUSH_ONCE X X X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
Pushes the player
*/
-class trigger_push: base_trigger_push
-{
+//----------------------------------------------------------------------
+// class trigger_push: base_trigger_push
+// {
//--------------------------------------------------------------
// dumptruck_ds
//--------------------------------------------------------------
/*
- virtual void() push_use =
+ void() trigger_push_use =
{
- this.is_waiting = !this.is_waiting;
+ sel.is_waiting = !self.is_waiting;
}
*/

//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) trigger_push_init =
{
- init_trigger ();
+ e.classname = "trigger_push";
+ e.classtype = CT_TRIGGER_PUSH;
+ e.touch = base_trigger_push_touch;
+
+ base_trigger_init (e);
precache_sound ("ambience/windfly.wav");

- if (!this.speed)
- this.speed = 1000;
+ if (!e.speed)
+ e.speed = 1000;

- if (this.target != __NULL__ && this.target != "")
+ if (e.target != __NULL__ && e.target != "")
{
// attempt to find the target
- this.findtarget ();
- if (!this.enemy)
- if (!this.movedir)
+ base_trigger_push_findtarget ();
+ if (!e.enemy)
+ if (!e.movedir)
// TODO CEV is this up? I don't remember
- this.movedir = '0 0 180';
+ e.movedir = '0 0 180';
}

- sub_checkwaiting ();
+ sub_checkwaiting (e);
};

//--------------------------------------------------------------
void() trigger_push =
{
- this.classtype = CT_TRIGGER_PUSH;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ trigger_push_init (self);
};
-};
+// };

/*QUAKED trigger_push_custom (.5 .5 .5) ? TRIGGER_PUSH_ONCE TRIGGER_PUSH_STARTOFF TRIGGER_PUSH_SILENT X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY

@@ -343,40 +363,60 @@ off" sounds NOT be looping.

Adapted from Hipnotic's func_togglewall
*/
-class trigger_push_custom: base_trigger_push
-{
+//----------------------------------------------------------------------
+// class trigger_push_custom: base_trigger_push
+// {
//--------------------------------------------------------------
// dumptruck_ds was based on hipnotic blocker_use now Alkaline estate
//--------------------------------------------------------------
- virtual void(entity caller) do_use =
+ void() trigger_push_custom_use =
{
- if (this.estate != STATE_ACTIVE)
- this.estate = STATE_ACTIVE;
+ if (self.estate != STATE_ACTIVE)
+ self.estate = STATE_ACTIVE;
else
- this.estate = STATE_INACTIVE;
+ self.estate = STATE_INACTIVE;
};

//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) trigger_push_custom_init =
{
- init_trigger ();
+ e.classname = "trigger_push_custom";
+ e.classtype = CT_TRIGGER_PUSH_CUSTOM;
+ e.touch = base_trigger_push_touch;
+ e.use = trigger_push_custom_use;
+
+ base_trigger_init (e);
precache_sound ("ambience/windfly.wav");

- if (this.spawnflags & TRIGGER_PUSH_STARTOFF)
- this.estate = STATE_INACTIVE;
+ if (e.spawnflags & TRIGGER_PUSH_STARTOFF)
+ e.estate = STATE_INACTIVE;

- if (this.noise != "")
- precache_sound (this.noise);
+ if (e.noise != "")
+ precache_sound (e.noise);

- if (!this.speed)
- this.speed = 1000;
+ if (!e.speed)
+ e.speed = 1000;

- sub_checkwaiting ();
+ if (e.target != __NULL__ && e.target != "")
+ {
+ // attempt to find the target
+ base_trigger_push_findtarget ();
+ if (!e.enemy)
+ if (!e.movedir)
+ // TODO CEV is this up? I don't remember
+ e.movedir = '0 0 180';
+ }
+
+ sub_checkwaiting (e);
};

//--------------------------------------------------------------
void() trigger_push_custom =
{
- this.classtype = CT_TRIGGER_PUSH_CUSTOM;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ trigger_push_custom_init (self);
};
-};
+// };

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

Diff qc/triggers/relay.qc

diff --git a/qc/triggers/relay.qc b/qc/triggers/relay.qc
index 61e6641..36db7e1 100644
--- a/qc/triggers/relay.qc
+++ b/qc/triggers/relay.qc
@@ -2,23 +2,48 @@
// trigger_relay
//==============================================================================

+//======================================================================
+// forward declarations
+//======================================================================
+
+// trigger_relay
+// void() trigger_relay_use;
+void(entity e) trigger_relay_init;
+void() trigger_relay;
+
+//------------------------------------------------------------------------------
+
/*QUAKED trigger_relay (.5 .5 .5) (-8 -8 -8) (8 8 8) X X X X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
This fixed size trigger cannot be touched, it can only be fired by other events. It can contain killtargets, targets, delays, and messages.
*/
-class trigger_relay: base_trigger
-{
+//----------------------------------------------------------------------
+// class trigger_relay: base_trigger
+// {
+ /*
//--------------------------------------------------------------
- virtual void(entity caller) do_use =
+ void() trigger_relay_use =
{
sub_usetargets ();
};
+ */

//--------------------------------------------------------------
- virtual void() init_spawned = { };
+ void(entity e) trigger_relay_init =
+ {
+ e.classname = "trigger_relay";
+ e.classtype = CT_TRIGGER_RELAY;
+ e.use = sub_usetargets;
+
+ base_trigger_init (e);
+ };

//-------------------------------------------------------------
void() trigger_relay =
{
- this.classtype = CT_TRIGGER_RELAY;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ trigger_relay_init (self);
};
-};
+// };

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

Diff qc/triggers/secret.qc

diff --git a/qc/triggers/secret.qc b/qc/triggers/secret.qc
index 83b5d6a..3e562f2 100644
--- a/qc/triggers/secret.qc
+++ b/qc/triggers/secret.qc
@@ -2,6 +2,15 @@
// trigger_secret
//==============================================================================

+//======================================================================
+// forward declarations
+//======================================================================
+
+void(entity e) trigger_secret_init;
+void() trigger_secret;
+
+//------------------------------------------------------------------------------
+
/*QUAKED trigger_secret (.5 .5 .5) ? X X X X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
secret counter trigger
sounds
@@ -9,37 +18,45 @@ sounds
2) beep beep
set "message" to text string
*/
-class trigger_secret: base_multiple
-{
+//----------------------------------------------------------------------
+// class trigger_secret: base_multiple
+// {
//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) trigger_secret_init =
{
+ e.classname = "trigger_secret";
+ e.classtype = CT_TRIGGER_SECRET;
+
total_secrets = total_secrets + 1;
- this.wait = -1;
+ e.wait = -1;

- if (!this.message)
- this.message = "You found a secret area!";
+ if (!e.message)
+ e.message = "You found a secret area!";

- if (!this.sounds)
- this.sounds = 1;
+ if (!e.sounds)
+ e.sounds = 1;

- if (this.sounds == 1)
+ if (e.sounds == 1)
{
precache_sound ("misc/secret.wav");
- this.noise = "misc/secret.wav";
+ e.noise = "misc/secret.wav";
}
- else if (this.sounds == 2)
+ else if (e.sounds == 2)
{
precache_sound ("misc/talk.wav");
- this.noise = "misc/talk.wav";
+ e.noise = "misc/talk.wav";
}

- this.multi_init ();
+ base_multiple_init (e);
};

//--------------------------------------------------------------
void() trigger_secret =
{
- this.classtype = CT_TRIGGER_SECRET;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ trigger_secret_init (self);
};
-};
+// };

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

Diff qc/triggers/setcount.qc

diff --git a/qc/triggers/setcount.qc b/qc/triggers/setcount.qc
index 8cb517d..1db6c75 100644
--- a/qc/triggers/setcount.qc
+++ b/qc/triggers/setcount.qc
@@ -2,64 +2,75 @@
// target_setcount
//==============================================================================

+//======================================================================
+// forward declarations
+//======================================================================
+
+void(string name, .string fld) target_setcount_set;
+void() target_setcount_use;
+void(entity e) target_setcount_init;
+void() target_setcount;
+
//------------------------------------------------------------------------------
+
+//----------------------------------------------------------------------
// target_setcount
-//------------------------------------------------------------------------------
-class target_setcount: base_trigger
-{
+//----------------------------------------------------------------------
+// class target_setcount: base_trigger
+// {
//--------------------------------------------------------------
- nonvirtual void(string name, .string fld) setcount_set =
+ void(string name, .string fld) target_setcount_set =
{
local entity t;

- t = find (world, ::fld, name);
+ t = find (world, fld, name);

while (t)
{
- if (this.style == 1)
- t.count += this.count;
+ if (self.style == 1)
+ t.count += self.count;
else
- t.count = this.count;
+ t.count = self.count;

- t = find (t, ::fld, name);
+ t = find (t, fld, name);
}
};

//--------------------------------------------------------------
- virtual void(entity caller) do_use =
+ void() target_setcount_use =
{
- if (this.target && this.target != "")
+ if (self.target && self.target != "")
{
- this.setcount_set (this.target, ::targetname);
- this.setcount_set (this.target, ::targetname2);
- this.setcount_set (this.target, ::targetname3);
- this.setcount_set (this.target, ::targetname4);
+ target_setcount_set (self.target, targetname);
+ target_setcount_set (self.target, targetname2);
+ target_setcount_set (self.target, targetname3);
+ target_setcount_set (self.target, targetname4);
}
- if (this.target2 && this.target2 != "")
+ if (self.target2 && self.target2 != "")
{
- this.setcount_set (this.target2, ::targetname);
- this.setcount_set (this.target2, ::targetname2);
- this.setcount_set (this.target2, ::targetname3);
- this.setcount_set (this.target2, ::targetname4);
+ target_setcount_set (self.target2, targetname);
+ target_setcount_set (self.target2, targetname2);
+ target_setcount_set (self.target2, targetname3);
+ target_setcount_set (self.target2, targetname4);
}
- if (this.target3 && this.target3 != "")
+ if (self.target3 && self.target3 != "")
{
- this.setcount_set (this.target3, ::targetname);
- this.setcount_set (this.target3, ::targetname2);
- this.setcount_set (this.target3, ::targetname3);
- this.setcount_set (this.target3, ::targetname4);
+ target_setcount_set (self.target3, targetname);
+ target_setcount_set (self.target3, targetname2);
+ target_setcount_set (self.target3, targetname3);
+ target_setcount_set (self.target3, targetname4);
}
- if (this.target4 && this.target4 != "")
+ if (self.target4 && self.target4 != "")
{
- this.setcount_set (this.target4, ::targetname);
- this.setcount_set (this.target4, ::targetname2);
- this.setcount_set (this.target4, ::targetname3);
- this.setcount_set (this.target4, ::targetname4);
+ target_setcount_set (self.target4, targetname);
+ target_setcount_set (self.target4, targetname2);
+ target_setcount_set (self.target4, targetname3);
+ target_setcount_set (self.target4, targetname4);
}

- if (this.spawnflags & 1)
+ if (self.spawnflags & 1)
{
- if (this.style == 1)
+ if (self.style == 1)
activator.count += activator.count;
else
activator.count = activator.count;
@@ -67,11 +78,21 @@ class target_setcount: base_trigger
};

//--------------------------------------------------------------
- virtual void() init_spawned = { };
+ void(entity e) target_setcount_init =
+ {
+ e.classname = "target_setcount";
+ e.classtype = CT_TARGET_SETCOUNT;
+ e.use = target_setcount_use;
+ base_mapentity_init (e);
+ };

//--------------------------------------------------------------
void() target_setcount =
{
- this.classtype = CT_TARGET_SETCOUNT;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ target_setcount_init (self);
};
-};
+// };

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

Diff qc/triggers/setgravity.qc

diff --git a/qc/triggers/setgravity.qc b/qc/triggers/setgravity.qc
index d0c599d..154cbbc 100644
--- a/qc/triggers/setgravity.qc
+++ b/qc/triggers/setgravity.qc
@@ -10,9 +10,24 @@
Distributed (unsupported) on 3.12.97
*/

+//======================================================================
// constants
+//======================================================================
+
const float TRIGGER_SETGRAVITY_STARTOFF = 8; // trigger will start off

+//======================================================================
+// forward declarations
+//======================================================================
+
+// trigger_setgravity
+void() trigger_setgravity_touch;
+void() trigger_setgravity_use;
+void(entity e) trigger_setgravity_init;
+void() trigger_setgravity;
+
+//------------------------------------------------------------------------------
+
/*QUAKED trigger_setgravity (.5 .5 .5) ? X X X X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
set the gravity of a player

@@ -36,20 +51,21 @@ set the gravity of a player
triggers not to work properly.

*/
-class trigger_setgravity: base_trigger
-{
+//----------------------------------------------------------------------
+// class trigger_setgravity: base_trigger
+// {
//--------------------------------------------------------------
// from Copper -- dumptruck_ds
//--------------------------------------------------------------
- virtual void(entity toucher) do_touch =
+ void() trigger_setgravity_touch =
{
// from Copper -- dumptruck_ds
/*
- if (sub_checkvalidtouch(toucher) == FALSE)
+ if (sub_checkvalidtouch(other) == FALSE)
return;
*/

- if (this.estate != STATE_ACTIVE)
+ if (self.estate != STATE_ACTIVE)
return;

local float grav;
@@ -57,54 +73,63 @@ class trigger_setgravity: base_trigger
// This is commented out so that the changing gravity will
// affect everything, if you don't want to use all affecting
// gravity changes, then uncomment these two lines.
- // if (toucher.classtype != CT_PLAYER)
+ // if (other.classtype != CT_PLAYER)
// return;

- if (this.gravity == -1)
+ if (self.gravity == -1)
grav = 1;
else
- grav = this.gravity;
+ grav = self.gravity;

// the player's gravity is now managed in PlayerPreThink(),
// however other entities don't have special gravity
// management, so their gravity is still set directly -- iw
- if (toucher.classtype == CT_PLAYER)
- toucher.wantedgravity = grav;
+ if (other.classtype == CT_PLAYER)
+ other.wantedgravity = grav;
else
- toucher.gravity = grav;
+ other.gravity = grav;
};

//--------------------------------------------------------------
// dumptruck_ds based on hipnotic blocker_use
//--------------------------------------------------------------
- virtual void(entity caller) do_use =
+ void() trigger_setgravity_use =
{
- if (this.estate != STATE_ACTIVE)
- this.estate = STATE_ACTIVE;
+ if (self.estate != STATE_ACTIVE)
+ self.estate = STATE_ACTIVE;
else
- this.estate = STATE_INACTIVE;
+ self.estate = STATE_INACTIVE;
};

//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) trigger_setgravity_init =
{
- init_trigger ();
+ e.classname = "trigger_setgravity";
+ e.classtype = CT_TRIGGER_SETGRAVITY;
+ e.touch = trigger_setgravity_touch;
+ e.use = trigger_setgravity_use;
+
+ base_trigger_init (e);

// dumptruck_ds
- if (this.spawnflags & TRIGGER_SETGRAVITY_STARTOFF)
- this.estate = STATE_INACTIVE;
+ if (e.spawnflags & TRIGGER_SETGRAVITY_STARTOFF)
+ e.estate = STATE_INACTIVE;

- if (!this.gravity)
- this.gravity = -1;
+ if (!e.gravity)
+ e.gravity = -1;
else
- this.gravity = ((this.gravity - 1) / 100);
+ e.gravity = ((e.gravity - 1) / 100);

- sub_checkwaiting ();
+ sub_checkwaiting (e);
};

//--------------------------------------------------------------
void() trigger_setgravity =
{
- this.classtype = CT_TRIGGER_SETGRAVITY;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ trigger_setgravity_init (self);
};
-};
+// };

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

Diff qc/triggers/setskill.qc

diff --git a/qc/triggers/setskill.qc b/qc/triggers/setskill.qc
index 0e32d91..149e2ed 100644
--- a/qc/triggers/setskill.qc
+++ b/qc/triggers/setskill.qc
@@ -2,32 +2,52 @@
// trigger_setskill
//==============================================================================

+//======================================================================
+// forward declarations
+//======================================================================
+
+// trigger_setskill
+void() trigger_setskill_touch;
+void(entity e) trigger_setskill_init;
+void() trigger_setskill;
+
+//------------------------------------------------------------------------------
+
/*QUAKED trigger_setskill (.5 .5 .5) ? X X X X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
sets skill level to the value of "message".
Only used on start map.
*/
-class trigger_setskill: base_trigger
-{
+//----------------------------------------------------------------------
+// class trigger_setskill: base_trigger
+// {
//--------------------------------------------------------------
- virtual void(entity toucher) do_touch =
+ void() trigger_setskill_touch =
{
// from Copper -- dumptruck_ds
- if (sub_checkvalidtouch(toucher) == FALSE)
+ if (sub_checkvalidtouch(other) == FALSE)
return;

- cvar_set ("skill", this.message);
+ cvar_set ("skill", self.message);
};

//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) trigger_setskill_init =
{
- init_trigger ();
- sub_checkwaiting ();
+ e.classname = "trigger_setskill";
+ e.classtype = CT_TRIGGER_SETSKILL;
+ e.touch = trigger_setskill_touch;
+
+ base_trigger_init (e);
+ sub_checkwaiting (e);
};

//--------------------------------------------------------------
void() trigger_setskill =
{
- this.classtype = CT_TRIGGER_SETSKILL;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ trigger_setskill_init (self);
};
-};
+// };

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

Diff qc/triggers/setstate.qc

diff --git a/qc/triggers/setstate.qc b/qc/triggers/setstate.qc
index 70b602a..2dcf706 100644
--- a/qc/triggers/setstate.qc
+++ b/qc/triggers/setstate.qc
@@ -2,18 +2,38 @@
// target_setstate
//==============================================================================

-// constants for setstate
+//======================================================================
+// constants
+//======================================================================
+
const float SETSTATE_STARTOFF = 1;
const float SETSTATE_CLOSEALLDOORS = 2;
const float SETSTATE_DONTRESETBUTTON = 4;

-//------------------------------------------------------------------------------
+//======================================================================
+// forward declarations
+//======================================================================
+
// target_setstate
+float(entity e) target_setstate_getestate;
+void(entity e, float state, float flags) target_setstate_setestate;
+void(string matchstring, .string matchfield, float state, float flags)
+ target_setstate_settarget;
+void(float state) target_setstate_setalltargets;
+void() target_setstate_use;
+void() target_setstate_think_startoff;
+void(entity e) target_setstate_init;
+void() target_setstate;
+
//------------------------------------------------------------------------------
-class target_setstate: base_trigger
-{
+
+//----------------------------------------------------------------------
+// target_setstate
+//----------------------------------------------------------------------
+// class target_setstate: base_trigger
+// {
//--------------------------------------------------------------
- nonvirtual float(entity e) entity_get_state =
+ float(entity e) target_setstate_getestate =
{
if (e.classtype == CT_FUNC_DOOR)
return e.estate;
@@ -22,32 +42,27 @@ class target_setstate: base_trigger
};

//--------------------------------------------------------------
- nonvirtual void(entity e, float state, float flags) entity_set_state =
+ void(entity e, float state, float flags) target_setstate_setestate =
{
float closealldoors = 0;

if (e.classtype == CT_FUNC_BUTTON)
{
- // cast to func_button -- CEV
- local func_button b = (func_button)e;
if (state == STATE_ACTIVE)
- b.button_unlock (b, flags &
- SETSTATE_DONTRESETBUTTON);
+ func_button_unlock (e,
+ flags & SETSTATE_DONTRESETBUTTON);
else
- b.button_lock (b);
+ func_button_lock (e);
}
else if (e.classtype == CT_FUNC_DOOR)
{
- // cast to func_door -- CEV
- local func_door d = (func_door)e;
-
if (flags & SETSTATE_CLOSEALLDOORS)
closealldoors = 1;

if (state == STATE_ACTIVE)
- d.estate_unlock (d, closealldoors);
+ func_door_estate_unlock (e, closealldoors);
else
- d.estate_lock (d, closealldoors);
+ func_door_estate_lock (e, closealldoors);
}
else
{
@@ -56,14 +71,13 @@ class target_setstate: base_trigger

if (e.classgroup & CG_TRIGGER)
{
- local base_trigger bt = (base_trigger)e;
-
- if (bt.is_waiting > 0 && state == STATE_ACTIVE)
+ if (e.is_waiting > 0 && state == STATE_ACTIVE)
{
- base_trigger::sub_endwaiting ((base_trigger)e);
+ sub_runvoidas (e, sub_endwaiting);
}
}

+ // commented out in progs_dump 3 -- CEV
/*
if (e.touch && e.touch != __NULL__)
{
@@ -73,123 +87,129 @@ class target_setstate: base_trigger
};

//--------------------------------------------------------------
- nonvirtual void(string matchstring, .string matchfield, float state,
- float flags) set_target =
+ void(string matchstring, .string matchfield, float state, float flags)
+ target_setstate_settarget =
{
local entity t;

- t = find (world, ::matchfield, matchstring);
+ t = find (world, matchfield, matchstring);
while (t != world)
{
if (state == -1)
{
- if (this.entity_get_state(t) == STATE_ACTIVE)
- this.entity_set_state (t,
+ if (target_setstate_getestate(t)==STATE_ACTIVE)
+ target_setstate_setestate (t,
STATE_INACTIVE, flags);
else
- this.entity_set_state (t,
+ target_setstate_setestate (t,
STATE_ACTIVE, flags);
}
else
{
- this.entity_set_state (t, state, flags);
+ target_setstate_setestate (t, state, flags);
}

- t = find (t, ::matchfield, matchstring);
+ t = find (t, matchfield, matchstring);
}
};

//--------------------------------------------------------------
- nonvirtual void(float state) set_alltargets =
+ void(float state) target_setstate_setalltargets =
{
- if (this.target && this.target != "")
+ if (self.target && self.target != "")
{
- this.set_target (this.target, ::targetname,
- state, this.spawnflags);
- this.set_target (this.target, ::targetname2,
- state, this.spawnflags);
- this.set_target (this.target, ::targetname3,
- state, this.spawnflags);
- this.set_target (this.target, ::targetname4,
- state, this.spawnflags);
+ target_setstate_settarget (self.target, targetname,
+ state, self.spawnflags);
+ target_setstate_settarget (self.target, targetname2,
+ state, self.spawnflags);
+ target_setstate_settarget (self.target, targetname3,
+ state, self.spawnflags);
+ target_setstate_settarget (self.target, targetname4,
+ state, self.spawnflags);
}
- if (this.target2 && this.target2 != "")
+ if (self.target2 && self.target2 != "")
{
- this.set_target (this.target2, ::targetname,
- state, this.spawnflags);
- this.set_target (this.target2, ::targetname2,
- state, this.spawnflags);
- this.set_target (this.target2, ::targetname3,
- state, this.spawnflags);
- this.set_target (this.target2, ::targetname4,
- state, this.spawnflags);
+ target_setstate_settarget (self.target2, targetname,
+ state, self.spawnflags);
+ target_setstate_settarget (self.target2, targetname2,
+ state, self.spawnflags);
+ target_setstate_settarget (self.target2, targetname3,
+ state, self.spawnflags);
+ target_setstate_settarget (self.target2, targetname4,
+ state, self.spawnflags);
}
- if (this.target3 && this.target3 != "")
+ if (self.target3 && self.target3 != "")
{
- this.set_target (this.target3, ::targetname,
- state, this.spawnflags);
- this.set_target (this.target3, ::targetname2,
- state, this.spawnflags);
- this.set_target (this.target3, ::targetname3,
- state, this.spawnflags);
- this.set_target (this.target3, ::targetname4,
- state, this.spawnflags);
+ target_setstate_settarget (self.target3, targetname,
+ state, self.spawnflags);
+ target_setstate_settarget (self.target3, targetname2,
+ state, self.spawnflags);
+ target_setstate_settarget (self.target3, targetname3,
+ state, self.spawnflags);
+ target_setstate_settarget (self.target3, targetname4,
+ state, self.spawnflags);
}
- if (this.target4 && this.target4 != "")
+ if (self.target4 && self.target4 != "")
{
- this.set_target (this.target4, ::targetname,
- state, this.spawnflags);
- this.set_target (this.target4, ::targetname2,
- state, this.spawnflags);
- this.set_target (this.target4, ::targetname3,
- state, this.spawnflags);
- this.set_target (this.target4, ::targetname4,
- state, this.spawnflags);
+ target_setstate_settarget (self.target4, targetname,
+ state, self.spawnflags);
+ target_setstate_settarget (self.target4, targetname2,
+ state, self.spawnflags);
+ target_setstate_settarget (self.target4, targetname3,
+ state, self.spawnflags);
+ target_setstate_settarget (self.target4, targetname4,
+ state, self.spawnflags);
}
};

//--------------------------------------------------------------
- virtual void(entity caller) do_use =
+ void() target_setstate_use =
{
local float state;

- if (this.style == 1)
+ if (self.style == 1)
state = STATE_ACTIVE;
- else if (this.style == 2)
+ else if (self.style == 2)
state = STATE_INACTIVE;
else
state = -1;

- this.set_alltargets (state);
+ target_setstate_setalltargets (state);
};

//--------------------------------------------------------------
// was setstate_startoff_think
//--------------------------------------------------------------
- virtual void(entity caller) setstate_startoff_think =
+ void() target_setstate_think_startoff =
{
- if (this.spawnflags & SETSTATE_STARTOFF)
- this.set_alltargets (STATE_INACTIVE);
+ if (self.spawnflags & SETSTATE_STARTOFF)
+ target_setstate_setalltargets (STATE_INACTIVE);
};

//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) target_setstate_init =
{
- if (this.spawnflags & SETSTATE_STARTOFF)
+ e.classname = "target_setstate";
+ e.classtype = CT_TARGET_SETSTATE;
+ e.use = target_setstate_use;
+
+ base_mapentity_init (e);
+
+ if (e.spawnflags & SETSTATE_STARTOFF)
{
// wait a bit while doors finish being set up
- this.interaction_flags &= ~DISABLE_THINK;
- this.nextthink = time + 0.2;
- }
- else
- {
- this.interaction_flags |= DISABLE_THINK;
+ e.think = target_setstate_think_startoff;
+ e.nextthink = time + 0.2;
}
};

//--------------------------------------------------------------
void() target_setstate =
{
- this.classtype = CT_TARGET_SETSTATE;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ target_setstate_init (self);
};
-};
+// };

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

Diff qc/triggers/shake.qc

diff --git a/qc/triggers/shake.qc b/qc/triggers/shake.qc
index 7ecf9b7..c67ca3d 100644
--- a/qc/triggers/shake.qc
+++ b/qc/triggers/shake.qc
@@ -2,9 +2,24 @@
// trigger_shake -- point entity from Rubicon Rumble Pack; requires TARGETNAME
//==============================================================================

+//======================================================================
// constants
+//======================================================================
+
const float TRIGGER_SHAKE_VIEWONLY = 1;

+//======================================================================
+// forward declarations
+//======================================================================
+
+// trigger_shake
+void() trigger_shake_think;
+void() trigger_shake_use;
+void(entity e) trigger_shake_init;
+void() trigger_shake;
+
+//------------------------------------------------------------------------------
+
/*QUAKED trigger_shake (.5 0 .5) (-8 -8 -8) (8 8 8) TRIGGER_SHAKE_VIEWONLY X X X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY

Earthquake trigger - shakes players in it's radius when active.
@@ -18,20 +33,21 @@ targetname Must be triggered
Spawnflags
TRIGGER_SHAKE_VIEWONLY Shakes the view, but player movement is not affected
*/
-class trigger_shake: base_trigger
-{
+//----------------------------------------------------------------------
+// class trigger_shake: base_trigger
+// {
//--------------------------------------------------------------
// was shake_think
//--------------------------------------------------------------
- virtual void() do_think =
+ void() trigger_shake_think =
{
- if (this.attack_finished < time)
+ if (self.attack_finished < time)
{
// Done
- this.nextthink = -1;
+ self.nextthink = -1;

- if (this.noise1 != "")
- sound (this, CHAN_VOICE, this.noise1,
+ if (self.noise1 != "")
+ sound (self, CHAN_VOICE, self.noise1,
1, ATTN_NORM);

return;
@@ -39,7 +55,7 @@ class trigger_shake: base_trigger

// Shake all players in the effect radius...
local entity p;
- p = findradius (this.origin, this.count);
+ p = findradius (self.origin, self.count);

while (p)
{
@@ -48,21 +64,21 @@ class trigger_shake: base_trigger
local float d;

// Scale effect by distance
- d = vlen (this.origin - p.origin);
- d = (this.count - d) / this.count;
+ d = vlen (self.origin - p.origin);
+ d = (self.count - d) / self.count;

if (d > 0)
{
// shake up the view
p.punchangle_x = -1 * (random() +
- (0.025 * this.dmg * d));
+ (0.025 * self.dmg * d));

// push the player around
if (p.flags & FL_ONGROUND
- && !(this.spawnflags &
+ && !(self.spawnflags &
TRIGGER_SHAKE_VIEWONLY))
{
- d = this.dmg * d;
+ d = self.dmg * d;
p.velocity_x = p.velocity_x +
(random() * d * 2 - d);
p.velocity_y = p.velocity_y +
@@ -77,50 +93,60 @@ class trigger_shake: base_trigger
}

// keep going
- this.nextthink = time + 0.1;
+ self.nextthink = time + 0.1;
};

//--------------------------------------------------------------
- virtual void(entity caller) do_use =
+ void() trigger_shake_use =
{
// already active
- if (this.attack_finished > time)
+ if (self.attack_finished > time)
return;

// Start...
- if (this.noise != "")
- sound (this, CHAN_VOICE, this.noise, 1, ATTN_NORM);
+ if (self.noise != "")
+ sound (self, CHAN_VOICE, self.noise, 1, ATTN_NORM);

- this.attack_finished = time + this.wait;
- this.nextthink = time + 0.1;
+ self.attack_finished = time + self.wait;
+ self.nextthink = time + 0.1;
};

//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) trigger_shake_init =
{
- if (!this.targetname)
+ e.classname = "trigger_shake";
+ e.classtype = CT_TRIGGER_SHAKE;
+
+ if (!e.targetname)
objerror ("trigger_shake without name");

- if (this.noise != "")
- precache_sound (this.noise);
- if (this.noise1 != "")
- precache_sound (this.noise1);
-
- if (!this.dmg)
- this.dmg = 120;
- if (this.count <= 0)
- this.count = 200;
- if (this.wait <= 0)
- this.wait = 1.0;
-
- setorigin (this, this.origin);
- // this.interaction_flags &= ~DISABLE_THINK;
- this.nextthink = -1;
+ if (e.noise != "")
+ precache_sound (e.noise);
+ if (e.noise1 != "")
+ precache_sound (e.noise1);
+
+ if (!e.dmg)
+ e.dmg = 120;
+ if (e.count <= 0)
+ e.count = 200;
+ if (e.wait <= 0)
+ e.wait = 1.0;
+
+ base_trigger_init (e);
+
+ setorigin (e, e.origin);
+ e.think = trigger_shake_think;
+ e.use = trigger_shake_use;
+ e.nextthink = -1;
};

//--------------------------------------------------------------
void() trigger_shake =
{
- this.classtype = CT_TRIGGER_SHAKE;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ trigger_shake_init (self);
};
-};
+// };

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

Diff qc/triggers/take_weapon.qc

diff --git a/qc/triggers/take_weapon.qc b/qc/triggers/take_weapon.qc
index dc401e5..271db21 100644
--- a/qc/triggers/take_weapon.qc
+++ b/qc/triggers/take_weapon.qc
@@ -7,48 +7,68 @@
// This is Axe only at the moment. Need to research removing all weapons.
//======================================================================

+//======================================================================
+// forward declarations
+//======================================================================
+
+void() trigger_take_weapon_touch;
+void(entity e) trigger_take_weapon_init;
+void() trigger_take_weapon;
+
+//------------------------------------------------------------------------------
+
/*QUAKED trigger_take_weapon (.5 .5 .5) ? X X X X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY

Removes shotgun upon touch. You can also set "reset_items" in the worldspawn entity to accomplish an axe only start.
*/
-class trigger_take_weapon: base_multiple
-{
+//----------------------------------------------------------------------
+// class trigger_take_weapon: base_multiple
+// {
//--------------------------------------------------------------
// trigger_take_weapon_use
// thanks to ShanJaq and Spike for their help on this.
//--------------------------------------------------------------
- virtual void(entity toucher) do_touch =
+ void() trigger_take_weapon_touch =
{
// from Copper -- dumptruck_ds
- if (sub_checkvalidtouch(toucher) == FALSE)
+ if (sub_checkvalidtouch(other) == FALSE)
return;

- if (!(toucher.flags & FL_CLIENT))
+ if (!(other.flags & FL_CLIENT))
return;

- this.multi_trigger ();
- toucher.items &= ~IT_SHOTGUN;
- toucher.currentammo = !toucher.ammo_shells;
- toucher.ammo_shells = !toucher.ammo_shells;
- toucher.items = toucher.items - (toucher.items & IT_SHELLS);
- if (toucher.classtype == CT_PLAYER)
+ base_multiple_fire ();
+ other.items &= ~IT_SHOTGUN;
+ other.currentammo = !other.ammo_shells;
+ other.ammo_shells = !other.ammo_shells;
+ other.items = other.items - (other.items & IT_SHELLS);
+
+ if (other.classtype == CT_PLAYER)
{
- ((player)toucher).set_current_ammo ();
- ((player)toucher).best_weapon ();
+ player_set_current_ammo ();
+ player_best_weapon ();
}
};

//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) trigger_take_weapon_init =
{
- this.wait = -1;
- this.multi_init ();
- sub_checkwaiting ();
+ e.classname = "trigger_take_weapon";
+ e.classtype = CT_TRIGGER_TAKE_WEAPON;
+ e.touch = trigger_take_weapon_touch;
+ e.wait = -1;
+
+ base_multiple_init (e);
+ sub_checkwaiting (e);
};

//--------------------------------------------------------------
void() trigger_take_weapon =
{
- this.classtype = CT_TRIGGER_TAKE_WEAPON;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ trigger_take_weapon_init (self);
};
-};
+// };

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

Diff qc/triggers/teleport.qc

diff --git a/qc/triggers/teleport.qc b/qc/triggers/teleport.qc
index b907988..a611335 100644
--- a/qc/triggers/teleport.qc
+++ b/qc/triggers/teleport.qc
@@ -3,7 +3,10 @@
// -- dumptruck_ds
//==============================================================================

+//======================================================================
// constants
+//======================================================================
+
const float TRIGGER_TELEPORT_ONLYPLAYER = 1;
const float TRIGGER_TELEPORT_SILENT = 2;
const float TRIGGER_TELEPORT_RANDOM = 4;
@@ -12,6 +15,25 @@ const float TRIGGER_TELEPORT_ONLYMONSTER = 16;
const float TRIGGER_TELEPORT_DD = 32;

//======================================================================
+// forward declarations
+//======================================================================
+
+// tfog & tdeath
+void() spawn_tfog_think;
+void(vector org) spawn_tfog;
+void() spawn_tdeath_touch;
+void(vector org, entity death_owner) spawn_tdeath;
+
+// trigger_teleport
+entity() trigger_teleport_randomspot;
+void() trigger_teleport_touch;
+void() trigger_teleport_use;
+void(entity e) trigger_teleport_init;
+void() trigger_teleport;
+
+//------------------------------------------------------------------------------
+
+//======================================================================
// teleporter fog & teleporter death
//======================================================================

@@ -68,7 +90,7 @@ void() spawn_tdeath_touch =
if (self.owner.classtype != CT_PLAYER)
{
// other monsters explode themselves
- base_entity::t_damage2 (self.owner, self, self, 50000);
+ t_damage2 (self.owner, self, self, 50000);
return;
}
// 1998-07-26 Pentagram telefrag fix by Zoid/Maddes end
@@ -85,8 +107,7 @@ void() spawn_tdeath_touch =
self.classname = "teledeath3";
other.invincible_finished = 0;
// kill player on spot
- base_entity::t_damage2 (other, self, self,
- 50000);
+ t_damage2 (other, self, self, 50000);

/*
// 1998-07-26 only telefrag player on spot
@@ -106,7 +127,7 @@ void() spawn_tdeath_touch =
self.classname = "teledeath2";
// 1998-07-26 Pentagram telefrag fix by
// Zoid/Maddes start
- base_entity::t_damage2 (self.owner, self, self, 50000);
+ t_damage2 (self.owner, self, self, 50000);
}
return;
}
@@ -122,7 +143,7 @@ void() spawn_tdeath_touch =
}

if (other.health)
- base_entity::t_damage2 (other, self, self, 50000);
+ t_damage2 (other, self, self, 50000);
};

//----------------------------------------------------------------------
@@ -172,36 +193,39 @@ an entity is teleported.

TRIGGER_TELEPORT_ONLYMONSTER(16) will only teleport monsters
*/
-class trigger_teleport: base_trigger
-{
+//----------------------------------------------------------------------
+// class trigger_teleport: base_trigger
+// {
//--------------------------------------------------------------
// trigger_teleport_randomspot -- more Zerstrorer -- dumptruck_ds
// teleport_randomspot - returns a random spot to teleport to
// among all of the "info_teleport_random" entities in the level.
// self.count is the number of spots
//--------------------------------------------------------------
- nonvirtual entity() randomspot =
+ entity() trigger_teleport_randomspot =
{
local float rndm;
// local float rndm, num1;
local entity spot, first;

- rndm = rint (random() * (this.count - 1));
- spot = findfloat (world, ::classtype, CT_INFO_TELEPORT_RANDOM);
+ rndm = rint (random() * (self.count - 1));
+ spot = findfloat (world, classtype, CT_INFO_TELEPORT_RANDOM);
if (!spot)
- dprint ("No random teleport points found!\n");
+ dprint ("trigger_teleport_randomspot: "
+ "no random teleport points found!\n");
first = spot;

while (rndm > 0)
{
rndm = rndm - 1;
- spot = findfloat (spot, ::classtype,
+ spot = findfloat (spot, classtype,
CT_INFO_TELEPORT_RANDOM);
}

if (spot == world)
{
- dprint ("Random spot found world!!\n");
+ dprint ("trigger_teleport_randomspot: "
+ "random spot found world!!\n");
spot = first;
}

@@ -210,79 +234,80 @@ class trigger_teleport: base_trigger
// end dumptruck_ds

//--------------------------------------------------------------
- virtual void(entity toucher) do_touch =
+ void() trigger_teleport_touch =
{
local entity t;
local vector org;

- if (this.estate != STATE_ACTIVE)
+ if (self.estate != STATE_ACTIVE)
return;

- if (this.targetname != "")
- if (this.nextthink < time)
+ if (self.targetname != "")
+ if (self.nextthink < time)
// not fired yet
return;

- if (this.spawnflags & TRIGGER_TELEPORT_ONLYPLAYER)
- if (toucher.classtype != CT_PLAYER &&
- toucher.classtype != CT_PROJECTILE_GRENADE)
+ if (self.spawnflags & TRIGGER_TELEPORT_ONLYPLAYER)
+ if (other.classtype != CT_PLAYER &&
+ other.classtype != CT_PROJECTILE_GRENADE)
return;

// is this going to work? dumptruck_ds
- if (this.spawnflags & TRIGGER_TELEPORT_ONLYMONSTER)
- if (toucher.classtype == CT_PLAYER)
+ if (self.spawnflags & TRIGGER_TELEPORT_ONLYMONSTER)
+ if (other.classtype == CT_PLAYER)
return;

// from Copper -- dumptruck_ds
- if (toucher.movetype == MOVETYPE_NOCLIP)
+ if (other.movetype == MOVETYPE_NOCLIP)
return;

// Supa, is this trigger waiting to be activated?
- if (this.is_waiting == TRUE)
+ if (self.is_waiting == TRUE)
return;

// Special case
- if (this.is_waiting != -1)
- if (this.targetname != "")
- if (this.nextthink < time)
+ if (self.is_waiting != -1)
+ if (self.targetname != "")
+ if (self.nextthink < time)
// not fired yet
return;

// only teleport living creatures (and projectiles)
- if (toucher.health <= 0 || (toucher.solid != SOLID_SLIDEBOX &&
- toucher.solid != SOLID_BBOX))
+ if (other.health <= 0 || (other.solid != SOLID_SLIDEBOX &&
+ other.solid != SOLID_BBOX))
return;

sub_usetargets ();

// put a tfog where the player was
// ### dhm - if stealth, don't spawn a fog
- if (!(this.spawnflags & TRIGGER_TELEPORT_STEALTH))
- spawn_tfog (toucher.origin);
+ if (!(self.spawnflags & TRIGGER_TELEPORT_STEALTH))
+ spawn_tfog (other.origin);

// dhm - if this is a random teleporter, pick a random spot!
- if (this.spawnflags & TRIGGER_TELEPORT_RANDOM)
+ if (self.spawnflags & TRIGGER_TELEPORT_RANDOM)
{
- t = randomspot ();
+ t = trigger_teleport_randomspot ();
}
- else if ((this.spawnflags & TRIGGER_TELEPORT_DD) &&
- toucher.classtype == CT_PLAYER)
+ else if ((self.spawnflags & TRIGGER_TELEPORT_DD) &&
+ other.classtype == CT_PLAYER)
{
- t = find (world, ::targetname, this.noise);
+ t = find (world, targetname, self.noise);
}
else
{
- t = find (world, ::targetname, this.target);
+ t = find (world, targetname, self.target);
}

if (!t)
- objerror ("couldn't find target");
+ objerror ("trigger_teleport_touch: couldn't "
+ "find target");

// put a tfog where the player was
/*
- spawn_tfog (toucher.origin);
+ spawn_tfog (other.origin);

- t = find (world, ::targetname, this.target);
+ t = find (world, targetname, self.target);
if (!t)
objerror ("couldn't find target");
*/
@@ -292,84 +317,92 @@ class trigger_teleport: base_trigger
org = t.origin + 32 * v_forward;

// ### dhm - if stealth, don't spawn a fog
- if (!(this.spawnflags & TRIGGER_TELEPORT_STEALTH))
+ if (!(self.spawnflags & TRIGGER_TELEPORT_STEALTH))
spawn_tfog (org);

- spawn_tdeath (t.origin, toucher);
+ spawn_tdeath (t.origin, other);

// move the player and lock him down for a little while
- if (!toucher.health)
+ if (!other.health)
{
- toucher.origin = t.origin;
- toucher.velocity = (v_forward * toucher.velocity_x) +
- (v_forward * toucher.velocity_y);
+ other.origin = t.origin;
+ other.velocity = (v_forward * other.velocity_x) +
+ (v_forward * other.velocity_y);
return;
}

- setorigin (toucher, t.origin);
- toucher.angles = t.mangle;
+ setorigin (other, t.origin);
+ other.angles = t.mangle;

- if (toucher.classtype == CT_PLAYER)
+ if (other.classtype == CT_PLAYER)
{
// retrieves fog values from teleport destination,
// if any
- fog_setFromEnt (toucher, t);
+ fog_set_from_ent (other, t);

// turn this way immediately
- toucher.fixangle = 1;
- toucher.teleport_time = time + 0.7;
+ other.fixangle = 1;
+ other.teleport_time = time + 0.7;
// push player out at PM_TELEEXITSPEED -- CEV
- toucher.velocity = v_forward * PM_TELEEXITSPEED;
+ other.velocity = v_forward * PM_TELEEXITSPEED;
// TODO CEV commented out the next line
- // toucher.flags -= toucher.flags & FL_ONGROUND;
+ // other.flags -= other.flags & FL_ONGROUND;
}

- if ((this.spawnflags & TRIGGER_TELEPORT_ONLYMONSTER) &&
- toucher.classtype != CT_PLAYER)
+ if ((self.spawnflags & TRIGGER_TELEPORT_ONLYMONSTER) &&
+ other.classtype != CT_PLAYER)
{
// turn this way immediately
- toucher.fixangle = 1;
- toucher.teleport_time = time + 0.7;
- if (toucher.flags & FL_ONGROUND)
- toucher.flags = toucher.flags - FL_ONGROUND;
- toucher.velocity = v_forward * PM_TELEEXITSPEED;
- toucher.flags -= toucher.flags & FL_ONGROUND;
+ other.fixangle = 1;
+ other.teleport_time = time + 0.7;
+ if (other.flags & FL_ONGROUND)
+ other.flags = other.flags - FL_ONGROUND;
+ other.velocity = v_forward * PM_TELEEXITSPEED;
+ other.flags -= other.flags & FL_ONGROUND;
}
};

//--------------------------------------------------------------
- virtual void(entity caller) do_use =
+ void() trigger_teleport_use =
{
- this.nextthink = time + 0.2;
+ self.nextthink = time + 0.2;
// make sure even still objects get hit
force_retouch = 2;
- this.interaction_flags |= DISABLE_THINK;
+ self.think = sub_null;
};

//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) trigger_teleport_init =
{
- init_trigger ();
+ e.classname = "trigger_teleport";
+ e.classtype = CT_TRIGGER_TELEPORT;
+ base_trigger_init (e);
+
+ e.touch = trigger_teleport_touch;
+ e.use = trigger_teleport_use;

// find the destination
- if (!this.target)
- objerror ("no target");
+ if (!e.target)
+ objerror ("trigger_teleport_init: no target");

- if (!(this.spawnflags & TRIGGER_TELEPORT_SILENT))
+ if (!(e.spawnflags & TRIGGER_TELEPORT_SILENT))
{
- local vector o;
precache_sound ("ambience/hum1.wav");
- o = (this.mins + this.maxs) * 0.5;
// volume was 0.5 -- CEV
- ambientsound (o, "ambience/hum1.wav", 0.3, ATTN_STATIC);
+ ambientsound ((e.mins + e.maxs) * 0.5,
+ "ambience/hum1.wav", 0.3, ATTN_STATIC);
}

- sub_checkwaiting ();
+ sub_checkwaiting (e);
};

//--------------------------------------------------------------
void() trigger_teleport =
{
- this.classtype = CT_TRIGGER_TELEPORT;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ trigger_teleport_init (self);
};
-};
+// };

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

Diff qc/triggers/textstory.qc

diff --git a/qc/triggers/textstory.qc b/qc/triggers/textstory.qc
index 2cb7235..05c8f22 100644
--- a/qc/triggers/textstory.qc
+++ b/qc/triggers/textstory.qc
@@ -2,306 +2,347 @@
// trigger_textstory
//==============================================================================

+//======================================================================
// constants
+//======================================================================
+
const float TEXTSTORY_SILENT = 1;
const float TEXTSTORY_NOFADE = 2;

-enum
-{
- TEXTSTORY_THINK_HIDE,
- TEXTSTORY_THINK_SHOW,
- TEXTSTORY_THINK_HELPERHIDE,
- TEXTSTORY_THINK_HELPERSHOW
-};
+//======================================================================
+// forward declarations
+//======================================================================
+
+// base_textstory
+void(entity controller) base_textstory_hide;
+void(entity controller) base_textstory_show;
+
+// trigger_textstory
+void() trigger_textstory_hide;
+void() trigger_textstory_show;
+void() trigger_textstory_touch;
+void(entity e) trigger_textstory_init;
+void() trigger_textstory;
+
+// target_textstory_helper
+void() target_textstory_helper_hide;
+void() target_textstory_helper_show;
+entity(entity src, entity tgt, float nthink, float atkfinished)
+ spawn_target_textstory_helper;
+void(entity e) target_textstory_helper_init;
+void() target_textstory_helper;
+
+// target_textstory
+void(entity tgt) target_textstory_spawn_helper;
+void() target_textstory_use;
+void(entity e) target_textstory_init;
+void() target_textstory;

//------------------------------------------------------------------------------
-// base textstory class
-//------------------------------------------------------------------------------
-class base_textstory: base_trigger
-{
- float think_state;

+//----------------------------------------------------------------------
+// base textstory class
+//----------------------------------------------------------------------
+// class base_textstory: base_trigger
+// {
//--------------------------------------------------------------
// hide a textstory
//--------------------------------------------------------------
- nonvirtual void(entity controller) text_hide =
+ void(entity controller) base_textstory_hide =
{
- if (!this.enemy || !(this.enemy.flags & FL_CLIENT))
+ if (!self.enemy || !(self.enemy.flags & FL_CLIENT))
return;

- this.enemy.suppressCenterPrint = FALSE;
- centerprint (this.enemy, "");
+ self.enemy.suppressCenterPrint = FALSE;
+ centerprint (self.enemy, "");

if (controller.noise2 != __NULL__ && controller.noise2 != "")
- sound (this.enemy, CHAN_BODY, controller.noise2, 1,
+ sound (self.enemy, CHAN_BODY, controller.noise2, 1,
ATTN_NORM);

if (!(controller.spawnflags & TEXTSTORY_NOFADE))
- csf_fade (this.enemy, 0, '0 0 0', 0.5);
+ csf_fade (self.enemy, 0, '0 0 0', 0.5);
};

//--------------------------------------------------------------
// show a textstory
//--------------------------------------------------------------
- nonvirtual void(entity controller) text_show =
+ void(entity controller) base_textstory_show =
{
- if (!this.enemy || !(this.enemy.flags & FL_CLIENT))
+ if (!self.enemy || !(self.enemy.flags & FL_CLIENT))
return;

- this.enemy.suppressCenterPrint = TRUE;
+ self.enemy.suppressCenterPrint = TRUE;

- centerprint_builtin (this.enemy, controller.message);
+ centerprint_builtin (self.enemy, controller.message);

- if (!this.state)
+ if (!self.state)
{
if (controller.noise1 != __NULL__ &&
controller.noise1 != "")
{
- sound (this.enemy, CHAN_BODY, controller.noise1,
+ sound (self.enemy, CHAN_BODY, controller.noise1,
1, ATTN_NORM);
}

if (!(controller.spawnflags & TEXTSTORY_NOFADE))
{
//custom fade amount --dumptruck_ds
- if (!this.fade_amt)
- csf_fade (this.enemy, 160, '0 0 0', 1);
+ if (!self.fade_amt)
+ csf_fade (self.enemy, 160, '0 0 0', 1);
else
- csf_fade (this.enemy, this.fade_amt,
+ csf_fade (self.enemy, self.fade_amt,
'0 0 0', 1);
}
}

- this.state = 1;
+ self.state = 1;
};
-};
+// };

-//------------------------------------------------------------------------------
+//----------------------------------------------------------------------
// trigger_textstory -- centerprint text when inside this trigger
-//------------------------------------------------------------------------------
-class trigger_textstory: base_textstory
-{
+//----------------------------------------------------------------------
+// class trigger_textstory: base_textstory
+// {
//--------------------------------------------------------------
// hide text
//--------------------------------------------------------------
- nonvirtual void() story_hide =
+ void() trigger_textstory_hide =
{
- text_hide (this);
+ base_textstory_hide (self);

- this.enemy = world;
- this.state = 0;
+ self.enemy = world;
+ self.state = 0;
};

//--------------------------------------------------------------
// show text
//--------------------------------------------------------------
- nonvirtual void() story_show =
+ void() trigger_textstory_show =
{
- text_show (this);
-
- this.think_state = TEXTSTORY_THINK_HIDE;
- this.nextthink = time + 0.2;
- };
+ base_textstory_show (self);

- //--------------------------------------------------------------
- virtual void() do_think =
- {
- if (this.think_state == TEXTSTORY_THINK_HIDE)
- this.story_hide ();
- else if (this.think_state == TEXTSTORY_THINK_SHOW)
- this.story_show ();
+ self.think = trigger_textstory_hide;
+ self.nextthink = time + 0.2;
};

//--------------------------------------------------------------
- virtual void(entity toucher) do_touch =
+ void() trigger_textstory_touch =
{
- if (!(toucher.flags & FL_CLIENT))
+ if (!(other.flags & FL_CLIENT))
return;
- if (this.estate != STATE_ACTIVE)
+
+ if (self.estate != STATE_ACTIVE)
return;

// don't show message if another player is already triggering it
- if (toucher != this.enemy && this.state == 1)
+ if (other != self.enemy && self.state == 1)
return;

- if (this.mangle && !isInAngle (toucher.v_angle, this.mangle,
- this.view_ofs))
+ if (self.mangle && !is_in_angle (other.v_angle, self.mangle,
+ self.view_ofs))
{
return;
}

- if (this.attack_finished < time)
+ if (self.attack_finished < time)
{
- this.attack_finished = time + 0.1;
- this.enemy = toucher;
+ self.attack_finished = time + 0.1;
+ self.enemy = other;

- this.story_show ();
+ trigger_textstory_show ();
}
};

//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) trigger_textstory_init =
{
- init_trigger ();
+ e.classname = "trigger_textstory";
+ e.classtype = CT_TRIGGER_TEXTSTORY;
+ e.touch = trigger_textstory_touch;
+ base_trigger_init (e);

- if (this.view_ofs == '0 0 0')
- this.view_ofs = '90 90 0';
+ if (e.view_ofs == '0 0 0')
+ e.view_ofs = '90 90 0';

- if (this.mangle)
- this.mangle = normalizeAngles180 (this.mangle);
+ if (e.mangle)
+ e.mangle = normalize_angles180 (e.mangle);

- if (this.noise1 == "")
- this.noise1 = "misc/talk.wav";
+ if (e.noise1 == "")
+ e.noise1 = "misc/talk.wav";

- if (this.noise2 == "")
- this.noise2 = "misc/null.wav";
+ if (e.noise2 == "")
+ e.noise2 = "misc/null.wav";

- if (this.spawnflags & TEXTSTORY_SILENT)
+ if (e.spawnflags & TEXTSTORY_SILENT)
{
- this.noise1 = "";
- this.noise2 = "";
+ e.noise1 = "";
+ e.noise2 = "";
}


- if (this.noise1 != "")
- precache_sound (this.noise1);
- if (this.noise2 != "")
- precache_sound (this.noise2);
+ if (e.noise1 != "")
+ precache_sound (e.noise1);
+ if (e.noise2 != "")
+ precache_sound (e.noise2);

- sub_checkwaiting ();
+ sub_checkwaiting (e);
};

//--------------------------------------------------------------
void() trigger_textstory =
{
- this.classtype = CT_TRIGGER_TEXTSTORY;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ trigger_textstory_init (self);
};
-};
+// };

//------------------------------------------------------------------------------
// helper class spawned by target_textstory below
//------------------------------------------------------------------------------
-class target_textstory_helper: base_textstory
-{
+// class target_textstory_helper: base_textstory
+// {
//--------------------------------------------------------------
// hide text
//--------------------------------------------------------------
- nonvirtual void() helper_story_hide =
+ void() target_textstory_helper_hide =
{
- this.text_hide (this.owner);
- remove (this);
+ base_textstory_hide (self.owner);
+ remove (self);
};

//--------------------------------------------------------------
// show text
//--------------------------------------------------------------
- nonvirtual void() helper_story_show =
+ void() target_textstory_helper_show =
{
- if (!this.enemy || !(this.enemy.flags & FL_CLIENT))
+ if (!self.enemy || !(self.enemy.flags & FL_CLIENT))
{
- remove (this);
+ remove (self);
return;
}

- this.text_show (this.owner);
+ base_textstory_show (self.owner);

- if (this.attack_finished < time)
- this.think_state = TEXTSTORY_THINK_HELPERHIDE;
+ if (self.attack_finished < time)
+ self.think = target_textstory_helper_hide;

- this.nextthink = time + 0.1;
+ self.nextthink = time + 0.1;
};

//--------------------------------------------------------------
- virtual void() do_think =
+ entity(entity src, entity tgt, float nthink, float atkfinished)
+ spawn_target_textstory_helper =
{
- if (this.think_state == TEXTSTORY_THINK_HELPERHIDE)
- this.helper_story_hide ();
- else if (this.think_state == TEXTSTORY_THINK_HELPERSHOW)
- this.helper_story_show ();
+ local entity e = spawn ();
+ e.owner = src;
+ e.enemy = tgt;
+ e.nextthink = nthink;
+ e.attack_finished = atkfinished;
+ target_textstory_helper_init (e);
+ return e;
};

//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) target_textstory_helper_init =
{
- this.think_state = TEXTSTORY_THINK_HELPERSHOW;
+ e.classname = "target_textstory_helper";
+ e.classtype = CT_TARGET_TEXTSTORY_HELPER;
+ e.think = target_textstory_helper_show;
+
+ base_tempentity_init (e);
};

//--------------------------------------------------------------
void() target_textstory_helper =
{
- this.classtype = CT_TARGET_TEXTSTORY_HELPER;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ target_textstory_helper_init (self);
};
-};
+// };

-//------------------------------------------------------------------------------
+//----------------------------------------------------------------------
// target_textstory: centerprint a message for an amount of time when used
-//------------------------------------------------------------------------------
-class target_textstory: base_textstory
-{
+//----------------------------------------------------------------------
+// class target_textstory: base_textstory
+// {
//--------------------------------------------------------------
// create the hidden object that'll show the actual message
//--------------------------------------------------------------
- nonvirtual void(entity tgt) spawn_helper =
+ void(entity tgt) target_textstory_spawn_helper =
{
- target_textstory_helper helper;
- helper = spawn (target_textstory_helper,
- owner:this,
- nextthink:time + 0.1,
- attack_finished:time + this.wait,
- enemy:tgt);
+ entity helper = spawn_target_textstory_helper (self, tgt,
+ time + 0.1, time + self.wait);
};

//--------------------------------------------------------------
- virtual void(entity caller) do_use =
+ void() target_textstory_use =
{
if (!(activator.flags & FL_CLIENT))
return;
- if (this.estate != STATE_ACTIVE)
+ if (self.estate != STATE_ACTIVE)
return;

local entity t;

- if (this.spawnflags & TRIGGER_CENTERPRINTALL)
+ if (self.spawnflags & TRIGGER_CENTERPRINTALL)
{
- t = findfloat (world, ::classtype, CT_PLAYER);
+ t = findfloat (world, classtype, CT_PLAYER);
while (t)
{
- this.spawn_helper (t);
- t = findfloat (t, ::classtype, CT_PLAYER);
+ target_textstory_spawn_helper (t);
+ t = findfloat (t, classtype, CT_PLAYER);
}
}
else
{
- this.spawn_helper (activator);
+ target_textstory_spawn_helper (activator);
}
};

//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) target_textstory_init =
{
- if (this.noise1 == "")
- this.noise1 = "misc/talk.wav";
+ e.classname = "target_textstory";
+ e.classtype = CT_TARGET_TEXTSTORY;
+ base_mapentity_init (e);
+
+ if (e.noise1 == "")
+ e.noise1 = "misc/talk.wav";

- if (this.noise2 == "")
- this.noise2 = "misc/null.wav";
+ if (e.noise2 == "")
+ e.noise2 = "misc/null.wav";

- if (this.spawnflags & TEXTSTORY_SILENT) {
- this.noise1 = "";
- this.noise2 = "";
+ if (e.spawnflags & TEXTSTORY_SILENT) {
+ e.noise1 = "";
+ e.noise2 = "";
}

- if (this.noise1 != "")
- precache_sound (this.noise1);
- if (this.noise2 != "")
- precache_sound (this.noise2);
+ if (e.noise1 != "")
+ precache_sound (e.noise1);
+ if (e.noise2 != "")
+ precache_sound (e.noise2);

- if (!this.wait)
- this.wait = 5;
+ if (!e.wait)
+ e.wait = 5;
+
+ e.use = target_textstory_use;
};

//--------------------------------------------------------------
void() target_textstory =
{
- this.classtype = CT_TARGET_TEXTSTORY;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ target_textstory_init (self);
};
-};
+// };

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

Diff qc/triggers/usekey.qc

diff --git a/qc/triggers/usekey.qc b/qc/triggers/usekey.qc
index 6c9e995..1ce0846 100644
--- a/qc/triggers/usekey.qc
+++ b/qc/triggers/usekey.qc
@@ -10,10 +10,25 @@
Distributed (unsupported) on 3.12.97
*/

+//======================================================================
// constants
+//======================================================================
+
const float TRIGGER_USEKEY_SILV_KEY = 8;
const float TRIGGER_USEKEY_GOLD_KEY = 16;

+//======================================================================
+// forward declarations
+//======================================================================
+
+void() trigger_usekey_unlock;
+void() trigger_usekey_use;
+void() trigger_usekey_touch;
+void(entity e) trigger_usekey_init;
+void() trigger_usekey;
+
+//------------------------------------------------------------------------------
+
/*
QUAKED trigger_usekey (0 .5 0) ? X X X
TRIGGER_USEKEY_SILV_KEY TRIGGER_USEKEY_GOLD_KEY X X X
@@ -30,11 +45,9 @@ targets. Must be targeted at one or more entities.
"noise1" sound file for the "key required" sound (default is per worldtype).
"noise2" sound file for the "key used" sound (default is per worldtype).
*/
-class trigger_usekey: base_trigger
-{
- // class fields
- float is_removed;
-
+//----------------------------------------------------------------------
+// class trigger_usekey: base_trigger
+// {
//--------------------------------------------------------------
// trigger_usekey_unlock
//
@@ -45,110 +58,113 @@ class trigger_usekey: base_trigger
// to the new keylock_try_to_unlock function. This code was
// previously part of the trigger_usekey_use function. -- iw
//--------------------------------------------------------------
- nonvirtual void() unlock =
+ void() trigger_usekey_unlock =
{
// we can't just remove (self) here, because this is a
// touch function called while C code is looping through
// area links...
- this.message = "";
+ self.message = "";

sub_usetargets ();

- this.interaction_flags |= DISABLE_TOUCH;
- this.interaction_flags |= DISABLE_USE;
- this.is_removed = TRUE;
- this.nextthink = time + 0.1;
+ self.think = sub_remove;
+ self.touch = sub_null;
+ self.use = sub_null;
+ self.nextthink = time + 0.1;
};

//--------------------------------------------------------------
- virtual void() do_think =
- {
- if (this.is_removed == TRUE)
- remove (this);
- };
-
- //--------------------------------------------------------------
- virtual void(entity caller) do_use =
+ void() trigger_usekey_use =
{
// from Copper -- dumptruck_ds
- if (sub_checkvalidtouch(caller) == FALSE)
+ if (sub_checkvalidtouch(other) == FALSE)
return;

- if (this.attack_finished > time)
+ if (self.attack_finished > time)
return;

- this.attack_finished = time + 2;
- keylock_try_to_unlock (caller, this.message, this.unlock);
+ self.attack_finished = time + 2;
+ keylock_try_to_unlock (other, self.message,
+ trigger_usekey_unlock);
};

//--------------------------------------------------------------
- virtual void(entity toucher) do_touch =
+ void() trigger_usekey_touch =
{
- this.do_use (toucher);
+ trigger_usekey_use ();
};

//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) trigger_usekey_init =
{
+ e.classname = "trigger_usekey";
+ e.classtype = CT_TRIGGER_USEKEY;
+
// the keylock_* functions use self.noise3 and self.noise4
// internally, but trigger_usekey doesn't use the self.noise1
// or self.noise2 fields for anything, so we allow the mapper
// to specify custom sound files by setting self.noise1 and
// self.noise2, but we move those values into self.noise3 and
// self.noise4 -- iw
- this.noise3 = this.noise1;
- this.noise4 = this.noise2;
- this.noise1 = "";
- this.noise2 = "";
+ e.noise3 = e.noise1;
+ e.noise4 = e.noise2;
+ e.noise1 = "";
+ e.noise2 = "";

- keylock_init ();
+ keylock_init (e);

- if (this.spawnflags & TRIGGER_USEKEY_SILV_KEY)
+ if (e.spawnflags & TRIGGER_USEKEY_SILV_KEY)
{
- //dumptruck_ds
- keylock_set_silver_key ();
+ // dumptruck_ds
+ keylock_set_silver_key (e);

- if (this.keyname != "")
+ if (e.keyname != "")
{
- this.netname = this.keyname;
- this.keyname = "";
+ e.netname = e.keyname;
+ e.keyname = "";
}
}

- if (this.spawnflags & TRIGGER_USEKEY_GOLD_KEY)
+ if (e.spawnflags & TRIGGER_USEKEY_GOLD_KEY)
{
- //dumptruck_ds
- keylock_set_gold_key ();
+ // dumptruck_ds
+ keylock_set_gold_key (e);

- if (this.keyname != "")
+ if (e.keyname != "")
{
- this.netname = this.keyname;
- this.keyname = "";
+ e.netname = e.keyname;
+ e.keyname = "";
}
}

// support for item_key_custom -- iw
- if (this.keyname != "")
+ if (e.keyname != "")
{
- keylock_set_custom_key (this.keyname);
+ keylock_set_custom_key (e, e.keyname);
// this should not be referenced again
- this.keyname = "";
+ e.keyname = "";
}

- if (!keylock_has_key_set(this))
+ if (!keylock_has_key_set(e))
{
objerror ("no key specified!");
return;
}

- this.is_removed = FALSE;
- init_trigger ();
- sub_checkwaiting ();
+ e.touch = trigger_usekey_touch;
+ e.use = trigger_usekey_use;
+
+ base_trigger_init (e);
+ sub_checkwaiting (e);
};

//--------------------------------------------------------------
void() trigger_usekey =
{
- this.classtype = CT_TRIGGER_USEKEY;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ trigger_usekey_init (self);
};
-};
+// };

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

Diff qc/triggers/void.qc

diff --git a/qc/triggers/void.qc b/qc/triggers/void.qc
index 3331d18..a01ece3 100644
--- a/qc/triggers/void.qc
+++ b/qc/triggers/void.qc
@@ -7,10 +7,23 @@
// by dumptruck_ds, modified again by CEV
//======================================================================

+//======================================================================
// constants
+//======================================================================
+
const float TRIGGER_VOID_MONSTER_SAFE = 1;
const float TRIGGER_VOID_PLAYER_SAFE = 2;

+//======================================================================
+// forward declarations
+//======================================================================
+
+void() trigger_void_touch;
+void(entity e) trigger_void_init;
+void() trigger_void;
+
+//------------------------------------------------------------------------------
+
/*
QUAKED trigger_void (.5 .5 .5) ? X X X X X X X X
NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH
@@ -18,68 +31,75 @@ NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
Use this for a 'void' area.
Removes monsters, gibs, ammo, etc... also kills player.
*/
-class trigger_void: base_trigger
-{
+//----------------------------------------------------------------------
+// class trigger_void: base_trigger
+// {
//--------------------------------------------------------------
- virtual void(entity toucher) do_touch =
+ void() trigger_void_touch =
{
- if (this.estate != STATE_ACTIVE)
+ if (self.estate != STATE_ACTIVE)
return;

// from Copper -- dumptruck_ds
- if (toucher.movetype == MOVETYPE_NOCLIP)
+ if (other.movetype == MOVETYPE_NOCLIP)
return FALSE;

- if (this.spawnflags & TRIGGER_VOID_MONSTER_SAFE &&
- toucher.flags & FL_MONSTER)
+ if (self.spawnflags & TRIGGER_VOID_MONSTER_SAFE &&
+ other.flags & FL_MONSTER)
{
// ignore monsters
return;
}

- if (this.spawnflags & TRIGGER_VOID_PLAYER_SAFE &&
- toucher.flags & FL_CLIENT)
+ if (self.spawnflags & TRIGGER_VOID_PLAYER_SAFE &&
+ other.flags & FL_CLIENT)
{
// ignore players
return;
}

- if (toucher.takedamage)
+ if (other.takedamage)
{
// kills even with Pentagram, this took forever to
// figure out!! -- dumptruck_ds
- toucher.invincible_finished = 0;
- this.t_damage2 (toucher, this, this,
- toucher.health + 1000);
+ other.invincible_finished = 0;
+ t_damage2 (other, self, self, other.health + 1000);

- if (toucher.flags & FL_MONSTER)
- remove (toucher);
+ if (other.flags & FL_MONSTER)
+ remove (other);
}

- if (toucher.classname == "gib" ||
- toucher.classname == "grenade" ||
- toucher.classname == "spike" ||
- toucher.classname == "missile")
+ if (other.classname == "gib" ||
+ other.classtype == CT_PROJECTILE_GRENADE ||
+ other.classtype == CT_PROJECTILE_SPIKE ||
+ other.classtype == CT_PROJECTILE_ROCKET)
{
- remove (toucher);
+ remove (other);
}

- if (toucher.flags & FL_ITEM)
- remove (toucher);
+ if (other.flags & FL_ITEM)
+ remove (other);

force_retouch = 2;
};

//--------------------------------------------------------------
- virtual void() init_spawned =
+ void(entity e) trigger_void_init =
{
- init_trigger ();
- sub_checkwaiting ();
+ e.classname = "trigger_void";
+ e.classtype = CT_TRIGGER_VOID;
+ e.touch = trigger_void_touch;
+ base_trigger_init (e);
+ sub_checkwaiting (e);
};

//--------------------------------------------------------------
void() trigger_void =
{
- this.classtype = CT_TRIGGER_VOID;
+ // new spawnflags for all entities -- iw
+ if (SUB_Inhibit())
+ return;
+
+ trigger_void_init (self);
};
-};
+// };

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

Diff qc/utility.qc

diff --git a/qc/utility.qc b/qc/utility.qc
index e1e01a4..717b662 100644
--- a/qc/utility.qc
+++ b/qc/utility.qc
@@ -2,6 +2,34 @@
// utility.qc
//==============================================================================

+//======================================================================
+// forward declarations
+//======================================================================
+
+void(string s1, string s2) dprint2;
+void(string s1, string s2, string s3) dprint3;
+void(string s1, string s2, string s3, string s4) dprint4;
+void(string s1, string s2, string s3, string s4, string s5) dprint5;
+void(string s1, string s2, string s3, string s4, string s5, string s6) dprint6;
+void(string s1, string s2, string s3, string s4, string s5, string s6,
+ string s7) dprint7;
+void(string s1, string s2, string s3, string s4, string s5, string s6,
+ string s7, string s8) dprint8;
+void(string s1, string s2, string s3, string s4, string s5, string s6,
+ string s7, string s8, string s9) dprint9;
+
+float(float in) bprint_int;
+float(float in) zeroconvert;
+float(float in, float def) zeroconvertdefault;
+
+float(vector v, vector s) bounds_angle_size;
+
+void(entity client, float f) stuffcmd_digit;
+void(entity client, float f, float numdigits) stuffcmd_int;
+void(entity client, float f) stuffcmd_float;
+
+//------------------------------------------------------------------------------
+
//----------------------------------------------------------------------
// dprint shims
//----------------------------------------------------------------------
@@ -123,15 +151,6 @@ float(float in) bprint_int =
};

//----------------------------------------------------------------------
-float(float in, float def) defaultFl =
-{
- if (in)
- return in;
- else
- return def;
-};
-
-//----------------------------------------------------------------------
// shorthand for turning -1 to 0 for keyvalues for which 0 is a
// valid non-default selection
//----------------------------------------------------------------------
@@ -156,7 +175,7 @@ float(float in, float def) zeroconvertdefault =
// for measuring how large an entity is along an arbitrary vector
// FIXME: this is trash and it returns trash
//----------------------------------------------------------------------
-float(vector v, vector s) BoundsAngleSize =
+float(vector v, vector s) bounds_angle_size =
{
v_x = fabs (v_x);
v_y = fabs (v_y);

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

Diff qc/world.qc

diff --git a/qc/world.qc b/qc/world.qc
index 9dbf2ed..be71310 100644
--- a/qc/world.qc
+++ b/qc/world.qc
@@ -3,172 +3,89 @@
//==============================================================================

//======================================================================
-// Globals
+// constants
//======================================================================
+
+const float KNOWN_RELEASE_NOT = 0; // known_release values -- iw
+const float KNOWN_RELEASE_ID1 = 1;
+const float KNOWN_RELEASE_FUNC_MAPJAMX = 2;
+
+const float WORLDTYPE_MEDIEVAL = 0; // worldtype values
+const float WORLDTYPE_METAL = 1;
+const float WORLDTYPE_BASE = 2;
+
+//======================================================================
+// globals
+//======================================================================
+
+#ifdef SSQC
entity bodyque_head;
entity lastspawn;
-// float known_release; // unique ID for a release
-// float skill; // latched skill CVAR
+float known_release; // unique ID for a release
+nosave float *world_sounds; // via Spike fun times! nosave=noclobber
+#endif
+
+float world_airstep; // latched cvars, reset on world spawn
+float world_bigcoords;
+float world_clrun;
+float world_gravity;
+float world_maxvelocity;
+float world_nostep;
+float world_standardphysics;
+float world_walljump;
+float world_clforwardspeed;
+float world_clsidespeed;
+
+//======================================================================
+// fields
+//======================================================================
+
+#ifdef SSQC
+.string wad;
+.string map;
+.float worldtype; // 0=medieval 1=metal 2=base
+.float skip_id1_overrides;
+#endif

//======================================================================
-// Prototypes / Compiler Forward Declarations
+// forward declarations
//======================================================================
+
+#ifdef SSQC
+void() world_latched_cvars;
+void() world_weapon_precache;
+void() world_detect_known_release;
+void() worldspawn;
+void() bodyque;
void() InitBodyQue;
+void(entity ent) CopyToBodyQue;
+#endif
+
+//------------------------------------------------------------------------------

+#if defined(CSQC) || defined(SSQC)
//----------------------------------------------------------------------
-void() main =
+void() world_latched_cvars =
{
- 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");
+ world_airstep = autocvar (pm_airstep, TRUE);
+ world_bigcoords = autocvar (sv_bigcoords, FALSE);
+ world_clrun = autocvar (cl_run, FALSE);
+ world_gravity = autocvar (sv_gravity, 800.0);
+ world_maxvelocity = autocvar (sv_maxvelocity, 10000.0);
+ world_nostep = autocvar (pm_nostep, FALSE);
+ world_standardphysics = autocvar (pm_standardphysics, FALSE);
+ world_walljump = autocvar (pm_walljump, TRUE);
+
+ world_clforwardspeed = autocvar (cl_forwardspeed, PM_RUNSPEED);
+ world_clsidespeed = autocvar (cl_sidespeed, PM_RUNSPEED);
};
+#endif

+#ifdef SSQC
//----------------------------------------------------------------------
-// WeaponPrecache -- was W_Precache; called by worldspawn
+// world_weapon_precache -- was W_Precache; called by worldspawn
//----------------------------------------------------------------------
-void() WeaponPrecache =
+void() world_weapon_precache =
{
precache_sound ("weapons/r_exp3.wav"); // new rocket explosion
precache_sound ("weapons/rocket1i.wav");// spike gun
@@ -332,6 +249,15 @@ void() WeaponPrecache =
precache_sound ("shambler/smack.wav");
// dumptruck_ds mobot.qc END

+ // CEV fish bite sound
+ precache_sound ("fish/bite.wav");
+
+ // CEV minigrenade model
+ precache_model ("progs/mervup.mdl");
+
+ // CEV superduperspike model
+ precache_model ("progs/lspike.mdl");
+
// CEV bullet projectile model from AD
precache_model ("progs/ad/proj_diam2.mdl");
};
@@ -342,7 +268,7 @@ void() WeaponPrecache =
// a backwards-compatibility hack should be applied, and sets the
// known_release global accordingly. -- iw
//----------------------------------------------------------------------
-void() DetectKnownRelease =
+void() world_detect_known_release =
{
local string release_name;

@@ -466,11 +392,14 @@ sky(string) : "Sky Texture" : : "Must have compatible skybox textures in gfx/en
*/
void() worldspawn =
{
- DetectKnownRelease ();
+ world_detect_known_release ();

// new spawnflags for all entities -- iw
InitNewSpawnflags ();

+ // read per-map latched cvars -- CEV
+ world_latched_cvars ();
+
lastspawn = world;
InitBodyQue ();
self.classname = "world";
@@ -480,12 +409,12 @@ void() worldspawn =
if (self.model == "maps/e1m8.bsp" && self.skip_id1_overrides == 0)
{
cvar_set ("sv_gravity", "100");
- frame_gravity = 100.0;
+ world_gravity = 100.0;
}
else
{
cvar_set ("sv_gravity", "800");
- frame_gravity = 800.0;
+ world_gravity = 800.0;
}

// No cutscene is active during worldspawn. Drake -- dumptruck_ds
@@ -497,10 +426,10 @@ void() worldspawn =
// the area based ambient sounds MUST be the first precache_sounds

// player precaches; get weapon precaches
- WeaponPrecache ();
+ world_weapon_precache ();

// sounds used from C physics code
- precache_sound_land ("demon/dland2.wav"); // landing thud
+ precache_sound_land (self, "demon/dland2.wav"); // landing thud
precache_sound ("misc/h2ohit1.wav"); // landing splash

// setup precaches always needed
@@ -524,11 +453,11 @@ void() worldspawn =
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 ("weapons/lhit.wav"); // lightning
+ precache_sound ("weapons/lstart.wav"); // lightning start

// iw -- fix powerup cheat sounds
- // noticed this in Copper so why not? --ds
+ // noticed this in Copper so why not? -- ds
// sounds used by cheats
precache_sound ("items/suit2.wav"); // suit (finish)
precache_sound ("items/protect2.wav"); // pent (finish)
@@ -633,7 +562,7 @@ void() worldspawn =
precache_model ("progs/health/pd_vial.mdl"); // DropVial -- dumptruck_ds
precache_sound ("items/r_item1.wav");
precache_sound ("items/armor_shard_q3.wav"); // DropShard - dumptruck_ds
- precache_sound ("items/item_respawn_q3.wav"); // CEV
+ precache_sound ("items/item_respawn_q3.wav");// CEV
precache_model ("progs/armshr.mdl");

// Setup light anim tables. 'a' is total darkness, 'z' is maxbright.
@@ -680,64 +609,6 @@ void() worldspawn =
lightstyle (63, "a");
};

-//----------------------------------------------------------------------
-void() RestartLoopSounds_think =
-{
- sound (self, self.impulse, self.noise, self.volume, self.speed);
-};
-
-//----------------------------------------------------------------------
-void() RestartLoopSounds =
-{
- entity e;
- e = find (world, classname, "play_sound_triggered");
- while (e) {
- if (e.spawnflags & 3 == 3) {
- // both "toggle" and "looped" need to be set
- if (e.state == 1) {
- e.nextthink = time + 0.1;
- e.think = RestartLoopSounds_think;
- }
- }
- e = find (e, classname, "play_sound_triggered");
- }
-};
-
-//----------------------------------------------------------------------
-void() StartFrame =
-{
- // new spawnflags for all entities -- iw
- if (!done_inhibition_summary)
- PrintInhibitionSummary ();
-
- // per-frame latched variables -- CEV
- teamplay = cvar ("teamplay");
- skill = cvar ("skill");
- frame_airstep = autocvar (pm_airstep, TRUE);
- frame_bigcoords = autocvar (sv_bigcoords, FALSE);
- frame_clrun = autocvar (cl_run, FALSE);
- frame_gravity = autocvar (sv_gravity, 800.0);
- frame_maxvelocity = autocvar (sv_maxvelocity, 10000.0);
- frame_nostep = autocvar (pm_nostep, FALSE);
- frame_standardphysics = autocvar (pm_standardphysics, FALSE);
- frame_walljump = autocvar (pm_walljump, TRUE);
-
- framecount = framecount + 1;
-
- if (cleanUpClientStuff)
- {
- cleanUpClientStuff -= 1;
- RestartLoopSounds ();
- }
- else if (!gamestarted && framecount > 2)
- {
- if (framecount != 3)
- cleanUpClientStuff += 2;
-
- gamestarted = TRUE;
- }
-};
-
//======================================================================
// BODY QUE
//======================================================================
@@ -781,3 +652,4 @@ void(entity ent) CopyToBodyQue =
setsize (bodyque_head, ent.mins, ent.maxs);
bodyque_head = bodyque_head.owner;
};
+#endif

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