]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
monsters: use generic item initialisation when dropping loot
authorbones_was_here <bones_was_here@xonotic.au>
Sun, 18 Jun 2023 22:12:43 +0000 (08:12 +1000)
committerbones_was_here <bones_was_here@xonotic.au>
Wed, 21 Jun 2023 10:59:03 +0000 (20:59 +1000)
Fixes monster loot sending no updates to CSQC and lacking despawn
effects.

qcsrc/common/monsters/sv_monsters.qc
qcsrc/common/mutators/mutator/instagib/sv_instagib.qc

index 7d644fa368c7012d4d761518f3fc65d5029ea387..7f00250fbf781a13a32572c71dc193b6bb483ba6 100644 (file)
@@ -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)
index 740b48c4c378cfe7c2faab8d6432d481d835d6ac..bd84a445f7511711244fdd9c214ab11bda9dc238 100644 (file)
@@ -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)