📄 p_floor.c
字号:
//**************************************************************************//**//** p_floor.c : Heretic 2 : Raven Software, Corp.//**//** $RCSfile: p_floor.c,v $//** $Revision: 1.23 $//** $Date: 95/10/06 16:53:19 $//** $Author: paul $//**//**************************************************************************#include "h2def.h"#include "p_local.h"#include "soundst.h"extern fixed_t FloatBobOffsets[64];//==================================================================//==================================================================//// FLOORS////==================================================================//==================================================================//==================================================================//// Move a plane (floor or ceiling) and check for crushing////==================================================================result_e T_MovePlane(sector_t *sector,fixed_t speed, fixed_t dest, int crush,int floorOrCeiling,int direction){ boolean flag; fixed_t lastpos; switch(floorOrCeiling) { case 0: // FLOOR switch(direction) { case -1: // DOWN if (sector->floorheight - speed < dest) { lastpos = sector->floorheight; sector->floorheight = dest; flag = P_ChangeSector(sector,crush); if (flag == true) { sector->floorheight =lastpos; P_ChangeSector(sector,crush); //return RES_CRUSHED; } return RES_PASTDEST; } else { lastpos = sector->floorheight; sector->floorheight -= speed; flag = P_ChangeSector(sector,crush); if (flag == true) { sector->floorheight = lastpos; P_ChangeSector(sector,crush); return RES_CRUSHED; } } break; case 1: // UP if (sector->floorheight + speed > dest) { lastpos = sector->floorheight; sector->floorheight = dest; flag = P_ChangeSector(sector,crush); if (flag == true) { sector->floorheight = lastpos; P_ChangeSector(sector,crush); //return RES_CRUSHED; } return RES_PASTDEST; } else // COULD GET CRUSHED { lastpos = sector->floorheight; sector->floorheight += speed; flag = P_ChangeSector(sector,crush); if (flag == true) { //if (crush == true) //{ // return RES_CRUSHED; //} sector->floorheight = lastpos; P_ChangeSector(sector,crush); return RES_CRUSHED; } } break; } break; case 1: // CEILING switch(direction) { case -1: // DOWN if (sector->ceilingheight - speed < dest) { lastpos = sector->ceilingheight; sector->ceilingheight = dest; flag = P_ChangeSector(sector,crush); if (flag == true) { sector->ceilingheight = lastpos; P_ChangeSector(sector,crush); //return RES_CRUSHED; } return RES_PASTDEST; } else // COULD GET CRUSHED { lastpos = sector->ceilingheight; sector->ceilingheight -= speed; flag = P_ChangeSector(sector,crush); if (flag == true) { //if (crush == true) //{ // return RES_CRUSHED; //} sector->ceilingheight = lastpos; P_ChangeSector(sector,crush); return RES_CRUSHED; } } break; case 1: // UP if (sector->ceilingheight + speed > dest) { lastpos = sector->ceilingheight; sector->ceilingheight = dest; flag = P_ChangeSector(sector,crush); if (flag == true) { sector->ceilingheight = lastpos; P_ChangeSector(sector,crush); //return RES_CRUSHED; } return RES_PASTDEST; } else { lastpos = sector->ceilingheight; sector->ceilingheight += speed; flag = P_ChangeSector(sector,crush); #if 0 if (flag == true) { sector->ceilingheight = lastpos; P_ChangeSector(sector,crush); return RES_CRUSHED; } #endif } break; } break; } return RES_OK;}//==================================================================//// MOVE A FLOOR TO IT'S DESTINATION (UP OR DOWN)////==================================================================void T_MoveFloor(floormove_t *floor){ result_e res; if(floor->resetDelayCount) { floor->resetDelayCount--; if(!floor->resetDelayCount) { floor->floordestheight = floor->resetHeight; floor->direction = -floor->direction; floor->resetDelay = 0; floor->delayCount = 0; floor->delayTotal = 0; } } if(floor->delayCount) { floor->delayCount--; if(!floor->delayCount && floor->textureChange) { floor->sector->floorpic += floor->textureChange; } return; } res = T_MovePlane(floor->sector,floor->speed, floor->floordestheight,floor->crush,0,floor->direction); if(floor->type == FLEV_RAISEBUILDSTEP) { if((floor->direction == 1 && floor->sector->floorheight >= floor->stairsDelayHeight) || (floor->direction == -1 && floor->sector->floorheight <= floor->stairsDelayHeight)) { floor->delayCount = floor->delayTotal; floor->stairsDelayHeight += floor->stairsDelayHeightDelta; } } if (res == RES_PASTDEST) { SN_StopSequence((mobj_t *)&floor->sector->soundorg); if(floor->delayTotal) { floor->delayTotal = 0; } if(floor->resetDelay) {// floor->resetDelayCount = floor->resetDelay;// floor->resetDelay = 0; return; } floor->sector->specialdata = NULL; /* if (floor->direction == 1) switch(floor->type) { case donutRaise: floor->sector->special = floor->newspecial; floor->sector->floorpic = floor->texture; default: break; } else if (floor->direction == -1) switch(floor->type) { case lowerAndChange: floor->sector->special = floor->newspecial; floor->sector->floorpic = floor->texture; default: break; } */ if(floor->textureChange) { floor->sector->floorpic -= floor->textureChange; } P_TagFinished(floor->sector->tag); P_RemoveThinker(&floor->thinker); }}//==================================================================//// HANDLE FLOOR TYPES////==================================================================int EV_DoFloor(line_t *line, byte *args, floor_e floortype){ int secnum; int rtn; sector_t *sec; floormove_t *floor=NULL; secnum = -1; rtn = 0; while ((secnum = P_FindSectorFromTag(args[0], secnum)) >= 0) { sec = §ors[secnum]; // ALREADY MOVING? IF SO, KEEP GOING... if (sec->specialdata) continue; // // new floor thinker // rtn = 1; floor = Z_Malloc (sizeof(*floor), PU_LEVSPEC, 0); memset(floor, 0, sizeof(*floor)); P_AddThinker (&floor->thinker); sec->specialdata = floor; floor->thinker.function = T_MoveFloor; floor->type = floortype; floor->crush = 0; floor->speed = args[1]*(FRACUNIT/8); if(floortype == FLEV_LOWERTIMES8INSTANT || floortype == FLEV_RAISETIMES8INSTANT) { floor->speed = 2000<<FRACBITS; } switch(floortype) { case FLEV_LOWERFLOOR: floor->direction = -1; floor->sector = sec; floor->floordestheight = P_FindHighestFloorSurrounding(sec); break; case FLEV_LOWERFLOORTOLOWEST: floor->direction = -1; floor->sector = sec; floor->floordestheight = P_FindLowestFloorSurrounding(sec); break; case FLEV_LOWERFLOORBYVALUE: floor->direction = -1; floor->sector = sec; floor->floordestheight = floor->sector->floorheight- args[2]*FRACUNIT; break; case FLEV_LOWERTIMES8INSTANT: case FLEV_LOWERBYVALUETIMES8: floor->direction = -1; floor->sector = sec; floor->floordestheight = floor->sector->floorheight- args[2]*FRACUNIT*8; break; case FLEV_RAISEFLOORCRUSH: floor->crush = args[2]; // arg[2] = crushing value floor->direction = 1; floor->sector = sec; floor->floordestheight = sec->ceilingheight-8*FRACUNIT; break; case FLEV_RAISEFLOOR: floor->direction = 1; floor->sector = sec; floor->floordestheight = P_FindLowestCeilingSurrounding(sec); if (floor->floordestheight > sec->ceilingheight) floor->floordestheight = sec->ceilingheight; break; case FLEV_RAISEFLOORTONEAREST: floor->direction = 1; floor->sector = sec; floor->floordestheight = P_FindNextHighestFloor(sec,sec->floorheight); break; case FLEV_RAISEFLOORBYVALUE: floor->direction = 1; floor->sector = sec; floor->floordestheight = floor->sector->floorheight+ args[2]*FRACUNIT; break; case FLEV_RAISETIMES8INSTANT: case FLEV_RAISEBYVALUETIMES8: floor->direction = 1; floor->sector = sec; floor->floordestheight = floor->sector->floorheight+ args[2]*FRACUNIT*8; break; case FLEV_MOVETOVALUETIMES8: floor->sector = sec; floor->floordestheight = args[2]*FRACUNIT*8; if(args[3]) { floor->floordestheight = -floor->floordestheight; } if(floor->floordestheight > floor->sector->floorheight) { floor->direction = 1; } else if(floor->floordestheight < floor->sector->floorheight) { floor->direction = -1; } else { // already at lowest position rtn = 0; } break; default: rtn = 0; break; } } if(rtn) { SN_StartSequence((mobj_t *)&floor->sector->soundorg, SEQ_PLATFORM+floor->sector->seqType); } return rtn;}//============================================================================//// EV_DoFloorAndCeiling////============================================================================int EV_DoFloorAndCeiling(line_t *line, byte *args, boolean raise){ boolean floor, ceiling; int secnum; sector_t *sec; if(raise) { floor = EV_DoFloor(line, args, FLEV_RAISEFLOORBYVALUE); secnum = -1; while((secnum = P_FindSectorFromTag(args[0], secnum)) >= 0) { sec = §ors[secnum]; sec->specialdata = NULL; } ceiling = EV_DoCeiling(line, args, CLEV_RAISEBYVALUE); } else { floor = EV_DoFloor(line, args, FLEV_LOWERFLOORBYVALUE); secnum = -1; while ((secnum = P_FindSectorFromTag(args[0], secnum)) >= 0) { sec = §ors[secnum]; sec->specialdata = NULL; } ceiling = EV_DoCeiling(line, args, CLEV_LOWERBYVALUE); } return (floor|ceiling);} // ===== Build Stairs Private Data =====#define STAIR_SECTOR_TYPE 26#define STAIR_QUEUE_SIZE 32struct{ sector_t *sector; int type; int height;} StairQueue[STAIR_QUEUE_SIZE];static int QueueHead;static int QueueTail;static int StepDelta;static int Direction;static int Speed;static int Texture;static int StartDelay;static int StartDelayDelta;static int TextureChange;static int StartHeight;//==========================================================================//// QueueStairSector////==========================================================================static void QueueStairSector(sector_t *sec, int type, int height){ if((QueueTail+1)%STAIR_QUEUE_SIZE == QueueHead) { I_Error("BuildStairs: Too many branches located.\n");
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -