📄 p_spec.c
字号:
//**************************************************************************//**//** p_spec.c : Heretic 2 : Raven Software, Corp.//**//** $RCSfile: p_spec.c,v $//** $Revision: 1.67 $//** $Date: 96/01/06 18:37:33 $//** $Author: bgokey $//**//**************************************************************************// HEADER FILES ------------------------------------------------------------#include "h2def.h"#include "p_local.h"#include "soundst.h"// MACROS ------------------------------------------------------------------#define MAX_TAGGED_LINES 64// TYPES -------------------------------------------------------------------// EXTERNAL FUNCTION PROTOTYPES --------------------------------------------// PUBLIC FUNCTION PROTOTYPES ----------------------------------------------// PRIVATE FUNCTION PROTOTYPES ---------------------------------------------static boolean CheckedLockedDoor(mobj_t *mo, byte lock);// EXTERNAL DATA DECLARATIONS ----------------------------------------------// PUBLIC DATA DEFINITIONS -------------------------------------------------int *TerrainTypes;struct{ char *name; int type;} TerrainTypeDefs[] ={ { "X_005", FLOOR_WATER }, { "X_001", FLOOR_LAVA }, { "X_009", FLOOR_SLUDGE }, { "F_033", FLOOR_ICE }, { "END", -1 }};// PRIVATE DATA DEFINITIONS ------------------------------------------------static struct{ line_t *line; int lineTag;} TaggedLines[MAX_TAGGED_LINES];static int TaggedLineCount;mobj_t LavaInflictor;// CODE --------------------------------------------------------------------//==========================================================================//// P_InitLava////==========================================================================void P_InitLava(void){ memset(&LavaInflictor, 0, sizeof(mobj_t)); LavaInflictor.type = MT_CIRCLEFLAME; LavaInflictor.flags2 = MF2_FIREDAMAGE|MF2_NODMGTHRUST;}//==========================================================================//// P_InitTerrainTypes////==========================================================================void P_InitTerrainTypes(void){ int i; int lump; int size; size = (numflats+1)*sizeof(int); TerrainTypes = Z_Malloc(size, PU_STATIC, 0); memset(TerrainTypes, 0, size); for(i = 0; TerrainTypeDefs[i].type != -1; i++) { lump = W_CheckNumForName(TerrainTypeDefs[i].name); if(lump != -1) { TerrainTypes[lump-firstflat] = TerrainTypeDefs[i].type; } }}//==========================================================================//// getSide//// Will return a side_t* given the number of the current sector, the// line number, and the side (0/1) that you want.////==========================================================================/*side_t *getSide(int currentSector, int line, int side){ return &sides[ (sectors[currentSector].lines[line])->sidenum[side] ];}*///==========================================================================//// getSector//// Will return a sector_t* given the number of the current sector, the// line number, and the side (0/1) that you want.////==========================================================================/*sector_t *getSector(int currentSector, int line, int side){ return sides[ (sectors[currentSector].lines[line])->sidenum[side] ].sector;}*///==========================================================================//// twoSided//// Given the sector number and the line number, will tell you whether// the line is two-sided or not.////==========================================================================/*int twoSided(int sector, int line){ return (sectors[sector].lines[line])->flags & ML_TWOSIDED;}*///==================================================================//// Return sector_t * of sector next to current. NULL if not two-sided line////==================================================================sector_t *getNextSector(line_t *line,sector_t *sec){ if (!(line->flags & ML_TWOSIDED)) return NULL; if (line->frontsector == sec) return line->backsector; return line->frontsector;}//==================================================================//// FIND LOWEST FLOOR HEIGHT IN SURROUNDING SECTORS////==================================================================fixed_t P_FindLowestFloorSurrounding(sector_t *sec){ int i; line_t *check; sector_t *other; fixed_t floor = sec->floorheight; for (i=0 ;i < sec->linecount ; i++) { check = sec->lines[i]; other = getNextSector(check,sec); if (!other) continue; if (other->floorheight < floor) floor = other->floorheight; } return floor;}//==================================================================//// FIND HIGHEST FLOOR HEIGHT IN SURROUNDING SECTORS////==================================================================fixed_t P_FindHighestFloorSurrounding(sector_t *sec){ int i; line_t *check; sector_t *other; fixed_t floor = -500*FRACUNIT; for (i=0 ;i < sec->linecount ; i++) { check = sec->lines[i]; other = getNextSector(check,sec); if (!other) continue; if (other->floorheight > floor) floor = other->floorheight; } return floor;}//==================================================================//// FIND NEXT HIGHEST FLOOR IN SURROUNDING SECTORS////==================================================================fixed_t P_FindNextHighestFloor(sector_t *sec,int currentheight){ int i; int h; int min; line_t *check; sector_t *other; fixed_t height = currentheight; fixed_t heightlist[20]; // 20 adjoining sectors max! for (i =0,h = 0 ;i < sec->linecount ; i++) { check = sec->lines[i]; other = getNextSector(check,sec); if (!other) continue; if (other->floorheight > height) heightlist[h++] = other->floorheight; } // // Find lowest height in list // min = heightlist[0]; for (i = 1;i < h;i++) if (heightlist[i] < min) min = heightlist[i]; return min;}//==================================================================//// FIND LOWEST CEILING IN THE SURROUNDING SECTORS////==================================================================fixed_t P_FindLowestCeilingSurrounding(sector_t *sec){ int i; line_t *check; sector_t *other; fixed_t height = MAXINT; for (i=0 ;i < sec->linecount ; i++) { check = sec->lines[i]; other = getNextSector(check,sec); if (!other) continue; if (other->ceilingheight < height) height = other->ceilingheight; } return height;}//==================================================================//// FIND HIGHEST CEILING IN THE SURROUNDING SECTORS////==================================================================fixed_t P_FindHighestCeilingSurrounding(sector_t *sec){ int i; line_t *check; sector_t *other; fixed_t height = 0; for (i=0 ;i < sec->linecount ; i++) { check = sec->lines[i]; other = getNextSector(check,sec); if (!other) continue; if (other->ceilingheight > height) height = other->ceilingheight; } return height;}//==================================================================//// RETURN NEXT SECTOR # THAT LINE TAG REFERS TO////==================================================================/*int P_FindSectorFromLineTag(line_t *line,int start){ int i; for (i=start+1;i<numsectors;i++) if (sectors[i].tag == line->arg1) return i; return -1;}*///=========================================================================//// P_FindSectorFromTag////=========================================================================int P_FindSectorFromTag(int tag, int start){ int i; for(i = start+1; i < numsectors; i++) { if(sectors[i].tag == tag) { return i; } } return -1;}//==================================================================//// Find minimum light from an adjacent sector////==================================================================/*int P_FindMinSurroundingLight(sector_t *sector,int max){ int i; int min; line_t *line; sector_t *check; min = max; for (i=0 ; i < sector->linecount ; i++) { line = sector->lines[i]; check = getNextSector(line,sector); if (!check) continue; if (check->lightlevel < min) min = check->lightlevel; } return min;}*///=========================================================================//// EV_SectorSoundChange////=========================================================================boolean EV_SectorSoundChange(byte *args){ int secNum; boolean rtn; if(!args[0]) { return false; } secNum = -1; rtn = false; while((secNum = P_FindSectorFromTag(args[0], secNum)) >= 0) { sectors[secNum].seqType = args[1]; rtn = true; } return rtn;}//============================================================================//// CheckedLockedDoor////============================================================================static boolean CheckedLockedDoor(mobj_t *mo, byte lock){ extern char *TextKeyMessages[11]; char LockedBuffer[80]; if(!mo->player) { return false; } if(!lock) { return true; } if(!(mo->player->keys&(1<<(lock-1)))) { sprintf(LockedBuffer, "YOU NEED THE %s\n", TextKeyMessages[lock-1]); P_SetMessage(mo->player, LockedBuffer, true); S_StartSound(mo, SFX_DOOR_LOCKED); return false; } return true;}//==========================================================================//// EV_LineSearchForPuzzleItem////==========================================================================boolean EV_LineSearchForPuzzleItem(line_t *line, byte *args, mobj_t *mo){ player_t *player; int i; artitype_t type,arti; if (!mo) return false; player = mo->player; if (!player) return false; // Search player's inventory for puzzle items for (i=0; i<player->artifactCount; i++) { arti = player->inventory[i].type; type = arti - arti_firstpuzzitem; if (type < 0) continue; if (type == line->arg1) { // A puzzle item was found for the line if (P_UseArtifact(player, arti)) { // A puzzle item was found for the line P_PlayerRemoveArtifact(player, i); if(player == &players[consoleplayer]) { if(arti < arti_firstpuzzitem) { S_StartSound(NULL, SFX_ARTIFACT_USE); } else { S_StartSound(NULL, SFX_PUZZLE_SUCCESS); } ArtifactFlash = 4; } return true; } } } return false;}/*============================================================================== EVENTSEvents are operations triggered by using, crossing, or shooting special lines, or by timed thinkers==============================================================================*///============================================================================//// P_ExecuteLineSpecial////============================================================================boolean P_ExecuteLineSpecial(int special, byte *args, line_t *line, int side, mobj_t *mo){ boolean buttonSuccess; buttonSuccess = false; switch(special) { case 1: // Poly Start Line break; case 2: // Poly Rotate Left buttonSuccess = EV_RotatePoly(line, args, 1, false); break; case 3: // Poly Rotate Right buttonSuccess = EV_RotatePoly(line, args, -1, false); break; case 4: // Poly Move buttonSuccess = EV_MovePoly(line, args, false, false); break; case 5: // Poly Explicit Line: Only used in initialization break; case 6: // Poly Move Times 8 buttonSuccess = EV_MovePoly(line, args, true, false); break; case 7: // Poly Door Swing buttonSuccess = EV_OpenPolyDoor(line, args, PODOOR_SWING); break; case 8: // Poly Door Slide buttonSuccess = EV_OpenPolyDoor(line, args, PODOOR_SLIDE); break; case 10: // Door Close buttonSuccess = EV_DoDoor(line, args, DREV_CLOSE); break; case 11: // Door Open if(!args[0]) { buttonSuccess = EV_VerticalDoor(line, mo); } else { buttonSuccess = EV_DoDoor(line, args, DREV_OPEN); } break; case 12: // Door Raise if(!args[0]) { buttonSuccess = EV_VerticalDoor(line, mo); } else { buttonSuccess = EV_DoDoor(line, args, DREV_NORMAL); } break; case 13: // Door Locked_Raise if(CheckedLockedDoor(mo, args[3])) { if(!args[0]) { buttonSuccess = EV_VerticalDoor(line, mo); } else { buttonSuccess = EV_DoDoor(line, args, DREV_NORMAL); } } break; case 20: // Floor Lower by Value buttonSuccess = EV_DoFloor(line, args, FLEV_LOWERFLOORBYVALUE); break; case 21: // Floor Lower to Lowest buttonSuccess = EV_DoFloor(line, args, FLEV_LOWERFLOORTOLOWEST); break; case 22: // Floor Lower to Nearest buttonSuccess = EV_DoFloor(line, args, FLEV_LOWERFLOOR); break; case 23: // Floor Raise by Value buttonSuccess = EV_DoFloor(line, args, FLEV_RAISEFLOORBYVALUE); break; case 24: // Floor Raise to Highest buttonSuccess = EV_DoFloor(line, args, FLEV_RAISEFLOOR); break; case 25: // Floor Raise to Nearest buttonSuccess = EV_DoFloor(line, args, FLEV_RAISEFLOORTONEAREST); break; case 26: // Stairs Build Down Normal buttonSuccess = EV_BuildStairs(line, args, -1, STAIRS_NORMAL); break; case 27: // Build Stairs Up Normal buttonSuccess = EV_BuildStairs(line, args, 1, STAIRS_NORMAL); break; case 28: // Floor Raise and Crush buttonSuccess = EV_DoFloor(line, args, FLEV_RAISEFLOORCRUSH); break;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -