| 1 | /* |
| 2 | * Descent 3 |
| 3 | * Copyright (C) 2024 Parallax Software |
| 4 | * |
| 5 | * This program is free software: you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation, either version 3 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 | |
| 18 | --- HISTORICAL COMMENTS FOLLOW --- |
| 19 | |
| 20 | * $Logfile: /DescentIII/main/doorway.h $ |
| 21 | * $Revision: 15 $ |
| 22 | * $Date: 5/05/99 12:58a $ |
| 23 | * $Author: Matt $ |
| 24 | * |
| 25 | * Doorway structures |
| 26 | * |
| 27 | * $Log: /DescentIII/main/doorway.h $ |
| 28 | * |
| 29 | * 15 5/05/99 12:58a Matt |
| 30 | * Added doorway flag to tell the Guide-Bot to ignore the locked state of |
| 31 | * the door. |
| 32 | * |
| 33 | * 14 4/23/99 8:28p Kevin |
| 34 | * trying to get doors working in save/load games |
| 35 | * |
| 36 | * 13 4/20/99 8:35p Matt |
| 37 | * Changed ActivateDoorway() to not exit if a door is locked. It's the |
| 38 | * caller's responsibility to check if the door is openable (if he cares) |
| 39 | * before activating. |
| 40 | * |
| 41 | * 12 4/20/99 6:55p Matt |
| 42 | * Added code to keep a bitmask of all keys held by all players, and to |
| 43 | * allow a robot to open a door if any player has the key(s) for that |
| 44 | * door. |
| 45 | * |
| 46 | * 11 2/06/99 10:03p Matt |
| 47 | * Added keys system |
| 48 | * |
| 49 | * 10 2/04/99 2:05p Matt |
| 50 | * Added blastable doors |
| 51 | * |
| 52 | * 9 1/29/99 12:47p Matt |
| 53 | * Rewrote the doorway system |
| 54 | * |
| 55 | * 8 9/08/98 12:06p Jason |
| 56 | * added automatic reinitting of doors when rooms get deleted |
| 57 | * |
| 58 | * 7 10/06/97 1:03p Samir |
| 59 | * Took out script name. Doorways are objects, and if there is a custom |
| 60 | * script for a doorway, we look at it's object. |
| 61 | * |
| 62 | * 6 10/06/97 1:01p Jason |
| 63 | * made doors work with scripts (sort of) |
| 64 | * |
| 65 | * 5 10/03/97 12:51p Jason |
| 66 | * added GetDoorwayNumFromObject function |
| 67 | * |
| 68 | * 4 10/03/97 12:24p Jason |
| 69 | * added new keys for doorways |
| 70 | * |
| 71 | * 3 9/29/97 12:09p Jason |
| 72 | * added functionality to doorway system |
| 73 | * |
| 74 | * 2 9/12/97 5:38p Jason |
| 75 | * got doors working |
| 76 | * |
| 77 | * 3 3/14/97 12:51p Samir |
| 78 | * Added code to clear active state of doorways. |
| 79 | * |
| 80 | * 2 3/13/97 11:58a Samir |
| 81 | * Added stuff for active doorway and opening/closing |
| 82 | * |
| 83 | * 1 3/12/97 2:08p Samir |
| 84 | * Moved structures and prototypes from door.h |
| 85 | * |
| 86 | * $NoKeywords: $ |
| 87 | */ |
| 88 | |
| 89 | #ifndef DOORWAY_H |
| 90 | #define DOORWAY_Hcxx . . $ `Descent3/doorway.h:90:9`! |
| 91 | |
| 92 | #include "pstypes.h"cxx . . $ `<file>/lib/pstypes.h`/ |
| 93 | |
| 94 | // IMPORTANT!!!!!!!!!!! |
| 95 | // "Doors" refers to a predefined door that is in memory |
| 96 | // "Doorways" are specific doors that are in the mine |
| 97 | // So, there can be several Doorways that all point to the same Door |
| 98 | // Get it? If not, talk to Samir or Jason |
| 99 | |
| 100 | // doorway state |
| 101 | #define DOORWAY_STOPPEDcxx . . $ `Descent3/doorway.h:101:9`! 0 // door is not moving |
| 102 | #define DOORWAY_OPENINGcxx . . $ `Descent3/doorway.h:102:9`! 1 // door is opening |
| 103 | #define DOORWAY_CLOSINGcxx . . $ `Descent3/doorway.h:103:9`! 2 // door is closing |
| 104 | #define DOORWAY_WAITINGcxx . . $ `Descent3/doorway.h:104:9`! 3 // door is waiting to be closed |
| 105 | #define DOORWAY_OPENING_AUTOcxx . . $ `Descent3/doorway.h:105:9`! 4 // door is opening and will automatically close |
| 106 | |
| 107 | // doorway flags |
| 108 | #define DF_BLASTEDcxx . . $ `Descent3/doorway.h:108:9`! 1 // it's been blasted away |
| 109 | #define DF_AUTOcxx . . $ `Descent3/doorway.h:109:9`! 2 // doorway closes after time. |
| 110 | #define DF_LOCKEDcxx . . $ `Descent3/doorway.h:110:9`! 4 // doorway can't open for now |
| 111 | #define DF_KEY_ONLY_ONEcxx . . $ `Descent3/doorway.h:111:9`! 8 // only one key is needed to open (not all keys) |
| 112 | #define DF_GB_IGNORE_LOCKEDcxx . . $ `Descent3/doorway.h:112:9`! 16 // the Guide-bot ignores the locked state of this door |
| 113 | |
| 114 | // keymasks |
| 115 | #define KF_KEY1cxx . . $ `Descent3/doorway.h:115:9`! 1 // Each key is a bit in the key_mask set in the door/object |
| 116 | #define KF_KEY2cxx . . $ `Descent3/doorway.h:116:9`! 2 |
| 117 | #define KF_KEY3cxx . . $ `Descent3/doorway.h:117:9`! 4 |
| 118 | #define KF_KEY4cxx . . $ `Descent3/doorway.h:118:9`! 8 |
| 119 | |
| 120 | #define MAX_ACTIVE_DOORWAYScxx . . $ `Descent3/doorway.h:120:9`! 30 |
| 121 | |
| 122 | extern int Num_active_doorwayscxx . . $ Num_active_doorways.; // number of active doors in game |
| 123 | extern int Active_doorwayscxx . . $ Active_doorways.[MAX_ACTIVE_DOORWAYScxx . . $ `Descent3/doorway.h:120:9`!]; |
| 124 | |
| 125 | // A doorway (room) in the mine |
| 126 | struct doorwaycxx . . $ doorway# { |
| 127 | int doornumcxx . . $ doorway#doornum.; // door type of this doorway |
| 128 | uint8_tcxx . . $ uint8_t# statecxx . . $ doorway#state.; // current state of doorway |
| 129 | uint8_tcxx . . $ uint8_t# flagscxx . . $ doorway#flags.; // flags associated with a doorway |
| 130 | uint8_tcxx . . $ uint8_t# keys_neededcxx . . $ doorway#keys_needed.; // used by trigger system. these bits need to be set to activate door |
| 131 | int8_t activenumcxx . . $ doorway#activenum.; // index into active doorways array, or -1 if not active |
| 132 | float positioncxx . . $ doorway#position.; // current position of door |
| 133 | float dest_poscxx . . $ doorway#dest_pos.; // destination position |
| 134 | int sound_handlecxx . . $ doorway#sound_handle.; // handle of last sound played |
| 135 | }; |
| 136 | |
| 137 | // Macros |
| 138 | |
| 139 | // returns the bitflag for the given key number |
| 140 | #define KEY_FLAGcxx . . $ `Descent3/doorway.h:140:9`!(keynum) (1 << (keynum - 1)) |
| 141 | |
| 142 | // Variables |
| 143 | |
| 144 | // This is a mask of all keys held by all players. Robots use this to determine if a door is openable. |
| 145 | extern int Global_keyscxx . . $ Global_keys.; |
| 146 | |
| 147 | // |
| 148 | // Editor Functions |
| 149 | // |
| 150 | |
| 151 | // Define a couple types |
| 152 | struct roomcxx . . $ room#; |
| 153 | struct objectcxx . . $ object#; |
| 154 | |
| 155 | // Adds a doorway to the specified room |
| 156 | // Returns a pointer to the doorway struct |
| 157 | doorwaycxx . . $ doorway# *DoorwayAddcxx . . $ DoorwayAdd(aeacdc229a118899).(roomcxx . . $ room# *rp, int doornum); |
| 158 | |
| 159 | // Updates the animation when the door position is changed |
| 160 | void DoorwayUpdateAnimationcxx . . $ DoorwayUpdateAnimation(cd8c4e8cd0ee4c38).(roomcxx . . $ room# *rp); |
| 161 | |
| 162 | // |
| 163 | // General Functions |
| 164 | // |
| 165 | |
| 166 | // executes all active doorways in the game |
| 167 | void DoorwayDoFramecxx . . $ DoorwayDoFrame(49f6e7a06ebc5aa8).(); |
| 168 | |
| 169 | // clears the active state of all doorways that are active back to closed |
| 170 | void DoorwayDeactivateAllcxx . . $ DoorwayDeactivateAll(49f6e7a06ebc5aa8).(); |
| 171 | |
| 172 | // Opens a door and, if it has the auto flag set, closes it |
| 173 | // Does not check to see if the door is openable -- the caller must do that. |
| 174 | void DoorwayActivatecxx . . $ DoorwayActivate(d4f767463ce0a6b3).(int door_obj_handle); |
| 175 | |
| 176 | // Stops the doorway if it's moving |
| 177 | void DoorwayStopcxx . . $ DoorwayStop(d4f767463ce0a6b3).(int door_obj_handle); |
| 178 | |
| 179 | // Locks a given doorway |
| 180 | void DoorwayLockUnlockcxx . . $ DoorwayLockUnlock(918ebd27a9ddbad3).(int door_obj_handle, bool state); |
| 181 | |
| 182 | // Sets the current position of the door. 0.0 = totally closed, 1.0 = totally open |
| 183 | // Does not check to see if the door is openable -- the caller must do that. |
| 184 | void DoorwaySetPositioncxx . . $ DoorwaySetPosition(43c79ee2f1b9aefe).(int door_obj_handle, float pos); |
| 185 | |
| 186 | // Called after loading a saved game to rebuild the active list |
| 187 | void DoorwayRebuildActiveListcxx . . $ DoorwayRebuildActiveList(49f6e7a06ebc5aa8).(); |
| 188 | |
| 189 | // Called when a door is blown up |
| 190 | void DoorwayDestroycxx . . $ DoorwayDestroy(419c470199a90a97).(objectcxx . . $ object# *objp); |
| 191 | |
| 192 | // |
| 193 | // Query Functions |
| 194 | // |
| 195 | |
| 196 | // Returns true if the doorway is locked, else false |
| 197 | bool DoorwayLockedcxx . . $ DoorwayLocked(83c267b20bac841a).(int door_obj_handle); |
| 198 | |
| 199 | // Returns true if the doorway is locked, else false |
| 200 | bool DoorwayLockedcxx . . $ DoorwayLocked(52ff2e225c16149e).(roomcxx . . $ room# *rp); |
| 201 | |
| 202 | // Returns true if the doorway is openable by the specified player, else false |
| 203 | bool DoorwayOpenablecxx . . $ DoorwayOpenable(cf9ef193275fa6d8).(int door_obj_handle, int opener_handle); |
| 204 | |
| 205 | // Returns the current state of the specified door |
| 206 | int DoorwayStatecxx . . $ DoorwayState(7864480464b09eea).(int door_obj_handle); |
| 207 | |
| 208 | // Returns the current position of the door. 0.0 = totally closed, 1.0 = totally open |
| 209 | float DoorwayPositioncxx . . $ DoorwayPosition(fd42386fc3d80a5d).(roomcxx . . $ room# *rp); |
| 210 | |
| 211 | // Returns the current position of the door. 0.0 = totally closed, 1.0 = totally open |
| 212 | float DoorwayPositioncxx . . $ DoorwayPosition(5cde91ea12d43f46).(int door_obj_handle); |
| 213 | |
| 214 | // Make old name work |
| 215 | #define DoorwayGetPositioncxx . . $ `Descent3/doorway.h:215:9`! DoorwayPosition |
| 216 | |
| 217 | #endif |