]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge branch 'master' into Mario/turrets
authorTimePath <andrew.hardaker1995@gmail.com>
Sun, 23 Aug 2015 08:56:02 +0000 (18:56 +1000)
committerTimePath <andrew.hardaker1995@gmail.com>
Sun, 23 Aug 2015 08:56:47 +0000 (18:56 +1000)
# Conflicts:
# qcsrc/client/progs.src
# qcsrc/common/monsters/sv_monsters.qc
# qcsrc/common/triggers/teleporters.qc
# qcsrc/common/vehicles/sv_vehicles.qh
# qcsrc/server/g_damage.qc
# qcsrc/server/g_damage.qh
# qcsrc/server/mutators/mutators_include.qc

46 files changed:
qcsrc/client/damage.qc
qcsrc/client/main.qc
qcsrc/client/mutators/events.qh
qcsrc/client/progs.src
qcsrc/client/view.qc
qcsrc/common/constants.qh
qcsrc/common/monsters/sv_monsters.qc
qcsrc/common/mutators/all.inc [new file with mode: 0644]
qcsrc/common/mutators/all.qc [new file with mode: 0644]
qcsrc/common/mutators/events.qh
qcsrc/common/mutators/mutator/damagetext.qc [new file with mode: 0644]
qcsrc/common/stats.qh
qcsrc/common/triggers/teleporters.qc
qcsrc/common/util-pre.qh
qcsrc/common/vehicles/all.inc [new file with mode: 0644]
qcsrc/common/vehicles/all.qc [new file with mode: 0644]
qcsrc/common/vehicles/all.qh
qcsrc/common/vehicles/cl_vehicles.qc
qcsrc/common/vehicles/sv_vehicles.qc
qcsrc/common/vehicles/sv_vehicles.qh
qcsrc/common/vehicles/unit/all.qh [deleted file]
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/vehicles/vehicle.qh [new file with mode: 0644]
qcsrc/common/vehicles/vehicles.qc [deleted file]
qcsrc/common/vehicles/vehicles.qh [deleted file]
qcsrc/common/vehicles/vehicles_include.qc [deleted file]
qcsrc/common/vehicles/vehicles_include.qh [deleted file]
qcsrc/menu/progs.src
qcsrc/server/antilag.qc
qcsrc/server/cl_client.qc
qcsrc/server/cl_player.qc
qcsrc/server/command/cmd.qc
qcsrc/server/g_damage.qc
qcsrc/server/g_damage.qh
qcsrc/server/g_hook.qc
qcsrc/server/g_world.qc
qcsrc/server/mutators/events.qh
qcsrc/server/mutators/gamemode_assault.qc
qcsrc/server/mutators/gamemode_ctf.qc
qcsrc/server/mutators/gamemode_onslaught.qc
qcsrc/server/mutators/mutators_include.qc
qcsrc/server/progs.src
qcsrc/server/sv_main.qc

index 7825b9f1cae385c6a14dcec2109657bf7ea78789..9479f5786ca6218b7550601328a10de72252dbd8 100644 (file)
@@ -4,7 +4,7 @@
 #include "gibs.qh"
 #include "prandom.qh"
 
-#include "../common/vehicles/cl_vehicles.qh"
+#include "../common/vehicles/all.qh"
 
 #include "../common/constants.qh"
 #include "../common/deathtypes.qh"
index 6d075b2f8690af5eaa72467375f6c3c2f070df8a..b50caca126266b311af005245aeedcd4f8d4eda3 100644 (file)
@@ -22,9 +22,9 @@
 #include "wall.qh"
 #include "waypointsprites.qh"
 
-#include "../common/vehicles/unit/bumblebee.qh"
-#include "../common/vehicles/cl_vehicles.qh"
-#include "../common/vehicles/vehicles.qh"
+#include "../common/vehicles/all.qh"
+
+#include "mutators/events.qh"
 
 #include "weapons/projectile.qh"
 
@@ -152,7 +152,6 @@ void CSQC_Init(void)
        CALL_ACCUMULATED_FUNCTION(RegisterDeathtypes);
        CALL_ACCUMULATED_FUNCTION(RegisterHUD_Panels);
        CALL_ACCUMULATED_FUNCTION(RegisterEffects);
-       CALL_ACCUMULATED_FUNCTION(RegisterVehicles);
 
        WaypointSprite_Load();
 
@@ -1259,69 +1258,55 @@ void Net_WeaponComplain()
 // Return value should be 1 if CSQC handled the temporary entity, otherwise return 0 to have the engine process the event.
 float CSQC_Parse_TempEntity()
 {
-       float bHandled;
-               bHandled  = true;
        // Acquire TE ID
-       float nTEID;
-               nTEID = ReadByte();
+       int nTEID = ReadByte();
 
-       if(autocvar_developer_csqcentities)
+       if (autocvar_developer_csqcentities)
                printf("CSQC_Parse_TempEntity() with nTEID=%d\n", nTEID);
 
-               // NOTE: Could just do return instead of break...
-       switch(nTEID)
+       switch (nTEID)
        {
+               case TE_CSQC_MUTATOR:
+                       int mutID = ReadMutator();
+                       if (MUTATOR_CALLHOOK(CSQC_Parse_TempEntity, mutID))
+                       return true;
                case TE_CSQC_TARGET_MUSIC:
                        Net_TargetMusic();
-                       bHandled = true;
-                       break;
+                       return true;
                case TE_CSQC_PICTURE:
                        Net_MapVote_Picture();
-                       bHandled = true;
-                       break;
+                       return true;
                case TE_CSQC_RACE:
                        Net_ReadRace();
-                       bHandled = true;
-                       break;
+                       return true;
                case TE_CSQC_VORTEXBEAMPARTICLE:
                        Net_ReadVortexBeamParticle();
-                       bHandled = true;
-                       break;
+                       return true;
                case TE_CSQC_TEAMNAGGER:
                        Net_TeamNagger();
-                       bHandled = true;
-                       break;
+                       return true;
                case TE_CSQC_ARC:
                        Net_ReadArc();
-                       bHandled = true;
-                       break;
+                       return true;
                case TE_CSQC_PINGPLREPORT:
                        Net_ReadPingPLReport();
-                       bHandled = true;
-                       break;
+                       return true;
                case TE_CSQC_WEAPONCOMPLAIN:
                        Net_WeaponComplain();
-                       bHandled = true;
-                       break;
+                       return true;
                case TE_CSQC_VEHICLESETUP:
                        Net_VehicleSetup();
-                       bHandled = true;
-                       break;
+                       return true;
                case TE_CSQC_SVNOTICE:
                        cl_notice_read();
-                       bHandled = true;
-                       break;
+                       return true;
                case TE_CSQC_SHOCKWAVEPARTICLE:
                        Net_ReadShockwaveParticle();
-                       bHandled = true;
-                       break;
+                       return true;
                default:
                        // No special logic for this temporary entity; return 0 so the engine can handle it
-                       bHandled = false;
-                       break;
+                       return false;
        }
-
-       return bHandled;
 }
 
 string getcommandkey(string text, string command)
index 362e8d321d28714e763cbd0751b72c544bef4260..8f317c8e8a6f042476a887fbeb1869bc2b7841a7 100644 (file)
@@ -35,4 +35,18 @@ string cmd_string;
     /**/
 MUTATOR_HOOKABLE(CSQC_ConsoleCommand, EV_CSQC_ConsoleCommand);
 
+/* Called when the crosshair is being updated */
+MUTATOR_HOOKABLE(UpdateCrosshair, EV_NO_ARGS);
+
+/**
+ * Called when a temp entity is parsed
+ * NOTE: hooks MUST start with `if (MUTATOR_RETURNVALUE) return false;`
+ * NOTE: hooks MUST start with `if (!ReadMutatorEquals(mutator_argv_int_0, name_of_mutator)) return false;`
+ * NOTE: return true if you handled the command, return false to continue handling
+ */
+#define EV_CSQC_Parse_TempEntity(i, o) \
+    /** entity id */ i(int, mutator_argv_int_0) \
+    /**/
+MUTATOR_HOOKABLE(CSQC_Parse_TempEntity, EV_CSQC_Parse_TempEntity);
+
 #endif
index 49b5640ae4796361b0d975b055469588d954681f..6a427b464d6dae2d534e15f942ddbfd2f7f896d6 100644 (file)
@@ -55,28 +55,25 @@ weapons/projectile.qc // TODO
 
 ../common/viewloc.qc
 
-../common/weapons/all.qc // TODO
-
 ../common/items/all.qc
-
 ../common/monsters/all.qc
+../common/mutators/all.qc
+../common/vehicles/all.qc
+../common/weapons/all.qc
+
 ../common/turrets/cl_turrets.qc
 ../common/turrets/turrets.qc
 
-
 ../common/triggers/include.qc
 
 ../csqcmodellib/cl_model.qc
 ../csqcmodellib/cl_player.qc
 ../csqcmodellib/interpolate.qc
 
-../common/vehicles/vehicles_include.qc
-
 ../server/mutators/mutator_multijump.qc
 
 ../warpzonelib/anglestransform.qc
 ../warpzonelib/client.qc
-
 ../warpzonelib/common.qc
 ../warpzonelib/mathlib.qc
 ../warpzonelib/util_server.qc
index 67bcf422493bb5ceb44b956a934cf7b50b074ccc..1475bf232603a540b62886e7f35080f74cc7700b 100644 (file)
@@ -10,6 +10,8 @@
 #include "shownames.qh"
 #include "waypointsprites.qh"
 
+#include "mutators/events.qh"
+
 #include "../common/constants.qh"
 #include "../common/mapinfo.qh"
 #include "../common/nades.qh"
@@ -801,6 +803,8 @@ void UpdateCrosshair()
                wcross_alpha_prev = wcross_alpha;
                wcross_color_prev = wcross_color;
 
+               MUTATOR_CALLHOOK(UpdateCrosshair);
+
                wcross_scale *= 1 - autocvar__menu_alpha;
                wcross_alpha *= 1 - autocvar__menu_alpha;
                wcross_size = draw_getimagesize(wcross_name) * wcross_scale;
index 1953b1f33d0c66a03341515ab044b54bca26c69c..1498e465eb4b8ca70f58302030c5a196d6556670 100644 (file)
@@ -31,6 +31,14 @@ const int AS_INT = 2;
 const int AS_FLOAT_TRUNCATED = 2;
 const int AS_FLOAT = 8;
 
+const int TE_CSQC_MUTATOR = 99;
+#define MUTATOR_HASH(s) crc16(true, s)
+#define WriteMutator(to, s) do { \
+    WriteByte(to, TE_CSQC_MUTATOR); \
+    WriteLong(to, MUTATOR_HASH(#s)); \
+} while (0)
+#define ReadMutator() ReadLong()
+#define ReadMutatorEquals(read, s) (read == MUTATOR_HASH(#s))
 const int TE_CSQC_PICTURE = 100;
 const int TE_CSQC_RACE = 101;
 const int TE_CSQC_VORTEXBEAMPARTICLE = 103;
index b453ba25714c26942dc1308adb50660cd372ff11..249e6f97eb768be7fed885364f200b0915d91baf 100644 (file)
     #include "../../server/defs.qh"
     #include "../deathtypes.qh"
     #include "../../server/mutators/mutators_include.qh"
-    #include "../../server/steerlib.qh"
-    #include "../turrets/sv_turrets.qh"
-    #include "../turrets/util.qh"
-    #include "../vehicles/sv_vehicles.qh"
+       #include "../../server/steerlib.qh"
+       #include "../turrets/sv_turrets.qh"
+       #include "../turrets/util.qh"
+    #include "../vehicles/all.qh"
     #include "../../server/campaign.qh"
     #include "../../server/command/common.qh"
     #include "../../server/command/cmd.qh"
diff --git a/qcsrc/common/mutators/all.inc b/qcsrc/common/mutators/all.inc
new file mode 100644 (file)
index 0000000..4cb1a6c
--- /dev/null
@@ -0,0 +1 @@
+#include "mutator/damagetext.qc"
diff --git a/qcsrc/common/mutators/all.qc b/qcsrc/common/mutators/all.qc
new file mode 100644 (file)
index 0000000..14530a3
--- /dev/null
@@ -0,0 +1 @@
+#include "all.inc"
index e193d5f8a0e125eacdf657da5d0869e76dc1b812..eb46486b6b8e6ca4a00ed7f4fedcd6fee7990c37 100644 (file)
@@ -3,8 +3,28 @@
 
 #define EV_NO_ARGS(i, o)
 
+#pragma noref 1
 string ret_string;
 
+#define MUTATOR_TYPES(_, x) \
+    _(x, bool) \
+    _(x, int) \
+    _(x, entity) \
+    _(x, float) \
+    _(x, vector) \
+    _(x, string) \
+    /**/
+
+#define MUTATOR_NEWGLOBAL(x, type) type mutator_argv_##type##_##x;
+
+MUTATOR_TYPES(MUTATOR_NEWGLOBAL, 0)
+MUTATOR_TYPES(MUTATOR_NEWGLOBAL, 1)
+
+#undef MUTATOR_TYPES
+#undef MUTATOR_NEWGLOBAL
+
+#pragma noref 0
+
 /** appends ":mutatorname" to ret_string for logging */
 #define EV_BuildMutatorsString(i, o) \
     /**/ i(string, ret_string) \
diff --git a/qcsrc/common/mutators/mutator/damagetext.qc b/qcsrc/common/mutators/mutator/damagetext.qc
new file mode 100644 (file)
index 0000000..aacfc73
--- /dev/null
@@ -0,0 +1,125 @@
+REGISTER_MUTATOR(damagetext, true);
+
+#ifdef CSQC
+bool autocvar_cl_damagetext = false;
+string autocvar_cl_damagetext_format = "-%3$d";
+vector autocvar_cl_damagetext_color = '1 1 0';
+float autocvar_cl_damagetext_size = 8;
+float autocvar_cl_damagetext_alpha_start = 1;
+float autocvar_cl_damagetext_alpha_lifetime = 3;
+vector autocvar_cl_damagetext_velocity = '0 0 20';
+vector autocvar_cl_damagetext_offset = '0 -40 0';
+float autocvar_cl_damagetext_accumulate_range = 30;
+STATIC_INIT(cl_damagetext) {
+    CVAR_DESCRIBE(cl_damagetext, _("Draw damage dealt. 0: disabled, 1: enabled"));
+    CVAR_DESCRIBESTR(cl_damagetext_format, _("How to format the damage text. 1$ is health, 2$ is armor, 3$ is both"));
+    CVAR_DESCRIBEVEC(cl_damagetext_color, _("Default damage text color"));
+    CVAR_DESCRIBE(cl_damagetext_size, _("Damage text font size"));
+    CVAR_DESCRIBE(cl_damagetext_alpha_start, _("Damage text initial alpha"));
+    CVAR_DESCRIBE(cl_damagetext_alpha_lifetime, _("Damage text lifetime in seconds"));
+    CVAR_DESCRIBEVEC(cl_damagetext_velocity, _("Damage text move direction"));
+    CVAR_DESCRIBEVEC(cl_damagetext_offset, _("Damage text offset"));
+    CVAR_DESCRIBE(cl_damagetext_accumulate_range, _("Damage text spawned within this range is accumulated"));
+}
+
+CLASS(DamageText, Object)
+    ATTRIB(DamageText, m_color, vector, autocvar_cl_damagetext_color)
+    ATTRIB(DamageText, m_size, float, autocvar_cl_damagetext_size)
+    ATTRIB(DamageText, alpha, float, autocvar_cl_damagetext_alpha_start)
+    ATTRIB(DamageText, fade_rate, float, 1 / autocvar_cl_damagetext_alpha_lifetime)
+    ATTRIB(DamageText, velocity, vector, autocvar_cl_damagetext_velocity)
+    ATTRIB(DamageText, m_group, int, 0)
+    ATTRIB(DamageText, m_damage, int, 0)
+    ATTRIB(DamageText, m_armordamage, int, 0)
+    ATTRIB(DamageText, time_prev, float, time)
+
+    void DamageText_draw() {
+        entity this = self;
+        float dt = time - this.time_prev;
+        this.time_prev = time;
+        setorigin(this, this.origin + dt * this.velocity);
+        this.alpha -= dt * this.fade_rate;
+        if (this.alpha < 0) remove(this);
+        vector pos = project_3d_to_2d(this.origin) + autocvar_cl_damagetext_offset;
+        if (pos.z >= 0 && this.m_size > 0) {
+            pos.z = 0;
+            string s = sprintf(autocvar_cl_damagetext_format, this.m_damage, this.m_armordamage, this.m_damage + this.m_armordamage);
+            drawcolorcodedstring2(pos, s, this.m_size * '1 1 0', this.m_color, this.alpha, DRAWFLAG_NORMAL);
+        }
+    }
+    ATTRIB(DamageText, draw2d, void(), DamageText_draw)
+
+    void DamageText_update(DamageText this, vector _origin, int _health, int _armor) {
+        this.m_damage = _health;
+        this.m_armordamage = _armor;
+        setorigin(this, _origin);
+        this.alpha = 1;
+    }
+
+    CONSTRUCTOR(DamageText, int _group, vector _origin, int _health, int _armor) {
+        CONSTRUCT(DamageText);
+        this.m_group = _group;
+        DamageText_update(this, _origin, _health, _armor);
+        return this;
+    }
+ENDCLASS(DamageText)
+#endif
+
+#ifdef SVQC
+int autocvar_sv_damagetext = 2;
+STATIC_INIT(sv_damagetext) {
+    CVAR_DESCRIBE(sv_damagetext, _("<= 0: disabled, >= 1: spectators, >= 2: players, >= 3: all players"));
+}
+#define SV_DAMAGETEXT_DISABLED()        (autocvar_sv_damagetext <= 0 /* disabled */)
+#define SV_DAMAGETEXT_SPECTATORS_ONLY() (autocvar_sv_damagetext >= 1 /* spectators only */)
+#define SV_DAMAGETEXT_PLAYERS()         (autocvar_sv_damagetext >= 2 /* players */)
+#define SV_DAMAGETEXT_ALL()             (autocvar_sv_damagetext >= 3 /* all players */)
+MUTATOR_HOOKFUNCTION(damagetext, PlayerDamaged) {
+    if (SV_DAMAGETEXT_DISABLED()) return;
+    const entity attacker = mutator_argv_entity_0;
+    const entity hit = mutator_argv_entity_1; if (hit == attacker) return;
+    const int health = mutator_argv_int_0;
+    const int armor = mutator_argv_int_1;
+    const vector location = hit.origin;
+    entity e;
+    FOR_EACH_REALCLIENT(e) if (
+        (SV_DAMAGETEXT_ALL()) ||
+        (SV_DAMAGETEXT_PLAYERS() && e == attacker) ||
+        (SV_DAMAGETEXT_SPECTATORS_ONLY() && IS_SPEC(e) && e.enemy == attacker) ||
+        (SV_DAMAGETEXT_SPECTATORS_ONLY() && IS_OBSERVER(e))
+    ) {
+        msg_entity = e;
+        WriteByte(MSG_ONE, SVC_TEMPENTITY);
+        WriteMutator(MSG_ONE, damagetext);
+        WriteShort(MSG_ONE, health);
+        WriteShort(MSG_ONE, armor);
+        WriteEntity(MSG_ONE, hit);
+        WriteCoord(MSG_ONE, location.x);
+        WriteCoord(MSG_ONE, location.y);
+        WriteCoord(MSG_ONE, location.z);
+    }
+}
+#endif
+
+#ifdef CSQC
+MUTATOR_HOOKFUNCTION(damagetext, CSQC_Parse_TempEntity) {
+    if (MUTATOR_RETURNVALUE) return false;
+    if (!ReadMutatorEquals(mutator_argv_int_0, damagetext)) return false;
+    int health = ReadShort();
+    int armor = ReadShort();
+    int group = ReadShort();
+    vector location = vec3(ReadCoord(), ReadCoord(), ReadCoord());
+    if (autocvar_cl_damagetext) {
+        if (autocvar_cl_damagetext_accumulate_range) {
+            for (entity e = findradius(location, autocvar_cl_damagetext_accumulate_range); e; e = e.chain) {
+                if (e.instanceOfDamageText && e.m_group == group) {
+                    DamageText_update(e, location, e.m_damage + health, e.m_armordamage + armor);
+                    return true;
+                }
+            }
+        }
+        NEW(DamageText, group, location, health, armor);
+    }
+    return true;
+}
+#endif
index eb6b0ea9704c67fadbe0c65fccf0901e903b9c04..7f82ae5985a821e450be0c80f059a6626456ef2c 100644 (file)
@@ -190,22 +190,22 @@ const int STAT_CTF_FLAGSTATUS         = 124;
 // 137 empty?
 // 138 empty?
 // 139 empty?
-// 140 empty?
-// 141 empty?
-// 142 empty?
-// 143 empty?
-// 144 empty?
-// 145 empty?
-// 146 empty?
-// 147 empty?
-// 148 empty?
-// 149 empty?
-// 150 empty?
-// 151 empty?
-// 152 empty?
-// 153 empty?
-// 154 empty?
-// 155 empty?
+// 140 reserved
+// 141 reserved
+// 142 reserved
+// 143 reserved
+// 144 reserved
+// 145 reserved
+// 146 reserved
+// 147 reserved
+// 148 reserved
+// 149 reserved
+// 150 reserved
+// 151 reserved
+// 152 reserved
+// 153 reserved
+// 154 reserved
+// 155 reserved
 // 156 empty?
 // 157 empty?
 // 158 empty?
index 5cd0981005538a7a86d0790f71a3f51069affc28..89a5fa20df1cef803ab61357d98e06e06d3ffd24 100644 (file)
@@ -16,7 +16,7 @@
     #include "../../server/defs.qh"
     #include "../deathtypes.qh"
     #include "../turrets/sv_turrets.qh"
-    #include "../vehicles/sv_vehicles.qh"
+    #include "../vehicles/all.qh"
     #include "../mapinfo.qh"
     #include "../../server/anticheat.qh"
 #endif
index b96e78d514f6832d6c39cfae274e678b641761e9..fc916d4dba37a17b182ee007f5ff9e21927a078a 100644 (file)
     #define BITSET(var, mask, flag) ((var) ^ (-(flag) ^ (var)) & (mask))
 #endif
 
+#define CVAR_DESCRIBE(var, desc)    localcmd(sprintf("\nset %s \"%s\" \"%s\"\n",        #var, ftos(autocvar_##var), desc))
+#define CVAR_DESCRIBESTR(var, desc) localcmd(sprintf("\nset %s \"%s\" \"%s\"\n",        #var, autocvar_##var, desc))
+#define CVAR_DESCRIBEVEC(var, desc) localcmd(sprintf("\nset %s \"%s %s %s\" \"%s\"\n",  #var, ftos(autocvar_##var##.x), ftos(autocvar_##var##.y), ftos(autocvar_##var##.z), desc))
+
 #endif
diff --git a/qcsrc/common/vehicles/all.inc b/qcsrc/common/vehicles/all.inc
new file mode 100644 (file)
index 0000000..eda4e00
--- /dev/null
@@ -0,0 +1,6 @@
+#include "unit/spiderbot.qc"
+#include "unit/raptor.qc"
+#include "unit/racer.qc"
+#ifndef VEHICLES_NO_UNSTABLE
+       #include "unit/bumblebee.qc"
+#endif
diff --git a/qcsrc/common/vehicles/all.qc b/qcsrc/common/vehicles/all.qc
new file mode 100644 (file)
index 0000000..f0316ab
--- /dev/null
@@ -0,0 +1,56 @@
+#ifndef VEHICLES_ALL_C
+#define VEHICLES_ALL_C
+
+#include "all.qh"
+
+#if defined(SVQC)
+       #include "sv_vehicles.qc"
+#elif defined(CSQC)
+       #include "cl_vehicles.qc"
+#endif
+
+#define IMPLEMENTATION
+#include "all.inc"
+#undef IMPLEMENTATION
+
+#ifndef MENUQC
+STATIC_INIT(vehicles_common_initialize)
+{
+#ifdef CSQC
+       precache_model("models/vehicles/bomblet.md3");
+       precache_model("models/vehicles/clusterbomb.md3");
+       precache_model("models/vehicles/clusterbomb_fragment.md3");
+       precache_model("models/vehicles/rocket01.md3");
+       precache_model("models/vehicles/rocket02.md3");
+
+       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);
+       addstat(STAT_VEHICLESTAT_ENERGY,  AS_INT, vehicle_energy);
+
+       addstat(STAT_VEHICLESTAT_W2MODE, AS_INT, vehicle_weapon2mode);
+
+       addstat(STAT_VEHICLESTAT_AMMO1,   AS_INT, vehicle_ammo1);
+       addstat(STAT_VEHICLESTAT_RELOAD1, AS_INT, vehicle_reload1);
+
+       addstat(STAT_VEHICLESTAT_AMMO2,   AS_INT, vehicle_ammo2);
+       addstat(STAT_VEHICLESTAT_RELOAD2, AS_INT, vehicle_reload2);
+#endif // SVQC
+}
+#endif
+
+entity get_vehicleinfo(int id)
+{
+       if (id < VEH_FIRST || id > VEH_LAST) return VEH_NULL;
+       entity m = vehicle_info[id];
+       return m ? m : VEH_NULL;
+}
+
+#endif
index 48ff80418c21c46bbc4339dee5a0d5b66203f78e..ccb3a05642830b27140c51bdbd46dbdd6efe5f5d 100644 (file)
@@ -1,10 +1,84 @@
+#ifndef VEHICLES_ALL_H
+#define VEHICLES_ALL_H
+
 #if defined(SVQC)
        #include "sv_vehicles.qh"
 #elif defined(CSQC)
        #include "cl_vehicles.qh"
 #endif
 
-#   ifndef VEHICLES_NO_UNSTABLE
-#       include "unit/bumblebee.qh"
-#       include "unit/raptor.qh"
-#   endif
+
+// vehicle requests
+const int VR_SETUP          = 1; // (BOTH) setup vehicle data
+const int VR_THINK                     = 2; // (SERVER) logic to run every frame
+const int VR_DEATH          = 3; // (SERVER) called when vehicle dies
+const int VR_PRECACHE       = 4; // (BOTH) precaches models/sounds used by this vehicle
+const int VR_ENTER          = 5; // (SERVER) called when a player enters this vehicle
+const int VR_SPAWN          = 6; // (SERVER) called when the vehicle re-spawns
+const int VR_IMPACT         = 7; // (SERVER) called when a vehicle hits something
+const int VR_HUD            = 8; // (CLIENT) logic to run every frame
+
+// vehicle spawn flags (need them here for common registrations)
+const int VHF_ISVEHICLE                        = 2; /// Indicates vehicle
+const int VHF_HASSHIELD                        = 4; /// Vehicle has shileding
+const int VHF_SHIELDREGEN              = 8; /// Vehicles shield regenerates
+const int VHF_HEALTHREGEN              = 16; /// Vehicles health regenerates
+const int VHF_ENERGYREGEN              = 32; /// Vehicles energy regenerates
+const int VHF_DEATHEJECT               = 64; /// Vehicle ejects pilot upon fatal damage
+const int VHF_MOVE_GROUND              = 128; /// Vehicle moves on gound
+const int VHF_MOVE_HOVER               = 256; /// Vehicle hover close to gound
+const int VHF_MOVE_FLY                 = 512; /// Vehicle is airborn
+const int VHF_DMGSHAKE                 = 1024; /// Add random velocity each frame if health < 50%
+const int VHF_DMGROLL                  = 2048; /// Add random angles each frame if health < 50%
+const int VHF_DMGHEADROLL              = 4096; /// Add random head angles each frame if health < 50%
+const int VHF_MULTISLOT                        = 8192; /// Vehicle has multiple player slots
+const int VHF_PLAYERSLOT               = 16384; /// This ent is a player slot on a multi-person vehicle
+
+// functions:
+entity get_vehicleinfo(float id);
+
+// fields:
+.entity tur_head;
+
+
+// other useful macros
+#define VEH_ACTION(vehicletype,mrequest) (get_vehicleinfo(vehicletype)).vehicle_func(mrequest)
+#define VEH_NAME(vehicletype) (get_vehicleinfo(vehicletype)).vehicle_name
+
+// =====================
+//  Vehicle Registration
+// =====================
+
+void RegisterVehicles();
+const int VEH_MAXCOUNT = 24;
+entity vehicle_info[VEH_MAXCOUNT], vehicle_info_first, vehicle_info_last;
+int VEH_COUNT;
+const int VEH_FIRST = 1;
+#define VEH_LAST (VEH_FIRST + VEH_COUNT - 1)
+/** If you register a new vehicle, make sure to add it to all.inc */
+#define REGISTER_VEHICLE(id, class) REGISTER(RegisterVehicles, VEH, vehicle_info, VEH_COUNT, id, vehicleid, NEW(class))
+#include "vehicle.qh"
+#define REGISTER_VEHICLE_SIMPLE(id, func, vehicleflags, min_s, max_s, modelname, headmodelname, hudmodelname, headtag, hudtag, viewtag, shortname, vname) \
+    REGISTER_VEHICLE(id, Vehicle) {         \
+       this.netname = shortname;           \
+       this.vehicle_name = vname;          \
+       this.vehicle_func = func;           \
+       this.mdl = modelname;               \
+       this.spawnflags = vehicleflags;     \
+       this.mins = min_s;                  \
+       this.maxs = max_s;                  \
+       this.model = modelname;             \
+       this.head_model = headmodelname;    \
+       this.hud_model = hudmodelname;      \
+       this.tag_head = headtag;            \
+       this.tag_hud = hudtag;              \
+       this.tag_view = viewtag;            \
+    }                                       \
+    REGISTER_INIT(VEH, id)
+REGISTER_REGISTRY(RegisterVehicles)
+
+REGISTER_VEHICLE(NULL, Vehicle);
+
+#include "all.inc"
+
+#endif
index 2511defb43860a8baa577b13aed7884329d601cf..141f8fc42d59b5362e4e8bfad7712cc27c8c22fb 100644 (file)
@@ -295,7 +295,7 @@ void Vehicles_drawHUD(
        }
 
        // Bumblebee gunner crosshairs
-       if(hud == VEH_BUMBLEBEE)
+       if(hud == VEH_BUMBLEBEE.vehicleid)
        {
                tmpSize = '1 1 1' * hud_fontsize;
                tmpPos.x = hudPos.x + hudSize.x * (520/768);
@@ -314,7 +314,7 @@ void Vehicles_drawHUD(
        }
 
        // Raptor bomb crosshair
-       if(hud == VEH_RAPTOR && weapon2mode != RSM_FLARE)
+       if(hud == VEH_RAPTOR.vehicleid && weapon2mode != RSM_FLARE)
        {
                vector where;
 
index b06596bbc9cd4da869ba3cab1d758831e210a96b..79f59018d218dd937e86aaa58e1124598b8c5122 100644 (file)
@@ -1,6 +1,5 @@
-#include "../effects.qh"
-#include "vehicles.qh"
 #include "sv_vehicles.qh"
+#include "../effects.qh"
 
 #if 0
 bool vehicle_send(entity to, int sf)
@@ -1184,17 +1183,15 @@ void vehicles_spawn()
        CSQCMODEL_AUTOINIT();
 }
 
-bool vehicle_initialize(int vehicle_id, bool nodrop)
+bool vehicle_initialize(entity veh, bool nodrop)
 {
        if(!autocvar_g_vehicles)
                return false;
 
-       entity veh = get_vehicleinfo(vehicle_id);
-
        if(!veh.vehicleid)
                return false;
        
-       if(!veh.tur_head) { VEH_ACTION(vehicle_id, VR_PRECACHE); }
+       if(!veh.tur_head) { VEH_ACTION(veh.vehicleid, VR_PRECACHE); }
 
        if(self.targetname && self.targetname != "")
        {
@@ -1239,7 +1236,7 @@ bool vehicle_initialize(int vehicle_id, bool nodrop)
        self.iscreature                         = true;
        self.teleportable                       = false; // no teleporting for vehicles, too buggy
        self.damagedbycontents          = true;
-       self.vehicleid                          = vehicle_id;
+       self.vehicleid                          = veh.vehicleid;
        self.PlayerPhysplug                     = veh.PlayerPhysplug;
        self.event_damage                       = func_null;
        self.touch                                      = vehicles_touch;
@@ -1287,7 +1284,7 @@ bool vehicle_initialize(int vehicle_id, bool nodrop)
        self.pos2 = self.angles;
        self.tur_head.team = self.team;
 
-       VEH_ACTION(vehicle_id, VR_SETUP);
+       VEH_ACTION(veh.vehicleid, VR_SETUP);
 
        if(self.active == ACTIVE_NOT)
                self.nextthink = 0; // wait until activated
index 6c0a6bd17937b415c24da322afb6086ff5b41c5c..b3f252e3b12597ed22b4bbae58ce9711c297bf19 100644 (file)
@@ -3,7 +3,6 @@
 #ifdef SVQC
 
 #include "../turrets/sv_turrets.qh"
-#include "sv_vehicles.qh"
 
 // #define VEHICLES_USE_ODE
 
@@ -101,10 +100,9 @@ float vehicles_exit_running;
 .float vehicle_enter_delay; // prevent players jumping to and from vehicles instantly
 
 void vehicles_exit(float eject);
-float vehicle_initialize(float vehicle_id, float nodrop);
+float vehicle_initialize(entity vehicle, float nodrop);
 bool vehicle_impulse(int imp);
 bool vehicles_crushable(entity e);
 
 #endif
-
 #endif
diff --git a/qcsrc/common/vehicles/unit/all.qh b/qcsrc/common/vehicles/unit/all.qh
deleted file mode 100644 (file)
index 7dfca83..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-#include "spiderbot.qc"
-#include "raptor.qc"
-#include "racer.qc"
-#ifndef VEHICLES_NO_UNSTABLE
-       #include "bumblebee.qc"
-#endif
index cc52716c79f4761c91fc83b3a00d768a4108f3a1..ba0db541a9634130a64160f235aa064465bcf4d0 100644 (file)
@@ -1,5 +1,8 @@
-#ifdef REGISTER_VEHICLE
-REGISTER_VEHICLE(
+#ifndef VEHICLE_BUMBLEBEE
+#define VEHICLE_BUMBLEBEE
+#include "bumblebee.qh"
+int v_bumblebee(int);
+REGISTER_VEHICLE_SIMPLE(
 /* VEH_##id   */ BUMBLEBEE,
 /* function   */ v_bumblebee,
 /* spawnflags */ VHF_DMGSHAKE,
@@ -10,8 +13,12 @@ REGISTER_VEHICLE(
 /* tags                  */ "", "", "tag_viewport",
 /* netname       */ "bumblebee",
 /* fullname   */ _("Bumblebee")
-);
-#else
+) {
+    this.m_icon = "vehicle_bumble";
+}
+#endif
+
+#ifdef IMPLEMENTATION
 
 const float BRG_SETUP = 2;
 const float BRG_START = 4;
@@ -656,7 +663,7 @@ void bumblebee_land()
 
 void bumblebee_exit(float eject)
 {
-       if(self.owner.vehicleid == VEH_BUMBLEBEE)
+       if(self.owner.vehicleid == VEH_BUMBLEBEE.vehicleid)
        {
                bumblebee_gunner_exit(eject);
                return;
@@ -1096,7 +1103,7 @@ float v_bumblebee(float req)
        {
                case VR_HUD:
                {
-                       Vehicles_drawHUD("vehicle_bumble", "vehicle_bumble_weapon1", "vehicle_bumble_weapon2",
+                       Vehicles_drawHUD(VEH_BUMBLEBEE.m_icon, "vehicle_bumble_weapon1", "vehicle_bumble_weapon2",
                                                         "vehicle_icon_ammo1", autocvar_hud_progressbar_vehicles_ammo1_color,
                                                         "vehicle_icon_ammo1", autocvar_hud_progressbar_vehicles_ammo1_color,
                                                         vCROSS_HEAL);
index 80cde0313529da648aedac80819a4947cb9a2d79..41a0b12ff71eaf2811fc826d9991226c3f734a7c 100644 (file)
@@ -1,5 +1,7 @@
-#ifdef REGISTER_VEHICLE
-REGISTER_VEHICLE(
+#ifndef VEHICLE_RACER
+#define VEHICLE_RACER
+int v_racer(int);
+REGISTER_VEHICLE_SIMPLE(
 /* VEH_##id   */ RACER,
 /* function   */ v_racer,
 /* spawnflags */ VHF_DMGSHAKE | VHF_DMGROLL,
@@ -10,8 +12,12 @@ REGISTER_VEHICLE(
 /* tags                  */ "", "", "tag_viewport",
 /* netname       */ "racer",
 /* fullname   */ _("Racer")
-);
-#else
+) {
+    this.m_icon = "vehicle_racer";
+}
+#endif
+
+#ifdef IMPLEMENTATION
 #ifdef SVQC
 #include "../../effects.qh"
 #include "../../triggers/trigger/impulse.qh"
@@ -804,7 +810,7 @@ bool v_racer(int req)
 #ifdef CSQC
                case VR_HUD:
                {
-                       Vehicles_drawHUD("vehicle_racer", "vehicle_racer_weapon1", "vehicle_racer_weapon2",
+                       Vehicles_drawHUD(VEH_RACER.m_icon, "vehicle_racer_weapon1", "vehicle_racer_weapon2",
                                                         "vehicle_icon_ammo1", autocvar_hud_progressbar_vehicles_ammo1_color,
                                                         "vehicle_icon_ammo2", autocvar_hud_progressbar_vehicles_ammo2_color,
                                                         vCROSS_GUIDE);
@@ -856,9 +862,10 @@ bool v_racer(int req)
 
                        precache_model ("models/vhshield.md3");
                #endif
-
+               #ifndef MENUQC
                        precache_model ("models/vehicles/wakizashi.dpm");
                        precache_model ("models/vehicles/wakizashi_cockpit.dpm");
+               #endif
                        return true;
                }
        }
index bff81b7d8690fce8a265b47538b08277c1246ef6..2ea89491bb21317f61637ab6480ef3a9d48bfddb 100644 (file)
@@ -1,5 +1,8 @@
-#ifdef REGISTER_VEHICLE
-REGISTER_VEHICLE(
+#ifndef VEHICLE_RAPTOR
+#define VEHICLE_RAPTOR
+#include "raptor.qh"
+int v_raptor(int);
+REGISTER_VEHICLE_SIMPLE(
 /* VEH_##id   */ RAPTOR,
 /* function   */ v_raptor,
 /* spawnflags */ VHF_DMGSHAKE | VHF_DMGROLL,
@@ -10,8 +13,12 @@ REGISTER_VEHICLE(
 /* tags                  */ "", "tag_hud", "tag_camera",
 /* netname       */ "raptor",
 /* fullname   */ _("Raptor")
-);
-#else
+) {
+    this.m_icon = "vehicle_raptor";
+}
+#endif
+
+#ifdef IMPLEMENTATION
 
 #ifdef SVQC
 bool autocvar_g_vehicle_raptor;
@@ -1038,7 +1045,7 @@ float v_raptor(float req)
                                default:        crosshair = vCROSS_BURST;
                        }
                        
-                       Vehicles_drawHUD("vehicle_raptor", "vehicle_raptor_weapon1", "vehicle_raptor_weapon2",
+                       Vehicles_drawHUD(VEH_RAPTOR.m_icon, "vehicle_raptor_weapon1", "vehicle_raptor_weapon2",
                                                         "vehicle_icon_ammo1", autocvar_hud_progressbar_vehicles_ammo1_color,
                                                         "vehicle_icon_ammo2", autocvar_hud_progressbar_vehicles_ammo2_color,
                                                         crosshair);
index 0aa2ebe792c0a7b58c6aac0f6bd4a8870250ba69..939dd28a63a557b5226b51b5ee12ebe9cf6087b7 100644 (file)
@@ -1,5 +1,7 @@
-#ifdef REGISTER_VEHICLE
-REGISTER_VEHICLE(
+#ifndef VEHICLE_SPIDERBOT
+#define VEHICLE_SPIDERBOT
+int v_spiderbot(int);
+REGISTER_VEHICLE_SIMPLE(
 /* VEH_##id   */ SPIDERBOT,
 /* function   */ v_spiderbot,
 /* spawnflags */ VHF_DMGSHAKE,
@@ -10,8 +12,12 @@ REGISTER_VEHICLE(
 /* tags                  */ "tag_head", "tag_hud", "",
 /* netname       */ "spiderbot",
 /* fullname   */ _("Spiderbot")
-);
-#else
+) {
+    this.m_icon = "vehicle_spider";
+}
+#endif
+
+#ifdef IMPLEMENTATION
 
 const int SBRM_FIRST = 1;
 const int SBRM_VOLLY = 1;
@@ -959,7 +965,7 @@ float v_spiderbot(float req)
                                default:             crosshair = vCROSS_BURST;
                        }
 
-                       Vehicles_drawHUD("vehicle_spider", "vehicle_spider_weapon1", "vehicle_spider_weapon2",
+                       Vehicles_drawHUD(VEH_SPIDERBOT.m_icon, "vehicle_spider_weapon1", "vehicle_spider_weapon2",
                                                         "vehicle_icon_ammo1", autocvar_hud_progressbar_vehicles_ammo1_color,
                                                         "vehicle_icon_ammo2", autocvar_hud_progressbar_vehicles_ammo2_color,
                                                         crosshair);
diff --git a/qcsrc/common/vehicles/vehicle.qh b/qcsrc/common/vehicles/vehicle.qh
new file mode 100644 (file)
index 0000000..7df3420
--- /dev/null
@@ -0,0 +1,40 @@
+#ifndef VEHICLE_H
+#define VEHICLE_H
+
+int v_null(int) { return 0; }
+
+CLASS(Vehicle, Object)
+    ATTRIB(Vehicle, vehicleid, int, 0)
+    /** hud icon */
+    ATTRIB(Vehicle, m_icon, string, string_null)
+    /** short name */
+    ATTRIB(Vehicle, netname, string, "")
+    /** human readable name */
+    ATTRIB(Vehicle, vehicle_name, string, "Vehicle")
+    /**  */
+    ATTRIB(Vehicle, vehicle_func, int(int), v_null)
+    /** full name of model */
+    ATTRIB(Vehicle, model, string, "")
+    /** currently a copy of the model */
+    ATTRIB(Vehicle, mdl, string, "")
+    /** full name of tur_head model */
+    ATTRIB(Vehicle, head_model, string, "")
+    /** cockpit model */
+    ATTRIB(Vehicle, hud_model, string, "")
+    /** tur_head model tag */
+    ATTRIB(Vehicle, tag_head, string, string_null)
+    /** hud model tag */
+    ATTRIB(Vehicle, tag_hud, string, string_null)
+    /** cockpit model tag */
+    ATTRIB(Vehicle, tag_view, string, string_null)
+    /** player physics mod */
+    ATTRIB(Vehicle, PlayerPhysplug, int(), func_null)
+    /**  */
+    ATTRIB(Vehicle, spawnflags, int, 0)
+    /** vehicle hitbox size */
+    ATTRIB(Vehicle, mins, vector, '-0 -0 -0')
+    /** vehicle hitbox size */
+    ATTRIB(Vehicle, maxs, vector, '0 0 0')
+ENDCLASS(Vehicle)
+
+#endif
diff --git a/qcsrc/common/vehicles/vehicles.qc b/qcsrc/common/vehicles/vehicles.qc
deleted file mode 100644 (file)
index e982c6f..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-#include "unit/all.qh"
-
-#include "vehicles_include.qc"
-
-// VEHICLE PLUGIN SYSTEM
-entity vehicle_info[VEH_MAXCOUNT];
-entity dummy_vehicle_info;
-
-void vehicles_common_initialize()
-{
-#ifdef CSQC
-       precache_model("models/vehicles/bomblet.md3");
-       precache_model("models/vehicles/clusterbomb.md3");
-       precache_model("models/vehicles/clusterbomb_fragment.md3");
-       precache_model("models/vehicles/rocket01.md3");
-       precache_model("models/vehicles/rocket02.md3");
-
-       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);
-       addstat(STAT_VEHICLESTAT_ENERGY,  AS_INT, vehicle_energy);
-
-       addstat(STAT_VEHICLESTAT_W2MODE, AS_INT, vehicle_weapon2mode);
-
-       addstat(STAT_VEHICLESTAT_AMMO1,   AS_INT, vehicle_ammo1);
-       addstat(STAT_VEHICLESTAT_RELOAD1, AS_INT, vehicle_reload1);
-
-       addstat(STAT_VEHICLESTAT_AMMO2,   AS_INT, vehicle_ammo2);
-       addstat(STAT_VEHICLESTAT_RELOAD2, AS_INT, vehicle_reload2);
-#endif // SVQC
-}
-
-void register_vehicle(float id, float(float) func, float vehicleflags, vector min_s, vector max_s, string modelname, string headmodelname, string hudmodelname, string headtag, string hudtag, string viewtag, string shortname, string vname)
-{
-       entity e;
-       vehicle_info[id - 1] = e = spawn();
-       e.classname = "vehicle_info";
-       e.vehicleid = id;
-       e.netname = shortname;
-       e.vehicle_name = vname;
-       e.vehicle_func = func;
-       e.mdl = modelname;
-       e.spawnflags = vehicleflags;
-       e.mins = min_s;
-       e.maxs = max_s;
-       e.model = modelname;
-       e.head_model = headmodelname;
-       e.hud_model = hudmodelname;
-       e.tag_head = headtag;
-       e.tag_hud = hudtag;
-       e.tag_view = viewtag;
-       
-       #ifndef MENUQC
-       vehicles_common_initialize();
-       #endif
-}
-float v_null(float dummy) { return 0; }
-void register_vehicles_done()
-{
-       dummy_vehicle_info = spawn();
-       dummy_vehicle_info.classname = "vehicle_info";
-       dummy_vehicle_info.vehicleid = 0; // you can recognize dummies by this
-       dummy_vehicle_info.netname = "";
-       dummy_vehicle_info.vehicle_name = "Vehicle";
-       dummy_vehicle_info.vehicle_func = v_null;
-       dummy_vehicle_info.mdl = "";
-       dummy_vehicle_info.mins = '-0 -0 -0';
-       dummy_vehicle_info.maxs = '0 0 0';
-       dummy_vehicle_info.model = "";
-       dummy_vehicle_info.head_model = "";
-       dummy_vehicle_info.hud_model = "";
-}
-entity get_vehicleinfo(float id)
-{
-       entity m;
-       if(id < VEH_FIRST || id > VEH_LAST)
-               return dummy_vehicle_info;
-       m = vehicle_info[id - 1];
-       if(m)
-               return m;
-       return dummy_vehicle_info;
-}
diff --git a/qcsrc/common/vehicles/vehicles.qh b/qcsrc/common/vehicles/vehicles.qh
deleted file mode 100644 (file)
index b0f28b5..0000000
+++ /dev/null
@@ -1,95 +0,0 @@
-#ifndef VEHICLES_H
-#define VEHICLES_H
-
-#include "sv_vehicles.qh"
-
-// vehicle requests
-const int VR_SETUP          = 1; // (BOTH) setup vehicle data
-const int VR_THINK                     = 2; // (SERVER) logic to run every frame
-const int VR_DEATH          = 3; // (SERVER) called when vehicle dies
-const int VR_PRECACHE       = 4; // (BOTH) precaches models/sounds used by this vehicle
-const int VR_ENTER          = 5; // (SERVER) called when a player enters this vehicle
-const int VR_SPAWN          = 6; // (SERVER) called when the vehicle re-spawns
-const int VR_IMPACT         = 7; // (SERVER) called when a vehicle hits something
-const int VR_HUD            = 8; // (CLIENT) logic to run every frame
-
-// vehicle spawn flags (need them here for common registrations)
-const int VHF_ISVEHICLE                        = 2; /// Indicates vehicle
-const int VHF_HASSHIELD                        = 4; /// Vehicle has shileding
-const int VHF_SHIELDREGEN              = 8; /// Vehicles shield regenerates
-const int VHF_HEALTHREGEN              = 16; /// Vehicles health regenerates
-const int VHF_ENERGYREGEN              = 32; /// Vehicles energy regenerates
-const int VHF_DEATHEJECT               = 64; /// Vehicle ejects pilot upon fatal damage
-const int VHF_MOVE_GROUND              = 128; /// Vehicle moves on gound
-const int VHF_MOVE_HOVER               = 256; /// Vehicle hover close to gound
-const int VHF_MOVE_FLY                 = 512; /// Vehicle is airborn
-const int VHF_DMGSHAKE                 = 1024; /// Add random velocity each frame if health < 50%
-const int VHF_DMGROLL                  = 2048; /// Add random angles each frame if health < 50%
-const int VHF_DMGHEADROLL              = 4096; /// Add random head angles each frame if health < 50%
-const int VHF_MULTISLOT                        = 8192; /// Vehicle has multiple player slots
-const int VHF_PLAYERSLOT               = 16384; /// This ent is a player slot on a multi-person vehicle
-
-// functions:
-entity get_vehicleinfo(float id);
-
-// fields:
-.entity tur_head;
-
-
-// entity properties of vehicleinfo:
-.int vehicleid; // VEH_...
-.string netname; // short name
-.string vehicle_name; // human readable name
-.int(int) vehicle_func; // v_...
-.string mdl; // currently a copy of the model
-.string model; // full name of model
-.string head_model; // full name of tur_head model
-.string hud_model; // cockpit model
-.string tag_head; // tur_head model tag
-.string tag_hud; // hud model tag
-.string tag_view; // cockpit model tag
-.int() PlayerPhysplug; // player physics mod
-.int spawnflags;
-.vector mins, maxs; // vehicle hitbox size
-
-// other useful macros
-#define VEH_ACTION(vehicletype,mrequest) (get_vehicleinfo(vehicletype)).vehicle_func(mrequest)
-#define VEH_NAME(vehicletype) (get_vehicleinfo(vehicletype)).vehicle_name
-
-// =====================
-//  Vehicle Registration
-// =====================
-
-int v_null(int dummy);
-void register_vehicle(int id, int(int) func, float vehicleflags, vector min_s, vector max_s, string modelname, string headmodelname, string hudmodelname, string headtag, string hudtag, string viewtag, string shortname, string vname);
-void register_vehicles_done();
-
-const int VEH_MAXCOUNT = 24;
-#define VEH_FIRST 1
-int VEH_COUNT;
-int VEH_LAST;
-
-#define REGISTER_VEHICLE_2(id,func,vehicleflags,min_s,max_s,modelname,headmodelname,hudmodelname,headtag,hudtag,viewtag,shortname,vname) \
-       int id; \
-       int func(int); \
-       void RegisterVehicles_##id() \
-       { \
-               VEH_LAST = (id = VEH_FIRST + VEH_COUNT); \
-               ++VEH_COUNT; \
-               register_vehicle(id,func,vehicleflags,min_s,max_s,modelname,headmodelname,hudmodelname,headtag,hudtag,viewtag,shortname,vname); \
-       } \
-       ACCUMULATE_FUNCTION(RegisterVehicles, RegisterVehicles_##id)
-#ifdef MENUQC
-#define REGISTER_VEHICLE(id,func,vehicleflags,min_s,max_s,modelname,headmodelname,hudmodelname,headtag,hudtag,viewtag,shortname,vname) \
-       REGISTER_VEHICLE_2(VEH_##id,v_null,vehicleflags,min_s,max_s,modelname,headmodelname,hudmodelname,headtag,hudtag,viewtag,shortname,vname)
-#else
-#define REGISTER_VEHICLE(id,func,vehicleflags,min_s,max_s,modelname,headmodelname,hudmodelname,headtag,hudtag,viewtag,shortname,vname) \
-       REGISTER_VEHICLE_2(VEH_##id,func,vehicleflags,min_s,max_s,modelname,headmodelname,hudmodelname,headtag,hudtag,viewtag,shortname,vname)
-#endif
-
-#include "unit/all.qh"
-
-#undef REGISTER_VEHICLE
-ACCUMULATE_FUNCTION(RegisterVehicles, register_vehicles_done);
-
-#endif
diff --git a/qcsrc/common/vehicles/vehicles_include.qc b/qcsrc/common/vehicles/vehicles_include.qc
deleted file mode 100644 (file)
index 1bd181d..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-#ifndef VEHICLES_INCLUDE_C
-#define VEHICLES_INCLUDE_C
-
-#include "vehicles_include.qh"
-
-#ifdef CSQC
-#include "cl_vehicles.qc"
-#include "vehicles.qc"
-#endif // CSQC
-#ifdef SVQC
-#include "sv_vehicles.qc"
-#include "vehicles.qc"
-#endif // SVQC
-
-#endif
diff --git a/qcsrc/common/vehicles/vehicles_include.qh b/qcsrc/common/vehicles/vehicles_include.qh
deleted file mode 100644 (file)
index 26e52e4..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-#ifndef VEHICLES_INCLUDE_H
-#define VEHICLES_INCLUDE_H
-
-#include "all.qh"
-
-#ifdef CSQC
-#include "vehicles.qh"
-#include "cl_vehicles.qh"
-#elif defined(SVQC)
-#include "vehicles.qh"
-#include "sv_vehicles.qh"
-#endif // SVQC
-
-#endif
index 64f12478ddeb9bff3fe171e50bf8f5e2480f5aa8..2bde451f8dc381aa80209319872bda56b69427be 100644 (file)
@@ -23,10 +23,9 @@ xonotic/util.qc
 ../common/util.qc
 
 ../common/items/all.qc
-
 ../common/monsters/all.qc
-
-../common/weapons/all.qc // TODO
+../common/vehicles/all.qc
+../common/weapons/all.qc
 
 ../warpzonelib/mathlib.qc
 
index 95495016416ccf2e4424eeaddb8674a5f4d4e67a..c51d3cf5ba536d01e5237da5fb2fe069adc5891a 100644 (file)
@@ -3,8 +3,7 @@
 #elif defined(SVQC)
        #include "../dpdefs/progsdefs.qh"
     #include "../dpdefs/dpextensions.qh"
-    #include "../common/vehicles/sv_vehicles.qh"
-    #include "../common/vehicles/vehicles.qh"
+    #include "../common/vehicles/all.qh"
     #include "antilag.qh"
 #endif
 
index 09d57986fd5085022a8da36aa0af435c1143d0d0..81ea03e0eb4bf7556b3a01899947b8c788dfef3f 100644 (file)
@@ -25,7 +25,7 @@
 #include "bot/bot.qh"
 #include "bot/navigation.qh"
 
-#include "../common/vehicles/sv_vehicles.qh"
+#include "../common/vehicles/all.qh"
 
 #include "weapons/hitplot.qh"
 #include "weapons/weaponsystem.qh"
index 9bc36c8df8098fe7c37ca22ae4977794bcd46b40..e3bb91e3954bfe112009a2d0a28d2549797993f0 100644 (file)
@@ -492,6 +492,7 @@ void PlayerDamage (entity inflictor, entity attacker, float damage, int deathtyp
                dh = dh - max(self.health, 0);
                da = da - max(self.armorvalue, 0);
                WeaponStats_LogDamage(awep, abot, self.weapon, vbot, dh + da);
+               MUTATOR_CALLHOOK(PlayerDamaged, attacker, self, dh, da, hitloc);
        }
 
        if (self.health < 1)
index 8672c3a292ac324fcf1f81c03a150a3e58149099..a9bd70763157429025a11cf2d16fa7e69144c661 100644 (file)
@@ -16,7 +16,7 @@
 #include "../mutators/mutators_include.qh"
 
 #ifdef SVQC
-       #include "../../common/vehicles/sv_vehicles.qh"
+       #include "../../common/vehicles/all.qh"
 #endif
 
 #include "../../common/constants.qh"
index ba9ed8898a1a59793f9a1e38f7706a62a5c25752..9791bbd2933ceac46d4e54e91fc7f0a6132978ad 100644 (file)
@@ -7,7 +7,7 @@
 #include "waypointsprites.qh"
 #include "spawnpoints.qh"
 #include "t_items.qh"
-#include "../common/vehicles/sv_vehicles.qh"
+#include "../common/vehicles/all.qh"
 #include "weapons/accuracy.qh"
 #include "weapons/csqcprojectile.qh"
 #include "weapons/selection.qh"
@@ -844,7 +844,7 @@ void Damage (entity targ, entity inflictor, entity attacker, float damage, int d
                        else
                                victim = targ;
 
-                       if(IS_PLAYER(victim) || (IS_TURRET(victim) && victim.active == ACTIVE_ACTIVE) || IS_MONSTER(victim))
+                       if(IS_PLAYER(victim) || (IS_TURRET(victim) && victim.active == ACTIVE_ACTIVE) || IS_MONSTER(victim) || MUTATOR_CALLHOOK(PlayHitsound, victim))
                        {
                                if(DIFF_TEAM(victim, attacker) && !victim.frozen)
                                {
index a7916957d3f4c6c50153e4b573a322c48c8be847..8d7db7f5dcf05a46e3804b0acf2d5aa16de0731d 100644 (file)
@@ -22,7 +22,7 @@
     #include "../common/deathtypes.qh"
     #include "mutators/mutators_include.qh"
     #include "../common/turrets/sv_turrets.qh"
-    #include "../common/vehicles/sv_vehicles.qh"
+    #include "../common/vehicles/all.qh"
     #include "../csqcmodellib/sv_model.qh"
     #include "../common/playerstats.qh"
     #include "g_hook.qh"
index e28b9b2ae7ad47c3112857a1ebcc642d3e638ae9..71c32df3989edf357f88fe4e69cdba0d38bc61b9 100644 (file)
@@ -8,7 +8,7 @@
 #include "cl_player.qh"
 #include "command/common.qh"
 #include "round_handler.qh"
-#include "../common/vehicles/sv_vehicles.qh"
+#include "../common/vehicles/all.qh"
 #include "../common/constants.qh"
 #include "../common/util.qh"
 #include "../common/weapons/all.qh"
index 70a31dfdc227492f2116be66d1a2c7b2acd4cddc..23c746af58c2a5e3ad2f935426624c3fca743d4f 100644 (file)
@@ -27,7 +27,7 @@
 #include "../common/mapinfo.qh"
 #include "../common/monsters/all.qh"
 #include "../common/monsters/sv_monsters.qh"
-#include "../common/vehicles/vehicles.qh"
+#include "../common/vehicles/all.qh"
 #include "../common/notifications.qh"
 #include "../common/playerstats.qh"
 #include "../common/stats.qh"
@@ -566,7 +566,6 @@ void spawnfunc___init_dedicated_server(void)
        CALL_ACCUMULATED_FUNCTION(RegisterNotifications);
        CALL_ACCUMULATED_FUNCTION(RegisterDeathtypes);
        CALL_ACCUMULATED_FUNCTION(RegisterEffects);
-       CALL_ACCUMULATED_FUNCTION(RegisterVehicles);
 
        MapInfo_Enumerate();
        MapInfo_FilterGametype(MapInfo_CurrentGametype(), MapInfo_CurrentFeatures(), MapInfo_RequiredFlags(), MapInfo_ForbiddenFlags(), 0);
@@ -616,7 +615,6 @@ void spawnfunc_worldspawn (void)
        CALL_ACCUMULATED_FUNCTION(RegisterNotifications);
        CALL_ACCUMULATED_FUNCTION(RegisterDeathtypes);
        CALL_ACCUMULATED_FUNCTION(RegisterEffects);
-       CALL_ACCUMULATED_FUNCTION(RegisterVehicles);
 
        ServerProgsDB = db_load(strcat("server.db", autocvar_sessionid));
 
index ab652d1b4f661df4e69acec055a40a2be7296fab..ec9e9c99a90dc5dd52c9f1fae1b2e976259f583f 100644 (file)
@@ -56,6 +56,13 @@ entity frag_target;
 int frag_deathtype;
 MUTATOR_HOOKABLE(PlayerDies, EV_PlayerDies);
 
+/** called when a player dies to e.g. remove stuff he was carrying. */
+#define EV_PlayHitsound(i, o) \
+    /**/ i(entity, frag_victim) \
+    /**/
+entity frag_victim;
+MUTATOR_HOOKABLE(PlayHitsound, EV_PlayHitsound);
+
 /** called when a player presses the jump key */
 #define EV_PlayerJump(i, o) \
     /**/ i(float, player_multijump) \
@@ -253,6 +260,18 @@ float frag_mirrordamage;
 vector frag_force;
 MUTATOR_HOOKABLE(PlayerDamage_Calculate, EV_PlayerDamage_Calculate);
 
+/**
+ * Called when a player is damaged
+ */
+#define EV_PlayerDamaged(i, o) \
+    /** attacker */ i(entity, mutator_argv_entity_0) \
+    /** target */ i(entity, mutator_argv_entity_1) \
+    /** health */ i(int, mutator_argv_int_0) \
+    /** armor */ i(int, mutator_argv_int_1) \
+    /** location */ i(vector, mutator_argv_vector_0) \
+    /**/
+MUTATOR_HOOKABLE(PlayerDamaged, EV_PlayerDamaged);
+
 /** called at the end of player_powerups() in cl_client.qc, used for manipulating the values which are set by powerup items. */
 #define EV_PlayerPowerups(i, o) \
     /**/ i(entity, self) \
index 5df056905433fe7e07b559f3c80580e3b40296ae..4700c57d87e94501159972903b3200b617fce604 100644 (file)
@@ -572,6 +572,11 @@ MUTATOR_HOOKFUNCTION(assault_BotRoles)
        return true;
 }
 
+MUTATOR_HOOKFUNCTION(assault_PlayHitsound)
+{
+       return (frag_victim.classname == "func_assault_destructible");
+}
+
 // scoreboard setup
 void assault_ScoreRules()
 {
@@ -587,6 +592,7 @@ MUTATOR_DEFINITION(gamemode_assault)
        MUTATOR_HOOK(TurretSpawn, assault_TurretSpawn, CBC_ORDER_ANY);
        MUTATOR_HOOK(VehicleSpawn, assault_VehicleSpawn, CBC_ORDER_ANY);
        MUTATOR_HOOK(HavocBot_ChooseRole, assault_BotRoles, CBC_ORDER_ANY);
+       MUTATOR_HOOK(PlayHitsound, assault_PlayHitsound, CBC_ORDER_ANY);
 
        MUTATOR_ONADD
        {
index 31d21116a483e1a1a0b0d6dabfd340427cef08df..4ebd27a456e4ecc40d646745b9a310933b95675a 100644 (file)
@@ -4,7 +4,7 @@
 #include "gamemode.qh"
 
 #ifdef SVQC
-#include "../../common/vehicles/sv_vehicles.qh"
+#include "../../common/vehicles/all.qh"
 #endif
 
 #include "../../warpzonelib/common.qh"
index 06b65cad589df7aaec2c0af0753862fc61e25841..f5ca947f7a88cf2cbd4ea2846eea16730bf2deda 100644 (file)
@@ -1704,6 +1704,12 @@ MUTATOR_HOOKFUNCTION(ons_MonsterSpawn)
        return false;
 }
 
+MUTATOR_HOOKFUNCTION(ons_PlayHitsound)
+{
+       return (frag_victim.classname == "onslaught_generator" && !frag_victim.isshielded)
+               || (frag_victim.classname == "onslaught_controlpoint_icon" && !frag_victim.owner.isshielded);
+}
+
 MUTATOR_DEFINITION(gamemode_onslaught)
 {
        MUTATOR_HOOK(BuildMutatorsPrettyString, ons_BuildMutatorsPrettyString, CBC_ORDER_ANY);
@@ -1712,6 +1718,7 @@ MUTATOR_DEFINITION(gamemode_onslaught)
        MUTATOR_HOOK(TurretSpawn, ons_TurretSpawn, CBC_ORDER_ANY);
        MUTATOR_HOOK(MonsterMove, ons_MonsterThink, CBC_ORDER_ANY);
        MUTATOR_HOOK(MonsterSpawn, ons_MonsterSpawn, CBC_ORDER_ANY);
+       MUTATOR_HOOK(PlayHitsound, ons_PlayHitsound, CBC_ORDER_ANY);
        //MUTATOR_HOOK(Spawn_Score, ons_Spawn_Score, CBC_ORDER_ANY);
 
        MUTATOR_ONADD
index 7a241e4e750e2bbd532072998cdcc41a7c25cb09..3129af92fab7b677150a3079c500de194ef8cdf6 100644 (file)
@@ -46,7 +46,7 @@
     #include "../../common/deathtypes.qh"
     #include "mutators_include.qh"
     #include "../../common/turrets/sv_turrets.qh"
-    #include "../../common/vehicles/sv_vehicles.qh"
+    #include "../../common/vehicles/all.qh"
     #include "../campaign.qh"
     #include "../../common/campaign_common.qh"
     #include "../../common/mapinfo.qh"
@@ -75,7 +75,7 @@
     #include "../round_handler.qh"
     #include "../item_key.qh"
     #include "../pathlib/pathlib.qh"
-    #include "../../common/vehicles/vehicles.qh"
+    #include "../../common/vehicles/all.qh"
 #endif
 
 #include "../../common/mutators/base.qh"
index 10113b0de0caf2515e3013f917b01c24f894681d..16769c8a6a1fe94b038ff2365fdcb9895bc4c88e 100644 (file)
@@ -87,7 +87,6 @@ weapons/weaponsystem.qc
 ../common/campaign_setup.qc
 ../common/effects.qc
 ../common/mapinfo.qc
-../common/monsters/all.qc
 ../common/monsters/spawn.qc
 ../common/monsters/sv_monsters.qc
 ../common/movetypes/include.qc
@@ -102,9 +101,12 @@ weapons/weaponsystem.qc
 ../common/triggers/include.qc
 ../common/urllib.qc
 ../common/util.qc
-../common/vehicles/vehicles_include.qc
 
 ../common/items/all.qc
+../common/monsters/all.qc
+../common/mutators/all.qc
+../common/vehicles/all.qc
+../common/weapons/all.qc // TODO
 
 ../common/turrets/sv_turrets.qc
 ../common/turrets/config.qc
@@ -113,7 +115,6 @@ weapons/weaponsystem.qc
 ../common/turrets/checkpoint.qc
 ../common/turrets/targettrigger.qc
 ../common/weapons/config.qc
-../common/weapons/all.qc // TODO
 
 ../csqcmodellib/sv_model.qc
 
index 9e4296539e9f72f983664c7b295af25aea97182f..18ea24d9498327546a90c07eb83f3ca182cc4f2d 100644 (file)
@@ -17,7 +17,7 @@
 #include "../common/mapinfo.qh"
 #include "../common/util.qh"
 
-#include "../common/vehicles/sv_vehicles.qh"
+#include "../common/vehicles/all.qh"
 #include "../common/weapons/all.qh"
 
 #include "../csqcmodellib/sv_model.qh"