| 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/weapon.cpp $ |
| 21 | * $Revision: 91 $ |
| 22 | * $Date: 4/19/00 5:07p $ |
| 23 | * $Author: Matt $ |
| 24 | * |
| 25 | * $Log: /DescentIII/main/weapon.cpp $ |
| 26 | * |
| 27 | * 91 4/19/00 5:07p Matt |
| 28 | * From Duane for 1.4 |
| 29 | * Added checks, asserts, and fixes for bad return values |
| 30 | * |
| 31 | * 90 11/03/99 6:29p Chris |
| 32 | * Improved the auto-selection code for dual fire secondary weapons |
| 33 | * |
| 34 | * 89 10/21/99 9:30p Jeff |
| 35 | * B.A. Macintosh code merge |
| 36 | * |
| 37 | * 88 5/20/99 9:56p Jeff |
| 38 | * AddWeaponToPlayer checks for max ammo when adding it |
| 39 | * |
| 40 | * 87 5/17/99 12:20p Samir |
| 41 | * don't print out any poweup weapon pickup messages in AddWeaponToPlayer. |
| 42 | * |
| 43 | * 86 5/08/99 6:18p Chris |
| 44 | * Fixed up no hearing cases |
| 45 | * |
| 46 | * 85 5/08/99 4:12p Chris |
| 47 | * Added AI hearing noises... version 1 |
| 48 | * |
| 49 | * 84 4/14/99 4:19a Jeff |
| 50 | * more case mismatch fixes in #includes |
| 51 | * |
| 52 | * 83 4/12/99 12:49p Jeff |
| 53 | * added recoil_force to weapon's page |
| 54 | * |
| 55 | * 82 3/31/99 10:27a Samir |
| 56 | * code to reset auto select states when ship is initializiaed and code to |
| 57 | * save and load these states from disk. |
| 58 | * |
| 59 | * 81 3/05/99 12:19p Matt |
| 60 | * Delete now-unused function AddWeaponAmmoToPlayer() |
| 61 | * |
| 62 | * 80 3/03/99 5:08p Samir |
| 63 | * AddWeaponAmmoToPlayer added. |
| 64 | * |
| 65 | * 79 2/25/99 1:29p Jason |
| 66 | * fixed zoom problem |
| 67 | * |
| 68 | * 78 2/20/99 7:06p Matt |
| 69 | * Changed a few HUD messages |
| 70 | * |
| 71 | * 77 2/10/99 3:48p Jason |
| 72 | * table filter changes |
| 73 | * |
| 74 | * 76 1/31/99 7:26p Matt |
| 75 | * Renamed a bunch of functions to have HUD capitalized |
| 76 | * |
| 77 | * 75 12/15/98 11:51a Samir |
| 78 | * fixed bugs with autoselect weapons when they're supposed to be skipped. |
| 79 | * |
| 80 | * 74 12/04/98 5:13p Jason |
| 81 | * took out extra mprintfs |
| 82 | * |
| 83 | * 73 10/22/98 2:41p Samir |
| 84 | * fixed autoselection for good. |
| 85 | * |
| 86 | * 72 10/21/98 11:52p Samir |
| 87 | * print different message if autoselecting a recently acquired weapon. |
| 88 | * |
| 89 | * 71 10/21/98 12:19p Samir |
| 90 | * fixed small bug in SwitchPlayerWeapon for skipped weapons. |
| 91 | * |
| 92 | * 70 10/21/98 11:14a Samir |
| 93 | * autoselect bug when selecting into a higher class without ammo/energy |
| 94 | * fixed. |
| 95 | * |
| 96 | * 69 10/19/98 11:31p Samir |
| 97 | * cycle up instead of down. |
| 98 | * |
| 99 | * 68 10/19/98 11:27p Samir |
| 100 | * fixed weapon cycling (switchplayerweapon) |
| 101 | * |
| 102 | * 67 10/07/98 9:46p Samir |
| 103 | * fixed small bug in SwitchPlayerWeapon |
| 104 | * |
| 105 | * 66 10/07/98 9:36p Samir |
| 106 | * added a function to switch a player's weapon to another in the given |
| 107 | * weapon class. |
| 108 | * |
| 109 | * 65 10/07/98 5:23p Jeff |
| 110 | * samir fixed an autoselect bug |
| 111 | * |
| 112 | * 64 10/07/98 4:13p Samir |
| 113 | * cleaned up weapon selection code. |
| 114 | * |
| 115 | * 63 9/30/98 4:31p Samir |
| 116 | * added functions to handle weapon select list. |
| 117 | * |
| 118 | * 62 7/31/98 5:17p Samir |
| 119 | * fixed weapon selection bug because secondaries weren't working properly |
| 120 | * and removed guided missile from autoselect list. |
| 121 | * |
| 122 | * 61 7/30/98 11:09a Jason |
| 123 | * added weapons that freeze and deform terrain |
| 124 | * |
| 125 | * 60 7/01/98 12:12p Jason |
| 126 | * added countermeasures |
| 127 | * |
| 128 | * 59 6/22/98 6:26p Jason |
| 129 | * added gravity field effect for weapons |
| 130 | * |
| 131 | * 58 6/19/98 12:04p Jason |
| 132 | * |
| 133 | * 57 6/17/98 3:27p Jeff |
| 134 | * Changes made for localization |
| 135 | * |
| 136 | * 56 6/16/98 10:54a Jeff |
| 137 | * |
| 138 | * 55 5/27/98 7:12p Samir |
| 139 | * yet another silly weapon selection(primary) bug fixed due to hasty |
| 140 | * checking in. |
| 141 | * |
| 142 | * 54 5/27/98 6:02p Samir |
| 143 | * foolishly, I don't check for primary weapon ammo when selecting |
| 144 | * weapons. |
| 145 | * |
| 146 | * 53 5/26/98 10:48p Samir |
| 147 | * weapon selection FIXED! |
| 148 | * |
| 149 | * 52 5/26/98 5:06p Samir |
| 150 | * changed name of weapon indices and added function to get weapon's icon |
| 151 | * image. |
| 152 | * |
| 153 | * 51 5/25/98 6:39p Jason |
| 154 | * got icons working for weapons |
| 155 | * |
| 156 | * 50 5/22/98 6:25p Samir |
| 157 | * fixed 'Rocker' bug. |
| 158 | * |
| 159 | * 49 5/22/98 11:59a Chris |
| 160 | * Fixed improper uses of FindSoundName and made the proper static sounds |
| 161 | * |
| 162 | * 48 5/14/98 12:56p Jason |
| 163 | * changes to help lower memory usage |
| 164 | * |
| 165 | * 47 4/24/98 5:32p Samir |
| 166 | * added reset reticle when setting a new weapon. |
| 167 | * |
| 168 | * 46 4/24/98 8:02a Samir |
| 169 | * added a int16_t weapon name array. |
| 170 | * |
| 171 | * 45 4/22/98 1:08p Chris |
| 172 | * Fixed auto-firing of weapons after auto-selection |
| 173 | * |
| 174 | * 44 4/08/98 12:16p Samir |
| 175 | * Weapon selection should be improved. |
| 176 | * |
| 177 | * 43 4/07/98 3:31p Jason |
| 178 | * got particle effects working with weapons |
| 179 | * |
| 180 | * 42 4/06/98 4:53p Jason |
| 181 | * got pageable polymodels working correctly with editor |
| 182 | * |
| 183 | * 41 4/02/98 3:54p Jason |
| 184 | * first pass in getting polymodel paging to work |
| 185 | * |
| 186 | * 40 3/23/98 3:52p Jason |
| 187 | * added weapon names |
| 188 | * |
| 189 | * 39 3/17/98 2:40p Samir |
| 190 | * reorg of hud/gauge system. |
| 191 | * |
| 192 | * 38 2/26/98 6:00p Jason |
| 193 | * fixed a bug where a OBJ_GHOST object (ie a dead player) could try to |
| 194 | * select a new weapon |
| 195 | * |
| 196 | * 37 2/17/98 11:33p Matt |
| 197 | * Use new function to stop player firing activity when switching weapons |
| 198 | * |
| 199 | * 36 2/17/98 5:04p Samir |
| 200 | * Fixed selection of secondary weapons. |
| 201 | * |
| 202 | * 35 2/17/98 4:06p Jason |
| 203 | * Fixed DrawAlphaBlendedScreen not zbuffering correctly |
| 204 | * |
| 205 | * 34 2/17/98 3:47p Matt |
| 206 | * Revamped weapon system and got sounds for spray and fusion weapons |
| 207 | * working. Still need to implements getting continuous & cutoff sounds |
| 208 | * from player ship. |
| 209 | * |
| 210 | * 33 2/15/98 1:18a Jason |
| 211 | * fixed zbuffer problem |
| 212 | * |
| 213 | * 32 2/14/98 10:48p Jason |
| 214 | * got preferred rendering working |
| 215 | * |
| 216 | * 31 2/11/98 2:04p Jason |
| 217 | * got spawning weapons working |
| 218 | * |
| 219 | * 30 2/05/98 7:06p Jason |
| 220 | * fixed weapon naming bug |
| 221 | * |
| 222 | * 29 2/05/98 6:53p Jason |
| 223 | * added new weapon slot |
| 224 | * |
| 225 | * 28 2/05/98 6:29p Jason |
| 226 | * added user settable explode time/size |
| 227 | * |
| 228 | * 27 2/04/98 9:28p Jason |
| 229 | * added some new weapons effects |
| 230 | * |
| 231 | * 26 2/02/98 4:07p Jason |
| 232 | * added a couple of weapons |
| 233 | * |
| 234 | * 25 1/29/98 6:06p Jason |
| 235 | * added new weapons |
| 236 | * |
| 237 | * 24 1/28/98 3:18p Jason |
| 238 | * Made AddWeaponToPlayer take a playernum |
| 239 | * |
| 240 | * |
| 241 | * 23 1/26/98 11:01a Jason |
| 242 | * incremental checkin for multiplayer |
| 243 | * |
| 244 | * 22 1/23/98 6:25p Jason |
| 245 | * Got spray weapons working |
| 246 | * |
| 247 | * 21 12/22/97 6:19p Chris |
| 248 | * Moved weapon battery firing sound off the projectile (weapon) and into |
| 249 | * the weapon battery. |
| 250 | * |
| 251 | * 20 11/14/97 6:57p Samir |
| 252 | * Maybe fixed selection of weapons <-> auto selection dependencies. |
| 253 | * |
| 254 | * 19 11/14/97 5:47p Mark |
| 255 | * Fixed some weapon selection hokeyness. |
| 256 | * |
| 257 | * 18 11/12/97 6:01p Samir |
| 258 | * Added omega and guided names to weapon list. |
| 259 | * |
| 260 | * 17 11/12/97 1:13p Jason |
| 261 | * added weapons that can ramp up |
| 262 | * |
| 263 | * 16 11/11/97 1:28p Samir |
| 264 | * Weapon selection should change hud, I think. |
| 265 | * |
| 266 | * 15 11/05/97 12:21p Chris |
| 267 | * Added weapon remap for player ship weapon batteries |
| 268 | * |
| 269 | * 14 11/04/97 5:52p Jason |
| 270 | * added DrawAplhaBlendedScreen function |
| 271 | * |
| 272 | * 13 10/30/97 4:02p Matt |
| 273 | * Added the flare |
| 274 | * |
| 275 | * 12 10/15/97 5:20p Jason |
| 276 | * did a HUGE overhaul of the bitmap system |
| 277 | * |
| 278 | * 11 9/16/97 3:03p Samir |
| 279 | * fixed autoselection of weapons when you don't have enough energy. |
| 280 | * |
| 281 | * 10 9/15/97 3:37p Samir |
| 282 | * Updated some more names for weapons. |
| 283 | * |
| 284 | * 9 9/10/97 11:45a Chris |
| 285 | * FIXED a major remapping bug |
| 286 | * Added support for weapon batteries |
| 287 | * |
| 288 | * 8 9/10/97 10:12a Samir |
| 289 | * Added weapon name text. |
| 290 | * |
| 291 | * 7 9/08/97 5:12p Samir |
| 292 | * Fixed weapon selection |
| 293 | * |
| 294 | * 6 9/05/97 12:25p Samir |
| 295 | * Added autoselection of weapons. |
| 296 | * |
| 297 | * 5 9/04/97 3:59p Samir |
| 298 | * Added code to switch weapons. |
| 299 | * |
| 300 | * 4 8/07/97 3:28p Jason |
| 301 | * Assign -1 as the default sound for weapons |
| 302 | * |
| 303 | * 3 8/07/97 1:01p Mark |
| 304 | * fixed a dumb bug |
| 305 | * |
| 306 | * 2 8/07/97 12:53p Mark |
| 307 | * FROM JASON: Made oof readable as discharge files |
| 308 | * |
| 309 | * 7 4/28/97 6:46p Jason |
| 310 | * made ships have multiple gun points |
| 311 | * |
| 312 | * 6 4/25/97 3:59p Jason |
| 313 | * fixed a bug that my last checkin caused |
| 314 | * |
| 315 | * 5 4/25/97 3:31p Jason |
| 316 | * implemented better memory management for vclips and bitmaps |
| 317 | * |
| 318 | * 4 4/17/97 2:54p Jason |
| 319 | * added clueless weapon picker upper |
| 320 | * |
| 321 | * 3 4/14/97 1:50p Jason |
| 322 | * first pass at getting weapons to fire |
| 323 | * |
| 324 | * 2 3/31/97 4:35p Jason |
| 325 | * added weapon page functionality |
| 326 | * |
| 327 | * 1 3/31/97 4:13p Jason |
| 328 | * weapons implementation file |
| 329 | * |
| 330 | |
| 331 | * |
| 332 | * $NoKeywords: $ |
| 333 | */ |
| 334 | |
| 335 | #include "weapon.h"cxx . . $ `<file>/Descent3/weapon.h`/ |
| 336 | #include "pstypes.h"cxx . . $ `<file>/lib/pstypes.h`/ |
| 337 | #include "pserror.h"cxx . . $ `<file>/misc/pserror.h`/ |
| 338 | #include "object.h"cxx . . $ `<file>/Descent3/object.h`/ |
| 339 | #include "3d.h"cxx . . $ `<file>/lib/3d.h`/ |
| 340 | #include <stdlib.h> |
| 341 | #include <stdio.h> |
| 342 | #include <stdarg.h> |
| 343 | #include <string.h> |
| 344 | #include "bitmap.h"cxx . . $ `<file>/lib/bitmap.h`/ |
| 345 | #include "vclip.h"cxx . . $ `<file>/Descent3/vclip.h`/ |
| 346 | #include "game.h"cxx . . $ `<file>/Descent3/game.h`/ |
| 347 | #include "polymodel.h"cxx . . $ `<file>/model/polymodel.h`/ |
| 348 | #include "player.h"cxx . . $ `<file>/Descent3/player.h`/ |
| 349 | #include "hud.h"cxx . . $ `<file>/Descent3/hud.h`/ |
| 350 | #include "hlsoundlib.h"cxx . . $ `<file>/sndlib/hlsoundlib.h`/ |
| 351 | #include "soundload.h"cxx . . $ `<file>/sndlib/soundload.h`/ |
| 352 | #include "objinfo.h"cxx . . $ `<file>/Descent3/objinfo.h`/ |
| 353 | #include "gametexture.h"cxx . . $ `<file>/Descent3/gametexture.h`/ |
| 354 | #include "ship.h"cxx . . $ `<file>/Descent3/ship.h`/ |
| 355 | #include "gauges.h"cxx . . $ `<file>/Descent3/gauges.h`/ |
| 356 | #include "sounds.h"cxx . . $ `<file>/Descent3/sounds.h`/ |
| 357 | #include "stringtable.h"cxx . . $ `<file>/Descent3/stringtable.h`/ |
| 358 | #include "Macros.h"cxx . . $ `<file>/lib/Macros.h`/ |
| 359 | #include "cfile.h"cxx . . $ `<file>/cfile/cfile.h`/ |
| 360 | #include "AIMain.h"cxx . . $ `<file>/Descent3/AIMain.h`/ |
| 361 | |
| 362 | #include <algorithm> |
| 363 | |
| 364 | // #include "samirlog.h" |
| 365 | #define LOGFILEcxx . . $ `Descent3/weapon.cpp:365:9`!(_s) |
| 366 | |
| 367 | weaponcxx . . $ weapon# Weaponscxx . . $ Weapons.[MAX_WEAPONScxx . . $ `Descent3/weapon.h:208:9`!]; |
| 368 | int Num_weaponscxx . . $ Num_weapons. = 0; |
| 369 | |
| 370 | const char *Static_weapon_namescxx . . $ Static_weapon_names.[] = { |
| 371 | // Primary weapons |
| 372 | "Laser", |
| 373 | "Vauss", |
| 374 | "Microwave", |
| 375 | "Plasma", |
| 376 | "Fusion", |
| 377 | "Super Laser", |
| 378 | "Mass Driver", |
| 379 | "Napalm", |
| 380 | "EMD Gun", |
| 381 | "Omega", |
| 382 | // Secondary weapons |
| 383 | "Concussion", |
| 384 | "Homing", |
| 385 | "Impact Mortar", |
| 386 | "Smart", |
| 387 | "Mega", |
| 388 | "Frag", |
| 389 | "Guided", |
| 390 | "Napalm Rocket", |
| 391 | "Cyclone", |
| 392 | "Black Shark", |
| 393 | // The flares |
| 394 | "Yellow Flare", |
| 395 | }; |
| 396 | |
| 397 | int Static_weapon_names_msgcxx . . $ Static_weapon_names_msg.[] = { |
| 398 | // Primary weapons |
| 399 | TXI_WPN_LASERcxx . . $ `Descent3/stringtable.h:208:9`!, |
| 400 | TXI_WPN_VAUSScxx . . $ `Descent3/stringtable.h:209:9`!, |
| 401 | TXI_WPN_MICROWAVEcxx . . $ `Descent3/stringtable.h:210:9`!, |
| 402 | TXI_WPN_PLASMAcxx . . $ `Descent3/stringtable.h:211:9`!, |
| 403 | TXI_WPN_FUSIONcxx . . $ `Descent3/stringtable.h:212:9`!, |
| 404 | TXI_WPN_SUPLASERcxx . . $ `Descent3/stringtable.h:213:9`!, |
| 405 | TXI_WPN_MASSDRIVERcxx . . $ `Descent3/stringtable.h:214:9`!, |
| 406 | TXI_WPN_NAPALMcxx . . $ `Descent3/stringtable.h:215:9`!, |
| 407 | TXI_WPN_EMDGUNcxx . . $ `Descent3/stringtable.h:216:9`!, |
| 408 | TXI_WPN_OMEGAcxx . . $ `Descent3/stringtable.h:217:9`!, |
| 409 | // Secondary weapons |
| 410 | TXI_WPN_CONCUSSIONcxx . . $ `Descent3/stringtable.h:218:9`!, |
| 411 | TXI_WPN_HOMINGcxx . . $ `Descent3/stringtable.h:219:9`!, |
| 412 | TXI_WPN_IMPACTcxx . . $ `Descent3/stringtable.h:220:9`!, |
| 413 | TXI_WPN_SMARTcxx . . $ `Descent3/stringtable.h:221:9`!, |
| 414 | TXI_WPN_MEGAcxx . . $ `Descent3/stringtable.h:222:9`!, |
| 415 | TXI_WPN_FRAGcxx . . $ `Descent3/stringtable.h:223:9`!, |
| 416 | TXI_WPN_GUIDEDcxx . . $ `Descent3/stringtable.h:224:9`!, |
| 417 | TXI_WPN_NAPALMRcxx . . $ `Descent3/stringtable.h:225:9`!, |
| 418 | TXI_WPN_CYCLONEcxx . . $ `Descent3/stringtable.h:226:9`!, |
| 419 | TXI_WPN_BLACKSHARKcxx . . $ `Descent3/stringtable.h:227:9`!, |
| 420 | // The flares |
| 421 | TXI_WPN_YELL_FLAREcxx . . $ `Descent3/stringtable.h:228:9`!, |
| 422 | }; |
| 423 | |
| 424 | int Static_weapon_ckpt_namescxx . . $ Static_weapon_ckpt_names.[][2] = { |
| 425 | // Primary weapons |
| 426 | {TXI_WPNC_LASER_1cxx . . $ `Descent3/stringtable.h:229:9`!, TXI_WPNC_LASER_2cxx . . $ `Descent3/stringtable.h:230:9`!}, |
| 427 | {TXI_WPNC_VAUSS_1cxx . . $ `Descent3/stringtable.h:231:9`!, TXI_WPNC_VAUSS_2cxx . . $ `Descent3/stringtable.h:232:9`!}, |
| 428 | {TXI_WPNC_MICRO_1cxx . . $ `Descent3/stringtable.h:233:9`!, TXI_WPNC_MICRO_2cxx . . $ `Descent3/stringtable.h:234:9`!}, |
| 429 | {TXI_WPNC_PLASMA_1cxx . . $ `Descent3/stringtable.h:235:9`!, TXI_WPNC_PLASMA_2cxx . . $ `Descent3/stringtable.h:236:9`!}, |
| 430 | {TXI_WPNC_FUSION_1cxx . . $ `Descent3/stringtable.h:237:9`!, TXI_WPNC_FUSION_2cxx . . $ `Descent3/stringtable.h:238:9`!}, |
| 431 | {TXI_WPNC_SUPLAS_1cxx . . $ `Descent3/stringtable.h:239:9`!, TXI_WPNC_SUPLAS_2cxx . . $ `Descent3/stringtable.h:240:9`!}, |
| 432 | {TXI_WPNC_MASSD_1cxx . . $ `Descent3/stringtable.h:241:9`!, TXI_WPNC_MASSD_2cxx . . $ `Descent3/stringtable.h:242:9`!}, |
| 433 | {TXI_WPNC_NAPALM_1cxx . . $ `Descent3/stringtable.h:243:9`!, TXI_WPNC_NAPALM_2cxx . . $ `Descent3/stringtable.h:244:9`!}, |
| 434 | {TXI_WPNC_EMD_1cxx . . $ `Descent3/stringtable.h:245:9`!, TXI_WPNC_EMD_2cxx . . $ `Descent3/stringtable.h:246:9`!}, |
| 435 | {TXI_WPNC_OMEGA_1cxx . . $ `Descent3/stringtable.h:247:9`!, TXI_WPNC_OMEGA_2cxx . . $ `Descent3/stringtable.h:248:9`!}, |
| 436 | // Secondary weapons |
| 437 | {TXI_WPNC_CONC_1cxx . . $ `Descent3/stringtable.h:249:9`!, TXI_WPNC_CONC_2cxx . . $ `Descent3/stringtable.h:250:9`!}, |
| 438 | {TXI_WPNC_HOMING_1cxx . . $ `Descent3/stringtable.h:251:9`!, TXI_WPNC_HOMING_2cxx . . $ `Descent3/stringtable.h:252:9`!}, |
| 439 | {TXI_WPNC_IMPACT_1cxx . . $ `Descent3/stringtable.h:253:9`!, TXI_WPNC_IMPACT_2cxx . . $ `Descent3/stringtable.h:254:9`!}, |
| 440 | {TXI_WPNC_SMART_1cxx . . $ `Descent3/stringtable.h:255:9`!, TXI_WPNC_SMART_2cxx . . $ `Descent3/stringtable.h:256:9`!}, |
| 441 | {TXI_WPNC_MEGA_1cxx . . $ `Descent3/stringtable.h:257:9`!, TXI_WPNC_MEGA_2cxx . . $ `Descent3/stringtable.h:258:9`!}, |
| 442 | {TXI_WPNC_FRAG_1cxx . . $ `Descent3/stringtable.h:259:9`!, TXI_WPNC_FRAG_2cxx . . $ `Descent3/stringtable.h:260:9`!}, |
| 443 | {TXI_WPNC_GUID_1cxx . . $ `Descent3/stringtable.h:261:9`!, TXI_WPNC_GUID_2cxx . . $ `Descent3/stringtable.h:262:9`!}, |
| 444 | {TXI_WPNC_NAPALMR_1cxx . . $ `Descent3/stringtable.h:263:9`!, TXI_WPNC_NAPALMR_2cxx . . $ `Descent3/stringtable.h:264:9`!}, |
| 445 | {TXI_WPNC_CYCLONE_1cxx . . $ `Descent3/stringtable.h:265:9`!, TXI_WPNC_CYCLONE_2cxx . . $ `Descent3/stringtable.h:266:9`!}, |
| 446 | {TXI_WPNC_BLKSHRK_1cxx . . $ `Descent3/stringtable.h:267:9`!, TXI_WPNC_BLKSHRK_2cxx . . $ `Descent3/stringtable.h:268:9`!}, |
| 447 | // The flares |
| 448 | {TXI_WPNC_YELFLARE_1cxx . . $ `Descent3/stringtable.h:269:9`!, TXI_WPNC_YELFLARE_2cxx . . $ `Descent3/stringtable.h:270:9`!}, |
| 449 | }; |
| 450 | |
| 451 | // Sets all weapons to unused |
| 452 | void InitWeaponscxx . . $ InitWeapons(49f6e7a06ebc5aa8).() { |
| 453 | for (int i = 0; i < MAX_WEAPONScxx . . $ `Descent3/weapon.h:208:9`!; i++) { |
| 454 | Weaponscxx . . $ Weapons.[i].usedcxx . . $ weapon#used. = 0; |
| 455 | Weaponscxx . . $ Weapons.[i].namecxx . . $ weapon#name.[0] = 0; |
| 456 | } |
| 457 | Num_weaponscxx . . $ Num_weapons. = 0; |
| 458 | } |
| 459 | |
| 460 | // Allocs a weapon for use, returns -1 if error, else index on success |
| 461 | int AllocWeaponcxx . . $ AllocWeapon(b126dc7c1de90089).() { |
| 462 | for (int i = MAX_STATIC_WEAPONScxx . . $ `Descent3/weapon.h:211:9`!; i < MAX_WEAPONScxx . . $ `Descent3/weapon.h:208:9`!; i++) { |
| 463 | if (Weaponscxx . . $ Weapons.[i].usedcxx . . $ weapon#used. == 0) { |
| 464 | memset(&Weaponscxx . . $ Weapons.[i], 0, sizeof(weaponcxx . . $ weapon#)); |
| 465 | for (int t = 0; t < MAX_WEAPON_SOUNDScxx . . $ `Descent3/weapon.h:259:9`!; t++) |
| 466 | Weaponscxx . . $ Weapons.[i].soundscxx . . $ weapon#sounds.[t] = SOUND_NONE_INDEXcxx . . $ `Descent3/sounds.h:105:9`!; |
| 467 | Weaponscxx . . $ Weapons.[i].alphacxx . . $ weapon#alpha. = 1.0; |
| 468 | Weaponscxx . . $ Weapons.[i].spawn_handlecxx . . $ weapon#spawn_handle. = -1; |
| 469 | Weaponscxx . . $ Weapons.[i].alternate_spawn_handlecxx . . $ weapon#alternate_spawn_handle. = -1; |
| 470 | Weaponscxx . . $ Weapons.[i].icon_handlecxx . . $ weapon#icon_handle. = -1; |
| 471 | Weaponscxx . . $ Weapons.[i].scorch_handlecxx . . $ weapon#scorch_handle. = -1; |
| 472 | Weaponscxx . . $ Weapons.[i].gravity_sizecxx . . $ weapon#gravity_size. = 1; |
| 473 | Weaponscxx . . $ Weapons.[i].gravity_timecxx . . $ weapon#gravity_time. = 1; |
| 474 | Weaponscxx . . $ Weapons.[i].explode_sizecxx . . $ weapon#explode_size. = 1; |
| 475 | Weaponscxx . . $ Weapons.[i].explode_timecxx . . $ weapon#explode_time. = 1; |
| 476 | Weaponscxx . . $ Weapons.[i].particle_countcxx . . $ weapon#particle_count. = 0; |
| 477 | Weaponscxx . . $ Weapons.[i].particle_sizecxx . . $ weapon#particle_size. = 1; |
| 478 | Weaponscxx . . $ Weapons.[i].particle_lifecxx . . $ weapon#particle_life. = 0; |
| 479 | Weaponscxx . . $ Weapons.[i].particle_handlecxx . . $ weapon#particle_handle. = -1; |
| 480 | Weaponscxx . . $ Weapons.[i].robot_spawn_handlecxx . . $ weapon#robot_spawn_handle. = -1; |
| 481 | Weaponscxx . . $ Weapons.[i].alternate_chancecxx . . $ weapon#alternate_chance. = 0; |
| 482 | Weaponscxx . . $ Weapons.[i].terrain_damage_sizecxx . . $ weapon#terrain_damage_size. = 0; |
| 483 | Weaponscxx . . $ Weapons.[i].terrain_damage_depthcxx . . $ weapon#terrain_damage_depth. = 0; |
| 484 | Weaponscxx . . $ Weapons.[i].usedcxx . . $ weapon#used. = 1; |
| 485 | Weaponscxx . . $ Weapons.[i].recoil_forcecxx . . $ weapon#recoil_force. = 0.0f; |
| 486 | Num_weaponscxx . . $ Num_weapons.++; |
| 487 | return i; |
| 488 | } |
| 489 | } |
| 490 | |
| 491 | Int3cxx . . $ `misc/pserror.h:247:9`!(); // No weapons free! |
| 492 | return -1; |
| 493 | } |
| 494 | |
| 495 | // Frees weapon index n and all associated images |
| 496 | void FreeWeaponcxx . . $ FreeWeapon(d4f767463ce0a6b3).(int n) { |
| 497 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(Weapons[n].used > 0); |
| 498 | |
| 499 | Weaponscxx . . $ Weapons.[n].usedcxx . . $ weapon#used. = 0; |
| 500 | Weaponscxx . . $ Weapons.[n].namecxx . . $ weapon#name.[0] = 0; |
| 501 | Num_weaponscxx . . $ Num_weapons.--; |
| 502 | } |
| 503 | |
| 504 | // Gets next weapon from n that has actually been alloced |
| 505 | int GetNextWeaponcxx . . $ GetNextWeapon(7864480464b09eea).(int n) { |
| 506 | int i; |
| 507 | |
| 508 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(n >= 0 && n < MAX_WEAPONScxx . . $ `Descent3/weapon.h:208:9`!); |
| 509 | |
| 510 | if (Num_weaponscxx . . $ Num_weapons. == 0) |
| 511 | return -1; |
| 512 | |
| 513 | for (i = n + 1; i < MAX_WEAPONScxx . . $ `Descent3/weapon.h:208:9`!; i++) |
| 514 | if (Weaponscxx . . $ Weapons.[i].usedcxx . . $ weapon#used.) |
| 515 | return i; |
| 516 | for (i = 0; i < n; i++) |
| 517 | if (Weaponscxx . . $ Weapons.[i].usedcxx . . $ weapon#used.) |
| 518 | return i; |
| 519 | |
| 520 | // this is the only one |
| 521 | |
| 522 | return n; |
| 523 | } |
| 524 | |
| 525 | // Gets previous weapon from n that has actually been alloced |
| 526 | int GetPrevWeaponcxx . . $ GetPrevWeapon(7864480464b09eea).(int n) { |
| 527 | int i; |
| 528 | |
| 529 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(n >= 0 && n < MAX_WEAPONScxx . . $ `Descent3/weapon.h:208:9`!); |
| 530 | |
| 531 | if (Num_weaponscxx . . $ Num_weapons. == 0) |
| 532 | return -1; |
| 533 | |
| 534 | for (i = n - 1; i >= 0; i--) { |
| 535 | if (Weaponscxx . . $ Weapons.[i].usedcxx . . $ weapon#used.) |
| 536 | return i; |
| 537 | } |
| 538 | for (i = MAX_WEAPONScxx . . $ `Descent3/weapon.h:208:9`! - 1; i > n; i--) { |
| 539 | if (Weaponscxx . . $ Weapons.[i].usedcxx . . $ weapon#used.) |
| 540 | return i; |
| 541 | } |
| 542 | |
| 543 | // this is the only one |
| 544 | return n; |
| 545 | } |
| 546 | // Searches thru all weapons for a specific name, returns -1 if not found |
| 547 | // or index of weapon with name |
| 548 | int FindWeaponNamecxx . . $ FindWeaponName(5c4306d8553b3696).(const char *name) { |
| 549 | int i; |
| 550 | |
| 551 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(name != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!); |
| 552 | |
| 553 | for (i = 0; i < MAX_WEAPONScxx . . $ `Descent3/weapon.h:208:9`!; i++) |
| 554 | if (Weaponscxx . . $ Weapons.[i].usedcxx . . $ weapon#used. && !stricmpcxx . . $ `linux/linux_fix.h:43:9`!(name, Weapons[i].name)) |
| 555 | return i; |
| 556 | |
| 557 | return -1; |
| 558 | } |
| 559 | |
| 560 | // Given a weapon handle, returns that weapons bitmap |
| 561 | // If the weapon is animated, returns framenum mod num_of_frames in the animation |
| 562 | // Also figures in gametime |
| 563 | int GetWeaponHudImagecxx . . $ GetWeaponHudImage(9b79fb6aee4c0440).(int handle, int framenum) { |
| 564 | if (Weaponscxx . . $ Weapons.[handle].flagscxx . . $ weapon#flags. & WF_HUD_ANIMATEDcxx . . $ `Descent3/weapon.h:218:9`!) { |
| 565 | float cur_frametime; |
| 566 | int int_frame; |
| 567 | |
| 568 | vclipcxx . . $ vclip# *vc = &GameVClipscxx . . $ GameVClips.[Weaponscxx . . $ Weapons.[handle].hud_image_handlecxx . . $ weapon#hud_image_handle.]; |
| 569 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(vc->used); |
| 570 | |
| 571 | cur_frametime = Gametimecxx . . $ Gametime. / vc->frame_timecxx . . $ vclip#frame_time.; |
| 572 | int_frame = cur_frametime; |
| 573 | int_frame += framenum; |
| 574 | |
| 575 | return (vc->framescxx . . $ vclip#frames.[int_frame % vc->num_framescxx . . $ vclip#num_frames.]); |
| 576 | } else |
| 577 | return (Weaponscxx . . $ Weapons.[handle].hud_image_handlecxx . . $ weapon#hud_image_handle.); |
| 578 | } |
| 579 | |
| 580 | // Given a filename, loads either the bitmap or vclip found in that file. If type |
| 581 | // is not NULL, sets it to 1 if file is animation, otherwise sets it to zero |
| 582 | int LoadWeaponHudImagecxx . . $ LoadWeaponHudImage(b0a0d720b596a511).(char *filename, int *type) { |
| 583 | int anim = 0, bm_handle; |
| 584 | char extension[10]; |
| 585 | |
| 586 | int len = strlen(filename); |
| 587 | |
| 588 | if (len < 4) |
| 589 | return -1; |
| 590 | |
| 591 | strncpy(extension, &filename[len - 3], 5); |
| 592 | |
| 593 | if ((!strnicmpcxx . . $ `linux/linux_fix.h:44:9`!("oaf", extension, 3)) || (!strnicmpcxx . . $ `linux/linux_fix.h:44:9`!("ifl", extension, 3)) || (!strnicmpcxx . . $ `linux/linux_fix.h:44:9`!("abm", extension, 3))) |
| 594 | anim = 1; |
| 595 | |
| 596 | if (type != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) |
| 597 | *type = anim; |
| 598 | |
| 599 | if (anim) |
| 600 | bm_handle = AllocLoadVClipcxx . . $ AllocLoadVClip(cf529e05df08c24).(IGNORE_TABLEcxx . . $ `lib/manage_external.h:54:9`!(filename), NOT_TEXTUREcxx . . $ `Descent3/gametexture.h:238:9`!, 0); |
| 601 | else |
| 602 | bm_handle = bm_AllocLoadFileBitmapcxx . . $ bm_AllocLoadFileBitmap(1163be050dbfff7).(IGNORE_TABLEcxx . . $ `lib/manage_external.h:54:9`!(filename), 0); |
| 603 | |
| 604 | return bm_handle; |
| 605 | } |
| 606 | |
| 607 | // Given a weapon handle, returns that weapons discharge bitmap |
| 608 | int GetWeaponFireImagecxx . . $ GetWeaponFireImage(9b79fb6aee4c0440).(int handle, int frame) { |
| 609 | if (Weaponscxx . . $ Weapons.[handle].flagscxx . . $ weapon#flags. & WF_IMAGE_VCLIPcxx . . $ `Descent3/weapon.h:223:9`!) { |
| 610 | float cur_frametime; |
| 611 | int int_frame; |
| 612 | |
| 613 | PageInVClipcxx . . $ PageInVClip(d4f767463ce0a6b3).(Weaponscxx . . $ Weapons.[handle].fire_image_handlecxx . . $ weapon#fire_image_handle.); |
| 614 | |
| 615 | vclipcxx . . $ vclip# *vc = &GameVClipscxx . . $ GameVClips.[Weaponscxx . . $ Weapons.[handle].fire_image_handlecxx . . $ weapon#fire_image_handle.]; |
| 616 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(vc->used >= 1); |
| 617 | |
| 618 | cur_frametime = Gametimecxx . . $ Gametime. / vc->frame_timecxx . . $ vclip#frame_time.; |
| 619 | int_frame = cur_frametime; |
| 620 | int_frame += frame; |
| 621 | return (vc->framescxx . . $ vclip#frames.[int_frame % vc->num_framescxx . . $ vclip#num_frames.]); |
| 622 | } else |
| 623 | return (Weaponscxx . . $ Weapons.[handle].fire_image_handlecxx . . $ weapon#fire_image_handle.); |
| 624 | } |
| 625 | |
| 626 | // Given a filename, loads either the bitmap or model found in that file. If type |
| 627 | // is not NULL, sets it to 1 if file is model, otherwise sets it to zero |
| 628 | int LoadWeaponFireImagecxx . . $ LoadWeaponFireImage(d5888b9b9a45a23).(char *filename, int *type, int *anim, int pageable) { |
| 629 | int model = 0, bm_handle; |
| 630 | int is_vclip = 0; |
| 631 | char extension[10]; |
| 632 | |
| 633 | int len = strlen(filename); |
| 634 | |
| 635 | if (len < 4) |
| 636 | return -1; |
| 637 | |
| 638 | strncpy(extension, &filename[len - 3], 5); |
| 639 | |
| 640 | if ((!strnicmpcxx . . $ `linux/linux_fix.h:44:9`!("pof", extension, 3)) || (!strnicmpcxx . . $ `linux/linux_fix.h:44:9`!("oof", extension, 3))) |
| 641 | model = 1; |
| 642 | |
| 643 | if (type != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) |
| 644 | *type = model; |
| 645 | if (anim != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) |
| 646 | *anim = is_vclip; |
| 647 | |
| 648 | if (model) |
| 649 | bm_handle = LoadPolyModelcxx . . $ LoadPolyModel(220e687f58daa9be).(IGNORE_TABLEcxx . . $ `lib/manage_external.h:54:9`!(filename), 0); |
| 650 | else { |
| 651 | bm_handle = LoadTextureImagecxx . . $ LoadTextureImage(f997a6335c8241fb).(IGNORE_TABLEcxx . . $ `lib/manage_external.h:54:9`!(filename), anim, NOT_TEXTUREcxx . . $ `Descent3/gametexture.h:238:9`!, 0); |
| 652 | } |
| 653 | |
| 654 | return bm_handle; |
| 655 | } |
| 656 | |
| 657 | // Given a weapon name, assigns that weapon to a specific index into |
| 658 | // the Weapons array. Returns -1 if the named weapon is not found, 0 if the weapon |
| 659 | // is already in its place, or 1 if successfully moved |
| 660 | int MatchWeaponToIndexcxx . . $ MatchWeaponToIndex(6abd07ddb1a912f0).(char *name, int dest_index) { |
| 661 | |
| 662 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(dest_index >= 0 && dest_index < MAX_WEAPONScxx . . $ `Descent3/weapon.h:208:9`!); |
| 663 | |
| 664 | int cur_index = FindWeaponNamecxx . . $ FindWeaponName(5c4306d8553b3696).(name); |
| 665 | int new_index; |
| 666 | |
| 667 | if (cur_index == -1) { |
| 668 | // The weapon we are trying to find is not loaded or doesn't exist |
| 669 | Int3cxx . . $ `misc/pserror.h:247:9`!(); // Get Jason or Matt |
| 670 | return -1; |
| 671 | } |
| 672 | |
| 673 | if (cur_index == dest_index) |
| 674 | return 0; // hurray, we're already matched up! |
| 675 | |
| 676 | if (Weaponscxx . . $ Weapons.[dest_index].usedcxx . . $ weapon#used.) { |
| 677 | // This weapon is currently in use. Copy the present data |
| 678 | // into a new weapon and then assign our desired weapon to that index |
| 679 | |
| 680 | new_index = AllocWeaponcxx . . $ AllocWeapon(b126dc7c1de90089).(); |
| 681 | if (new_index >= 0) // DAJ -1FIX |
| 682 | memcpy(&Weaponscxx . . $ Weapons.[new_index], &Weaponscxx . . $ Weapons.[dest_index], sizeof(weaponcxx . . $ weapon#)); |
| 683 | |
| 684 | // Now copy our new info over and free the old one |
| 685 | memcpy(&Weaponscxx . . $ Weapons.[dest_index], &Weaponscxx . . $ Weapons.[cur_index], sizeof(weaponcxx . . $ weapon#)); |
| 686 | FreeWeaponcxx . . $ FreeWeapon(d4f767463ce0a6b3).(cur_index); |
| 687 | } else { |
| 688 | // This slot is unused, so just take it |
| 689 | |
| 690 | Weaponscxx . . $ Weapons.[dest_index].usedcxx . . $ weapon#used. = 1; |
| 691 | Num_weaponscxx . . $ Num_weapons.++; |
| 692 | |
| 693 | memcpy(&Weaponscxx . . $ Weapons.[dest_index], &Weaponscxx . . $ Weapons.[cur_index], sizeof(weaponcxx . . $ weapon#)); |
| 694 | FreeWeaponcxx . . $ FreeWeapon(d4f767463ce0a6b3).(cur_index); |
| 695 | return 0; |
| 696 | } |
| 697 | |
| 698 | return new_index; // we made it! |
| 699 | } |
| 700 | |
| 701 | // Moves a weapon from a given index into a new one (above MAX_STATIC_WEAPONS) |
| 702 | // returns new index |
| 703 | int MoveWeaponFromIndexcxx . . $ MoveWeaponFromIndex(7864480464b09eea).(int index) { |
| 704 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(index >= 0 && index < MAX_STATIC_WEAPONScxx . . $ `Descent3/weapon.h:211:9`!); |
| 705 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(Weapons[index].used); |
| 706 | |
| 707 | int new_index = AllocWeaponcxx . . $ AllocWeapon(b126dc7c1de90089).(); |
| 708 | memcpy(&Weaponscxx . . $ Weapons.[new_index], &Weaponscxx . . $ Weapons.[index], sizeof(weaponcxx . . $ weapon#)); |
| 709 | FreeWeaponcxx . . $ FreeWeapon(d4f767463ce0a6b3).(index); |
| 710 | |
| 711 | return new_index; |
| 712 | } |
| 713 | |
| 714 | // This is a very confusing function. It takes all the weapons that we have loaded |
| 715 | // and remaps then into their proper places (if they are static). |
| 716 | void RemapWeaponscxx . . $ RemapWeapons(49f6e7a06ebc5aa8).() { |
| 717 | int limit = sizeof(Static_weapon_namescxx . . $ Static_weapon_names.) / sizeof(void *); |
| 718 | int i; |
| 719 | |
| 720 | for (i = 0; i < MAX_STATIC_WEAPONScxx . . $ `Descent3/weapon.h:211:9`!; i++) { |
| 721 | if (Weaponscxx . . $ Weapons.[i].usedcxx . . $ weapon#used.) { |
| 722 | int match = -1; |
| 723 | for (int t = 0; t < limit; t++) |
| 724 | if (!stricmpcxx . . $ `linux/linux_fix.h:43:9`!(Weapons[i].name, Static_weapon_names[t])) { |
| 725 | match = t; |
| 726 | break; |
| 727 | } |
| 728 | |
| 729 | if (match == -1) // this weapon is not supposed to be in the static area |
| 730 | { |
| 731 | int new_index; |
| 732 | |
| 733 | new_index = MoveWeaponFromIndexcxx . . $ MoveWeaponFromIndex(7864480464b09eea).(i); |
| 734 | RemapAllWeaponObjectscxx . . $ RemapAllWeaponObjects(3e454b8ccf442868).(i, new_index); |
| 735 | } else // this weapon is a static weapon, make sure its in its place |
| 736 | { |
| 737 | if (i != match) // its not where it belongs, move it |
| 738 | { |
| 739 | int new_index; |
| 740 | |
| 741 | new_index = MatchWeaponToIndexcxx . . $ MatchWeaponToIndex(6abd07ddb1a912f0).(Weaponscxx . . $ Weapons.[i].namecxx . . $ weapon#name., match); |
| 742 | |
| 743 | if (new_index != 0) |
| 744 | RemapAllWeaponObjectscxx . . $ RemapAllWeaponObjects(3e454b8ccf442868).(match, new_index); |
| 745 | RemapAllWeaponObjectscxx . . $ RemapAllWeaponObjects(3e454b8ccf442868).(i, match); |
| 746 | } |
| 747 | } |
| 748 | } |
| 749 | } |
| 750 | |
| 751 | for (i = MAX_STATIC_WEAPONScxx . . $ `Descent3/weapon.h:211:9`!; i < MAX_WEAPONScxx . . $ `Descent3/weapon.h:208:9`!; i++) { |
| 752 | if (Weaponscxx . . $ Weapons.[i].usedcxx . . $ weapon#used.) { |
| 753 | int match = -1; |
| 754 | for (int t = 0; t < limit; t++) |
| 755 | if (!stricmpcxx . . $ `linux/linux_fix.h:43:9`!(Weapons[i].name, Static_weapon_names[t])) { |
| 756 | match = t; |
| 757 | break; |
| 758 | } |
| 759 | |
| 760 | if (match != -1) // this is a static weapon that isn't supposed to be in the free area |
| 761 | { |
| 762 | |
| 763 | int new_index; |
| 764 | new_index = MatchWeaponToIndexcxx . . $ MatchWeaponToIndex(6abd07ddb1a912f0).(Weaponscxx . . $ Weapons.[i].namecxx . . $ weapon#name., match); |
| 765 | if (new_index != 0) |
| 766 | RemapAllWeaponObjectscxx . . $ RemapAllWeaponObjects(3e454b8ccf442868).(match, new_index); |
| 767 | RemapAllWeaponObjectscxx . . $ RemapAllWeaponObjects(3e454b8ccf442868).(i, match); |
| 768 | } |
| 769 | } |
| 770 | } |
| 771 | } |
| 772 | |
| 773 | // goes thru every entity that could possible have a weapon index (ie objects, weapons, etc) |
| 774 | // and changes the old index to the new index |
| 775 | void RemapAllWeaponObjectscxx . . $ RemapAllWeaponObjects(3e454b8ccf442868).(int old_index, int new_index) { |
| 776 | int i, j, k; |
| 777 | |
| 778 | // Remaps flying weapons |
| 779 | for (i = 0; i < MAX_OBJECTScxx . . $ `lib/object_external_struct.h:107:9`!; i++) { |
| 780 | |
| 781 | if (Objectscxx . . $ Objects.[i].typecxx . . $ object#type. == OBJ_WEAPONcxx . . $ `Descent3/object_external.h:165:9`!) { |
| 782 | if (Objectscxx . . $ Objects.[i].idcxx . . $ object#id. == old_index) { |
| 783 | Objectscxx . . $ Objects.[i].idcxx . . $ object#id. = new_index; |
| 784 | } |
| 785 | } |
| 786 | } |
| 787 | |
| 788 | // Remaps weapons contained by generic objects |
| 789 | for (i = 0; i < MAX_OBJECT_IDScxx . . $ `Descent3/objinfo.h:327:9`!; i++) { |
| 790 | if (Object_infocxx . . $ Object_info.[i].static_wbcxx . . $ object_info#static_wb.) { |
| 791 | for (j = 0; j < MAX_WBS_PER_OBJcxx . . $ `lib/robotfirestruct.h:32:9`!; j++) { |
| 792 | for (k = 0; k < MAX_WB_GUNPOINTScxx . . $ `lib/robotfirestruct_external.h:22:9`!; k++) { |
| 793 | if (Object_infocxx . . $ Object_info.[i].static_wbcxx . . $ object_info#static_wb.[j].gp_weapon_indexcxx . . $ otype_wb_info#gp_weapon_index.[k] == old_index) { |
| 794 | Object_infocxx . . $ Object_info.[i].static_wbcxx . . $ object_info#static_wb.[j].gp_weapon_indexcxx . . $ otype_wb_info#gp_weapon_index.[k] = new_index; |
| 795 | } |
| 796 | } |
| 797 | } |
| 798 | } |
| 799 | } |
| 800 | |
| 801 | // Remaps weapons contained by Ships |
| 802 | for (i = 0; i < MAX_SHIPScxx . . $ `Descent3/ship.h:122:9`!; i++) { |
| 803 | for (j = 0; j < MAX_WBS_PER_OBJcxx . . $ `lib/robotfirestruct.h:32:9`!; j++) { |
| 804 | for (k = 0; k < MAX_WB_FIRING_MASKScxx . . $ `lib/robotfirestruct_external.h:23:9`!; k++) { |
| 805 | if (Shipscxx . . $ Ships.[i].static_wbcxx . . $ ship#static_wb.[j].gp_weapon_indexcxx . . $ otype_wb_info#gp_weapon_index.[k] == old_index) { |
| 806 | Shipscxx . . $ Ships.[i].static_wbcxx . . $ ship#static_wb.[j].gp_weapon_indexcxx . . $ otype_wb_info#gp_weapon_index.[k] = new_index; |
| 807 | } |
| 808 | } |
| 809 | } |
| 810 | } |
| 811 | |
| 812 | // Do spawns |
| 813 | for (i = 0; i < MAX_WEAPONScxx . . $ `Descent3/weapon.h:208:9`!; i++) { |
| 814 | if (!Weaponscxx . . $ Weapons.[i].usedcxx . . $ weapon#used.) |
| 815 | continue; |
| 816 | |
| 817 | if (Weaponscxx . . $ Weapons.[i].spawn_handlecxx . . $ weapon#spawn_handle. == old_index) |
| 818 | Weaponscxx . . $ Weapons.[i].spawn_handlecxx . . $ weapon#spawn_handle. = new_index; |
| 819 | if (Weaponscxx . . $ Weapons.[i].alternate_spawn_handlecxx . . $ weapon#alternate_spawn_handle. == old_index) |
| 820 | Weaponscxx . . $ Weapons.[i].alternate_spawn_handlecxx . . $ weapon#alternate_spawn_handle. = new_index; |
| 821 | } |
| 822 | } |
| 823 | |
| 824 | bool IsWeaponSecondarycxx . . $ IsWeaponSecondary(83c267b20bac841a).(int index) { |
| 825 | if (index < SECONDARY_INDEXcxx . . $ `Descent3/weapon.h:255:9`!) |
| 826 | return false; |
| 827 | else |
| 828 | return true; |
| 829 | } |
| 830 | |
| 831 | /////////////////////////////////////////////////////////////////////////// |
| 832 | // Weapon acquirement |
| 833 | |
| 834 | // unconditionally adds a weapon and ammo to a player. |
| 835 | int AddWeaponToPlayercxx . . $ AddWeaponToPlayer(2326284602b0bb2d).(int slot, int weap_index, int ammo) { |
| 836 | bool select_new = false; |
| 837 | |
| 838 | LOGFILEcxx . . $ `Descent3/weapon.cpp:365:9`!((_logfp, "Adding weapon(%d,ammo=%d) to player.\n", weap_index, ammo)); |
| 839 | |
| 840 | Playerscxx . . $ Players.[slot].weapon_flagscxx . . $ player#weapon_flags. |= HAS_FLAGcxx . . $ `Descent3/weapon.h:215:9`!(weap_index); |
| 841 | |
| 842 | shipcxx . . $ ship# *ship = &Shipscxx . . $ Ships.[Playerscxx . . $ Players.[slot].ship_indexcxx . . $ player#ship_index.]; |
| 843 | otype_wb_infocxx . . $ otype_wb_info# *wb = &ship->static_wbcxx . . $ ship#static_wb.[weap_index]; |
| 844 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(wb != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!); |
| 845 | |
| 846 | // if secondary or primary that uses ammo, then use the ammo |
| 847 | if ((weap_index >= SECONDARY_INDEXcxx . . $ `Descent3/weapon.h:255:9`!) || wb->ammo_usagecxx . . $ otype_wb_info#ammo_usage.) { |
| 848 | // figure out much ammo to add |
| 849 | int added = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(ship->max_ammocxx . . $ ship#max_ammo.[weap_index] - Playerscxx . . $ Players.[slot].weapon_ammocxx . . $ player#weapon_ammo.[weap_index], ammo); |
| 850 | |
| 851 | // now add it |
| 852 | Playerscxx . . $ Players.[slot].weapon_ammocxx . . $ player#weapon_ammo.[weap_index] += (uint16_tcxx . . $ uint16_t#)added; |
| 853 | } |
| 854 | |
| 855 | if (slot == Player_numcxx . . $ Player_num.) { |
| 856 | if (weap_index < SECONDARY_INDEXcxx . . $ `Descent3/weapon.h:255:9`!) |
| 857 | select_new = AutoSelectWeaponcxx . . $ AutoSelectWeapon(cf9ef193275fa6d8).(PW_PRIMARYcxx . . $ `Descent3/player_external.h:108:9`!, weap_index); |
| 858 | else |
| 859 | select_new = AutoSelectWeaponcxx . . $ AutoSelectWeapon(cf9ef193275fa6d8).(PW_SECONDARYcxx . . $ `Descent3/player_external.h:109:9`!, weap_index); |
| 860 | |
| 861 | // this should be done in multisafe code now. |
| 862 | // if (!select_new) { |
| 863 | // AddHUDMessage ("%s!",TXT(Static_weapon_names_msg[weap_index])); |
| 864 | //} |
| 865 | } |
| 866 | |
| 867 | return 1; |
| 868 | } |
| 869 | |
| 870 | /////////////////////////////////////////////////////////////////////////// |
| 871 | // Weapon selection |
| 872 | |
| 873 | // Note that we allocate five keys per category of weapon (primary, secondary) |
| 874 | // We essentially select the weapon in slot passed. |
| 875 | |
| 876 | #define NUM_PRIMARY_SLOTScxx . . $ `Descent3/weapon.cpp:876:9`! 5 |
| 877 | #define NUM_SECONDARY_SLOTScxx . . $ `Descent3/weapon.cpp:877:9`! 5 |
| 878 | |
| 879 | // This is NOT a mask of weapons available to the player. This is a mask of what CLASS of |
| 880 | // weapon this slot is currently in. The code below checks this mask to see if it should |
| 881 | // select the higher class weapon in that slot when switching to that slot. |
| 882 | static uint16_tcxx . . $ uint16_t# Weapon_slot_maskcxx . . $ Weapon_slot_mask. = 0; |
| 883 | |
| 884 | void SelectPrimaryWeaponcxx . . $ SelectPrimaryWeapon(d4f767463ce0a6b3).(int slot); |
| 885 | void SelectSecondaryWeaponcxx . . $ SelectSecondaryWeapon(d4f767463ce0a6b3).(int slot); |
| 886 | void SetPrimaryWeaponcxx . . $ SetPrimaryWeapon(3e454b8ccf442868).(int index, int slot); |
| 887 | void SetSecondaryWeaponcxx . . $ SetSecondaryWeapon(3e454b8ccf442868).(int index, int slot); |
| 888 | |
| 889 | static inline bool is_weapon_availablecxx . . $ is_weapon_available(400679a455e568fa).(unsigned player_weapon_flags, int new_weapon, uint16_tcxx . . $ uint16_t# ammo = 0xffff) { |
| 890 | return ((player_weapon_flags & HAS_FLAGcxx . . $ `Descent3/weapon.h:215:9`!(new_weapon)) && ammo > 0) ? true : false; |
| 891 | } |
| 892 | |
| 893 | // used for sequencing |
| 894 | void ResetWeaponSelectStatescxx . . $ ResetWeaponSelectStates(ed53e3bbd3fa2f69).(uint16_tcxx . . $ uint16_t# new_state) { Weapon_slot_maskcxx . . $ Weapon_slot_mask. = new_state; } |
| 895 | |
| 896 | void SaveWeaponSelectStatescxx . . $ SaveWeaponSelectStates(3639e799710acb68).(CFILEcxx . . $ CFILE# *fp) { cf_WriteShortcxx . . $ cf_WriteShort(d7cf1a05aca96fe5).(fp, Weapon_slot_maskcxx . . $ Weapon_slot_mask.); } |
| 897 | |
| 898 | void LoadWeaponSelectStatescxx . . $ LoadWeaponSelectStates(3639e799710acb68).(CFILEcxx . . $ CFILE# *fp) { |
| 899 | uint16_tcxx . . $ uint16_t# state = (uint16_tcxx . . $ uint16_t#)cf_ReadShortcxx . . $ cf_ReadShort(30b00389b433b379).(fp); |
| 900 | ResetWeaponSelectStatescxx . . $ ResetWeaponSelectStates(ed53e3bbd3fa2f69).(state); |
| 901 | } |
| 902 | |
| 903 | void SelectWeaponcxx . . $ SelectWeapon(d4f767463ce0a6b3).(int slot) { |
| 904 | if (Player_objectcxx . . $ Player_object.->typecxx . . $ object#type. != OBJ_PLAYERcxx . . $ `Descent3/object_external.h:164:9`!) |
| 905 | return; // This can happen when a player is dead and tries to select a weapon |
| 906 | |
| 907 | if (slot < NUM_PRIMARY_SLOTScxx . . $ `Descent3/weapon.cpp:876:9`!) |
| 908 | SelectPrimaryWeaponcxx . . $ SelectPrimaryWeapon(d4f767463ce0a6b3).(slot); |
| 909 | else |
| 910 | SelectSecondaryWeaponcxx . . $ SelectSecondaryWeapon(d4f767463ce0a6b3).(slot); |
| 911 | } |
| 912 | |
| 913 | // slot ranges 0-4 |
| 914 | void SelectPrimaryWeaponcxx . . $ SelectPrimaryWeapon(d4f767463ce0a6b3).(int slot) { |
| 915 | // get slot of currently selected weapon |
| 916 | int oldslot; |
| 917 | int nw_low, nw_high; |
| 918 | unsigned avail_flags; |
| 919 | playercxx . . $ player# *plr = &Playerscxx . . $ Players.[Player_numcxx . . $ Player_num.]; |
| 920 | |
| 921 | avail_flags = plr->weapon_flagscxx . . $ player#weapon_flags.; |
| 922 | oldslot = plr->weaponcxx . . $ player#weapon.[PW_PRIMARYcxx . . $ `Descent3/player_external.h:108:9`!].indexcxx . . $ player_weapon#index. % NUM_PRIMARY_SLOTScxx . . $ `Descent3/weapon.cpp:876:9`!; |
| 923 | |
| 924 | // do selection. if we are selecting the same slot of weapon, then we select to the next |
| 925 | // level of weapon. when going from highest level, go to lowest |
| 926 | if (oldslot == slot) { |
| 927 | uint16_tcxx . . $ uint16_t# nw_low = (plr->weaponcxx . . $ player#weapon.[PW_PRIMARYcxx . . $ `Descent3/player_external.h:108:9`!].indexcxx . . $ player_weapon#index. + NUM_PRIMARY_SLOTScxx . . $ `Descent3/weapon.cpp:876:9`!) % MAX_PRIMARY_WEAPONScxx . . $ `Descent3/weapon.h:202:9`!; |
| 928 | |
| 929 | if (is_weapon_availablecxx . . $ is_weapon_available(400679a455e568fa).(avail_flags, nw_low)) { |
| 930 | // toggle class of weapon in specified slot (save for selection) |
| 931 | SetPrimaryWeaponcxx . . $ SetPrimaryWeapon(3e454b8ccf442868).(nw_low, slot); |
| 932 | } else { |
| 933 | AddHUDMessagecxx . . $ AddHUDMessage(f90d95ab21fd6d97).(TXT_WPNNOTAVAILcxx . . $ `Descent3/stringtable.h:271:9`!); |
| 934 | Sound_systemcxx . . $ Sound_system..Play2dSoundcxx . . $ hlsSystem#Play2dSound(d251026853493025).(SOUND_DO_NOT_HAVE_ITcxx . . $ `Descent3/sounds.h:117:9`!); |
| 935 | |
| 936 | ain_hearcxx . . $ ain_hear# hear; |
| 937 | hear.f_directly_playercxx . . $ ain_hear#f_directly_player. = true; |
| 938 | hear.hostile_levelcxx . . $ ain_hear#hostile_level. = 0.1f; |
| 939 | hear.curiosity_levelcxx . . $ ain_hear#curiosity_level. = 0.5f; |
| 940 | hear.max_distcxx . . $ ain_hear#max_dist. = AI_SOUND_SHORT_DISTcxx . . $ `Descent3/AIMain.h:157:9`!; |
| 941 | AINotifycxx . . $ AINotify(f32b5964aaa42c22).(&Objectscxx . . $ Objects.[Playerscxx . . $ Players.[Player_numcxx . . $ Player_num.].objnumcxx . . $ player#objnum.], AIN_HEAR_NOISEcxx . . $ `Descent3/aistruct_external.h:297:9`!, (void *)&hear); |
| 942 | } |
| 943 | |
| 944 | return; |
| 945 | } else { |
| 946 | // we are selecting a new weapon slot. |
| 947 | nw_low = slot % NUM_PRIMARY_SLOTScxx . . $ `Descent3/weapon.cpp:876:9`!; |
| 948 | nw_high = nw_low + NUM_PRIMARY_SLOTScxx . . $ `Descent3/weapon.cpp:876:9`!; |
| 949 | |
| 950 | if (Weapon_slot_maskcxx . . $ Weapon_slot_mask. & (1 << slot)) { |
| 951 | // we think we have a higher class of weapon. |
| 952 | if (is_weapon_availablecxx . . $ is_weapon_available(400679a455e568fa).(avail_flags, nw_high)) { |
| 953 | // if this slot had the higher class of weapon then check if we still have the higher class weapon. |
| 954 | // toggle class of weapon in specified slot (save for selection) |
| 955 | SetPrimaryWeaponcxx . . $ SetPrimaryWeapon(3e454b8ccf442868).(nw_high, slot); |
| 956 | } else if (is_weapon_availablecxx . . $ is_weapon_available(400679a455e568fa).(avail_flags, nw_low)) { |
| 957 | // check if we have the lower class. |
| 958 | // toggle class of weapon in specified slot (save for selection) |
| 959 | SetPrimaryWeaponcxx . . $ SetPrimaryWeapon(3e454b8ccf442868).(nw_low, slot); |
| 960 | } else { |
| 961 | AddHUDMessagecxx . . $ AddHUDMessage(f90d95ab21fd6d97).(TXT_WPNNOTAVAILcxx . . $ `Descent3/stringtable.h:271:9`!); |
| 962 | Sound_systemcxx . . $ Sound_system..Play2dSoundcxx . . $ hlsSystem#Play2dSound(d251026853493025).(SOUND_DO_NOT_HAVE_ITcxx . . $ `Descent3/sounds.h:117:9`!); |
| 963 | |
| 964 | ain_hearcxx . . $ ain_hear# hear; |
| 965 | hear.f_directly_playercxx . . $ ain_hear#f_directly_player. = true; |
| 966 | hear.hostile_levelcxx . . $ ain_hear#hostile_level. = 0.1f; |
| 967 | hear.curiosity_levelcxx . . $ ain_hear#curiosity_level. = 0.5f; |
| 968 | hear.max_distcxx . . $ ain_hear#max_dist. = AI_SOUND_SHORT_DISTcxx . . $ `Descent3/AIMain.h:157:9`!; |
| 969 | AINotifycxx . . $ AINotify(f32b5964aaa42c22).(&Objectscxx . . $ Objects.[Playerscxx . . $ Players.[Player_numcxx . . $ Player_num.].objnumcxx . . $ player#objnum.], AIN_HEAR_NOISEcxx . . $ `Descent3/aistruct_external.h:297:9`!, (void *)&hear); |
| 970 | } |
| 971 | } else { |
| 972 | // if this is a lower class of weapon, make sure this slot is flagged as having the lower version |
| 973 | if (is_weapon_availablecxx . . $ is_weapon_available(400679a455e568fa).(avail_flags, nw_low)) { |
| 974 | // if this slot had the higher class of weapon then check if we still have the higher class weapon. |
| 975 | // toggle class of weapon in specified slot (save for selection) |
| 976 | SetPrimaryWeaponcxx . . $ SetPrimaryWeapon(3e454b8ccf442868).(nw_low, slot); |
| 977 | } else if (is_weapon_availablecxx . . $ is_weapon_available(400679a455e568fa).(avail_flags, nw_high)) { |
| 978 | // check if we have the lower class. |
| 979 | // toggle class of weapon in specified slot (save for selection) |
| 980 | SetPrimaryWeaponcxx . . $ SetPrimaryWeapon(3e454b8ccf442868).(nw_high, slot); |
| 981 | } else { |
| 982 | AddHUDMessagecxx . . $ AddHUDMessage(f90d95ab21fd6d97).(TXT_WPNNOTAVAILcxx . . $ `Descent3/stringtable.h:271:9`!); |
| 983 | Sound_systemcxx . . $ Sound_system..Play2dSoundcxx . . $ hlsSystem#Play2dSound(d251026853493025).(SOUND_DO_NOT_HAVE_ITcxx . . $ `Descent3/sounds.h:117:9`!); |
| 984 | |
| 985 | ain_hearcxx . . $ ain_hear# hear; |
| 986 | hear.f_directly_playercxx . . $ ain_hear#f_directly_player. = true; |
| 987 | hear.hostile_levelcxx . . $ ain_hear#hostile_level. = 0.1f; |
| 988 | hear.curiosity_levelcxx . . $ ain_hear#curiosity_level. = 0.5f; |
| 989 | hear.max_distcxx . . $ ain_hear#max_dist. = AI_SOUND_SHORT_DISTcxx . . $ `Descent3/AIMain.h:157:9`!; |
| 990 | AINotifycxx . . $ AINotify(f32b5964aaa42c22).(&Objectscxx . . $ Objects.[Playerscxx . . $ Players.[Player_numcxx . . $ Player_num.].objnumcxx . . $ player#objnum.], AIN_HEAR_NOISEcxx . . $ `Descent3/aistruct_external.h:297:9`!, (void *)&hear); |
| 991 | } |
| 992 | } |
| 993 | } |
| 994 | } |
| 995 | |
| 996 | // slot ranges 5-9 |
| 997 | void SelectSecondaryWeaponcxx . . $ SelectSecondaryWeapon(d4f767463ce0a6b3).(int slot) { |
| 998 | // get slot of currently selected weapon |
| 999 | int oldslot; |
| 1000 | int nw_low, nw_high; |
| 1001 | unsigned avail_flags; |
| 1002 | playercxx . . $ player# *plr = &Playerscxx . . $ Players.[Player_numcxx . . $ Player_num.]; |
| 1003 | |
| 1004 | avail_flags = plr->weapon_flagscxx . . $ player#weapon_flags.; |
| 1005 | oldslot = (plr->weaponcxx . . $ player#weapon.[PW_SECONDARYcxx . . $ `Descent3/player_external.h:109:9`!].indexcxx . . $ player_weapon#index. % NUM_SECONDARY_SLOTScxx . . $ `Descent3/weapon.cpp:877:9`!) + NUM_PRIMARY_SLOTScxx . . $ `Descent3/weapon.cpp:876:9`!; |
| 1006 | |
| 1007 | // do selection. if we are selecting the same slot of weapon, then we select to the next |
| 1008 | // level of weapon. when going from highest level, go to lowest |
| 1009 | if (oldslot == slot) { |
| 1010 | nw_low = SECONDARY_INDEXcxx . . $ `Descent3/weapon.h:255:9`! + ((plr->weaponcxx . . $ player#weapon.[PW_SECONDARYcxx . . $ `Descent3/player_external.h:109:9`!].indexcxx . . $ player_weapon#index. + NUM_SECONDARY_SLOTScxx . . $ `Descent3/weapon.cpp:877:9`!) % MAX_SECONDARY_WEAPONScxx . . $ `Descent3/weapon.h:203:9`!); |
| 1011 | |
| 1012 | if (is_weapon_availablecxx . . $ is_weapon_available(400679a455e568fa).(avail_flags, nw_low, plr->weapon_ammocxx . . $ player#weapon_ammo.[nw_low])) { |
| 1013 | // toggle class of weapon in specified slot (save for selection) |
| 1014 | SetSecondaryWeaponcxx . . $ SetSecondaryWeapon(3e454b8ccf442868).(nw_low, slot); |
| 1015 | } else { |
| 1016 | AddHUDMessagecxx . . $ AddHUDMessage(f90d95ab21fd6d97).(TXT_WPNNOTAVAILcxx . . $ `Descent3/stringtable.h:271:9`!); |
| 1017 | Sound_systemcxx . . $ Sound_system..Play2dSoundcxx . . $ hlsSystem#Play2dSound(d251026853493025).(SOUND_DO_NOT_HAVE_ITcxx . . $ `Descent3/sounds.h:117:9`!); |
| 1018 | |
| 1019 | ain_hearcxx . . $ ain_hear# hear; |
| 1020 | hear.f_directly_playercxx . . $ ain_hear#f_directly_player. = true; |
| 1021 | hear.hostile_levelcxx . . $ ain_hear#hostile_level. = 0.1f; |
| 1022 | hear.curiosity_levelcxx . . $ ain_hear#curiosity_level. = 0.5f; |
| 1023 | hear.max_distcxx . . $ ain_hear#max_dist. = AI_SOUND_SHORT_DISTcxx . . $ `Descent3/AIMain.h:157:9`!; |
| 1024 | AINotifycxx . . $ AINotify(f32b5964aaa42c22).(&Objectscxx . . $ Objects.[Playerscxx . . $ Players.[Player_numcxx . . $ Player_num.].objnumcxx . . $ player#objnum.], AIN_HEAR_NOISEcxx . . $ `Descent3/aistruct_external.h:297:9`!, (void *)&hear); |
| 1025 | } |
| 1026 | return; |
| 1027 | } |
| 1028 | |
| 1029 | // we are selecting a new weapon slot. |
| 1030 | nw_low = (slot % NUM_SECONDARY_SLOTScxx . . $ `Descent3/weapon.cpp:877:9`!) + SECONDARY_INDEXcxx . . $ `Descent3/weapon.h:255:9`!; |
| 1031 | nw_high = nw_low + NUM_SECONDARY_SLOTScxx . . $ `Descent3/weapon.cpp:877:9`!; |
| 1032 | |
| 1033 | if (Weapon_slot_maskcxx . . $ Weapon_slot_mask. & (1 << slot)) { |
| 1034 | // we think we have a higher class of weapon. |
| 1035 | if (is_weapon_availablecxx . . $ is_weapon_available(400679a455e568fa).(avail_flags, nw_high, plr->weapon_ammocxx . . $ player#weapon_ammo.[nw_high])) { |
| 1036 | // if this slot had the higher class of weapon then check if we still have the higher class weapon. |
| 1037 | SetSecondaryWeaponcxx . . $ SetSecondaryWeapon(3e454b8ccf442868).(nw_high, slot); |
| 1038 | } else if (is_weapon_availablecxx . . $ is_weapon_available(400679a455e568fa).(avail_flags, nw_low, plr->weapon_ammocxx . . $ player#weapon_ammo.[nw_low])) { |
| 1039 | SetSecondaryWeaponcxx . . $ SetSecondaryWeapon(3e454b8ccf442868).(nw_low, slot); |
| 1040 | } else { |
| 1041 | AddHUDMessagecxx . . $ AddHUDMessage(f90d95ab21fd6d97).(TXT_WPNNOTAVAILcxx . . $ `Descent3/stringtable.h:271:9`!); |
| 1042 | Sound_systemcxx . . $ Sound_system..Play2dSoundcxx . . $ hlsSystem#Play2dSound(d251026853493025).(SOUND_DO_NOT_HAVE_ITcxx . . $ `Descent3/sounds.h:117:9`!); |
| 1043 | |
| 1044 | ain_hearcxx . . $ ain_hear# hear; |
| 1045 | hear.f_directly_playercxx . . $ ain_hear#f_directly_player. = true; |
| 1046 | hear.hostile_levelcxx . . $ ain_hear#hostile_level. = 0.1f; |
| 1047 | hear.curiosity_levelcxx . . $ ain_hear#curiosity_level. = 0.5f; |
| 1048 | hear.max_distcxx . . $ ain_hear#max_dist. = AI_SOUND_SHORT_DISTcxx . . $ `Descent3/AIMain.h:157:9`!; |
| 1049 | AINotifycxx . . $ AINotify(f32b5964aaa42c22).(&Objectscxx . . $ Objects.[Playerscxx . . $ Players.[Player_numcxx . . $ Player_num.].objnumcxx . . $ player#objnum.], AIN_HEAR_NOISEcxx . . $ `Descent3/aistruct_external.h:297:9`!, (void *)&hear); |
| 1050 | } |
| 1051 | } else { |
| 1052 | // if this is a lower class of weapon, make sure this slot is flagged as having the lower version |
| 1053 | if (is_weapon_availablecxx . . $ is_weapon_available(400679a455e568fa).(avail_flags, nw_low, plr->weapon_ammocxx . . $ player#weapon_ammo.[nw_low])) { |
| 1054 | // if this slot had the higher class of weapon then check if we still have the higher class weapon. |
| 1055 | SetSecondaryWeaponcxx . . $ SetSecondaryWeapon(3e454b8ccf442868).(nw_low, slot); |
| 1056 | } else if (is_weapon_availablecxx . . $ is_weapon_available(400679a455e568fa).(avail_flags, nw_high, plr->weapon_ammocxx . . $ player#weapon_ammo.[nw_high])) { |
| 1057 | // check if we have the lower class. |
| 1058 | SetSecondaryWeaponcxx . . $ SetSecondaryWeapon(3e454b8ccf442868).(nw_high, slot); |
| 1059 | } else { |
| 1060 | AddHUDMessagecxx . . $ AddHUDMessage(f90d95ab21fd6d97).(TXT_WPNNOTAVAILcxx . . $ `Descent3/stringtable.h:271:9`!); |
| 1061 | Sound_systemcxx . . $ Sound_system..Play2dSoundcxx . . $ hlsSystem#Play2dSound(d251026853493025).(SOUND_DO_NOT_HAVE_ITcxx . . $ `Descent3/sounds.h:117:9`!); |
| 1062 | |
| 1063 | ain_hearcxx . . $ ain_hear# hear; |
| 1064 | hear.f_directly_playercxx . . $ ain_hear#f_directly_player. = true; |
| 1065 | hear.hostile_levelcxx . . $ ain_hear#hostile_level. = 0.1f; |
| 1066 | hear.curiosity_levelcxx . . $ ain_hear#curiosity_level. = 0.5f; |
| 1067 | hear.max_distcxx . . $ ain_hear#max_dist. = AI_SOUND_SHORT_DISTcxx . . $ `Descent3/AIMain.h:157:9`!; |
| 1068 | AINotifycxx . . $ AINotify(f32b5964aaa42c22).(&Objectscxx . . $ Objects.[Playerscxx . . $ Players.[Player_numcxx . . $ Player_num.].objnumcxx . . $ player#objnum.], AIN_HEAR_NOISEcxx . . $ `Descent3/aistruct_external.h:297:9`!, (void *)&hear); |
| 1069 | } |
| 1070 | } |
| 1071 | } |
| 1072 | |
| 1073 | void SetPrimaryWeaponcxx . . $ SetPrimaryWeapon(3e454b8ccf442868).(int index, int slot) { |
| 1074 | dynamic_wb_infocxx . . $ dynamic_wb_info# *p_dwb = &Player_objectcxx . . $ Player_object.->dynamic_wbcxx . . $ object#dynamic_wb.[index]; |
| 1075 | |
| 1076 | if (index < NUM_PRIMARY_SLOTScxx . . $ `Descent3/weapon.cpp:876:9`!) |
| 1077 | Weapon_slot_maskcxx . . $ Weapon_slot_mask. &= ~(1 << slot); |
| 1078 | else |
| 1079 | Weapon_slot_maskcxx . . $ Weapon_slot_mask. |= (1 << slot); |
| 1080 | |
| 1081 | if (index != Playerscxx . . $ Players.[Player_numcxx . . $ Player_num.].weaponcxx . . $ player#weapon.[PW_PRIMARYcxx . . $ `Descent3/player_external.h:108:9`!].indexcxx . . $ player_weapon#index.) { |
| 1082 | ClearPlayerFiringcxx . . $ ClearPlayerFiring(766a1b7183ffa4b4).(Player_objectcxx . . $ Player_object., PW_PRIMARYcxx . . $ `Descent3/player_external.h:108:9`!); |
| 1083 | Playerscxx . . $ Players.[Player_numcxx . . $ Player_num.].weaponcxx . . $ player#weapon.[PW_PRIMARYcxx . . $ `Descent3/player_external.h:108:9`!].indexcxx . . $ player_weapon#index. = index; |
| 1084 | |
| 1085 | AddHUDMessagecxx . . $ AddHUDMessage(f90d95ab21fd6d97).(TXT_WPNSELECTcxx . . $ `Descent3/stringtable.h:273:9`!, TXTcxx . . $ `Descent3/stringtable.h:24:9`!(Static_weapon_names_msg[index])); |
| 1086 | // SetGaugeModified(GGF_PRIMARYLOAD, true); |
| 1087 | Sound_systemcxx . . $ Sound_system..Play2dSoundcxx . . $ hlsSystem#Play2dSound(d251026853493025).(SOUND_CHANGE_PRIMARYcxx . . $ `Descent3/sounds.h:118:9`!); |
| 1088 | |
| 1089 | ain_hearcxx . . $ ain_hear# hear; |
| 1090 | hear.f_directly_playercxx . . $ ain_hear#f_directly_player. = true; |
| 1091 | hear.hostile_levelcxx . . $ ain_hear#hostile_level. = 0.2f; |
| 1092 | hear.curiosity_levelcxx . . $ ain_hear#curiosity_level. = 0.5f; |
| 1093 | hear.max_distcxx . . $ ain_hear#max_dist. = AI_SOUND_SHORT_DISTcxx . . $ `Descent3/AIMain.h:157:9`!; |
| 1094 | AINotifycxx . . $ AINotify(f32b5964aaa42c22).(&Objectscxx . . $ Objects.[Playerscxx . . $ Players.[Player_numcxx . . $ Player_num.].objnumcxx . . $ player#objnum.], AIN_HEAR_NOISEcxx . . $ `Descent3/aistruct_external.h:297:9`!, (void *)&hear); |
| 1095 | |
| 1096 | // Stop any firing activity |
| 1097 | p_dwb->last_fire_timecxx . . $ dynamic_wb_info#last_fire_time. = Gametimecxx . . $ Gametime.; |
| 1098 | // resets reticle to current weapon. |
| 1099 | ResetReticlecxx . . $ ResetReticle(49f6e7a06ebc5aa8).(); |
| 1100 | } |
| 1101 | } |
| 1102 | |
| 1103 | void SetSecondaryWeaponcxx . . $ SetSecondaryWeapon(3e454b8ccf442868).(int index, int slot) { |
| 1104 | dynamic_wb_infocxx . . $ dynamic_wb_info# *p_dwb = &Player_objectcxx . . $ Player_object.->dynamic_wbcxx . . $ object#dynamic_wb.[index]; |
| 1105 | |
| 1106 | if (index < (NUM_SECONDARY_SLOTScxx . . $ `Descent3/weapon.cpp:877:9`! + SECONDARY_INDEXcxx . . $ `Descent3/weapon.h:255:9`!)) |
| 1107 | Weapon_slot_maskcxx . . $ Weapon_slot_mask. &= ~(1 << slot); |
| 1108 | else |
| 1109 | Weapon_slot_maskcxx . . $ Weapon_slot_mask. |= (1 << slot); |
| 1110 | |
| 1111 | // Stop any firing activity |
| 1112 | ClearPlayerFiringcxx . . $ ClearPlayerFiring(766a1b7183ffa4b4).(Player_objectcxx . . $ Player_object., PW_SECONDARYcxx . . $ `Descent3/player_external.h:109:9`!); |
| 1113 | |
| 1114 | if (index != Playerscxx . . $ Players.[Player_numcxx . . $ Player_num.].weaponcxx . . $ player#weapon.[PW_SECONDARYcxx . . $ `Descent3/player_external.h:109:9`!].indexcxx . . $ player_weapon#index.) { |
| 1115 | Playerscxx . . $ Players.[Player_numcxx . . $ Player_num.].weaponcxx . . $ player#weapon.[PW_SECONDARYcxx . . $ `Descent3/player_external.h:109:9`!].indexcxx . . $ player_weapon#index. = index; |
| 1116 | |
| 1117 | AddHUDMessagecxx . . $ AddHUDMessage(f90d95ab21fd6d97).(TXT_WPNSELECTcxx . . $ `Descent3/stringtable.h:273:9`!, TXTcxx . . $ `Descent3/stringtable.h:24:9`!(Static_weapon_names_msg[index])); |
| 1118 | // SetGaugeModified(GGF_SECONDARYLOAD, true); |
| 1119 | Sound_systemcxx . . $ Sound_system..Play2dSoundcxx . . $ hlsSystem#Play2dSound(d251026853493025).(SOUND_CHANGE_SECONDARYcxx . . $ `Descent3/sounds.h:119:9`!); |
| 1120 | |
| 1121 | ain_hearcxx . . $ ain_hear# hear; |
| 1122 | hear.f_directly_playercxx . . $ ain_hear#f_directly_player. = true; |
| 1123 | hear.hostile_levelcxx . . $ ain_hear#hostile_level. = 0.1f; |
| 1124 | hear.curiosity_levelcxx . . $ ain_hear#curiosity_level. = 0.3f; |
| 1125 | hear.max_distcxx . . $ ain_hear#max_dist. = AI_SOUND_SHORT_DISTcxx . . $ `Descent3/AIMain.h:157:9`!; |
| 1126 | AINotifycxx . . $ AINotify(f32b5964aaa42c22).(&Objectscxx . . $ Objects.[Playerscxx . . $ Players.[Player_numcxx . . $ Player_num.].objnumcxx . . $ player#objnum.], AIN_HEAR_NOISEcxx . . $ `Descent3/aistruct_external.h:297:9`!, (void *)&hear); |
| 1127 | |
| 1128 | // Stop any firing activity |
| 1129 | ClearPlayerFiringcxx . . $ ClearPlayerFiring(766a1b7183ffa4b4).(Player_objectcxx . . $ Player_object., PW_SECONDARYcxx . . $ `Descent3/player_external.h:109:9`!); |
| 1130 | p_dwb->last_fire_timecxx . . $ dynamic_wb_info#last_fire_time. = Gametimecxx . . $ Gametime.; |
| 1131 | // resets reticle to current weapon. |
| 1132 | ResetReticlecxx . . $ ResetReticle(49f6e7a06ebc5aa8).(); |
| 1133 | } |
| 1134 | } |
| 1135 | |
| 1136 | /////////////////////////////////////////////////////////////////////////// |
| 1137 | // Weapon AUTO selection |
| 1138 | |
| 1139 | const uint16_tcxx . . $ uint16_t# SELLIST_STARTcxx . . $ SELLIST_START. = 0x7ffe, SELLIST_ENDcxx . . $ SELLIST_END. = 0x7fff; |
| 1140 | |
| 1141 | static uint16_tcxx . . $ uint16_t# PrimaryWpnSelectListcxx . . $ PrimaryWpnSelectList.[] = {SELLIST_STARTcxx . . $ SELLIST_START., LASER_INDEXcxx . . $ `Descent3/weapon_external.h:22:9`!, VAUSS_INDEXcxx . . $ `Descent3/weapon_external.h:23:9`!, MICROWAVE_INDEXcxx . . $ `Descent3/weapon_external.h:24:9`!, |
| 1142 | PLASMA_INDEXcxx . . $ `Descent3/weapon_external.h:25:9`!, FUSION_INDEXcxx . . $ `Descent3/weapon_external.h:26:9`!, SUPER_LASER_INDEXcxx . . $ `Descent3/weapon_external.h:27:9`!, MASSDRIVER_INDEXcxx . . $ `Descent3/weapon_external.h:28:9`!, |
| 1143 | NAPALM_INDEXcxx . . $ `Descent3/weapon_external.h:29:9`!, EMD_INDEXcxx . . $ `Descent3/weapon_external.h:30:9`!, OMEGA_INDEXcxx . . $ `Descent3/weapon_external.h:31:9`!, SELLIST_ENDcxx . . $ SELLIST_END.}; |
| 1144 | |
| 1145 | static uint16_tcxx . . $ uint16_t# SecondaryWpnSelectListcxx . . $ SecondaryWpnSelectList.[] = { |
| 1146 | SELLIST_STARTcxx . . $ SELLIST_START., CONCUSSION_INDEXcxx . . $ `Descent3/weapon_external.h:32:9`!, HOMING_INDEXcxx . . $ `Descent3/weapon_external.h:33:9`!, IMPACTMORTAR_INDEXcxx . . $ `Descent3/weapon_external.h:34:9`!, SMART_INDEXcxx . . $ `Descent3/weapon_external.h:35:9`!, MEGA_INDEXcxx . . $ `Descent3/weapon_external.h:36:9`!, |
| 1147 | FRAG_INDEXcxx . . $ `Descent3/weapon_external.h:37:9`!, GUIDED_INDEXcxx . . $ `Descent3/weapon_external.h:38:9`! + WPNSEL_SKIPcxx . . $ WPNSEL_SKIP., NAPALMROCKET_INDEXcxx . . $ `Descent3/weapon_external.h:39:9`!, CYCLONE_INDEXcxx . . $ `Descent3/weapon_external.h:40:9`!, BLACKSHARK_INDEXcxx . . $ `Descent3/weapon_external.h:41:9`!, SELLIST_ENDcxx . . $ SELLIST_END.}; |
| 1148 | |
| 1149 | uint16_tcxx . . $ uint16_t# GetAutoSelectPrimaryWpnIdxcxx . . $ GetAutoSelectPrimaryWpnIdx(1ab5934a54f935a6).(int slot) { |
| 1150 | int i = -1; |
| 1151 | |
| 1152 | while (PrimaryWpnSelectListcxx . . $ PrimaryWpnSelectList.[i + 1] != SELLIST_ENDcxx . . $ SELLIST_END.) { |
| 1153 | if (slot == i) |
| 1154 | return PrimaryWpnSelectListcxx . . $ PrimaryWpnSelectList.[i + 1]; |
| 1155 | i++; |
| 1156 | } |
| 1157 | |
| 1158 | return WPNSEL_INVALIDcxx . . $ WPNSEL_INVALID.; |
| 1159 | } |
| 1160 | |
| 1161 | uint16_tcxx . . $ uint16_t# GetAutoSelectSecondaryWpnIdxcxx . . $ GetAutoSelectSecondaryWpnIdx(1ab5934a54f935a6).(int slot) { |
| 1162 | int i = -1; |
| 1163 | |
| 1164 | while (SecondaryWpnSelectListcxx . . $ SecondaryWpnSelectList.[i + 1] != SELLIST_ENDcxx . . $ SELLIST_END.) { |
| 1165 | if (slot == i) |
| 1166 | return SecondaryWpnSelectListcxx . . $ SecondaryWpnSelectList.[i + 1]; |
| 1167 | i++; |
| 1168 | } |
| 1169 | |
| 1170 | return WPNSEL_INVALIDcxx . . $ WPNSEL_INVALID.; |
| 1171 | } |
| 1172 | |
| 1173 | void SetAutoSelectPrimaryWpnIdxcxx . . $ SetAutoSelectPrimaryWpnIdx(a7050f1a4cb56049).(int slot, uint16_tcxx . . $ uint16_t# idx) { |
| 1174 | if (slot < 0 || slot >= MAX_PRIMARY_WEAPONScxx . . $ `Descent3/weapon.h:202:9`!) |
| 1175 | Int3cxx . . $ `misc/pserror.h:247:9`!(); |
| 1176 | |
| 1177 | PrimaryWpnSelectListcxx . . $ PrimaryWpnSelectList.[slot + 1] = idx; |
| 1178 | } |
| 1179 | |
| 1180 | void SetAutoSelectSecondaryWpnIdxcxx . . $ SetAutoSelectSecondaryWpnIdx(a7050f1a4cb56049).(int slot, uint16_tcxx . . $ uint16_t# idx) { |
| 1181 | if (slot < 0 || slot >= MAX_SECONDARY_WEAPONScxx . . $ `Descent3/weapon.h:203:9`!) |
| 1182 | Int3cxx . . $ `misc/pserror.h:247:9`!(); |
| 1183 | |
| 1184 | SecondaryWpnSelectListcxx . . $ SecondaryWpnSelectList.[slot + 1] = idx; |
| 1185 | } |
| 1186 | |
| 1187 | const uint16_tcxx . . $ uint16_t# IWPNSEL_SKIPcxx . . $ IWPNSEL_SKIP. = (uint16_tcxx . . $ uint16_t#) ((~WPNSEL_SKIPcxx . . $ WPNSEL_SKIP.) & 0xFFFF); |
| 1188 | |
| 1189 | #define WPNINDEXcxx . . $ `Descent3/weapon.cpp:1189:9`!(_index) (sel_list[(_index)] & IWPNSEL_SKIP) |
| 1190 | |
| 1191 | // automatically switches weapon up to next level in autoselect order to this value. and type. |
| 1192 | int SwitchPlayerWeaponcxx . . $ SwitchPlayerWeapon(7864480464b09eea).(int weapon_type) { |
| 1193 | playercxx . . $ player# *plr; |
| 1194 | shipcxx . . $ ship# *ship; |
| 1195 | int new_index; |
| 1196 | void (*setwpnfunc)(int, int); // Call either primary or secondary set weapon function |
| 1197 | uint16_tcxx . . $ uint16_t# *sel_list; |
| 1198 | int plr_wpn_index; |
| 1199 | |
| 1200 | plr = &Playerscxx . . $ Players.[Player_numcxx . . $ Player_num.]; |
| 1201 | ship = &Shipscxx . . $ Ships.[plr->ship_indexcxx . . $ player#ship_index.]; |
| 1202 | plr_wpn_index = plr->weaponcxx . . $ player#weapon.[weapon_type].indexcxx . . $ player_weapon#index.; |
| 1203 | |
| 1204 | setwpnfunc = (weapon_type == PW_SECONDARYcxx . . $ `Descent3/player_external.h:109:9`!) ? SetSecondaryWeaponcxx . . $ SetSecondaryWeapon(3e454b8ccf442868). : SetPrimaryWeaponcxx . . $ SetPrimaryWeapon(3e454b8ccf442868).; |
| 1205 | sel_list = (weapon_type == PW_SECONDARYcxx . . $ `Descent3/player_external.h:109:9`!) ? SecondaryWpnSelectListcxx . . $ SecondaryWpnSelectList. : PrimaryWpnSelectListcxx . . $ PrimaryWpnSelectList.; |
| 1206 | |
| 1207 | new_index = 0; |
| 1208 | while (WPNINDEXcxx . . $ `Descent3/weapon.cpp:1189:9`!(new_index) != plr_wpn_index && WPNINDEXcxx . . $ `Descent3/weapon.cpp:1189:9`!(new_index) != SELLIST_ENDcxx . . $ SELLIST_END.) |
| 1209 | new_index++; |
| 1210 | |
| 1211 | if (WPNINDEXcxx . . $ `Descent3/weapon.cpp:1189:9`!(new_index) == SELLIST_ENDcxx . . $ SELLIST_END.) { |
| 1212 | Int3cxx . . $ `misc/pserror.h:247:9`!(); // every weapon should be in list that's in the game. bad |
| 1213 | new_index = 1; // 1st item after SELLIST_START |
| 1214 | } |
| 1215 | |
| 1216 | // select weapon if we can. find a weapon we can select, if we go back to start, return. |
| 1217 | // THIS CODE IS SIMILAR BUT NOT THE SAME AS THE AUTO SELECT CODE. |
| 1218 | int old_index = new_index; |
| 1219 | new_index++; |
| 1220 | |
| 1221 | while (old_index != new_index) { |
| 1222 | if (WPNINDEXcxx . . $ `Descent3/weapon.cpp:1189:9`!(new_index) == SELLIST_ENDcxx . . $ SELLIST_END.) { |
| 1223 | new_index = 0; |
| 1224 | } else if (WPNINDEXcxx . . $ `Descent3/weapon.cpp:1189:9`!(new_index) == SELLIST_STARTcxx . . $ SELLIST_START.) { |
| 1225 | new_index++; |
| 1226 | } else { |
| 1227 | uint16_tcxx . . $ uint16_t# wpn_index = WPNINDEXcxx . . $ `Descent3/weapon.cpp:1189:9`!(new_index); |
| 1228 | otype_wb_infocxx . . $ otype_wb_info# *wb = &ship->static_wbcxx . . $ ship#static_wb.[wpn_index]; |
| 1229 | int slot = (weapon_type == PW_SECONDARYcxx . . $ `Descent3/player_external.h:109:9`!) |
| 1230 | ? (((wpn_index - SECONDARY_INDEXcxx . . $ `Descent3/weapon.h:255:9`!) % NUM_SECONDARY_SLOTScxx . . $ `Descent3/weapon.cpp:877:9`!) + NUM_PRIMARY_SLOTScxx . . $ `Descent3/weapon.cpp:876:9`!) |
| 1231 | : (wpn_index % NUM_PRIMARY_SLOTScxx . . $ `Descent3/weapon.cpp:876:9`!); |
| 1232 | |
| 1233 | // mprintf(0, "wpn_index = %d\n", wpn_index); |
| 1234 | |
| 1235 | if ((Playerscxx . . $ Players.[Player_numcxx . . $ Player_num.].weapon_flagscxx . . $ player#weapon_flags. & HAS_FLAGcxx . . $ `Descent3/weapon.h:215:9`!(wpn_index)) && !(sel_list[new_index] & WPNSEL_SKIPcxx . . $ WPNSEL_SKIP.)) { |
| 1236 | |
| 1237 | if (wpn_index >= SECONDARY_INDEXcxx . . $ `Descent3/weapon.h:255:9`! && wb->ammo_usagecxx . . $ otype_wb_info#ammo_usage. && (wb->ammo_usagecxx . . $ otype_wb_info#ammo_usage. <= plr->weapon_ammocxx . . $ player#weapon_ammo.[wpn_index])) { |
| 1238 | // we've found a weapon to select to that uses ammo! |
| 1239 | (*setwpnfunc)(wpn_index, slot); |
| 1240 | LOGFILEcxx . . $ `Descent3/weapon.cpp:365:9`!((_logfp, "ammo wpn: switch to new index %d\n", wpn_index)); |
| 1241 | break; |
| 1242 | } else if (wpn_index < SECONDARY_INDEXcxx . . $ `Descent3/weapon.h:255:9`! && wb->ammo_usagecxx . . $ otype_wb_info#ammo_usage. && plr->weapon_ammocxx . . $ player#weapon_ammo.[wpn_index]) { |
| 1243 | // we've found a weapon to select to that uses ammo! |
| 1244 | (*setwpnfunc)(wpn_index, slot); |
| 1245 | LOGFILEcxx . . $ `Descent3/weapon.cpp:365:9`!((_logfp, "ammo wpn: switch to new index %d\n", wpn_index)); |
| 1246 | break; |
| 1247 | } else if (!wb->ammo_usagecxx . . $ otype_wb_info#ammo_usage. && (plr->energycxx . . $ player#energy. >= wb->energy_usagecxx . . $ otype_wb_info#energy_usage.)) { |
| 1248 | // we've found an energy weapon to select to! |
| 1249 | (*setwpnfunc)(wpn_index, slot); |
| 1250 | LOGFILEcxx . . $ `Descent3/weapon.cpp:365:9`!((_logfp, "energy wpn:switch to new index %d\n", wpn_index)); |
| 1251 | break; |
| 1252 | } |
| 1253 | } |
| 1254 | |
| 1255 | new_index++; |
| 1256 | // mprintf(0, "new_index = %d\n", new_index); |
| 1257 | } |
| 1258 | } |
| 1259 | |
| 1260 | return sel_list[new_index] & (~WPNSEL_SKIPcxx . . $ WPNSEL_SKIP.); |
| 1261 | } |
| 1262 | |
| 1263 | // Auto selects a weapon, usually the next best weapon. |
| 1264 | // step_up = true if we're going to next higher in order. |
| 1265 | // step_up = false if we're going to next lower in order. |
| 1266 | bool AutoSelectWeaponcxx . . $ AutoSelectWeapon(cf9ef193275fa6d8).(int weapon_type, int new_wpn) { |
| 1267 | playercxx . . $ player# *plr; |
| 1268 | shipcxx . . $ ship# *ship; |
| 1269 | uint16_tcxx . . $ uint16_t# *sel_list; // a weapon selection list |
| 1270 | int weapon_index; // the current weapon index |
| 1271 | int list_index; // index into a selection list |
| 1272 | int list_initial; // initial index in list. |
| 1273 | int slot; |
| 1274 | bool sel_new_wpn = false; |
| 1275 | |
| 1276 | void (*setwpnfunc)(int, int); // Call either primary or secondary set weapon function |
| 1277 | |
| 1278 | LOGFILEcxx . . $ `Descent3/weapon.cpp:365:9`!((_logfp, "Entering AutoSelect\n")); |
| 1279 | |
| 1280 | ASSERTcxx . . $ `misc/pserror.h:246:9`!((weapon_type == PW_PRIMARYcxx . . $ `Descent3/player_external.h:108:9`!) || (weapon_type == PW_SECONDARYcxx . . $ `Descent3/player_external.h:109:9`!)); |
| 1281 | plr = &Playerscxx . . $ Players.[Player_numcxx . . $ Player_num.]; |
| 1282 | weapon_index = plr->weaponcxx . . $ player#weapon.[weapon_type].indexcxx . . $ player_weapon#index.; |
| 1283 | ship = &Shipscxx . . $ Ships.[plr->ship_indexcxx . . $ player#ship_index.]; |
| 1284 | |
| 1285 | // choose primary or secondary list and select function |
| 1286 | sel_list = (weapon_type == PW_SECONDARYcxx . . $ `Descent3/player_external.h:109:9`!) ? SecondaryWpnSelectListcxx . . $ SecondaryWpnSelectList. : PrimaryWpnSelectListcxx . . $ PrimaryWpnSelectList.; |
| 1287 | setwpnfunc = (weapon_type == PW_SECONDARYcxx . . $ `Descent3/player_external.h:109:9`!) ? SetSecondaryWeaponcxx . . $ SetSecondaryWeapon(3e454b8ccf442868). : SetPrimaryWeaponcxx . . $ SetPrimaryWeapon(3e454b8ccf442868).; |
| 1288 | |
| 1289 | list_index = 0; |
| 1290 | list_initial = 0; |
| 1291 | while (WPNINDEXcxx . . $ `Descent3/weapon.cpp:1189:9`!(list_index) != SELLIST_ENDcxx . . $ SELLIST_END.) { |
| 1292 | if (WPNINDEXcxx . . $ `Descent3/weapon.cpp:1189:9`!(list_index) == weapon_index) |
| 1293 | list_initial = list_index; |
| 1294 | list_index++; |
| 1295 | } |
| 1296 | |
| 1297 | list_index--; |
| 1298 | |
| 1299 | // this code takes care of selecting a GIVEN new weapon over the existing. |
| 1300 | if (new_wpn > -1) { |
| 1301 | while (WPNINDEXcxx . . $ `Descent3/weapon.cpp:1189:9`!(list_index) != SELLIST_STARTcxx . . $ SELLIST_START. && WPNINDEXcxx . . $ `Descent3/weapon.cpp:1189:9`!(list_index) != new_wpn) |
| 1302 | list_index--; |
| 1303 | if (!(sel_list[list_index] & WPNSEL_SKIPcxx . . $ WPNSEL_SKIP.)) { |
| 1304 | if (list_initial >= list_index) { |
| 1305 | uint16_tcxx . . $ uint16_t# index = WPNINDEXcxx . . $ `Descent3/weapon.cpp:1189:9`!(list_initial); |
| 1306 | otype_wb_infocxx . . $ otype_wb_info# *wb = &ship->static_wbcxx . . $ ship#static_wb.[index]; |
| 1307 | if (index >= SECONDARY_INDEXcxx . . $ `Descent3/weapon.h:255:9`! && wb->ammo_usagecxx . . $ otype_wb_info#ammo_usage. && (wb->ammo_usagecxx . . $ otype_wb_info#ammo_usage. <= plr->weapon_ammocxx . . $ player#weapon_ammo.[index])) { |
| 1308 | LOGFILEcxx . . $ `Descent3/weapon.cpp:365:9`!((_logfp, "keep current ammo weapon...(ind=%d)\n", list_index)); |
| 1309 | return sel_new_wpn; // the current weapon supercedes the new weapon, (or is the same) so return |
| 1310 | } else if (index < SECONDARY_INDEXcxx . . $ `Descent3/weapon.h:255:9`! && wb->ammo_usagecxx . . $ otype_wb_info#ammo_usage. && plr->weapon_ammocxx . . $ player#weapon_ammo.[index]) { |
| 1311 | LOGFILEcxx . . $ `Descent3/weapon.cpp:365:9`!((_logfp, "keep current ammo weapon...(ind=%d)\n", list_index)); |
| 1312 | return sel_new_wpn; // the current weapon supercedes the new weapon, (or is the same) so return |
| 1313 | } else if (!wb->ammo_usagecxx . . $ otype_wb_info#ammo_usage. && (plr->energycxx . . $ player#energy. >= wb->energy_usagecxx . . $ otype_wb_info#energy_usage.)) { |
| 1314 | LOGFILEcxx . . $ `Descent3/weapon.cpp:365:9`!((_logfp, "keep current energy weapon...(ind=%d)\n", list_index)); |
| 1315 | return sel_new_wpn; // the current weapon supercedes the new weapon, (or is the same) so return |
| 1316 | } |
| 1317 | LOGFILEcxx . . $ `Descent3/weapon.cpp:365:9`!((_logfp, "tried to keep current weapon, but no ammo!...(ind=%d)\n", list_index)); |
| 1318 | } |
| 1319 | } else { |
| 1320 | LOGFILEcxx . . $ `Descent3/weapon.cpp:365:9`!((_logfp, "tried to autoselect skipped weapon, will not do...(ind=%d)\n", list_index)); |
| 1321 | return sel_new_wpn; |
| 1322 | } |
| 1323 | } |
| 1324 | |
| 1325 | while (1) { |
| 1326 | uint16_tcxx . . $ uint16_t# index = sel_list[list_index]; |
| 1327 | otype_wb_infocxx . . $ otype_wb_info# *wb = &ship->static_wbcxx . . $ ship#static_wb.[index]; |
| 1328 | |
| 1329 | if (index == SELLIST_STARTcxx . . $ SELLIST_START.) { |
| 1330 | break; |
| 1331 | } else { |
| 1332 | // we have a real weapon coming up, lets see if we have it, and if we do, then do we have |
| 1333 | // ammo |
| 1334 | if (!(index & WPNSEL_SKIPcxx . . $ WPNSEL_SKIP.)) { |
| 1335 | if (plr->weapon_flagscxx . . $ player#weapon_flags. & HAS_FLAGcxx . . $ `Descent3/weapon.h:215:9`!(index)) { |
| 1336 | slot = (weapon_type == PW_SECONDARYcxx . . $ `Descent3/player_external.h:109:9`!) ? (((index - SECONDARY_INDEXcxx . . $ `Descent3/weapon.h:255:9`!) % NUM_SECONDARY_SLOTScxx . . $ `Descent3/weapon.cpp:877:9`!) + NUM_PRIMARY_SLOTScxx . . $ `Descent3/weapon.cpp:876:9`!) |
| 1337 | : (index % NUM_PRIMARY_SLOTScxx . . $ `Descent3/weapon.cpp:876:9`!); |
| 1338 | if (new_wpn == -1) { |
| 1339 | // if no new weapon, then select to next best weapon that can be used |
| 1340 | if (index >= SECONDARY_INDEXcxx . . $ `Descent3/weapon.h:255:9`! && wb->ammo_usagecxx . . $ otype_wb_info#ammo_usage. && (wb->ammo_usagecxx . . $ otype_wb_info#ammo_usage. <= plr->weapon_ammocxx . . $ player#weapon_ammo.[index])) { |
| 1341 | // we've found a weapon to select to that uses ammo! |
| 1342 | LOGFILEcxx . . $ `Descent3/weapon.cpp:365:9`!((_logfp, "ammo wpn: auto select to new index %d\n", index)); |
| 1343 | (*setwpnfunc)(index, slot); |
| 1344 | break; |
| 1345 | } else if (index <= SECONDARY_INDEXcxx . . $ `Descent3/weapon.h:255:9`! && wb->ammo_usagecxx . . $ otype_wb_info#ammo_usage. && plr->weapon_ammocxx . . $ player#weapon_ammo.[index]) { |
| 1346 | // we've found a weapon to select to that uses ammo! |
| 1347 | LOGFILEcxx . . $ `Descent3/weapon.cpp:365:9`!((_logfp, "ammo wpn: auto select to new index %d\n", index)); |
| 1348 | (*setwpnfunc)(index, slot); |
| 1349 | break; |
| 1350 | } else if (!wb->ammo_usagecxx . . $ otype_wb_info#ammo_usage. && (plr->energycxx . . $ player#energy. >= wb->energy_usagecxx . . $ otype_wb_info#energy_usage.)) { |
| 1351 | // we've found an energy weapon to select to! |
| 1352 | LOGFILEcxx . . $ `Descent3/weapon.cpp:365:9`!((_logfp, "energy wpn: auto select to new index %d\n", index)); |
| 1353 | (*setwpnfunc)(index, slot); |
| 1354 | break; |
| 1355 | } |
| 1356 | } else { |
| 1357 | if (index < SECONDARY_INDEXcxx . . $ `Descent3/weapon.h:255:9`! || !wb->ammo_usagecxx . . $ otype_wb_info#ammo_usage. || |
| 1358 | (index >= SECONDARY_INDEXcxx . . $ `Descent3/weapon.h:255:9`! && wb->ammo_usagecxx . . $ otype_wb_info#ammo_usage. && (wb->ammo_usagecxx . . $ otype_wb_info#ammo_usage. <= plr->weapon_ammocxx . . $ player#weapon_ammo.[index]))) { |
| 1359 | // if new weapon, then always select that weapon (already assumes that new weapon is better.) |
| 1360 | LOGFILEcxx . . $ `Descent3/weapon.cpp:365:9`!((_logfp, "auto select to new index with new weapon!! %d\n", index)); |
| 1361 | (*setwpnfunc)(index, slot); |
| 1362 | sel_new_wpn = true; |
| 1363 | break; |
| 1364 | } |
| 1365 | } |
| 1366 | } |
| 1367 | } |
| 1368 | } |
| 1369 | |
| 1370 | list_index--; |
| 1371 | } |
| 1372 | |
| 1373 | return sel_new_wpn; |
| 1374 | } |
| 1375 | |
| 1376 | // Draws an alpha blended polygon over the entire 3d rendering scene |
| 1377 | // The r,g,b floats specify the color |
| 1378 | void DrawAlphaBlendedScreencxx . . $ DrawAlphaBlendedScreen(7e9a355db6148521).(float r, float g, float b, float alpha) { |
| 1379 | g3Pointcxx . . $ g3Point# *pntlist[4], points[4]; |
| 1380 | ddgr_colorcxx . . $ ddgr_color# color; |
| 1381 | int i; |
| 1382 | |
| 1383 | color = GR_RGBcxx . . $ GR_RGB(530956271a9518a5).(r * 255, g * 255, b * 255); |
| 1384 | |
| 1385 | // Set our four corners to cover the screen |
| 1386 | points[0].p3_sxcxx . . $ g3Point#p3_sx. = 0; |
| 1387 | points[0].p3_sycxx . . $ g3Point#p3_sy. = 0; |
| 1388 | points[1].p3_sxcxx . . $ g3Point#p3_sx. = Game_window_wcxx . . $ Game_window_w.; |
| 1389 | points[1].p3_sycxx . . $ g3Point#p3_sy. = 0; |
| 1390 | points[2].p3_sxcxx . . $ g3Point#p3_sx. = Game_window_wcxx . . $ Game_window_w.; |
| 1391 | points[2].p3_sycxx . . $ g3Point#p3_sy. = Game_window_hcxx . . $ Game_window_h.; |
| 1392 | points[3].p3_sxcxx . . $ g3Point#p3_sx. = 0; |
| 1393 | points[3].p3_sycxx . . $ g3Point#p3_sy. = Game_window_hcxx . . $ Game_window_h.; |
| 1394 | |
| 1395 | for (i = 0; i < 4; i++) { |
| 1396 | points[i].p3_zcxx . . $ `lib/3d.h:247:9`! = 0; |
| 1397 | points[i].p3_flagscxx . . $ g3Point#p3_flags. = PF_PROJECTEDcxx . . $ `lib/3d.h:214:9`!; |
| 1398 | pntlist[i] = &points[i]; |
| 1399 | } |
| 1400 | |
| 1401 | rend_SetZBufferStatecxx . . $ rend_SetZBufferState(4af4fd0e2b26c4ac).(0); |
| 1402 | rend_SetTextureTypecxx . . $ rend_SetTextureType(cccd9781d96f97ff).(TT_FLATcxx . . $ TT_FLAT.); |
| 1403 | rend_SetAlphaTypecxx . . $ rend_SetAlphaType(4af4fd0e2b26c4ac).(AT_CONSTANTcxx . . $ `lib/renderer.h:400:9`!); |
| 1404 | rend_SetAlphaValuecxx . . $ rend_SetAlphaValue(ac50b47256ae7414).(alpha * 255); |
| 1405 | rend_SetLightingcxx . . $ rend_SetLighting(e55526c9d3dd1656).(LS_NONEcxx . . $ LS_NONE.); |
| 1406 | rend_SetFlatColorcxx . . $ rend_SetFlatColor(cb2f890c2fdad230).(color); |
| 1407 | |
| 1408 | rend_DrawPolygon2Dcxx . . $ rend_DrawPolygon2D(1464bdba6025a51).(0, pntlist, 4); |
| 1409 | rend_SetZBufferStatecxx . . $ rend_SetZBufferState(4af4fd0e2b26c4ac).(1); |
| 1410 | } |
| 1411 | |
| 1412 | // Retreives the weapon in the weapon array based off of an 'index' from 0-19 (non-mapped |
| 1413 | // primary and secondaries) |
| 1414 | weaponcxx . . $ weapon# *GetWeaponFromIndexcxx . . $ GetWeaponFromIndex(8877214bf23c386e).(int player, int index) { |
| 1415 | shipcxx . . $ ship# *ship = &Shipscxx . . $ Ships.[Playerscxx . . $ Players.[player].ship_indexcxx . . $ player#ship_index.]; |
| 1416 | otype_wb_infocxx . . $ otype_wb_info# *wb = &ship->static_wbcxx . . $ ship#static_wb.[index]; |
| 1417 | objectcxx . . $ object# *pobj = &Objectscxx . . $ Objects.[Playerscxx . . $ Players.[player].objnumcxx . . $ player#objnum.]; |
| 1418 | poly_modelcxx . . $ poly_model# *pm = &Poly_modelscxx . . $ Poly_models.[pobj->rtypecxx . . $ object#rtype..pobj_infocxx . . $ object#$anonymous_type_10#pobj_info..model_numcxx . . $ polyobj_info#model_num.]; |
| 1419 | dynamic_wb_infocxx . . $ dynamic_wb_info# *dyn_wb = &pobj->dynamic_wbcxx . . $ object#dynamic_wb.[index]; |
| 1420 | int cur_m_bit; |
| 1421 | |
| 1422 | for (cur_m_bit = 0; cur_m_bit < pm->poly_wbcxx . . $ poly_model#poly_wb.[0].num_gpscxx . . $ poly_wb_info#num_gps.; cur_m_bit++) { |
| 1423 | if (wb->gp_fire_maskscxx . . $ otype_wb_info#gp_fire_masks.[dyn_wb->cur_firing_maskcxx . . $ dynamic_wb_info#cur_firing_mask.] & (0x01 << cur_m_bit)) { |
| 1424 | return &Weaponscxx . . $ Weapons.[wb->gp_weapon_indexcxx . . $ otype_wb_info#gp_weapon_index.[cur_m_bit]]; |
| 1425 | } |
| 1426 | } |
| 1427 | |
| 1428 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 1429 | } |