From: bones_was_here Date: Sun, 18 Jun 2023 22:12:43 +0000 (+1000) Subject: monsters: use generic item initialisation when dropping loot X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=8d4bb704010b166fb7b21086d49e668db4ede9e9;p=xonotic%2Fxonotic-data.pk3dir.git monsters: use generic item initialisation when dropping loot Fixes monster loot sending no updates to CSQC and lacking despawn effects. --- diff --git a/qcsrc/common/monsters/sv_monsters.qc b/qcsrc/common/monsters/sv_monsters.qc index 7d644fa36..7f00250fb 100644 --- a/qcsrc/common/monsters/sv_monsters.qc +++ b/qcsrc/common/monsters/sv_monsters.qc @@ -42,28 +42,17 @@ void monster_dropitem(entity this, entity attacker) if(!this.candrop || !this.monster_loot || !autocvar_g_monsters_drop) return; - vector org = CENTER_OR_VIEWOFS(this); entity e = spawn(); - Item_SetLoot(e, true); - e.spawnfunc_checked = true; - - e.monster_loot = this.monster_loot; + e.itemdef = this.monster_loot; + e.origin = CENTER_OR_VIEWOFS(this); + e.velocity = randomvec() * 175 + '0 0 325'; + e.lifetime = max(0, autocvar_g_monsters_drop_time); MUTATOR_CALLHOOK(MonsterDropItem, this, e, attacker); e = M_ARGV(1, entity); - if(e && e.monster_loot) - { - e.noalign = true; - StartItem(e, e.monster_loot); - if(startitem_failed || wasfreed(e)) - return; - e.gravity = 1; - setorigin(e, org); - e.velocity = randomvec() * 175 + '0 0 325'; - e.item_spawnshieldtime = time + 0.7; - SUB_SetFade(e, time + autocvar_g_monsters_drop_time, 1); - } + if(e && e.itemdef) + Item_Initialise(e); } bool monster_facing(entity this, entity targ) diff --git a/qcsrc/common/mutators/mutator/instagib/sv_instagib.qc b/qcsrc/common/mutators/mutator/instagib/sv_instagib.qc index 740b48c4c..bd84a445f 100644 --- a/qcsrc/common/mutators/mutator/instagib/sv_instagib.qc +++ b/qcsrc/common/mutators/mutator/instagib/sv_instagib.qc @@ -109,7 +109,7 @@ MUTATOR_HOOKFUNCTION(mutator_instagib, MonsterDropItem) { entity item = M_ARGV(1, entity); - item.monster_loot = ITEM_VaporizerCells; + item.itemdef = ITEM_VaporizerCells; } MUTATOR_HOOKFUNCTION(mutator_instagib, MonsterSpawn)