📄 p_mobj.c
字号:
x = mo->x+((P_Random()-P_Random())<<12); y = mo->y+((P_Random()-P_Random())<<12); z = mo->z+((P_Random()-P_Random())<<12); th = P_SpawnMobj(x, y, z, MT_BLOOD);// th->flags |= MF_NOGRAVITY; th->momx = mo->momx>>1; th->momy = mo->momy>>1; th->tics += P_Random()&3;}//---------------------------------------------------------------------------//// FUNC P_GetThingFloorType////---------------------------------------------------------------------------int P_GetThingFloorType(mobj_t *thing){ if(thing->floorpic) { return(TerrainTypes[thing->floorpic]); } else { return(TerrainTypes[thing->subsector->sector->floorpic]); }/* if(thing->subsector->sector->floorpic == W_GetNumForName("FLTWAWA1")-firstflat) { return(FLOOR_WATER); } else { return(FLOOR_SOLID); }*/}//---------------------------------------------------------------------------//// FUNC P_HitFloor////---------------------------------------------------------------------------#define SMALLSPLASHCLIP 12<<FRACBITS;int P_HitFloor(mobj_t *thing){ mobj_t *mo; int smallsplash=false; if(thing->floorz != thing->subsector->sector->floorheight) { // don't splash if landing on the edge above water/lava/etc.... return(FLOOR_SOLID); } // Things that don't splash go here switch(thing->type) { case MT_LEAF1: case MT_LEAF2:// case MT_BLOOD: // I set these to low mass -- pm// case MT_BLOODSPLATTER: case MT_SPLASH: case MT_SLUDGECHUNK: return(FLOOR_SOLID); default: break; } // Small splash for small masses if (thing->info->mass < 10) smallsplash = true; switch(P_GetThingFloorType(thing)) { case FLOOR_WATER: if (smallsplash) { mo=P_SpawnMobj(thing->x, thing->y, ONFLOORZ, MT_SPLASHBASE); if (mo) mo->floorclip += SMALLSPLASHCLIP; S_StartSound(mo, SFX_AMBIENT10); // small drip } else { mo = P_SpawnMobj(thing->x, thing->y, ONFLOORZ, MT_SPLASH); mo->target = thing; mo->momx = (P_Random()-P_Random())<<8; mo->momy = (P_Random()-P_Random())<<8; mo->momz = 2*FRACUNIT+(P_Random()<<8); mo = P_SpawnMobj(thing->x, thing->y, ONFLOORZ, MT_SPLASHBASE); if (thing->player) P_NoiseAlert(thing, thing); S_StartSound(mo, SFX_WATER_SPLASH); } return(FLOOR_WATER); case FLOOR_LAVA: if (smallsplash) { mo=P_SpawnMobj(thing->x, thing->y, ONFLOORZ, MT_LAVASPLASH); if (mo) mo->floorclip += SMALLSPLASHCLIP; } else { mo = P_SpawnMobj(thing->x, thing->y, ONFLOORZ, MT_LAVASMOKE); mo->momz = FRACUNIT+(P_Random()<<7); mo = P_SpawnMobj(thing->x, thing->y, ONFLOORZ, MT_LAVASPLASH); if (thing->player) P_NoiseAlert(thing, thing); } S_StartSound(mo, SFX_LAVA_SIZZLE); if(thing->player && leveltime&31) { P_DamageMobj(thing, &LavaInflictor, NULL, 5); } return(FLOOR_LAVA); case FLOOR_SLUDGE: if (smallsplash) { mo = P_SpawnMobj(thing->x, thing->y, ONFLOORZ, MT_SLUDGESPLASH); if (mo) mo->floorclip += SMALLSPLASHCLIP; } else { mo = P_SpawnMobj(thing->x, thing->y, ONFLOORZ, MT_SLUDGECHUNK); mo->target = thing; mo->momx = (P_Random()-P_Random())<<8; mo->momy = (P_Random()-P_Random())<<8; mo->momz = FRACUNIT+(P_Random()<<8); mo = P_SpawnMobj(thing->x, thing->y, ONFLOORZ, MT_SLUDGESPLASH); if (thing->player) P_NoiseAlert(thing, thing); } S_StartSound(mo, SFX_SLUDGE_GLOOP); return(FLOOR_SLUDGE); } return(FLOOR_SOLID);}//---------------------------------------------------------------------------//// FUNC P_CheckMissileSpawn//// Returns true if the missile is at a valid spawn point, otherwise// explodes it and returns false.////---------------------------------------------------------------------------boolean P_CheckMissileSpawn(mobj_t *missile){ //missile->tics -= P_Random()&3; // move a little forward so an angle can be computed if it // immediately explodes missile->x += (missile->momx>>1); missile->y += (missile->momy>>1); missile->z += (missile->momz>>1); if(!P_TryMove(missile, missile->x, missile->y)) { P_ExplodeMissile(missile); return(false); } return(true);}//---------------------------------------------------------------------------//// FUNC P_SpawnMissile//// Returns NULL if the missile exploded immediately, otherwise returns// a mobj_t pointer to the missile.////---------------------------------------------------------------------------mobj_t *P_SpawnMissile(mobj_t *source, mobj_t *dest, mobjtype_t type){ fixed_t z; mobj_t *th; angle_t an; int dist; switch(type) { case MT_MNTRFX1: // Minotaur swing attack missile z = source->z+40*FRACUNIT; break; case MT_MNTRFX2: // Minotaur floor fire missile z = ONFLOORZ+source->floorclip; break; case MT_CENTAUR_FX: z = source->z+45*FRACUNIT; break; case MT_ICEGUY_FX: z = source->z+40*FRACUNIT; break; case MT_HOLY_MISSILE: z = source->z+40*FRACUNIT; break; default: z = source->z+32*FRACUNIT; break; } z -= source->floorclip; th = P_SpawnMobj(source->x, source->y, z, type); if(th->info->seesound) { S_StartSound(th, th->info->seesound); } th->target = source; // Originator an = R_PointToAngle2(source->x, source->y, dest->x, dest->y); if(dest->flags&MF_SHADOW) { // Invisible target an += (P_Random()-P_Random())<<21; } th->angle = an; an >>= ANGLETOFINESHIFT; th->momx = FixedMul(th->info->speed, finecosine[an]); th->momy = FixedMul(th->info->speed, finesine[an]); dist = P_AproxDistance(dest->x - source->x, dest->y - source->y); dist = dist/th->info->speed; if(dist < 1) { dist = 1; } th->momz = (dest->z-source->z)/dist; return(P_CheckMissileSpawn(th) ? th : NULL);}//---------------------------------------------------------------------------//// FUNC P_SpawnMissileXYZ//// Returns NULL if the missile exploded immediately, otherwise returns// a mobj_t pointer to the missile.////---------------------------------------------------------------------------mobj_t *P_SpawnMissileXYZ(fixed_t x, fixed_t y, fixed_t z, mobj_t *source, mobj_t *dest, mobjtype_t type){ mobj_t *th; angle_t an; int dist; z -= source->floorclip; th = P_SpawnMobj(x, y, z, type); if(th->info->seesound) { S_StartSound(th, th->info->seesound); } th->target = source; // Originator an = R_PointToAngle2(source->x, source->y, dest->x, dest->y); if(dest->flags&MF_SHADOW) { // Invisible target an += (P_Random()-P_Random())<<21; } th->angle = an; an >>= ANGLETOFINESHIFT; th->momx = FixedMul(th->info->speed, finecosine[an]); th->momy = FixedMul(th->info->speed, finesine[an]); dist = P_AproxDistance(dest->x - source->x, dest->y - source->y); dist = dist/th->info->speed; if(dist < 1) { dist = 1; } th->momz = (dest->z-source->z)/dist; return(P_CheckMissileSpawn(th) ? th : NULL);}//---------------------------------------------------------------------------//// FUNC P_SpawnMissileAngle//// Returns NULL if the missile exploded immediately, otherwise returns// a mobj_t pointer to the missile.////---------------------------------------------------------------------------mobj_t *P_SpawnMissileAngle(mobj_t *source, mobjtype_t type, angle_t angle, fixed_t momz){ fixed_t z; mobj_t *mo; switch(type) { case MT_MNTRFX1: // Minotaur swing attack missile z = source->z+40*FRACUNIT; break; case MT_MNTRFX2: // Minotaur floor fire missile z = ONFLOORZ+source->floorclip; break; case MT_ICEGUY_FX2: // Secondary Projectiles of the Ice Guy z = source->z+3*FRACUNIT; break; case MT_MSTAFF_FX2: z = source->z+40*FRACUNIT; break; default: z = source->z+32*FRACUNIT; break; } z -= source->floorclip; mo = P_SpawnMobj(source->x, source->y, z, type); if(mo->info->seesound) { S_StartSound(mo, mo->info->seesound); } mo->target = source; // Originator mo->angle = angle; angle >>= ANGLETOFINESHIFT; mo->momx = FixedMul(mo->info->speed, finecosine[angle]); mo->momy = FixedMul(mo->info->speed, finesine[angle]); mo->momz = momz; return(P_CheckMissileSpawn(mo) ? mo : NULL);}//---------------------------------------------------------------------------//// FUNC P_SpawnMissileAngleSpeed//// Returns NULL if the missile exploded immediately, otherwise returns// a mobj_t pointer to the missile.////---------------------------------------------------------------------------mobj_t *P_SpawnMissileAngleSpeed(mobj_t *source, mobjtype_t type, angle_t angle, fixed_t momz, fixed_t speed){ fixed_t z; mobj_t *mo; z = source->z; z -= source->floorclip; mo = P_SpawnMobj(source->x, source->y, z, type); if(mo->info->seesound) { //S_StartSound(mo, mo->info->seesound); } mo->target = source; // Originator mo->angle = angle; angle >>= ANGLETOFINESHIFT; mo->momx = FixedMul(speed, finecosine[angle]); mo->momy = FixedMul(speed, finesine[angle]); mo->momz = momz; return(P_CheckMissileSpawn(mo) ? mo : NULL);}/*================== P_SpawnPlayerMissile== Tries to aim at a nearby monster================*/mobj_t *P_SpawnPlayerMissile(mobj_t *source, mobjtype_t type){ angle_t an; fixed_t x, y, z, slope; // Try to find a target an = source->angle; slope = P_AimLineAttack(source, an, 16*64*FRACUNIT); if(!linetarget) { an += 1<<26; slope = P_AimLineAttack(source, an, 16*64*FRACUNIT); if(!linetarget) { an -= 2<<26; slope = P_AimLineAttack(source, an, 16*64*FRACUNIT); } if(!linetarget) { an = source->angle; slope = ((source->player->lookdir)<<FRACBITS)/173; } } x = source->x; y = source->y; if(type == MT_LIGHTNING_FLOOR) { z = ONFLOORZ; slope = 0; } else if(type == MT_LIGHTNING_CEILING) { z = ONCEILINGZ; slope = 0; } else { z = source->z + 4*8*FRACUNIT+((source->player->lookdir)<<FRACBITS)/173; z -= source->floorclip; } MissileMobj = P_SpawnMobj(x, y, z, type); if(MissileMobj->info->seesound) { //S_StartSound(MissileMobj, MissileMobj->info->seesound); } MissileMobj->target = source; MissileMobj->angle = an; MissileMobj->momx = FixedMul(MissileMobj->info->speed, finecosine[an>>ANGLETOFINESHIFT]); MissileMobj->momy = FixedMul(MissileMobj->info->speed, finesine[an>>ANGLETOFINESHIFT]); MissileMobj->momz = FixedMul(MissileMobj->info->speed, slope); if(MissileMobj->type == MT_MWAND_MISSILE || MissileMobj->type == MT_CFLAME_MISSILE) { // Ultra-fast ripper spawning missile MissileMobj->x += (MissileMobj->momx>>3); MissileMobj->y += (MissileMobj->momy>>3); MissileMobj->z += (MissileMobj->momz>>3); } else { // Normal missile MissileMobj->x += (MissileMobj->momx>>1); MissileMobj->y += (MissileMobj->momy>>1); MissileMobj->z += (MissileMobj->momz>>1); } if(!P_TryMove(MissileMobj, MissileMobj->x, MissileMobj->y)) { // Exploded immediately P_ExplodeMissile(MissileMobj); return(NULL); } return(MissileMobj);}//----------------------------------------------------------------------------//// P_SpawnPlayerMinotaur - //// Special missile that has larger blocking than player//----------------------------------------------------------------------------/*mobj_t *P_SpawnPlayerMinotaur(mobj_t *source, mobjtype_t type){ angle_t an; fixed_t x, y, z; fixed_t dist=0 *FRACUNIT; an = source->angle; x = source->x + FixedMul(dist, finecosine[an>>ANGLETOFINESHIFT]); y = source->y + FixedMul(dist, finesine[an>>ANGLETOFINESHIFT]); z = source->z + 4*8*FRACUNIT+((source->player->lookdir)<<FRACBITS)/173; z -= source->floorclip; MissileMobj = P_SpawnMobj(x, y, z, type); if(MissileMobj->info->seesound) { //S_StartSound(MissileMobj, MissileMobj->info->seesound); } MissileMobj->target = source; MissileMobj->angle = an; MissileMobj->momx = FixedMul(MissileMobj->info->speed, finecosine[an>>ANGLETOFINESHIFT]); MissileMobj->momy = FixedMul(MissileMobj->info->speed, finesine[an>>ANGLETOFINESHIFT]); MissileMobj->momz = 0;// MissileMobj->x += (MissileMobj->momx>>3);// MissileMobj->y += (MissileMobj->momy>>3);// MissileMobj->z += (MissileMobj->momz>>3); if(!P_TryMove(MissileMobj, MissileMobj->x, MissileMobj->y)) { // Wouln't fit return(NULL); } return(MissileMobj);}*///---------------------------------------------------------------------------//// PROC P_SPMAngle////---------------------------------------------------------------------------mobj_t *P_SPMAngle(mobj_t *source, mobjtype_t type, angle_t angle){ mobj_t *th; angle_t an; fixed_t x, y, z, slope;//// see which target is to be aimed at// an = angle; slope = P_AimLineAttack (source, an, 16*64*FRACUNIT); if (!linetarget) { an += 1<<26; slope = P_AimLineAttack (source, an, 16*64*FRACUNIT); if (!linetarget) { an -= 2<<26; slope = P_AimLineAttack (source, an, 16*64*FRACUNIT); } if (!linetarget) { an = angle; slope = ((source->player->lookdir)<<FRACBITS)/173; } } x = source->x; y = source->y; z = source->z + 4*8*FRACUNIT+((source->player->lookdir)<<FRACBITS)/173; z -= source->floorclip; th = P_SpawnMobj(x, y, z, type);// if(th->info->seesound)// {// S_StartSound(th, th->info->seesound);// } th->target = source; th->angle = an; th->momx = FixedMul(th->info->speed, finecosine[an>>ANGLETOFINESHIFT]); th->momy = FixedMul(th->info->speed, finesine[an>>ANGLETOFINESHIFT]); th->momz = FixedMul(th->info->speed, slope); return(P_CheckMissileSpawn(th) ? th : NULL);}//===========================================================================//// P_SPMAngleXYZ////===========================================================================mobj_t *P_SPMAngleXYZ(mobj_t *source, fixed_t x, fixed_t y, fixed_t z, mobjtype_t type, angle_t angle){ mobj_t *th; angle_t an; fixed_t slope;//// see which target is to be aimed at// an = angle; slope = P_AimLineAttack (source, an, 16*64*FRACUNIT); if (!linetarget) { an += 1<<26; slope = P_AimLineAttack (source, an, 16*64*FRACUNIT); if (!linetarget) { an -= 2<<26; slope = P_AimLineAttack (source, an, 16*64*FRACUNIT); } if (!linetarget) { an = angle; slope = ((source->player->lookdir)<<FRACBITS)/173; } } z += 4*8*FRACUNIT+((source->player->lookdir)<<FRACBITS)/173; z -= source->floorclip; th = P_SpawnMobj(x, y, z, type);// if(th->info->seesound)// {// S_StartSound(th, th->info->seesound);// } th->target = source; th->angle = an; th->momx = FixedMul(th->info->speed, finecosine[an>>ANGLETOFINESHIFT]); th->momy = FixedMul(th->info->speed, finesine[an>>ANGLETOFINESHIFT]); th->momz = FixedMul(th->info->speed, slope); return(P_CheckMissileSpawn(th) ? th : NULL);}mobj_t *P_SpawnKoraxMissile(fixed_t x, fixed_t y, fixed_t z, mobj_t *source, mobj_t *dest, mobjtype_t type){ mobj_t *th; angle_t an; int dist; z -= source->floorclip; th = P_SpawnMobj(x, y, z, type); if(th->info->seesound) { S_StartSound(th, th->info->seesound); } th->target = source; // Originator an = R_PointToAngle2(x, y, dest->x, dest->y); if(dest->flags&MF_SHADOW) { // Invisible target an += (P_Random()-P_Random())<<21; } th->angle = an; an >>= ANGLETOFINESHIFT; th->momx = FixedMul(th->info->speed, finecosine[an]); th->momy = FixedMul(th->info->speed, finesine[an]); dist = P_AproxDistance(dest->x - x, dest->y - y); dist = dist/th->info->speed; if(dist < 1) { dist = 1; } th->momz = (dest->z-z+(30*FRACUNIT))/dist; return(P_CheckMissileSpawn(th) ? th : NULL);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -