diff options
author | Simon Howard | 2007-09-14 22:20:08 +0000 |
---|---|---|
committer | Simon Howard | 2007-09-14 22:20:08 +0000 |
commit | 5ac7ac324198351603d07f8895a53ec906653ff7 (patch) | |
tree | 7b673bd717981b2fd60ab8a89202b2329756917c /src/p_enemy.c | |
parent | 056415e2d68e261583a6fcfe1df24d5724ef91a8 (diff) | |
download | chocolate-doom-5ac7ac324198351603d07f8895a53ec906653ff7.tar.gz chocolate-doom-5ac7ac324198351603d07f8895a53ec906653ff7.tar.bz2 chocolate-doom-5ac7ac324198351603d07f8895a53ec906653ff7.zip |
Add P_SubstNullMobj, substitute NULL mobjs for a dummy mobj where
mo->target is not checked for NULL.
Subversion-branch: /trunk/chocolate-doom
Subversion-revision: 971
Diffstat (limited to 'src/p_enemy.c')
-rw-r--r-- | src/p_enemy.c | 37 |
1 files changed, 26 insertions, 11 deletions
diff --git a/src/p_enemy.c b/src/p_enemy.c index 0ed7f60f..16d2ff06 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -1258,14 +1258,17 @@ void A_FireCrackle (mobj_t* actor) void A_Fire (mobj_t* actor) { mobj_t* dest; + mobj_t* target; unsigned an; dest = actor->tracer; if (!dest) return; + + target = P_SubstNullMobj(actor->target); // don't move it if the vile lost sight - if (!P_CheckSight (actor->target, dest) ) + if (!P_CheckSight (target, dest) ) return; an = dest->angle >> ANGLETOFINESHIFT; @@ -1359,14 +1362,17 @@ void A_FatRaise (mobj_t *actor) void A_FatAttack1 (mobj_t* actor) { mobj_t* mo; + mobj_t* target; int an; - + A_FaceTarget (actor); + // Change direction to ... actor->angle += FATSPREAD; - P_SpawnMissile (actor, actor->target, MT_FATSHOT); + target = P_SubstNullMobj(actor->target); + P_SpawnMissile (actor, target, MT_FATSHOT); - mo = P_SpawnMissile (actor, actor->target, MT_FATSHOT); + mo = P_SpawnMissile (actor, target, MT_FATSHOT); mo->angle += FATSPREAD; an = mo->angle >> ANGLETOFINESHIFT; mo->momx = FixedMul (mo->info->speed, finecosine[an]); @@ -1376,14 +1382,16 @@ void A_FatAttack1 (mobj_t* actor) void A_FatAttack2 (mobj_t* actor) { mobj_t* mo; + mobj_t* target; int an; A_FaceTarget (actor); // Now here choose opposite deviation. actor->angle -= FATSPREAD; - P_SpawnMissile (actor, actor->target, MT_FATSHOT); + target = P_SubstNullMobj(actor->target); + P_SpawnMissile (actor, target, MT_FATSHOT); - mo = P_SpawnMissile (actor, actor->target, MT_FATSHOT); + mo = P_SpawnMissile (actor, target, MT_FATSHOT); mo->angle -= FATSPREAD*2; an = mo->angle >> ANGLETOFINESHIFT; mo->momx = FixedMul (mo->info->speed, finecosine[an]); @@ -1393,17 +1401,20 @@ void A_FatAttack2 (mobj_t* actor) void A_FatAttack3 (mobj_t* actor) { mobj_t* mo; + mobj_t* target; int an; A_FaceTarget (actor); + + target = P_SubstNullMobj(actor->target); - mo = P_SpawnMissile (actor, actor->target, MT_FATSHOT); + mo = P_SpawnMissile (actor, target, MT_FATSHOT); mo->angle -= FATSPREAD/2; an = mo->angle >> ANGLETOFINESHIFT; mo->momx = FixedMul (mo->info->speed, finecosine[an]); mo->momy = FixedMul (mo->info->speed, finesine[an]); - mo = P_SpawnMissile (actor, actor->target, MT_FATSHOT); + mo = P_SpawnMissile (actor, target, MT_FATSHOT); mo->angle += FATSPREAD/2; an = mo->angle >> ANGLETOFINESHIFT; mo->momx = FixedMul (mo->info->speed, finecosine[an]); @@ -1598,7 +1609,11 @@ void A_Fall (mobj_t *actor) // void A_Explode (mobj_t* thingy) { - P_RadiusAttack ( thingy, thingy->target, 128 ); + mobj_t *target; + + target = P_SubstNullMobj(thingy->target); + + P_RadiusAttack(thingy, target, 128); } @@ -1823,7 +1838,7 @@ A_CloseShotgun2 mobj_t* braintargets[32]; int numbraintargets; -int braintargeton; +int braintargeton = 0; void A_BrainAwake (mobj_t* mo) { @@ -1959,7 +1974,7 @@ void A_SpawnFly (mobj_t* mo) if (--mo->reactiontime) return; // still flying - targ = mo->target; + targ = P_SubstNullMobj(mo->target); // First spawn teleport fog. fog = P_SpawnMobj (targ->x, targ->y, targ->z, MT_SPAWNFIRE); |