From: TimePath Date: Sun, 27 Sep 2015 03:14:37 +0000 (+1000) Subject: Items: Use model registry X-Git-Tag: xonotic-v0.8.2~1909 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=b686b95dc447f7308fc4e45e75fed4603d264872;p=xonotic%2Fxonotic-data.pk3dir.git Items: Use model registry --- diff --git a/qcsrc/common/items/all.qc b/qcsrc/common/items/all.qc index fc225cdb7..8a9e31402 100644 --- a/qcsrc/common/items/all.qc +++ b/qcsrc/common/items/all.qc @@ -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 diff --git a/qcsrc/common/items/all.qh b/qcsrc/common/items/all.qh index 2e33119fb..3f8c603e7 100644 --- a/qcsrc/common/items/all.qh +++ b/qcsrc/common/items/all.qh @@ -11,6 +11,10 @@ REGISTER_REGISTRY(RegisterItems) void Dump_Items(); +#ifndef MENUQC +string Item_Model(string item_mdl); +#endif + #endif #include "inventory.qh" diff --git a/qcsrc/common/items/item/ammo.qc b/qcsrc/common/items/item/ammo.qc index 2d487a7b5..16673711e 100644 --- a/qcsrc/common/items/item/ammo.qc +++ b/qcsrc/common/items/item/ammo.qc @@ -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 diff --git a/qcsrc/common/items/item/armor.qc b/qcsrc/common/items/item/armor.qc index e7965803e..13a774ebc 100644 --- a/qcsrc/common/items/item/armor.qc +++ b/qcsrc/common/items/item/armor.qc @@ -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"; diff --git a/qcsrc/common/items/item/health.qc b/qcsrc/common/items/item/health.qc index bb9d90eb4..b81bde7af 100644 --- a/qcsrc/common/items/item/health.qc +++ b/qcsrc/common/items/item/health.qc @@ -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"; diff --git a/qcsrc/common/items/item/jetpack.qc b/qcsrc/common/items/item/jetpack.qc index 3b4cfbc14..63019aebe 100644 --- a/qcsrc/common/items/item/jetpack.qc +++ b/qcsrc/common/items/item/jetpack.qc @@ -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'; diff --git a/qcsrc/common/items/item/pickup.qh b/qcsrc/common/items/item/pickup.qh index 793230e35..6f60337c1 100644 --- a/qcsrc/common/items/item/pickup.qh +++ b/qcsrc/common/items/item/pickup.qh @@ -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)); diff --git a/qcsrc/common/items/item/powerup.qc b/qcsrc/common/items/item/powerup.qc index fcfe2afb9..f411d748a 100644 --- a/qcsrc/common/items/item/powerup.qc +++ b/qcsrc/common/items/item/powerup.qc @@ -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"; diff --git a/qcsrc/server/mutators/mutator_instagib_items.qc b/qcsrc/server/mutators/mutator_instagib_items.qc index 8beec7db2..87abd78a2 100644 --- a/qcsrc/server/mutators/mutator_instagib_items.qc +++ b/qcsrc/server/mutators/mutator_instagib_items.qc @@ -5,8 +5,14 @@ float instagib_respawntimejitter_ammo = 0; GETTER(float, instagib_respawntime_ammo) GETTER(float, instagib_respawntimejitter_ammo) +#ifndef MENUQC +MODEL(VaporizerCells_ITEM, Item_Model("a_cells.md3")); +#endif + REGISTER_ITEM(VaporizerCells, Ammo) { - this.m_model = "a_cells.md3"; +#ifndef MENUQC + this.m_model = MDL_VaporizerCells_ITEM; +#endif this.m_sound = "misc/itempickup.wav"; this.m_name = "Vaporizer Ammo"; this.m_icon = "ammo_supercells"; @@ -18,8 +24,14 @@ REGISTER_ITEM(VaporizerCells, Ammo) { #endif } +#ifndef MENUQC +MODEL(ExtraLife_ITEM, Item_Model("g_h100.md3")); +#endif + REGISTER_ITEM(ExtraLife, Powerup) { - this.m_model = "g_h100.md3"; +#ifndef MENUQC + this.m_model = MDL_ExtraLife_ITEM; +#endif this.m_sound = "misc/megahealth.wav"; this.m_name = "Extra life"; this.m_icon = "item_mega_health"; @@ -29,8 +41,14 @@ REGISTER_ITEM(ExtraLife, Powerup) { this.m_itemid = IT_NAILS; } +#ifndef MENUQC +MODEL(Invisibility_ITEM, Item_Model("g_strength.md3")); +#endif + REGISTER_ITEM(Invisibility, Powerup) { - this.m_model = "g_strength.md3"; +#ifndef MENUQC + this.m_model = MDL_Invisibility_ITEM; +#endif this.m_sound = "misc/powerup.wav"; this.m_name = "Invisibility"; this.m_icon = "strength"; @@ -40,8 +58,14 @@ REGISTER_ITEM(Invisibility, Powerup) { this.m_itemid = IT_STRENGTH; } +#ifndef MENUQC +MODEL(Speed_ITEM, Item_Model("g_invincible.md3")); +#endif + REGISTER_ITEM(Speed, Powerup) { - this.m_model = "g_invincible.md3"; +#ifndef MENUQC + this.m_model = MDL_Speed_ITEM; +#endif this.m_sound = "misc/powerup_shield.wav"; this.m_name = "Speed"; this.m_icon = "shield"; diff --git a/qcsrc/server/t_items.qc b/qcsrc/server/t_items.qc index 68cc43fb9..7d3e59836 100644 --- a/qcsrc/server/t_items.qc +++ b/qcsrc/server/t_items.qc @@ -1197,17 +1197,10 @@ 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(item_model_output); -} - void StartItemA (entity a) {SELFPARAM(); self.itemdef = a; - 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); + StartItem(strzone(a.m_model.model_str()), 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()