From: Lyberta Date: Thu, 5 Oct 2017 21:09:06 +0000 (+0300) Subject: Random items: Added proper overkill support. X-Git-Tag: xonotic-v0.8.5~2426^2~44 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=e320d7a0e5cb096ca5c22cfee133d3f94d5f24f4;p=xonotic%2Fxonotic-data.pk3dir.git Random items: Added proper overkill support. --- diff --git a/mutators.cfg b/mutators.cfg index 9b50a6476..70ff24717 100644 --- a/mutators.cfg +++ b/mutators.cfg @@ -512,6 +512,8 @@ set g_random_items_replace_weapon_hlac "random" "Classnames to replace HLAC with set g_random_items_replace_weapon_rifle "random" "Classnames to replace rifle with." set g_random_items_replace_weapon_seeker "random" "Classnames to replace TAG seeker with." set g_random_items_replace_weapon_vaporizer "random" "Classnames to replace vaporizer with." +set g_random_items_replace_weapon_hmg "random" "Classnames to replace HMG with." +set g_random_items_replace_weapon_rpc "random" "Classnames to replace RPC with." set g_random_items_replace_item_strength "random" "Classnames to replace strength with." set g_random_items_replace_item_shield "random" "Classnames to replace shield with." set g_random_items_replace_item_fuel_regen "random" "Classnames to replace fuel regeneration with." @@ -524,7 +526,7 @@ set g_random_items_health_probability 1 "Probability of random health items spaw set g_random_items_armor_probability 1 "Probability of random armor items spawning in the map." set g_random_items_resource_probability 1 "Probability of random ammo items spawning in the map." set g_random_items_weapon_probability 1 "Probability of random weapons spawning in the map." -set g_random_items_powerup_probability 0.175 "Probability of random powerups spawning in the map." +set g_random_items_powerup_probability 0.15 "Probability of random powerups spawning in the map." set g_random_items_health_small_probability 10 "Probability of random small health spawning in the map." set g_random_items_health_medium_probability 4 "Probability of random medium health spawning in the map." set g_random_items_health_big_probability 2 "Probability of random big health spawning in the map." @@ -567,6 +569,13 @@ set g_random_items_vaporizer_cells_probability 20 "Probability of random vaporiz set g_random_items_invisibility_probability 1 "Probability of random invisibility spawning in the map." set g_random_items_extralife_probability 1 "Probability of random extra life spawning in the map." set g_random_items_speed_probability 1 "Probability of random speed spawning in the map." +set g_random_items_overkill_health_mega_probability 1 "Probability of random mega health spawning in the map during overkill." +set g_random_items_overkill_armor_small_probability 10 "Probability of random small armor spawning in the map during overkill." +set g_random_items_overkill_armor_medium_probability 4 "Probability of random medium armor spawning in the map during overkill." +set g_random_items_overkill_armor_big_probability 2 "Probability of random big armor spawning in the map during overkill." +set g_random_items_overkill_armor_mega_probability 1 "Probability of random mega armor spawning in the map during overkill." +set g_random_items_overkill_weapon_hmg_probability 0.5 "Probability of random HMG spawning in the map during overkill." +set g_random_items_overkill_weapon_rpc_probability 0.5 "Probability of random RPC spawning in the map during overkill." set g_random_loot 0 "Whether to enable random loot." set g_random_loot_min 0 "Minimum amount of loot items." set g_random_loot_max 4 "Minimum amount of loot items." @@ -619,3 +628,10 @@ set g_random_loot_vaporizer_cells_probability 20 "Probability of random vaporize set g_random_loot_invisibility_probability 1 "Probability of random invisibility spawning as loot." set g_random_loot_extralife_probability 1 "Probability of random extra life spawning as loot." set g_random_loot_speed_probability 1 "Probability of random speed spawning as loot." +set g_random_loot_overkill_health_mega_probability 1 "Probability of random mega health spawning as loot during overkill." +set g_random_loot_overkill_armor_small_probability 10 "Probability of random small armor spawning as loot during overkill." +set g_random_loot_overkill_armor_medium_probability 4 "Probability of random medium armor spawning as loot during overkill." +set g_random_loot_overkill_armor_big_probability 2 "Probability of random big armor spawning as loot during overkill." +set g_random_loot_overkill_armor_mega_probability 1 "Probability of random mega armor spawning as loot during overkill." +set g_random_loot_overkill_weapon_hmg_probability 1 "Probability of random HMG spawning as loot during overkill." +set g_random_loot_overkill_weapon_rpc_probability 1 "Probability of random RPC spawning as loot during overkill." diff --git a/qcsrc/common/mutators/mutator/overkill/hmg.qh b/qcsrc/common/mutators/mutator/overkill/hmg.qh index 07b31ea3c..b77728fc9 100644 --- a/qcsrc/common/mutators/mutator/overkill/hmg.qh +++ b/qcsrc/common/mutators/mutator/overkill/hmg.qh @@ -40,3 +40,7 @@ CLASS(HeavyMachineGun, Weapon) ENDCLASS(HeavyMachineGun) REGISTER_WEAPON(HMG, hmg, NEW(HeavyMachineGun)); + +#ifdef SVQC +spawnfunc(weapon_hmg); +#endif diff --git a/qcsrc/common/mutators/mutator/overkill/rpc.qh b/qcsrc/common/mutators/mutator/overkill/rpc.qh index 560f7f4fa..a107da39b 100644 --- a/qcsrc/common/mutators/mutator/overkill/rpc.qh +++ b/qcsrc/common/mutators/mutator/overkill/rpc.qh @@ -45,3 +45,7 @@ CLASS(RocketPropelledChainsaw, Weapon) ENDCLASS(RocketPropelledChainsaw) REGISTER_WEAPON(RPC, rpc, NEW(RocketPropelledChainsaw)); + +#ifdef SVQC +spawnfunc(weapon_rpc); +#endif diff --git a/qcsrc/common/mutators/mutator/overkill/sv_overkill.qc b/qcsrc/common/mutators/mutator/overkill/sv_overkill.qc index ea541ce44..ce015b12c 100644 --- a/qcsrc/common/mutators/mutator/overkill/sv_overkill.qc +++ b/qcsrc/common/mutators/mutator/overkill/sv_overkill.qc @@ -9,13 +9,6 @@ bool autocvar_g_overkill_powerups_replace; bool autocvar_g_overkill_itemwaypoints = true; -bool autocvar_g_overkill_filter_healthmega; -bool autocvar_g_overkill_filter_armormedium; -bool autocvar_g_overkill_filter_armorbig; -bool autocvar_g_overkill_filter_armormega; - -.float ok_item; - .Weapon ok_lastwep[MAX_WEAPONSLOTS]; void ok_Initialize(); diff --git a/qcsrc/common/mutators/mutator/overkill/sv_overkill.qh b/qcsrc/common/mutators/mutator/overkill/sv_overkill.qh index 6f70f09be..72324e6db 100644 --- a/qcsrc/common/mutators/mutator/overkill/sv_overkill.qh +++ b/qcsrc/common/mutators/mutator/overkill/sv_overkill.qh @@ -1 +1,8 @@ #pragma once + +bool autocvar_g_overkill_filter_healthmega; +bool autocvar_g_overkill_filter_armormedium; +bool autocvar_g_overkill_filter_armorbig; +bool autocvar_g_overkill_filter_armormega; + +.float ok_item; diff --git a/qcsrc/common/mutators/mutator/random_items/sv_random_items.qc b/qcsrc/common/mutators/mutator/random_items/sv_random_items.qc index 10bbadd68..c33b42b86 100644 --- a/qcsrc/common/mutators/mutator/random_items/sv_random_items.qc +++ b/qcsrc/common/mutators/mutator/random_items/sv_random_items.qc @@ -80,6 +80,17 @@ enum RANDOM_ITEM_SUBTYPE_INSTAGIB_SPEED }; +enum +{ + RANDOM_ITEM_SUBTYPE_OVERKILL_HEALTH_MEGA, + RANDOM_ITEM_SUBTYPE_OVERKILL_ARMOR_SMALL, + RANDOM_ITEM_SUBTYPE_OVERKILL_ARMOR_MEDIUM, + RANDOM_ITEM_SUBTYPE_OVERKILL_ARMOR_BIG, + RANDOM_ITEM_SUBTYPE_OVERKILL_ARMOR_MEGA, + RANDOM_ITEM_SUBTYPE_OVERKILL_WEAPON_HMG, + RANDOM_ITEM_SUBTYPE_OVERKILL_WEAPON_RPC +}; + //======================= Global variables ==================================== bool autocvar_g_random_items; ///< Whether to enable random items. @@ -157,6 +168,10 @@ string autocvar_g_random_items_replace_weapon_rifle; string autocvar_g_random_items_replace_weapon_seeker; /// \brief Classnames to replace vaporizer with. string autocvar_g_random_items_replace_weapon_vaporizer; +/// \brief Classnames to replace HMG with. +string autocvar_g_random_items_replace_weapon_hmg; +/// \brief Classnames to replace RPC with. +string autocvar_g_random_items_replace_weapon_rpc; /// \brief Classnames to replace strength with. string autocvar_g_random_items_replace_item_strength; @@ -279,6 +294,23 @@ float autocvar_g_random_items_extralife_probability; /// \brief Probability of random speed spawning in the map. float autocvar_g_random_items_speed_probability; +/// \brief Probability of random mega health spawning in the map during overkill. +float autocvar_g_random_items_overkill_health_mega_probability; +/// \brief Probability of random small armor spawning in the map during +/// overkill. +float autocvar_g_random_items_overkill_armor_small_probability; +/// \brief Probability of random medium armor spawning in the map during +/// overkill. +float autocvar_g_random_items_overkill_armor_medium_probability; +/// \brief Probability of random big armor spawning in the map during overkill. +float autocvar_g_random_items_overkill_armor_big_probability; +/// \brief Probability of random mega armor spawning in the map during overkill. +float autocvar_g_random_items_overkill_armor_mega_probability; +/// \brief Probability of random HMG spawning in the map during overkill. +float autocvar_g_random_items_overkill_weapon_hmg_probability; +/// \brief Probability of random RPC spawning in the map during overkill. +float autocvar_g_random_items_overkill_weapon_rpc_probability; + // Loot bool autocvar_g_random_loot; ///< Whether to enable random loot. @@ -391,6 +423,22 @@ float autocvar_g_random_loot_extralife_probability; /// \brief Probability of random speed spawning as loot. float autocvar_g_random_loot_speed_probability; +/// \brief Probability of random mega health spawning as loot during overkill. +float autocvar_g_random_loot_overkill_health_mega_probability; +/// \brief Probability of random small armor spawning as loot during overkill. +float autocvar_g_random_loot_overkill_armor_small_probability; +/// \brief Probability of random medium armor spawning as loot during overkill. +float autocvar_g_random_loot_overkill_armor_medium_probability; +/// \brief Probability of random big armor spawning as loot during overkill. +float autocvar_g_random_loot_overkill_armor_big_probability; +/// \brief Probability of random mega armor spawning as loot during overkill. +float autocvar_g_random_loot_overkill_armor_mega_probability; +/// \brief Probability of random HMG spawning as loot during overkill. +float autocvar_g_random_loot_overkill_weapon_hmg_probability; +/// \brief Probability of random RPC spawning as loot during overkill. +float autocvar_g_random_loot_overkill_weapon_rpc_probability; + + /// \brief Holds whether random item is spawning. Used to prevent infinite /// recursion. bool random_items_is_spawning = false; @@ -550,6 +598,14 @@ string RandomItems_GetItemReplacementClassNames(entity item) { return autocvar_g_random_items_replace_weapon_vaporizer; } + case "weapon_hmg": + { + return autocvar_g_random_items_replace_weapon_hmg; + } + case "weapon_rpc": + { + return autocvar_g_random_items_replace_weapon_rpc; + } case "item_strength": { return autocvar_g_random_items_replace_item_strength; @@ -615,8 +671,8 @@ string RandomItems_GetItemReplacementClassNames(entity item) } } -/// \brief Returns a random instagib classname of the map item. -/// \return Random instagib classname of the map item. +/// \brief Returns a random classname of the instagib map item. +/// \return Random classname of the instagib map item. string RandomItems_GetRandomInstagibMapItemClassName() { RandomSelection_Init(); @@ -651,6 +707,72 @@ string RandomItems_GetRandomInstagibMapItemClassName() return ""; } +/// \brief Returns a random classname of the overkill map item. +/// \return Random classname of the overkill map item. +string RandomItems_GetRandomOverkillMapItemClassName() +{ + RandomSelection_Init(); + if (!autocvar_g_overkill_filter_healthmega) + { + RandomSelection_AddFloat(RANDOM_ITEM_SUBTYPE_OVERKILL_HEALTH_MEGA, + autocvar_g_random_items_overkill_health_mega_probability, 1); + } + RandomSelection_AddFloat(RANDOM_ITEM_SUBTYPE_OVERKILL_ARMOR_SMALL, + autocvar_g_random_items_overkill_armor_small_probability, 1); + if (!autocvar_g_overkill_filter_armormedium) + { + RandomSelection_AddFloat(RANDOM_ITEM_SUBTYPE_OVERKILL_ARMOR_MEDIUM, + autocvar_g_random_items_overkill_armor_medium_probability, 1); + } + if (!autocvar_g_overkill_filter_armorbig) + { + RandomSelection_AddFloat(RANDOM_ITEM_SUBTYPE_OVERKILL_ARMOR_BIG, + autocvar_g_random_items_overkill_armor_big_probability, 1); + } + if (!autocvar_g_overkill_filter_armormega) + { + RandomSelection_AddFloat(RANDOM_ITEM_SUBTYPE_OVERKILL_ARMOR_MEGA, + autocvar_g_random_items_overkill_armor_mega_probability, 1); + } + RandomSelection_AddFloat(RANDOM_ITEM_SUBTYPE_OVERKILL_WEAPON_HMG, + autocvar_g_random_items_overkill_weapon_hmg_probability, 1); + RandomSelection_AddFloat(RANDOM_ITEM_SUBTYPE_OVERKILL_WEAPON_RPC, + autocvar_g_random_items_overkill_weapon_rpc_probability, 1); + int item_type = RandomSelection_chosen_float; + switch (item_type) + { + case RANDOM_ITEM_SUBTYPE_OVERKILL_HEALTH_MEGA: + { + return "item_health_mega"; + } + case RANDOM_ITEM_SUBTYPE_OVERKILL_ARMOR_SMALL: + { + return "item_armor_small"; + } + case RANDOM_ITEM_SUBTYPE_OVERKILL_ARMOR_MEDIUM: + { + return "item_armor_medium"; + } + case RANDOM_ITEM_SUBTYPE_OVERKILL_ARMOR_BIG: + { + return "item_armor_big"; + } + case RANDOM_ITEM_SUBTYPE_OVERKILL_ARMOR_MEGA: + { + return "item_armor_mega"; + } + case RANDOM_ITEM_SUBTYPE_OVERKILL_WEAPON_HMG: + { + return "weapon_hmg"; + } + case RANDOM_ITEM_SUBTYPE_OVERKILL_WEAPON_RPC: + { + return "weapon_rpc"; + } + } + return ""; +} + /// \brief Returns a random classname of the map item. /// \return Random classname of the map item. string RandomItems_GetRandomMapItemClassName() @@ -659,6 +781,10 @@ string RandomItems_GetRandomMapItemClassName() { return RandomItems_GetRandomInstagibMapItemClassName(); } + if (autocvar_g_overkill) + { + return RandomItems_GetRandomOverkillMapItemClassName(); + } RandomSelection_Init(); RandomSelection_AddFloat(RANDOM_ITEM_TYPE_HEALTH, autocvar_g_random_items_health_probability, 1); @@ -989,13 +1115,30 @@ entity RandomItems_ReplaceMapItem(entity item) return NULL; } random_items_is_spawning = true; - entity new_item = Item_Create(strzone(new_classname), item.origin); + entity new_item; + if (!autocvar_g_overkill) + { + new_item = Item_Create(strzone(new_classname), item.origin); + } + else + { + new_item = spawn(); + new_item.classname = strzone(new_classname); + new_item.spawnfunc_checked = true; + new_item.ok_item = true; + Item_Initialize(new_item, new_classname); + if (wasfreed(new_item)) + { + return NULL; + } + setorigin(new_item, item.origin); + } random_items_is_spawning = false; return new_item; } -/// \brief Returns a random instagib classname of the loot item. -/// \return Random instagib classname of the loot item. +/// \brief Returns a random classname of the instagib loot item. +/// \return Random classname of the instagib loot item. string RandomItems_GetRandomInstagibLootItemClassName() { RandomSelection_Init(); @@ -1030,6 +1173,71 @@ string RandomItems_GetRandomInstagibLootItemClassName() return ""; } +/// \brief Returns a random classname of the overkill loot item. +/// \return Random classname of the overkill loot item. +string RandomItems_GetRandomOverkillLootItemClassName() +{ + RandomSelection_Init(); + if (!autocvar_g_overkill_filter_healthmega) + { + RandomSelection_AddFloat(RANDOM_ITEM_SUBTYPE_OVERKILL_HEALTH_MEGA, + autocvar_g_random_loot_overkill_health_mega_probability, 1); + } + RandomSelection_AddFloat(RANDOM_ITEM_SUBTYPE_OVERKILL_ARMOR_SMALL, + autocvar_g_random_loot_overkill_armor_small_probability, 1); + if (!autocvar_g_overkill_filter_armormedium) + { + RandomSelection_AddFloat(RANDOM_ITEM_SUBTYPE_OVERKILL_ARMOR_MEDIUM, + autocvar_g_random_loot_overkill_armor_medium_probability, 1); + } + if (!autocvar_g_overkill_filter_armorbig) + { + RandomSelection_AddFloat(RANDOM_ITEM_SUBTYPE_OVERKILL_ARMOR_BIG, + autocvar_g_random_loot_overkill_armor_big_probability, 1); + } + if (!autocvar_g_overkill_filter_armormega) + { + RandomSelection_AddFloat(RANDOM_ITEM_SUBTYPE_OVERKILL_ARMOR_MEGA, + autocvar_g_random_loot_overkill_armor_mega_probability, 1); + } + RandomSelection_AddFloat(RANDOM_ITEM_SUBTYPE_OVERKILL_WEAPON_HMG, + autocvar_g_random_loot_overkill_weapon_hmg_probability, 1); + RandomSelection_AddFloat(RANDOM_ITEM_SUBTYPE_OVERKILL_WEAPON_RPC, + autocvar_g_random_loot_overkill_weapon_rpc_probability, 1); + int item_type = RandomSelection_chosen_float; + switch (item_type) + { + case RANDOM_ITEM_SUBTYPE_OVERKILL_HEALTH_MEGA: + { + return "item_health_mega"; + } + case RANDOM_ITEM_SUBTYPE_OVERKILL_ARMOR_SMALL: + { + return "item_armor_small"; + } + case RANDOM_ITEM_SUBTYPE_OVERKILL_ARMOR_MEDIUM: + { + return "item_armor_medium"; + } + case RANDOM_ITEM_SUBTYPE_OVERKILL_ARMOR_BIG: + { + return "item_armor_big"; + } + case RANDOM_ITEM_SUBTYPE_OVERKILL_ARMOR_MEGA: + { + return "item_armor_mega"; + } + case RANDOM_ITEM_SUBTYPE_OVERKILL_WEAPON_HMG: + { + return "weapon_hmg"; + } + case RANDOM_ITEM_SUBTYPE_OVERKILL_WEAPON_RPC: + { + return "weapon_rpc"; + } + } + return ""; +} /// \brief Returns a random classname of the loot item. /// \return Random classname of the loot item. @@ -1039,6 +1247,10 @@ string RandomItems_GetRandomLootItemClassName() { return RandomItems_GetRandomInstagibLootItemClassName(); } + if (autocvar_g_overkill) + { + return RandomItems_GetRandomOverkillLootItemClassName(); + } RandomSelection_Init(); RandomSelection_AddFloat(RANDOM_ITEM_TYPE_HEALTH, autocvar_g_random_loot_health_probability, 1); @@ -1344,7 +1556,19 @@ void RandomItems_SpawnLootItem(vector position) spread.z = autocvar_g_random_loot_spread / 2; spread += randomvec() * autocvar_g_random_loot_spread; random_items_is_spawning = true; - Item_CreateLoot(class_name, position, spread, autocvar_g_random_loot_time); + if (!autocvar_g_overkill) + { + Item_CreateLoot(class_name, position, spread, + autocvar_g_random_loot_time); + } + else + { + entity item = spawn(); + item.ok_item = true; + item.classname = class_name; + Item_InitializeLoot(item, class_name, position, spread, + autocvar_g_random_loot_time); + } random_items_is_spawning = false; } diff --git a/qcsrc/server/items.qc b/qcsrc/server/items.qc index c0fb7648d..413703906 100644 --- a/qcsrc/server/items.qc +++ b/qcsrc/server/items.qc @@ -6,6 +6,8 @@ /// \copyright GNU GPLv2 or any later version. #include +#include +#include .bool m_isloot; ///< Holds whether item is loot. @@ -207,6 +209,16 @@ void Item_Initialize(entity item, string class_name) spawnfunc_weapon_vaporizer(item); return; } + case "weapon_hmg": + { + spawnfunc_weapon_hmg(item); + return; + } + case "weapon_rpc": + { + spawnfunc_weapon_rpc(item); + return; + } case "item_strength": { spawnfunc_item_strength(item);