From: terencehill Date: Sat, 6 May 2023 15:06:20 +0000 (+0200) Subject: LMS: fix megahealths from other games not getting replaced by extralife X-Git-Tag: xonotic-v0.8.6~114^2~3 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=5f80779235c0c0f1d1fdf6c46e36aac819552af4;p=xonotic%2Fxonotic-data.pk3dir.git LMS: fix megahealths from other games not getting replaced by extralife --- diff --git a/qcsrc/common/gamemodes/gamemode/lms/sv_lms.qc b/qcsrc/common/gamemodes/gamemode/lms/sv_lms.qc index 51df1bb2a..692d987aa 100644 --- a/qcsrc/common/gamemodes/gamemode/lms/sv_lms.qc +++ b/qcsrc/common/gamemodes/gamemode/lms/sv_lms.qc @@ -646,39 +646,33 @@ MUTATOR_HOOKFUNCTION(lms, FilterItemDefinition) if (autocvar_g_lms_items) return false; - entity definition = M_ARGV(0, entity); + entity def = M_ARGV(0, entity); - if (autocvar_g_lms_extra_lives && definition == ITEM_ExtraLife) - { + if (autocvar_g_powerups && autocvar_g_lms_extra_lives && (def == ITEM_ExtraLife || def == ITEM_HealthMega)) return false; - } return (autocvar_g_pickup_items <= 0); // only allow items if explicitly enabled } -void lms_extralife(entity this) +void lms_replace_with_extralife(entity this) { - StartItem(this, ITEM_ExtraLife); + entity e = new(item_extralife); + Item_CopyFields(this, e); + + StartItem(e, ITEM_ExtraLife); } -MUTATOR_HOOKFUNCTION(lms, OnEntityPreSpawn) +MUTATOR_HOOKFUNCTION(lms, FilterItem) { - if (MUTATOR_RETURNVALUE) return false; - if (!autocvar_g_powerups) return false; - if (!autocvar_g_lms_extra_lives) return false; - - entity ent = M_ARGV(0, entity); - - // Can't use .itemdef here - if (ent.classname != "item_health_mega") return false; - - entity e = spawn(); - setthink(e, lms_extralife); - - Item_CopyFields(ent, e); - - e.nextthink = time + 0.1; + entity item = M_ARGV(0, entity); + entity def = item.itemdef; + if(def == ITEM_HealthMega) + { + if(autocvar_g_powerups && autocvar_g_lms_extra_lives) + lms_replace_with_extralife(item); + return true; + } - return true; + return false; } MUTATOR_HOOKFUNCTION(lms, ItemTouch)