📄 p_mobj.c
字号:
if (mthing->type == mobjinfo[i].doomednum) break; // spawn it if (mobjinfo[i].flags & MF_SPAWNCEILING) z = ONCEILINGZ; else z = ONFLOORZ; mo = P_SpawnMobj (x,y,z, i); mo->spawnpoint = mthing; mo->angle = ANG45 * (mthing->angle/45); if( gamemode ==heretic ) S_StartSound (mo, sfx_itmbk); // pull it from the que iquetail = (iquetail+1)&(ITEMQUESIZE-1);}// used when we are going from deathmatch 2 to deathmatch 1void P_RespawnWeapons(void){ fixed_t x; fixed_t y; fixed_t z; subsector_t* ss; mobj_t* mo; mapthing_t* mthing; int i,j,freeslot; freeslot=iquetail; for(j=iquetail;j!=iquehead;j=(j+1)&(ITEMQUESIZE-1)) { mthing = itemrespawnque[j]; i=0; switch(mthing->type) { case 2001 : //mobjinfo[MT_SHOTGUN].doomednum : i=MT_SHOTGUN; break; case 82 : //mobjinfo[MT_SUPERSHOTGUN].doomednum : i=MT_SUPERSHOTGUN; break; case 2002 : //mobjinfo[MT_CHAINGUN].doomednum : i=MT_CHAINGUN; break; case 2006 : //mobjinfo[MT_BFG9000].doomednum : // bfg9000 i=MT_BFG9000; break; case 2004 : //mobjinfo[MT_PLASMAGUN].doomednum : // plasma launcher i=MT_PLASMAGUN; break; case 2003 : //mobjinfo[MT_ROCKETLAUNCH].doomednum : // rocket launcher i=MT_ROCKETLAUNCH; break; case 2005 : //mobjinfo[MT_SHAINSAW].doomednum : // shainsaw i=MT_SHAINSAW; break; default: if(freeslot!=j) { itemrespawnque[freeslot]=itemrespawnque[j]; itemrespawntime[freeslot]=itemrespawntime[j]; } freeslot=(freeslot+1)&(ITEMQUESIZE-1); continue; } // respwan it x = mthing->x << FRACBITS; y = mthing->y << FRACBITS; // spawn a teleport fog at the new spot ss = R_PointInSubsector (x,y); mo = P_SpawnMobj (x, y, ss->sector->floorheight , MT_IFOG); S_StartSound (mo, sfx_itmbk); // spawn it if (mobjinfo[i].flags & MF_SPAWNCEILING) z = ONCEILINGZ; else z = ONFLOORZ; mo = P_SpawnMobj (x,y,z, i); mo->spawnpoint = mthing; mo->angle = ANG45 * (mthing->angle/45); // here don't increment freeslot } iquehead=freeslot;}extern byte weapontobutton[NUMWEAPONS];//// P_SpawnPlayer// Called when a player is spawned on the level.// Most of the player structure stays unchanged// between levels.//// BP: spawn it at a playerspawn mapthingvoid P_SpawnPlayer (mapthing_t* mthing){ player_t* p; fixed_t x; fixed_t y; fixed_t z; mobj_t* mobj; int playernum=mthing->type-1; // not playing? if (!playeringame[playernum]) return;#ifdef PARANOIA if(playernum<0 && playernum>=MAXPLAYERS) I_Error("P_SpawnPlayer : playernum not in bound (%d)",playernum);#endif p = &players[playernum]; if (p->playerstate == PST_REBORN) G_PlayerReborn (playernum); x = mthing->x << FRACBITS; y = mthing->y << FRACBITS; z = ONFLOORZ; mobj = P_SpawnMobj (x,y,z, MT_PLAYER); //SoM: mthing->mobj = mobj; // set color translations for player sprites // added 6-2-98 : change color : now use skincolor (befor is mthing->type-1 mobj->flags |= (p->skincolor)<<MF_TRANSSHIFT; // // set 'spritedef' override in mobj for player skins.. (see ProjectSprite) // (usefulness : when body mobj is detached from player (who respawns), // the dead body mobj retain the skin through the 'spritedef' override). mobj->skin = &skins[p->skin]; mobj->angle = ANG45 * (mthing->angle/45); if (playernum == consoleplayer) localangle = mobj->angle; else if (playernum == secondarydisplayplayer) localangle2 = mobj->angle; mobj->player = p; mobj->health = p->health; p->mo = mobj; p->playerstate = PST_LIVE; p->refire = 0; p->message = NULL; p->damagecount = 0; p->bonuscount = 0; p->chickenTics = 0; p->rain1 = NULL; p->rain2 = NULL; p->extralight = 0; p->fixedcolormap = 0; p->viewheight = cv_viewheight.value<<FRACBITS; // added 2-12-98 p->viewz = p->mo->z + p->viewheight; p->flamecount = 0; p->flyheight = 0; // setup gun psprite P_SetupPsprites (p); // give all cards in death match mode if (cv_deathmatch.value) p->cards = it_allkeys; if (playernum == consoleplayer) { // wake up the status bar ST_Start (); // wake up the heads up text HU_Start (); }#ifdef CLIENTPREDICTION2 if (demoversion>132) { //added 1-6-98 : for movement prediction if(p->spirit) CL_ResetSpiritPosition(mobj); // reset spirit possition else p->spirit = P_SpawnMobj (x,y,z, MT_SPIRIT); p->spirit->skin = mobj->skin; p->spirit->angle = mobj->angle; p->spirit->player = mobj->player; p->spirit->health = mobj->health; p->spirit->movedir = weapontobutton[p->readyweapon]; p->spirit->flags2 |= MF2_DONTDRAW; }#endif SV_SpawnPlayer(playernum, mobj->x, mobj->y, mobj->angle); if(camera.chase && displayplayer==playernum) P_ResetCamera(p);}//// P_SpawnMapThing// The fields of the mapthing should// already be in host byte order.//void P_SpawnMapThing (mapthing_t* mthing){ int i; int bit; mobj_t* mobj; fixed_t x; fixed_t y; fixed_t z; if(!mthing->type) return; //SoM: 4/7/2000: Ignore type-0 things as NOPs // count deathmatch start positions if (mthing->type == 11) { if (numdmstarts < MAX_DM_STARTS) { deathmatchstarts[numdmstarts] = mthing; mthing->type = 0; numdmstarts++; } return; } // check for players specially // added 9-2-98 type 5 -> 8 player[x] starts for cooperative // support ctfdoom cooperative playerstart //SoM: 4/7/2000: Fix crashing bug. if ((mthing->type > 0 && mthing->type <=4) || (mthing->type<=4028 && mthing->type>=4001) ) { if(mthing->type>4000) mthing->type=mthing->type-4001+5; // save spots for respawning in network games playerstarts[mthing->type-1] = mthing; // old version spawn player now, new version spawn player when level is // loaded, or in network event later when player join game if (cv_deathmatch.value==0 && demoversion<128) P_SpawnPlayer (mthing); return; } // Ambient sound sequences if(mthing->type >= 1200 && mthing->type < 1300) { P_AddAmbientSfx(mthing->type-1200); return; } // check for apropriate skill level if (!multiplayer && (mthing->options & 16)) return; //SoM: 4/7/2000: Implement "not deathmatch" thing flag if (netgame && cv_deathmatch.value && (mthing->options & 32) ) return; //SoM: 4/7/2000: Implement "not cooperative" thing flag if (netgame && !cv_deathmatch.value && (mthing->options & 64) ) return; if (gameskill == sk_baby) bit = 1; else if (gameskill == sk_nightmare) bit = 4; else bit = 1<<(gameskill-1); if (!(mthing->options & bit) ) return; // find which type to spawn for (i=0 ; i< NUMMOBJTYPES ; i++) if (mthing->type == mobjinfo[i].doomednum) break; if (i==NUMMOBJTYPES) { CONS_Printf ("\2P_SpawnMapThing: Unknown type %i at (%i, %i)\n", mthing->type, mthing->x, mthing->y); return; } // don't spawn keycards and players in deathmatch if (cv_deathmatch.value && mobjinfo[i].flags & MF_NOTDMATCH) return; // don't spawn any monsters if -nomonsters if (nomonsters && ( i == MT_SKULL || (mobjinfo[i].flags & MF_COUNTKILL)) ) { return; } if( i == MT_WMACE ) { P_AddMaceSpot(mthing); return; } // spawn it x = mthing->x << FRACBITS; y = mthing->y << FRACBITS; if (mobjinfo[i].flags & MF_SPAWNCEILING) z = ONCEILINGZ; else if(mobjinfo[i].flags2&MF2_SPAWNFLOAT) z = FLOATRANDZ; else z = ONFLOORZ; mobj = P_SpawnMobj (x,y,z, i); mobj->spawnpoint = mthing; // Seed random starting index for bobbing motion if(mobj->flags2&MF2_FLOATBOB) mobj->health = P_Random(); if (mobj->tics > 0) mobj->tics = 1 + (P_Random () % mobj->tics); if (mobj->flags & MF_COUNTKILL) totalkills++; if (mobj->flags & MF_COUNTITEM) totalitems++; mobj->angle = ANG45 * (mthing->angle/45); if (mthing->options & MTF_AMBUSH) mobj->flags |= MF_AMBUSH; mthing->mobj = mobj;}//// GAME SPAWN FUNCTIONS////// P_SpawnSplash//// when player moves in water// SoM: Passing the Z height saves extra calculations...void P_SpawnSplash (mobj_t* mo, fixed_t z) // flatwater : old water FWATER flat texture{ mobj_t* th; //fixed_t z; if (demoversion<125) return; // we are supposed to be in water sector and my current // hack uses negative tag as water height /*if (flatwater) z = mo->subsector->sector->floorheight + (FRACUNIT/4); else z = sectors[mo->subsector->sector->heightsec].floorheight; *///SoM: 3/17/2000 // need to touch the surface because the splashes only appear at surface if (mo->z > z || mo->z + mo->height < z) return; // note pos +1 +1 so it doesn't eat the sound of the player.. th = P_SpawnMobj (mo->x+1,mo->y+1,z, MT_SPLASH); //if( z - mo->subsector->sector->floorheight > 4*FRACUNIT) S_StartSound (th, sfx_gloop); //else // S_StartSound (th,sfx_splash); th->tics -= P_Random()&3; if (th->tics < 1) th->tics = 1; // get rough idea of speed /* thrust = (mo->momx + mo->momy) >> FRACBITS+1; if (thrust >= 2 && thrust<=3) P_SetMobjState (th,S_SPLASH2); else if (thrust < 2) P_SetMobjState (th,S_SPLASH3); */}// --------------------------------------------------------------------------// P_SpawnSmoke// --------------------------------------------------------------------------// when player gets hurt by lava/slime, spawn at feetvoid P_SpawnSmoke ( fixed_t x, fixed_t y, fixed_t z ){ mobj_t* th; if (demoversion<125) return; x = x - ((P_Random()&8) * FRACUNIT) - 4*FRACUNIT; y = y - ((P_Random()&8) * FRACUNIT) - 4*FRACUNIT; z += (P_Random()&3) * FRACUNIT; th = P_SpawnMobj (x,y,z, MT_SMOK); th->momz = FRACUNIT; th->tics -= P_Random()&3; if (th->tics < 1) th->tics = 1;}// --------------------------------------------------------------------------// P_SpawnPuff// --------------------------------------------------------------------------void P_SpawnPuff ( fixed_t x, fixed_t y, fixed_t z ){ mobj_t *puff; z += P_SignedRandom()<<10; if( gamemode == heretic ) { puff = P_SpawnMobj(x, y, z, PuffType); if(puff->info->attacksound) { S_StartSound(puff, puff->info->attacksound); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -