From 3de6603a1849f6a3811c924a33a45047a6328c37 Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 15 Nov 2019 21:47:51 +1000 Subject: [PATCH] Fix some potential crashes revolving around monster attacks' use of makevectors --- qcsrc/common/monsters/monster/mage.qc | 1 + qcsrc/common/monsters/monster/spider.qc | 2 -- qcsrc/common/monsters/monster/wyvern.qc | 1 - qcsrc/common/monsters/sv_monsters.qc | 2 ++ 4 files changed, 3 insertions(+), 3 deletions(-) diff --git a/qcsrc/common/monsters/monster/mage.qc b/qcsrc/common/monsters/monster/mage.qc index efdd836d2..1cba349ed 100644 --- a/qcsrc/common/monsters/monster/mage.qc +++ b/qcsrc/common/monsters/monster/mage.qc @@ -12,6 +12,7 @@ METHOD(MageSpike, wr_think, void(MageSpike thiswep, entity actor, .entity weapon if (!IS_PLAYER(actor) || weapon_prepareattack(thiswep, actor, weaponentity, false, 0.2)) { if (!actor.target_range) actor.target_range = autocvar_g_monsters_target_range; actor.enemy = Monster_FindTarget(actor); + monster_makevectors(actor, actor.enemy); W_SetupShot_Dir(actor, weaponentity, v_forward, false, 0, SND_MageSpike_FIRE, CH_WEAPON_B, 0, DEATH_MONSTER_MAGE.m_id); if (!IS_PLAYER(actor)) w_shotdir = normalize((actor.enemy.origin + '0 0 10') - actor.origin); M_Mage_Attack_Spike(actor, w_shotdir); diff --git a/qcsrc/common/monsters/monster/spider.qc b/qcsrc/common/monsters/monster/spider.qc index 52bf37f7d..b684af152 100644 --- a/qcsrc/common/monsters/monster/spider.qc +++ b/qcsrc/common/monsters/monster/spider.qc @@ -128,8 +128,6 @@ void adaptor_think2use_hittype_splash(entity this); void M_Spider_Attack_Web(entity this) { - monster_makevectors(this, this.enemy); - sound(this, CH_SHOTS, SND_ELECTRO_FIRE2, VOL_BASE, ATTEN_NORM); entity proj = new(plasma); diff --git a/qcsrc/common/monsters/monster/wyvern.qc b/qcsrc/common/monsters/monster/wyvern.qc index 8a4ad1605..d07669af0 100644 --- a/qcsrc/common/monsters/monster/wyvern.qc +++ b/qcsrc/common/monsters/monster/wyvern.qc @@ -22,7 +22,6 @@ METHOD(WyvernAttack, wr_think, void(WyvernAttack thiswep, entity actor, .entity if (IS_MONSTER(actor)) { actor.attack_finished_single[0] = time + 1.2; actor.anim_finished = time + 1.2; - monster_makevectors(actor, actor.enemy); } entity missile = spawn(); diff --git a/qcsrc/common/monsters/sv_monsters.qc b/qcsrc/common/monsters/sv_monsters.qc index 0673cd0ba..b30bf4583 100644 --- a/qcsrc/common/monsters/sv_monsters.qc +++ b/qcsrc/common/monsters/sv_monsters.qc @@ -424,6 +424,7 @@ void Monster_Attack_Check(entity this, entity targ, .entity weaponentity) if(vdist(targ.origin - this.origin, <=, this.attack_range)) { + monster_makevectors(this, targ); int attack_success = this.monster_attackfunc(MONSTER_ATTACK_MELEE, this, targ, weaponentity); if(attack_success == 1) Monster_Sound(this, monstersound_melee, 0, false, CH_VOICE); @@ -433,6 +434,7 @@ void Monster_Attack_Check(entity this, entity targ, .entity weaponentity) if(vdist(targ.origin - this.origin, >, this.attack_range)) { + monster_makevectors(this, targ); int attack_success = this.monster_attackfunc(MONSTER_ATTACK_RANGED, this, targ, weaponentity); if(attack_success == 1) Monster_Sound(this, monstersound_melee, 0, false, CH_VOICE); -- 2.39.2