1 //************************************************************************** 2 //** 3 //** ## ## ## ## ## #### #### ### ### 4 //** ## ## ## ## ## ## ## ## ## ## #### #### 5 //** ## ## ## ## ## ## ## ## ## ## ## ## ## ## 6 //** ## ## ######## ## ## ## ## ## ## ## ### ## 7 //** ### ## ## ### ## ## ## ## ## ## 8 //** # ## ## # #### #### ## ## 9 //** 10 //** $Id: p_gameobject.h 4305 2010-06-12 22:08:53Z firebrand_kh $ 11 //** 12 //** Copyright (C) 1999-2006 Jānis Legzdiņš 13 //** 14 //** This program is free software; you can redistribute it and/or 15 //** modify it under the terms of the GNU General Public License 16 //** as published by the Free Software Foundation; either version 2 17 //** of the License, or (at your option) any later version. 18 //** 19 //** This program is distributed in the hope that it will be useful, 20 //** but WITHOUT ANY WARRANTY; without even the implied warranty of 21 //** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 //** GNU General Public License for more details. 23 //** 24 //************************************************************************** 25 //** 26 //** INTERNAL DATA TYPES 27 //** used by play and refresh 28 //** 29 //************************************************************************** 30 31 class VRenderLevelPublic; 32 class VTextureTranslation; 33 class VAcsLevel; 34 class VNetContext; 35 36 struct sector_t; 37 struct mapInfo_t; 38 struct fakefloor_t; 39 struct seg_t; 40 struct subsector_t; 41 struct node_t; 42 struct drawseg_t; 43 struct subregion_t; 44 45 class VThinker; 46 class VLevelInfo; 47 class VEntity; 48 class VBasePlayer; 49 class VWorldInfo; 50 class VGameInfo; 51 52 // All line specials that are used by the engine. 53 enum 54 { 55 LNSPEC_PolyStartLine = 1, 56 LNSPEC_PolyExplicitLine = 5, 57 LNSPEC_LineHorizon = 9, 58 LNSPEC_DoorLockedRaise = 13, 59 LNSPEC_ACSLockedExecute = 83, 60 LNSPEC_ACSLockedExecuteDoor = 85, 61 LNSPEC_LineMirror = 182, 62 LNSPEC_StaticInit = 190, 63 LNSPEC_LineTranslucent = 208, 64 LNSPEC_TransferHeights = 209, 65 }; 66 67 //========================================================================== 68 // 69 // Vertex 70 // 71 //========================================================================== 72 73 // 74 // Your plain vanilla vertex. 75 // Note: transformed values not buffered locally, 76 // like some DOOM-alikes ("wt", "WebView") did. 77 // 78 typedef TVec vertex_t; 79 80 //========================================================================== 81 // 82 // LineDef 83 // 84 //========================================================================== 85 86 // 87 // Move clipping aid for LineDefs. 88 // 89 enum 90 { 91 ST_HORIZONTAL, 92 ST_VERTICAL, 93 ST_POSITIVE, 94 ST_NEGATIVE 95 }; 96 97 // If a texture is pegged, the texture will have the end exposed to air held 98 // constant at the top or bottom of the texture (stairs or pulled down 99 // things) and will move with a height change of one of the neighbor sectors. 100 // Unpegged textures allways have the first row of the texture at the top 101 // pixel of the line for both top and bottom textures (use next to windows). 102 103 // 104 // LineDef attributes. 105 // 106 enum 107 { 108 ML_BLOCKING = 0x00000001, // Solid, is an obstacle. 109 ML_BLOCKMONSTERS = 0x00000002, // Blocks monsters only. 110 ML_TWOSIDED = 0x00000004, // Backside will not be present at all 111 ML_DONTPEGTOP = 0x00000008, // upper texture unpegged 112 ML_DONTPEGBOTTOM = 0x00000010, // lower texture unpegged 113 ML_SECRET = 0x00000020, // don't map as two sided: IT'S A SECRET! 114 ML_SOUNDBLOCK = 0x00000040, // don't let sound cross two of these 115 ML_DONTDRAW = 0x00000080, // don't draw on the automap 116 ML_MAPPED = 0x00000100, // set if already drawn in automap 117 ML_REPEAT_SPECIAL = 0x00000200, // special is repeatable 118 ML_ADDITIVE = 0x00000400, // Additive translucency. 119 ML_MONSTERSCANACTIVATE = 0x00002000, // Monsters (as well as players) can activate the line 120 ML_BLOCKPLAYERS = 0x00004000, // Blocks players only. 121 ML_BLOCKEVERYTHING = 0x00008000, // Line blocks everything. 122 ML_ZONEBOUNDARY = 0x00010000, // Boundary of reverb zones. 123 ML_RAILING = 0x00020000, 124 ML_BLOCK_FLOATERS = 0x00040000, 125 ML_CLIP_MIDTEX = 0x00080000, // Automatic for every Strife line 126 ML_WRAP_MIDTEX = 0x00100000, 127 ML_FIRSTSIDEONLY = 0x00800000, // Actiavte only when crossed from front side. 128 ML_KEEPDATA = 0x01000000, // Keep FloorData or CeilingData after activating them. 129 // Used to simulate original Heretic behaviour. 130 131 ML_SPAC_SHIFT = 10, 132 ML_SPAC_MASK = 0x00001c00, 133 }; 134 135 // 136 // Special activation types 137 // 138 enum 139 { 140 SPAC_Cross = 0x0001, // when player crosses line 141 SPAC_Use = 0x0002, // when player uses line 142 SPAC_MCross = 0x0004, // when monster crosses line 143 SPAC_Impact = 0x0008, // when projectile hits line 144 SPAC_Push = 0x0010, // when player pushes line 145 SPAC_PCross = 0x0020, // when projectile crosses line 146 SPAC_UseThrough = 0x0040, // SPAC_USE, but passes it through 147 // SPAC_PTouch is remapped as SPAC_Impact | SPAC_PCross 148 SPAC_AnyCross = 0x0080, 149 SPAC_MUse = 0x0100, // when monster uses line 150 SPAC_MPush = 0x0200, // when monster pushes line 151 }; 152 153 struct line_t : public TPlane 154 { 155 // Vertices, from v1 to v2. 156 vertex_t* v1; 157 vertex_t* v2; 158 159 // Precalculated v2 - v1 for side checking. 160 TVec dir; 161 162 // Animation related. 163 int flags; 164 int SpacFlags; 165 166 // Visual appearance: SideDefs. 167 // sidenum[1] will be -1 if one sided 168 int sidenum[2]; 169 170 // Neat. Another bounding box, for the extent 171 // of the LineDef. 172 float bbox[4]; 173 174 // To aid move clipping. 175 int slopetype; 176 177 // Front and back sector. 178 // Note: redundant? Can be retrieved from SideDefs. 179 sector_t* frontsector; 180 sector_t* backsector; 181 182 // if == validcount, already checked 183 int validcount; 184 185 float alpha; 186 187 int special; 188 int arg1; 189 int arg2; 190 int arg3; 191 int arg4; 192 int arg5; 193 194 int LineTag; 195 int HashFirst; 196 int HashNext; 197 }; 198 199 //========================================================================== 200 // 201 // SideDef 202 // 203 //========================================================================== 204 205 enum 206 { 207 SDF_ABSLIGHT = 0x0001, // Light is absolute value. 208 }; 209 210 struct side_t 211 { 212 // Add this to the calculated texture column 213 float TopTextureOffset; 214 float BotTextureOffset; 215 float MidTextureOffset; 216 217 // Add this to the calculated texture top 218 float TopRowOffset; 219 float BotRowOffset; 220 float MidRowOffset; 221 222 // Texture indices. We do not maintain names here. 223 int TopTexture; 224 int BottomTexture; 225 int MidTexture; 226 227 // Sector the SideDef is facing. 228 sector_t* Sector; 229 230 int LineNum; 231 232 vuint32 Flags; 233 234 int Light; 235 }; 236 237 //========================================================================== 238 // 239 // Sector 240 // 241 //========================================================================== 242 243 enum 244 { 245 SPF_NOBLOCKING = 1, // Not blocking 246 SPF_NOBLOCKSIGHT = 2, // Do not block sight 247 SPF_NOBLOCKSHOOT = 4, // Do not block shooting 248 SPF_ADDITIVE = 8, // Additive translucency 249 }; 250 251 enum 252 { 253 SKY_FROM_SIDE = 0x8000 254 }; 255 256 struct sec_plane_t : public TPlane 257 { 258 float minz; 259 float maxz; 260 261 // Use for wall texture mapping. 262 float TexZ; 263 264 int pic; 265 266 float xoffs; 267 float yoffs; 268 269 float XScale; 270 float YScale; 271 272 float Angle; 273 274 float BaseAngle; 275 float BaseYOffs; 276 277 int flags; 278 float Alpha; 279 float MirrorAlpha; 280 281 int LightSourceSector; 282 VEntity* SkyBox; 283 }; 284 285 struct sec_params_t 286 { 287 int lightlevel; 288 int LightColour; 289 int Fade; 290 int contents; 291 }; 292 293 struct sec_region_t 294 { 295 // Linked list of regions in bottom to top order 296 sec_region_t* prev; 297 sec_region_t* next; 298 299 // Planes 300 sec_plane_t* floor; 301 sec_plane_t* ceiling; 302 303 sec_params_t* params; 304 line_t* extraline; 305 }; 306 307 // 308 // phares 3/14/98 309 // 310 // Sector list node showing all sectors an object appears in. 311 // 312 // There are two threads that flow through these nodes. The first thread 313 // starts at TouchingThingList in a sector_t and flows through the SNext 314 // links to find all mobjs that are entirely or partially in the sector. 315 // The second thread starts at TouchingSectorList in a VEntity and flows 316 // through the TNext links to find all sectors a thing touches. This is 317 // useful when applying friction or push effects to sectors. These effects 318 // can be done as thinkers that act upon all objects touching their sectors. 319 // As an mobj moves through the world, these nodes are created and 320 // destroyed, with the links changed appropriately. 321 // 322 // For the links, NULL means top or end of list. 323 // 324 struct msecnode_t 325 { 326 sector_t* Sector; // a sector containing this object 327 VEntity* Thing; // this object 328 msecnode_t* TPrev; // prev msecnode_t for this thing 329 msecnode_t* TNext; // next msecnode_t for this thing 330 msecnode_t* SPrev; // prev msecnode_t for this sector 331 msecnode_t* SNext; // next msecnode_t for this sector 332 bool Visited;// killough 4/4/98, 4/7/98: used in search algorithms 333 }; 334 335 // 336 // The SECTORS record, at runtime. 337 // Stores things/mobjs. 338 // 339 struct sector_t 340 { 341 sec_plane_t floor; 342 sec_plane_t ceiling; 343 sec_params_t params; 344 345 sec_region_t *topregion; // Highest region 346 sec_region_t *botregion; // Lowest region 347 348 int special; 349 int tag; 350 int HashFirst; 351 int HashNext; 352 353 float skyheight; 354 355 // stone, metal, heavy, etc... 356 int seqType; 357 358 // mapblock bounding box for height changes 359 int blockbox[4]; 360 361 // origin for any sounds played by the sector 362 TVec soundorg; 363 364 // if == validcount, already checked 365 int validcount; 366 367 // list of subsectors in sector 368 // used to check if client can see this sector (it needs to be updated) 369 subsector_t* subsectors; 370 371 // List of things in sector. 372 VEntity* ThingList; 373 msecnode_t* TouchingThingList; 374 375 int linecount; 376 line_t** lines; // [linecount] size 377 378 // Boom's fake floors. 379 sector_t* heightsec; 380 fakefloor_t* fakefloors; // Info for rendering. 381 382 // Flags. 383 enum 384 { 385 SF_HasExtrafloors = 0x0001, // This sector has extrafloors. 386 SF_ExtrafloorSource = 0x0002, // This sector is a source of an extrafloor. 387 SF_TransferSource = 0x0004, // Source of an heightsec or transfer light. 388 SF_FakeFloorOnly = 0x0008, // When used as heightsec in R_FakeFlat, only copies floor 389 SF_ClipFakePlanes = 0x0010, // As a heightsec, clip planes to target sector's planes 390 SF_NoFakeLight = 0x0020, // heightsec does not change lighting 391 SF_IgnoreHeightSec = 0x0040, // heightsec is only for triggering sector actions 392 SF_UnderWater = 0x0080, // Sector is underwater 393 SF_Silent = 0x0100, // Actors don't make noise in this sector. 394 SF_NoFallingDamage = 0x0200, // No falling damage in this sector. 395 }; 396 vuint32 SectorFlags; 397 398 // 0 = untraversed, 1,2 = sndlines -1 399 vint32 soundtraversed; 400 401 // thing that made a sound (or null) 402 VEntity* SoundTarget; 403 404 // Thinker for reversable actions 405 VThinker* FloorData; 406 VThinker* CeilingData; 407 VThinker* LightingData; 408 VThinker* AffectorData; 409 410 // Sector action triggers. 411 VEntity* ActionList; 412 413 vint32 Damage; 414 415 float Friction; 416 float MoveFactor; 417 float Gravity; // Sector gravity (1.0 is normal) 418 419 int Sky; 420 421 int Zone; 422 }; 423 424 //========================================================================== 425 // 426 // Polyobject 427 // 428 //========================================================================== 429 430 // 431 // ===== Polyobj data ===== 432 // 433 struct polyobj_t 434 { 435 int numsegs; 436 seg_t** segs; 437 TVec startSpot; 438 vertex_t* originalPts; // used as the base for the rotations 439 vertex_t* prevPts; // use to restore the old point values 440 float angle; 441 int tag; // reference tag assigned in HereticEd 442 int bbox[4]; 443 int validcount; 444 enum 445 { 446 PF_Crush = 0x01, // should the polyobj attempt to crush mobjs? 447 PF_HurtOnTouch = 0x02, 448 }; 449 vuint32 PolyFlags; 450 int seqType; 451 subsector_t* subsector; 452 VThinker* SpecialData; // pointer a thinker, if the poly is moving 453 }; 454 455 // 456 // 457 // 458 struct polyblock_t 459 { 460 polyobj_t* polyobj; 461 polyblock_t* prev; 462 polyblock_t* next; 463 }; 464 465 struct PolyAnchorPoint_t 466 { 467 float x; 468 float y; 469 int tag; 470 }; 471 472 //========================================================================== 473 // 474 // LineSeg 475 // 476 //========================================================================== 477 478 struct seg_t : public TPlane 479 { 480 vertex_t *v1; 481 vertex_t *v2; 482 483 float offset; 484 float length; 485 486 side_t *sidedef; 487 line_t *linedef; 488 489 // Sector references. 490 // Could be retrieved from linedef, too. 491 // backsector is NULL for one sided lines 492 sector_t *frontsector; 493 sector_t *backsector; 494 495 // Side of line (for light calculations) 496 int side; 497 498 drawseg_t *drawsegs; 499 }; 500 501 //========================================================================== 502 // 503 // Subsector 504 // 505 //========================================================================== 506 507 // 508 // A SubSector. 509 // References a Sector. Basically, this is a list of LineSegs, indicating 510 // the visible walls that define (all or some) sides of a convex BSP leaf. 511 // 512 struct subsector_t 513 { 514 sector_t* sector; 515 subsector_t* seclink; 516 int numlines; 517 int firstline; 518 polyobj_t* poly; 519 520 node_t* parent; 521 int VisFrame; 522 int SkyVisFrame; 523 524 vuint32 dlightbits; 525 int dlightframe; 526 subregion_t* regions; 527 }; 528 529 //========================================================================== 530 // 531 // Node 532 // 533 //========================================================================== 534 535 // 536 // Indicate a leaf. 537 // 538 enum 539 { 540 NF_SUBSECTOR = 0x80000000 541 }; 542 543 // 544 // BSP node. 545 // 546 struct node_t : public TPlane 547 { 548 // Bounding box for each child. 549 float bbox[2][6]; 550 551 // If NF_SUBSECTOR its a subsector. 552 vuint32 children[2]; 553 554 node_t *parent; 555 int VisFrame; 556 int SkyVisFrame; 557 }; 558 559 //========================================================================== 560 // 561 // Thing 562 // 563 //========================================================================== 564 565 // 566 // Map thing definition with initialised fields for global use. 567 // 568 struct mthing_t 569 { 570 int tid; 571 float x; 572 float y; 573 float height; 574 int angle; 575 int type; 576 int options; 577 int SkillClassFilter; 578 int special; 579 int arg1; 580 int arg2; 581 int arg3; 582 int arg4; 583 int arg5; 584 }; 585 586 //========================================================================== 587 // 588 // Strife conversation scripts 589 // 590 //========================================================================== 591 592 struct FRogueConChoice 593 { 594 vint32 GiveItem; // Item given on success 595 vint32 NeedItem1; // Required item 1 596 vint32 NeedItem2; // Required item 2 597 vint32 NeedItem3; // Required item 3 598 vint32 NeedAmount1;// Amount of item 1 599 vint32 NeedAmount2;// Amount of item 2 600 vint32 NeedAmount3;// Amount of item 3 601 VStr Text; // Text of the answer 602 VStr TextOK; // Message displayed on success 603 vint32 Next; // Dialog to go on success, negative values 604 // to go here immediately 605 vint32 Objectives; // Mission objectives, LOGxxxx lump 606 VStr TextNo; // Message displayed on failure (player doesn't 607 // have needed thing, it haves enough health/ammo, 608 // item is not ready, quest is not completed) 609 }; 610 611 struct FRogueConSpeech 612 { 613 vint32 SpeakerID; // Type of the object (MT_xxx) 614 vint32 DropItem; // Item dropped when killed 615 vint32 CheckItem1; // Item 1 to check for jump 616 vint32 CheckItem2; // Item 2 to check for jump 617 vint32 CheckItem3; // Item 3 to check for jump 618 vint32 JumpToConv; // Jump to conversation if have certain item(s) 619 VStr Name; // Name of the character 620 VName Voice; // Voice to play 621 VName BackPic; // Picture of the speaker 622 VStr Text; // Message 623 FRogueConChoice Choices[5]; // Choices 624 }; 625 626 //========================================================================== 627 // 628 // Misc game structs 629 // 630 //========================================================================== 631 632 enum 633 { 634 PT_ADDLINES = 1, 635 PT_ADDTHINGS = 2, 636 PT_EARLYOUT = 4, 637 }; 638 639 struct intercept_t 640 { 641 float frac; // along trace line 642 enum 643 { 644 IF_IsALine = 0x01, 645 }; 646 vuint32 Flags; 647 VEntity* thing; 648 line_t* line; 649 }; 650 651 struct linetrace_t 652 { 653 TVec Start; 654 TVec End; 655 TVec Delta; 656 TPlane Plane; // from t1 to t2 657 TVec LineStart; 658 TVec LineEnd; 659 vuint32 PlaneNoBlockFlags; 660 TVec HitPlaneNormal; 661 bool SightEarlyOut; 662 }; 663 664 struct VStateCall 665 { 666 VEntity* Item; 667 VState* State; 668 vuint8 Result; 669 }; 670 671 //========================================================================== 672 // 673 // VGameObject 674 // 675 //========================================================================== 676 677 class VGameObject : public VObject 678 { 679 DECLARE_CLASS(VGameObject, VObject, 0) 680 NO_DEFAULT_CONSTRUCTOR(VGameObject) 681 }; 682