From b13f0907bb1f099662521558e8af590faf4984a8 Mon Sep 17 00:00:00 2001 From: Mario Date: Mon, 24 Aug 2015 16:03:13 +1000 Subject: [PATCH] Hack item models --- qcsrc/common/items/item/ammo.qc | 10 +++++----- qcsrc/common/items/item/armor.qc | 8 ++++---- qcsrc/common/items/item/health.qc | 8 ++++---- qcsrc/common/items/item/jetpack.qc | 6 +++--- qcsrc/common/items/item/powerup.qc | 4 ++-- qcsrc/server/mutators/events.qh | 10 ++++++++++ qcsrc/server/mutators/mutator_instagib_items.qc | 4 ++-- qcsrc/server/t_items.qc | 17 ++++++++++++----- qcsrc/server/weapons/spawning.qc | 2 +- 9 files changed, 43 insertions(+), 26 deletions(-) diff --git a/qcsrc/common/items/item/ammo.qc b/qcsrc/common/items/item/ammo.qc index 84c22cdcd..2d487a7b5 100644 --- a/qcsrc/common/items/item/ammo.qc +++ b/qcsrc/common/items/item/ammo.qc @@ -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 diff --git a/qcsrc/common/items/item/armor.qc b/qcsrc/common/items/item/armor.qc index a4fa60574..4b6b75a66 100644 --- a/qcsrc/common/items/item/armor.qc +++ b/qcsrc/common/items/item/armor.qc @@ -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"; diff --git a/qcsrc/common/items/item/health.qc b/qcsrc/common/items/item/health.qc index dded21951..9d06b6c2f 100644 --- a/qcsrc/common/items/item/health.qc +++ b/qcsrc/common/items/item/health.qc @@ -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"; diff --git a/qcsrc/common/items/item/jetpack.qc b/qcsrc/common/items/item/jetpack.qc index 856704dd8..b45e1c18e 100644 --- a/qcsrc/common/items/item/jetpack.qc +++ b/qcsrc/common/items/item/jetpack.qc @@ -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 diff --git a/qcsrc/common/items/item/powerup.qc b/qcsrc/common/items/item/powerup.qc index fe3258211..bc4ff8ddd 100644 --- a/qcsrc/common/items/item/powerup.qc +++ b/qcsrc/common/items/item/powerup.qc @@ -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"; diff --git a/qcsrc/server/mutators/events.qh b/qcsrc/server/mutators/events.qh index 0f93f2ebf..71542d543 100644 --- a/qcsrc/server/mutators/events.qh +++ b/qcsrc/server/mutators/events.qh @@ -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) \ diff --git a/qcsrc/server/mutators/mutator_instagib_items.qc b/qcsrc/server/mutators/mutator_instagib_items.qc index 1d806e679..339dc49aa 100644 --- a/qcsrc/server/mutators/mutator_instagib_items.qc +++ b/qcsrc/server/mutators/mutator_instagib_items.qc @@ -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"; diff --git a/qcsrc/server/t_items.qc b/qcsrc/server/t_items.qc index 18d8c19aa..4ee0add84 100644 --- a/qcsrc/server/t_items.qc +++ b/qcsrc/server/t_items.qc @@ -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); diff --git a/qcsrc/server/weapons/spawning.qc b/qcsrc/server/weapons/spawning.qc index d6d158f49..8e7810bbb 100644 --- a/qcsrc/server/weapons/spawning.qc +++ b/qcsrc/server/weapons/spawning.qc @@ -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); -- 2.39.2