]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Hack item models
authorMario <zacjardine@y7mail.com>
Mon, 24 Aug 2015 06:03:13 +0000 (16:03 +1000)
committerMario <zacjardine@y7mail.com>
Mon, 24 Aug 2015 06:03:13 +0000 (16:03 +1000)
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/powerup.qc
qcsrc/server/mutators/events.qh
qcsrc/server/mutators/mutator_instagib_items.qc
qcsrc/server/t_items.qc
qcsrc/server/weapons/spawning.qc

index 84c22cdcd24ebde82902831848671affeb66124f..2d487a7b51be6723a030f44af5e14d5997da9883 100644 (file)
@@ -4,7 +4,7 @@
 #endif
 
 REGISTER_ITEM(Bullets, Ammo) {
-    this.m_model    =   "models/items/a_bullets.mdl";
+    this.m_model    =   "a_bullets.mdl";
     this.m_name     =   "bullets";
     this.m_icon     =   "ammo_bullets";
 #ifdef SVQC
@@ -13,7 +13,7 @@ REGISTER_ITEM(Bullets, Ammo) {
 #endif
 }
 REGISTER_ITEM(Cells, Ammo) {
-    this.m_model    =   "models/items/a_cells.md3";
+    this.m_model    =   "a_cells.md3";
     this.m_name     =   "cells";
     this.m_icon     =   "ammo_cells";
 #ifdef SVQC
@@ -22,7 +22,7 @@ REGISTER_ITEM(Cells, Ammo) {
 #endif
 }
 REGISTER_ITEM(Plasma, Ammo) {
-    this.m_model    =   "models/items/a_cells.md3";
+    this.m_model    =   "a_cells.md3";
     this.m_name     =   "plasma";
     this.m_icon     =   "ammo_plasma";
 #ifdef SVQC
@@ -31,7 +31,7 @@ REGISTER_ITEM(Plasma, Ammo) {
 #endif
 }
 REGISTER_ITEM(Rockets, Ammo) {
-    this.m_model    =   "models/items/a_rockets.md3";
+    this.m_model    =   "a_rockets.md3";
     this.m_name     =   "rockets";
     this.m_icon     =   "ammo_rockets";
 #ifdef SVQC
@@ -40,7 +40,7 @@ REGISTER_ITEM(Rockets, Ammo) {
 #endif
 }
 REGISTER_ITEM(Shells, Ammo) {
-    this.m_model    =   "models/items/a_shells.md3";
+    this.m_model    =   "a_shells.md3";
     this.m_name     =   "shells";
     this.m_icon     =   "ammo_shells";
 #ifdef SVQC
index a4fa605740f75e8e5f821752b50495d32d7bb8f2..4b6b75a6615472c2308f4f2cf2db7961123f2aab 100644 (file)
@@ -4,7 +4,7 @@
 #endif
 
 REGISTER_ITEM(ArmorSmall, Armor) {
-    this.m_model                =   "models/items/item_armor_small.md3";
+    this.m_model                =   "item_armor_small.md3";
     this.m_sound                =   "misc/armor1.wav";
     this.m_name                 =   "5 Armor";
     this.m_icon                 =   "armor";
@@ -17,7 +17,7 @@ REGISTER_ITEM(ArmorSmall, Armor) {
 }
 
 REGISTER_ITEM(ArmorMedium, Armor) {
-    this.m_model                =   "models/items/item_armor_medium.md3";
+    this.m_model                =   "item_armor_medium.md3";
     this.m_sound                =   "misc/armor10.wav";
     this.m_name                 =   "25 Armor";
     this.m_icon                 =   "armor";
@@ -30,7 +30,7 @@ REGISTER_ITEM(ArmorMedium, Armor) {
 }
 
 REGISTER_ITEM(ArmorLarge, Armor) {
-    this.m_model                =   "models/items/item_armor_big.md3";
+    this.m_model                =   "item_armor_big.md3";
     this.m_sound                =   "misc/armor17_5.wav";
     this.m_name                 =   "50 Armor";
     this.m_icon                 =   "armor";
@@ -43,7 +43,7 @@ REGISTER_ITEM(ArmorLarge, Armor) {
 }
 
 REGISTER_ITEM(ArmorMega, Armor) {
-    this.m_model                =   "models/items/item_armor_large.md3";
+    this.m_model                =   "item_armor_large.md3";
     this.m_sound                =   "misc/armor25.wav";
     this.m_name                 =   "100 Armor";
     this.m_icon                 =   "item_large_armor";
index dded21951f8b255c312bc74897405b7603a99848..9d06b6c2fec8730fe67d4400f5d8d0ae960acb47 100644 (file)
@@ -4,7 +4,7 @@
 #endif
 
 REGISTER_ITEM(HealthSmall, Health) {
-    this.m_model                =   "models/items/g_h1.md3";
+    this.m_model                =   "g_h1.md3";
     this.m_sound                =   "misc/minihealth.wav";
     this.m_name                 =   "5 Health";
     this.m_icon                 =   "health";
@@ -17,7 +17,7 @@ REGISTER_ITEM(HealthSmall, Health) {
 }
 
 REGISTER_ITEM(HealthMedium, Health) {
-    this.m_model                =   "models/items/g_h25.md3";
+    this.m_model                =   "g_h25.md3";
     this.m_sound                =   "misc/mediumhealth.wav";
     this.m_name                 =   "25 Health";
     this.m_icon                 =   "health";
@@ -30,7 +30,7 @@ REGISTER_ITEM(HealthMedium, Health) {
 }
 
 REGISTER_ITEM(HealthLarge, Health) {
-    this.m_model                =   "models/items/g_h50.md3";
+    this.m_model                =   "g_h50.md3";
     this.m_sound                =   "misc/mediumhealth.wav";
     this.m_name                 =   "50 Health";
     this.m_icon                 =   "health";
@@ -43,7 +43,7 @@ REGISTER_ITEM(HealthLarge, Health) {
 }
 
 REGISTER_ITEM(HealthMega, Health) {
-    this.m_model                =   "models/items/g_h100.md3";
+    this.m_model                =   "g_h100.md3";
     this.m_sound                =   "misc/megahealth.wav";
     this.m_name                 =   "100 Health";
     this.m_icon                 =   "item_mega_health";
index 856704dd840e4c4964a2b3867c7ce091ac83d931..b45e1c18e18a08bf13759964bdebf68922da9018 100644 (file)
@@ -7,7 +7,7 @@
 #include "powerup.qh"
 
 REGISTER_ITEM(Jetpack, Powerup) {
-    this.m_model                =   "models/items/g_jetpack.md3";
+    this.m_model                =   "g_jetpack.md3";
     this.m_name                 =   "Jet pack";
     this.m_icon                 =   "jetpack";
 #ifdef SVQC
@@ -18,7 +18,7 @@ REGISTER_ITEM(Jetpack, Powerup) {
 }
 
 REGISTER_ITEM(JetpackFuel, Ammo) {
-    this.m_model    =   "models/items/g_fuel.md3";
+    this.m_model    =   "g_fuel.md3";
     this.m_name     =   "Fuel";
     this.m_icon     =   "ammo_fuel";
 #ifdef SVQC
@@ -28,7 +28,7 @@ REGISTER_ITEM(JetpackFuel, Ammo) {
 }
 
 REGISTER_ITEM(JetpackRegen, Pickup) {
-    this.m_model                =   "models/items/g_fuelregen.md3";
+    this.m_model                =   "g_fuelregen.md3";
     this.m_name                 =   "Fuel regenerator";
     this.m_icon                 =   "fuelregen";
 #ifdef SVQC
index fe325821189cc2d682b27a3aaba974a9bc4c2431..bc4ff8ddd859878ca5e8ad9cd244d9082009dd26 100644 (file)
@@ -5,14 +5,14 @@
 .int m_itemid;
 #endif
 REGISTER_ITEM(Strength, Powerup) {
-    this.m_model    =   "models/items/g_strength.md3";
+    this.m_model    =   "g_strength.md3";
     this.m_sound    =   "misc/powerup.wav";
     this.m_name     =   "Strength Powerup";
     this.m_icon     =   "strength";
     this.m_itemid   =   IT_STRENGTH;
 }
 REGISTER_ITEM(Shield, Powerup) {
-    this.m_model    =   "models/items/g_invincible.md3";
+    this.m_model    =   "g_invincible.md3";
     this.m_sound    =   "misc/powerup_shield.wav";
     this.m_name     =   "Shield";
     this.m_icon     =   "shield";
index 0f93f2ebfaa2f94037cfec79a0128abd0f0fab06..71542d543646272a29184fefad9194f175e475f3 100644 (file)
@@ -83,6 +83,16 @@ string weapon_model;
 string weapon_model_output;
 MUTATOR_HOOKABLE(WeaponModel, EV_WeaponModel);
 
+/** called when an item model is about to be set, allows custom paths etc. */
+#define EV_ItemModel(i, o) \
+    /**/ i(string, item_model) \
+    /**/ i(string, item_model_output) \
+    /**/ o(string, item_model_output) \
+    /**/
+string item_model;
+string item_model_output;
+MUTATOR_HOOKABLE(ItemModel, EV_ItemModel);
+
 /** called when a player presses the jump key */
 #define EV_PlayerJump(i, o) \
     /**/ i(float, player_multijump) \
index 1d806e6796e13706951be7f96311341d93a11999..339dc49aa5365f0e5f672fa520d1458acafffc79 100644 (file)
@@ -9,7 +9,7 @@ GETTER(float, instagib_respawntime_ammo)
 GETTER(float, instagib_respawntimejitter_ammo)
 
 REGISTER_ITEM(VaporizerCells, Ammo) {
-    this.m_model                =   "models/items/a_cells.md3";
+    this.m_model                =   "a_cells.md3";
     this.m_sound                =   "misc/itempickup.wav";
     this.m_name                 =   "Vaporizer Ammo";
     this.m_icon                 =   "ammo_supercells";
@@ -22,7 +22,7 @@ REGISTER_ITEM(VaporizerCells, Ammo) {
 }
 
 REGISTER_ITEM(ExtraLife, Powerup) {
-    this.m_model                =   "models/items/g_h100.md3";
+    this.m_model                =   "g_h100.md3";
     this.m_sound                =   "misc/megahealth.wav";
     this.m_name                 =   "Extralife";
     this.m_icon                 =   "item_mega_health";
index 18d8c19aa562f2667ae669e4ce3249c5cb9480d4..4ee0add84ff89953f4e392e34e705062a8a0fdde 100644 (file)
@@ -174,12 +174,12 @@ void ItemRead(float _IsNew)
                 self.mdl = strzone(sprintf("%s%s.dpm", _fn2, autocvar_cl_simpleitems_postfix));
             else if(fexists(sprintf("%s%s.iqm", _fn2, autocvar_cl_simpleitems_postfix)))
                 self.mdl = strzone(sprintf("%s%s.iqm", _fn2, autocvar_cl_simpleitems_postfix));
-            else if(fexists(sprintf("%s%s.obj", _fn2, autocvar_cl_simpleitems_postfix)))
-                self.mdl = strzone(sprintf("%s%s.obj", _fn2, autocvar_cl_simpleitems_postfix));
+            else if(fexists(sprintf("%s%s.mdl", _fn2, autocvar_cl_simpleitems_postfix)))
+                self.mdl = strzone(sprintf("%s%s.mdl", _fn2, autocvar_cl_simpleitems_postfix));
             else
             {
                 self.draw = ItemDraw;
-                dprint("Simple item requested for ", _fn, " but no model exsist for it\n");
+                dprint("Simple item requested for ", _fn, " but no model exists for it\n");
             }
         }
 
@@ -1365,10 +1365,17 @@ void StartItem (string itemmodel, string pickupsound, float defaultrespawntime,
        }
 }
 
+string Item_Model(string item_mdl)
+{
+       string output = strcat("models/items/", item_mdl);
+       MUTATOR_CALLHOOK(ItemModel, item_mdl, output);
+       return strzone(output);
+}
+
 void StartItemA (entity a)
 {
     self.itemdef = a;
-    StartItem(a.m_model, a.m_sound, a.m_respawntime(), a.m_respawntimejitter(), a.m_name, a.m_itemid, 0, a.m_itemflags, a.m_pickupevalfunc, a.m_botvalue);
+    StartItem(Item_Model(a.m_model), a.m_sound, a.m_respawntime(), a.m_respawntimejitter(), a.m_name, a.m_itemid, 0, a.m_itemflags, a.m_pickupevalfunc, a.m_botvalue);
 }
 
 void spawnfunc_item_rockets (void) {
@@ -1520,7 +1527,7 @@ void spawnfunc_item_health25() { spawnfunc_item_health_medium(); }
 void spawnfunc_item_health100() { spawnfunc_item_health_mega(); }
 
 void spawnfunc_item_strength (void) {
-               precache_sound(W_Sound("strength_fire"));
+               precache_sound("weapons/strength_fire.wav");
                if(!self.strength_finished)
                        self.strength_finished = autocvar_g_balance_powerup_strength_time;
                StartItemA (ITEM_Strength);
index d6d158f49b44702c53bda89a849e33ea9229de08..8e7810bbb117de338ed62dc6a32e6684466e8f1e 100644 (file)
@@ -179,7 +179,7 @@ void weapon_defaultspawnfunc(float wpn)
        if(self.team)
                f |= FL_NO_WEAPON_STAY;
 
-       StartItem(e.model, W_Sound("weaponpickup"), self.respawntime, self.respawntimejitter, e.message, 0, e.weapon, f, weapon_pickupevalfunc, e.bot_pickupbasevalue);
+       StartItem(e.model, "weapons/weaponpickup.wav", self.respawntime, self.respawntimejitter, e.message, 0, e.weapon, f, weapon_pickupevalfunc, e.bot_pickupbasevalue);
        #if 0 // WEAPONTODO
        if (self.modelindex) // don't precache if self was removed
                WEP_ACTION(e.weapon, WR_INIT);