📄 p_enemy.c
字号:
S_StartSound (actor, sfx_claw);#endif damage = (P_Random()%8+1)*10; P_DamageMobj (actor->target, actor, actor, damage); return; } // launch a missile P_SpawnMissile (actor, actor->target, MT_BRUISERSHOT);}//// A_SkelMissile//void A_SkelMissile (mobj_t* actor){ mobj_t* mo; if (!actor->target) return; A_FaceTarget (actor); actor->z += 16*FRACUNIT; // so missile spawns higher mo = P_SpawnMissile (actor, actor->target, MT_TRACER); actor->z -= 16*FRACUNIT; // back to normal if(mo) { mo->x += mo->momx; mo->y += mo->momy; mo->tracer = actor->target; }}int TRACEANGLE = 0xc000000;void A_Tracer (mobj_t* actor){ angle_t exact; fixed_t dist; fixed_t slope; mobj_t* dest; mobj_t* th; if (gametic % (4 * NEWTICRATERATIO)) return; // spawn a puff of smoke behind the rocket P_SpawnPuff (actor->x, actor->y, actor->z); th = P_SpawnMobj (actor->x-actor->momx, actor->y-actor->momy, actor->z, MT_SMOKE); th->momz = FRACUNIT; th->tics -= P_Random()&3; if (th->tics < 1) th->tics = 1; // adjust direction dest = actor->tracer; if (!dest || dest->health <= 0) return; // change angle exact = R_PointToAngle2 (actor->x, actor->y, dest->x, dest->y); if (exact != actor->angle) { if (exact - actor->angle > 0x80000000) { actor->angle -= TRACEANGLE; if (exact - actor->angle < 0x80000000) actor->angle = exact; } else { actor->angle += TRACEANGLE; if (exact - actor->angle > 0x80000000) actor->angle = exact; } } exact = actor->angle>>ANGLETOFINESHIFT; actor->momx = FixedMul (actor->info->speed, finecosine[exact]); actor->momy = FixedMul (actor->info->speed, finesine[exact]); // change slope dist = P_AproxDistance (dest->x - actor->x, dest->y - actor->y); dist = dist / actor->info->speed; if (dist < 1) dist = 1; slope = (dest->z+40*FRACUNIT - actor->z) / dist; if (slope < actor->momz) actor->momz -= FRACUNIT/8; else actor->momz += FRACUNIT/8;}void A_SkelWhoosh (mobj_t* actor){ if (!actor->target) return; A_FaceTarget (actor); // judgecutor: // CHECK ME!#ifdef HW3SOUND S_StartAttackSound(actor, sfx_skeswg);#else S_StartSound (actor,sfx_skeswg);#endif}void A_SkelFist (mobj_t* actor){ int damage; if (!actor->target) return; A_FaceTarget (actor); if (P_CheckMeleeRange (actor)) { damage = ((P_Random()%10)+1)*6;#ifdef HW3SOUND S_StartAttackSound(actor, sfx_skepch);#else S_StartSound (actor, sfx_skepch);#endif P_DamageMobj (actor->target, actor, actor, damage); }}//// PIT_VileCheck// Detect a corpse that could be raised.//mobj_t* corpsehit;mobj_t* vileobj;fixed_t viletryx;fixed_t viletryy;boolean PIT_VileCheck (mobj_t* thing){ int maxdist; boolean check; if (!(thing->flags & MF_CORPSE) ) return true; // not a monster if (thing->tics != -1) return true; // not lying still yet if (thing->info->raisestate == S_NULL) return true; // monster doesn't have a raise state maxdist = thing->info->radius + mobjinfo[MT_VILE].radius; if ( abs(thing->x - viletryx) > maxdist || abs(thing->y - viletryy) > maxdist ) return true; // not actually touching corpsehit = thing; corpsehit->momx = corpsehit->momy = 0; corpsehit->height <<= 2; check = P_CheckPosition (corpsehit, corpsehit->x, corpsehit->y); corpsehit->height >>= 2; if (!check) return true; // doesn't fit here return false; // got one, so stop checking}//// A_VileChase// Check for ressurecting a body//void A_VileChase (mobj_t* actor){ int xl; int xh; int yl; int yh; int bx; int by; mobjinfo_t* info; mobj_t* temp; if (actor->movedir != DI_NODIR) { // check for corpses to raise viletryx = actor->x + actor->info->speed*xspeed[actor->movedir]; viletryy = actor->y + actor->info->speed*yspeed[actor->movedir]; xl = (viletryx - bmaporgx - MAXRADIUS*2)>>MAPBLOCKSHIFT; xh = (viletryx - bmaporgx + MAXRADIUS*2)>>MAPBLOCKSHIFT; yl = (viletryy - bmaporgy - MAXRADIUS*2)>>MAPBLOCKSHIFT; yh = (viletryy - bmaporgy + MAXRADIUS*2)>>MAPBLOCKSHIFT; vileobj = actor; for (bx=xl ; bx<=xh ; bx++) { for (by=yl ; by<=yh ; by++) { // Call PIT_VileCheck to check // whether object is a corpse // that canbe raised. if (!P_BlockThingsIterator(bx,by,PIT_VileCheck)) { // got one! temp = actor->target; actor->target = corpsehit; A_FaceTarget (actor); actor->target = temp; P_SetMobjState (actor, S_VILE_HEAL1); S_StartSound (corpsehit, sfx_slop); info = corpsehit->info; P_SetMobjState (corpsehit,info->raisestate); if( demoversion<129 ) corpsehit->height <<= 2; else { corpsehit->height = info->height; corpsehit->radius = info->radius; } corpsehit->flags = info->flags; corpsehit->health = info->spawnhealth; corpsehit->target = NULL; return; } } } } // Return to normal attack. A_Chase (actor);}//// A_VileStart//void A_VileStart (mobj_t* actor){#ifdef HW3SOUND S_StartAttackSound(actor, sfx_vilatk);#else S_StartSound (actor, sfx_vilatk);#endif}//// A_Fire// Keep fire in front of player unless out of sight//void A_Fire (mobj_t* actor);void A_StartFire (mobj_t* actor){ S_StartSound(actor,sfx_flamst); A_Fire(actor);}void A_FireCrackle (mobj_t* actor){ S_StartSound(actor,sfx_flame); A_Fire(actor);}void A_Fire (mobj_t* actor){ mobj_t* dest; unsigned an; dest = actor->tracer; if (!dest) return; // don't move it if the vile lost sight if (!P_CheckSight (actor->target, dest) ) return; an = dest->angle >> ANGLETOFINESHIFT; P_UnsetThingPosition (actor); actor->x = dest->x + FixedMul (24*FRACUNIT, finecosine[an]); actor->y = dest->y + FixedMul (24*FRACUNIT, finesine[an]); actor->z = dest->z; P_SetThingPosition (actor);}//// A_VileTarget// Spawn the hellfire//void A_VileTarget (mobj_t* actor){ mobj_t* fog; if (!actor->target) return; A_FaceTarget (actor); fog = P_SpawnMobj (actor->target->x, actor->target->x, // Bp: shoul'nt be y ? actor->target->z, MT_FIRE); actor->tracer = fog; fog->target = actor; fog->tracer = actor->target; A_Fire (fog);}//// A_VileAttack//void A_VileAttack (mobj_t* actor){ mobj_t* fire; int an; if (!actor->target) return; A_FaceTarget (actor); if (!P_CheckSight (actor, actor->target) ) return; S_StartSound (actor, sfx_barexp); P_DamageMobj (actor->target, actor, actor, 20); actor->target->momz = 1000*FRACUNIT/actor->target->info->mass; an = actor->angle >> ANGLETOFINESHIFT; fire = actor->tracer; if (!fire) return; // move the fire between the vile and the player fire->x = actor->target->x - FixedMul (24*FRACUNIT, finecosine[an]); fire->y = actor->target->y - FixedMul (24*FRACUNIT, finesine[an]); P_RadiusAttack (fire, actor, 70 );}//// Mancubus attack,// firing three missiles (bruisers)// in three different directions?// Doesn't look like it.//#define FATSPREAD (ANG90/8)void A_FatRaise (mobj_t *actor){ A_FaceTarget (actor);#ifdef HW3SOUND S_StartAttackSound(actor, sfx_manatk);#else S_StartSound (actor, sfx_manatk);#endif}void A_FatAttack1 (mobj_t* actor){ mobj_t* mo; int an; A_FaceTarget (actor); // Change direction to ... actor->angle += FATSPREAD; P_SpawnMissile (actor, actor->target, MT_FATSHOT); mo = P_SpawnMissile (actor, actor->target, MT_FATSHOT); if(mo) { mo->angle += FATSPREAD; an = mo->angle >> ANGLETOFINESHIFT; mo->momx = FixedMul (mo->info->speed, finecosine[an]); mo->momy = FixedMul (mo->info->speed, finesine[an]); }}void A_FatAttack2 (mobj_t* actor){ mobj_t* mo; int an; A_FaceTarget (actor); // Now here choose opposite deviation. actor->angle -= FATSPREAD; P_SpawnMissile (actor, actor->target, MT_FATSHOT); mo = P_SpawnMissile (actor, actor->target, MT_FATSHOT); if(mo) { mo->angle -= FATSPREAD*2; an = mo->angle >> ANGLETOFINESHIFT; mo->momx = FixedMul (mo->info->speed, finecosine[an]); mo->momy = FixedMul (mo->info->speed, finesine[an]); }}void A_FatAttack3 (mobj_t* actor){ mobj_t* mo; int an; A_FaceTarget (actor); mo = P_SpawnMissile (actor, actor->target, MT_FATSHOT); if(mo) { 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); if(mo) { mo->angle += FATSPREAD/2; an = mo->angle >> ANGLETOFINESHIFT; mo->momx = FixedMul (mo->info->speed, finecosine[an]); mo->momy = FixedMul (mo->info->speed, finesine[an]); }}//// SkullAttack// Fly at the player like a missile.//#define SKULLSPEED (20*FRACUNIT)void A_SkullAttack (mobj_t* actor){ mobj_t* dest; angle_t an; int dist; if (!actor->target) return; dest = actor->target; actor->flags |= MF_SKULLFLY;#ifdef HW3SOUND S_StartScreamSound(actor, actor->info->attacksound);#else S_StartSound (actor, actor->info->attacksound);#endif A_FaceTarget (actor); an = actor->angle >> ANGLETOFINESHIFT; actor->momx = FixedMul (SKULLSPEED, finecosine[an]); actor->momy = FixedMul (SKULLSPEED, finesine[an]); dist = P_AproxDistance (dest->x - actor->x, dest->y - actor->y); dist = dist / SKULLSPEED; if (dist < 1) dist = 1; actor->momz = (dest->z+(dest->height>>1) - actor->z) / dist;}//// A_PainShootSkull// Spawn a lost soul and launch it at the target//voidA_PainShootSkull( mobj_t* actor, angle_t angle ){ fixed_t x; fixed_t y; fixed_t z; mobj_t* newmobj; angle_t an; int prestep;/* --------------- SKULL LIMITE CODE ----------------- int count; thinker_t* currentthinker; // count total number of skull currently on the level count = 0; currentthinker = thinkercap.next; while (currentthinker != &thinkercap) { if ( (currentthinker->function.acp1 == (actionf_p1)P_MobjThinker) && ((mobj_t *)currentthinker)->type == MT_SKULL) count++; currentthinker = currentthinker->next; } // if there are allready 20 skulls on the level, // don't spit another one if (count > 20) return; ---------------------------------------------------*/ // okay, there's place for another one an = angle >> ANGLETOFINESHIFT; prestep = 4*FRACUNIT + 3*(actor->info->radius + mobjinfo[MT_SKULL].radius)/2; x = actor->x + FixedMul (prestep, finecosine[an]); y = actor->y + FixedMul (prestep, finesine[an]); z = actor->z + 8*FRACUNIT; newmobj = P_SpawnMobj (x , y, z, MT_SKULL); // Check for movements. if (!P_TryMove (newmobj, newmobj->x, newmobj->y, false)) { // kill it immediately P_DamageMobj (newmobj,actor,actor,10000); return; } newmobj->target = actor->target; A_SkullAttack (newmobj);}//// A_PainAttack// Spawn a lost soul and launch it at the target//void A_PainAttack (mobj_t* actor)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -