From: Mario Date: Wed, 19 Oct 2016 20:27:42 +0000 (+1000) Subject: Make monster appear flag work properly with re-spawning X-Git-Tag: xonotic-v0.8.2~499 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=76270b717329f236524703956c0b486352f31725;p=xonotic%2Fxonotic-data.pk3dir.git Make monster appear flag work properly with re-spawning --- diff --git a/qcsrc/common/monsters/monster/mage.qc b/qcsrc/common/monsters/monster/mage.qc index 30d09807f..2015bcc47 100644 --- a/qcsrc/common/monsters/monster/mage.qc +++ b/qcsrc/common/monsters/monster/mage.qc @@ -371,7 +371,7 @@ bool M_Mage_Attack(int attack_type, entity actor, entity targ) return false; } -spawnfunc(monster_mage) { Monster_Spawn(this, MON_MAGE.monsterid); } +spawnfunc(monster_mage) { Monster_Spawn(this, true, MON_MAGE.monsterid); } #endif // SVQC diff --git a/qcsrc/common/monsters/monster/shambler.qc b/qcsrc/common/monsters/monster/shambler.qc index 8f84bdce3..bbaf2e469 100644 --- a/qcsrc/common/monsters/monster/shambler.qc +++ b/qcsrc/common/monsters/monster/shambler.qc @@ -200,7 +200,7 @@ bool M_Shambler_Attack(int attack_type, entity actor, entity targ) return false; } -spawnfunc(monster_shambler) { Monster_Spawn(this, MON_SHAMBLER.monsterid); } +spawnfunc(monster_shambler) { Monster_Spawn(this, true, MON_SHAMBLER.monsterid); } #endif // SVQC #ifdef SVQC diff --git a/qcsrc/common/monsters/monster/spider.qc b/qcsrc/common/monsters/monster/spider.qc index d2cb8313e..51122dfcf 100644 --- a/qcsrc/common/monsters/monster/spider.qc +++ b/qcsrc/common/monsters/monster/spider.qc @@ -190,7 +190,7 @@ bool M_Spider_Attack(int attack_type, entity actor, entity targ) return false; } -spawnfunc(monster_spider) { Monster_Spawn(this, MON_SPIDER.monsterid); } +spawnfunc(monster_spider) { Monster_Spawn(this, true, MON_SPIDER.monsterid); } #endif // SVQC #ifdef SVQC diff --git a/qcsrc/common/monsters/monster/wyvern.qc b/qcsrc/common/monsters/monster/wyvern.qc index 3fd7ec967..cd53ff26f 100644 --- a/qcsrc/common/monsters/monster/wyvern.qc +++ b/qcsrc/common/monsters/monster/wyvern.qc @@ -106,7 +106,7 @@ bool M_Wyvern_Attack(int attack_type, entity actor, entity targ) return false; } -spawnfunc(monster_wyvern) { Monster_Spawn(this, MON_WYVERN.monsterid); } +spawnfunc(monster_wyvern) { Monster_Spawn(this, true, MON_WYVERN.monsterid); } #endif // SVQC #ifdef SVQC diff --git a/qcsrc/common/monsters/monster/zombie.qc b/qcsrc/common/monsters/monster/zombie.qc index c48c2108f..8bbb300c7 100644 --- a/qcsrc/common/monsters/monster/zombie.qc +++ b/qcsrc/common/monsters/monster/zombie.qc @@ -125,7 +125,7 @@ bool M_Zombie_Attack(int attack_type, entity actor, entity targ) return false; } -spawnfunc(monster_zombie) { Monster_Spawn(this, MON_ZOMBIE.monsterid); } +spawnfunc(monster_zombie) { Monster_Spawn(this, true, MON_ZOMBIE.monsterid); } #endif // SVQC #ifdef SVQC @@ -188,6 +188,8 @@ METHOD(Zombie, mr_setup, bool(Zombie this, entity actor)) if(actor.spawnflags & MONSTERFLAG_NORESPAWN) actor.spawnflags &= ~MONSTERFLAG_NORESPAWN; // zombies always respawn + actor.spawnflags &= ~MONSTERFLAG_APPEAR; // once it's appeared, it will respawn quickly, we don't want it to appear + actor.spawnflags |= MONSTER_RESPAWN_DEATHPOINT; actor.monster_loot = spawnfunc_item_health_medium; diff --git a/qcsrc/common/monsters/sv_monsters.qc b/qcsrc/common/monsters/sv_monsters.qc index 8fe84a3b6..3de0ad8d4 100644 --- a/qcsrc/common/monsters/sv_monsters.qc +++ b/qcsrc/common/monsters/sv_monsters.qc @@ -505,7 +505,7 @@ bool Monster_Respawn_Check(entity this) return true; } -void Monster_Respawn(entity this) { Monster_Spawn(this, this.monsterid); } +void Monster_Respawn(entity this) { Monster_Spawn(this, true, this.monsterid); } .vector pos1, pos2; @@ -934,8 +934,7 @@ void Monster_Dead_Think(entity this) void Monster_Appear(entity this, entity actor, entity trigger) { this.enemy = actor; - this.spawnflags &= ~MONSTERFLAG_APPEAR; // otherwise, we get an endless loop - Monster_Spawn(this, this.monsterid); + Monster_Spawn(this, false, this.monsterid); } bool Monster_Appear_Check(entity this, int monster_id) @@ -1292,7 +1291,7 @@ bool Monster_Spawn_Setup(entity this) return true; } -bool Monster_Spawn(entity this, int mon_id) +bool Monster_Spawn(entity this, bool check_appear, int mon_id) { // setup the basic required properties for a monster entity mon = Monsters_from(mon_id); @@ -1303,7 +1302,7 @@ bool Monster_Spawn(entity this, int mon_id) if(!(this.spawnflags & MONSTERFLAG_RESPAWNED)) IL_PUSH(g_monsters, this); - if(Monster_Appear_Check(this, mon_id)) { return true; } // return true so the monster isn't removed + if(check_appear && Monster_Appear_Check(this, mon_id)) { return true; } // return true so the monster isn't removed if(!this.monster_skill) this.monster_skill = cvar("g_monsters_skill"); diff --git a/qcsrc/common/monsters/sv_monsters.qh b/qcsrc/common/monsters/sv_monsters.qh index 56509cf66..b667373a0 100644 --- a/qcsrc/common/monsters/sv_monsters.qh +++ b/qcsrc/common/monsters/sv_monsters.qh @@ -72,7 +72,7 @@ void Monster_Remove(entity this); void monsters_setstatus(entity this); -bool Monster_Spawn(entity this, int mon_id); +bool Monster_Spawn(entity this, bool check_appear, int mon_id); void monster_setupcolors(entity this); diff --git a/qcsrc/common/monsters/sv_spawn.qc b/qcsrc/common/monsters/sv_spawn.qc index 8c6582520..6b9d4ea05 100644 --- a/qcsrc/common/monsters/sv_spawn.qc +++ b/qcsrc/common/monsters/sv_spawn.qc @@ -62,7 +62,7 @@ entity spawnmonster (string monster, int monster_id, entity spawnedby, entity ow } // Monster_Spawn checks if monster is valid - Monster_Spawn(e, monster_id); + Monster_Spawn(e, false, monster_id); return e; }