📄 p_spec.c
字号:
// Emacs style mode select -*- C++ -*-//-----------------------------------------------------------------------------//// $Id: p_spec.c,v 1.25 2001/05/03 18:23:30 crashrl Exp $//// Copyright (C) 1993-1996 by id Software, Inc.// Portions Copyright (C) 1998-2000 by DooM Legacy Team.//// This program is free software; you can redistribute it and/or// modify it under the terms of the GNU General Public License// as published by the Free Software Foundation; either version 2// of the License, or (at your option) any later version.//// This program is distributed in the hope that it will be useful,// but WITHOUT ANY WARRANTY; without even the implied warranty of// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the// GNU General Public License for more details.////// $Log: p_spec.c,v $// Revision 1.25 2001/05/03 18:23:30 crashrl// corrected wrong comment concerning teamstartsec//// Revision 1.24 2001/04/04 20:24:21 judgecutor// Added support for the 3D Sound//// Revision 1.23 2001/03/21 18:24:38 stroggonmeth// Misc changes and fixes. Code cleanup//// Revision 1.22 2001/03/13 22:14:19 stroggonmeth// Long time no commit. 3D floors, FraggleScript, portals, ect.//// Revision 1.21 2001/02/24 13:35:20 bpereira// no message//// Revision 1.20 2001/01/25 22:15:44 bpereira// added heretic support//// Revision 1.19 2000/11/21 21:13:17 stroggonmeth// Optimised 3D floors and fixed crashing bug in high resolutions.//// Revision 1.18 2000/11/11 13:59:45 bpereira// no message//// Revision 1.17 2000/11/04 16:23:43 bpereira// no message//// Revision 1.16 2000/11/02 17:50:08 stroggonmeth// Big 3Dfloors & FraggleScript commit!!//// Revision 1.15 2000/10/21 08:43:30 bpereira// no message//// Revision 1.14 2000/10/07 20:36:13 crashrl// Added deathmatch team-start-sectors via sector/line-tag and linedef-type 1000-1031//// Revision 1.13 2000/05/23 15:22:34 stroggonmeth// Not much. A graphic bug fixed.//// Revision 1.12 2000/05/03 23:51:00 stroggonmeth// A few, quick, changes.//// Revision 1.11 2000/04/16 18:38:07 bpereira// no message//// Revision 1.10 2000/04/15 22:12:57 stroggonmeth// Minor bug fixes//// Revision 1.9 2000/04/13 23:47:47 stroggonmeth// See logs//// Revision 1.8 2000/04/11 19:07:24 stroggonmeth// Finished my logs, fixed a crashing bug.//// Revision 1.7 2000/04/08 17:29:25 stroggonmeth// no message//// Revision 1.6 2000/04/08 11:27:29 hurdler// fix some boom stuffs//// Revision 1.5 2000/04/06 20:54:28 hurdler// Mostly remove warnings under windows//// Revision 1.4 2000/04/04 19:28:43 stroggonmeth// Global colormaps working. Added a new linedef type 272.//// Revision 1.3 2000/04/04 00:32:47 stroggonmeth// Initial Boom compatability plus few misc changes all around.//// Revision 1.2 2000/02/27 00:42:10 hurdler// fix CR+LF problem//// Revision 1.1.1.1 2000/02/22 20:32:32 hurdler// Initial import into CVS (v1.29 pr3)////// DESCRIPTION:// Implements special effects:// Texture animation, height or lighting changes// according to adjacent sectors, respective// utility functions, etc.// Line Tag handling. Line and Sector triggers.////-----------------------------------------------------------------------------#include "doomdef.h"#include "g_game.h"#include "p_local.h"#include "p_setup.h" //levelflats for flat animation#include "r_data.h"#include "m_random.h"#include "s_sound.h"#include "w_wad.h"#include "z_zone.h"#include "dstrings.h" //SoM: 3/10/2000#include "r_main.h" //Two extra includes.#include "t_script.h"#include "r_sky.h" // Portals#ifdef HW3SOUND#include "hardware/hw3sound.h"#endif//SoM: Enable Boom features?int boomsupport = 1;int variable_friction = 1;int allow_pushers = 1;//SoM: 3/7/2000static void P_SpawnScrollers(void);static void P_SpawnFriction(void);static void P_SpawnPushers(void);static void Add_Pusher(int type, int x_mag, int y_mag, mobj_t* source, int affectee); //SoM: 3/9/2000void P_FindAnimatedFlat (int i);//// Animating textures and planes// There is another anim_t used in wi_stuff, unrelated.//typedef struct{ boolean istexture; int picnum; int basepic; int numpics; int speed;} anim_t;//// source animation definition//#pragma pack(1) //Hurdler: 04/04/2000: I think pragma is more portabletypedef struct{ char istexture; // if false, it is a flat char endname[9]; char startname[9]; int speed;} animdef_t; #pragma pack()#define MAXANIMS 32//SoM: 3/7/2000: New sturcture without limits.static anim_t* lastanim;static anim_t* anims;static size_t maxanims;//// P_InitPicAnims//// Floor/ceiling animation sequences,// defined by first and last frame,// i.e. the flat (64x64 tile) name to// be used.// The full animation sequence is given// using all the flats between the start// and end entry, in the order found in// the WAD file.//animdef_t harddefs[] ={ // DOOM II flat animations. {false, "NUKAGE3", "NUKAGE1", 8}, {false, "FWATER4", "FWATER1", 8}, {false, "SWATER4", "SWATER1", 8}, {false, "LAVA4", "LAVA1", 8}, {false, "BLOOD3", "BLOOD1", 8}, {false, "RROCK08", "RROCK05", 8}, {false, "SLIME04", "SLIME01", 8}, {false, "SLIME08", "SLIME05", 8}, {false, "SLIME12", "SLIME09", 8}, // animated textures {true, "BLODGR4", "BLODGR1", 8}, {true, "SLADRIP3", "SLADRIP1", 8}, {true, "BLODRIP4", "BLODRIP1", 8}, {true, "FIREWALL", "FIREWALA", 8}, {true, "GSTFONT3", "GSTFONT1", 8}, {true, "FIRELAVA", "FIRELAV3", 8}, {true, "FIREMAG3", "FIREMAG1", 8}, {true, "FIREBLU2", "FIREBLU1", 8}, {true, "ROCKRED3", "ROCKRED1", 8}, {true, "BFALL4", "BFALL1", 8}, {true, "SFALL4", "SFALL1", 8}, {true, "WFALL4", "WFALL1", 8}, {true, "DBRAIN4", "DBRAIN1", 8}, // heretic {false, "FLTWAWA3", "FLTWAWA1", 8}, // Water {false, "FLTSLUD3", "FLTSLUD1", 8}, // Sludge {false, "FLTTELE4", "FLTTELE1", 6}, // Teleport {false, "FLTFLWW3", "FLTFLWW1", 9}, // River - West {false, "FLTLAVA4", "FLTLAVA1", 8}, // Lava {false, "FLATHUH4", "FLATHUH1", 8}, // Super Lava {true, "LAVAFL3", "LAVAFL1", 6}, // Texture: Lavaflow {true, "WATRWAL3", "WATRWAL1", 4}, // Texture: Waterfall {-1}};//// Animating line specials//#define MAXLINEANIMS 64short numlinespecials;line_t* linespeciallist[MAXLINEANIMS];//// Init animated textures// - now called at level loading P_SetupLevel()//static animdef_t *animdefs;//SoM: 3/7/2000: Use new boom method of reading lump from wad file.void P_InitPicAnims (void){ // Init animation int i; if(W_CheckNumForName("ANIMATED") != -1) animdefs = (animdef_t *)W_CacheLumpName("ANIMATED",PU_STATIC); else animdefs = harddefs; for (i = 0; animdefs[i].istexture != -1; i++, maxanims++); anims = (anim_t *)malloc(sizeof(anim_t) * (maxanims + 1)); lastanim = anims; for (i = 0; animdefs[i].istexture != -1; i++) { if (animdefs[i].istexture) { // different episode ? if (R_CheckTextureNumForName(animdefs[i].startname) == -1) continue; lastanim->picnum = R_TextureNumForName (animdefs[i].endname); lastanim->basepic = R_TextureNumForName (animdefs[i].startname); } else { if ((W_CheckNumForName(animdefs[i].startname)) == -1) continue; lastanim->picnum = R_FlatNumForName (animdefs[i].endname); lastanim->basepic = R_FlatNumForName (animdefs[i].startname); } lastanim->istexture = (boolean)animdefs[i].istexture; lastanim->numpics = lastanim->picnum - lastanim->basepic + 1; if (lastanim->numpics < 2) I_Error ("P_InitPicAnims: bad cycle from %s to %s", animdefs[i].startname, animdefs[i].endname); lastanim->speed = LONG(animdefs[i].speed) * NEWTICRATERATIO; lastanim++; } lastanim->istexture = -1; if(animdefs != harddefs) Z_ChangeTag (animdefs,PU_CACHE);}// Check for flats in levelflats, that are part// of a flat anim sequence, if so, set them up for animation////SoM: 3/16/2000: Changed parameter from pointer to "anims" entry numbervoid P_FindAnimatedFlat (int animnum){ int i; int startflatnum,endflatnum; levelflat_t* foundflats = levelflats; anim_t* animdef = &anims[animnum]; startflatnum = W_CheckNumForName (animdefs[animnum].startname); if (startflatnum == -1) return; // skip anims not in Doom1 ? endflatnum = W_CheckNumForName (animdefs[animnum].endname); // note: high word of lumpnum is the wad number if ( (startflatnum>>16) != (endflatnum>>16) ) I_Error ("AnimatedFlat start %s not in same wad as end %s\n", animdefs[animnum].startname, animdefs[animnum].endname); // // now search through the levelflats if this anim flat sequence is used // for (i = 0; i<numlevelflats; i++, foundflats++) { // is that levelflat from the flat anim sequence ? if (foundflats->lumpnum >= startflatnum && foundflats->lumpnum <= endflatnum) { foundflats->baselumpnum = startflatnum; foundflats->animseq = foundflats->lumpnum - startflatnum; foundflats->numpics = endflatnum - startflatnum + 1; foundflats->speed = animdef->speed; if (devparm) CONS_Printf("animflat: %#03d name:%.8s animseq:%d numpics:%d speed:%d\n", i, foundflats->name, foundflats->animseq, foundflats->numpics,foundflats->speed); } }}//// Called by P_LoadSectors//void P_SetupLevelFlatAnims (void){ int i; // the original game flat anim sequences for (i=0 ; anims[i].istexture != -1; i++) { if (!anims[i].istexture) { P_FindAnimatedFlat (i); } }}//// UTILITIES////// 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,// it will tell you whether the line is two-sided or not.////SoM: 3/7/2000: Use the boom methodinttwoSided( int sector, int line ){ return boomsupport? ((sectors[sector].lines[line])->sidenum[1] != -1) : ((sectors[sector].lines[line])->flags & ML_TWOSIDED);}//// getNextSector()// Return sector_t * of sector next to current.// NULL if not two-sided line////SoM: 3/7/2000: Use boom method.sector_t*getNextSector( line_t* line, sector_t* sec ){ if (!boomsupport) { if (!(line->flags & ML_TWOSIDED)) return NULL; } if (line->frontsector == sec) { if (!boomsupport || line->backsector!=sec) return line->backsector; else return NULL; } return line->frontsector;}//// P_FindLowestFloorSurrounding()// 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;}//// P_FindHighestFloorSurrounding()// 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; int foundsector = 0; for (i=0 ;i < sec->linecount ; i++) { check = sec->lines[i]; other = getNextSector(check,sec); if (!other) continue; if (other->floorheight > floor || !foundsector) floor = other->floorheight; if(!foundsector)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -