Merge branch 'master' into TimePath/effectinfo
authorTimePath <andrew.hardaker1995@gmail.com>
Sat, 3 Oct 2015 06:11:23 +0000 (16:11 +1000)
committerTimePath <andrew.hardaker1995@gmail.com>
Sat, 3 Oct 2015 06:11:23 +0000 (16:11 +1000)
190 files changed:
gfx/hud/default/minigames/qto/board.jpg [deleted file]
gfx/hud/default/minigames/qto/board_alpha.jpg [deleted file]
gfx/hud/default/minigames/qto/icon.jpg [deleted file]
gfx/hud/default/minigames/qto/icon_notif.jpg [deleted file]
gfx/hud/default/minigames/qto/icon_notif_alpha.jpg [deleted file]
gfx/hud/default/minigames/qto/piece0.tga [deleted file]
gfx/hud/default/minigames/qto/piece1.tga [deleted file]
gfx/hud/default/minigames/snake/board.jpg [new file with mode: 0644]
gfx/hud/default/minigames/snake/board_alpha.jpg [new file with mode: 0644]
gfx/hud/default/minigames/snake/body.tga [new file with mode: 0644]
gfx/hud/default/minigames/snake/head.tga [new file with mode: 0644]
gfx/hud/default/minigames/snake/icon.jpg [new file with mode: 0644]
gfx/hud/default/minigames/snake/icon_notif.jpg [new file with mode: 0644]
gfx/hud/default/minigames/snake/icon_notif_alpha.jpg [new file with mode: 0644]
gfx/hud/default/minigames/snake/mouse.tga [new file with mode: 0644]
gfx/hud/default/minigames/snake/tail.tga [new file with mode: 0644]
gfx/hud/default/minigames/snake/tongue.tga [new file with mode: 0644]
minigames.cfg
monsters.cfg
qcsrc/Makefile
qcsrc/client/_all.qh
qcsrc/client/controlpoint.qc
qcsrc/client/controlpoint.qh
qcsrc/client/csqcmodel_hooks.qc
qcsrc/client/csqcmodel_hooks.qh [deleted file]
qcsrc/client/damage.qc
qcsrc/client/generator.qc
qcsrc/client/generator.qh
qcsrc/client/gibs.qc
qcsrc/client/gibs.qh
qcsrc/client/hook.qc
qcsrc/client/hook.qh
qcsrc/client/main.qc
qcsrc/client/mapvoting.qc
qcsrc/client/progs.inc
qcsrc/client/tuba.qc
qcsrc/client/view.qc
qcsrc/client/weapons/projectile.qc
qcsrc/collect-precache.sh [deleted file]
qcsrc/common/effects/effects.inc
qcsrc/common/items/all.qc
qcsrc/common/items/all.qh
qcsrc/common/items/item/ammo.qc
qcsrc/common/items/item/armor.qc
qcsrc/common/items/item/health.qc
qcsrc/common/items/item/jetpack.qc
qcsrc/common/items/item/pickup.qh
qcsrc/common/items/item/powerup.qc
qcsrc/common/minigames/cl_minigames.qc
qcsrc/common/minigames/cl_minigames.qh
qcsrc/common/minigames/cl_minigames_hud.qc
qcsrc/common/minigames/minigame/all.qh
qcsrc/common/minigames/minigame/c4.qc
qcsrc/common/minigames/minigame/nmm.qc
qcsrc/common/minigames/minigame/pong.qc
qcsrc/common/minigames/minigame/pp.qc
qcsrc/common/minigames/minigame/ps.qc
qcsrc/common/minigames/minigame/qto.qc [deleted file]
qcsrc/common/minigames/minigame/snake.qc [new file with mode: 0644]
qcsrc/common/minigames/minigame/ttt.qc
qcsrc/common/minigames/minigames.qc
qcsrc/common/minigames/minigames.qh
qcsrc/common/minigames/sv_minigames.qc
qcsrc/common/minigames/sv_minigames.qh
qcsrc/common/models/models.qh
qcsrc/common/monsters/monster/mage.qc
qcsrc/common/monsters/monster/shambler.qc
qcsrc/common/monsters/monster/spider.qc
qcsrc/common/monsters/sv_monsters.qc
qcsrc/common/mutators/mutator/casings.qc
qcsrc/common/nades.qh
qcsrc/common/notifications.qc
qcsrc/common/sounds/sounds.inc [new file with mode: 0644]
qcsrc/common/sounds/sounds.qh [new file with mode: 0644]
qcsrc/common/triggers/func/breakable.qc
qcsrc/common/triggers/func/button.qc
qcsrc/common/triggers/func/door.qc
qcsrc/common/triggers/func/door_secret.qc
qcsrc/common/triggers/func/pointparticles.qc
qcsrc/common/triggers/func/train.qc
qcsrc/common/triggers/platforms.qc
qcsrc/common/triggers/target/music.qc
qcsrc/common/triggers/target/speaker.qc
qcsrc/common/triggers/teleporters.qc
qcsrc/common/triggers/trigger/gravity.qc
qcsrc/common/triggers/trigger/heal.qc
qcsrc/common/triggers/trigger/jumppads.qc
qcsrc/common/triggers/trigger/keylock.qc
qcsrc/common/triggers/trigger/multi.qc
qcsrc/common/triggers/triggers.qc
qcsrc/common/turrets/all.inc [new file with mode: 0644]
qcsrc/common/turrets/all.qc [new file with mode: 0644]
qcsrc/common/turrets/all.qh
qcsrc/common/turrets/cl_turrets.qc
qcsrc/common/turrets/cl_turrets.qh
qcsrc/common/turrets/config.qc
qcsrc/common/turrets/sv_turrets.qc
qcsrc/common/turrets/sv_turrets.qh
qcsrc/common/turrets/turrets.qc [deleted file]
qcsrc/common/turrets/turrets.qh [deleted file]
qcsrc/common/turrets/unit/ewheel.qc
qcsrc/common/turrets/unit/flac.qc
qcsrc/common/turrets/unit/fusionreactor.qc
qcsrc/common/turrets/unit/hellion.qc
qcsrc/common/turrets/unit/hk.qc
qcsrc/common/turrets/unit/machinegun.qc
qcsrc/common/turrets/unit/mlrs.qc
qcsrc/common/turrets/unit/phaser.qc
qcsrc/common/turrets/unit/plasma.qc
qcsrc/common/turrets/unit/plasma_dual.qc
qcsrc/common/turrets/unit/tesla.qc
qcsrc/common/turrets/unit/walker.qc
qcsrc/common/util.qc
qcsrc/common/util.qh
qcsrc/common/vehicles/all.qc
qcsrc/common/vehicles/cl_vehicles.qc
qcsrc/common/vehicles/sv_vehicles.qc
qcsrc/common/vehicles/unit/bumblebee.qc
qcsrc/common/vehicles/unit/racer.qc
qcsrc/common/vehicles/unit/raptor.qc
qcsrc/common/vehicles/unit/spiderbot.qc
qcsrc/common/weapons/all.qc
qcsrc/common/weapons/weapon/arc.qc
qcsrc/common/weapons/weapon/blaster.qc
qcsrc/common/weapons/weapon/crylink.qc
qcsrc/common/weapons/weapon/devastator.qc
qcsrc/common/weapons/weapon/electro.qc
qcsrc/common/weapons/weapon/fireball.qc
qcsrc/common/weapons/weapon/hagar.qc
qcsrc/common/weapons/weapon/hlac.qc
qcsrc/common/weapons/weapon/hmg.qc
qcsrc/common/weapons/weapon/hook.qc
qcsrc/common/weapons/weapon/machinegun.qc
qcsrc/common/weapons/weapon/minelayer.qc
qcsrc/common/weapons/weapon/mortar.qc
qcsrc/common/weapons/weapon/porto.qc
qcsrc/common/weapons/weapon/rifle.qc
qcsrc/common/weapons/weapon/rpc.qc
qcsrc/common/weapons/weapon/seeker.qc
qcsrc/common/weapons/weapon/shockwave.qc
qcsrc/common/weapons/weapon/shotgun.qc
qcsrc/common/weapons/weapon/vaporizer.qc
qcsrc/common/weapons/weapon/vortex.qc
qcsrc/lib/_all.inc
qcsrc/lib/file.qh [new file with mode: 0644]
qcsrc/lib/registry.qh
qcsrc/menu/item/button.qc
qcsrc/menu/item/label.qc
qcsrc/menu/item/slider.qc
qcsrc/menu/xonotic/dialog_monstertools.qc
qcsrc/server/_all.qh
qcsrc/server/autocvars.qh
qcsrc/server/bot/scripting.qc
qcsrc/server/cheats.qc
qcsrc/server/cl_client.qc
qcsrc/server/cl_player.qc
qcsrc/server/defs.qh
qcsrc/server/g_hook.qc
qcsrc/server/g_world.qc
qcsrc/server/item_key.qc
qcsrc/server/miscfunctions.qc
qcsrc/server/miscfunctions.qh
qcsrc/server/mutators/gamemode_ctf.qc
qcsrc/server/mutators/gamemode_domination.qc
qcsrc/server/mutators/gamemode_keepaway.qc
qcsrc/server/mutators/gamemode_keyhunt.qc
qcsrc/server/mutators/gamemode_nexball.qc
qcsrc/server/mutators/gamemode_onslaught.qc
qcsrc/server/mutators/mutator_buffs.qc
qcsrc/server/mutators/mutator_instagib.qc
qcsrc/server/mutators/mutator_instagib_items.qc
qcsrc/server/mutators/mutator_nades.qc
qcsrc/server/mutators/mutator_new_toys.qc
qcsrc/server/mutators/mutator_overkill.qc
qcsrc/server/mutators/mutator_touchexplode.qc
qcsrc/server/mutators/sandbox.qc
qcsrc/server/pathlib.qc [deleted file]
qcsrc/server/pathlib.qh [deleted file]
qcsrc/server/pathlib/costs.qc
qcsrc/server/pathlib/debug.qc
qcsrc/server/portals.qc
qcsrc/server/progs.inc
qcsrc/server/sv_main.qc
qcsrc/server/sys-pre.qh
qcsrc/server/t_items.qc
qcsrc/server/weapons/common.qc
qcsrc/server/weapons/selection.qc
qcsrc/server/weapons/spawning.qc
qcsrc/server/weapons/tracing.qc
qcsrc/server/weapons/weaponsystem.qc

diff --git a/gfx/hud/default/minigames/qto/board.jpg b/gfx/hud/default/minigames/qto/board.jpg
deleted file mode 100644 (file)
index cf8fe0a..0000000
Binary files a/gfx/hud/default/minigames/qto/board.jpg and /dev/null differ
diff --git a/gfx/hud/default/minigames/qto/board_alpha.jpg b/gfx/hud/default/minigames/qto/board_alpha.jpg
deleted file mode 100644 (file)
index 44a8708..0000000
Binary files a/gfx/hud/default/minigames/qto/board_alpha.jpg and /dev/null differ
diff --git a/gfx/hud/default/minigames/qto/icon.jpg b/gfx/hud/default/minigames/qto/icon.jpg
deleted file mode 100644 (file)
index a534f48..0000000
Binary files a/gfx/hud/default/minigames/qto/icon.jpg and /dev/null differ
diff --git a/gfx/hud/default/minigames/qto/icon_notif.jpg b/gfx/hud/default/minigames/qto/icon_notif.jpg
deleted file mode 100644 (file)
index 90e0e2e..0000000
Binary files a/gfx/hud/default/minigames/qto/icon_notif.jpg and /dev/null differ
diff --git a/gfx/hud/default/minigames/qto/icon_notif_alpha.jpg b/gfx/hud/default/minigames/qto/icon_notif_alpha.jpg
deleted file mode 100644 (file)
index 040990f..0000000
Binary files a/gfx/hud/default/minigames/qto/icon_notif_alpha.jpg and /dev/null differ
diff --git a/gfx/hud/default/minigames/qto/piece0.tga b/gfx/hud/default/minigames/qto/piece0.tga
deleted file mode 100644 (file)
index fad7dbd..0000000
Binary files a/gfx/hud/default/minigames/qto/piece0.tga and /dev/null differ
diff --git a/gfx/hud/default/minigames/qto/piece1.tga b/gfx/hud/default/minigames/qto/piece1.tga
deleted file mode 100644 (file)
index 80a34c2..0000000
Binary files a/gfx/hud/default/minigames/qto/piece1.tga and /dev/null differ
diff --git a/gfx/hud/default/minigames/snake/board.jpg b/gfx/hud/default/minigames/snake/board.jpg
new file mode 100644 (file)
index 0000000..dfc5c3c
Binary files /dev/null and b/gfx/hud/default/minigames/snake/board.jpg differ
diff --git a/gfx/hud/default/minigames/snake/board_alpha.jpg b/gfx/hud/default/minigames/snake/board_alpha.jpg
new file mode 100644 (file)
index 0000000..44a8708
Binary files /dev/null and b/gfx/hud/default/minigames/snake/board_alpha.jpg differ
diff --git a/gfx/hud/default/minigames/snake/body.tga b/gfx/hud/default/minigames/snake/body.tga
new file mode 100644 (file)
index 0000000..b8064cc
Binary files /dev/null and b/gfx/hud/default/minigames/snake/body.tga differ
diff --git a/gfx/hud/default/minigames/snake/head.tga b/gfx/hud/default/minigames/snake/head.tga
new file mode 100644 (file)
index 0000000..0679f84
Binary files /dev/null and b/gfx/hud/default/minigames/snake/head.tga differ
diff --git a/gfx/hud/default/minigames/snake/icon.jpg b/gfx/hud/default/minigames/snake/icon.jpg
new file mode 100644 (file)
index 0000000..14252ae
Binary files /dev/null and b/gfx/hud/default/minigames/snake/icon.jpg differ
diff --git a/gfx/hud/default/minigames/snake/icon_notif.jpg b/gfx/hud/default/minigames/snake/icon_notif.jpg
new file mode 100644 (file)
index 0000000..988b6db
Binary files /dev/null and b/gfx/hud/default/minigames/snake/icon_notif.jpg differ
diff --git a/gfx/hud/default/minigames/snake/icon_notif_alpha.jpg b/gfx/hud/default/minigames/snake/icon_notif_alpha.jpg
new file mode 100644 (file)
index 0000000..040990f
Binary files /dev/null and b/gfx/hud/default/minigames/snake/icon_notif_alpha.jpg differ
diff --git a/gfx/hud/default/minigames/snake/mouse.tga b/gfx/hud/default/minigames/snake/mouse.tga
new file mode 100644 (file)
index 0000000..eda8ef7
Binary files /dev/null and b/gfx/hud/default/minigames/snake/mouse.tga differ
diff --git a/gfx/hud/default/minigames/snake/tail.tga b/gfx/hud/default/minigames/snake/tail.tga
new file mode 100644 (file)
index 0000000..71a7901
Binary files /dev/null and b/gfx/hud/default/minigames/snake/tail.tga differ
diff --git a/gfx/hud/default/minigames/snake/tongue.tga b/gfx/hud/default/minigames/snake/tongue.tga
new file mode 100644 (file)
index 0000000..9818d4e
Binary files /dev/null and b/gfx/hud/default/minigames/snake/tongue.tga differ
index 9922d7e5674db21aa80098de1f956eb4f8863791..6dfec5088f886a3b229b0185c35f2e6d24a4ff17 100644 (file)
@@ -11,4 +11,11 @@ set sv_minigames_pong_ball_radius   0.03125 "Ball radius relative to the board s
 set sv_minigames_pong_ball_number   1       "Number of balls to be played at once"
 
 set sv_minigames_pong_ai_thinkspeed 0.1     "Seconds between AI actions"
-set sv_minigames_pong_ai_tolerance  0.33    "Distance of the ball relative to the paddle size"
\ No newline at end of file
+set sv_minigames_pong_ai_tolerance  0.33    "Distance of the ball relative to the paddle size"
+
+
+// Snake? Snake! SNAAAAKE!!
+set sv_minigames_snake_wrap 0 "Wrap around the edges of the screen instead of dying on touch"
+set sv_minigames_snake_delay_initial 0.7 "Initial delay between snake movement"
+set sv_minigames_snake_delay_multiplier 50 "Multiplier of incremental of movement speed (player_score / cvar)"
+set sv_minigames_snake_delay_min 0.1 "Minimum delay between snake movement (at fastest rate)"
index 9d961c0ad636036bfd440a91ecdddbb2f83dc75b..2cb6c3e7d90431937bab6a1246f001f40b05e2e6 100644 (file)
@@ -102,6 +102,7 @@ set g_monsters_spawnshieldtime 2
 set g_monsters_typefrag 1
 set g_monsters_target_range 2000
 set g_monsters_target_infront 0
+set g_monsters_target_infront_range 0.3
 set g_monsters_attack_range 120
 set g_monsters_respawn 1
 set g_monsters_respawn_delay 20
index 6dd476c2d3b9c1cea04b8ad97a37f75d2b551907..51440d4a3c90da83d77f8e57033c7e2287c188d6 100644 (file)
@@ -9,32 +9,34 @@ QCCVERSIONFILE := qccversion.$(shell (cd server && $(QCC) --version) > qccversio
 QCCFLAGS_WTFS ?= \
        -Wno-field-redeclared
 
-QCCFLAGS ?= \
-       -std=gmqcc \
-       -O3 -flno \
-       -Werror -fno-bail-on-werror -Wall \
-       -fftepp -fftepp-predefs -Wcpp -futf8 -frelaxed-switch -freturn-assignments \
-       $(QCCFLAGS_WTFS) \
-       $(QCCFLAGS_FEATURES) \
-       $(QCCFLAGS_EXTRA) $(QCCFLAGS_WATERMARK)
-
 QCCFLAGS_FEATURES ?= \
        -DVEHICLES_ENABLED=1 \
        -DVEHICLES_USE_ODE=0 \
        -DBUILD_MOD=$(BUILD_MOD)
 
+QCCFLAGS ?= \
+       -std=gmqcc \
+       -O3 \
+       -Werror -Wall -Wcpp \
+       $(QCCFLAGS_WTFS) \
+       -fftepp -flno -futf8 -fno-bail-on-werror -fftepp-predefs \
+       -frelaxed-switch -freturn-assignments \
+       $(QCCFLAGS_WATERMARK) \
+       $(QCCFLAGS_FEATURES) \
+       $(QCCFLAGS_EXTRA)
+
 # xonotic build system overrides this by command line argument to turn off the update-cvarcount step
 XON_BUILDSYSTEM =
 
-all: qc
 .PHONY: all
+all: qc
 
 .PHONY: qc
 qc: ../menu.dat ../progs.dat ../csprogs.dat
 
 .PHONY: clean
 clean:
-       rm -f ../progs.dat ../menu.dat ../csprogs.dat server/precache-for-csqc.inc
+       rm -f ../progs.dat ../menu.dat ../csprogs.dat
 
 $(QCCVERSIONFILE):
        $(RM) qccversion.*
@@ -45,11 +47,8 @@ FILES_CSPROGS = $(shell find client lib common warpzonelib csqcmodellib -type f
        @echo make[1]: Entering directory \`$(PWD)/client\'
        cd client && $(QCC) $(QCCFLAGS) -DCSQC
 
-server/precache-for-csqc.inc: $(FILES_CSPROGS)
-       sh collect-precache.sh
-
 FILES_PROGS = $(shell find server lib common warpzonelib csqcmodellib -type f -not -name fteqcc.log -not -name qc.asm)
-../progs.dat: $(FILES_PROGS) $(QCCVERSIONFILE) server/precache-for-csqc.inc
+../progs.dat: $(FILES_PROGS) $(QCCVERSIONFILE)
        @echo make[1]: Entering directory \`$(PWD)/server\'
        cd server && $(QCC) $(QCCFLAGS) -DSVQC
 
index 66fd813143ded40e3c222e4a70c49aefdc558fa9..12dc1b4a3ae6b23dc09ca2af94a5065d2f32fec4 100644 (file)
@@ -9,5 +9,6 @@
 #include "../dpdefs/csprogsdefs.qh"
 
 #include "../common/models/models.qh"
+#include "../common/sounds/sounds.qh"
 
 #endif
index aec000d64c7c069b8c1d342484b977b3232c680a..a83260b1049c7dfcabcb04926e9b6c817fe1dd23 100644 (file)
@@ -4,7 +4,6 @@
 #include "../common/movetypes/movetypes.qh"
 
 .float alpha;
-bool cpicon_precached;
 .int count;
 .float pain_finished;
 
@@ -21,14 +20,6 @@ bool cpicon_precached;
 
 .entity icon_realmodel;
 
-void cpicon_precache()
-{
-       if(cpicon_precached)
-               return; // already precached
-
-       cpicon_precached = true;
-}
-
 void cpicon_draw()
 {SELFPARAM();
        if(time < self.move_time) { return; }
@@ -186,7 +177,6 @@ void ent_cpicon()
                        self.count = (self.health - self.max_health) * frametime;
 
                cpicon_changeteam();
-               cpicon_precache();
                cpicon_construct();
        }
 
index 8469b5226fc36ef3f0efc15310c9732b0f654552..a2ce395917ae7561f4482c36bac921250780b1f8 100644 (file)
@@ -8,6 +8,5 @@ const int CPSF_STATUS = 4;
 const int CPSF_SETUP = 8;
 
 void ent_cpicon();
-void cpicon_precache();
 
 #endif
index 022afd9d11c937ed493fd1df41ea96f6a0140edb..0c25e60064533141963afe43b98f957756279e2f 100644 (file)
@@ -1,4 +1,3 @@
-#include "csqcmodel_hooks.qh"
 #include "_all.qh"
 
 #include "gibs.qh"
@@ -591,7 +590,7 @@ void CSQCModel_Effects_Apply(void)
        {
                if(!self.snd_looping)
                {
-                       sound(self, CH_TRIGGER_SINGLE, "misc/jetpack_fly.wav", VOL_BASE, autocvar_g_jetpack_attenuation);
+                       sound(self, CH_TRIGGER_SINGLE, SND_JETPACK_FLY, VOL_BASE, autocvar_g_jetpack_attenuation);
                        self.snd_looping = CH_TRIGGER_SINGLE;
                }
        }
@@ -599,17 +598,12 @@ void CSQCModel_Effects_Apply(void)
        {
                if(self.snd_looping)
                {
-                       sound(self, self.snd_looping, "misc/null.wav", VOL_BASE, autocvar_g_jetpack_attenuation);
+                       sound(self, self.snd_looping, SND_Null, VOL_BASE, autocvar_g_jetpack_attenuation);
                        self.snd_looping = 0;
                }
        }
 }
 
-void CSQCPlayer_Precache()
-{
-       precache_sound("misc/jetpack_fly.wav");
-}
-
 // general functions
 .int csqcmodel_predraw_run;
 .int anim_frame;
diff --git a/qcsrc/client/csqcmodel_hooks.qh b/qcsrc/client/csqcmodel_hooks.qh
deleted file mode 100644 (file)
index 8995880..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-#ifndef CSQCMODEL_HOOKS
-#define CSQCMODEL_HOOKS
-
-void CSQCPlayer_Precache();
-
-#endif
index ec6da98428e372d66f15348fc2c50682bec5ac0d..4f25aef13ef2d25bd6c9a1cdf81637f8a104e60c 100644 (file)
@@ -228,35 +228,33 @@ void Ent_DamageInfo(float isNew)
 
                        // spiderbot
                        case DEATH_VH_SPID_MINIGUN:
-                               string _snd;
-                               _snd = W_Sound(strcat("ric", ftos(1 + rint(random() * 2))));
-                               sound(self, CH_SHOTS, _snd, VOL_BASE, ATTEN_NORM);
+                               sound(self, CH_SHOTS, SND_RIC_RANDOM(), VOL_BASE, ATTEN_NORM);
                                pointparticles(particleeffectnum(EFFECT_SPIDERBOT_MINIGUN_IMPACT), self.origin, w_backoff * 1000, 1);
                                break;
                        case DEATH_VH_SPID_ROCKET:
-                               sound(self, CH_SHOTS, W_Sound("rocket_impact"), VOL_BASE, ATTEN_NORM);
+                               sound(self, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
                                pointparticles(particleeffectnum(EFFECT_SPIDERBOT_ROCKET_EXPLODE), self.origin, w_backoff * 1000, 1);
                                break;
                        case DEATH_VH_SPID_DEATH:
-                               sound(self, CH_SHOTS, W_Sound("rocket_impact"), VOL_BASE, ATTEN_MIN);
+                               sound(self, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_MIN);
                                pointparticles(particleeffectnum(EFFECT_EXPLOSION_BIG), self.origin, w_backoff * 1000, 1);
                                break;
 
                        case DEATH_VH_WAKI_GUN:
-                               sound(self, CH_SHOTS, W_Sound("laserimpact"), VOL_BASE, ATTEN_NORM);
+                               sound(self, CH_SHOTS, SND_LASERIMPACT, VOL_BASE, ATTEN_NORM);
                                pointparticles(particleeffectnum(EFFECT_RACER_IMPACT), self.origin, w_backoff * 1000, 1);
                                break;
                        case DEATH_VH_WAKI_ROCKET:
-                               sound(self, CH_SHOTS, W_Sound("rocket_impact"), VOL_BASE, ATTEN_NORM);
+                               sound(self, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
                                pointparticles(particleeffectnum(EFFECT_RACER_ROCKET_EXPLODE), self.origin, w_backoff * 1000, 1);
                                break;
                        case DEATH_VH_WAKI_DEATH:
-                               sound(self, CH_SHOTS, W_Sound("rocket_impact"), VOL_BASE, ATTEN_MIN);
+                               sound(self, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_MIN);
                                pointparticles(particleeffectnum(EFFECT_EXPLOSION_BIG), self.origin, w_backoff * 1000, 1);
                                break;
 
                        case DEATH_VH_RAPT_CANNON:
-                               sound(self, CH_SHOTS, W_Sound("laserimpact"), VOL_BASE, ATTEN_NORM);
+                               sound(self, CH_SHOTS, SND_LASERIMPACT, VOL_BASE, ATTEN_NORM);
                                pointparticles(particleeffectnum(EFFECT_RAPTOR_CANNON_IMPACT), self.origin, w_backoff * 1000, 1);
                                break;
                        case DEATH_VH_RAPT_FRAGMENT:
@@ -268,19 +266,19 @@ void Ent_DamageInfo(float isNew)
                                        ang = vectoangles(vel);
                                        RaptorCBShellfragToss(w_org, vel, ang + '0 0 1' * (120 * i));
                                }
-                               sound(self, CH_SHOTS, W_Sound("rocket_impact"), VOL_BASE, ATTEN_NORM);
+                               sound(self, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
                                pointparticles(particleeffectnum(EFFECT_RAPTOR_BOMB_SPREAD), self.origin, w_backoff * 1000, 1);
                                break;
                        case DEATH_VH_RAPT_BOMB:
-                               sound(self, CH_SHOTS, W_Sound("rocket_impact"), VOL_BASE, ATTEN_NORM);
+                               sound(self, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
                                pointparticles(particleeffectnum(EFFECT_RAPTOR_BOMB_IMPACT), self.origin, w_backoff * 1000, 1);
                                break;
                        case DEATH_VH_RAPT_DEATH:
-                               sound(self, CH_SHOTS, W_Sound("laserimpact"), VOL_BASE, ATTEN_MIN);
+                               sound(self, CH_SHOTS, SND_LASERIMPACT, VOL_BASE, ATTEN_MIN);
                                pointparticles(particleeffectnum(EFFECT_EXPLOSION_BIG), self.origin, w_backoff * 1000, 1);
                                break;
                        case DEATH_VH_BUMB_GUN:
-                               sound(self, CH_SHOTS, W_Sound("fireball_impact2"), VOL_BASE, ATTEN_NORM);
+                               sound(self, CH_SHOTS, SND_FIREBALL_IMPACT2, VOL_BASE, ATTEN_NORM);
                                pointparticles(particleeffectnum(EFFECT_BIGPLASMA_IMPACT), self.origin, w_backoff * 1000, 1);
                                break;
                }
@@ -289,7 +287,6 @@ void Ent_DamageInfo(float isNew)
 
        if(DEATH_ISTURRET(w_deathtype))
        {
-               string _snd;
                traceline(w_org - normalize(force) * 16, w_org + normalize(force) * 16, MOVE_NOMONSTERS, world);
                if(trace_plane_normal != '0 0 0')
                        w_backoff = trace_plane_normal;
@@ -301,38 +298,36 @@ void Ent_DamageInfo(float isNew)
                switch(w_deathtype)
                {
                         case DEATH_TURRET_EWHEEL:
-                               sound(self, CH_SHOTS, W_Sound("laserimpact"), VOL_BASE, ATTEN_MIN);
+                               sound(self, CH_SHOTS, SND_LASERIMPACT, VOL_BASE, ATTEN_MIN);
                                pointparticles(particleeffectnum(EFFECT_BLASTER_IMPACT), self.origin, w_backoff * 1000, 1);
                                break;
 
                         case DEATH_TURRET_FLAC:
                                pointparticles(particleeffectnum(EFFECT_HAGAR_EXPLODE), w_org, '0 0 0', 1);
-                               _snd = W_Sound(strcat("hagexp", ftos(1 + rint(random() * 2))));
-                               sound(self, CH_SHOTS, _snd, VOL_BASE, ATTEN_NORM);
+                               sound(self, CH_SHOTS, SND_HAGEXP_RANDOM(), VOL_BASE, ATTEN_NORM);
                                break;
 
                         case DEATH_TURRET_MLRS:
                         case DEATH_TURRET_HK:
                         case DEATH_TURRET_WALK_ROCKET:
                         case DEATH_TURRET_HELLION:
-                               sound(self, CH_SHOTS, W_Sound("rocket_impact"), VOL_BASE, ATTEN_MIN);
+                               sound(self, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_MIN);
                                pointparticles(particleeffectnum(EFFECT_ROCKET_EXPLODE), self.origin, w_backoff * 1000, 1);
                                break;
 
                         case DEATH_TURRET_MACHINEGUN:
                         case DEATH_TURRET_WALK_GUN:
-                               _snd = W_Sound(strcat("ric", ftos(1 + rint(random() * 2))));
-                               sound(self, CH_SHOTS, _snd, VOL_BASE, ATTEN_NORM);
+                               sound(self, CH_SHOTS, SND_RIC_RANDOM(), VOL_BASE, ATTEN_NORM);
                                pointparticles(particleeffectnum(EFFECT_MACHINEGUN_IMPACT), self.origin, w_backoff * 1000, 1);
                                break;
 
                         case DEATH_TURRET_PLASMA:
-                               sound(self, CH_SHOTS, W_Sound("electro_impact"), VOL_BASE, ATTEN_MIN);
+                               sound(self, CH_SHOTS, SND_ELECTRO_IMPACT, VOL_BASE, ATTEN_MIN);
                                pointparticles(particleeffectnum(EFFECT_ELECTRO_IMPACT), self.origin, w_backoff * 1000, 1);
                                break;
 
                         case DEATH_TURRET_WALK_MELEE:
-                               sound(self, CH_SHOTS, W_Sound("ric1"), VOL_BASE, ATTEN_MIN);
+                               sound(self, CH_SHOTS, SND_RIC1, VOL_BASE, ATTEN_MIN);
                                pointparticles(particleeffectnum(EFFECT_TE_SPARK), self.origin, w_backoff * 1000, 1);
                                break;
 
index c9358b6795cea7091efad0056da321f6eb831ec0..148a8f521b0ab3a2991c9f95aa388368ca69c0f6 100644 (file)
@@ -1,22 +1,8 @@
 #include "generator.qh"
 
-bool generator_precached;
 .int count;
 .float max_health;
 
-void generator_precache()
-{
-       if(generator_precached)
-               return; // already precached
-
-       precache_sound("onslaught/shockwave.wav");
-       precache_sound(W_Sound("grenade_impact"));
-       precache_sound(W_Sound("rocket_impact"));
-       precache_sound("onslaught/electricity_explode.wav");
-
-       generator_precached = true;
-}
-
 void ons_generator_ray_draw()
 {SELFPARAM();
        if(time < self.move_time)
@@ -68,7 +54,7 @@ void generator_draw()
                if(random() < 0.01)
                {
                        pointparticles(particleeffectnum(EFFECT_ELECTRO_BALLEXPLODE), self.origin + randompos('-50 -50 -20', '50 50 50'), '0 0 0', 1);
-                       sound(self, CH_TRIGGER, "onslaught/electricity_explode.wav", VOL_BASE, ATTEN_NORM);
+                       sound(self, CH_TRIGGER, SND_ONS_ELECTRICITY_EXPLODE, VOL_BASE, ATTEN_NORM);
                }
                else
                        pointparticles(particleeffectnum(EFFECT_ONS_GENERATOR_DAMAGED), self.origin + randompos('-60 -60 -20', '60 60 60'), '0 0 0', 1);
@@ -87,7 +73,7 @@ void generator_draw()
        // White shockwave
        if(self.count==40||self.count==20)
        {
-               sound(self, CH_TRIGGER, "onslaught/shockwave.wav", VOL_BASE, ATTEN_NORM);
+               sound(self, CH_TRIGGER, SND_ONS_SHOCKWAVE, VOL_BASE, ATTEN_NORM);
                pointparticles(particleeffectnum(EFFECT_ELECTRO_COMBO), self.origin, '0 0 0', 6);
        }
 
@@ -108,7 +94,7 @@ void generator_draw()
        if(random() < 0.25)
        {
                te_explosion(self.origin);
-               sound(self, CH_TRIGGER, W_Sound("grenade_impact"), VOL_BASE, ATTEN_NORM);
+               sound(self, CH_TRIGGER, SND_GRENADE_IMPACT, VOL_BASE, ATTEN_NORM);
        }
 
        // Particles
@@ -121,7 +107,7 @@ void generator_draw()
                org = self.origin;
                te_explosion(org);
                pointparticles(particleeffectnum(EFFECT_ONS_GENERATOR_EXPLODE2), org, '0 0 0', 1);
-               sound(self, CH_TRIGGER, W_Sound("rocket_impact"), VOL_BASE, ATTEN_NORM);
+               sound(self, CH_TRIGGER, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
        }
 
        self.move_time = time + 0.05;
@@ -213,7 +199,6 @@ void ent_generator()
                        self.count = 40;
 
                generator_changeteam();
-               generator_precache();
                generator_construct();
        }
 
index e4e1611f31273ca1d7dda2173f72405d733ab3c4..744bc5589f47a39edba81e1bf1fe78dbc215d617 100644 (file)
@@ -7,5 +7,4 @@ const int GSF_STATUS = 4;
 const int GSF_SETUP = 8;
 
 void ent_generator();
-void generator_precache();
 #endif
index 0302f184150f81525487e63b5ca272c9052be29e..5c4c338f155c5e91ad7272c5556de0c80f10c486 100644 (file)
@@ -85,7 +85,7 @@ void Gib_Touch()
        }
 
        if(!self.silent)
-               sound(self, CH_PAIN, strcat("misc/gib_splat0", ftos(floor(prandom() * 4 + 1)), ".wav"), VOL_BASE, ATTEN_NORM);
+               sound(self, CH_PAIN, SND_GIB_SPLAT_RANDOM(), VOL_BASE, ATTEN_NORM);
        pointparticles(_particleeffectnum(strcat(species_prefix(self.cnt), "blood")), self.origin + '0 0 1', '0 0 30', 10);
 
        Gib_Delete();
@@ -218,7 +218,7 @@ void Ent_GibSplash(bool isNew)
        {
                case 0x01:
                        if(!issilent)
-                               sound (self, CH_PAIN, "misc/gib.wav", VOL_BASE, ATTEN_NORM);
+                               sound (self, CH_PAIN, SND_GIB, VOL_BASE, ATTEN_NORM);
 
                        if(prandom() < amount)
                                TossGib ("models/gibs/eye.md3", org, org, vel, prandomvec() * 150, specnum, 0, issilent);
@@ -272,12 +272,3 @@ void Ent_GibSplash(bool isNew)
                        break;
        }
 }
-
-void GibSplash_Precache()
-{
-       precache_sound ("misc/gib.wav");
-    precache_sound ("misc/gib_splat01.wav");
-    precache_sound ("misc/gib_splat02.wav");
-    precache_sound ("misc/gib_splat03.wav");
-    precache_sound ("misc/gib_splat04.wav");
-}
index b33a1a5e061bf1416e11085bd812a899a0ca2e88..5b8b16bfd8c11cbac3caba4fd709716dfd8b07a6 100644 (file)
@@ -23,5 +23,4 @@ void TossGib (string mdlname, vector safeorg, vector org, vector vconst, vector
 
 void Ent_GibSplash(bool isNew);
 
-void GibSplash_Precache();
 #endif
index 528646979e987606f70fc3f9c939f9cd15aebbd8..dd70c760c34534a1456165647e1fcc019b10754a 100644 (file)
@@ -44,7 +44,7 @@ void Draw_GrapplingHook()
        if(self.teleport_time)
        if(time > self.teleport_time)
        {
-               sound (self, CH_SHOTS_SINGLE, "misc/null.wav", VOL_BASE, ATTEN_NORM); // safeguard
+               sound (self, CH_SHOTS_SINGLE, SND_Null, VOL_BASE, ATTEN_NORM); // safeguard
                self.teleport_time = 0;
        }
 
@@ -168,7 +168,7 @@ void Draw_GrapplingHook()
 
 void Remove_GrapplingHook()
 {SELFPARAM();
-       sound (self, CH_SHOTS_SINGLE, "misc/null.wav", VOL_BASE, ATTEN_NORM);
+       sound (self, CH_SHOTS_SINGLE, SND_Null, VOL_BASE, ATTEN_NORM);
 }
 
 void Ent_ReadHook(float bIsNew, float type)
@@ -228,7 +228,7 @@ void Ent_ReadHook(float bIsNew, float type)
                                self.drawmask = MASK_NORMAL;
                                break;
                        case ENT_CLIENT_ARC_BEAM:
-                               sound (self, CH_SHOTS_SINGLE, W_Sound("lgbeam_fly"), VOL_BASE, ATTEN_NORM);
+                               sound (self, CH_SHOTS_SINGLE, SND_LGBEAM_FLY, VOL_BASE, ATTEN_NORM);
                                break;
                }
        }
@@ -236,9 +236,4 @@ void Ent_ReadHook(float bIsNew, float type)
        self.teleport_time = time + 10;
 }
 
-void Hook_Precache()
-{
-       precache_sound(W_Sound("lgbeam_fly"));
-}
-
 // TODO: hook: temporarily transform self.origin for drawing the model along warpzones!
index 8401dce049a43cd1c90accf3c6e3c30471da7946..e513ed6afa4451ee0271a1bc33d15716b869edfc 100644 (file)
@@ -2,7 +2,6 @@
 #define HOOK_H
 
 void Draw_CylindricLine(vector from, vector to, float thickness, string texture, float aspect, float shift, vector rgb, float theAlpha, float drawflag, vector vieworg);
-void Hook_Precache();
 
 void Ent_ReadHook(float bIsNew, float type);
 
index c534cc7a5db46dc3362a9b511b551e7bb4861f86..ca31f32f71bf7b5afb82bb487a650653d1da108d 100644 (file)
@@ -2,7 +2,6 @@
 #include "_all.qh"
 
 #include "controlpoint.qh"
-#include "csqcmodel_hooks.qh"
 #include "damage.qh"
 #include "effects.qh"
 #include "generator.qh"
@@ -49,7 +48,6 @@
 #include "../common/triggers/include.qh"
 
 #include "../common/turrets/cl_turrets.qh"
-#include "../common/turrets/turrets.qh"
 
 #include "../warpzonelib/client.qh"
 
@@ -153,18 +151,10 @@ void CSQC_Init(void)
        CALL_ACCUMULATED_FUNCTION(RegisterDeathtypes);
        CALL_ACCUMULATED_FUNCTION(RegisterHUD_Panels);
 
-       initialize_minigames();
-
        // precaches
-       precache_sound("misc/hit.wav");
-       precache_sound("misc/typehit.wav");
 
-       generator_precache();
        Projectile_Precache();
-       Hook_Precache();
-       GibSplash_Precache();
        Tuba_Precache();
-       CSQCPlayer_Precache();
 
        if(autocvar_cl_reticle)
        {
@@ -778,7 +768,7 @@ void Ent_ReadSpawnEvent(float is_new)
                        }
                        if(autocvar_cl_spawn_event_sound)
                        {
-                               sound(self, CH_TRIGGER, "misc/spawn.wav", VOL_BASE, ATTEN_NORM);
+                               sound(self, CH_TRIGGER, SND_SPAWN, VOL_BASE, ATTEN_NORM);
                        }
                }
        }
@@ -935,7 +925,7 @@ void Ent_Remove()
 
        if(self.snd_looping > 0)
        {
-               sound(self, self.snd_looping, "misc/null.wav", VOL_BASE, autocvar_g_jetpack_attenuation);
+               sound(self, self.snd_looping, SND_Null, VOL_BASE, autocvar_g_jetpack_attenuation);
                self.snd_looping = 0;
        }
 
index 3511c743f05b7478a6436c884775742962532b72..945f312ab29a29592806145c248229b94c1fcf92 100644 (file)
@@ -630,8 +630,6 @@ void GameTypeVote_ReadOption(int i)
 
 void MapVote_Init()
 {
-       precache_sound ("misc/invshot.wav");
-
        mv_active = 1;
        if(autocvar_hud_cursormode) { setcursormode(1); }
        else { mv_mousepos = '0.5 0 0' * vid_conwidth + '0 0.5 0' * vid_conheight; }
index 9fd5647afd9cc801c818c38f013322257f705e97..3d742a624588ce6de0fc83ae2fef10896ea172ea 100644 (file)
@@ -60,7 +60,7 @@
 #include "../common/weapons/all.qc"
 
 #include "../common/turrets/cl_turrets.qc"
-#include "../common/turrets/turrets.qc"
+#include "../common/turrets/all.qc"
 
 #include "../common/triggers/include.qc"
 
index 1acfbd7eb7b1aee14fc43e40dd8507bfe7379fe2..91ccbba5c853e7d1d7367e1da60c0f404cefefca 100644 (file)
@@ -65,7 +65,7 @@ void tubasound(entity e, bool restart)
                if (restart) {
                        snd1 = TUBA_STARTNOTE(e.tuba_instrument, e.note);
                }
-               sound(e, CH_TUBA_SINGLE, snd1, e.tuba_volume, e.tuba_attenuate * autocvar_g_balance_tuba_attenuation);
+               _sound(e, CH_TUBA_SINGLE, snd1, e.tuba_volume, e.tuba_attenuate * autocvar_g_balance_tuba_attenuation);
        }
 }
 
@@ -79,9 +79,9 @@ void Ent_TubaNote_Think()
        }
        self.nextthink = time;
        if (self.tuba_volume <= 0) {
-               sound(self, CH_TUBA_SINGLE, "misc/null.wav", 0, 0);
+               sound(self, CH_TUBA_SINGLE, SND_Null, 0, 0);
                if (self.enemy) {
-                       sound(self.enemy, CH_TUBA_SINGLE, "misc/null.wav", 0, 0);
+                       sound(self.enemy, CH_TUBA_SINGLE, SND_Null, 0, 0);
                        remove(self.enemy);
                }
                remove(self);
index 146d322fcce134b6d23df2e915c98df2d4f9c749..26089f9158e764ff2d1d47b41f2661b8494c5c46 100644 (file)
@@ -517,7 +517,7 @@ void UpdateHitsound()
                        // todo: avoid very long and very short sounds from wave stretching using different sound files? seems unnecessary
                        // todo: normalize sound pressure levels? seems unnecessary
 
-                       sound7(world, CH_INFO, "misc/hit.wav", VOL_BASE, ATTN_NONE, pitch_shift * 100, 0);
+                       sound7(world, CH_INFO, SND(HIT), VOL_BASE, ATTN_NONE, pitch_shift * 100, 0);
                }
                unaccounted_damage = 0;
                hitsound_time_prev = time;
@@ -527,7 +527,7 @@ void UpdateHitsound()
        float typehit_time = getstatf(STAT_TYPEHIT_TIME);
        if (COMPARE_INCREASING(typehit_time, typehit_time_prev) > autocvar_cl_hitsound_antispam_time)
        {
-               sound(world, CH_INFO, "misc/typehit.wav", VOL_BASE, ATTN_NONE);
+               sound(world, CH_INFO, SND_TYPEHIT, VOL_BASE, ATTN_NONE);
                typehit_time_prev = typehit_time;
        }
 }
index 1be6f8974b77bb5034279b82afb0e9ecae104b55..07228885db781391164839d875dc489315ce52bf 100644 (file)
@@ -170,7 +170,7 @@ void loopsound(entity e, int ch, string samp, float vol, float attn)
        if(self.silent)
                return;
 
-       sound(e, ch, samp, vol, attn);
+       _sound(e, ch, samp, vol, attn);
        e.snd_looping = ch;
 }
 
@@ -270,9 +270,6 @@ void Ent_Projectile()
 
        if(f & 2)
        {
-               string rm_suffix = strcat("rocketminsta_laser_", Static_Team_ColorName_Lower(self.team));
-               if(_particleeffectnum(rm_suffix) < 0 || Team_TeamToNumber(self.team) == -1) { rm_suffix = "TR_NEXUIZPLASMA"; }
-
                self.cnt = ReadByte();
 
                self.silent = (self.cnt & 0x80);
@@ -320,7 +317,7 @@ void Ent_Projectile()
 
                        CASE(RPC)                self.traileffect = particleeffectnum(EFFECT_TR_ROCKET); break;
 
-                       CASE(ROCKETMINSTA_LASER) self.traileffect = _particleeffectnum(rm_suffix); break;
+                       CASE(ROCKETMINSTA_LASER) self.traileffect = particleeffectnum(EFFECT_ROCKETMINSTA_LASER(self.team)); break;
 #undef CASE
                        default:
                                if(MUTATOR_CALLHOOK(Ent_Projectile, self))
@@ -347,7 +344,7 @@ void Ent_Projectile()
                {
                        case PROJECTILE_ELECTRO:
                                // only new engines support sound moving with object
-                               loopsound(self, CH_SHOTS_SINGLE, W_Sound("electro_fly"), VOL_BASE, ATTEN_NORM);
+                               loopsound(self, CH_SHOTS_SINGLE, SND(ELECTRO_FLY), VOL_BASE, ATTEN_NORM);
                                self.mins = '0 0 -4';
                                self.maxs = '0 0 -4';
                                self.move_movetype = MOVETYPE_BOUNCE;
@@ -357,7 +354,7 @@ void Ent_Projectile()
                                break;
                        case PROJECTILE_RPC:
                        case PROJECTILE_ROCKET:
-                               loopsound(self, CH_SHOTS_SINGLE, W_Sound("rocket_fly"), VOL_BASE, ATTEN_NORM);
+                               loopsound(self, CH_SHOTS_SINGLE, SND(ROCKET_FLY), VOL_BASE, ATTEN_NORM);
                                self.mins = '-3 -3 -3';
                                self.maxs = '3 3 3';
                                break;
@@ -405,12 +402,12 @@ void Ent_Projectile()
                                break;
                        case PROJECTILE_NAPALM_FOUNTAIN:
                        case PROJECTILE_FIREBALL:
-                               loopsound(self, CH_SHOTS_SINGLE, W_Sound("fireball_fly2"), VOL_BASE, ATTEN_NORM);
+                               loopsound(self, CH_SHOTS_SINGLE, SND(FIREBALL_FLY2), VOL_BASE, ATTEN_NORM);
                                self.mins = '-16 -16 -16';
                                self.maxs = '16 16 16';
                                break;
                        case PROJECTILE_FIREMINE:
-                               loopsound(self, CH_SHOTS_SINGLE, W_Sound("fireball_fly"), VOL_BASE, ATTEN_NORM);
+                               loopsound(self, CH_SHOTS_SINGLE, SND(FIREBALL_FLY), VOL_BASE, ATTEN_NORM);
                                self.move_movetype = MOVETYPE_BOUNCE;
                                self.move_touch = func_null;
                                self.mins = '-4 -4 -4';
@@ -425,7 +422,7 @@ void Ent_Projectile()
                                self.maxs = '2 2 2';
                                break;
                        case PROJECTILE_SEEKER:
-                               loopsound(self, CH_SHOTS_SINGLE, W_Sound("tag_rocket_fly"), VOL_BASE, ATTEN_NORM);
+                               loopsound(self, CH_SHOTS_SINGLE, SND(TAG_ROCKET_FLY), VOL_BASE, ATTEN_NORM);
                                self.mins = '-4 -4 -4';
                                self.maxs = '4 4 4';
                                break;
@@ -438,17 +435,17 @@ void Ent_Projectile()
             case PROJECTILE_RAPTORCANNON:
                                break;
             case PROJECTILE_SPIDERROCKET:
-                loopsound(self, CH_SHOTS_SINGLE, W_Sound("tag_rocket_fly"), VOL_BASE, ATTEN_NORM);
+                loopsound(self, CH_SHOTS_SINGLE, SND(TAG_ROCKET_FLY), VOL_BASE, ATTEN_NORM);
                                break;
             case PROJECTILE_WAKIROCKET:
-                loopsound(self, CH_SHOTS_SINGLE, W_Sound("tag_rocket_fly"), VOL_BASE, ATTEN_NORM);
+                loopsound(self, CH_SHOTS_SINGLE, SND(TAG_ROCKET_FLY), VOL_BASE, ATTEN_NORM);
                                break;
             /*
             case PROJECTILE_WAKICANNON:
                                break;
                        case PROJECTILE_BUMBLE_GUN:
                                // only new engines support sound moving with object
-                               loopsound(self, CH_SHOTS_SINGLE, W_Sound("electro_fly"), VOL_BASE, ATTEN_NORM);
+                               loopsound(self, CH_SHOTS_SINGLE, SND(ELECTRO_FLY), VOL_BASE, ATTEN_NORM);
                                self.mins = '0 0 -4';
                                self.maxs = '0 0 -4';
                                self.move_movetype = MOVETYPE_BOUNCE;
@@ -508,11 +505,5 @@ void Ent_Projectile()
 
 void Projectile_Precache()
 {
-       precache_sound(W_Sound("electro_fly"));
-       precache_sound(W_Sound("rocket_fly"));
-       precache_sound(W_Sound("fireball_fly"));
-       precache_sound(W_Sound("fireball_fly2"));
-       precache_sound(W_Sound("tag_rocket_fly"));
-
        MUTATOR_CALLHOOK(PrecacheProjectiles);
 }
diff --git a/qcsrc/collect-precache.sh b/qcsrc/collect-precache.sh
deleted file mode 100755 (executable)
index 302220c..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/bin/sh
-
-{
-       grep -h '\<precache_model *( *"' client/* | grep -v "//NO_SV_PRECACHE"
-       grep -h '\<precache_sound *( *"' client/* | grep -v "//NO_SV_PRECACHE"
-} > server/precache-for-csqc.inc
-
index cbd3a44ab5d40e4f739d3ef04b734e3c5d8d2754..4d82087e05dc47bea1ec9eb0b08aa18cd56247f6 100644 (file)
@@ -46,15 +46,35 @@ EFFECT(0, VORTEX_IMPACT,            "nex_impact")
 EFFECT(0, VORTEX_MUZZLEFLASH,       "nex_muzzleflash")
 
 EFFECT(1, VAPORIZER_RED,            "TE_TEI_G3RED")
-EFFECT(1, VAPORIZER_RED_HIT,        "TE_TEI_G3RED_HIT")
+EFFECT(1, VAPORIZER_HIT_RED,        "TE_TEI_G3RED_HIT")
 EFFECT(1, VAPORIZER_BLUE,           "TE_TEI_G3BLUE")
-EFFECT(1, VAPORIZER_BLUE_HIT,       "TE_TEI_G3BLUE_HIT")
+EFFECT(1, VAPORIZER_HIT_BLUE,       "TE_TEI_G3BLUE_HIT")
 EFFECT(1, VAPORIZER_YELLOW,         "TE_TEI_G3YELLOW")
-EFFECT(1, VAPORIZER_YELLOW_HIT,     "TE_TEI_G3YELLOW_HIT")
+EFFECT(1, VAPORIZER_HIT_YELLOW,     "TE_TEI_G3YELLOW_HIT")
 EFFECT(1, VAPORIZER_PINK,           "TE_TEI_G3PINK")
-EFFECT(1, VAPORIZER_PINK_HIT,       "TE_TEI_G3PINK_HIT")
+EFFECT(1, VAPORIZER_HIT_PINK,       "TE_TEI_G3PINK_HIT")
 EFFECT(1, VAPORIZER_NEUTRAL,        "TE_TEI_G3")
-EFFECT(1, VAPORIZER_NEUTRAL_HIT,    "TE_TEI_G3_HIT")
+EFFECT(1, VAPORIZER_HIT_NEUTRAL,    "TE_TEI_G3_HIT")
+entity EFFECT_VAPORIZER(int teamid)
+{
+    switch (teamid) {
+        case NUM_TEAM_1:    return EFFECT_VAPORIZER_RED;
+        case NUM_TEAM_2:    return EFFECT_VAPORIZER_BLUE;
+        case NUM_TEAM_3:    return EFFECT_VAPORIZER_YELLOW;
+        case NUM_TEAM_4:    return EFFECT_VAPORIZER_PINK;
+        default:            return EFFECT_VAPORIZER_NEUTRAL;
+    }
+}
+entity EFFECT_VAPORIZER_HIT(int teamid)
+{
+    switch (teamid) {
+        case NUM_TEAM_1:    return EFFECT_VAPORIZER_HIT_RED;
+        case NUM_TEAM_2:    return EFFECT_VAPORIZER_HIT_BLUE;
+        case NUM_TEAM_3:    return EFFECT_VAPORIZER_HIT_YELLOW;
+        case NUM_TEAM_4:    return EFFECT_VAPORIZER_HIT_PINK;
+        default:            return EFFECT_VAPORIZER_HIT_NEUTRAL;
+    }
+}
 
 EFFECT(0, RIFLE_IMPACT,             "machinegun_impact")
 EFFECT(0, RIFLE_MUZZLEFLASH,        "rifle_muzzleflash")
@@ -124,11 +144,53 @@ EFFECT(0, SPAWN_PINK,               "spawn_event_pink")
 EFFECT(0, SPAWNPOINT_NEUTRAL,       "spawn_point_neutral")
 EFFECT(0, SPAWN_NEUTRAL,            "spawn_event_neutral")
 
-EFFECT(0, NADE_RED_EXPLODE,         "nade_red_explode")
-EFFECT(0, NADE_BLUE_EXPLODE,        "nade_blue_explode")
-EFFECT(0, NADE_YELLOW_EXPLODE,      "nade_yellow_explode")
-EFFECT(0, NADE_PINK_EXPLODE,        "nade_pink_explode")
-EFFECT(0, NADE_NEUTRAL_EXPLODE,     "nade_neutral_explode")
+EFFECT(0, NADE_EXPLODE_RED,         "nade_red_explode")
+EFFECT(0, NADE_EXPLODE_BLUE,        "nade_blue_explode")
+EFFECT(0, NADE_EXPLODE_YELLOW,      "nade_yellow_explode")
+EFFECT(0, NADE_EXPLODE_PINK,        "nade_pink_explode")
+EFFECT(0, NADE_EXPLODE_NEUTRAL,     "nade_neutral_explode")
+entity EFFECT_NADE_EXPLODE(int teamid)
+{
+    switch (teamid) {
+        case NUM_TEAM_1:    return EFFECT_NADE_EXPLODE_RED;
+        case NUM_TEAM_2:    return EFFECT_NADE_EXPLODE_BLUE;
+        case NUM_TEAM_3:    return EFFECT_NADE_EXPLODE_YELLOW;
+        case NUM_TEAM_4:    return EFFECT_NADE_EXPLODE_PINK;
+        default:                   return EFFECT_NADE_EXPLODE_NEUTRAL;
+    }
+}
+
+EFFECT(1, NADE_TRAIL_RED,           "nade_red")
+EFFECT(1, NADE_TRAIL_BLUE,          "nade_blue")
+EFFECT(1, NADE_TRAIL_YELLOW,        "nade_yellow")
+EFFECT(1, NADE_TRAIL_PINK,          "nade_pink")
+EFFECT(1, NADE_TRAIL_NEUTRAL,       "nade_neutral")
+entity EFFECT_NADE_TRAIL(int teamid)
+{
+    switch (teamid) {
+        case NUM_TEAM_1:    return EFFECT_NADE_TRAIL_RED;
+        case NUM_TEAM_2:    return EFFECT_NADE_TRAIL_BLUE;
+        case NUM_TEAM_3:    return EFFECT_NADE_TRAIL_YELLOW;
+        case NUM_TEAM_4:    return EFFECT_NADE_TRAIL_PINK;
+        default:            return EFFECT_NADE_TRAIL_NEUTRAL;
+    }
+}
+
+EFFECT(1, NADE_TRAIL_BURN_RED,      "nade_red_burn")
+EFFECT(1, NADE_TRAIL_BURN_BLUE,     "nade_blue_burn")
+EFFECT(1, NADE_TRAIL_BURN_YELLOW,   "nade_yellow_burn")
+EFFECT(1, NADE_TRAIL_BURN_PINK,     "nade_pink_burn")
+EFFECT(1, NADE_TRAIL_BURN_NEUTRAL,  "nade_neutral_burn")
+entity EFFECT_NADE_TRAIL_BURN(int teamid)
+{
+    switch (teamid) {
+        case NUM_TEAM_1:    return EFFECT_NADE_TRAIL_BURN_RED;
+        case NUM_TEAM_2:    return EFFECT_NADE_TRAIL_BURN_BLUE;
+        case NUM_TEAM_3:    return EFFECT_NADE_TRAIL_BURN_YELLOW;
+        case NUM_TEAM_4:    return EFFECT_NADE_TRAIL_BURN_PINK;
+        default:            return EFFECT_NADE_TRAIL_BURN_NEUTRAL;
+    }
+}
 
 EFFECT(0, ICEORGLASS,               "iceorglass")
 EFFECT(0, ICEFIELD,                 "icefield")
@@ -137,20 +199,43 @@ EFFECT(0, HEALING,                  "healing_fx")
 EFFECT(1, LASER_BEAM_FAST,          "nex242_misc_laser_beam_fast")
 EFFECT(0, RESPAWN_GHOST,            "respawn_ghost")
 
-EFFECT(0, FLAG_RED_TOUCH,           "redflag_touch")
-EFFECT(0, FLAG_BLUE_TOUCH,          "blueflag_touch")
-EFFECT(0, FLAG_YELLOW_TOUCH,        "yellowflag_touch")
-EFFECT(0, FLAG_PINK_TOUCH,          "pinkflag_touch")
-EFFECT(0, FLAG_NEUTRAL_TOUCH,       "neutralflag_touch")
-EFFECT(1, RED_PASS,                 "red_pass")
-EFFECT(1, BLUE_PASS,                "blue_pass")
-EFFECT(1, YELLOW_PASS,              "yellow_pass")
-EFFECT(1, PINK_PASS,                "pink_pass")
-EFFECT(1, NEUTRAL_PASS,             "neutral_pass")
-EFFECT(0, RED_CAP,                  "red_cap")
-EFFECT(0, BLUE_CAP,                 "blue_cap")
-EFFECT(0, YELLOW_CAP,               "yellow_cap")
-EFFECT(0, PINK_CAP,                 "pink_cap")
+EFFECT(0, FLAG_TOUCH_RED,           "redflag_touch")
+EFFECT(0, FLAG_TOUCH_BLUE,          "blueflag_touch")
+EFFECT(0, FLAG_TOUCH_YELLOW,        "yellowflag_touch")
+EFFECT(0, FLAG_TOUCH_PINK,          "pinkflag_touch")
+EFFECT(0, FLAG_TOUCH_NEUTRAL,       "neutralflag_touch")
+entity EFFECT_FLAG_TOUCH(int teamid)
+{
+    switch (teamid) {
+        case NUM_TEAM_1:    return EFFECT_FLAG_TOUCH_RED;
+        case NUM_TEAM_2:    return EFFECT_FLAG_TOUCH_BLUE;
+        case NUM_TEAM_3:    return EFFECT_FLAG_TOUCH_YELLOW;
+        case NUM_TEAM_4:    return EFFECT_FLAG_TOUCH_PINK;
+        default:            return EFFECT_FLAG_TOUCH_NEUTRAL;
+    }
+}
+
+EFFECT(1, PASS_RED,                 "red_pass")
+EFFECT(1, PASS_BLUE,                "blue_pass")
+EFFECT(1, PASS_YELLOW,              "yellow_pass")
+EFFECT(1, PASS_PINK,                "pink_pass")
+EFFECT(1, PASS_NEUTRAL,             "neutral_pass")
+
+EFFECT(0, CAP_RED,                  "red_cap")
+EFFECT(0, CAP_BLUE,                 "blue_cap")
+EFFECT(0, CAP_YELLOW,               "yellow_cap")
+EFFECT(0, CAP_PINK,                 "pink_cap")
+EFFECT(0, CAP_NEUTRAL,              "neutral_cap")
+entity EFFECT_CAP(int teamid)
+{
+    switch (teamid) {
+        case NUM_TEAM_1:    return EFFECT_CAP_RED;
+        case NUM_TEAM_2:    return EFFECT_CAP_BLUE;
+        case NUM_TEAM_3:    return EFFECT_CAP_YELLOW;
+        case NUM_TEAM_4:    return EFFECT_CAP_PINK;
+        default:            return EFFECT_CAP_NEUTRAL;
+    }
+}
 
 EFFECT(0, ITEM_PICKUP,              "item_pickup")
 EFFECT(0, ITEM_RESPAWN,             "item_respawn")
@@ -187,3 +272,22 @@ EFFECT(1, TR_SLIGHTBLOOD,           "TR_SLIGHTBLOOD")
 EFFECT(1, TR_KNIGHTSPIKE,           "TR_KNIGHTSPIKE")
 EFFECT(1, TR_VORESPIKE,             "TR_VORESPIKE")
 EFFECT(0, TE_SPARK,                 "TE_SPARK")
+
+EFFECT(1, ROCKETMINSTA_LASER_RED,       "rocketminsta_laser_red")
+EFFECT(1, ROCKETMINSTA_LASER_BLUE,      "rocketminsta_laser_blue")
+EFFECT(1, ROCKETMINSTA_LASER_YELLOW,    "rocketminsta_laser_yellow")
+EFFECT(1, ROCKETMINSTA_LASER_PINK,      "rocketminsta_laser_pink")
+EFFECT(1, ROCKETMINSTA_LASER_NEUTRAL,   "rocketminsta_laser_neutral")
+entity EFFECT_ROCKETMINSTA_LASER(int teamid)
+{
+    entity e;
+    switch (teamid) {
+        case NUM_TEAM_1:    e = EFFECT_ROCKETMINSTA_LASER_RED; break;
+        case NUM_TEAM_2:    e = EFFECT_ROCKETMINSTA_LASER_BLUE; break;
+        case NUM_TEAM_3:    e = EFFECT_ROCKETMINSTA_LASER_YELLOW; break;
+        case NUM_TEAM_4:    e = EFFECT_ROCKETMINSTA_LASER_PINK; break;
+        default:            e = EFFECT_ROCKETMINSTA_LASER_NEUTRAL; break;
+    }
+    if (particleeffectnum(e) < 0 || Team_TeamToNumber(teamid) == -1) { e = EFFECT_TR_NEXUIZPLASMA; }
+    return e;
+}
index fc225cdb7d40ecf648da2b802ecd504fba8631cc..8a9e314020bd16f100774837050c14d3ed3019a5 100644 (file)
@@ -11,4 +11,14 @@ void Dump_Items()
     ));
 }
 
+string Item_Model(string item_mdl)
+{
+    string output = strcat("models/items/", item_mdl);
+#ifdef SVQC
+    MUTATOR_CALLHOOK(ItemModel, item_mdl, output);
+    output = item_model_output;
+#endif
+    return output;
+}
+
 #endif
index 2e33119fb089920e71c69ccf07051223dc945496..3f8c603e7ab2aabeb75c74f438a00e73bba7593b 100644 (file)
@@ -11,6 +11,10 @@ REGISTER_REGISTRY(RegisterItems)
 
 void Dump_Items();
 
+#ifndef MENUQC
+string Item_Model(string item_mdl);
+#endif
+
 #endif
 
 #include "inventory.qh"
index 2d487a7b51be6723a030f44af5e14d5997da9883..16673711eea4b463b17c76d37702148dfa72176b 100644 (file)
@@ -3,8 +3,14 @@
     #include "../../../server/t_items.qh"
 #endif
 
+#ifndef MENUQC
+MODEL(Bullets_ITEM, Item_Model("a_bullets.mdl"));
+#endif
+
 REGISTER_ITEM(Bullets, Ammo) {
-    this.m_model    =   "a_bullets.mdl";
+#ifndef MENUQC
+    this.m_model    =   MDL_Bullets_ITEM;
+#endif
     this.m_name     =   "bullets";
     this.m_icon     =   "ammo_bullets";
 #ifdef SVQC
@@ -12,8 +18,15 @@ REGISTER_ITEM(Bullets, Ammo) {
     this.m_itemid   =   IT_NAILS;
 #endif
 }
+
+#ifndef MENUQC
+MODEL(Cells_ITEM, Item_Model("a_cells.md3"));
+#endif
+
 REGISTER_ITEM(Cells, Ammo) {
-    this.m_model    =   "a_cells.md3";
+#ifndef MENUQC
+    this.m_model    =   MDL_Cells_ITEM;
+#endif
     this.m_name     =   "cells";
     this.m_icon     =   "ammo_cells";
 #ifdef SVQC
@@ -21,8 +34,15 @@ REGISTER_ITEM(Cells, Ammo) {
     this.m_itemid   =   IT_CELLS;
 #endif
 }
+
+#ifndef MENUQC
+MODEL(Plasma_ITEM, Item_Model("a_cells.md3"));
+#endif
+
 REGISTER_ITEM(Plasma, Ammo) {
-    this.m_model    =   "a_cells.md3";
+#ifndef MENUQC
+    this.m_model    =   MDL_Plasma_ITEM;
+#endif
     this.m_name     =   "plasma";
     this.m_icon     =   "ammo_plasma";
 #ifdef SVQC
@@ -30,8 +50,15 @@ REGISTER_ITEM(Plasma, Ammo) {
     this.m_itemid   =   IT_PLASMA;
 #endif
 }
+
+#ifndef MENUQC
+MODEL(Rockets_ITEM, Item_Model("a_rockets.md3"));
+#endif
+
 REGISTER_ITEM(Rockets, Ammo) {
-    this.m_model    =   "a_rockets.md3";
+#ifndef MENUQC
+    this.m_model    =   MDL_Rockets_ITEM;
+#endif
     this.m_name     =   "rockets";
     this.m_icon     =   "ammo_rockets";
 #ifdef SVQC
@@ -39,8 +66,15 @@ REGISTER_ITEM(Rockets, Ammo) {
     this.m_itemid   =   IT_ROCKETS;
 #endif
 }
+
+#ifndef MENUQC
+MODEL(Shells_ITEM, Item_Model("a_shells.md3"));
+#endif
+
 REGISTER_ITEM(Shells, Ammo) {
-    this.m_model    =   "a_shells.md3";
+#ifndef MENUQC
+    this.m_model    =   MDL_Shells_ITEM;
+#endif
     this.m_name     =   "shells";
     this.m_icon     =   "ammo_shells";
 #ifdef SVQC
index e7965803e2115e1e2f7f631fae6680a878d2eeaa..13a774ebcec18f693120f19e7b89982d688fe788 100644 (file)
@@ -3,8 +3,14 @@
     #include "../../../server/t_items.qh"
 #endif
 
+#ifndef MENUQC
+MODEL(ArmorSmall_ITEM, Item_Model("item_armor_small.md3"));
+#endif
+
 REGISTER_ITEM(ArmorSmall, Armor) {
-    this.m_model                =   "item_armor_small.md3";
+#ifndef MENUQC
+    this.m_model                =   MDL_ArmorSmall_ITEM;
+#endif
     this.m_sound                =   "misc/armor1.wav";
     this.m_name                 =   "5 Armor";
     this.m_icon                 =   "armor";
@@ -16,8 +22,14 @@ REGISTER_ITEM(ArmorSmall, Armor) {
 #endif
 }
 
+#ifndef MENUQC
+MODEL(ArmorMedium_ITEM, Item_Model("item_armor_medium.md3"));
+#endif
+
 REGISTER_ITEM(ArmorMedium, Armor) {
-    this.m_model                =   "item_armor_medium.md3";
+#ifndef MENUQC
+    this.m_model                =   MDL_ArmorMedium_ITEM;
+#endif
     this.m_sound                =   "misc/armor10.wav";
     this.m_name                 =   "25 Armor";
     this.m_icon                 =   "armor";
@@ -29,8 +41,14 @@ REGISTER_ITEM(ArmorMedium, Armor) {
 #endif
 }
 
+#ifndef MENUQC
+MODEL(ArmorLarge_ITEM, Item_Model("item_armor_big.md3"));
+#endif
+
 REGISTER_ITEM(ArmorLarge, Armor) {
-    this.m_model                =   "item_armor_big.md3";
+#ifndef MENUQC
+    this.m_model                =   MDL_ArmorLarge_ITEM;
+#endif
     this.m_sound                =   "misc/armor17_5.wav";
     this.m_name                 =   "50 Armor";
     this.m_icon                 =   "armor";
@@ -44,8 +62,14 @@ REGISTER_ITEM(ArmorLarge, Armor) {
 #endif
 }
 
+#ifndef MENUQC
+MODEL(ArmorMega_ITEM, Item_Model("item_armor_large.md3"));
+#endif
+
 REGISTER_ITEM(ArmorMega, Armor) {
-    this.m_model                =   "item_armor_large.md3";
+#ifndef MENUQC
+    this.m_model                =   MDL_ArmorMega_ITEM;
+#endif
     this.m_sound                =   "misc/armor25.wav";
     this.m_name                 =   "100 Armor";
     this.m_icon                 =   "item_large_armor";
index bb9d90eb44cdb9c2af8fc1d62cb54ec8665318a8..b81bde7afc22d1b0bd2152f990d5746725e215b3 100644 (file)
@@ -3,8 +3,14 @@
     #include "../../../server/t_items.qh"
 #endif
 
+#ifndef MENUQC
+MODEL(HealthSmall_ITEM, Item_Model("g_h1.md3"));
+#endif
+
 REGISTER_ITEM(HealthSmall, Health) {
-    this.m_model                =   "g_h1.md3";
+#ifndef MENUQC
+    this.m_model                =   MDL_HealthSmall_ITEM;
+#endif
     this.m_sound                =   "misc/minihealth.wav";
     this.m_name                 =   "5 Health";
     this.m_icon                 =   "health";
@@ -16,8 +22,14 @@ REGISTER_ITEM(HealthSmall, Health) {
 #endif
 }
 
+#ifndef MENUQC
+MODEL(HealthMedium_ITEM, Item_Model("g_h25.md3"));
+#endif
+
 REGISTER_ITEM(HealthMedium, Health) {
-    this.m_model                =   "g_h25.md3";
+#ifndef MENUQC
+    this.m_model                =   MDL_HealthMedium_ITEM;
+#endif
     this.m_sound                =   "misc/mediumhealth.wav";
     this.m_name                 =   "25 Health";
     this.m_icon                 =   "health";
@@ -29,8 +41,14 @@ REGISTER_ITEM(HealthMedium, Health) {
 #endif
 }
 
+#ifndef MENUQC
+MODEL(HealthLarge_ITEM, Item_Model("g_h50.md3"));
+#endif
+
 REGISTER_ITEM(HealthLarge, Health) {
-    this.m_model                =   "g_h50.md3";
+#ifndef MENUQC
+    this.m_model                =   MDL_HealthLarge_ITEM;
+#endif
     this.m_sound                =   "misc/mediumhealth.wav";
     this.m_name                 =   "50 Health";
     this.m_icon                 =   "health";
@@ -44,8 +62,14 @@ REGISTER_ITEM(HealthLarge, Health) {
 #endif
 }
 
+#ifndef MENUQC
+MODEL(HealthMega_ITEM, Item_Model("g_h100.md3"));
+#endif
+
 REGISTER_ITEM(HealthMega, Health) {
-    this.m_model                =   "g_h100.md3";
+#ifndef MENUQC
+    this.m_model                =   MDL_HealthMega_ITEM;
+#endif
     this.m_sound                =   "misc/megahealth.wav";
     this.m_name                 =   "100 Health";
     this.m_icon                 =   "item_mega_health";
index 3b4cfbc141c9a6b1798612f7b8ef7238162f20eb..63019aebe8bbf50800da4967ce6421144bb1d906 100644 (file)
@@ -6,8 +6,14 @@
 #include "ammo.qh"
 #include "powerup.qh"
 
+#ifndef MENUQC
+MODEL(Jetpack_ITEM, Item_Model("g_jetpack.md3"));
+#endif
+
 REGISTER_ITEM(Jetpack, Powerup) {
-    this.m_model                =   "g_jetpack.md3";
+#ifndef MENUQC
+    this.m_model                =   MDL_Jetpack_ITEM;
+#endif
     this.m_name                 =   "Jet pack";
     this.m_icon                 =   "jetpack";
     this.m_color                =   '0.5 0.5 0.5';
@@ -20,8 +26,14 @@ REGISTER_ITEM(Jetpack, Powerup) {
 #endif
 }
 
+#ifndef MENUQC
+MODEL(JetpackFuel_ITEM, Item_Model("g_fuel.md3"));
+#endif
+
 REGISTER_ITEM(JetpackFuel, Ammo) {
-    this.m_model    =   "g_fuel.md3";
+#ifndef MENUQC
+    this.m_model    =   MDL_JetpackFuel_ITEM;
+#endif
     this.m_name     =   "Fuel";
     this.m_icon     =   "ammo_fuel";
 #ifdef SVQC
@@ -30,8 +42,14 @@ REGISTER_ITEM(JetpackFuel, Ammo) {
 #endif
 }
 
+#ifndef MENUQC
+MODEL(JetpackRegen_ITEM, Item_Model("g_fuelregen.md3"));
+#endif
+
 REGISTER_ITEM(JetpackRegen, Pickup) {
-    this.m_model                =   "g_fuelregen.md3";
+#ifndef MENUQC
+    this.m_model                =   MDL_JetpackRegen_ITEM;
+#endif
     this.m_name                 =   "Fuel regenerator";
     this.m_icon                 =   "fuelregen";
     this.m_color                =   '1 0.5 0';
index 793230e359f831222ad7c309a7a7b001cbe332a0..6f60337c195a7ab7d79c43a04f5ec937e771ab67 100644 (file)
@@ -2,7 +2,9 @@
 #define PICKUP_H
 #include "../item.qh"
 CLASS(Pickup, GameItem)
-    ATTRIB(Pickup, m_model, string, string_null)
+#ifndef MENUQC
+    ATTRIB(Pickup, m_model, Model, NULL)
+#endif
     ATTRIB(Pickup, m_sound, string, "misc/itempickup.wav")
     ATTRIB(Pickup, m_name, string, string_null)
     METHOD(Pickup, show, void(entity this));
index fcfe2afb93a5a7c4b44183dfd6c654595f9c1c77..f411d748a8d5eaeb891ec8eace2d2dd76725695e 100644 (file)
@@ -4,8 +4,15 @@
 #ifndef SVQC
 .int m_itemid;
 #endif
+
+#ifndef MENUQC
+MODEL(Strength_ITEM, Item_Model("g_strength.md3"));
+#endif
+
 REGISTER_ITEM(Strength, Powerup) {
-    this.m_model            =   "g_strength.md3";
+#ifndef MENUQC
+    this.m_model            =   MDL_Strength_ITEM;
+#endif
     this.m_sound            =   "misc/powerup.wav";
     this.m_name             =   "Strength Powerup";
     this.m_icon             =   "strength";
@@ -14,8 +21,15 @@ REGISTER_ITEM(Strength, Powerup) {
     this.m_waypointblink    =   2;
     this.m_itemid           =   IT_STRENGTH;
 }
+
+#ifndef MENUQC
+MODEL(Shield_ITEM, Item_Model("g_invincible.md3"));
+#endif
+
 REGISTER_ITEM(Shield, Powerup) {
-    this.m_model            =   "g_invincible.md3";
+#ifndef MENUQC
+    this.m_model            =   MDL_Shield_ITEM;
+#endif
     this.m_sound            =   "misc/powerup_shield.wav";
     this.m_name             =   "Shield";
     this.m_icon             =   "shield";
index b88d219916edc4bd764e085467e1a9a0ec099701..38614c7d4629481c9c8fafeb6b029b533e263491 100644 (file)
@@ -42,27 +42,6 @@ bool minigame_hud_mouse_in(vector pos, vector sz)
               mousepos_y >= pos_y && mousepos_y < pos_y + sz_y ;
 }
 
-void initialize_minigames()
-{
-       entity last_minig = world;
-       entity minig;
-       #define MINIGAME(name,nicename) \
-               minig = spawn(); \
-               minig.classname = "minigame_descriptor"; \
-               minig.netname = strzone(strtolower(#name)); \
-               minig.message = nicename; \
-               minig.minigame_hud_board = name##_hud_board; \
-               minig.minigame_hud_status = name##_hud_status; \
-               minig.minigame_event = name##_client_event; \
-               if ( !last_minig ) minigame_descriptors = minig; \
-               else last_minig.list_next = minig; \
-               last_minig = minig;
-
-       REGISTERED_MINIGAMES
-
-       #undef MINIGAME
-}
-
 string minigame_texture_skin(string skinname, string name)
 {
        return sprintf("gfx/hud/%s/minigames/%s", skinname, name);
@@ -95,7 +74,7 @@ MINIGAME_SIMPLELINKED_ENTITIES
 
 void minigame_autoclean_entity(entity e)
 {
-       LOG_TRACE("CL Auto-cleaned: ",ftos(num_for_edict(e)), " (",e.classname,")\n");
+       LOG_DEBUG("CL Auto-cleaned: ",ftos(num_for_edict(e)), " (",e.classname,")\n");
        remove(e);
 }
 
@@ -235,7 +214,7 @@ void ent_read_minigame()
                        minigame_read_owner();
                        float ent = ReadLong();
                        self.minigame_playerslot = ent;
-                       LOG_TRACE("Player: ",GetPlayerName(ent-1),"\n");
+                       LOG_DEBUG("Player: ",GetPlayerName(ent-1),"\n");
 
                        activate = (ent == player_localnum+1 && self.owner && self.owner != active_minigame);
 
@@ -258,9 +237,9 @@ void ent_read_minigame()
 
        if ( sf & MINIG_SF_CREATE )
        {
-               LOG_TRACE("CL Reading entity: ",ftos(num_for_edict(self)),
+               LOG_DEBUG("CL Reading entity: ",ftos(num_for_edict(self)),
                        " classname:",self.classname," enttype:",ftos(self.enttype) );
-               LOG_TRACE(" sf:",ftos(sf)," netname:",self.netname,"\n\n");
+               LOG_DEBUG(" sf:",ftos(sf)," netname:",self.netname,"\n\n");
        }
 }
 #undef ReadString
index a839b1106194a7156bd56d669f4aefc720686cba..76d10986405891fa3d8e902983d33ce5ed6e0bb9 100644 (file)
@@ -79,9 +79,6 @@ string minigame_texture(string name);
 // For minigame_player: player server slot, don't use for anything else
 .float minigame_playerslot;
 
-// register all minigames
-void initialize_minigames();
-
 // client-side minigame session cleanup
 void deactivate_minigame();
 
@@ -118,4 +115,25 @@ void HUD_MinigameMenu_CustomEntry(entity parent, string message, string event_ar
        entityvar=world; \
        while( (entityvar = findentity(entityvar,owner,active_minigame)) )
 
+
+void RegisterMinigames();
+const int MINIGAMES_MAX = 24;
+entity MINIGAMES[MINIGAMES_MAX], MINIGAMES_first, MINIGAMES_last;
+int MINIGAMES_COUNT;
+#define REGISTER_MINIGAME(name,nicename) \
+    REGISTER(RegisterMinigames, MINIGAME, MINIGAMES, MINIGAMES_COUNT, name, m_id, spawn()); \
+    void name##_hud_board(vector, vector); \
+    void name##_hud_status(vector, vector); \
+    int name##_client_event(entity, string, ...); \
+    REGISTER_INIT_POST(MINIGAME, name) { \
+        this.classname = "minigame_descriptor"; \
+        this.netname = strzone(strtolower(#name)); \
+        this.message = nicename; \
+        this.minigame_hud_board = name##_hud_board; \
+               this.minigame_hud_status = name##_hud_status; \
+               this.minigame_event = name##_client_event; \
+    } \
+    REGISTER_INIT(MINIGAME, name)
+REGISTER_REGISTRY(RegisterMinigames)
+
 #endif
index 11470ec136acc3929cbd6721a720f8356e06d822..b0dba86c1ed9525cddb9f6f29b7818b3a9931c06 100644 (file)
@@ -211,18 +211,17 @@ void HUD_MinigameMenu_ClickCreate()
 {SELFPARAM();
        if ( HUD_MinigameMenu_Click_ExpandCollapse() )
        {
-               entity e;
                entity curr;
                entity prev = self;
-               for ( e = minigame_descriptors; e != world; e = e.list_next )
+               FOREACH(MINIGAMES, true, LAMBDA(
                {
                        curr = HUD_MinigameMenu_SpawnSubEntry(
-                               e.message, HUD_MinigameMenu_ClickCreate_Entry,  self );
-                       curr.netname = e.netname;
-                       curr.model = strzone(minigame_texture(strcat(e.netname,"/icon")));
+                               it.message, HUD_MinigameMenu_ClickCreate_Entry,  self );
+                       curr.netname = it.netname;
+                       curr.model = strzone(minigame_texture(strcat(it.netname,"/icon")));
                        HUD_MinigameMenu_InsertEntry( curr, prev );
                        prev = curr;
-               }
+               }));
        }
 }
 
index afcc93d4821bb69c0c8b60e9d7783118301617a9..d3874e7aa77cb42b79bc8c42230982cb0a4781f6 100644 (file)
@@ -65,25 +65,9 @@ that .owner is set to the minigame session entity and .minigame_autoclean is tru
 #include "ttt.qc"
 #include "c4.qc"
 #include "pong.qc"
-#include "qto.qc"
 #include "ps.qc"
 #include "pp.qc"
-
-/**
- * Registration:
- *     MINIGAME(id,"Name")
- *             id    (QuakeC symbol) Game identifier, used to find the functions explained above
- *             "Name"(String)        Human readable name for the game, shown in the UI
- */
-#define REGISTERED_MINIGAMES \
-       MINIGAME(nmm, "Nine Men's Morris") \
-       MINIGAME(ttt, "Tic Tac Toe") \
-       MINIGAME(pong,"Pong") \
-       MINIGAME(c4,  "Connect Four") \
-       MINIGAME(qto, "Quinto") \
-       MINIGAME(ps,  "Peg Solitaire") \
-       MINIGAME(pp,  "Push-Pull") \
-       /*empty line*/
+#include "snake.qc"
 
 /**
  * Set up automatic entity read/write functionality
index 31388d0f38a3b6457868fd3609e6cf77967f676b..98020972a742ee5a59e4eef24e69a7a483f6e69c 100644 (file)
@@ -1,3 +1,5 @@
+REGISTER_MINIGAME(c4, "Connect Four");
+
 const float C4_TURN_PLACE = 0x0100; // player has to place a piece on the board
 const float C4_TURN_WIN   = 0x0200; // player has won
 const float C4_TURN_DRAW  = 0x0400; // no moves are possible
index 2bd4a4267fa22484af7dd6549711105b723272d6..1e4da05075ad20c76b11587a69f4a2e5b3105782 100644 (file)
@@ -1,3 +1,5 @@
+REGISTER_MINIGAME(nmm, "Nine Men's Morris");
+
 const int NMM_TURN_PLACE = 0x0100; // player has to place a piece on the board
 const int NMM_TURN_MOVE  = 0x0200; // player has to move a piece by one tile
 const int NMM_TURN_FLY   = 0x0400; // player has to move a piece anywhere
index e295c7cd64ec867ac56af8813d0517262feb0fb8..540f7ecf2f1d506b30a28e98f045c3783f9c4e0e 100644 (file)
@@ -1,3 +1,5 @@
+REGISTER_MINIGAME(pong, "Pong");
+
 // minigame flags
 const int PONG_STATUS_WAIT = 0x0010; // waiting for players to join
 const int PONG_STATUS_PLAY = 0x0020; // playing
index 01b257a82a94b4a17cbf9fdc763bcc2e03f1b5cf..efce0e66b6be5030a96beb0446cdd2c3378a4b66 100644 (file)
@@ -1,3 +1,5 @@
+REGISTER_MINIGAME(pp, "Push-Pull");
+
 const int PP_TURN_PLACE = 0x0100; // player has to place a piece on the board
 const int PP_TURN_WIN   = 0x0200; // player has won
 const int PP_TURN_DRAW  = 0x0400; // players have equal scores
index 2b8de29920a416d687298b036769c2313de8141e..54be75cd46f51ba2c62756d99ec8716cb6764fd0 100644 (file)
@@ -1,3 +1,5 @@
+REGISTER_MINIGAME(ps, "Peg Solitaire");
+
 const float PS_TURN_MOVE  = 0x0100; // player has to click on a piece on the board
 const float PS_TURN_WIN   = 0x0200; // player has won
 const float PS_TURN_DRAW  = 0x0400; // player can make no more moves
diff --git a/qcsrc/common/minigames/minigame/qto.qc b/qcsrc/common/minigames/minigame/qto.qc
deleted file mode 100644 (file)
index 76fa3ce..0000000
+++ /dev/null
@@ -1,461 +0,0 @@
-const float QTO_TURN_MOVE  = 0x0100; // player has to click on a piece on the board
-const float QTO_TURN_WIN   = 0x0200; // player has won
-const float QTO_TURN_TYPE  = 0x0f00; // turn type mask
-
-const int QTO_SF_PLAYERSCORE = MINIG_SF_CUSTOM;
-
-const int QTO_LET_CNT = 5;
-const int QTO_NUM_CNT = 5;
-
-const int QTO_TILE_SIZE = 8;
-
-.int qto_moves;
-
-// find same game piece given its tile name
-entity qto_find_piece(entity minig, string tile)
-{
-       entity e = world;
-       while ( ( e = findentity(e,owner,minig) ) )
-               if ( e.classname == "minigame_board_piece" && e.netname == tile )
-                       return e;
-       return world;
-}
-
-// Checks if the given piece completes a row
-bool qto_winning_piece(entity minigame)
-{
-       //int number = minigame_tile_number(piece.netname);
-       //int letter = minigame_tile_letter(piece.netname);
-
-       entity e = world;
-       while ( ( e = findentity(e,owner,minigame) ) )
-               if ( e.classname == "minigame_board_piece" )
-               {
-                       if(!e.cnt)
-                               return false;
-               }
-
-       return true;
-}
-
-// check if the tile name is valid (5x5 grid)
-bool qto_valid_tile(string tile)
-{
-       if ( !tile )
-               return false;
-       float number = minigame_tile_number(tile);
-       float letter = minigame_tile_letter(tile);
-       return 0 <= number && number < QTO_NUM_CNT && 0 <= letter && letter < QTO_LET_CNT;
-}
-
-void qto_setup_pieces(entity minigame)
-{
-       int i, t;
-       for(i = 0; i < QTO_NUM_CNT; ++i)
-       for(t = 0; t < QTO_LET_CNT; ++t)
-       {
-               entity piece = msle_spawn(minigame,"minigame_board_piece");
-               piece.team = 1; // init default team?
-               piece.cnt = 0; // initialize cnt
-               piece.netname = strzone(minigame_tile_buildname(t,i));
-               minigame_server_sendflags(piece,MINIG_SF_ALL);
-       }
-
-       minigame_server_sendflags(minigame,MINIG_SF_UPDATE);
-}
-
-void qto_add_score(entity minigame, int thescore)
-{
-#ifdef SVQC
-       if(!minigame)
-               return;
-       if(minigame.minigame_players)
-       {
-               minigame.minigame_players.qto_moves += thescore;
-               minigame.minigame_players.SendFlags |= QTO_SF_PLAYERSCORE;
-       }
-#endif
-}
-
-// make a move
-void qto_move(entity minigame, entity player, string pos )
-{
-       if ( minigame.minigame_flags & QTO_TURN_MOVE )
-       if ( pos )
-       {
-               if ( qto_valid_tile(pos) )
-               if ( qto_find_piece(minigame, pos) )
-               {
-                       entity piece;
-               #define DO_JUNK \
-                       if(piece) \
-                       { \
-                               piece.cnt = (piece.cnt) ? 0 : 1; \
-                               minigame_server_sendflags(piece,MINIG_SF_UPDATE); \
-                       }
-
-                       int number = minigame_tile_number(pos);
-                       int letter = minigame_tile_letter(pos);
-                       piece = qto_find_piece(minigame, pos);
-                       DO_JUNK
-                       piece = qto_find_piece(minigame, minigame_tile_buildname(letter-1,number));
-                       DO_JUNK
-                       piece = qto_find_piece(minigame, minigame_tile_buildname(letter+1,number));
-                       DO_JUNK
-                       piece = qto_find_piece(minigame, minigame_tile_buildname(letter,number-1));
-                       DO_JUNK
-                       piece = qto_find_piece(minigame, minigame_tile_buildname(letter,number+1));
-                       DO_JUNK
-
-                       qto_add_score(minigame,1); // add 1 move score
-
-                       minigame_server_sendflags(minigame,MINIG_SF_UPDATE);
-
-                       if ( qto_winning_piece(minigame) )
-                       {
-                               minigame.minigame_flags = QTO_TURN_WIN;
-                       }
-                       else
-                               minigame.minigame_flags = QTO_TURN_MOVE;
-               }
-       }
-}
-
-// restart match
-void qto_restart_match(entity minigame, entity player)
-{
-       minigame.minigame_flags = QTO_TURN_MOVE;
-       minigame_server_sendflags(minigame,MINIG_SF_UPDATE);
-       entity e = world;
-       while ( ( e = findentity(e,owner,minigame) ) )
-               if ( e.classname == "minigame_board_piece" )
-                       remove(e);
-
-       qto_setup_pieces(minigame);
-#ifdef SVQC
-       if(minigame.minigame_players)
-       {
-               minigame.minigame_players.qto_moves = 0;
-               minigame.minigame_players.SendFlags |= QTO_SF_PLAYERSCORE;
-       }
-#endif
-}
-
-#ifdef SVQC
-
-
-// required function, handle server side events
-int qto_server_event(entity minigame, string event, ...)
-{
-       switch(event)
-       {
-               case "start":
-               {
-                       qto_setup_pieces(minigame);
-                       minigame.minigame_flags = QTO_TURN_MOVE;
-                       return true;
-               }
-               case "end":
-               {
-                       entity e = world;
-                       while( (e = findentity(e, owner, minigame)) )
-                       if(e.classname == "minigame_board_piece")
-                       {
-                               if(e.netname) { strunzone(e.netname); }
-                               remove(e);
-                       }
-                       return false;
-               }
-               case "join":
-               {
-                       int pl_num = minigame_count_players(minigame);
-
-                       // Don't allow more than 1 player
-                       if(pl_num >= 1) { return false; }
-
-                       // Team 1 by default
-                       return 1;
-               }
-               case "cmd":
-               {
-                       switch(argv(0))
-                       {
-                               case "move":
-                                       qto_move(minigame, ...(0,entity), ...(1,int) == 2 ? argv(1) : string_null );
-                                       return true;
-                               case "restart":
-                                       qto_restart_match(minigame,...(0,entity));
-                                       return true;
-                       }
-
-                       return false;
-               }
-               case "network_send":
-               {
-                       entity sent = ...(0,entity);
-                       int sf = ...(1,int);
-                       if ( sent.classname == "minigame_board_piece" && (sf & MINIG_SF_UPDATE) )
-                       {
-                               WriteByte(MSG_ENTITY,sent.cnt);
-                       }
-                       else if ( sent.classname == "minigame_player" && (sf & QTO_SF_PLAYERSCORE ) )
-                       {
-                               WriteLong(MSG_ENTITY,sent.qto_moves);
-                       }
-                       return false;
-               }
-       }
-
-       return false;
-}
-
-
-#elif defined(CSQC)
-
-string qto_curr_pos; // identifier of the tile under the mouse
-vector qto_boardpos; // HUD board position
-vector qto_boardsize;// HUD board size
-
-// Required function, draw the game board
-void qto_hud_board(vector pos, vector mySize)
-{
-       minigame_hud_fitsqare(pos, mySize);
-       qto_boardpos = pos;
-       qto_boardsize = mySize;
-
-       minigame_hud_simpleboard(pos,mySize,minigame_texture("qto/board"));
-
-       vector tile_size = minigame_hud_denormalize_size('1 1 0' / QTO_TILE_SIZE,pos,mySize);
-       vector tile_pos;
-
-       bool valid = qto_valid_tile(qto_curr_pos);
-       int number = minigame_tile_number(qto_curr_pos);
-       int letter = minigame_tile_letter(qto_curr_pos);
-       string pos1 = minigame_tile_buildname(letter-1,number);
-       string pos2 = minigame_tile_buildname(letter+1,number);
-       string pos3 = minigame_tile_buildname(letter,number-1);
-       string pos4 = minigame_tile_buildname(letter,number+1);
-
-       entity e;
-       FOREACH_MINIGAME_ENTITY(e)
-       {
-               if ( e.classname == "minigame_board_piece" )
-               {
-                       tile_pos = minigame_tile_pos(e.netname,QTO_NUM_CNT,QTO_LET_CNT);
-                       tile_pos = minigame_hud_denormalize(tile_pos,pos,mySize);
-
-                       vector tile_color = '0.4 0.4 0.4';
-
-                       if(valid)
-                       switch(e.netname)
-                       {
-                               case qto_curr_pos:
-                               case pos1: case pos2: case pos3: case pos4:
-                                       tile_color = '0.8 0.8 0.8';
-                                       break;
-                       }
-
-                       minigame_drawpic_centered( tile_pos,
-                                       minigame_texture(strcat("qto/piece", ftos(e.cnt))),
-                                       tile_size, tile_color, panel_fg_alpha, DRAWFLAG_NORMAL );
-               }
-       }
-}
-
-
-// Required function, draw the game status panel
-void qto_hud_status(vector pos, vector mySize)
-{
-       HUD_Panel_DrawBg(1);
-       vector ts;
-       ts = minigame_drawstring_wrapped(mySize_x,pos,active_minigame.descriptor.message,
-               hud_fontsize * 2, '0.25 0.47 0.72', panel_fg_alpha, DRAWFLAG_NORMAL,0.5);
-
-       pos_y += ts_y;
-       mySize_y -= ts_y;
-
-       vector player_fontsize = hud_fontsize * 1.75;
-       ts_y = ( mySize_y - 2*player_fontsize_y ) / 2;
-       ts_x = mySize_x;
-       vector mypos;
-       vector tile_size = '48 48 0';
-
-       mypos = pos;
-       drawfill(mypos,eX*mySize_x+eY*player_fontsize_y,'1 1 1',0.5,DRAWFLAG_ADDITIVE);
-       mypos_y += player_fontsize_y;
-       drawfill(mypos,eX*mySize_x+eY*tile_size_y,'1 1 1',0.25,DRAWFLAG_ADDITIVE);
-
-       entity e;
-       FOREACH_MINIGAME_ENTITY(e)
-       {
-               if ( e.classname == "minigame_player" )
-               {
-                       mypos = pos;
-                       minigame_drawcolorcodedstring_trunc(mySize_x,mypos,
-                               GetPlayerName(e.minigame_playerslot-1),
-                               player_fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
-
-                       mypos_y += player_fontsize_y;
-                       //drawpic( mypos,
-                       //              minigame_texture("qto/piece"),
-                       //              tile_size, '1 0 0', panel_fg_alpha, DRAWFLAG_NORMAL );
-
-                       //mypos_x += tile_size_x;
-
-                       drawstring(mypos,sprintf(_("Moves: %s"), ftos(e.qto_moves)),'32 32 0',
-                                          '0.7 0.84 1', panel_fg_alpha, DRAWFLAG_NORMAL);
-               }
-       }
-}
-
-// Turn a set of flags into a help message
-string qto_turn_to_string(int turnflags)
-{
-       if ( turnflags & QTO_TURN_WIN )
-               return _("Well done, you win!");
-
-       if ( turnflags & QTO_TURN_MOVE )
-               return _("Turn all the angry faces into happy faces");
-
-       return "";
-}
-
-// Make the correct move
-void qto_make_move(entity minigame)
-{
-       if ( minigame.minigame_flags == QTO_TURN_MOVE )
-       {
-               minigame_cmd("move ",qto_curr_pos);
-       }
-}
-
-void qto_set_curr_pos(string s)
-{
-       if ( qto_curr_pos )
-               strunzone(qto_curr_pos);
-       if ( s )
-               s = strzone(s);
-       qto_curr_pos = s;
-}
-
-// Required function, handle client events
-int qto_client_event(entity minigame, string event, ...)
-{
-       switch(event)
-       {
-               case "activate":
-               {
-                       qto_set_curr_pos("");
-                       minigame.message = qto_turn_to_string(minigame.minigame_flags);
-                       return false;
-               }
-               case "key_pressed":
-               {
-                       //if((minigame.minigame_flags & QTO_TURN_TEAM) == minigame_self.team)
-                       {
-                               switch ( ...(0,int) )
-                               {
-                                       case K_RIGHTARROW:
-                                       case K_KP_RIGHTARROW:
-                                               if ( ! qto_curr_pos )
-                                                       qto_set_curr_pos("a3");
-                                               else
-                                                       qto_set_curr_pos( minigame_relative_tile(qto_curr_pos,1,0,QTO_NUM_CNT,QTO_LET_CNT));
-                                               return true;
-                                       case K_LEFTARROW:
-                                       case K_KP_LEFTARROW:
-                                               if ( ! qto_curr_pos )
-                                                       qto_set_curr_pos("c3");
-                                               else
-                                                       qto_set_curr_pos(minigame_relative_tile(qto_curr_pos,-1,0,QTO_NUM_CNT,QTO_LET_CNT));
-                                               return true;
-                                       case K_UPARROW:
-                                       case K_KP_UPARROW:
-                                               if ( ! qto_curr_pos )
-                                                       qto_set_curr_pos("a1");
-                                               else
-                                                       qto_set_curr_pos(minigame_relative_tile(qto_curr_pos,0,1,QTO_NUM_CNT,QTO_LET_CNT));
-                                               return true;
-                                       case K_DOWNARROW:
-                                       case K_KP_DOWNARROW:
-                                               if ( ! qto_curr_pos )
-                                                       qto_set_curr_pos("a3");
-                                               else
-                                                       qto_set_curr_pos(minigame_relative_tile(qto_curr_pos,0,-1,QTO_NUM_CNT,QTO_LET_CNT));
-                                               return true;
-                                       case K_ENTER:
-                                       case K_KP_ENTER:
-                                       case K_SPACE:
-                                               qto_make_move(minigame);
-                                               return true;
-                               }
-                       }
-
-                       return false;
-               }
-               case "mouse_pressed":
-               {
-                       if(...(0,int) == K_MOUSE1)
-                       {
-                               qto_make_move(minigame);
-                               return true;
-                       }
-
-                       return false;
-               }
-               case "mouse_moved":
-               {
-                       vector mouse_pos = minigame_hud_normalize(mousepos,qto_boardpos,qto_boardsize);
-                       if ( minigame.minigame_flags == QTO_TURN_MOVE )
-                       {
-                               qto_set_curr_pos(minigame_tile_name(mouse_pos,QTO_NUM_CNT,QTO_LET_CNT));
-                       }
-                       if ( ! qto_valid_tile(qto_curr_pos) )
-                               qto_set_curr_pos("");
-
-                       return true;
-               }
-               case "network_receive":
-               {
-                       entity sent = ...(0,entity);
-                       int sf = ...(1,int);
-                       if ( sent.classname == "minigame" )
-                       {
-                               if ( sf & MINIG_SF_UPDATE )
-                               {
-                                       sent.message = qto_turn_to_string(sent.minigame_flags);
-                                       if ( sent.minigame_flags & minigame_self.team )
-                                               minigame_prompt();
-                               }
-                       }
-                       else if(sent.classname == "minigame_board_piece")
-                       {
-                               if(sf & MINIG_SF_UPDATE)
-                               {
-                                       sent.cnt = ReadByte();
-                               }
-                       }
-                       else if ( sent.classname == "minigame_player" && (sf & QTO_SF_PLAYERSCORE ) )
-                       {
-                               sent.qto_moves = ReadLong();
-                       }
-
-                       return false;
-               }
-               case "menu_show":
-               {
-                       HUD_MinigameMenu_CustomEntry(...(0,entity),_("Restart"),"restart");
-                       return false;
-               }
-               case "menu_click":
-               {
-                       if(...(0,string) == "restart")
-                               minigame_cmd("restart");
-                       return false;
-               }
-       }
-
-       return false;
-}
-
-#endif
diff --git a/qcsrc/common/minigames/minigame/snake.qc b/qcsrc/common/minigames/minigame/snake.qc
new file mode 100644 (file)
index 0000000..c7bf6ae
--- /dev/null
@@ -0,0 +1,621 @@
+REGISTER_MINIGAME(snake, "Snake");
+
+const float SNAKE_TURN_MOVE  = 0x0100; // the snake is moving, player must control it
+const float SNAKE_TURN_LOSS  = 0x0200; // they did it?!
+const float SNAKE_TURN_WAIT  = 0x0400; // the snake is waiting for the player to make their first move and begin the game
+const float SNAKE_TURN_TYPE  = 0x0f00; // turn type mask
+
+const int SNAKE_SF_PLAYERSCORE = MINIG_SF_CUSTOM;
+
+const int SNAKE_LET_CNT = 15;
+const int SNAKE_NUM_CNT = 15;
+
+const int SNAKE_TILE_SIZE = 15;
+
+bool autocvar_sv_minigames_snake_wrap = false;
+float autocvar_sv_minigames_snake_delay_initial = 0.7;
+float autocvar_sv_minigames_snake_delay_multiplier = 50;
+float autocvar_sv_minigames_snake_delay_min = 0.1;
+
+.int snake_score;
+.entity snake_head;
+
+.float snake_delay;
+.float snake_nextmove;
+.vector snake_dir;
+
+// find same game piece given its tile name
+entity snake_find_piece(entity minig, string tile)
+{
+       entity e = world;
+       while ( ( e = findentity(e,owner,minig) ) )
+               if ( e.classname == "minigame_board_piece" && e.netname == tile )
+                       return e;
+       return world;
+}
+
+// find same game piece given its cnt
+entity snake_find_cnt(entity minig, int tile)
+{
+       entity e = world;
+       while ( ( e = findentity(e,owner,minig) ) )
+               if ( e.classname == "minigame_board_piece" && e.cnt == tile )
+                       return e;
+       return world;
+}
+
+// check if the tile name is valid (15x15 grid)
+bool snake_valid_tile(string tile)
+{
+       if ( !tile )
+               return false;
+       int number = minigame_tile_number(tile);
+       int letter = minigame_tile_letter(tile);
+       return 0 <= number && number < SNAKE_NUM_CNT && 0 <= letter && letter < SNAKE_LET_CNT;
+}
+
+void snake_new_mouse(entity minigame)
+{
+       RandomSelection_Init();
+       int i, j;
+       for(i = 0; i < SNAKE_LET_CNT; ++i)
+       for(j = 0; j < SNAKE_NUM_CNT; ++j)
+       {
+               string pos = minigame_tile_buildname(i, j);
+               if(!snake_find_piece(minigame, pos))
+                       RandomSelection_Add(world, 0, pos, 1, 1);
+       }
+
+       entity piece = msle_spawn(minigame,"minigame_board_piece");
+       piece.team = 1;
+       piece.netname = strzone(RandomSelection_chosen_string);
+       minigame_server_sendflags(piece,MINIG_SF_ALL);
+
+       minigame_server_sendflags(minigame,MINIG_SF_UPDATE);
+}
+
+void snake_setup_pieces(entity minigame)
+{
+       int targnum = bound(1, floor(random() * SNAKE_NUM_CNT), SNAKE_NUM_CNT - 1);
+       int targlet = bound(1, floor(random() * SNAKE_LET_CNT), SNAKE_LET_CNT - 1);
+
+       entity piece = msle_spawn(minigame,"minigame_board_piece");
+       piece.team = 1; // init default team?
+       piece.netname = strzone(minigame_tile_buildname(targlet,targnum));
+       piece.cnt = 1;
+       minigame_server_sendflags(piece,MINIG_SF_ALL);
+
+       minigame.snake_head = piece;
+
+       snake_new_mouse(minigame);
+
+       minigame_server_sendflags(minigame,MINIG_SF_UPDATE);
+}
+
+void snake_add_score(entity minigame, int thescore)
+{
+#ifdef SVQC
+       if(!minigame)
+               return;
+       if(minigame.minigame_players)
+       {
+               minigame.minigame_players.snake_score += thescore;
+               minigame.minigame_players.SendFlags |= SNAKE_SF_PLAYERSCORE;
+       }
+#endif
+}
+
+void snake_move_body(entity minigame, bool ate_mouse)
+{
+       entity tail = world;
+       string tailpos = string_null;
+       vector taildir = '0 0 0';
+
+       int i, pieces = 0;
+       for(i = (SNAKE_NUM_CNT * SNAKE_LET_CNT); i >= 2; --i)
+       {
+               entity piece = snake_find_cnt(minigame, i);
+               entity nextpiece = snake_find_cnt(minigame, i - 1);
+               if(!piece)
+                       continue;
+
+               pieces++;
+
+               if(!tail)
+               {
+                       tail = piece;
+                       tailpos = piece.netname;
+                       taildir = piece.snake_dir;
+               }
+
+               if(piece.netname) { strunzone(piece.netname); }
+               piece.netname = strzone(nextpiece.netname);
+               piece.snake_dir = nextpiece.snake_dir;
+               minigame_server_sendflags(piece, MINIG_SF_ALL);
+       }
+
+       // just a head
+       if(!pieces)
+       {
+               tail = minigame.snake_head;
+               tailpos = minigame.snake_head.netname;
+               taildir = minigame.snake_head.snake_dir;
+       }
+
+       if(tail && ate_mouse)
+       {
+               int newcnt = tail.cnt + 1;
+               minigame.snake_delay = max(autocvar_sv_minigames_snake_delay_min, autocvar_sv_minigames_snake_delay_initial - (newcnt / autocvar_sv_minigames_snake_delay_multiplier));
+               snake_add_score(minigame, 1);
+
+               entity piece = msle_spawn(minigame,"minigame_board_piece");
+               piece.cnt = newcnt;
+               piece.team = 1;
+               piece.snake_dir = taildir;
+               piece.netname = strzone(tailpos);
+               minigame_server_sendflags(piece,MINIG_SF_ALL);
+
+               minigame_server_sendflags(minigame,MINIG_SF_UPDATE);
+       }
+}
+
+void snake_move_head(entity minigame)
+{
+       entity head = minigame.snake_head;
+       string newpos;
+
+       if(autocvar_sv_minigames_snake_wrap)
+               newpos = minigame_relative_tile(head.netname, minigame.snake_dir_x, minigame.snake_dir_y, SNAKE_NUM_CNT, SNAKE_LET_CNT);
+       else
+       {
+               int myx = minigame_tile_letter(head.netname);
+               int myy = minigame_tile_number(head.netname);
+
+               myx += minigame.snake_dir_x;
+               myy += minigame.snake_dir_y;
+
+               newpos = minigame_tile_buildname(myx, myy);
+       }
+
+       if(!snake_valid_tile(newpos) || (snake_find_piece(minigame, newpos)).cnt)
+       {
+               minigame.minigame_flags = SNAKE_TURN_LOSS;
+               minigame_server_sendflags(minigame,MINIG_SF_UPDATE);
+               return;
+       }
+
+       bool ate_mouse = false;
+       entity piece = snake_find_piece(minigame, newpos);
+       if(piece && !piece.cnt)
+               ate_mouse = true;
+
+       // move the body first, then set the new head position?
+       snake_move_body(minigame, ate_mouse);
+
+       if(ate_mouse)
+       {
+               if(piece.netname) { strunzone(piece.netname); }
+               remove(piece);
+
+               snake_new_mouse(minigame);
+       }
+
+       if(head.netname) { strunzone(head.netname); }
+       head.netname = strzone(newpos);
+       minigame_server_sendflags(head,MINIG_SF_ALL);
+}
+
+// make a move
+void snake_move(entity minigame, entity player, string dxs, string dys )
+{
+       if ( (minigame.minigame_flags & SNAKE_TURN_MOVE) || (minigame.minigame_flags & SNAKE_TURN_WAIT) )
+       if ( dxs || dys )
+       {
+               //if ( snake_valid_tile(pos) )
+               //if ( snake_find_piece(minigame, pos) )
+               {
+                       int dx = ((dxs) ? bound(-1, stof(dxs), 1) : 0);
+                       int dy = ((dys) ? bound(-1, stof(dys), 1) : 0);
+
+                       int myl = minigame_tile_letter(minigame.snake_head.netname);
+                       int myn = minigame_tile_number(minigame.snake_head.netname);
+
+                       entity head = snake_find_piece(minigame, minigame_tile_buildname(myl + dx, myn + dy));
+                       if(head && head.cnt == 2)
+                               return; // nope!
+
+                       if(minigame.minigame_flags & SNAKE_TURN_WAIT)
+                               minigame.snake_nextmove = time;
+                       minigame.minigame_flags = SNAKE_TURN_MOVE;
+                       minigame.snake_dir_x = dx;
+                       minigame.snake_dir_y = dy;
+                       minigame.snake_dir_z = 0;
+                       minigame.snake_head.snake_dir = minigame.snake_dir;
+                       minigame_server_sendflags(minigame.snake_head,MINIG_SF_UPDATE);
+                       minigame_server_sendflags(minigame,MINIG_SF_UPDATE);
+               }
+       }
+}
+
+#ifdef SVQC
+
+
+// required function, handle server side events
+int snake_server_event(entity minigame, string event, ...)
+{
+       switch(event)
+       {
+               case "start":
+               {
+                       snake_setup_pieces(minigame);
+                       minigame.snake_delay = autocvar_sv_minigames_snake_delay_initial;
+                       minigame.minigame_flags = SNAKE_TURN_WAIT;
+                       return true;
+               }
+               case "end":
+               {
+                       entity e = world;
+                       while( (e = findentity(e, owner, minigame)) )
+                       if(e.classname == "minigame_board_piece")
+                       {
+                               if(e.netname) { strunzone(e.netname); }
+                               remove(e);
+                       }
+                       minigame.snake_head = world;
+                       return false;
+               }
+               case "join":
+               {
+                       int pl_num = minigame_count_players(minigame);
+
+                       // Don't allow more than 1 player
+                       // not sure if this should be a multiplayer game (might get crazy)
+                       if(pl_num >= 1) { return false; }
+
+                       // Team 1 by default
+                       return 1;
+               }
+               case "frame":
+               {
+                       if(minigame.minigame_flags & SNAKE_TURN_MOVE)
+                       if(time >= minigame.snake_nextmove)
+                       {
+                               snake_move_head(minigame);
+                               minigame.snake_nextmove = time + minigame.snake_delay;
+                       }
+                       return false;
+               }
+               case "cmd":
+               {
+                       switch(argv(0))
+                       {
+                               case "move": 
+                                       snake_move(minigame, ...(0,entity), ((...(1,int)) >= 2 ? argv(1) : string_null), ((...(1,int)) == 3 ? argv(2) : string_null)); 
+                                       return true;
+                       }
+
+                       return false;
+               }
+               case "network_send":
+               {
+                       entity sent = ...(0,entity);
+                       int sf = ...(1,int);
+                       if ( sent.classname == "minigame_board_piece" && (sf & MINIG_SF_UPDATE) )
+                       {
+                               WriteByte(MSG_ENTITY,sent.cnt);
+                               WriteCoord(MSG_ENTITY,sent.snake_dir_x);
+                               WriteCoord(MSG_ENTITY,sent.snake_dir_y);
+                       }
+                       else if ( sent.classname == "minigame_player" && (sf & SNAKE_SF_PLAYERSCORE ) )
+                       {
+                               WriteLong(MSG_ENTITY,sent.snake_score);
+                       }
+                       else if ( sent.classname == "minigame" && (sf & MINIG_SF_UPDATE ) )
+                       {
+                               WriteByte(MSG_ENTITY,autocvar_sv_minigames_snake_wrap);
+                       }
+                       return false;
+               }
+       }
+       
+       return false;
+}
+
+
+#elif defined(CSQC)
+
+vector snake_boardpos; // HUD board position
+vector snake_boardsize;// HUD board size
+
+bool snake_wrap;
+
+// Required function, draw the game board
+void snake_hud_board(vector pos, vector mySize)
+{
+       minigame_hud_fitsqare(pos, mySize);
+       snake_boardpos = pos;
+       snake_boardsize = mySize;
+       
+       minigame_hud_simpleboard(pos,mySize,minigame_texture("snake/board"));
+
+       vector tile_size = minigame_hud_denormalize_size('1 1 0' / SNAKE_TILE_SIZE,pos,mySize);
+       vector tile_pos;
+
+       entity tail = world;
+       int i;
+       for(i = (SNAKE_NUM_CNT * SNAKE_LET_CNT); i >= 2; --i)
+       {
+               entity piece = snake_find_cnt(active_minigame, i);
+               if(piece)
+               {
+                       tail = piece;
+                       break;
+               }
+       }
+
+       entity e;
+       FOREACH_MINIGAME_ENTITY(e)
+       {
+               if ( e.classname == "minigame_board_piece" )
+               {
+                       tile_pos = minigame_tile_pos(e.netname,SNAKE_NUM_CNT,SNAKE_LET_CNT);
+                       tile_pos = minigame_hud_denormalize(tile_pos,pos,mySize);
+                       string thepiece = "snake/mouse";
+                       if(e.cnt)
+                               thepiece = "snake/body";
+                       if(tail && e.cnt == tail.cnt)
+                               thepiece = "snake/tail";
+                       if(e.cnt == 1)
+                       {
+                               int dx = minigame_tile_letter(e.netname) + e.snake_dir_x * 2;
+                               int dy = minigame_tile_number(e.netname) + e.snake_dir_y * 2;
+                               entity mouse = snake_find_piece(active_minigame, minigame_tile_buildname(dx, dy));
+                               thepiece = "snake/head";
+                               if(mouse && !mouse.cnt)
+                               {
+                                       float myang = 0;
+                                       int myx = minigame_tile_letter(e.netname);
+                                       int myy = minigame_tile_number(e.netname);
+                                       if(myx - 2 == dx)
+                                               myang = M_PI*3/2;
+                                       if(myx + 2 == dx)
+                                               myang = M_PI/2;
+                                       if(myy - 2 == dy)
+                                               myang = M_PI;
+
+                                       int newx = minigame_tile_letter(e.netname) + e.snake_dir_x;
+                                       int newy = minigame_tile_number(e.netname) + e.snake_dir_y;
+                                       string newpos = minigame_tile_buildname(newx, newy);
+
+                                       vector my_pos = minigame_tile_pos(newpos,SNAKE_NUM_CNT,SNAKE_LET_CNT);
+                                       my_pos = minigame_hud_denormalize(my_pos,pos,mySize);
+
+                                       drawrotpic(my_pos, myang, minigame_texture("snake/tongue"),
+                                                       tile_size, tile_size/2, '1 1 1',
+                                                       panel_fg_alpha, DRAWFLAG_NORMAL );
+                               }
+                       }
+
+                       if(e.cnt == 1 || e.cnt == tail.cnt)
+                       {
+                               vector thedir = e.snake_dir;
+                               float theang = 0;
+                               if(e.cnt == tail.cnt)
+                               {
+                                       int thex = minigame_tile_letter(e.netname);
+                                       int they = minigame_tile_number(e.netname);
+                                       entity t = snake_find_cnt(active_minigame, e.cnt - 1);
+                                       int tx = minigame_tile_letter(t.netname);
+                                       int ty = minigame_tile_number(t.netname);
+
+                                       if(thex - 1 == tx)
+                                       {
+                                               thedir_y = 0;
+                                               thedir_x = -1;
+                                       }
+                                       if(they + 1 == ty)
+                                       {
+                                               thedir_x = 0;
+                                               thedir_y = 1;
+                                       }
+                                       if(they - 1 == ty)
+                                       {
+                                               thedir_x = 0;
+                                               thedir_y = -1;
+                                       }
+                               }
+
+                               if(thedir_y == -1)
+                                       theang = M_PI;
+                               if(thedir_x == 1)
+                                       theang = M_PI/2;
+                               if(thedir_x == -1)
+                                       theang = M_PI*3/2;
+
+                               drawrotpic(tile_pos, theang, minigame_texture(thepiece),
+                                                       tile_size, tile_size/2, '1 1 1',
+                                                       panel_fg_alpha, DRAWFLAG_NORMAL );
+                       }
+                       else
+                       {
+                               minigame_drawpic_centered( tile_pos,  
+                                               minigame_texture(thepiece),
+                                               tile_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL );
+                       }
+               }
+       }
+
+       if ( active_minigame.minigame_flags & SNAKE_TURN_LOSS )
+       {
+               int scores = 0;
+               FOREACH_MINIGAME_ENTITY(e)
+                       if(e.classname == "minigame_player")
+                               scores = e.snake_score;
+
+               vector winfs = hud_fontsize*2;
+               string scores_text;
+               scores_text = strcat("Score: ", ftos(scores));
+               
+               vector win_pos = pos+eY*(mySize_y-winfs_y)/2;
+               vector win_sz;
+               win_sz = minigame_drawcolorcodedstring_wrapped(mySize_x,win_pos,
+                       sprintf("Game over! %s", scores_text), 
+                       winfs, 0, DRAWFLAG_NORMAL, 0.5);
+               
+               drawfill(win_pos-eY*hud_fontsize_y,win_sz+2*eY*hud_fontsize_y,'0.3 0.3 1',0.8,DRAWFLAG_ADDITIVE);
+               
+               minigame_drawcolorcodedstring_wrapped(mySize_x,win_pos,
+                       sprintf("Game over! %s", scores_text), 
+                       winfs, panel_fg_alpha, DRAWFLAG_NORMAL, 0.5);
+       }
+}
+
+
+// Required function, draw the game status panel
+void snake_hud_status(vector pos, vector mySize)
+{
+       HUD_Panel_DrawBg(1);
+       vector ts;
+       ts = minigame_drawstring_wrapped(mySize_x,pos,active_minigame.descriptor.message,
+               hud_fontsize * 2, '0.25 0.47 0.72', panel_fg_alpha, DRAWFLAG_NORMAL,0.5);
+       
+       pos_y += ts_y;
+       mySize_y -= ts_y;
+       
+       vector player_fontsize = hud_fontsize * 1.75;
+       ts_y = ( mySize_y - 2*player_fontsize_y ) / 2;
+       ts_x = mySize_x;
+       vector mypos;
+       vector tile_size = '48 48 0';
+
+       mypos = pos;
+       drawfill(mypos,eX*mySize_x+eY*player_fontsize_y,'1 1 1',0.5,DRAWFLAG_ADDITIVE);
+       mypos_y += player_fontsize_y;
+       drawfill(mypos,eX*mySize_x+eY*tile_size_y,'1 1 1',0.25,DRAWFLAG_ADDITIVE);
+
+       entity e;
+       FOREACH_MINIGAME_ENTITY(e)
+       {
+               if ( e.classname == "minigame_player" )
+               {
+                       mypos = pos;
+                       minigame_drawcolorcodedstring_trunc(mySize_x,mypos,
+                               GetPlayerName(e.minigame_playerslot-1),
+                               player_fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
+                       
+                       mypos_y += player_fontsize_y;
+                       //drawpic( mypos,  
+                       //              minigame_texture("snake/piece"),
+                       //              tile_size, '1 0 0', panel_fg_alpha, DRAWFLAG_NORMAL );
+                       
+                       //mypos_x += tile_size_x;
+
+                       drawstring(mypos,ftos(e.snake_score),tile_size,
+                                          '0.7 0.84 1', panel_fg_alpha, DRAWFLAG_NORMAL);
+               }
+       }
+}
+
+// Turn a set of flags into a help message
+string snake_turn_to_string(int turnflags)
+{
+       if ( turnflags & SNAKE_TURN_LOSS )
+               return _("Game over!");
+       
+       if ( turnflags & SNAKE_TURN_WAIT )
+               return _("Press an arrow key to begin the game");
+
+       if ( turnflags & SNAKE_TURN_MOVE )
+               if(snake_wrap)
+                       return _("Avoid the snake's body, collect the mice!");
+               else
+                       return _("Avoid the screen edges and the snake's body, collect the mice!");
+       
+       return "";
+}
+
+// Make the correct move
+void snake_set_direction(entity minigame, int dx, int dy)
+{
+       //if ( minigame.minigame_flags == SNAKE_TURN_MOVE )
+       //{
+               minigame_cmd("move ",ftos(dx), " ", ftos(dy));
+       //}
+}
+
+// Required function, handle client events
+int snake_client_event(entity minigame, string event, ...)
+{
+       switch(event)
+       {
+               case "activate":
+               {
+                       minigame.message = snake_turn_to_string(minigame.minigame_flags);
+                       return false;
+               }
+               case "key_pressed":
+               {
+                       //if((minigame.minigame_flags & SNAKE_TURN_TEAM) == minigame_self.team)
+                       {
+                               switch ( ...(0,int) )
+                               {
+                                       case K_RIGHTARROW:
+                                       case K_KP_RIGHTARROW:
+                                               snake_set_direction(minigame, 1, 0);
+                                               return true;
+                                       case K_LEFTARROW:
+                                       case K_KP_LEFTARROW:
+                                               snake_set_direction(minigame, -1, 0);
+                                               return true;
+                                       case K_UPARROW:
+                                       case K_KP_UPARROW:
+                                               snake_set_direction(minigame, 0, 1);
+                                               return true;
+                                       case K_DOWNARROW:
+                                       case K_KP_DOWNARROW:
+                                               snake_set_direction(minigame, 0, -1);
+                                               return true;
+                               }
+                       }
+
+                       return false;
+               }
+               case "network_receive":
+               {
+                       entity sent = ...(0,entity);
+                       int sf = ...(1,int);
+                       if ( sent.classname == "minigame" )
+                       {
+                               if ( sf & MINIG_SF_UPDATE )
+                               {
+                                       snake_wrap = ReadByte();
+                                       sent.message = snake_turn_to_string(sent.minigame_flags);
+                                       //if ( sent.minigame_flags & minigame_self.team )
+                                               minigame_prompt();
+                               }
+                       }
+                       else if(sent.classname == "minigame_board_piece")
+                       {
+                               if(sf & MINIG_SF_UPDATE)
+                               {
+                                       sent.cnt = ReadByte();
+                                       sent.snake_dir_x = ReadCoord();
+                                       sent.snake_dir_y = ReadCoord();
+                                       sent.snake_dir_z = 0;
+                                       if(sent.cnt == 1)
+                                               minigame.snake_head = sent; // hax
+                               }
+                       }
+                       else if ( sent.classname == "minigame_player" && (sf & SNAKE_SF_PLAYERSCORE ) )
+                       {
+                               sent.snake_score = ReadLong();
+                       }
+
+                       return false;
+               }
+       }
+
+       return false;
+}
+
+#endif
\ No newline at end of file
index f2253c2a4b7c2da56fc7489a65b9829ac5389152..8c5005ed259f301e924a19c781ec2080db2e064a 100644 (file)
@@ -1,3 +1,5 @@
+REGISTER_MINIGAME(ttt, "Tic Tac Toe");
+
 const int TTT_TURN_PLACE = 0x0100; // player has to place a piece on the board
 const int TTT_TURN_WIN   = 0x0200; // player has won
 const int TTT_TURN_DRAW  = 0x0400; // no moves are possible
index c2392ae0e0a733bd154e56ca7bdb6cd1a7075ab5..6a24d37ad8033a17036e671a0e0de5dacc8dcadb 100644 (file)
@@ -2,10 +2,11 @@
 
 entity minigame_get_descriptor(string id)
 {
-       entity e;
-       for ( e = minigame_descriptors; e != world; e = e.list_next )
-               if ( e.netname == id )
-                       return e;
+       FOREACH(MINIGAMES, true, LAMBDA(
+       {
+               if(it.netname == id)
+                       return it;
+       }));
        return world;
 }
 
index 536ac5018753af104d1cbb34fc3300efcdc6a506..7425149f389d9b484c38d089ebef97c2b750f6df 100644 (file)
@@ -1,8 +1,6 @@
 #ifndef MINIGAMES_H
 #define MINIGAMES_H
 
-entity minigame_descriptors;
-
 // previous node in a doubly linked list
 .entity list_prev;
 // next node in a linked list
index 1bd9609dede6adfbe57056456d2da92779119485..36c54c18d6858a595a834ad7c726f9c0710eade2 100644 (file)
@@ -163,6 +163,14 @@ int minigame_addplayer(entity minigame_session, entity player)
        return mgteam;
 }
 
+void minigame_frame()
+{
+       entity minig = self;
+
+       minig.minigame_event(minig,"frame");
+       minig.nextthink = time;
+}
+
 entity start_minigame(entity player, string minigame )
 {
        if ( !autocvar_sv_minigames || !IS_REAL_CLIENT(player) )
@@ -175,6 +183,8 @@ entity start_minigame(entity player, string minigame )
                minig.classname = "minigame";
                minig.netname = strzone(strcat(e.netname,"_",ftos(num_for_edict(minig))));
                minig.descriptor = e;
+               minig.think = minigame_frame;
+               minig.nextthink = time;
                minig.minigame_event = e.minigame_event;
                minig.minigame_event(minig,"start");
                GameLogEcho(strcat(":minigame:start:",minig.netname));
@@ -263,25 +273,6 @@ void end_minigames()
        }
 }
 
-void initialize_minigames()
-{
-       entity last_minig = world;
-       entity minig;
-       #define MINIGAME(name,nicename) \
-               minig = spawn(); \
-               minig.classname = "minigame_descriptor"; \
-               minig.netname = #name; \
-               minig.message = nicename; \
-               minig.minigame_event = name##_server_event; \
-               if ( !last_minig ) minigame_descriptors = minig; \
-               else last_minig.list_next = minig; \
-               last_minig = minig;
-
-       REGISTERED_MINIGAMES
-
-       #undef MINIGAME
-}
-
 string invite_minigame(entity inviter, entity player)
 {
        if ( !inviter || !inviter.active_minigame )
@@ -359,9 +350,10 @@ void ClientCommand_minigame(int request, int argc, string command)
                }
                else if ( minig_cmd == "list" )
                {
-                       entity e;
-                       for ( e = minigame_descriptors; e != world; e = e.list_next )
-                               sprint(self,e.netname," (",e.message,") ","\n");
+                       FOREACH(MINIGAMES, true, LAMBDA(
+                       {
+                               sprint(self,it.netname," (",it.message,") ","\n");
+                       }));
                        return;
                }
                else if ( minig_cmd == "list-sessions" )
index 246440d39e5d0f84f03f06c0353033f03f5f4967..43b392f743a843caf5ecf26be5996be40a431536 100644 (file)
@@ -1,9 +1,6 @@
 #ifndef SV_MINIGAMES_H
 #define SV_MINIGAMES_H
 
-/// Initialize the minigame system
-void initialize_minigames();
-
 /// Create a new minigame session
 /// \return minigame session entity
 entity start_minigame(entity player, string minigame );
@@ -49,4 +46,20 @@ entity minigame_sessions;
 
 bool minigame_SendEntity(entity to, int sf);
 
+void RegisterMinigames();
+const int MINIGAMES_MAX = 24;
+entity MINIGAMES[MINIGAMES_MAX], MINIGAMES_first, MINIGAMES_last;
+int MINIGAMES_COUNT;
+#define REGISTER_MINIGAME(name,nicename) \
+    REGISTER(RegisterMinigames, MINIGAME, MINIGAMES, MINIGAMES_COUNT, name, m_id, spawn()); \
+    int name##_server_event(entity, string, ...); \
+    REGISTER_INIT_POST(MINIGAME, name) { \
+        this.classname = "minigame_descriptor"; \
+        this.netname = strzone(strtolower(#name)); \
+        this.message = nicename; \
+               this.minigame_event = name##_server_event; \
+    } \
+    REGISTER_INIT(MINIGAME, name)
+REGISTER_REGISTRY(RegisterMinigames)
+
 #endif
index c668959655db0c25c19b8214afafffb91cd62e19..0d17f43ab4ef1b9b1dbe5e28bc73db8c9f677c3b 100644 (file)
@@ -18,10 +18,7 @@ CLASS(Model, Object)
     }
     METHOD(Model, model_precache, void(entity this)) {
         string s = this.model_str();
-        int fh = fopen(s, FILE_READ);
-        if (fh >= 0) {
-            fclose(fh);
-        } else if (s && s != "" && s != "null") {
+        if (s != "" && s != "null" && !fexists(s)) {
             LOG_WARNINGF("Missing model: \"%s\"\n", s);
             return;
         }
index d2881e9ba98d8d1ff5336af4a656d5e0143ba4c0..534005db93f558ea4bf25b9f80a53dc351b7f08a 100644 (file)
@@ -91,7 +91,7 @@ void M_Mage_Attack_Spike_Explode()
 {SELFPARAM();
        self.event_damage = func_null;
 
-       sound(self, CH_SHOTS, W_Sound("grenade_impact"), VOL_BASE, ATTEN_NORM);
+       sound(self, CH_SHOTS, SND_GRENADE_IMPACT, VOL_BASE, ATTEN_NORM);
 
        self.realowner.mage_spike = world;
 
@@ -258,7 +258,7 @@ void M_Mage_Defend_Heal()
 
 void M_Mage_Attack_Push()
 {SELFPARAM();
-       sound(self, CH_SHOTS, W_Sound("tagexp1"), 1, ATTEN_NORM);
+       sound(self, CH_SHOTS, SND_TAGEXP1, 1, ATTEN_NORM);
        RadiusDamage (self, self, (autocvar_g_monster_mage_attack_push_damage), (autocvar_g_monster_mage_attack_push_damage), (autocvar_g_monster_mage_attack_push_radius), world, world, (autocvar_g_monster_mage_attack_push_force), DEATH_MONSTER_MAGE, self.enemy);
        Send_Effect(EFFECT_TE_EXPLOSION, self.origin, '0 0 0', 1);
 
@@ -422,8 +422,6 @@ bool M_Mage(int req)
                }
                case MR_PRECACHE:
                {
-                       precache_sound (W_Sound("grenade_impact"));
-                       precache_sound (W_Sound("tagexp1"));
                        return true;
                }
                #endif
index ea7fbbf7cc7fb17346ca57bc0a7ba4ed6e8c46a7..55e0f46e95413053bd525a6ce185437b17c06c88 100644 (file)
@@ -50,7 +50,7 @@ void M_Shambler_Attack_Smash()
 {SELFPARAM();
        makevectors(self.angles);
        Send_Effect(EFFECT_EXPLOSION_MEDIUM, (self.origin + (v_forward * 150)) - ('0 0 1' * self.maxs.z), '0 0 0', 1);
-       sound(self, CH_SHOTS, W_Sound("rocket_impact"), VOL_BASE, ATTEN_NORM);
+       sound(self, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
 
        // RadiusDamage does NOT support custom starting location, which means we must use this hack...
 
@@ -75,7 +75,7 @@ void M_Shambler_Attack_Lightning_Explode()
 {SELFPARAM();
        entity head;
 
-       sound(self, CH_SHOTS, W_Sound("electro_impact"), VOL_BASE, ATTEN_NORM);
+       sound(self, CH_SHOTS, SND_ELECTRO_IMPACT, VOL_BASE, ATTEN_NORM);
        Send_Effect(EFFECT_ELECTRO_IMPACT, '0 0 0', '0 0 0', 1);
 
        self.event_damage = func_null;
index fb71c2f22279b199fa8f0f1c518f6de506f88ca5..f6c3089ce358d0c45b64e985f04d507a674d29e5 100644 (file)
@@ -63,7 +63,7 @@ void M_Spider_Attack_Web()
 {SELFPARAM();
        monster_makevectors(self.enemy);
 
-       sound(self, CH_SHOTS, W_Sound("electro_fire2"), VOL_BASE, ATTEN_NORM);
+       sound(self, CH_SHOTS, SND_ELECTRO_FIRE2, VOL_BASE, ATTEN_NORM);
 
        entity proj = spawn ();
        proj.classname = "plasma";
@@ -176,7 +176,6 @@ bool M_Spider(int req)
                }
                case MR_PRECACHE:
                {
-                       precache_sound (W_Sound("electro_fire2"));
                        return true;
                }
                #endif
index 8eab200a6d9748d37269910dd06603ec2e1690a3..0734d54d56943b7e71809c383eaf68e722c2b90e 100644 (file)
@@ -118,7 +118,7 @@ bool Monster_ValidTarget(entity mon, entity player)
                makevectors (mon.angles);
                dot = normalize (player.origin - mon.origin) * v_forward;
 
-               if(dot <= 0.3) { return false; }
+               if(dot <= autocvar_g_monsters_target_infront_range) { return false; }
        }
 
        return true; // this target is valid!
@@ -1085,7 +1085,7 @@ void Monster_Damage(entity inflictor, entity attacker, float damage, int deathty
        self.dmg_time = time;
 
        if(sound_allowed(MSG_BROADCAST, attacker) && deathtype != DEATH_DROWN)
-               spamsound (self, CH_PAIN, "misc/bodyimpact1.wav", VOL_BASE, ATTEN_NORM);  // FIXME: PLACEHOLDER
+               spamsound (self, CH_PAIN, SND(BODYIMPACT1), VOL_BASE, ATTEN_NORM);  // FIXME: PLACEHOLDER
 
        self.velocity += force * self.damageforcescale;
 
index fedcf9fe571d6445a60fbc9ad10cffcce8844a25..7a05c85ea3b05071fdeb4fe14d8d2c443bd51cc3 100644 (file)
@@ -63,6 +63,19 @@ void Casing_Draw()
     }
 }
 
+SOUND(BRASS1, W_Sound("brass1"));
+SOUND(BRASS2, W_Sound("brass2"));
+SOUND(BRASS3, W_Sound("brass3"));
+Sound SND_BRASS_RANDOM() {
+    return SOUNDS[SND_BRASS1.m_id + floor(prandom() * 3)];
+}
+SOUND(CASINGS1, W_Sound("casings1"));
+SOUND(CASINGS2, W_Sound("casings2"));
+SOUND(CASINGS3, W_Sound("casings3"));
+Sound SND_CASINGS_RANDOM() {
+    return SOUNDS[SND_CASINGS1.m_id + floor(prandom() * 3)];
+}
+
 void Casing_Touch()
 {SELFPARAM();
     if (trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT)
@@ -78,16 +91,14 @@ void Casing_Touch()
         {
             if (time >= self.nextthink)
             {
-                string s;
-                int f = floor(prandom() * 3) + 1;
-
+                Sound s;
                 switch (self.state)
                 {
                     case 1:
-                        s = W_Sound(strcat("casings", itos(f)));
+                        s = SND_CASINGS_RANDOM();
                         break;
                     default:
-                        s = W_Sound(strcat("brass", itos(f)));
+                        s = SND_BRASS_RANDOM();
                         break;
                 }
 
@@ -163,13 +174,4 @@ MUTATOR_HOOKFUNCTION(casings, CSQC_Parse_TempEntity)
     RubbleLimit("casing", autocvar_cl_casings_maxcount, Casing_Delete);
 }
 
-STATIC_INIT(Casings)
-{
-    precache_sound(W_Sound("brass1"));
-    precache_sound(W_Sound("brass2"));
-    precache_sound(W_Sound("brass3"));
-    precache_sound(W_Sound("casings1"));
-    precache_sound(W_Sound("casings2"));
-    precache_sound(W_Sound("casings3"));
-}
 #endif
index 9ec6c291451c20a80d683138178121afbbac88c0..ba189c9bf8dc38cb416107cf24682f67e89eea05 100644 (file)
@@ -127,8 +127,8 @@ string Nade_TrailEffect(float proj, float nade_team)
     ));
     switch (proj)
     {
-        case PROJECTILE_NADE: return strcat("nade_", Static_Team_ColorName_Lower(nade_team));
-        case PROJECTILE_NADE_BURN: return strcat("nade_", Static_Team_ColorName_Lower(nade_team), "_burn");
+        case PROJECTILE_NADE:       return EFFECT_NADE_TRAIL(nade_team).eent_eff_name;
+        case PROJECTILE_NADE_BURN:  return EFFECT_NADE_TRAIL_BURN(nade_team).eent_eff_name;
     }
     return "";
 }
index 626c42c7d61d590c5d4e00f71b34041220e64edc..f2195698190f19aa8e7e2aaa64f93c131905929d 100644 (file)
@@ -1286,7 +1286,7 @@ void Local_Notification_sound(
                ));
                #endif
 
-               sound(
+               _sound(
                        world,
                        soundchannel,
                        sprintf(
diff --git a/qcsrc/common/sounds/sounds.inc b/qcsrc/common/sounds/sounds.inc
new file mode 100644 (file)
index 0000000..7993450
--- /dev/null
@@ -0,0 +1,276 @@
+// Global list of sounds
+// TODO: remove uses of _sound
+
+string W_Sound(string w_snd);
+
+SOUND(ARC_FIRE, W_Sound("arc_fire"));
+SOUND(ARC_LOOP, W_Sound("arc_loop"));
+SOUND(ARC_LOOP_OVERHEAT, W_Sound("arc_loop_overheat"));
+SOUND(ARC_STOP, W_Sound("arc_stop"));
+SOUND(CAMPINGRIFLE_FIRE2, W_Sound("campingrifle_fire2"));
+SOUND(CAMPINGRIFLE_FIRE, W_Sound("campingrifle_fire"));
+SOUND(CRYLINK_FIRE2, W_Sound("crylink_fire2"));
+SOUND(CRYLINK_FIRE, W_Sound("crylink_fire"));
+SOUND(CRYLINK_IMPACT2, W_Sound("crylink_impact2"));
+SOUND(CRYLINK_IMPACT, W_Sound("crylink_impact"));
+SOUND(CRYLINK_LINKJOIN, W_Sound("crylink_linkjoin"));
+SOUND(DRYFIRE, W_Sound("dryfire"));
+SOUND(ELECTRO_BOUNCE, W_Sound("electro_bounce"));
+SOUND(ELECTRO_FIRE2, W_Sound("electro_fire2"));
+SOUND(ELECTRO_FIRE, W_Sound("electro_fire"));
+SOUND(ELECTRO_FLY, W_Sound("electro_fly"));
+SOUND(ELECTRO_IMPACT, W_Sound("electro_impact"));
+SOUND(ELECTRO_IMPACT_COMBO, W_Sound("electro_impact_combo"));
+SOUND(FIREBALL_FIRE2, W_Sound("fireball_fire2"));
+SOUND(FIREBALL_FIRE, W_Sound("fireball_fire"));
+SOUND(FIREBALL_FLY2, W_Sound("fireball_fly2"));
+SOUND(FIREBALL_FLY, W_Sound("fireball_fly"));
+SOUND(FIREBALL_IMPACT2, W_Sound("fireball_impact2"));
+SOUND(FIREBALL_PREFIRE2, W_Sound("fireball_prefire2"));
+SOUND(FLAC_FIRE, W_Sound("flac_fire"));
+SOUND(GRENADE_BOUNCE1, W_Sound("grenade_bounce1"));
+SOUND(GRENADE_BOUNCE2, W_Sound("grenade_bounce2"));
+SOUND(GRENADE_BOUNCE3, W_Sound("grenade_bounce3"));
+SOUND(GRENADE_BOUNCE4, W_Sound("grenade_bounce4"));
+SOUND(GRENADE_BOUNCE5, W_Sound("grenade_bounce5"));
+SOUND(GRENADE_BOUNCE6, W_Sound("grenade_bounce6"));
+Sound SND_GRENADE_BOUNCE_RANDOM() {
+    return SOUNDS[SND_GRENADE_BOUNCE1.m_id + rint(random() * 5)];
+}
+SOUND(GRENADE_FIRE, W_Sound("grenade_fire"));
+SOUND(GRENADE_IMPACT, W_Sound("grenade_impact"));
+SOUND(GRENADE_STICK, W_Sound("grenade_stick"));
+SOUND(HAGAR_BEEP, W_Sound("hagar_beep"));
+SOUND(HAGAR_FIRE, W_Sound("hagar_fire"));
+SOUND(HAGAR_LOAD, W_Sound("hagar_load"));
+SOUND(HAGEXP1, W_Sound("hagexp1"));
+SOUND(HAGEXP2, W_Sound("hagexp2"));
+SOUND(HAGEXP3, W_Sound("hagexp3"));
+Sound SND_HAGEXP_RANDOM() {
+    return SOUNDS[SND_HAGEXP1.m_id + rint(random() * 2)];
+}
+
+SOUND(HOOKBOMB_FIRE, W_Sound("hookbomb_fire"));
+SOUND(HOOKBOMB_IMPACT, W_Sound("hookbomb_impact"));
+SOUND(HOOK_FIRE, W_Sound("hook_fire"));
+SOUND(HOOK_IMPACT, W_Sound("hook_impact"));
+SOUND(LASERGUN_FIRE, W_Sound("lasergun_fire"));
+SOUND(LASERIMPACT, W_Sound("laserimpact"));
+SOUND(LGBEAM_FLY, W_Sound("lgbeam_fly"));
+SOUND(MINE_DET, W_Sound("mine_det"));
+SOUND(MINE_EXP, W_Sound("mine_exp"));
+SOUND(MINE_FIRE, W_Sound("mine_fire"));
+SOUND(MINE_STICK, W_Sound("mine_stick"));
+SOUND(MINE_TRIGGER, W_Sound("mine_trigger"));
+SOUND(MINSTANEXFIRE, W_Sound("minstanexfire"));
+SOUND(NEXCHARGE, W_Sound("nexcharge"));
+SOUND(NEXFIRE, W_Sound("nexfire"));
+SOUND(NEXIMPACT, W_Sound("neximpact"));
+SOUND(NEXWHOOSH1, W_Sound("nexwhoosh1"));
+SOUND(NEXWHOOSH2, W_Sound("nexwhoosh2"));
+SOUND(NEXWHOOSH3, W_Sound("nexwhoosh3"));
+Sound SND_NEXWHOOSH_RANDOM() {
+    return SOUNDS[SND_NEXWHOOSH1.m_id + rint(random() * 2)];
+}
+SOUND(RELOAD, W_Sound("reload")); // until weapons have individual reload sounds, precache the reload sound here
+
+SOUND(RIC1, W_Sound("ric1"));
+SOUND(RIC2, W_Sound("ric2"));
+SOUND(RIC3, W_Sound("ric3"));
+Sound SND_RIC_RANDOM() {
+    return SOUNDS[SND_RIC1.m_id + rint(random() * 2)];
+}
+
+SOUND(ROCKET_DET, W_Sound("rocket_det"));
+SOUND(ROCKET_FIRE, W_Sound("rocket_fire"));
+SOUND(ROCKET_FLY, W_Sound("rocket_fly"));
+SOUND(ROCKET_IMPACT, W_Sound("rocket_impact"));
+SOUND(ROCKET_MODE, W_Sound("rocket_mode"));
+SOUND(SEEKEREXP1, W_Sound("seekerexp1"));
+SOUND(SEEKEREXP2, W_Sound("seekerexp2"));
+SOUND(SEEKEREXP3, W_Sound("seekerexp3"));
+SOUND(SEEKER_FIRE, W_Sound("seeker_fire"));
+SOUND(SHOTGUN_FIRE, W_Sound("shotgun_fire"));
+SOUND(SHOTGUN_MELEE, W_Sound("shotgun_melee"));
+SOUND(STRENGTH_FIRE, W_Sound("strength_fire"));
+SOUND(TAGEXP1, W_Sound("tagexp1"));
+SOUND(TAGEXP2, W_Sound("tagexp2"));
+SOUND(TAGEXP3, W_Sound("tagexp3"));
+SOUND(TAG_FIRE, W_Sound("tag_fire"));
+SOUND(TAG_IMPACT, W_Sound("tag_impact"));
+SOUND(TAG_ROCKET_FLY, W_Sound("tag_rocket_fly"));
+SOUND(UNAVAILABLE, W_Sound("unavailable"));
+SOUND(UZI_FIRE, W_Sound("uzi_fire"));
+SOUND(WEAPONPICKUP, W_Sound("weaponpickup"));
+SOUND(WEAPONPICKUP_NEW_TOYS, W_Sound("weaponpickup_new_toys"));
+SOUND(WEAPON_SWITCH, W_Sound("weapon_switch"));
+
+SOUND(CTF_CAPTURE_NEUTRAL, "ctf/capture.ogg");
+SOUND(CTF_CAPTURE_RED, "ctf/red_capture.wav");
+SOUND(CTF_CAPTURE_BLUE, "ctf/blue_capture.wav");
+SOUND(CTF_CAPTURE_YELLOW, "ctf/yellow_capture.ogg");
+SOUND(CTF_CAPTURE_PINK, "ctf/pink_capture.ogg");
+Sound SND_CTF_CAPTURE(int teamid) {
+    switch (teamid) {
+        case NUM_TEAM_1:    return SND_CTF_CAPTURE_RED;
+        case NUM_TEAM_2:    return SND_CTF_CAPTURE_BLUE;
+        case NUM_TEAM_3:    return SND_CTF_CAPTURE_YELLOW;
+        case NUM_TEAM_4:    return SND_CTF_CAPTURE_PINK;
+        default:            return SND_CTF_CAPTURE_NEUTRAL;
+    }
+}
+
+SOUND(CTF_DROPPED_NEUTRAL,  "ctf/neutral_dropped.wav");
+SOUND(CTF_DROPPED_RED,      "ctf/red_dropped.wav");
+SOUND(CTF_DROPPED_BLUE,     "ctf/blue_dropped.wav");
+SOUND(CTF_DROPPED_YELLOW,   "ctf/yellow_dropped.wav");
+SOUND(CTF_DROPPED_PINK,     "ctf/pink_dropped.wav");
+Sound SND_CTF_DROPPED(int teamid) {
+    switch (teamid) {
+        case NUM_TEAM_1:    return SND_CTF_DROPPED_RED;
+        case NUM_TEAM_2:    return SND_CTF_DROPPED_BLUE;
+        case NUM_TEAM_3:    return SND_CTF_DROPPED_YELLOW;
+        case NUM_TEAM_4:    return SND_CTF_DROPPED_PINK;
+        default:            return SND_CTF_DROPPED_NEUTRAL;
+    }
+}
+
+SOUND(CTF_PASS, "ctf/pass.wav");
+SOUND(CTF_RESPAWN, "ctf/flag_respawn.wav");
+
+SOUND(CTF_RETURNED_NEUTRAL,  "ctf/return.wav");
+SOUND(CTF_RETURNED_RED,      "ctf/red_returned.wav");
+SOUND(CTF_RETURNED_BLUE,     "ctf/blue_returned.wav");
+SOUND(CTF_RETURNED_YELLOW,   "ctf/yellow_returned.wav");
+SOUND(CTF_RETURNED_PINK,     "ctf/pink_returned.wav");
+Sound SND_CTF_RETURNED(int teamid) {
+    switch (teamid) {
+        case NUM_TEAM_1:    return SND_CTF_RETURNED_RED;
+        case NUM_TEAM_2:    return SND_CTF_RETURNED_BLUE;
+        case NUM_TEAM_3:    return SND_CTF_RETURNED_YELLOW;
+        case NUM_TEAM_4:    return SND_CTF_RETURNED_PINK;
+        default:            return SND_CTF_RETURNED_NEUTRAL;
+    }
+}
+
+SOUND(CTF_TAKEN_NEUTRAL,  "ctf/neutral_taken.wav");
+SOUND(CTF_TAKEN_RED,      "ctf/red_taken.wav");
+SOUND(CTF_TAKEN_BLUE,     "ctf/blue_taken.wav");
+SOUND(CTF_TAKEN_YELLOW,   "ctf/yellow_taken.wav");
+SOUND(CTF_TAKEN_PINK,     "ctf/pink_taken.wav");
+Sound SND_CTF_TAKEN(int teamid) {
+    switch (teamid) {
+        case NUM_TEAM_1:    return SND_CTF_TAKEN_RED;
+        case NUM_TEAM_2:    return SND_CTF_TAKEN_BLUE;
+        case NUM_TEAM_3:    return SND_CTF_TAKEN_YELLOW;
+        case NUM_TEAM_4:    return SND_CTF_TAKEN_PINK;
+        default:            return SND_CTF_TAKEN_NEUTRAL;
+    }
+}
+
+SOUND(CTF_TOUCH, "ctf/touch.wav");
+
+SOUND(DOM_CLAIM, "domination/claim.wav");
+
+SOUND(KA_DROPPED, "keepaway/dropped.wav");
+SOUND(KA_PICKEDUP, "keepaway/pickedup.wav");
+SOUND(KA_RESPAWN, "keepaway/respawn.wav");
+SOUND(KA_TOUCH, "keepaway/touch.wav");
+
+SOUND(KH_ALARM, "kh/alarm.wav");
+SOUND(KH_CAPTURE, "kh/capture.wav");
+SOUND(KH_COLLECT, "kh/collect.wav");
+SOUND(KH_DESTROY, "kh/destroy.wav");
+SOUND(KH_DROP, "kh/drop.wav");
+
+SOUND(NB_BOUNCE, "nexball/bounce.ogg");
+SOUND(NB_DROP, "nexball/drop.ogg");
+SOUND(NB_SHOOT1, "nexball/shoot1.ogg");
+SOUND(NB_SHOOT2, "nexball/shoot2.ogg");
+SOUND(NB_STEAL, "nexball/steal.ogg");
+
+SOUND(ONS_CONTROLPOINT_BUILD, "onslaught/controlpoint_build.ogg");
+SOUND(ONS_CONTROLPOINT_BUILT, "onslaught/controlpoint_built.ogg");
+SOUND(ONS_CONTROLPOINT_UNDERATTACK, "onslaught/controlpoint_underattack.ogg");
+SOUND(ONS_DAMAGEBLOCKEDBYSHIELD, "onslaught/damageblockedbyshield.wav");
+SOUND(ONS_ELECTRICITY_EXPLODE, "onslaught/electricity_explode.ogg");
+SOUND(ONS_GENERATOR_DECAY, "onslaught/generator_decay.ogg");
+SOUND(ONS_GENERATOR_UNDERATTACK, "onslaught/generator_underattack.ogg");
+SOUND(ONS_HIT1, "onslaught/ons_hit1.ogg");
+SOUND(ONS_HIT2, "onslaught/ons_hit2.ogg");
+SOUND(ONS_SPARK1, "onslaught/ons_spark1.ogg");
+SOUND(ONS_SPARK2, "onslaught/ons_spark2.ogg");
+SOUND(ONS_SHOCKWAVE, "onslaught/shockwave.ogg");
+
+SOUND(PORTO_BOUNCE, "porto/bounce.ogg");
+SOUND(PORTO_CREATE, "porto/create.ogg");
+SOUND(PORTO_EXPIRE, "porto/expire.ogg");
+SOUND(PORTO_EXPLODE, "porto/explode.ogg");
+SOUND(PORTO_FIRE, "porto/fire.ogg");
+SOUND(PORTO_UNSUPPORTED, "porto/unsupported.ogg");
+
+SOUND(TUR_PHASER, "turrets/phaser.ogg");
+
+SOUND(VEH_ALARM, "vehicles/alarm.wav");
+SOUND(VEH_ALARM_SHIELD, "vehicles/alarm_shield.wav");
+SOUND(VEH_MISSILE_ALARM, "vehicles/missile_alarm.wav");
+
+SOUND(VEH_BUMBLEBEE_FIRE, W_Sound("flacexp3"));
+
+SOUND(VEH_RACER_BOOST, "vehicles/racer_boost.wav");
+SOUND(VEH_RACER_IDLE, "vehicles/racer_idle.wav");
+SOUND(VEH_RACER_MOVE, "vehicles/racer_move.wav");
+
+SOUND(VEH_RAPTOR_FLY, "vehicles/raptor_fly.wav");
+SOUND(VEH_RAPTOR_SPEED, "vehicles/raptor_speed.wav");
+
+SOUND(VEH_SPIDERBOT_DIE, "vehicles/spiderbot_die.wav");
+SOUND(VEH_SPIDERBOT_IDLE, "vehicles/spiderbot_idle.wav");
+SOUND(VEH_SPIDERBOT_JUMP, "vehicles/spiderbot_jump.wav");
+SOUND(VEH_SPIDERBOT_LAND, "vehicles/spiderbot_land.wav");
+SOUND(VEH_SPIDERBOT_STRAFE, "vehicles/spiderbot_strafe.wav");
+SOUND(VEH_SPIDERBOT_WALK, "vehicles/spiderbot_walk.wav");
+
+SOUND(NADE_BEEP, "overkill/grenadebip.ogg");
+
+SOUND(BUFF_LOST, "relics/relic_effect.wav");
+
+SOUND(POWEROFF, "misc/poweroff.wav");
+SOUND(POWERUP, "misc/powerup.ogg");
+SOUND(SHIELD_RESPAWN, "misc/shield_respawn.wav");
+SOUND(STRENGTH_RESPAWN, "misc/strength_respawn.wav");
+
+SOUND(ARMOR25, "misc/armor25.wav");
+SOUND(ARMORIMPACT, "misc/armorimpact.wav");
+SOUND(BODYIMPACT1, "misc/bodyimpact1.wav");
+SOUND(BODYIMPACT2, "misc/bodyimpact2.wav");
+
+SOUND(ITEMPICKUP, "misc/itempickup.ogg");
+SOUND(ITEMRESPAWNCOUNTDOWN, "misc/itemrespawncountdown.ogg");
+SOUND(ITEMRESPAWN, "misc/itemrespawn.ogg");
+SOUND(MEGAHEALTH, "misc/megahealth.ogg");
+
+SOUND(LAVA, "player/lava.wav");
+SOUND(SLIME, "player/slime.wav");
+
+SOUND(GIB, "misc/gib.wav");
+SOUND(GIB_SPLAT01, "misc/gib_splat01.wav");
+SOUND(GIB_SPLAT02, "misc/gib_splat02.wav");
+SOUND(GIB_SPLAT03, "misc/gib_splat03.wav");
+SOUND(GIB_SPLAT04, "misc/gib_splat04.wav");
+Sound SND_GIB_SPLAT_RANDOM() {
+    return SOUNDS[SND_GIB_SPLAT01.m_id + floor(prandom() * 4)];
+}
+
+SOUND(HIT, "misc/hit.wav");
+SOUND(TYPEHIT, "misc/typehit.wav");
+
+SOUND(SPAWN, "misc/spawn.ogg");
+
+SOUND(TALK, "misc/talk.wav");
+
+SOUND(TELEPORT, "misc/teleport.ogg");
+
+SOUND(INVSHOT, "misc/invshot.wav");
+
+SOUND(JETPACK_FLY, "misc/jetpack_fly.ogg");
diff --git a/qcsrc/common/sounds/sounds.qh b/qcsrc/common/sounds/sounds.qh
new file mode 100644 (file)
index 0000000..c9838b2
--- /dev/null
@@ -0,0 +1,59 @@
+#ifndef SOUNDS_H
+#define SOUNDS_H
+
+#include "../teams.qh"
+
+// Play all sounds via sound7, for access to the extra channels.
+// Otherwise, channels 8 to 15 would be blocked for a weird QW feature.
+#ifdef SVQC
+    #define _sound(e, c, s, v, a) do { \
+        entity __e = e; \
+        if (!sound_allowed(MSG_BROADCAST, __e)) break; \
+        sound7(__e, c, s, v, a, 0, 0); \
+    } while (0)
+#else
+    #define _sound(e, c, s, v, a) sound7(e, c, s, v, a, 0, 0)
+#endif
+#define sound(e, c, s, v, a) _sound(e, c, s.sound_str(), v, a)
+// Used in places where a string is required
+#define SND(id) (SND_##id.sound_str())
+
+void RegisterSounds();
+const int MAX_SOUNDS = 128;
+entity SOUNDS[MAX_SOUNDS], SOUNDS_first, SOUNDS_last;
+int SOUNDS_COUNT;
+
+CLASS(Sound, Object)
+    ATTRIB(Sound, m_id, int, 0)
+    ATTRIB(Sound, sound_str, string(), func_null)
+    CONSTRUCTOR(Sound, string() path)
+    {
+        CONSTRUCT(Sound);
+        this.sound_str = path;
+    }
+    METHOD(Sound, sound_precache, void(entity this)) {
+        string s = this.sound_str();
+        if (s && s != "" && !fexists(strcat("sound/", s))) {
+            LOG_WARNINGF("Missing sound: \"%s\"\n", s);
+            return;
+        }
+        LOG_TRACEF("precache_sound(\"%s\")\n", s);
+        precache_sound(s);
+    }
+ENDCLASS(Sound)
+
+#define SOUND(name, path) \
+    string SND_##name##_get() { return path; } \
+    REGISTER(RegisterSounds, SND, SOUNDS, SOUNDS_COUNT, name, m_id, NEW(Sound, SND_##name##_get))
+REGISTER_REGISTRY(RegisterSounds)
+
+STATIC_INIT(RegisterSounds_precache) {
+    FOREACH(SOUNDS, true, LAMBDA({
+        it.sound_precache(it);
+    }));
+}
+
+SOUND(Null, "misc/null.wav");
+#include "sounds.inc"
+
+#endif
index 0430db2d4104e49901f32b80549e144f8fcba45c..b2a4894a5238a84f6cfa1dc7d901cc316860e7cf 100644 (file)
@@ -162,7 +162,7 @@ void func_breakable_behave_restore()
        self.nextthink = 0; // cancel auto respawn
        func_breakable_colormod();
        if (self.noise1)
-               sound (self, CH_TRIGGER_SINGLE, self.noise1, VOL_BASE, ATTEN_NORM);
+               _sound (self, CH_TRIGGER_SINGLE, self.noise1, VOL_BASE, ATTEN_NORM);
 }
 
 void func_breakable_init_for_player(entity player)
@@ -207,7 +207,7 @@ void func_breakable_destroy()
        func_breakable_destroyed();
 
        if(self.noise)
-               sound (self, CH_TRIGGER, self.noise, VOL_BASE, ATTEN_NORM);
+               _sound (self, CH_TRIGGER, self.noise, VOL_BASE, ATTEN_NORM);
 
        if(self.dmg)
                RadiusDamage(self, activator, self.dmg, self.dmg_edge, self.dmg_radius, self, world, self.dmg_force, DEATH_HURTTRIGGER, world);
index 228b3f810aa5c3b62b91a8508cbd9a545ddcfcf4..a55f02ef2fcc003852ef8aadde68dc799326f147 100644 (file)
@@ -44,7 +44,7 @@ void button_fire()
                return;
 
        if (self.noise != "")
-               sound (self, CH_TRIGGER, self.noise, VOL_BASE, ATTEN_NORM);
+               _sound (self, CH_TRIGGER, self.noise, VOL_BASE, ATTEN_NORM);
 
        self.state = STATE_UP;
        SUB_CalcMove (self.pos2, TSPEED_LINEAR, self.speed, button_wait);
index 8d19a740c26dbd6b6c89dccd0fab7b874abc454b..422295fa86397510b3230fb87912f490a39059ef 100644 (file)
@@ -87,7 +87,7 @@ void door_blocked()
 void door_hit_top()
 {SELFPARAM();
        if (self.noise1 != "")
-               sound (self, CH_TRIGGER_SINGLE, self.noise1, VOL_BASE, ATTEN_NORM);
+               _sound (self, CH_TRIGGER_SINGLE, self.noise1, VOL_BASE, ATTEN_NORM);
        self.state = STATE_TOP;
        if (self.spawnflags & DOOR_TOGGLE)
                return;         // don't come down automatically
@@ -104,14 +104,14 @@ void door_hit_top()
 void door_hit_bottom()
 {SELFPARAM();
        if (self.noise1 != "")
-               sound (self, CH_TRIGGER_SINGLE, self.noise1, VOL_BASE, ATTEN_NORM);
+               _sound (self, CH_TRIGGER_SINGLE, self.noise1, VOL_BASE, ATTEN_NORM);
        self.state = STATE_BOTTOM;
 }
 
 void door_go_down()
 {SELFPARAM();
        if (self.noise2 != "")
-               sound (self, CH_TRIGGER_SINGLE, self.noise2, VOL_BASE, ATTEN_NORM);
+               _sound (self, CH_TRIGGER_SINGLE, self.noise2, VOL_BASE, ATTEN_NORM);
        if (self.max_health)
        {
                self.takedamage = DAMAGE_YES;
@@ -134,7 +134,7 @@ void door_go_up()
        }
 
        if (self.noise2 != "")
-               sound (self, CH_TRIGGER_SINGLE, self.noise2, VOL_BASE, ATTEN_NORM);
+               _sound (self, CH_TRIGGER_SINGLE, self.noise2, VOL_BASE, ATTEN_NORM);
        self.state = STATE_UP;
        SUB_CalcMove (self.pos2, TSPEED_LINEAR, self.speed, door_hit_top);
 
@@ -180,7 +180,7 @@ float door_check_keys(void)
                if (other.key_door_messagetime <= time)
                {
 
-                       play2(other, "misc/talk.wav");
+                       play2(other, SND(TALK));
                        Send_Notification(NOTIF_ONE, other, MSG_CENTER, CENTER_DOOR_LOCKED_ALSONEED, item_keys_keylist(door.itemkeys));
                        other.key_door_messagetime = time + 2;
                }
@@ -190,7 +190,7 @@ float door_check_keys(void)
                // no keys were used
                if (other.key_door_messagetime <= time)
                {
-                       play2(other, "misc/talk.wav");
+                       play2(other, SND(TALK));
                        Send_Notification(NOTIF_ONE, other, MSG_CENTER, CENTER_DOOR_LOCKED_NEED, item_keys_keylist(door.itemkeys));
 
                        other.key_door_messagetime = time + 2;
@@ -202,7 +202,7 @@ float door_check_keys(void)
        {
 #ifdef SVQC
                // door is now unlocked
-               play2(other, "misc/talk.wav");
+               play2(other, SND(TALK));
                Send_Notification(NOTIF_ONE, other, MSG_CENTER, CENTER_DOOR_UNLOCKED);
 #endif
                return true;
@@ -321,7 +321,7 @@ void door_touch()
        {
                if (IS_CLIENT(other))
                        centerprint(other, self.owner.message);
-               play2(other, "misc/talk.wav");
+               play2(other, SND(TALK));
        }
 #endif
 }
@@ -367,7 +367,7 @@ void door_generic_plat_blocked()
 void door_rotating_hit_top()
 {SELFPARAM();
        if (self.noise1 != "")
-               sound (self, CH_TRIGGER_SINGLE, self.noise1, VOL_BASE, ATTEN_NORM);
+               _sound (self, CH_TRIGGER_SINGLE, self.noise1, VOL_BASE, ATTEN_NORM);
        self.state = STATE_TOP;
        if (self.spawnflags & DOOR_TOGGLE)
                return;         // don't come down automatically
@@ -378,7 +378,7 @@ void door_rotating_hit_top()
 void door_rotating_hit_bottom()
 {SELFPARAM();
        if (self.noise1 != "")
-               sound (self, CH_TRIGGER_SINGLE, self.noise1, VOL_BASE, ATTEN_NORM);
+               _sound (self, CH_TRIGGER_SINGLE, self.noise1, VOL_BASE, ATTEN_NORM);
        if (self.lip==666) // self.lip is used to remember reverse opening direction for door_rotating
        {
                self.pos2 = '0 0 0' - self.pos2;
@@ -390,7 +390,7 @@ void door_rotating_hit_bottom()
 void door_rotating_go_down()
 {SELFPARAM();
        if (self.noise2 != "")
-               sound (self, CH_TRIGGER_SINGLE, self.noise2, VOL_BASE, ATTEN_NORM);
+               _sound (self, CH_TRIGGER_SINGLE, self.noise2, VOL_BASE, ATTEN_NORM);
        if (self.max_health)
        {
                self.takedamage = DAMAGE_YES;
@@ -412,7 +412,7 @@ void door_rotating_go_up()
                return;
        }
        if (self.noise2 != "")
-               sound (self, CH_TRIGGER_SINGLE, self.noise2, VOL_BASE, ATTEN_NORM);
+               _sound (self, CH_TRIGGER_SINGLE, self.noise2, VOL_BASE, ATTEN_NORM);
        self.state = STATE_UP;
        SUB_CalcAngleMove (self.pos2, TSPEED_LINEAR, self.speed, door_rotating_hit_top);
 
index b793228784822068ec579e1b29924c95c5c5a789..5b2cfc5ba05a4f620bc541279dbf59c6dc28d970 100644 (file)
@@ -35,7 +35,7 @@ void fd_secret_use()
        // Make a sound, wait a little...
 
        if (self.noise1 != "")
-               sound(self, CH_TRIGGER_SINGLE, self.noise1, VOL_BASE, ATTEN_NORM);
+               _sound(self, CH_TRIGGER_SINGLE, self.noise1, VOL_BASE, ATTEN_NORM);
        self.SUB_NEXTTHINK = self.SUB_LTIME + 0.1;
 
        temp = 1 - (self.spawnflags & SECRET_1ST_LEFT); // 1 or -1
@@ -60,7 +60,7 @@ void fd_secret_use()
        self.dest2 = self.dest1 + v_forward * self.t_length;
        SUB_CalcMove(self.dest1, TSPEED_LINEAR, self.speed, fd_secret_move1);
        if (self.noise2 != "")
-               sound(self, CH_TRIGGER_SINGLE, self.noise2, VOL_BASE, ATTEN_NORM);
+               _sound(self, CH_TRIGGER_SINGLE, self.noise2, VOL_BASE, ATTEN_NORM);
 }
 
 void fd_secret_damage(entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
@@ -74,14 +74,14 @@ void fd_secret_move1()
        self.SUB_NEXTTHINK = self.SUB_LTIME + 1.0;
        self.think = fd_secret_move2;
        if (self.noise3 != "")
-               sound(self, CH_TRIGGER_SINGLE, self.noise3, VOL_BASE, ATTEN_NORM);
+               _sound(self, CH_TRIGGER_SINGLE, self.noise3, VOL_BASE, ATTEN_NORM);
 }
 
 // Start moving sideways w/sound...
 void fd_secret_move2()
 {SELFPARAM();
        if (self.noise2 != "")
-               sound(self, CH_TRIGGER_SINGLE, self.noise2, VOL_BASE, ATTEN_NORM);
+               _sound(self, CH_TRIGGER_SINGLE, self.noise2, VOL_BASE, ATTEN_NORM);
        SUB_CalcMove(self.dest2, TSPEED_LINEAR, self.speed, fd_secret_move3);
 }
 
@@ -89,7 +89,7 @@ void fd_secret_move2()
 void fd_secret_move3()
 {SELFPARAM();
        if (self.noise3 != "")
-               sound(self, CH_TRIGGER_SINGLE, self.noise3, VOL_BASE, ATTEN_NORM);
+               _sound(self, CH_TRIGGER_SINGLE, self.noise3, VOL_BASE, ATTEN_NORM);
        if (!(self.spawnflags & SECRET_OPEN_ONCE))
        {
                self.SUB_NEXTTHINK = self.SUB_LTIME + self.wait;
@@ -101,7 +101,7 @@ void fd_secret_move3()
 void fd_secret_move4()
 {SELFPARAM();
        if (self.noise2 != "")
-               sound(self, CH_TRIGGER_SINGLE, self.noise2, VOL_BASE, ATTEN_NORM);
+               _sound(self, CH_TRIGGER_SINGLE, self.noise2, VOL_BASE, ATTEN_NORM);
        SUB_CalcMove(self.dest1, TSPEED_LINEAR, self.speed, fd_secret_move5);
 }
 
@@ -111,13 +111,13 @@ void fd_secret_move5()
        self.SUB_NEXTTHINK = self.SUB_LTIME + 1.0;
        self.think = fd_secret_move6;
        if (self.noise3 != "")
-               sound(self, CH_TRIGGER_SINGLE, self.noise3, VOL_BASE, ATTEN_NORM);
+               _sound(self, CH_TRIGGER_SINGLE, self.noise3, VOL_BASE, ATTEN_NORM);
 }
 
 void fd_secret_move6()
 {SELFPARAM();
        if (self.noise2 != "")
-               sound(self, CH_TRIGGER_SINGLE, self.noise2, VOL_BASE, ATTEN_NORM);
+               _sound(self, CH_TRIGGER_SINGLE, self.noise2, VOL_BASE, ATTEN_NORM);
        SUB_CalcMove(self.oldorigin, TSPEED_LINEAR, self.speed, fd_secret_done);
 }
 
@@ -130,7 +130,7 @@ void fd_secret_done()
                //self.th_pain = fd_secret_use;
        }
        if (self.noise3 != "")
-               sound(self, CH_TRIGGER_SINGLE, self.noise3, VOL_BASE, ATTEN_NORM);
+               _sound(self, CH_TRIGGER_SINGLE, self.noise3, VOL_BASE, ATTEN_NORM);
 }
 
 void secret_blocked()
@@ -161,7 +161,7 @@ void secret_touch()
        {
                if (IS_CLIENT(other))
                        centerprint(other, self.message);
-               play2(other, "misc/talk.wav");
+               play2(other, SND(TALK));
        }
 }
 
index 3c11b2a5b675cef977ed8a0764871c5bc9c41694..058f1199f405189a11e4026c43464c6535109a4d 100644 (file)
@@ -230,7 +230,7 @@ void Draw_PointParticles()
                        if(self.noise != "")
                        {
                                setorigin(self, p);
-                               sound(self, CH_AMBIENT, self.noise, VOL_BASE * self.volume, self.atten);
+                               _sound(self, CH_AMBIENT, self.noise, VOL_BASE * self.volume, self.atten);
                        }
                        self.just_toggled = 0;
                }
index 4149b538dcf9b24626e0b5afa279fd5b83e2586b..187fd3f1b97be9174c2bbdf962be42f507c0c104 100644 (file)
@@ -98,7 +98,7 @@ void train_next()
        }
 
        if(self.noise != "")
-               sound(self, CH_TRIGGER_SINGLE, self.noise, VOL_BASE, ATTEN_IDLE);
+               _sound(self, CH_TRIGGER_SINGLE, self.noise, VOL_BASE, ATTEN_IDLE);
 }
 
 #ifdef SVQC
index b4f387470c64bea1c3e1e47fd17dbab141293e7d..dc568cae09224c001b4b1ba5c61f48bb5dede01a 100644 (file)
@@ -65,7 +65,7 @@ void plat_spawn_inside_trigger()
 
 void plat_hit_top()
 {SELFPARAM();
-       sound (self, CH_TRIGGER_SINGLE, self.noise1, VOL_BASE, ATTEN_NORM);
+       _sound (self, CH_TRIGGER_SINGLE, self.noise1, VOL_BASE, ATTEN_NORM);
        self.state = 1;
 
        self.SUB_THINK = plat_go_down;
@@ -74,20 +74,20 @@ void plat_hit_top()
 
 void plat_hit_bottom()
 {SELFPARAM();
-       sound (self, CH_TRIGGER_SINGLE, self.noise1, VOL_BASE, ATTEN_NORM);
+       _sound (self, CH_TRIGGER_SINGLE, self.noise1, VOL_BASE, ATTEN_NORM);
        self.state = 2;
 }
 
 void plat_go_down()
 {SELFPARAM();
-       sound (self, CH_TRIGGER_SINGLE, self.noise, VOL_BASE, ATTEN_NORM);
+       _sound (self, CH_TRIGGER_SINGLE, self.noise, VOL_BASE, ATTEN_NORM);
        self.state = 3;
        SUB_CalcMove (self.pos2, TSPEED_LINEAR, self.speed, plat_hit_bottom);
 }
 
 void plat_go_up()
 {SELFPARAM();
-       sound (self, CH_TRIGGER_SINGLE, self.noise, VOL_BASE, ATTEN_NORM);
+       _sound (self, CH_TRIGGER_SINGLE, self.noise, VOL_BASE, ATTEN_NORM);
        self.state = 4;
        SUB_CalcMove (self.pos1, TSPEED_LINEAR, self.speed, plat_hit_top);
 }
index 33261eabdbefc82206a2165da4d382053acddf4b..879c3042329c3898de0e252a1eddbd864181d9c1 100644 (file)
@@ -182,9 +182,9 @@ void TargetMusic_Advance()
                if(vol != vol0)
                {
                        if(vol0 < 0)
-                               sound(e, CH_BGM_SINGLE, e.noise, vol, ATTEN_NONE); // restart
+                               _sound(e, CH_BGM_SINGLE, e.noise, vol, ATTEN_NONE); // restart
                        else
-                               sound(e, CH_BGM_SINGLE, "", vol, ATTEN_NONE);
+                               _sound(e, CH_BGM_SINGLE, "", vol, ATTEN_NONE);
                        e.lastvol = vol;
                }
        }
@@ -223,7 +223,7 @@ void Net_TargetMusic()
                        strunzone(e.noise);
                e.noise = strzone(noi);
                precache_sound(e.noise);
-               sound(e, CH_BGM_SINGLE, e.noise, 0, ATTEN_NONE);
+               _sound(e, CH_BGM_SINGLE, e.noise, 0, ATTEN_NONE);
                if(getsoundtime(e, CH_BGM_SINGLE) < 0)
                {
                        LOG_TRACEF("Cannot initialize sound %s\n", e.noise);
@@ -310,7 +310,7 @@ void Ent_ReadTriggerMusic()
                if(self.noise != s)
                {
                        precache_sound(self.noise);
-                       sound(self, CH_BGM_SINGLE, self.noise, 0, ATTEN_NONE);
+                       _sound(self, CH_BGM_SINGLE, self.noise, 0, ATTEN_NONE);
                        if(getsoundtime(self, CH_BGM_SINGLE) < 0)
                        {
                                LOG_TRACEF("Cannot initialize sound %s\n", self.noise);
index e0701dc14f3273487baec91a8d19543f0b1d1e08..75f733c09eefa44d420a36c894beb88dfa05b791 100644 (file)
@@ -10,9 +10,9 @@ void target_speaker_use_activator()
        {
                var .string sample = GetVoiceMessageSampleField(substring(self.noise, 1, -1));
                if(GetPlayerSoundSampleField_notFound)
-                       snd = "misc/null.wav";
+                       snd = SND(Null);
                else if(activator.(sample) == "")
-                       snd = "misc/null.wav";
+                       snd = SND(Null);
                else
                {
                        tokenize_console(activator.(sample));
@@ -36,9 +36,9 @@ void target_speaker_use_on()
        {
                var .string sample = GetVoiceMessageSampleField(substring(self.noise, 1, -1));
                if(GetPlayerSoundSampleField_notFound)
-                       snd = "misc/null.wav";
+                       snd = SND(Null);
                else if(activator.(sample) == "")
-                       snd = "misc/null.wav";
+                       snd = SND(Null);
                else
                {
                        tokenize_console(activator.(sample));
@@ -52,13 +52,13 @@ void target_speaker_use_on()
        }
        else
                snd = self.noise;
-       sound(self, CH_TRIGGER_SINGLE, snd, VOL_BASE * self.volume, self.atten);
+       _sound(self, CH_TRIGGER_SINGLE, snd, VOL_BASE * self.volume, self.atten);
        if(self.spawnflags & 3)
                self.use = target_speaker_use_off;
 }
 void target_speaker_use_off()
 {SELFPARAM();
-       sound(self, CH_TRIGGER_SINGLE, "misc/null.wav", VOL_BASE * self.volume, self.atten);
+       sound(self, CH_TRIGGER_SINGLE, SND_Null, VOL_BASE * self.volume, self.atten);
        self.use = target_speaker_use_on;
 }
 void target_speaker_reset()
index bc4398601920968c61cfd7fd9d25f879569461bc..94f2bd26bc99b897a88a45002f27a6a83a7b3f78 100644 (file)
@@ -79,7 +79,7 @@ void TeleportPlayer(entity teleporter, entity player, vector to, vector to_angle
                if(self.pushltime < time) // only show one teleport effect per teleporter per 0.2 seconds, for better fps
                {
                        if(tflags & TELEPORT_FLAG_SOUND)
-                               sound (player, CH_TRIGGER, "misc/teleport.wav", VOL_BASE, ATTEN_NORM);
+                               sound (player, CH_TRIGGER, SND_TELEPORT, VOL_BASE, ATTEN_NORM);
                        if(tflags & TELEPORT_FLAG_PARTICLES)
                        {
                                Send_Effect(EFFECT_TELEPORT, player.origin, '0 0 0', 1);
index 659a336901e26665bb0ce56e14e1ee04327a252f..f329c71b0da0d79f6415472d454b1c5f1dcd272d 100644 (file)
@@ -80,7 +80,7 @@ void trigger_gravity_touch()
        {
                other.gravity = g;
                if(self.noise != "")
-                       sound (other, CH_TRIGGER, self.noise, VOL_BASE, ATTEN_NORM);
+                       _sound (other, CH_TRIGGER, self.noise, VOL_BASE, ATTEN_NORM);
                UpdateCSQCProjectile(self.owner);
        }
 }
index 323a4a160d2fb64cf36523fdfd58f3a624259219..49042427e61fa261f5d98f0fc05edf398fdc5cba 100644 (file)
@@ -19,7 +19,7 @@ void trigger_heal_touch()
                        {
                                other.health = min(other.health + self.health, self.max_health);
                                other.pauserothealth_finished = max(other.pauserothealth_finished, time + autocvar_g_balance_pause_health_rot);
-                               sound (other, CH_TRIGGER, self.noise, VOL_BASE, ATTEN_NORM);
+                               _sound (other, CH_TRIGGER, self.noise, VOL_BASE, ATTEN_NORM);
                        }
                }
        }
index 5eb25221821def3f73fb5b13d22994f3fb337cd8..cdc181ceb6513a769157756bd26e0e12c22cdbf7 100644 (file)
@@ -182,7 +182,7 @@ void trigger_push_touch()
                {
                        // flash when activated
                        Send_Effect(EFFECT_JUMPPAD, other.origin, other.velocity, 1);
-                       sound (other, CH_TRIGGER, self.noise, VOL_BASE, ATTEN_NORM);
+                       _sound (other, CH_TRIGGER, self.noise, VOL_BASE, ATTEN_NORM);
                        self.pushltime = time + 0.2;
                }
                if(IS_REAL_CLIENT(other) || IS_BOT_CLIENT(other))
index 17313f0aa85de43dda806660633a4055dcf10a73..f792185bc01eff4e608f176be13d8f4004be87b4 100644 (file)
@@ -146,7 +146,7 @@ void spawnfunc_trigger_keylock(void)
                if(self.sounds == 1)
                        self.noise = "misc/secret.wav";
                else if(self.sounds == 2)
-                       self.noise = "misc/talk.wav";
+                       self.noise = SND(TALK);
                else //if (self.sounds == 3) {
                        self.noise = "misc/trigger1.wav";
        }
@@ -157,7 +157,7 @@ void spawnfunc_trigger_keylock(void)
 
        // set closed sourd
        if(self.noise2 == "")
-               self.noise2 = "misc/talk.wav";
+               self.noise2 = SND(TALK);
 
        // delay between triggering message2 and trigger2
        if(!self.wait) { self.wait = 5; }
index 007e6da2f5e980cfc89a807b338e907edeeba296..2aa8f5c1ddf1ed8e101cf78466106d6c96c2dc9b 100644 (file)
@@ -32,7 +32,7 @@ void multi_trigger()
        }
 
        if (self.noise)
-               sound (self.enemy, CH_TRIGGER, self.noise, VOL_BASE, ATTEN_NORM);
+               _sound (self.enemy, CH_TRIGGER, self.noise, VOL_BASE, ATTEN_NORM);
 
 // don't trigger again until reset
        self.takedamage = DAMAGE_NO;
@@ -149,8 +149,7 @@ void spawnfunc_trigger_multiple()
        }
        else if (self.sounds == 2)
        {
-               precache_sound ("misc/talk.wav");
-               self.noise = "misc/talk.wav";
+               self.noise = SND(TALK);
        }
        else if (self.sounds == 3)
        {
index a44c688ed9544fb16c2e27647a8dd952807a39e3..73c5c49651259aaa9376945cc6e1c080df0bb91b 100644 (file)
@@ -173,7 +173,7 @@ void SUB_UseTargets()
        {
                centerprint(activator, self.message);
                if (self.noise == "")
-                       play2(activator, "misc/talk.wav");
+                       play2(activator, SND(TALK));
        }
 
 //
diff --git a/qcsrc/common/turrets/all.inc b/qcsrc/common/turrets/all.inc
new file mode 100644 (file)
index 0000000..04bb10f
--- /dev/null
@@ -0,0 +1,12 @@
+#include "unit/ewheel.qc"
+#include "unit/flac.qc"
+#include "unit/fusionreactor.qc"
+#include "unit/hellion.qc"
+#include "unit/hk.qc"
+#include "unit/machinegun.qc"
+#include "unit/mlrs.qc"
+#include "unit/phaser.qc"
+#include "unit/plasma.qc"
+#include "unit/plasma_dual.qc"
+#include "unit/tesla.qc"
+#include "unit/walker.qc"
diff --git a/qcsrc/common/turrets/all.qc b/qcsrc/common/turrets/all.qc
new file mode 100644 (file)
index 0000000..f0fc719
--- /dev/null
@@ -0,0 +1,5 @@
+#include "all.qh"
+
+#define IMPLEMENTATION
+#include "all.inc"
+#undef IMPLEMENTATION
index 04bb10f6a548e67da5fba28ed487c71a1300f52c..4f8a728028074f31aabfc02b9ae586532d77ca2a 100644 (file)
-#include "unit/ewheel.qc"
-#include "unit/flac.qc"
-#include "unit/fusionreactor.qc"
-#include "unit/hellion.qc"
-#include "unit/hk.qc"
-#include "unit/machinegun.qc"
-#include "unit/mlrs.qc"
-#include "unit/phaser.qc"
-#include "unit/plasma.qc"
-#include "unit/plasma_dual.qc"
-#include "unit/tesla.qc"
-#include "unit/walker.qc"
+#ifndef TURRETS_H
+#define TURRETS_H
+
+// turret requests
+#define TR_SETUP          1 // (BOTH) setup turret data
+#define TR_THINK                 2 // (SERVER) logic to run every frame
+#define TR_DEATH          3 // (SERVER) called when turret dies
+#define TR_PRECACHE       4 // (BOTH) precaches models/sounds used by this turret
+#define TR_ATTACK         5 // (SERVER) called when turret attacks
+#define TR_CONFIG         6 // (ALL)
+
+// functions:
+entity get_turretinfo(int id);
+
+// fields:
+.entity tur_head;
+
+// target selection flags
+.int target_select_flags;
+.int target_validate_flags;
+const int TFL_TARGETSELECT_NO = 2; // don't automatically find targets
+const int TFL_TARGETSELECT_LOS = 4; // require line of sight to find targets
+const int TFL_TARGETSELECT_PLAYERS = 8; // target players
+const int TFL_TARGETSELECT_MISSILES = 16; // target projectiles
+const int TFL_TARGETSELECT_TRIGGERTARGET = 32; // respond to turret_trigger_target events
+const int TFL_TARGETSELECT_ANGLELIMITS = 64; // apply extra angular limits to target selection
+const int TFL_TARGETSELECT_RANGELIMITS = 128; // limit target selection range
+const int TFL_TARGETSELECT_TEAMCHECK = 256; // don't attack teammates
+const int TFL_TARGETSELECT_NOBUILTIN = 512; // only attack targets when triggered
+const int TFL_TARGETSELECT_OWNTEAM = 1024; // only attack teammates
+const int TFL_TARGETSELECT_NOTURRETS = 2048; // don't attack other turrets
+const int TFL_TARGETSELECT_FOV = 4096; // extra limits to attack range
+const int TFL_TARGETSELECT_MISSILESONLY = 8192; // only attack missiles
+
+// aim flags
+.int aim_flags;
+const int TFL_AIM_NO = 1; // no aiming
+const int TFL_AIM_SPLASH = 2; // aim for ground around the target's feet
+const int TFL_AIM_LEAD = 4; // try to predict target movement
+const int TFL_AIM_SHOTTIMECOMPENSATE = 8; // compensate for shot traveltime when leading
+const int TFL_AIM_ZPREDICT = 16; // predict target's z position at impact
+const int TFL_AIM_SIMPLE = 32; // aim at player's current location
+
+// tracking flags
+.int track_flags;
+const int TFL_TRACK_NO = 2; // don't move head
+const int TFL_TRACK_PITCH = 4; // pitch head
+const int TFL_TRACK_ROTATE = 8; // rotate head
+
+// prefire checks
+.int firecheck_flags;
+const int TFL_FIRECHECK_DEAD = 4; // don't attack dead targets (zombies?)
+const int TFL_FIRECHECK_DISTANCES = 8; // another range check
+const int TFL_FIRECHECK_LOS = 16; // line of sight
+const int TFL_FIRECHECK_AIMDIST = 32; // consider distance impactpoint<->aimspot
+const int TFL_FIRECHECK_REALDIST = 64; // consider enemy origin<->impactpoint
+const int TFL_FIRECHECK_ANGLEDIST = 128; // consider angular diff head<->aimspot
+const int TFL_FIRECHECK_TEAMCHECK = 256; // don't attack teammates
+const int TFL_FIRECHECK_AFF = 512; // try to avoid any friendly fire
+const int TFL_FIRECHECK_AMMO_OWN = 1024; // own ammo needs to be larger than damage dealt
+const int TFL_FIRECHECK_AMMO_OTHER = 2048; // target's ammo needs to be less than max
+const int TFL_FIRECHECK_REFIRE = 4096; // check single attack finished delays
+const int TFL_FIRECHECK_NO = 16384; // no prefire checks
+
+// attack flags
+.int shoot_flags;
+const int TFL_SHOOT_NO = 64; // no attacking
+const int TFL_SHOOT_VOLLY = 2; // fire in vollies
+const int TFL_SHOOT_VOLLYALWAYS = 4; // always do a full volly, even if target is lost
+const int TFL_SHOOT_HITALLVALID = 8; // loop through all valid targets
+const int TFL_SHOOT_CLEARTARGET = 16; // lose target after attack (after volly is done if in volly mode)
+const int TFL_SHOOT_CUSTOM = 32; // custom attacking
+
+// turret capabilities
+.int turret_flags;
+const int TUR_FLAG_NONE = 0; // no abilities
+const int TUR_FLAG_SNIPER = 2; // sniping turret
+const int TUR_FLAG_SPLASH = 4; // can deal splash damage
+const int TUR_FLAG_HITSCAN = 8; // hit scan
+const int TUR_FLAG_MULTIGUN = 16; // multiple guns
+const int TUR_FLAG_GUIDED = 32; // laser guided projectiles
+const int TUR_FLAG_SLOWPROJ = 64; // turret fires slow projectiles
+const int TUR_FLAG_MEDPROJ = 128; // turret fires medium projectiles
+const int TUR_FLAG_FASTPROJ = 256; // turret fires fast projectiles
+const int TUR_FLAG_PLAYER = 512; // can damage players
+const int TUR_FLAG_MISSILE = 1024; // can damage missiles
+const int TUR_FLAG_SUPPORT = 2048; // supports other units
+const int TUR_FLAG_AMMOSOURCE = 4096; // can provide ammunition
+const int TUR_FLAG_RECIEVETARGETS = 8192; // can recieve targets from external sources
+const int TUR_FLAG_MOVE = 16384; // can move
+const int TUR_FLAG_ROAM = 32768; // roams around if not attacking
+const int TUR_FLAG_ISTURRET = 65536; // identifies this unit as a turret
+
+// ammo types
+#define ammo_flags currentammo
+const int TFL_AMMO_NONE = 64; // doesn't use ammo
+const int TFL_AMMO_ENERGY = 2; // uses power
+const int TFL_AMMO_BULLETS = 4; // uses bullets
+const int TFL_AMMO_ROCKETS = 8; // uses explosives
+const int TFL_AMMO_RECHARGE = 16; // regenerates ammo
+const int TFL_AMMO_RECIEVE = 32; // can recieve ammo from support units
+
+// damage flags
+.int damage_flags;
+const int TFL_DMG_NO = 256; // doesn't take damage
+const int TFL_DMG_YES = 2; // can be damaged
+const int TFL_DMG_TEAM = 4; // can be damaged by teammates
+const int TFL_DMG_RETALIATE = 8; // target attackers
+const int TFL_DMG_RETALIATE_TEAM = 16; // target attackers, even if on same team
+const int TFL_DMG_TARGETLOSS = 32; // loses target when damaged
+const int TFL_DMG_AIMSHAKE = 64; // damage throws off aim
+const int TFL_DMG_HEADSHAKE = 128; // damage shakes head
+const int TFL_DMG_DEATH_NORESPAWN = 256; // no re-spawning
+
+// spawn flags
+const int TSF_SUSPENDED = 1;
+const int TSF_TERRAINBASE = 2; // currently unused
+const int TSF_NO_AMMO_REGEN = 4; // disable builtin ammo regeneration
+const int TSF_NO_PATHBREAK = 8; // don't break path to chase enemies, will still fire at them if possible
+const int TSL_NO_RESPAWN = 16; // don't re-spawn
+const int TSL_ROAM = 32; // roam while idle
+
+// send flags
+const int TNSF_UPDATE       = 2;
+const int TNSF_STATUS       = 4;
+const int TNSF_SETUP        = 8;
+const int TNSF_ANG          = 16;
+const int TNSF_AVEL         = 32;
+const int TNSF_MOVE         = 64;
+.float anim_start_time;
+const int TNSF_ANIM         = 128;
+
+const int TNSF_FULL_UPDATE  = 16777215;
+
+
+// other useful macros
+#define TUR_ACTION(turrettype,mrequest) (get_turretinfo(turrettype)).turret_func(mrequest)
+#define TUR_NAME(turrettype) (get_turretinfo(turrettype)).turret_name
+
+// =====================
+//  Turret Registration
+// =====================
+
+float t_null(float dummy);
+void register_turret(entity e, float(float) func, float turretflags, vector min_s, vector max_s, string modelname, string headmodelname, string shortname, string mname);
+
+const int TUR_MAXCOUNT = 24;
+entity turret_info[TUR_MAXCOUNT], turret_info_first, turret_info_last;
+float TUR_COUNT;
+
+#define _REGISTER_TURRET(id, func, turretflags, min_s, max_s, modelname, headmodelname, shortname, mname) \
+       float func(float); \
+       REGISTER(RegisterTurrets, TUR, turret_info, TUR_COUNT, id, m_id, NEW(Turret)) { \
+               register_turret(this, func,turretflags,min_s,max_s,modelname,headmodelname,shortname,mname); \
+       }
+void RegisterTurrets();
+REGISTER_REGISTRY(RegisterTurrets)
+
+#ifdef MENUQC
+#define REGISTER_TURRET(id,func,turretflags,min_s,max_s,modelname,headmodelname,shortname,mname) \
+       _REGISTER_TURRET(id,t_null,turretflags,min_s,max_s,modelname,headmodelname,shortname,mname)
+#else
+#define REGISTER_TURRET(id,func,turretflags,min_s,max_s,modelname,headmodelname,shortname,mname) \
+       _REGISTER_TURRET(id,func,turretflags,min_s,max_s,modelname,headmodelname,shortname,mname)
+#endif
+
+float t_null(float dummy) { return 0; }
+
+CLASS(Turret, Object)
+    ATTRIB(Turret, m_id, int, 0)
+
+    ATTRIB(Turret, turretid, int, 0)
+    /** short name */
+    ATTRIB(Turret, netname, string, string_null)
+    /** human readable name */
+    ATTRIB(Turret, turret_name, string, string_null)
+    /** t_... */
+    ATTRIB(Turret, turret_func, float(float), t_null)
+    /** currently a copy of the model */
+    ATTRIB(Turret, mdl, string, string_null)
+    /** full name of model */
+    ATTRIB(Turret, model, string, string_null)
+    /** full name of tur_head model */
+    ATTRIB(Turret, head_model, string, string_null)
+    /** TODO: deprecate! */
+    ATTRIB(Turret, cvar_basename, string, string_null)
+
+    ATTRIB(Turret, spawnflags, int, 0)
+    /** turret hitbox size */
+    ATTRIB(Turret, mins, vector, '0 0 0')
+    /** turret hitbox size */
+    ATTRIB(Turret, maxs, vector, '0 0 0')
+
+    METHOD(Turret, display, void(entity this, void(string name, string icon) returns)) {
+        returns(this.turret_name, string_null);
+    }
+
+void register_turret(Turret e, float(float) func, float turretflags, vector min_s, vector max_s, string modelname, string headmodelname, string shortname, string mname)
+{
+       e.classname = "turret_info";
+       e.turretid = e.m_id;
+       e.netname = shortname;
+       e.turret_name = mname;
+       e.turret_func = func;
+       e.mdl = modelname;
+       e.cvar_basename = shortname;
+       e.spawnflags = turretflags;
+       e.mins = min_s;
+       e.maxs = max_s;
+       e.model = strzone(strcat("models/turrets/", modelname));
+       e.head_model = strzone(strcat("models/turrets/", headmodelname));
+}
+ENDCLASS(Turret)
+
+
+REGISTER_TURRET(Null,
+       t_null,
+       0,
+       '-0 -0 -0',
+       '0 0 0',
+       "",
+       "",
+       "",
+       "Turret"
+);
+
+entity get_turretinfo(float id)
+{
+       entity m;
+       if(id < 1 || id > TUR_COUNT - 1)
+               return TUR_Null;
+       m = turret_info[id];
+       if(m)
+               return m;
+       return TUR_Null;
+}
+
+#include "all.inc"
+
+#endif
index 232f546c125e2ec8f117de95870e8651bb3fce7e..b2a0fe1b53bcc798b1421299487f63a619dbe835 100644 (file)
@@ -1,3 +1,5 @@
+#include "all.qh"
+
 void turret_remove()
 {SELFPARAM();
        remove(self.tur_head);
@@ -216,7 +218,7 @@ void turret_construct()
        setsize(self, tur.mins, tur.maxs);
        setsize(self.tur_head, '0 0 0', '0 0 0');
 
-       if(self.turretid == TUR_EWHEEL)
+       if(self.turretid == TUR_EWHEEL.m_id)
                setattachment(self.tur_head, self, "");
        else
                setattachment(self.tur_head, self, "tag_head");
@@ -272,7 +274,7 @@ void turret_gibboom()
 {SELFPARAM();
        float i;
 
-       sound (self, CH_SHOTS, W_Sound("rocket_impact"), VOL_BASE, ATTEN_NORM);
+       sound (self, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
        pointparticles(particleeffectnum(EFFECT_ROCKET_EXPLODE), self.origin, '0 0 0', 1);
 
        for (i = 1; i < 5; i = i + 1)
@@ -318,16 +320,16 @@ entity turret_gibtoss(string _model, vector _from, vector _to, vector _cmod, flo
 
 void turret_die()
 {SELFPARAM();
-       sound (self, CH_SHOTS, W_Sound("rocket_impact"), VOL_BASE, ATTEN_NORM);
+       sound (self, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
        pointparticles(particleeffectnum(EFFECT_ROCKET_EXPLODE), self.origin, '0 0 0', 1);
        if (!autocvar_cl_nogibs)
        {
                // Base
-               if(self.turretid == TUR_EWHEEL)
+               if(self.turretid == TUR_EWHEEL.m_id)
                        turret_gibtoss((get_turretinfo(self.turretid)).model, self.origin + '0 0 18', self.velocity + '0 0 400' + '0.1 0.1 1' * (random() * 400), '-1 -1 -1', true);
-               else if (self.turretid == TUR_WALKER)
+               else if (self.turretid == TUR_WALKER.m_id)
                        turret_gibtoss((get_turretinfo(self.turretid)).model, self.origin + '0 0 18', self.velocity + '0 0 300' + '0.1 0.1 1' * (random() * 200), '-1 -1 -1', true);
-               else if (self.turretid == TUR_TESLA)
+               else if (self.turretid == TUR_TESLA.m_id)
                        turret_gibtoss((get_turretinfo(self.turretid)).model, self.origin + '0 0 18', '0 0 200', '-1 -1 -1', false);
                else
                {
index 0f8ff9485117807a5f7e752a54b17eba6e3f3d42..f8ea64ad1151ce6bc873ca6a4feac7aba6a78d55 100644 (file)
@@ -1,6 +1,8 @@
 #ifndef CL_TURRETS_H
 #define CL_TURRETS_H
 
+#include "all.qh"
+
 void ent_turret();
 
 #endif
index f35448e9c2212dd98506391dbced0b0133658e6d..1a8c2cbe7705e4bf9bf3f037eb37aa8d48107b97 100644 (file)
@@ -27,9 +27,8 @@ float T_Config_Queue_Compare(float root, float child, entity pass)
 
 void Dump_Turret_Settings(void)
 {
-       float i, x, totalsettings = 0;
-       for(i = TUR_FIRST; i <= TUR_LAST; ++i)
-       {
+       float x, totalsettings = 0;
+       FOREACH(turret_info, it != TUR_Null, LAMBDA({
                // step 1: clear the queue
                TUR_CONFIG_COUNT = 0;
                for(x = 0; x <= MAX_TUR_CONFIG; ++x)
@@ -50,7 +49,7 @@ void Dump_Turret_Settings(void)
                // step 5: debug info
                LOG_INFO(sprintf("#%d: %s: %d settings...\n", i, TUR_NAME(i), TUR_CONFIG_COUNT));
                totalsettings += TUR_CONFIG_COUNT;
-       }
+       }));
 
        // clear queue now that we're finished
        TUR_CONFIG_COUNT = 0;
@@ -58,5 +57,5 @@ void Dump_Turret_Settings(void)
                { tur_config_queue[x] = string_null; }
 
        // extra information
-       LOG_INFO(sprintf("Totals: %d turrets, %d settings\n", (i - 1), totalsettings));
+       LOG_INFO(sprintf("Totals: %d turrets, %d settings\n", (TUR_COUNT - 1), totalsettings));
 }
index 9c02d7ad91ec28f57adbb5ecf96ebd1472b326cb..c17061b22f0211422b48619fc1da96849e0ff222 100644 (file)
@@ -1,4 +1,5 @@
 #ifdef SVQC
+#include "all.qh"
 #include "../../server/autocvars.qh"
 
 // Generic aiming
@@ -457,7 +458,7 @@ entity turret_projectile(string _snd, float _size, float _health, float _death,
 {SELFPARAM();
        entity proj;
 
-       sound (self, CH_WEAPON_A, _snd, VOL_BASE, ATTEN_NORM);
+       _sound (self, CH_WEAPON_A, _snd, VOL_BASE, ATTEN_NORM);
        proj                             = spawn ();
        setorigin(proj, self.tur_shotorg);
        setsize(proj, '-0.5 -0.5 -0.5' * _size, '0.5 0.5 0.5' * _size);
index 8bba1c4a4a6e39ff3fcd11596b3224ec5aace3a9..1a4ade6806b29e0a713fdb63bb0c0b2da2a6e9ce 100644 (file)
@@ -1,6 +1,8 @@
 #ifndef SV_TURRETS_H
 #define SV_TURRETS_H
 
+#include "all.qh"
+
 // turret fields
 .float ticrate; // interal ai think rate
 .vector aim_idle; // where to aim while idle
diff --git a/qcsrc/common/turrets/turrets.qc b/qcsrc/common/turrets/turrets.qc
deleted file mode 100644 (file)
index 37c85ca..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-#include "all.qh"
-
-// TURRET PLUGIN SYSTEM
-entity turret_info[TUR_MAXCOUNT];
-entity dummy_turret_info;
-
-void turrets_common_precache()
-{
-       precache_sound (W_Sound("rocket_impact"));
-
-#ifdef SVQC
-       precache_sound(W_Sound("rocket_impact"));
-#endif
-
-#ifdef TURRET_DEBUG
-       precache_model ("models/pathlib/goodsquare.md3");
-       precache_model ("models/pathlib/badsquare.md3");
-       precache_model ("models/pathlib/square.md3");
-       precache_model ("models/pathlib/edge.md3");
-#endif
-}
-
-void register_turret(float id, float(float) func, float turretflags, vector min_s, vector max_s, string modelname, string headmodelname, string shortname, string mname)
-{
-       entity e;
-       turret_info[id - 1] = e = spawn();
-       e.classname = "turret_info";
-       e.turretid = id;
-       e.netname = shortname;
-       e.turret_name = mname;
-       e.turret_func = func;
-       e.mdl = modelname;
-       e.cvar_basename = shortname;
-       e.spawnflags = turretflags;
-       e.mins = min_s;
-       e.maxs = max_s;
-       e.model = strzone(strcat("models/turrets/", modelname));
-       e.head_model = strzone(strcat("models/turrets/", headmodelname));
-
-       #ifndef MENUQC
-       turrets_common_precache();
-       #endif
-}
-float t_null(float dummy) { return 0; }
-void register_turrets_done()
-{
-       dummy_turret_info = spawn();
-       dummy_turret_info.classname = "turret_info";
-       dummy_turret_info.turretid = 0; // you can recognize dummies by this
-       dummy_turret_info.netname = "";
-       dummy_turret_info.turret_name = "Turret";
-       dummy_turret_info.turret_func = t_null;
-       dummy_turret_info.mdl = "";
-       dummy_turret_info.mins = '-0 -0 -0';
-       dummy_turret_info.maxs = '0 0 0';
-       dummy_turret_info.model = "";
-}
-entity get_turretinfo(float id)
-{
-       entity m;
-       if(id < TUR_FIRST || id > TUR_LAST)
-               return dummy_turret_info;
-       m = turret_info[id - 1];
-       if(m)
-               return m;
-       return dummy_turret_info;
-}
diff --git a/qcsrc/common/turrets/turrets.qh b/qcsrc/common/turrets/turrets.qh
deleted file mode 100644 (file)
index e1bf48c..0000000
+++ /dev/null
@@ -1,188 +0,0 @@
-#ifndef TURRETS_H
-#define TURRETS_H
-
-// turret requests
-#define TR_SETUP          1 // (BOTH) setup turret data
-#define TR_THINK                 2 // (SERVER) logic to run every frame
-#define TR_DEATH          3 // (SERVER) called when turret dies
-#define TR_PRECACHE       4 // (BOTH) precaches models/sounds used by this turret
-#define TR_ATTACK         5 // (SERVER) called when turret attacks
-#define TR_CONFIG         6 // (ALL)
-
-// functions:
-entity get_turretinfo(int id);
-
-// fields:
-.entity tur_head;
-
-// target selection flags
-.int target_select_flags;
-.int target_validate_flags;
-const int TFL_TARGETSELECT_NO = 2; // don't automatically find targets
-const int TFL_TARGETSELECT_LOS = 4; // require line of sight to find targets
-const int TFL_TARGETSELECT_PLAYERS = 8; // target players
-const int TFL_TARGETSELECT_MISSILES = 16; // target projectiles
-const int TFL_TARGETSELECT_TRIGGERTARGET = 32; // respond to turret_trigger_target events
-const int TFL_TARGETSELECT_ANGLELIMITS = 64; // apply extra angular limits to target selection
-const int TFL_TARGETSELECT_RANGELIMITS = 128; // limit target selection range
-const int TFL_TARGETSELECT_TEAMCHECK = 256; // don't attack teammates
-const int TFL_TARGETSELECT_NOBUILTIN = 512; // only attack targets when triggered
-const int TFL_TARGETSELECT_OWNTEAM = 1024; // only attack teammates
-const int TFL_TARGETSELECT_NOTURRETS = 2048; // don't attack other turrets
-const int TFL_TARGETSELECT_FOV = 4096; // extra limits to attack range
-const int TFL_TARGETSELECT_MISSILESONLY = 8192; // only attack missiles
-
-// aim flags
-.int aim_flags;
-const int TFL_AIM_NO = 1; // no aiming
-const int TFL_AIM_SPLASH = 2; // aim for ground around the target's feet
-const int TFL_AIM_LEAD = 4; // try to predict target movement
-const int TFL_AIM_SHOTTIMECOMPENSATE = 8; // compensate for shot traveltime when leading
-const int TFL_AIM_ZPREDICT = 16; // predict target's z position at impact
-const int TFL_AIM_SIMPLE = 32; // aim at player's current location
-
-// tracking flags
-.int track_flags;
-const int TFL_TRACK_NO = 2; // don't move head
-const int TFL_TRACK_PITCH = 4; // pitch head
-const int TFL_TRACK_ROTATE = 8; // rotate head
-
-// prefire checks
-.int firecheck_flags;
-const int TFL_FIRECHECK_DEAD = 4; // don't attack dead targets (zombies?)
-const int TFL_FIRECHECK_DISTANCES = 8; // another range check
-const int TFL_FIRECHECK_LOS = 16; // line of sight
-const int TFL_FIRECHECK_AIMDIST = 32; // consider distance impactpoint<->aimspot
-const int TFL_FIRECHECK_REALDIST = 64; // consider enemy origin<->impactpoint
-const int TFL_FIRECHECK_ANGLEDIST = 128; // consider angular diff head<->aimspot
-const int TFL_FIRECHECK_TEAMCHECK = 256; // don't attack teammates
-const int TFL_FIRECHECK_AFF = 512; // try to avoid any friendly fire
-const int TFL_FIRECHECK_AMMO_OWN = 1024; // own ammo needs to be larger than damage dealt
-const int TFL_FIRECHECK_AMMO_OTHER = 2048; // target's ammo needs to be less than max
-const int TFL_FIRECHECK_REFIRE = 4096; // check single attack finished delays
-const int TFL_FIRECHECK_NO = 16384; // no prefire checks
-
-// attack flags
-.int shoot_flags;
-const int TFL_SHOOT_NO = 64; // no attacking
-const int TFL_SHOOT_VOLLY = 2; // fire in vollies
-const int TFL_SHOOT_VOLLYALWAYS = 4; // always do a full volly, even if target is lost
-const int TFL_SHOOT_HITALLVALID = 8; // loop through all valid targets
-const int TFL_SHOOT_CLEARTARGET = 16; // lose target after attack (after volly is done if in volly mode)
-const int TFL_SHOOT_CUSTOM = 32; // custom attacking
-
-// turret capabilities
-.int turret_flags;
-const int TUR_FLAG_NONE = 0; // no abilities
-const int TUR_FLAG_SNIPER = 2; // sniping turret
-const int TUR_FLAG_SPLASH = 4; // can deal splash damage
-const int TUR_FLAG_HITSCAN = 8; // hit scan
-const int TUR_FLAG_MULTIGUN = 16; // multiple guns
-const int TUR_FLAG_GUIDED = 32; // laser guided projectiles
-const int TUR_FLAG_SLOWPROJ = 64; // turret fires slow projectiles
-const int TUR_FLAG_MEDPROJ = 128; // turret fires medium projectiles
-const int TUR_FLAG_FASTPROJ = 256; // turret fires fast projectiles
-const int TUR_FLAG_PLAYER = 512; // can damage players
-const int TUR_FLAG_MISSILE = 1024; // can damage missiles
-const int TUR_FLAG_SUPPORT = 2048; // supports other units
-const int TUR_FLAG_AMMOSOURCE = 4096; // can provide ammunition
-const int TUR_FLAG_RECIEVETARGETS = 8192; // can recieve targets from external sources
-const int TUR_FLAG_MOVE = 16384; // can move
-const int TUR_FLAG_ROAM = 32768; // roams around if not attacking
-const int TUR_FLAG_ISTURRET = 65536; // identifies this unit as a turret
-
-// ammo types
-#define ammo_flags currentammo
-const int TFL_AMMO_NONE = 64; // doesn't use ammo
-const int TFL_AMMO_ENERGY = 2; // uses power
-const int TFL_AMMO_BULLETS = 4; // uses bullets
-const int TFL_AMMO_ROCKETS = 8; // uses explosives
-const int TFL_AMMO_RECHARGE = 16; // regenerates ammo
-const int TFL_AMMO_RECIEVE = 32; // can recieve ammo from support units
-
-// damage flags
-.int damage_flags;
-const int TFL_DMG_NO = 256; // doesn't take damage
-const int TFL_DMG_YES = 2; // can be damaged
-const int TFL_DMG_TEAM = 4; // can be damaged by teammates
-const int TFL_DMG_RETALIATE = 8; // target attackers
-const int TFL_DMG_RETALIATE_TEAM = 16; // target attackers, even if on same team
-const int TFL_DMG_TARGETLOSS = 32; // loses target when damaged
-const int TFL_DMG_AIMSHAKE = 64; // damage throws off aim
-const int TFL_DMG_HEADSHAKE = 128; // damage shakes head
-const int TFL_DMG_DEATH_NORESPAWN = 256; // no re-spawning
-
-// spawn flags
-const int TSF_SUSPENDED = 1;
-const int TSF_TERRAINBASE = 2; // currently unused
-const int TSF_NO_AMMO_REGEN = 4; // disable builtin ammo regeneration
-const int TSF_NO_PATHBREAK = 8; // don't break path to chase enemies, will still fire at them if possible
-const int TSL_NO_RESPAWN = 16; // don't re-spawn
-const int TSL_ROAM = 32; // roam while idle
-
-// send flags
-const int TNSF_UPDATE       = 2;
-const int TNSF_STATUS       = 4;
-const int TNSF_SETUP        = 8;
-const int TNSF_ANG          = 16;
-const int TNSF_AVEL         = 32;
-const int TNSF_MOVE         = 64;
-.float anim_start_time;
-const int TNSF_ANIM         = 128;
-
-const int TNSF_FULL_UPDATE  = 16777215;
-
-
-// entity properties of turretinfo:
-.int turretid; // TUR_...
-.string netname; // short name
-.string turret_name; // human readable name
-.float(float) turret_func; // m_...
-.string mdl; // currently a copy of the model
-.string model; // full name of model
-.string head_model; // full name of tur_head model
-.string cvar_basename; // TODO: deprecate!
-.float spawnflags;
-.vector mins, maxs; // turret hitbox size
-
-// other useful macros
-#define TUR_ACTION(turrettype,mrequest) (get_turretinfo(turrettype)).turret_func(mrequest)
-#define TUR_NAME(turrettype) (get_turretinfo(turrettype)).turret_name
-
-// =====================
-//  Turret Registration
-// =====================
-
-float t_null(float dummy);
-void register_turret(float id, float(float) func, float turretflags, vector min_s, vector max_s, string modelname, string headmodelname, string shortname, string mname);
-void register_turrets_done();
-
-const float TUR_MAXCOUNT = 24;
-const int TUR_FIRST = 1;
-float TUR_COUNT;
-float TUR_LAST;
-
-#define REGISTER_TURRET_2(id,func,turretflags,min_s,max_s,modelname,headmodelname,shortname,mname) \
-       float id; \
-       float func(float); \
-       void RegisterTurrets_##id() \
-       { \
-               TUR_LAST = (id = TUR_FIRST + TUR_COUNT); \
-               ++TUR_COUNT; \
-               register_turret(id,func,turretflags,min_s,max_s,modelname,headmodelname,shortname,mname); \
-       } \
-       ACCUMULATE_FUNCTION(RegisterTurrets, RegisterTurrets_##id)
-#ifdef MENUQC
-#define REGISTER_TURRET(id,func,turretflags,min_s,max_s,modelname,headmodelname,shortname,mname) \
-       REGISTER_TURRET_2(TUR_##id,t_null,turretflags,min_s,max_s,modelname,headmodelname,shortname,mname)
-#else
-#define REGISTER_TURRET(id,func,turretflags,min_s,max_s,modelname,headmodelname,shortname,mname) \
-       REGISTER_TURRET_2(TUR_##id,func,turretflags,min_s,max_s,modelname,headmodelname,shortname,mname)
-#endif
-
-#include "all.qh"
-
-#undef REGISTER_TURRET
-ACCUMULATE_FUNCTION(RegisterTurrets, register_turrets_done)
-
-#endif
index e61897cdd8d876d0841076d7443fa782e5518b7e..cd111b258e6851a2d2b5450dd6ed396b7b7d98c8 100644 (file)
@@ -1,4 +1,4 @@
-#ifdef REGISTER_TURRET
+#ifndef IMPLEMENTATION
 REGISTER_TURRET(
 /* TUR_##id   */ EWHEEL,
 /* function   */ t_ewheel,
@@ -121,7 +121,7 @@ void ewheel_move_idle()
         movelib_beak_simple((autocvar_g_turrets_unit_ewheel_speed_stop));
 }
 
-void spawnfunc_turret_ewheel() { SELFPARAM(); if(!turret_initialize(TUR_EWHEEL)) remove(self); }
+void spawnfunc_turret_ewheel() { SELFPARAM(); if(!turret_initialize(TUR_EWHEEL.m_id)) remove(self); }
 
 float t_ewheel(float req)
 {SELFPARAM();
@@ -136,7 +136,7 @@ float t_ewheel(float req)
             {
                 turret_do_updates(self);
 
-                _mis = turret_projectile(W_Sound("lasergun_fire"), 1, 0, DEATH_TURRET_EWHEEL, PROJECTILE_BLASTER, TRUE, TRUE);
+                _mis = turret_projectile(SND(LASERGUN_FIRE), 1, 0, DEATH_TURRET_EWHEEL, PROJECTILE_BLASTER, TRUE, TRUE);
                 _mis.missile_flags = MIF_SPLASH;
 
                 Send_Effect(EFFECT_BLASTER_MUZZLEFLASH, self.tur_shotorg, self.tur_shotdir_updated * 1000, 1);
index 228049f4114bd6551aec8fdf1fb4073926a0c126..e19116067ee037cb4d12aff94ec2c9f982095fe2 100644 (file)
@@ -1,4 +1,4 @@
-#ifdef REGISTER_TURRET
+#ifndef IMPLEMENTATION
 REGISTER_TURRET(
 /* TUR_##id   */ FLAC,
 /* function   */ t_flac,
@@ -28,7 +28,7 @@ void turret_flac_projectile_think_explode()
     remove(self);
 }
 
-void spawnfunc_turret_flac() { SELFPARAM(); if(!turret_initialize(TUR_FLAC)) remove(self); }
+void spawnfunc_turret_flac() { SELFPARAM(); if(!turret_initialize(TUR_FLAC.m_id)) remove(self); }
 
 float t_flac(float req)
 {SELFPARAM();
@@ -40,7 +40,7 @@ float t_flac(float req)
 
             turret_tag_fire_update();
 
-            proj = turret_projectile(W_Sound("hagar_fire"), 5, 0, DEATH_TURRET_FLAC, PROJECTILE_HAGAR, TRUE, TRUE);
+            proj = turret_projectile(SND(HAGAR_FIRE), 5, 0, DEATH_TURRET_FLAC, PROJECTILE_HAGAR, TRUE, TRUE);
             Send_Effect(EFFECT_BLASTER_MUZZLEFLASH, self.tur_shotorg, self.tur_shotdir_updated * 1000, 1);
             proj.think   = turret_flac_projectile_think_explode;
             proj.nextthink  = time + self.tur_impacttime + (random() * 0.01 - random() * 0.01);
index 3ba1ff07476a9e03e568f395eeb7561b5bfbdc88..5a8df2aad16a20e40e1a0177cf91ca599f26aa26 100644 (file)
@@ -1,4 +1,4 @@
-#ifdef REGISTER_TURRET
+#ifndef IMPLEMENTATION
 REGISTER_TURRET(
 /* TUR_##id   */ FUSIONREACTOR,
 /* function   */ t_fusionreactor,
@@ -40,7 +40,7 @@ bool turret_fusionreactor_firecheck()
     return true;
 }
 
-void spawnfunc_turret_fusionreactor() { SELFPARAM(); if(!turret_initialize(TUR_FUSIONREACTOR)) remove(self); }
+void spawnfunc_turret_fusionreactor() { SELFPARAM(); if(!turret_initialize(TUR_FUSIONREACTOR.m_id)) remove(self); }
 
 float t_fusionreactor(float req)
 {SELFPARAM();
index f785f4e953e8c9121844dba663a5b88f68a40e76..56f5da90a3d70b72d9e407c2923c72f6f84aa792 100644 (file)
@@ -1,4 +1,4 @@
-#ifdef REGISTER_TURRET
+#ifndef IMPLEMENTATION
 REGISTER_TURRET(
 /* TUR_##id   */ HELLION,
 /* function   */ t_hellion,
@@ -76,7 +76,7 @@ void turret_hellion_missile_think()
     UpdateCSQCProjectile(self);
 }
 
-void spawnfunc_turret_hellion() { SELFPARAM(); if(!turret_initialize(TUR_HELLION)) remove(self); }
+void spawnfunc_turret_hellion() { SELFPARAM(); if(!turret_initialize(TUR_HELLION.m_id)) remove(self); }
 
 float t_hellion(float req)
 {SELFPARAM();
@@ -91,7 +91,7 @@ float t_hellion(float req)
             else
                 self.tur_shotorg = gettaginfo(self.tur_head, gettagindex(self.tur_head, "tag_fire2"));
 
-            missile = turret_projectile(W_Sound("rocket_fire"), 6, 10, DEATH_TURRET_HELLION, PROJECTILE_ROCKET, FALSE, FALSE);
+            missile = turret_projectile(SND(ROCKET_FIRE), 6, 10, DEATH_TURRET_HELLION, PROJECTILE_ROCKET, FALSE, FALSE);
             te_explosion (missile.origin);
             missile.think              = turret_hellion_missile_think;
             missile.nextthink  = time;
index f01275187db0ab496065187ff155d4713b38fd32..106c982ae8cfa8d8b5d2832f9891740cf086241f 100644 (file)
@@ -1,4 +1,4 @@
-#ifdef REGISTER_TURRET
+#ifndef IMPLEMENTATION
 REGISTER_TURRET(
 /* TUR_##id   */ HK,
 /* function   */ t_hk,
@@ -273,7 +273,7 @@ float turret_hk_addtarget(entity e_target,entity e_sender)
     return 0;
 }
 
-void spawnfunc_turret_hk() { SELFPARAM(); if(!turret_initialize(TUR_HK)) remove(self); }
+void spawnfunc_turret_hk() { SELFPARAM(); if(!turret_initialize(TUR_HK.m_id)) remove(self); }
 
 float t_hk(float req)
 {SELFPARAM();
@@ -283,7 +283,7 @@ float t_hk(float req)
         {
             entity missile;
 
-            missile = turret_projectile(W_Sound("rocket_fire"), 6, 10, DEATH_TURRET_HK, PROJECTILE_ROCKET, FALSE, FALSE);
+            missile = turret_projectile(SND(ROCKET_FIRE), 6, 10, DEATH_TURRET_HK, PROJECTILE_ROCKET, FALSE, FALSE);
             te_explosion (missile.origin);
 
             missile.think                      = turret_hk_missile_think;
index afecb7fa56a377d33f49c9df7ea03e8a799f702c..35f1921edae621cca8681943bb5d8c80fdd73651 100644 (file)
@@ -1,4 +1,4 @@
-#ifdef REGISTER_TURRET
+#ifndef IMPLEMENTATION
 REGISTER_TURRET(
 /* TUR_##id   */ MACHINEGUN,
 /* function   */ t_machinegun,
@@ -11,7 +11,7 @@ REGISTER_TURRET(
 );
 #else
 #ifdef SVQC
-void spawnfunc_turret_machinegun() { SELFPARAM(); if(!turret_initialize(TUR_MACHINEGUN)) remove(self); }
+void spawnfunc_turret_machinegun() { SELFPARAM(); if(!turret_initialize(TUR_MACHINEGUN.m_id)) remove(self); }
 
 void W_MachineGun_MuzzleFlash(void);
 
@@ -48,7 +48,6 @@ float t_machinegun(float req)
         }
         case TR_PRECACHE:
         {
-            precache_sound (W_Sound("uzi_fire"));
             return true;
         }
     }
index 1a3c9220b84ca48b6fb75d0c9c986901a73955d4..21e0a435d7a951619029d085a63d12fc113196a7 100644 (file)
@@ -1,4 +1,4 @@
-#ifdef REGISTER_TURRET
+#ifndef IMPLEMENTATION
 REGISTER_TURRET(
 /* TUR_##id   */ MLRS,
 /* function   */ t_mlrs,
@@ -11,7 +11,7 @@ REGISTER_TURRET(
 );
 #else
 #ifdef SVQC
-void spawnfunc_turret_mlrs() { SELFPARAM(); if(!turret_initialize(TUR_MLRS)) remove(self); }
+void spawnfunc_turret_mlrs() { SELFPARAM(); if(!turret_initialize(TUR_MLRS.m_id)) remove(self); }
 
 float t_mlrs(float req)
 {SELFPARAM();
@@ -22,7 +22,7 @@ float t_mlrs(float req)
             entity missile;
 
             turret_tag_fire_update();
-            missile = turret_projectile(W_Sound("rocket_fire"), 6, 10, DEATH_TURRET_MLRS, PROJECTILE_ROCKET, TRUE, TRUE);
+            missile = turret_projectile(SND(ROCKET_FIRE), 6, 10, DEATH_TURRET_MLRS, PROJECTILE_ROCKET, TRUE, TRUE);
             missile.nextthink = time + max(self.tur_impacttime,(self.shot_radius * 2) / self.shot_speed);
             missile.missile_flags = MIF_SPLASH;
             te_explosion (missile.origin);
index e1ddef3a9d359292e2e0ff09508e3b1e04681070..04e226448405b58acfa9786be112c38918887616 100644 (file)
@@ -1,4 +1,4 @@
-#ifdef REGISTER_TURRET
+#ifndef IMPLEMENTATION
 REGISTER_TURRET(
 /* TUR_##id   */ PHASER,
 /* function   */ t_phaser,
@@ -26,7 +26,7 @@ void beam_think()
         self.owner.attack_finished_single = time + self.owner.shot_refire;
         self.owner.fireflag = 2;
         self.owner.tur_head.frame = 10;
-        sound (self, CH_SHOTS_SINGLE, "misc/null.wav", VOL_BASE, ATTEN_NORM);
+        sound (self, CH_SHOTS_SINGLE, SND_Null, VOL_BASE, ATTEN_NORM);
         remove(self);
         return;
     }
@@ -36,7 +36,7 @@ void beam_think()
     if (time - self.shot_spread > 0)
     {
         self.shot_spread = time + 2;
-        sound (self, CH_SHOTS_SINGLE, "turrets/phaser.wav", VOL_BASE, ATTEN_NORM);
+        sound (self, CH_SHOTS_SINGLE, SND_TUR_PHASER, VOL_BASE, ATTEN_NORM);
     }
 
 
@@ -57,7 +57,7 @@ void beam_think()
 
 }
 
-void spawnfunc_turret_phaser() { SELFPARAM(); if(!turret_initialize(TUR_PHASER)) remove(self); }
+void spawnfunc_turret_phaser() { SELFPARAM(); if(!turret_initialize(TUR_PHASER.m_id)) remove(self); }
 
 float t_phaser(float req)
 {SELFPARAM();
@@ -83,7 +83,7 @@ float t_phaser(float req)
             beam.enemy = self.enemy;
             beam.bot_dodge = true;
             beam.bot_dodgerating = beam.shot_dmg;
-            sound (beam, CH_SHOTS_SINGLE, "turrets/phaser.wav", VOL_BASE, ATTEN_NORM);
+            sound (beam, CH_SHOTS_SINGLE, SND_TUR_PHASER, VOL_BASE, ATTEN_NORM);
             self.fireflag = 1;
 
             beam.attack_finished_single = self.attack_finished_single;
@@ -91,7 +91,7 @@ float t_phaser(float req)
 
             setattachment(beam,self.tur_head,"tag_fire");
 
-            soundat (self, trace_endpos, CH_SHOTS, W_Sound("neximpact"), VOL_BASE, ATTEN_NORM);
+            soundat (self, trace_endpos, CH_SHOTS, SND(NEXIMPACT), VOL_BASE, ATTEN_NORM);
 
             if (self.tur_head.frame == 0)
                 self.tur_head.frame = 1;
@@ -137,7 +137,6 @@ float t_phaser(float req)
         }
         case TR_PRECACHE:
         {
-            precache_sound ("turrets/phaser.wav");
             return true;
         }
     }
index df986d79e04b8bd1ffab31babf101ad596f2abdb..baafa51c66b5c1a596f68c9d0337121a75a1d073 100644 (file)
@@ -1,4 +1,4 @@
-#ifdef REGISTER_TURRET
+#ifndef IMPLEMENTATION
 REGISTER_TURRET(
 /* TUR_##id   */ PLASMA,
 /* function   */ t_plasma,
@@ -11,7 +11,7 @@ REGISTER_TURRET(
 );
 #else
 #ifdef SVQC
-void spawnfunc_turret_plasma() { SELFPARAM(); if(!turret_initialize(TUR_PLASMA)) remove(self); }
+void spawnfunc_turret_plasma() { SELFPARAM(); if(!turret_initialize(TUR_PLASMA.m_id)) remove(self); }
 
 float t_plasma(float req)
 {SELFPARAM();
@@ -30,19 +30,14 @@ float t_plasma(float req)
                 Send_Effect(EFFECT_VORTEX_MUZZLEFLASH, self.tur_shotorg, self.tur_shotdir_updated * 1000, 1);
 
                 // teamcolor / hit beam effect
-                vector v;
-                string s;
-                v = WarpZone_UnTransformOrigin(WarpZone_trace_transform, trace_endpos);
-                s = strcat("TE_TEI_G3", ((self.team) ? Static_Team_ColorName_Upper(self.team) : ""));
-
-                WarpZone_TrailParticles(world, _particleeffectnum(s), self.tur_shotorg, v);
-
+                vector v = WarpZone_UnTransformOrigin(WarpZone_trace_transform, trace_endpos);
+                WarpZone_TrailParticles(world, particleeffectnum(EFFECT_VAPORIZER(self.team)), self.tur_shotorg, v);
                 if (self.tur_head.frame == 0)
                     self.tur_head.frame = 1;
             }
             else
             {
-                entity missile = turret_projectile(W_Sound("hagar_fire"), 1, 0, DEATH_TURRET_PLASMA, PROJECTILE_ELECTRO_BEAM, TRUE, TRUE);
+                entity missile = turret_projectile(SND(HAGAR_FIRE), 1, 0, DEATH_TURRET_PLASMA, PROJECTILE_ELECTRO_BEAM, TRUE, TRUE);
                 missile.missile_flags = MIF_SPLASH;
 
                 Send_Effect(EFFECT_BLASTER_MUZZLEFLASH, self.tur_shotorg, self.tur_shotdir_updated * 1000, 1);
index f3bd32448f40538a94fc72243b95c118453e4aeb..bf3362ab897593149faff730c372e3b6653fff9f 100644 (file)
@@ -1,4 +1,4 @@
-#ifdef REGISTER_TURRET
+#ifndef IMPLEMENTATION
 REGISTER_TURRET(
 /* TUR_##id   */ PLASMA_DUAL,
 /* function   */ t_plasma_dual,
@@ -11,7 +11,7 @@ REGISTER_TURRET(
 );
 #else
 #ifdef SVQC
-void spawnfunc_turret_plasma_dual() { SELFPARAM(); if(!turret_initialize(TUR_PLASMA_DUAL)) remove(self); }
+void spawnfunc_turret_plasma_dual() { SELFPARAM(); if(!turret_initialize(TUR_PLASMA_DUAL.m_id)) remove(self); }
 
 float t_plasma_dual(float req)
 {SELFPARAM();
@@ -31,18 +31,13 @@ float t_plasma_dual(float req)
                 Send_Effect(EFFECT_VORTEX_MUZZLEFLASH, self.tur_shotorg, self.tur_shotdir_updated * 1000, 1);
 
                 // teamcolor / hit beam effect
-                vector v;
-                string s;
-                v = WarpZone_UnTransformOrigin(WarpZone_trace_transform, trace_endpos);
-                s = strcat(EFFECT_VAPORIZER_NEUTRAL.eent_eff_name, ((self.team) ? Static_Team_ColorName_Upper(self.team) : ""));
-
-                WarpZone_TrailParticles(world, _particleeffectnum(s), self.tur_shotorg, v);
-
+                vector v = WarpZone_UnTransformOrigin(WarpZone_trace_transform, trace_endpos);
+                WarpZone_TrailParticles(world, particleeffectnum(EFFECT_VAPORIZER(self.team)), self.tur_shotorg, v);
                 self.tur_head.frame += 1;
             }
             else
             {
-                entity missile = turret_projectile(W_Sound("hagar_fire"), 1, 0, DEATH_TURRET_PLASMA, PROJECTILE_ELECTRO_BEAM, TRUE, TRUE);
+                entity missile = turret_projectile(SND(HAGAR_FIRE), 1, 0, DEATH_TURRET_PLASMA, PROJECTILE_ELECTRO_BEAM, TRUE, TRUE);
                 missile.missile_flags = MIF_SPLASH;
                 Send_Effect(EFFECT_BLASTER_MUZZLEFLASH, self.tur_shotorg, self.tur_shotdir_updated * 1000, 1);
                 self.tur_head.frame += 1;
index 50e37182c3a6ce0a143b6fc8975bd2f89a9fce84..d3c894b96edfe548bbbd2f1b9c9ac8c4d8641267 100644 (file)
@@ -1,4 +1,4 @@
-#ifdef REGISTER_TURRET
+#ifndef IMPLEMENTATION
 REGISTER_TURRET(
 /* TUR_##id   */ TESLA,
 /* function   */ t_tesla,
@@ -89,7 +89,7 @@ float turret_tesla_firecheck()
     return 0;
 }
 
-void spawnfunc_turret_tesla() { SELFPARAM(); if(!turret_initialize(TUR_TESLA)) remove(self); }
+void spawnfunc_turret_tesla() { SELFPARAM(); if(!turret_initialize(TUR_TESLA.m_id)) remove(self); }
 
 float t_tesla(float req)
 {SELFPARAM();
index 9e7b0cbe136255a0fd4a9a86c8a24d2db8165732..792e7a338d0b080a16d4dcb4a1d0a7f69d936f4f 100644 (file)
@@ -1,4 +1,4 @@
-#ifdef REGISTER_TURRET
+#ifndef IMPLEMENTATION
 REGISTER_TURRET(
 /* TUR_##id   */ WALKER,
 /* function   */ t_walker,
@@ -221,7 +221,7 @@ void walker_fire_rocket(vector org)
     rocket = spawn ();
     setorigin(rocket, org);
 
-    sound (self, CH_WEAPON_A, W_Sound("hagar_fire"), VOL_BASE, ATTEN_NORM);
+    sound (self, CH_WEAPON_A, SND_HAGAR_FIRE, VOL_BASE, ATTEN_NORM);
     setsize (rocket, '-3 -3 -3', '3 3 3'); // give it some size so it can be shot
 
     rocket.classname             = "walker_rocket";
@@ -334,7 +334,7 @@ void walker_move_path()
 #endif
 }
 
-void spawnfunc_turret_walker() { SELFPARAM(); if(!turret_initialize(TUR_WALKER)) remove(self); }
+void spawnfunc_turret_walker() { SELFPARAM(); if(!turret_initialize(TUR_WALKER.m_id)) remove(self); }
 
 float t_walker(float req)
 {SELFPARAM();
@@ -342,7 +342,7 @@ float t_walker(float req)
     {
         case TR_ATTACK:
         {
-            sound (self, CH_WEAPON_A, W_Sound("uzi_fire"), VOL_BASE, ATTEN_NORM);
+            sound (self, CH_WEAPON_A, SND_UZI_FIRE, VOL_BASE, ATTEN_NORM);
             fireBullet (self.tur_shotorg, self.tur_shotdir_updated, self.shot_spread, 0, self.shot_dmg, self.shot_force, DEATH_TURRET_WALK_GUN, 0);
             Send_Effect(EFFECT_BLASTER_MUZZLEFLASH, self.tur_shotorg, self.tur_shotdir_updated * 1000, 1);
 
@@ -634,7 +634,6 @@ float t_walker(float req)
         }
         case TR_PRECACHE:
         {
-            precache_sound (W_Sound("rocket_impact"));
             return true;
         }
     }
@@ -645,7 +644,7 @@ float t_walker(float req)
 #endif // SVQC
 #ifdef CSQC
 
-#include "../../../server/movelib.qh"
+#include "../../../client/movelib.qh"
 
 void walker_draw()
 {SELFPARAM();
index a054edde8a56748c5d10fcd4e8d5640ce4882a5a..a506a59fcd2808ac26419691fe3c1b5ca7f90b17 100644 (file)
@@ -271,15 +271,6 @@ string fstrunzone(string s)
        return sc;
 }
 
-bool fexists(string f)
-{
-    int fh = fopen(f, FILE_READ);
-    if (fh < 0)
-        return false;
-    fclose(fh);
-    return true;
-}
-
 // Databases (hash tables)
 const float DB_BUCKETS = 8192;
 void db_save(float db, string pFilename)
index e3fab47b7da6d9961c982b9eda081f71a6bbde7f..d43136c6734d23842a08ab570d926edfa67b1d76 100644 (file)
@@ -230,10 +230,6 @@ const float XENCODE_LEN = 5;
 string xencode(float f);
 float xdecode(string s);
 
-// Play all sounds via sound7, for access to the extra channels.
-// Otherwise, channels 8 to 15 would be blocked for a weird QW feature.
-#define sound(e,c,s,v,a) sound7(e,c,s,v,a,0,0)
-
 int lowestbit(float f);
 
 #ifdef CSQC
index 3f3b77ea3308c80749042021a1ba5a5389e6e8fa..6e26f171264eb1c1f1fda5ae170604e1b86ad98e 100644 (file)
 #ifndef MENUQC
 STATIC_INIT(vehicles_common_initialize)
 {
-#ifdef CSQC
-       precache_sound ("vehicles/alarm.wav");
-       precache_sound ("vehicles/alarm_shield.wav");
-#endif // CSQC
 #ifdef SVQC
-       precache_sound("onslaught/ons_hit2.wav");
-       precache_sound("onslaught/electricity_explode.wav");
-
        addstat(STAT_HUD, AS_INT, hud);
        addstat(STAT_VEHICLESTAT_HEALTH,  AS_INT, vehicle_health);
        addstat(STAT_VEHICLESTAT_SHIELD,  AS_INT, vehicle_shield);
index b6c8844abd8028920814b047c0b3b62202fa7326..a91e3e212abcac3e162aeb2d901200297003e7f3 100644 (file)
@@ -23,7 +23,7 @@ void vehicle_alarm(entity e, int ch, string s0und)
        if(!autocvar_cl_vehicles_alarm)
                return;
 
-       sound(e, ch, s0und, VOL_BASEVOICE, ATTEN_NONE);
+       _sound(e, ch, s0und, VOL_BASEVOICE, ATTEN_NONE);
 }
 
 void AuxiliaryXhair_Draw2D()
@@ -79,8 +79,8 @@ void Net_VehicleSetup()
        // hud_id == 0 means we exited a vehicle, so stop alarm sound/s
        if(hud_id == 0)
        {
-               sound(self, CH_TRIGGER_SINGLE, "misc/null.wav", VOL_BASEVOICE, ATTEN_NONE);
-               sound(self, CH_PAIN_SINGLE, "misc/null.wav", VOL_BASEVOICE, ATTEN_NONE);
+               sound(self, CH_TRIGGER_SINGLE, SND_Null, VOL_BASEVOICE, ATTEN_NONE);
+               sound(self, CH_PAIN_SINGLE, SND_Null, VOL_BASEVOICE, ATTEN_NONE);
                return;
        }
 
@@ -235,7 +235,7 @@ void Vehicles_drawHUD(
                if(alarm1time < time)
                {
                        alarm1time = time + 2;
-                       vehicle_alarm(self, CH_PAIN_SINGLE, "vehicles/alarm.wav");
+                       vehicle_alarm(self, CH_PAIN_SINGLE, SND(VEH_ALARM));
                }
                drawpic_skin(tmpPos, "vehicle_icon_health", tmpSize, '1 1 1', hudAlpha * blinkValue, DRAWFLAG_NORMAL);
        }
@@ -243,7 +243,7 @@ void Vehicles_drawHUD(
        {
                if(alarm1time)
                {
-                       vehicle_alarm(self, CH_PAIN_SINGLE, "misc/null.wav");
+                       vehicle_alarm(self, CH_PAIN_SINGLE, SND(Null));
                        alarm1time = 0;
                }
                drawpic_skin(tmpPos, "vehicle_icon_health", tmpSize, '1 1 1', hudAlpha, DRAWFLAG_NORMAL);
@@ -257,7 +257,7 @@ void Vehicles_drawHUD(
                if(alarm2time < time)
                {
                        alarm2time = time + 1;
-                       vehicle_alarm(self, CH_TRIGGER_SINGLE, "vehicles/alarm_shield.wav");
+                       vehicle_alarm(self, CH_TRIGGER_SINGLE, SND(VEH_ALARM_SHIELD));
                }
                drawpic_skin(tmpPos, "vehicle_icon_shield", tmpSize, '1 1 1', hudAlpha * blinkValue, DRAWFLAG_NORMAL);
        }
@@ -265,7 +265,7 @@ void Vehicles_drawHUD(
        {
                if(alarm2time)
                {
-                       vehicle_alarm(self, CH_TRIGGER_SINGLE, "misc/null.wav");
+                       vehicle_alarm(self, CH_TRIGGER_SINGLE, SND(Null));
                        alarm2time = 0;
                }
                drawpic_skin(tmpPos, "vehicle_icon_shield", tmpSize, '1 1 1', hudAlpha, DRAWFLAG_NORMAL);
index 73ff86b4bef3d04c253ec25ad3ea92b37bbe8e12..8f2f7581a215c4c8cb2264dffecfd9cfe355589f 100644 (file)
@@ -289,7 +289,7 @@ entity vehicles_projectile(string _mzlfx, string _mzlsound,
                proj.flags                 = FL_PROJECTILE | FL_NOTARGET;
 
        if(_mzlsound)
-               sound (self, CH_WEAPON_A, _mzlsound, VOL_BASE, ATTEN_NORM);
+               _sound (self, CH_WEAPON_A, _mzlsound, VOL_BASE, ATTEN_NORM);
 
        if(_mzlfx)
                Send_Effect_(_mzlfx, proj.origin, proj.velocity, 1);
@@ -303,7 +303,7 @@ entity vehicles_projectile(string _mzlfx, string _mzlsound,
 
 void vehicles_gib_explode()
 {SELFPARAM();
-       sound (self, CH_SHOTS, W_Sound("rocket_impact"), VOL_BASE, ATTEN_NORM);
+       sound (self, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
        Send_Effect(EFFECT_EXPLOSION_SMALL, randomvec() * 80 + (self.origin + '0 0 100'), '0 0 0', 1);
        Send_Effect(EFFECT_EXPLOSION_SMALL, self.wp00.origin + '0 0 64', '0 0 0', 1);
        remove(self);
@@ -907,7 +907,7 @@ void vehicles_exit(bool eject)
 
        _vehicle.team = _vehicle.tur_head.team;
 
-       sound (_vehicle, CH_TRIGGER_SINGLE, "misc/null.wav", 1, ATTEN_NORM);
+       sound (_vehicle, CH_TRIGGER_SINGLE, SND_Null, 1, ATTEN_NORM);
        _vehicle.vehicle_hudmodel.viewmodelforclient = _vehicle;
        _vehicle.phase = time + 1;
 
index 96fef6c05c2cafb02f25be443b6803c84e95fbac..6f8a2bf8f5e7bf56c357aef6b805ba5c043fd523 100644 (file)
@@ -104,7 +104,7 @@ float bumble_raygun_send(entity to, int sf);
 void bumblebee_fire_cannon(entity _gun, string _tagname, entity _owner)
 {
        vector v = gettaginfo(_gun, gettagindex(_gun, _tagname));
-       vehicles_projectile(EFFECT_BIGPLASMA_MUZZLEFLASH.eent_eff_name, W_Sound("flacexp3"),
+       vehicles_projectile(EFFECT_BIGPLASMA_MUZZLEFLASH.eent_eff_name, SND(VEH_BUMBLEBEE_FIRE),
                                                v, normalize(v_forward + randomvec() * autocvar_g_vehicle_bumblebee_cannon_spread) * autocvar_g_vehicle_bumblebee_cannon_speed,
                                                autocvar_g_vehicle_bumblebee_cannon_damage, autocvar_g_vehicle_bumblebee_cannon_radius, autocvar_g_vehicle_bumblebee_cannon_force,  0,
                                                DEATH_VH_BUMB_GUN, PROJECTILE_BUMBLE_GUN, 0, true, true, _owner);
@@ -716,7 +716,7 @@ void bumblebee_blowup()
                                 autocvar_g_vehicle_bumblebee_blowup_forceintensity,
                                 DEATH_VH_BUMB_DEATH, world);
 
-       sound(self, CH_SHOTS, W_Sound("rocket_impact"), VOL_BASE, ATTEN_NORM);
+       sound(self, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
        Send_Effect(EFFECT_EXPLOSION_BIG, (self.origin + '0 0 100') + (randomvec() * 80), '0 0 0', 1);
 
        if(self.owner.deadflag == DEAD_DYING)
@@ -732,7 +732,7 @@ void bumblebee_diethink()
 
        if(random() < 0.1)
        {
-               sound(self, CH_SHOTS, W_Sound("rocket_impact"), VOL_BASE, ATTEN_NORM);
+               sound(self, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
                Send_Effect(EFFECT_EXPLOSION_SMALL, randomvec() * 80 + (self.origin + '0 0 100'), '0 0 0', 1);
        }
 
index 62a6e850fdb2c4bcc1c2b7f5bb029b39d6451889..a1dc7ced65c78c9a69637ad6702bc66dd8dc9456 100644 (file)
@@ -174,7 +174,7 @@ void racer_fire_cannon(string tagname)
        entity bolt;
 
        v = gettaginfo(self, gettagindex(self, tagname));
-       bolt = vehicles_projectile(EFFECT_RACER_MUZZLEFLASH.eent_eff_name, W_Sound("lasergun_fire"),
+       bolt = vehicles_projectile(EFFECT_RACER_MUZZLEFLASH.eent_eff_name, SND(LASERGUN_FIRE),
                                                   v, normalize(v_forward + randomvec() * autocvar_g_vehicle_racer_cannon_spread) * autocvar_g_vehicle_racer_cannon_speed,
                                                   autocvar_g_vehicle_racer_cannon_damage, autocvar_g_vehicle_racer_cannon_radius, autocvar_g_vehicle_racer_cannon_force,  0,
                                                   DEATH_VH_WAKI_GUN, PROJECTILE_WAKICANNON, 0, true, true, self.owner);
@@ -292,7 +292,7 @@ void racer_rocket_tracker()
 void racer_fire_rocket(string tagname, entity trg)
 {SELFPARAM();
        vector v = gettaginfo(self, gettagindex(self, tagname));
-       entity rocket = vehicles_projectile(EFFECT_RACER_ROCKETLAUNCH.eent_eff_name, W_Sound("rocket_fire"),
+       entity rocket = vehicles_projectile(EFFECT_RACER_ROCKETLAUNCH.eent_eff_name, SND(ROCKET_FIRE),
                                                   v, v_forward * autocvar_g_vehicle_racer_rocket_speed,
                                                   autocvar_g_vehicle_racer_rocket_damage, autocvar_g_vehicle_racer_rocket_radius, autocvar_g_vehicle_racer_rocket_force, 3,
                                                   DEATH_VH_WAKI_ROCKET, PROJECTILE_WAKIROCKET, 20, false, false, self.owner);
@@ -385,7 +385,7 @@ float racer_frame()
                {
                        self.sounds = 1;
                        self.sound_nexttime = time + 10.922667; //soundlength("vehicles/racer_move.wav");
-                       sound (self, CH_TRIGGER_SINGLE, "vehicles/racer_move.wav", VOL_VEHICLEENGINE, ATTEN_NORM);
+                       sound (self, CH_TRIGGER_SINGLE, SND_VEH_RACER_MOVE, VOL_VEHICLEENGINE, ATTEN_NORM);
                }
 #endif
        }
@@ -396,7 +396,7 @@ float racer_frame()
                {
                        self.sounds = 0;
                        self.sound_nexttime = time + 11.888604; //soundlength("vehicles/racer_idle.wav");
-                       sound (self, CH_TRIGGER_SINGLE, "vehicles/racer_idle.wav", VOL_VEHICLEENGINE, ATTEN_NORM);
+                       sound (self, CH_TRIGGER_SINGLE, SND_VEH_RACER_IDLE, VOL_VEHICLEENGINE, ATTEN_NORM);
                }
        }
 #endif
@@ -435,14 +435,14 @@ float racer_frame()
                if(racer.strength_finished < time)
                {
                        racer.strength_finished = time + 10.922667; //soundlength("vehicles/racer_boost.wav");
-                       sound (racer.tur_head, CH_TRIGGER_SINGLE, "vehicles/racer_boost.wav", VOL_VEHICLEENGINE, ATTEN_NORM);
+                       sound (racer.tur_head, CH_TRIGGER_SINGLE, SND_VEH_RACER_BOOST, VOL_VEHICLEENGINE, ATTEN_NORM);
                }
 #endif
        }
        else
        {
                racer.strength_finished = 0;
-               sound (racer.tur_head, CH_TRIGGER_SINGLE, "misc/null.wav", VOL_VEHICLEENGINE, ATTEN_NORM);
+               sound (racer.tur_head, CH_TRIGGER_SINGLE, SND_Null, VOL_VEHICLEENGINE, ATTEN_NORM);
        }
 
        if(cont == CONTENT_WATER || cont == CONTENT_LAVA || cont == CONTENT_SLIME)
@@ -589,7 +589,7 @@ void racer_exit(float eject)
        self.think        = racer_think;
        self.nextthink  = time;
        self.movetype   = MOVETYPE_BOUNCE;
-       sound (self.tur_head, CH_TRIGGER_SINGLE, "misc/null.wav", VOL_VEHICLEENGINE, ATTEN_NORM);
+       sound (self.tur_head, CH_TRIGGER_SINGLE, SND_Null, VOL_VEHICLEENGINE, ATTEN_NORM);
 
        if(!self.owner)
                return;
@@ -856,14 +856,6 @@ bool v_racer(int req)
 
                case VR_PRECACHE:
                {
-               #ifdef SVQC
-                       precache_sound (W_Sound("lasergun_fire"));
-                       precache_sound (W_Sound("rocket_fire"));
-
-                       precache_sound ("vehicles/racer_idle.wav");
-                       precache_sound ("vehicles/racer_move.wav");
-                       precache_sound ("vehicles/racer_boost.wav");
-               #endif
                        return true;
                }
        }
index 96a84892cfb43cb02aabf6778df63f718729e5f4..742ef7b9b2a990eac309fe7ec1922c3ecc5b6047 100644 (file)
@@ -195,7 +195,7 @@ void raptor_bombdrop()
 
 void raptor_fire_cannon(entity gun, string tagname)
 {SELFPARAM();
-       vehicles_projectile(EFFECT_RAPTOR_MUZZLEFLASH.eent_eff_name, W_Sound("lasergun_fire"),
+       vehicles_projectile(EFFECT_RAPTOR_MUZZLEFLASH.eent_eff_name, SND(LASERGUN_FIRE),
                                                   gettaginfo(gun, gettagindex(gun, tagname)), normalize(v_forward + randomvec() * autocvar_g_vehicle_raptor_cannon_spread) * autocvar_g_vehicle_raptor_cannon_speed,
                                                   autocvar_g_vehicle_raptor_cannon_damage, autocvar_g_vehicle_raptor_cannon_radius, autocvar_g_vehicle_raptor_cannon_force,  0,
                                                   DEATH_VH_RAPT_CANNON, PROJECTILE_RAPTORCANNON, 0, true, true, self.owner);
@@ -334,15 +334,15 @@ float raptor_frame()
        if(self.sound_nexttime < time)
        {
                self.sound_nexttime = time + 7.955812;
-               //sound (self.tur_head, CH_TRIGGER_SINGLE, "vehicles/raptor_fly.wav", 1 - ftmp,   ATTEN_NORM );
-               sound (self, CH_TRIGGER_SINGLE, "vehicles/raptor_speed.wav", 1, ATTEN_NORM);
+               //sound (self.tur_head, CH_TRIGGER_SINGLE, SND_VEH_RAPTOR_FLY, 1 - ftmp,   ATTEN_NORM );
+               sound (self, CH_TRIGGER_SINGLE, SND_VEH_RAPTOR_SPEED, 1, ATTEN_NORM);
                self.wait = ftmp;
        }
        /*
        else if(fabs(ftmp - self.wait) > 0.2)
        {
-               sound (self.tur_head, CH_TRIGGER_SINGLE, "", 1 - ftmp,   ATTEN_NORM );
-               sound (self, CH_TRIGGER_SINGLE, "", ftmp, ATTEN_NORM);
+               sound (self.tur_head, CH_TRIGGER_SINGLE, SND_Null, 1 - ftmp,   ATTEN_NORM );
+               sound (self, CH_TRIGGER_SINGLE, SND_Null, ftmp, ATTEN_NORM);
                self.wait = ftmp;
        }
        */
@@ -629,7 +629,7 @@ float raptor_frame()
                }
 
                if(_incomming)
-                       sound(self, CH_PAIN_SINGLE, "vehicles/missile_alarm.wav", VOL_BASE, ATTEN_NONE);
+                       sound(self, CH_PAIN_SINGLE, SND_VEH_MISSILE_ALARM, VOL_BASE, ATTEN_NONE);
 
                self.bomb1.cnt = time + 1;
        }
@@ -661,7 +661,7 @@ float raptor_takeoff()
        if(self.sound_nexttime < time)
        {
                self.sound_nexttime = time + 7.955812; //soundlength("vehicles/raptor_fly.wav");
-               sound (self, CH_TRIGGER_SINGLE, "vehicles/raptor_speed.wav", VOL_VEHICLEENGINE, ATTEN_NORM);
+               sound (self, CH_TRIGGER_SINGLE, SND_VEH_RAPTOR_SPEED, VOL_VEHICLEENGINE, ATTEN_NORM);
        }
 
        // Takeoff sequense
@@ -727,7 +727,7 @@ void raptor_diethink()
 
        if(random() < 0.05)
        {
-               sound (self, CH_SHOTS, W_Sound("rocket_impact"), VOL_BASE, ATTEN_NORM);
+               sound (self, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
                Send_Effect(EFFECT_EXPLOSION_SMALL, randomvec() * 80 + (self.origin + '0 0 100'), '0 0 0', 1);
        }
        self.nextthink = time;
@@ -969,10 +969,6 @@ float v_raptor(float req)
                }
                case VR_PRECACHE:
                {
-                       precache_sound ("vehicles/raptor_fly.wav");
-                       precache_sound ("vehicles/raptor_speed.wav");
-                       precache_sound ("vehicles/missile_alarm.wav");
-
                        return true;
                }
        }
index 7d03c7736f9547e99f18710a55b52ecd19581901..f8efe528dd28614cfa301063a8663e1f51d94d8a 100644 (file)
@@ -269,7 +269,7 @@ void spiderbot_rocket_do()
        switch(self.vehicle_weapon2mode)
        {
                case SBRM_VOLLY:
-                       rocket = vehicles_projectile(EFFECT_SPIDERBOT_ROCKETLAUNCH.eent_eff_name, W_Sound("rocket_fire"),
+                       rocket = vehicles_projectile(EFFECT_SPIDERBOT_ROCKETLAUNCH.eent_eff_name, SND(ROCKET_FIRE),
                                                                   v, normalize(randomvec() * autocvar_g_vehicle_spiderbot_rocket_spread + v_forward) * autocvar_g_vehicle_spiderbot_rocket_speed,
                                                                   autocvar_g_vehicle_spiderbot_rocket_damage, autocvar_g_vehicle_spiderbot_rocket_radius, autocvar_g_vehicle_spiderbot_rocket_force, 1,
                                                                   DEATH_VH_SPID_ROCKET, PROJECTILE_SPIDERROCKET, autocvar_g_vehicle_spiderbot_rocket_health, false, true, self.owner);
@@ -283,7 +283,7 @@ void spiderbot_rocket_do()
                                self.wait = -10;
                        break;
                case SBRM_GUIDE:
-                       rocket = vehicles_projectile(EFFECT_SPIDERBOT_ROCKETLAUNCH.eent_eff_name, W_Sound("rocket_fire"),
+                       rocket = vehicles_projectile(EFFECT_SPIDERBOT_ROCKETLAUNCH.eent_eff_name, SND(ROCKET_FIRE),
                                                                   v, normalize(v_forward) * autocvar_g_vehicle_spiderbot_rocket_speed,
                                                                   autocvar_g_vehicle_spiderbot_rocket_damage, autocvar_g_vehicle_spiderbot_rocket_radius, autocvar_g_vehicle_spiderbot_rocket_force, 1,
                                                                   DEATH_VH_SPID_ROCKET, PROJECTILE_SPIDERROCKET, autocvar_g_vehicle_spiderbot_rocket_health, false, false, self.owner);
@@ -295,7 +295,7 @@ void spiderbot_rocket_do()
 
                break;
                case SBRM_ARTILLERY:
-                       rocket = vehicles_projectile(EFFECT_SPIDERBOT_ROCKETLAUNCH.eent_eff_name, W_Sound("rocket_fire"),
+                       rocket = vehicles_projectile(EFFECT_SPIDERBOT_ROCKETLAUNCH.eent_eff_name, SND(ROCKET_FIRE),
                                                                   v, normalize(v_forward) * autocvar_g_vehicle_spiderbot_rocket_speed,
                                                                   autocvar_g_vehicle_spiderbot_rocket_damage, autocvar_g_vehicle_spiderbot_rocket_radius, autocvar_g_vehicle_spiderbot_rocket_force, 1,
                                                                   DEATH_VH_SPID_ROCKET, PROJECTILE_SPIDERROCKET, autocvar_g_vehicle_spiderbot_rocket_health, false, true, self.owner);
@@ -407,7 +407,7 @@ float spiderbot_frame()
                if(spider.flags & FL_ONGROUND)
                if(spider.frame == 4 && self.tur_head.wait != 0)
                {
-                       sound (self, CH_TRIGGER_SINGLE, "vehicles/spiderbot_land.wav", VOL_VEHICLEENGINE, ATTEN_NORM);
+                       sound (self, CH_TRIGGER_SINGLE, SND_VEH_SPIDERBOT_LAND, VOL_VEHICLEENGINE, ATTEN_NORM);
                        spider.frame = 5;
                }
 
@@ -416,7 +416,7 @@ float spiderbot_frame()
 
                if((spider.flags & FL_ONGROUND) && player.BUTTON_JUMP && !spider.BUTTON_JUMP && self.tur_head.wait < time)
                {
-                       sound (self, CH_TRIGGER_SINGLE, "vehicles/spiderbot_jump.wav", VOL_VEHICLEENGINE, ATTEN_NORM);
+                       sound (self, CH_TRIGGER_SINGLE, SND_VEH_SPIDERBOT_JUMP, VOL_VEHICLEENGINE, ATTEN_NORM);
                        //dprint("spiderbot_jump:", ftos(soundlength("vehicles/spiderbot_jump.wav")), "\n");
                        self.delay = 0;
 
@@ -452,7 +452,7 @@ float spiderbot_frame()
                                                self.delay = 3;
                                                self.sound_nexttime = time + 6.486500; //soundlength("vehicles/spiderbot_idle.wav");
                                                //dprint("spiderbot_idle:", ftos(soundlength("vehicles/spiderbot_idle.wav")), "\n");
-                                               sound (self, CH_TRIGGER_SINGLE, "vehicles/spiderbot_idle.wav", VOL_VEHICLEENGINE, ATTEN_NORM);
+                                               sound (self, CH_TRIGGER_SINGLE, SND_VEH_SPIDERBOT_IDLE, VOL_VEHICLEENGINE, ATTEN_NORM);
                                        }
                                        movelib_beak_simple(autocvar_g_vehicle_spiderbot_speed_stop);
                                        spider.frame = 5;
@@ -496,7 +496,7 @@ float spiderbot_frame()
                                        {
                                                self.delay = 1;
                                                self.sound_nexttime = time + 6.486500; //soundlength("vehicles/spiderbot_walk.wav");
-                                               sound (self, CH_TRIGGER_SINGLE, "vehicles/spiderbot_walk.wav", VOL_VEHICLEENGINE, ATTEN_NORM);
+                                               sound (self, CH_TRIGGER_SINGLE, SND_VEH_SPIDERBOT_WALK, VOL_VEHICLEENGINE, ATTEN_NORM);
                                                //dprint("spiderbot_walk:", ftos(soundlength("vehicles/spiderbot_walk.wav")), "\n");
                                        }
                                }
@@ -526,7 +526,7 @@ float spiderbot_frame()
                                        {
                                                self.delay = 2;
                                                self.sound_nexttime = time + 6.486500; //soundlength("vehicles/spiderbot_strafe.wav");
-                                               sound (self, CH_TRIGGER_SINGLE, "vehicles/spiderbot_strafe.wav", VOL_VEHICLEENGINE, ATTEN_NORM);
+                                               sound (self, CH_TRIGGER_SINGLE, SND_VEH_SPIDERBOT_STRAFE, VOL_VEHICLEENGINE, ATTEN_NORM);
                                                //dprint("spiderbot_strafe:", ftos(soundlength("vehicles/spiderbot_strafe.wav")), "\n");
                                        }
                                }
@@ -558,7 +558,7 @@ float spiderbot_frame()
                        fireBullet(v, v_forward, autocvar_g_vehicle_spiderbot_minigun_spread, autocvar_g_vehicle_spiderbot_minigun_solidpenetration,
                                 autocvar_g_vehicle_spiderbot_minigun_damage, autocvar_g_vehicle_spiderbot_minigun_force, DEATH_VH_SPID_MINIGUN, 0);
 
-                       sound (gun, CH_WEAPON_A, W_Sound("uzi_fire"), VOL_BASE, ATTEN_NORM);
+                       sound (gun, CH_WEAPON_A, SND_UZI_FIRE, VOL_BASE, ATTEN_NORM);
                        //trailparticles(self, _particleeffectnum("spiderbot_minigun_trail"), v, trace_endpos);
                        pointparticles(particleeffectnum(EFFECT_SPIDERBOT_MINIGUN_MUZZLEFLASH), v, v_forward * 2500, 1);
 
@@ -678,7 +678,7 @@ void spiderbot_headfade()
        {
                if(self.alpha > 0.1)
                {
-                       sound (self, CH_SHOTS, W_Sound("rocket_impact"), VOL_BASE, ATTEN_NORM);
+                       sound (self, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
                        Send_Effect(EFFECT_EXPLOSION_BIG, self.origin + '0 0 100', '0 0 0', 1);
                }
                remove(self);
@@ -691,7 +691,7 @@ void spiderbot_blowup()
        {
                if(random() < 0.1)
                {
-                       sound (self, CH_SHOTS, W_Sound("rocket_impact"), VOL_BASE, ATTEN_NORM);
+                       sound (self, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
                        Send_Effect(EFFECT_EXPLOSION_SMALL, randomvec() * 80 + (self.origin + '0 0 100'), '0 0 0', 1);
                }
                self.nextthink = time + 0.1;
@@ -925,15 +925,6 @@ float v_spiderbot(float req)
                }
                case VR_PRECACHE:
                {
-                       precache_sound (W_Sound("uzi_fire") );
-                       precache_sound (W_Sound("rocket_impact"));
-
-                       precache_sound ("vehicles/spiderbot_die.wav");
-                       precache_sound ("vehicles/spiderbot_idle.wav");
-                       precache_sound ("vehicles/spiderbot_jump.wav");
-                       precache_sound ("vehicles/spiderbot_strafe.wav");
-                       precache_sound ("vehicles/spiderbot_walk.wav");
-                       precache_sound ("vehicles/spiderbot_land.wav");
                        return true;
                }
        }
index 046298a4c4f97c7bd2111a74503b2ac7483d46c6..b972cfdec4adfa1a74a6d7ef24b4c6c7dc6b9498 100644 (file)
+++ b/