| 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/damage.cpp $ |
| 21 | * $Revision: 164 $ |
| 22 | * $Date: 3/22/00 12:13p $ |
| 23 | * $Author: Matt $ |
| 24 | * |
| 25 | * Applies and handles damage to game entities. |
| 26 | * |
| 27 | * $Log: /DescentIII/main/damage.cpp $ |
| 28 | * |
| 29 | * 164 3/22/00 12:13p Matt |
| 30 | * Added some if statements to not damage & kill objects when playing back |
| 31 | * a demo. |
| 32 | * |
| 33 | * 163 1/26/00 9:19p Jeff |
| 34 | * added support for IntelliVIBE DLL |
| 35 | * |
| 36 | * 162 10/21/99 2:44p Matt |
| 37 | * Mac merge |
| 38 | * |
| 39 | * 161 10/08/99 4:54p Nate |
| 40 | * Fixed bug that prevented custom damage modification from working |
| 41 | * |
| 42 | * 160 10/08/99 4:28p Chris |
| 43 | * Added the forcefield and glass breaking override options |
| 44 | * |
| 45 | * 159 9/22/99 11:58a Jeff |
| 46 | * always call the multiplayer event when player shields change and then |
| 47 | * check to see if the player should be killed |
| 48 | * |
| 49 | * 158 7/26/99 11:07a Jason |
| 50 | * fixed broke glass bug |
| 51 | * |
| 52 | * 157 5/22/99 10:27p Jason |
| 53 | * changes for multiplayer and buildings, ai |
| 54 | * |
| 55 | * 156 5/21/99 4:30a Matt |
| 56 | * Added commented-out code to play sound for sparking death, in case we |
| 57 | * ever get a sound we like. |
| 58 | * |
| 59 | * 155 5/17/99 9:23p Matt |
| 60 | * When applying damage to player, only play invulnerability sound if |
| 61 | * would otherwise be playing a sound. |
| 62 | * |
| 63 | * 154 5/09/99 10:50p Jason |
| 64 | * made napalm rocket burn people longer |
| 65 | * |
| 66 | * 153 5/04/99 6:53p Jeff |
| 67 | * added event for when a player dies |
| 68 | * |
| 69 | * 152 4/30/99 2:32p Matt |
| 70 | * Doubled the velocity of straight-up flying deaths to make Josh's pop |
| 71 | * machines cooler. |
| 72 | * |
| 73 | * 151 4/30/99 3:28a Chris |
| 74 | * Flares disappear when they hit bad surfaces (volatile and lava) |
| 75 | * |
| 76 | * 150 4/29/99 6:48p Matt |
| 77 | * Made volatile surfaces apply damage and lava surfaces catch the player |
| 78 | * on fire. Both now generate the steam puff effect. |
| 79 | * |
| 80 | * 149 4/28/99 4:48a Chris |
| 81 | * Added the no-scale damage by diff checkbox |
| 82 | * |
| 83 | * 148 4/27/99 12:12a Matt |
| 84 | * Added option to make object not tumble in flying death |
| 85 | * |
| 86 | * 147 4/26/99 7:07p Jason |
| 87 | * fixed multiplayer bug with destroy object |
| 88 | * |
| 89 | * 146 4/26/99 6:23p Jeff |
| 90 | * don't apply damage to OBJ_DUMMYs! (It cause problems in multiplayer |
| 91 | * with the guidebot) |
| 92 | * |
| 93 | * 145 4/25/99 10:38p Matt |
| 94 | * Made the Osiris kill object function work on players. |
| 95 | * |
| 96 | * 144 4/25/99 10:19p Matt |
| 97 | * Fixed multiplayer and demo problems will killing an object from script, |
| 98 | * and cleaned up the death code a bit in the process. |
| 99 | * |
| 100 | * 143 4/24/99 11:38p Matt |
| 101 | * Set the death delay for electrical deaths on default-death objects. |
| 102 | * This has apparently been broken since I rewrote the death system ages |
| 103 | * ago, but no one reported it. |
| 104 | * |
| 105 | * 142 4/24/99 4:32p Jason |
| 106 | * made fusion damage sound not be irritating |
| 107 | * |
| 108 | * 141 4/23/99 12:32a Matt |
| 109 | * Added a death info option to play the explosion sound at the start of |
| 110 | * the delay, instead of at the end when the object actually dies. |
| 111 | * |
| 112 | * 140 4/22/99 4:15p Matt |
| 113 | * Don't bash the delay time when setting the flying physics for dying |
| 114 | * objects. For default deaths, this was already set to the same values |
| 115 | * when setting up the death, and for explicit deaths, use the value from |
| 116 | * the page. |
| 117 | * |
| 118 | * 139 4/21/99 3:01p Matt |
| 119 | * Added a new type for dying objects that have AI, instead of keeping a |
| 120 | * flag in the dying info. |
| 121 | * |
| 122 | * 138 4/21/99 12:40p Jason |
| 123 | * made explosion system framerate independant |
| 124 | * |
| 125 | * 137 4/21/99 12:22p Matt |
| 126 | * Added extra time to delay-from-anim time to allow object to finish its |
| 127 | * current anim before starting the death anim. |
| 128 | * |
| 129 | * 136 4/21/99 11:05a Kevin |
| 130 | * new ps_rand and ps_srand to replace rand & srand |
| 131 | * |
| 132 | * 135 4/14/99 2:50a Jeff |
| 133 | * fixed some case mismatched #includes |
| 134 | * |
| 135 | * 134 4/12/99 6:15p Samir |
| 136 | * Sound priorities pass 1 |
| 137 | * |
| 138 | * 133 4/10/99 6:32p Matt |
| 139 | * Don't allow glass to be broken twice. |
| 140 | * |
| 141 | * 132 4/06/99 6:24p Jason |
| 142 | * various fixes for multiplayer |
| 143 | * |
| 144 | * 131 4/06/99 6:02p Matt |
| 145 | * Added score system |
| 146 | * |
| 147 | * 130 4/02/99 11:23a Matt |
| 148 | * Made KillObject not take a death_info struct, but rather the death info |
| 149 | * as individual parameters. Moved death_info into objinfo.h, since it's |
| 150 | * only used for generic objects. Took out fade-away death hack, now that |
| 151 | * fade-away deaths can be explicitely set. |
| 152 | * |
| 153 | * 129 4/01/99 4:28p Matt |
| 154 | * Cleaned up handling of dying flag to prevent infinite recursion. Jeff |
| 155 | * will test. |
| 156 | * |
| 157 | * 128 3/29/99 11:20a Matt |
| 158 | * Added more flexibility to death delays, and added fade away deaths. |
| 159 | * |
| 160 | * 127 3/22/99 1:47p Matt |
| 161 | * Moved breaking glass code from collide.cpp to damage.cpp |
| 162 | * |
| 163 | * 126 3/08/99 5:10p Chris |
| 164 | * Make upsidedown robots fall faster (use the loss anti-grav flag) |
| 165 | * |
| 166 | * 125 3/05/99 6:41p Matt |
| 167 | * In default death, instead of adding 3 second to delay time, calculate |
| 168 | * the time remaining the robot's current animation and add that. |
| 169 | * |
| 170 | * 124 3/05/99 3:32p Matt |
| 171 | * Added hack for making nomads fade out |
| 172 | * |
| 173 | * 123 3/05/99 11:30a Kevin |
| 174 | * Fixed really stupid bug |
| 175 | * |
| 176 | * 122 3/03/99 5:41p Matt |
| 177 | * Don't scale applied damage if damage type is GD_SCRIPTED |
| 178 | * |
| 179 | * 121 2/28/99 6:20p Matt |
| 180 | * Added the ability to set death types for generic objects. |
| 181 | * |
| 182 | * 120 2/26/99 2:03p Matt |
| 183 | * Got blastable doors working, and cleaned up concussive force code. |
| 184 | * |
| 185 | * 119 2/25/99 10:58a Matt |
| 186 | * Added new explosion system. |
| 187 | * |
| 188 | * 118 2/22/99 2:03p Jason |
| 189 | * added different damages for players and generics |
| 190 | * |
| 191 | * 117 2/13/99 6:16p Jeff |
| 192 | * fixed ApplyDamageTo functions so they only damage what objects they are |
| 193 | * supposed to |
| 194 | * |
| 195 | * 116 2/13/99 12:29a Jeff |
| 196 | * don't apply damage to OBJ_DUMMYs |
| 197 | * |
| 198 | * 115 2/10/99 1:47p Matt |
| 199 | * Changed object handle symbolic constants |
| 200 | * |
| 201 | * 114 2/08/99 5:17p Jason |
| 202 | * took out EMD effect and added more weapon options |
| 203 | * |
| 204 | * 113 2/07/99 1:19a Jeff |
| 205 | * added new multiplayer game events EVT_GAMEOBJKILLED and |
| 206 | * EVT_GAMEOBJDESTROYED |
| 207 | * |
| 208 | * 112 2/04/99 2:05p Matt |
| 209 | * Added blastable doors |
| 210 | * |
| 211 | * 111 2/04/99 11:36a Jason |
| 212 | * fixed some multi bugs |
| 213 | * |
| 214 | * 110 2/03/99 12:15p Jason |
| 215 | * added multiplayer vis optimizations |
| 216 | * |
| 217 | * 109 2/02/99 8:43a Chris |
| 218 | * I made buildings with AI work correctly (ie really big robots should be |
| 219 | * buildings) |
| 220 | * anim to and from states are now shorts instead of bytes |
| 221 | * |
| 222 | * 108 2/01/99 4:25p Jeff |
| 223 | * fixed player invulnerabilty after cinematic sequence and death bug |
| 224 | * |
| 225 | * 107 2/01/99 12:55p Jeff |
| 226 | * don't damage player if OF_DESTROYABLE is not set |
| 227 | * |
| 228 | * 106 1/28/99 12:09p Jeff |
| 229 | * added force feedback to player shake...fixed spelling error in define |
| 230 | * for forcefeedback |
| 231 | * |
| 232 | * 105 1/20/99 12:31p Chris |
| 233 | * Include the weapon_handle in evt_damage |
| 234 | * |
| 235 | * 104 1/20/99 2:13a Chris |
| 236 | * It is now possible for robots to have special immunities, resistances, |
| 237 | * and vunerabilities |
| 238 | * |
| 239 | * 103 1/18/99 2:46p Matt |
| 240 | * Combined flags & flags2 fields in object struct |
| 241 | * |
| 242 | * 102 1/17/99 7:20p Jeff |
| 243 | * doh! put back in call to multiplayer event on object damage |
| 244 | * |
| 245 | * 101 1/15/99 3:49a Jeff |
| 246 | * removed calls to multiplayer dll events (EVT_DAMAGED) |
| 247 | * |
| 248 | * 100 1/13/99 2:42p Jason |
| 249 | * added damage event |
| 250 | * |
| 251 | * 99 1/13/99 2:28a Chris |
| 252 | * Massive AI, OSIRIS update |
| 253 | * |
| 254 | * 98 1/08/99 2:55p Samir |
| 255 | * Ripped out OSIRIS1. |
| 256 | * |
| 257 | * 97 1/06/99 3:07p Jason |
| 258 | * toned down redness |
| 259 | * |
| 260 | * 96 12/13/98 7:47p Chris |
| 261 | * Make walkers die slowly more often |
| 262 | * |
| 263 | * 95 12/07/98 2:26p Jason |
| 264 | * fixed a bug with peer to peer damage on the client end |
| 265 | * |
| 266 | * 94 12/04/98 3:03p Jason |
| 267 | * |
| 268 | * 93 12/04/98 1:41p Jason |
| 269 | * made napalm do even less damage |
| 270 | * |
| 271 | * 92 12/03/98 3:39p Jason |
| 272 | * added peer 2 peer style damage |
| 273 | * |
| 274 | * 91 12/02/98 10:30a Jason |
| 275 | * added additional damage types for client-side multiplayer |
| 276 | * |
| 277 | * 90 12/01/98 10:57a Jason |
| 278 | * fixed compiler warning |
| 279 | * |
| 280 | * 89 11/19/98 5:40p Kevin |
| 281 | * Demo system |
| 282 | * |
| 283 | * 88 11/19/98 12:22p Jason |
| 284 | * optimizations |
| 285 | * |
| 286 | * 87 11/13/98 2:25p Samir |
| 287 | * modify game music info when damaged or killed robot |
| 288 | * |
| 289 | * 86 11/13/98 12:29p Jason |
| 290 | * changes for weapons |
| 291 | * |
| 292 | * 85 11/11/98 2:46p Kevin |
| 293 | * Demo recording system work |
| 294 | * |
| 295 | * 84 11/11/98 11:41a Jason |
| 296 | * added sunlight damage |
| 297 | * |
| 298 | * 83 11/10/98 3:12p Chris |
| 299 | * Got rid of a const double to float warning |
| 300 | * |
| 301 | * 82 10/30/98 4:24p Jason |
| 302 | * changes for multiplayer |
| 303 | * |
| 304 | * 81 10/22/98 2:58p Chris |
| 305 | * Difficulty levels are in beta |
| 306 | * |
| 307 | * 80 10/22/98 10:50a Samir |
| 308 | * only register kill for robots so accuracy rating can be closer. |
| 309 | * |
| 310 | * 79 10/19/98 7:17p Matt |
| 311 | * Added system to support different types of damage to the player and |
| 312 | * have these different types make different sounds. |
| 313 | * |
| 314 | * 78 10/14/98 1:02p Jason |
| 315 | * fixed FindSoundName issues |
| 316 | * |
| 317 | * 77 10/06/98 11:27a Jason |
| 318 | * added new death type for robots |
| 319 | * |
| 320 | * 76 9/30/98 5:35p Jason |
| 321 | * added multiplayer menu bailing for samir |
| 322 | * |
| 323 | * 75 9/25/98 5:02p Jason |
| 324 | * fixed parenting problems |
| 325 | * |
| 326 | * 74 9/17/98 6:08p Jason |
| 327 | * more tweaks for effects |
| 328 | * |
| 329 | * 73 9/17/98 3:03p Jason |
| 330 | * added lightning and invul hit effects |
| 331 | * |
| 332 | * 72 9/14/98 4:17p Jason |
| 333 | * added friendly fire damage |
| 334 | * |
| 335 | * 71 8/14/98 6:26p Kevin |
| 336 | * for chris: dealt with killer==NULL in ExplodeObject |
| 337 | * |
| 338 | * 70 8/14/98 4:58p Jeff |
| 339 | * only if damage>0 does it play sound |
| 340 | * |
| 341 | * 69 8/14/98 12:49p Chris |
| 342 | * Working on attach system |
| 343 | * |
| 344 | * 68 8/12/98 12:04p Chris |
| 345 | * Attach system version .5 (still needs more work to be multiplayer |
| 346 | * friendly) |
| 347 | * |
| 348 | * 67 8/10/98 5:24p Jason |
| 349 | * made robots have a little variation when dying |
| 350 | * |
| 351 | * 66 8/03/98 5:56p Jason |
| 352 | * got fusion cannon working correctly |
| 353 | * |
| 354 | * 65 7/31/98 5:23p Jason |
| 355 | * added ship armor scalars |
| 356 | * |
| 357 | * 64 7/30/98 11:09a Jason |
| 358 | * added weapons that freeze and deform terrain |
| 359 | * |
| 360 | * 63 7/21/98 12:13p Jason |
| 361 | * Told DLL about which weapon was used to kill a player |
| 362 | * |
| 363 | * 62 7/15/98 2:33p Jason |
| 364 | * added scalar variables for various player skills |
| 365 | * |
| 366 | * 61 7/15/98 12:48p Jeff |
| 367 | * put in calls to handle new multiplayer event...when an object's shields |
| 368 | * change |
| 369 | * |
| 370 | * 60 6/30/98 11:39a Jason |
| 371 | * added AdditionalDamage packet type for multiplayer |
| 372 | * |
| 373 | * 59 6/29/98 12:12p Kevin |
| 374 | * Added robot damage and death packets |
| 375 | * |
| 376 | * 58 6/26/98 7:26p Jason |
| 377 | * checked in so kevin can work on coop |
| 378 | * |
| 379 | * 57 6/26/98 2:14p Jason |
| 380 | * fixed InitiatePlayerDeath bug with dead robots |
| 381 | * |
| 382 | * 56 6/02/98 6:04p Jason |
| 383 | * undid pre-e3 invul change |
| 384 | * |
| 385 | * 55 5/25/98 6:38p Matt |
| 386 | * Added needed include. |
| 387 | * |
| 388 | * 54 5/25/98 4:16p Jason |
| 389 | * made invulnerability different for E3 demo |
| 390 | * |
| 391 | * 53 5/22/98 6:22p Chris |
| 392 | * Improved Dynamic path allocation |
| 393 | * |
| 394 | * 52 5/19/98 2:41a Chris |
| 395 | * Added shockwave's -- enjoy. :) |
| 396 | * |
| 397 | * 51 5/04/98 4:04p Chris |
| 398 | * Minestone checkin' -- energy effect and more AI functionality |
| 399 | * |
| 400 | * 50 5/04/98 12:55p Jason |
| 401 | * fixed NULL pointer bug |
| 402 | * |
| 403 | * 49 5/01/98 6:50p Samir |
| 404 | * call initiate player death with melee if killed by robot. |
| 405 | * |
| 406 | * 48 5/01/98 3:41p Chris |
| 407 | * |
| 408 | * 47 5/31/98 3:07p Chris |
| 409 | * Robots die slowly more often. Made robots die slowly when the killer |
| 410 | * object is a |
| 411 | * player or robot. (Melee attacks and bumping damage deaths) |
| 412 | * |
| 413 | * 46 4/19/98 5:00p Jason |
| 414 | * added cool napalm effect, plus made object effects dynamically |
| 415 | * allocated |
| 416 | * |
| 417 | * 45 4/17/98 3:57p Jason |
| 418 | * added microwave effect |
| 419 | * |
| 420 | * 44 4/17/98 1:59p Jason |
| 421 | * added cool object effects |
| 422 | * |
| 423 | * 43 4/10/98 3:28p Jason |
| 424 | * Turn off guided missile when you get hit |
| 425 | * |
| 426 | * 42 4/09/98 5:17p Jason |
| 427 | * got guided working in multiplayer |
| 428 | * |
| 429 | * 41 4/06/98 4:05p Jason |
| 430 | * made suicides work correctly |
| 431 | * |
| 432 | * 40 4/06/98 2:54p Jason |
| 433 | * yet more multiplayer changes |
| 434 | * |
| 435 | * 39 4/06/98 12:14p Jason |
| 436 | * changes to multiplayer |
| 437 | * |
| 438 | * 38 3/31/98 12:16p Jason |
| 439 | * some small changes for explosions |
| 440 | * |
| 441 | * 37 3/30/98 5:11p Jason |
| 442 | * more changes for game/dll integration |
| 443 | * |
| 444 | * 36 3/23/98 4:51p Jason |
| 445 | * incremental checkin for multiplay |
| 446 | * |
| 447 | * 35 3/23/98 4:36p Jason |
| 448 | * make powerups non-destroyable in multiplay |
| 449 | * |
| 450 | * 34 3/12/98 7:30p Chris |
| 451 | * Added ObjSetOrient |
| 452 | * |
| 453 | * 33 2/25/98 4:31p Jason |
| 454 | * changes for explosions |
| 455 | * |
| 456 | * 32 2/18/98 4:12a Jason |
| 457 | * took out ridiculous explosions |
| 458 | * |
| 459 | * 31 2/16/98 11:19p Chris |
| 460 | * Added support for melee robots |
| 461 | * |
| 462 | * 30 2/16/98 4:55p Chris |
| 463 | * Added default sounds for explosions |
| 464 | * |
| 465 | * 29 2/10/98 11:32a Samir |
| 466 | * Added D3X support when a player gets killed to the gamemode script. |
| 467 | * |
| 468 | * 28 2/09/98 5:38p Jeff |
| 469 | * changed EVT_PLAYERKILLED to EVT_GAMEPLAYERKILLED for osiris |
| 470 | * |
| 471 | * 27 2/05/98 2:54p Jason |
| 472 | * changes for explosions |
| 473 | * |
| 474 | * 26 2/04/98 9:28p Jason |
| 475 | * added some new weapons effects |
| 476 | * |
| 477 | * 25 2/04/98 6:09p Matt |
| 478 | * Changed object room number to indicate a terrain cell via a flag. Got |
| 479 | * rid of the object flag which used to indicate terrain. |
| 480 | * |
| 481 | * 24 2/03/98 4:04p Jeff |
| 482 | * added OSIRIS events for player killed and exploded |
| 483 | * |
| 484 | * 23 1/28/98 1:11p Jason |
| 485 | * took shields field out of Player struct |
| 486 | * |
| 487 | * 22 1/28/98 12:00p Jason |
| 488 | * more changes for multiplayer |
| 489 | * |
| 490 | * 21 1/21/98 6:09p Jason |
| 491 | * Got player deaths working in multiplayer |
| 492 | * |
| 493 | * 20 1/21/98 1:11p Jason |
| 494 | * incremental checkin for multiplayer |
| 495 | * |
| 496 | * 19 1/20/98 6:01p Jason |
| 497 | * first pass at getting multiplayer deaths working |
| 498 | * |
| 499 | * 18 1/19/98 6:23p Chris |
| 500 | * Fixed a crash when the killer is no longer alive. |
| 501 | * |
| 502 | * 17 1/19/98 10:04a Matt |
| 503 | * Added new object handle system |
| 504 | * |
| 505 | * 16 1/15/98 6:49p Jason |
| 506 | * incremental checkin for multiplayer |
| 507 | * |
| 508 | * 15 1/05/98 3:54p Chris |
| 509 | * Added ambient and explosion sounds |
| 510 | * |
| 511 | * 14 1/05/98 11:02a Jason |
| 512 | * made shake magnitude proportional to the distance from the explosion |
| 513 | * |
| 514 | * |
| 515 | * 13 12/12/97 6:13p Jason |
| 516 | * added sparks |
| 517 | * |
| 518 | * 12 12/08/97 5:21p Jason |
| 519 | * added code for destroyable buildings that leave their base object |
| 520 | * around |
| 521 | * |
| 522 | * 11 12/08/97 3:28p Jason |
| 523 | * tweaked explosions |
| 524 | * |
| 525 | * 10 12/03/97 5:53p Jason |
| 526 | * worked on cooler explosion effects |
| 527 | * |
| 528 | * 9 12/01/97 11:02a Jason |
| 529 | * made camera shake from explosions |
| 530 | * |
| 531 | * 8 12/01/97 9:50a Chris |
| 532 | * Added support for concussive forces, generalized robot collisions to |
| 533 | * generic collisions |
| 534 | * |
| 535 | * 7 11/18/97 4:37p Jason |
| 536 | * added visible damage system |
| 537 | * |
| 538 | * 6 11/04/97 5:50p Jason |
| 539 | * made #define for strange number (.6) |
| 540 | * |
| 541 | * 5 10/24/97 2:47p Jason |
| 542 | * added blast rings to robots |
| 543 | * |
| 544 | * 4 10/20/97 4:46p Jason |
| 545 | * changes for explosions |
| 546 | * |
| 547 | * 3 10/08/97 6:35p Samir |
| 548 | * Dying player ships get marked as destroyed. When death sequence is |
| 549 | * over, they are marked as dead. This is needed to better control |
| 550 | * movement of the dying ship. |
| 551 | * |
| 552 | * 2 10/03/97 11:58a Samir |
| 553 | * Added mission name |
| 554 | * |
| 555 | * 1 10/01/97 4:50p Samir |
| 556 | * Damage for players and robots. |
| 557 | * |
| 558 | * $NoKeywords: $ |
| 559 | */ |
| 560 | |
| 561 | #include <stdlib.h> |
| 562 | #include <memory.h> |
| 563 | #include "damage.h"cxx . . $ `<file>/Descent3/damage.h`/ |
| 564 | #include "object.h"cxx . . $ `<file>/Descent3/object.h`/ |
| 565 | #include "objinfo.h"cxx . . $ `<file>/Descent3/objinfo.h`/ |
| 566 | #include "player.h"cxx . . $ `<file>/Descent3/player.h`/ |
| 567 | #include "fireball.h"cxx . . $ `<file>/Descent3/fireball.h`/ |
| 568 | #include "gameevent.h"cxx . . $ `<file>/Descent3/gameevent.h`/ |
| 569 | #include "hlsoundlib.h"cxx . . $ `<file>/sndlib/hlsoundlib.h`/ |
| 570 | #include "multi.h"cxx . . $ `<file>/Descent3/multi.h`/ |
| 571 | #include "game.h"cxx . . $ `<file>/Descent3/game.h`/ |
| 572 | #include "sounds.h"cxx . . $ `<file>/Descent3/sounds.h`/ |
| 573 | #include "soundload.h"cxx . . $ `<file>/sndlib/soundload.h`/ |
| 574 | #include "game2dll.h"cxx . . $ `<file>/lib/game2dll.h`/ |
| 575 | #include "weapon.h"cxx . . $ `<file>/Descent3/weapon.h`/ |
| 576 | #include "ship.h"cxx . . $ `<file>/Descent3/ship.h`/ |
| 577 | #include "attach.h"cxx . . $ `<file>/Descent3/attach.h`/ |
| 578 | #include "difficulty.h"cxx . . $ `<file>/Descent3/difficulty.h`/ |
| 579 | #include "demofile.h"cxx . . $ `<file>/lib/demofile.h`/ |
| 580 | #include "d3music.h"cxx . . $ `<file>/Descent3/d3music.h`/ |
| 581 | #include "osiris_dll.h"cxx . . $ `<file>/Descent3/osiris_dll.h`/ |
| 582 | #include "D3ForceFeedback.h"cxx . . $ `<file>/Descent3/D3ForceFeedback.h`/ |
| 583 | #include "multi_server.h"cxx . . $ `<file>/Descent3/multi_server.h`/ |
| 584 | #include "doorway.h"cxx . . $ `<file>/Descent3/doorway.h`/ |
| 585 | #include "DeathInfo.h"cxx . . $ `<file>/Descent3/DeathInfo.h`/ |
| 586 | #include "AIGoal.h"cxx . . $ `<file>/Descent3/AIGoal.h`/ |
| 587 | #include "viseffect.h"cxx . . $ `<file>/Descent3/viseffect.h`/ |
| 588 | #include "psrand.h"cxx . . $ `<file>/misc/psrand.h`/ |
| 589 | |
| 590 | #include <algorithm> |
| 591 | |
| 592 | static void SetDeformDamageEffectcxx . . $ SetDeformDamageEffect(419c470199a90a97).(objectcxx . . $ object# *obj); |
| 593 | static void ApplyFreezeDamageEffectcxx . . $ ApplyFreezeDamageEffect(419c470199a90a97).(objectcxx . . $ object# *obj); |
| 594 | static void DecreasePlayerShieldscxx . . $ DecreasePlayerShields(43c79ee2f1b9aefe).(int slot, float damage); |
| 595 | static void DoEDrainEffectcxx . . $ DoEDrainEffect(6ca3d68f5c5f0975).(int eventnum, void *data); |
| 596 | static void PlayPlayerDamageSoundcxx . . $ PlayPlayerDamageSound(766a1b7183ffa4b4).(objectcxx . . $ object# *playerobj, int damage_type); |
| 597 | static void GenerateDefaultDeathcxx . . $ GenerateDefaultDeath(e3e8a27ff878be74).(objectcxx . . $ object# *obj, int *death_flags, float *delay_time); |
| 598 | static void PlayPlayerInvulnerabilitySoundcxx . . $ PlayPlayerInvulnerabilitySound(419c470199a90a97).(objectcxx . . $ object# *playerobj); |
| 599 | static void SetFlyingPhysicscxx . . $ SetFlyingPhysics(674fac047436fc5b).(objectcxx . . $ object# *objp, bool tumbles); |
| 600 | static float GetDeathAnimTimecxx . . $ GetDeathAnimTime(9e89091ee687c4f3).(objectcxx . . $ object# *objp); |
| 601 | static void SetFallingPhysicscxx . . $ SetFallingPhysics(419c470199a90a97).(objectcxx . . $ object# *objp); |
| 602 | |
| 603 | // Shake variables |
| 604 | static matrixcxx . . $ matrix# Old_player_orientcxx . . $ Old_player_orient.; |
| 605 | float Shake_magnitudecxx . . $ Shake_magnitude. = 0.0; |
| 606 | |
| 607 | // Causes an object to deform |
| 608 | void SetDeformDamageEffectcxx . . $ SetDeformDamageEffect(419c470199a90a97).(objectcxx . . $ object# *obj) { |
| 609 | if (obj->effect_infocxx . . $ object#effect_info.) { |
| 610 | obj->effect_infocxx . . $ object#effect_info.->type_flagscxx . . $ effect_info_s#type_flags. |= EF_DEFORMcxx . . $ `Descent3/object_external.h:198:9`!; |
| 611 | obj->effect_infocxx . . $ object#effect_info.->deform_timecxx . . $ effect_info_s#deform_time. = 1.0; |
| 612 | obj->effect_infocxx . . $ object#effect_info.->deform_rangecxx . . $ effect_info_s#deform_range. = .3f; |
| 613 | } |
| 614 | } |
| 615 | |
| 616 | #define MAX_NAPALM_DAMAGE_TIMEcxx . . $ `Descent3/damage.cpp:616:9`! 10.0f |
| 617 | // Causes an object to have napalm attached to it |
| 618 | void SetNapalmDamageEffectcxx . . $ SetNapalmDamageEffect(6964148eab73f28a).(objectcxx . . $ object# *obj, objectcxx . . $ object# *killer, int weapon_id) { |
| 619 | if (obj->effect_infocxx . . $ object#effect_info.) { |
| 620 | obj->effect_infocxx . . $ object#effect_info.->type_flagscxx . . $ effect_info_s#type_flags. |= EF_NAPALMEDcxx . . $ `Descent3/object_external.h:200:9`!; |
| 621 | |
| 622 | if (Weaponscxx . . $ Weapons.[weapon_id].flagscxx . . $ weapon#flags. & WF_INVISIBLEcxx . . $ `Descent3/weapon.h:226:9`!) |
| 623 | obj->effect_infocxx . . $ object#effect_info.->damage_timecxx . . $ effect_info_s#damage_time. += (MAX_NAPALM_DAMAGE_TIMEcxx . . $ `Descent3/damage.cpp:616:9`! / 5.0f); |
| 624 | else |
| 625 | obj->effect_infocxx . . $ object#effect_info.->damage_timecxx . . $ effect_info_s#damage_time. += (MAX_NAPALM_DAMAGE_TIMEcxx . . $ `Descent3/damage.cpp:616:9`! / 1.5f); |
| 626 | |
| 627 | obj->effect_infocxx . . $ object#effect_info.->damage_timecxx . . $ effect_info_s#damage_time. = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(MAX_NAPALM_DAMAGE_TIMEcxx . . $ `Descent3/damage.cpp:616:9`!, obj->effect_infocxx . . $ object#effect_info.->damage_timecxx . . $ effect_info_s#damage_time.); |
| 628 | |
| 629 | if (obj->typecxx . . $ object#type. == OBJ_PLAYERcxx . . $ `Descent3/object_external.h:164:9`!) |
| 630 | obj->effect_infocxx . . $ object#effect_info.->damage_per_secondcxx . . $ effect_info_s#damage_per_second. = Weaponscxx . . $ Weapons.[weapon_id].player_damagecxx . . $ weapon#player_damage.; |
| 631 | else |
| 632 | obj->effect_infocxx . . $ object#effect_info.->damage_per_secondcxx . . $ effect_info_s#damage_per_second. = Weaponscxx . . $ Weapons.[weapon_id].generic_damagecxx . . $ weapon#generic_damage.; |
| 633 | |
| 634 | if (Gametimecxx . . $ Gametime. - obj->effect_infocxx . . $ object#effect_info.->last_damage_timecxx . . $ effect_info_s#last_damage_time. > 1.0f) |
| 635 | obj->effect_infocxx . . $ object#effect_info.->last_damage_timecxx . . $ effect_info_s#last_damage_time. = 0; |
| 636 | |
| 637 | if (killer != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!) |
| 638 | obj->effect_infocxx . . $ object#effect_info.->damage_handlecxx . . $ effect_info_s#damage_handle. = killer->handlecxx . . $ object#handle.; |
| 639 | else |
| 640 | obj->effect_infocxx . . $ object#effect_info.->damage_handlecxx . . $ effect_info_s#damage_handle. = OBJECT_HANDLE_NONEcxx . . $ `Descent3/object_external.h:156:9`!; |
| 641 | |
| 642 | if (obj->effect_infocxx . . $ object#effect_info.->sound_handlecxx . . $ effect_info_s#sound_handle. == SOUND_NONE_INDEXcxx . . $ `Descent3/sounds.h:105:9`!) |
| 643 | obj->effect_infocxx . . $ object#effect_info.->sound_handlecxx . . $ effect_info_s#sound_handle. = Sound_systemcxx . . $ Sound_system..Play3dSoundcxx . . $ hlsSystem#Play3dSound(17f485224ada8dd7).(SOUND_PLAYER_BURNINGcxx . . $ `Descent3/sounds.h:134:9`!, SND_PRIORITY_HIGHESTcxx . . $ `sndlib/ssl_lib.h:282:9`!, obj); |
| 644 | } |
| 645 | } |
| 646 | |
| 647 | // Causes an object to have napalm attached to it |
| 648 | void ApplyFreezeDamageEffectcxx . . $ ApplyFreezeDamageEffect(419c470199a90a97).(objectcxx . . $ object# *obj) { |
| 649 | if (obj->effect_infocxx . . $ object#effect_info.) { |
| 650 | if (!(obj->effect_infocxx . . $ object#effect_info.->type_flagscxx . . $ effect_info_s#type_flags. & EF_FREEZEcxx . . $ `Descent3/object_external.h:203:9`!)) |
| 651 | obj->effect_infocxx . . $ object#effect_info.->freeze_scalarcxx . . $ effect_info_s#freeze_scalar. = 1.0; |
| 652 | |
| 653 | obj->effect_infocxx . . $ object#effect_info.->type_flagscxx . . $ effect_info_s#type_flags. |= EF_FREEZEcxx . . $ `Descent3/object_external.h:203:9`!; |
| 654 | obj->effect_infocxx . . $ object#effect_info.->freeze_scalarcxx . . $ effect_info_s#freeze_scalar. -= .2f; |
| 655 | |
| 656 | if (obj->effect_infocxx . . $ object#effect_info.->freeze_scalarcxx . . $ effect_info_s#freeze_scalar. < .3) |
| 657 | obj->effect_infocxx . . $ object#effect_info.->freeze_scalarcxx . . $ effect_info_s#freeze_scalar. = .3f; |
| 658 | } |
| 659 | } |
| 660 | |
| 661 | // Event to handle damage effect |
| 662 | void DoDamageEffectcxx . . $ DoDamageEffect(6ca3d68f5c5f0975).(int eventnum, void *data) { |
| 663 | float damage_norm = Playerscxx . . $ Players.[Player_numcxx . . $ Player_num.].damage_magnitudecxx . . $ player#damage_magnitude. / MAX_DAMAGE_MAGcxx . . $ `Descent3/damage.h:106:9`!; |
| 664 | |
| 665 | if (damage_norm > 1.0) |
| 666 | damage_norm = 1.0; |
| 667 | |
| 668 | DrawAlphaBlendedScreencxx . . $ DrawAlphaBlendedScreen(7e9a355db6148521).(1.0, 0, 0, .4 * damage_norm); |
| 669 | |
| 670 | // If we're all done, just stop. Else, make another event! |
| 671 | if (Playerscxx . . $ Players.[Player_numcxx . . $ Player_num.].damage_magnitudecxx . . $ player#damage_magnitude. < .0001f) |
| 672 | Playerscxx . . $ Players.[Player_numcxx . . $ Player_num.].damage_magnitudecxx . . $ player#damage_magnitude. = 0.0; |
| 673 | else |
| 674 | CreateNewEventcxx . . $ CreateNewEvent(85af21da76cb0316).(RENDER_EVENTcxx . . $ `Descent3/gameevent.h:29:9`!, DAMAGE_EFFECTcxx . . $ `Descent3/gameevent.h:34:9`!, 0, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!, 0, DoDamageEffectcxx . . $ DoDamageEffect(6ca3d68f5c5f0975).); |
| 675 | } |
| 676 | |
| 677 | // Decreases a players shields |
| 678 | void DecreasePlayerShieldscxx . . $ DecreasePlayerShields(43c79ee2f1b9aefe).(int slot, float damage) { |
| 679 | objectcxx . . $ object# *playerobj = &Objectscxx . . $ Objects.[Playerscxx . . $ Players.[slot].objnumcxx . . $ player#objnum.]; |
| 680 | playerobj->shieldscxx . . $ object#shields. -= damage; |
| 681 | Playerscxx . . $ Players.[slot].damage_magnitudecxx . . $ player#damage_magnitude. += damage; |
| 682 | |
| 683 | if (slot == Player_numcxx . . $ Player_num.) { |
| 684 | if ((FindEventIDcxx . . $ FindEventID(7864480464b09eea).(DAMAGE_EFFECTcxx . . $ `Descent3/gameevent.h:34:9`!)) == -1) |
| 685 | CreateNewEventcxx . . $ CreateNewEvent(85af21da76cb0316).(RENDER_EVENTcxx . . $ `Descent3/gameevent.h:29:9`!, DAMAGE_EFFECTcxx . . $ `Descent3/gameevent.h:34:9`!, 0, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!, 0, DoDamageEffectcxx . . $ DoDamageEffect(6ca3d68f5c5f0975).); |
| 686 | |
| 687 | if (Game_modecxx . . $ Game_mode. & GM_MULTIcxx . . $ `Descent3/game.h:288:9`!) |
| 688 | Multi_bail_ui_menucxx . . $ Multi_bail_ui_menu. = true; |
| 689 | |
| 690 | Game_music_infocxx . . $ Game_music_info..player_damagedcxx . . $ tMusicSeqInfo#player_damaged. = true; |
| 691 | } |
| 692 | } |
| 693 | |
| 694 | // Event to handle damage effect |
| 695 | void DoEDrainEffectcxx . . $ DoEDrainEffect(6ca3d68f5c5f0975).(int eventnum, void *data) { |
| 696 | float edrain_norm = Playerscxx . . $ Players.[Player_numcxx . . $ Player_num.].edrain_magnitudecxx . . $ player#edrain_magnitude. / MAX_EDRAIN_MAGcxx . . $ `Descent3/damage.h:107:9`!; |
| 697 | |
| 698 | if (edrain_norm > 1.0) |
| 699 | edrain_norm = 1.0; |
| 700 | |
| 701 | DrawAlphaBlendedScreencxx . . $ DrawAlphaBlendedScreen(7e9a355db6148521).(0, 0, 1.0, .6 * edrain_norm); |
| 702 | |
| 703 | // If we're all done, just stop. Else, make another event! |
| 704 | if (Playerscxx . . $ Players.[Player_numcxx . . $ Player_num.].edrain_magnitudecxx . . $ player#edrain_magnitude. < .0001f) |
| 705 | Playerscxx . . $ Players.[Player_numcxx . . $ Player_num.].edrain_magnitudecxx . . $ player#edrain_magnitude. = 0.0; |
| 706 | else |
| 707 | CreateNewEventcxx . . $ CreateNewEvent(85af21da76cb0316).(RENDER_EVENTcxx . . $ `Descent3/gameevent.h:29:9`!, EDRAIN_EFFECTcxx . . $ `Descent3/gameevent.h:38:9`!, 0, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!, 0, DoEDrainEffectcxx . . $ DoEDrainEffect(6ca3d68f5c5f0975).); |
| 708 | } |
| 709 | |
| 710 | // Decreases a players shields |
| 711 | void DecreasePlayerEnergycxx . . $ DecreasePlayerEnergy(43c79ee2f1b9aefe).(int slot, float energy) { |
| 712 | Playerscxx . . $ Players.[slot].energycxx . . $ player#energy. -= energy; |
| 713 | Playerscxx . . $ Players.[slot].edrain_magnitudecxx . . $ player#edrain_magnitude. += energy; |
| 714 | |
| 715 | if (slot == Player_numcxx . . $ Player_num.) { |
| 716 | if ((FindEventIDcxx . . $ FindEventID(7864480464b09eea).(EDRAIN_EFFECTcxx . . $ `Descent3/gameevent.h:38:9`!)) == -1) |
| 717 | CreateNewEventcxx . . $ CreateNewEvent(85af21da76cb0316).(RENDER_EVENTcxx . . $ `Descent3/gameevent.h:29:9`!, EDRAIN_EFFECTcxx . . $ `Descent3/gameevent.h:38:9`!, 0, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!, 0, DoEDrainEffectcxx . . $ DoEDrainEffect(6ca3d68f5c5f0975).); |
| 718 | } |
| 719 | } |
| 720 | |
| 721 | // Plays the sound for a player being damaged |
| 722 | void PlayPlayerDamageSoundcxx . . $ PlayPlayerDamageSound(766a1b7183ffa4b4).(objectcxx . . $ object# *playerobj, int damage_type) { |
| 723 | int sound_handle; |
| 724 | |
| 725 | switch (damage_type) { |
| 726 | case PD_ENERGY_WEAPONcxx . . $ `Descent3/damage_external.h:24:9`!: |
| 727 | sound_handle = SOUND_HIT_BY_ENERGY_WEAPONcxx . . $ `Descent3/sounds.h:131:9`!; |
| 728 | break; |
| 729 | case PD_MATTER_WEAPONcxx . . $ `Descent3/damage_external.h:25:9`!: |
| 730 | sound_handle = SOUND_HIT_BY_MATTER_WEAPONcxx . . $ `Descent3/sounds.h:132:9`!; |
| 731 | break; |
| 732 | case PD_CONCUSSIVE_FORCEcxx . . $ `Descent3/damage_external.h:27:9`!: |
| 733 | sound_handle = SOUND_HIT_BY_CONCUSSIVE_FORCEcxx . . $ `Descent3/sounds.h:133:9`!; |
| 734 | break; |
| 735 | case PD_WALL_HITcxx . . $ `Descent3/damage_external.h:28:9`!: |
| 736 | sound_handle = SOUND_PLAYER_HIT_WALLcxx . . $ `Descent3/sounds.h:120:9`!; |
| 737 | break; |
| 738 | case PD_VOLATILE_HISScxx . . $ `Descent3/damage_external.h:29:9`!: |
| 739 | sound_handle = SOUND_VOLATILE_HISScxx . . $ `Descent3/sounds.h:151:9`!; |
| 740 | break; |
| 741 | |
| 742 | default: |
| 743 | Int3cxx . . $ `misc/pserror.h:247:9`!(); |
| 744 | case PD_MELEE_ATTACKcxx . . $ `Descent3/damage_external.h:26:9`!: // melee sounds handled in aimain.cpp for now |
| 745 | case PD_NONEcxx . . $ `Descent3/damage_external.h:23:9`!: |
| 746 | return; |
| 747 | } |
| 748 | |
| 749 | Sound_systemcxx . . $ Sound_system..Play3dSoundcxx . . $ hlsSystem#Play3dSound(17f485224ada8dd7).(sound_handle, SND_PRIORITY_HIGHESTcxx . . $ `sndlib/ssl_lib.h:282:9`!, playerobj); |
| 750 | } |
| 751 | |
| 752 | // Plays the sound for a player being damaged |
| 753 | void PlayPlayerInvulnerabilitySoundcxx . . $ PlayPlayerInvulnerabilitySound(419c470199a90a97).(objectcxx . . $ object# *playerobj) { |
| 754 | Sound_systemcxx . . $ Sound_system..Play3dSoundcxx . . $ hlsSystem#Play3dSound(17f485224ada8dd7).(SOUND_METALLIC_DOOR_HITcxx . . $ `Descent3/sounds.h:127:9`!, SND_PRIORITY_HIGHESTcxx . . $ `sndlib/ssl_lib.h:282:9`!, playerobj); |
| 755 | } |
| 756 | |
| 757 | // Kills the player |
| 758 | // weapon_id can be -1 for no weapon |
| 759 | void KillPlayercxx . . $ KillPlayer(3a7735745f872cae).(objectcxx . . $ object# *playerobj, objectcxx . . $ object# *killer, float damage_amount, int weapon_id) { |
| 760 | // Save the killer |
| 761 | Playerscxx . . $ Players.[playerobj->idcxx . . $ object#id.].killer_objnumcxx . . $ player#killer_objnum. = killer ? OBJNUMcxx . . $ `Descent3/object.h:700:9`!(killer) : 0; |
| 762 | |
| 763 | // Set some stuff |
| 764 | Playerscxx . . $ Players.[playerobj->idcxx . . $ object#id.].damage_magnitudecxx . . $ player#damage_magnitude. = 0; |
| 765 | Playerscxx . . $ Players.[playerobj->idcxx . . $ object#id.].edrain_magnitudecxx . . $ player#edrain_magnitude. = 0; |
| 766 | |
| 767 | tOSIRISEventInfocxx . . $ tOSIRISEventInfo# ei; |
| 768 | ei.evt_player_diescxx . . $ tOSIRISEventInfo#$anonymous_type_1#evt_player_dies..it_handlecxx . . $ tOSIRISEVTPLAYERDIES#it_handle. = playerobj->handlecxx . . $ object#handle.; |
| 769 | Osiris_CallLevelEventcxx . . $ Osiris_CallLevelEvent(a880c8b99cdc05b4).(EVT_PLAYER_DIEScxx . . $ `scripts/osiris_common.h:400:9`!, &ei); |
| 770 | |
| 771 | // If single-player, record & initiate death |
| 772 | if (!(Game_modecxx . . $ Game_mode. & GM_MULTIcxx . . $ `Descent3/game.h:288:9`!)) { |
| 773 | |
| 774 | if (Demo_flagscxx . . $ Demo_flags. == DF_RECORDINGcxx . . $ `lib/demofile.h:122:9`!) |
| 775 | DemoWritePlayerDeathcxx . . $ DemoWritePlayerDeath(638d79040b3e553a).(playerobj, (killer && IS_ROBOTcxx . . $ `Descent3/object_external.h:194:9`!(killer))); |
| 776 | |
| 777 | if (Demo_flagscxx . . $ Demo_flags. != DF_PLAYBACKcxx . . $ `lib/demofile.h:123:9`!) |
| 778 | InitiatePlayerDeathcxx . . $ InitiatePlayerDeath(638d79040b3e553a).(playerobj, (killer && IS_ROBOTcxx . . $ `Descent3/object_external.h:194:9`!(killer))); |
| 779 | } else if (Netgamecxx . . $ Netgame..local_rolecxx . . $ netgame_info#local_role. == LR_SERVERcxx . . $ `Descent3/multi_external.h:129:9`!) { // Multiplayer & server |
| 780 | |
| 781 | // Call DLL stuff |
| 782 | DLLInfocxx . . $ DLLInfo..me_handlecxx . . $ dllinfo#me_handle. = playerobj->handlecxx . . $ object#handle.; |
| 783 | |
| 784 | if (killer != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!) |
| 785 | DLLInfocxx . . $ DLLInfo..it_handlecxx . . $ dllinfo#it_handle. = killer->handlecxx . . $ object#handle.; |
| 786 | else |
| 787 | DLLInfocxx . . $ DLLInfo..it_handlecxx . . $ dllinfo#it_handle. = OBJECT_HANDLE_NONEcxx . . $ `Descent3/object_external.h:156:9`!; |
| 788 | |
| 789 | DLLInfocxx . . $ DLLInfo..iParamcxx . . $ dllinfo#iParam. = weapon_id; |
| 790 | |
| 791 | CallGameDLLcxx . . $ CallGameDLL(32ca0c0c7dbc2fcf).(EVT_GAMEPLAYERKILLEDcxx . . $ `lib/d3events.h:65:9`!, &DLLInfocxx . . $ DLLInfo.); |
| 792 | |
| 793 | // pick a fate for this guy |
| 794 | int fate = PlayerChooseDeathFatecxx . . $ PlayerChooseDeathFate(3894405e7b40415d).(playerobj->idcxx . . $ object#id., damage_amount, false); |
| 795 | |
| 796 | // Send it to everyone |
| 797 | MultiSendPlayerDeadcxx . . $ MultiSendPlayerDead(9633529ce3c4ff50).(playerobj->idcxx . . $ object#id., fate); |
| 798 | |
| 799 | // Figure out new rankings |
| 800 | GetNewRankingscxx . . $ GetNewRankings(6273fa812ac58a8).(playerobj, killer); |
| 801 | } |
| 802 | } |
| 803 | |
| 804 | // Applies damage to a player object, returns false if damage wasn't applied due to things like |
| 805 | // invunerability |
| 806 | bool ApplyDamageToPlayercxx . . $ ApplyDamageToPlayer(1fbfa7277d8ac7b4).(objectcxx . . $ object# *playerobj, objectcxx . . $ object# *killer, int damage_type, float damage_amount, int server_says, |
| 807 | int weapon_id, bool playsound) { |
| 808 | if (!playerobj || playerobj->typecxx . . $ object#type. != OBJ_PLAYERcxx . . $ `Descent3/object_external.h:164:9`!) { |
| 809 | // bail it's not a player (no damage should be applied to ghosts or observer's either |
| 810 | return false; |
| 811 | } |
| 812 | |
| 813 | // apply damage to the current player! |
| 814 | objectcxx . . $ object# *weapon_obj = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!; |
| 815 | |
| 816 | if (killer != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`! && killer->typecxx . . $ object#type. == OBJ_WEAPONcxx . . $ `Descent3/object_external.h:165:9`!) { |
| 817 | weapon_obj = killer; |
| 818 | killer = ObjGetUltimateParentcxx . . $ ObjGetUltimateParent(64a00b84ed3f82ee).(killer); |
| 819 | |
| 820 | if (!(Game_modecxx . . $ Game_mode. & GM_MULTIcxx . . $ `Descent3/game.h:288:9`!) || ((Game_modecxx . . $ Game_mode. & GM_MULTIcxx . . $ `Descent3/game.h:288:9`!) && Netgamecxx . . $ Netgame..local_rolecxx . . $ netgame_info#local_role. == LR_SERVERcxx . . $ `Descent3/multi_external.h:129:9`!)) |
| 821 | weapon_id = weapon_obj->idcxx . . $ object#id.; |
| 822 | if ((Game_modecxx . . $ Game_mode. & GM_MULTIcxx . . $ `Descent3/game.h:288:9`!) && Netgamecxx . . $ Netgame..local_rolecxx . . $ netgame_info#local_role. == LR_CLIENTcxx . . $ `Descent3/multi_external.h:128:9`! && !server_says && (Netgamecxx . . $ Netgame..flagscxx . . $ netgame_info#flags. & NF_PEER_PEERcxx . . $ `Descent3/multi_external.h:230:9`!)) |
| 823 | weapon_id = weapon_obj->idcxx . . $ object#id.; |
| 824 | } |
| 825 | |
| 826 | if ((Playerscxx . . $ Players.[playerobj->idcxx . . $ object#id.].flagscxx . . $ player#flags. & PLAYER_FLAGS_DYINGcxx . . $ `Descent3/player_external.h:80:9`!) || (Playerscxx . . $ Players.[playerobj->idcxx . . $ object#id.].flagscxx . . $ player#flags. & PLAYER_FLAGS_DEADcxx . . $ `Descent3/player_external.h:81:9`!)) { |
| 827 | PlayPlayerDamageSoundcxx . . $ PlayPlayerDamageSound(766a1b7183ffa4b4).(playerobj, damage_type); |
| 828 | return false; |
| 829 | } |
| 830 | |
| 831 | if ((Playerscxx . . $ Players.[playerobj->idcxx . . $ object#id.].flagscxx . . $ player#flags. & PLAYER_FLAGS_INVULNERABLEcxx . . $ `Descent3/player_external.h:79:9`!) || ((Player_objectcxx . . $ Player_object.->flagscxx . . $ object#flags. & OF_DESTROYABLEcxx . . $ `Descent3/object_external.h:279:9`!) == 0)) { |
| 832 | if (damage_type != PD_NONEcxx . . $ `Descent3/damage_external.h:23:9`!) |
| 833 | PlayPlayerInvulnerabilitySoundcxx . . $ PlayPlayerInvulnerabilitySound(419c470199a90a97).(playerobj); |
| 834 | |
| 835 | if (weapon_obj != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!) { |
| 836 | Playerscxx . . $ Players.[playerobj->idcxx . . $ object#id.].invul_magnitudecxx . . $ player#invul_magnitude. = 1; |
| 837 | Playerscxx . . $ Players.[playerobj->idcxx . . $ object#id.].invul_vectorcxx . . $ player#invul_vector. =cxx . . $ vector#`operator=`(c0842353a20857d). weapon_obj->poscxx . . $ object#pos. -cxx . . $ operator-(b77b703cd1e43e33). playerobj->poscxx . . $ object#pos.; |
| 838 | vm_NormalizeVectorFastcxx . . $ vm_NormalizeVectorFast(4939a7e530383cd4).(&Playerscxx . . $ Players.[playerobj->idcxx . . $ object#id.].invul_vectorcxx . . $ player#invul_vector.); |
| 839 | } |
| 840 | return false; |
| 841 | } else { |
| 842 | if (!(Game_modecxx . . $ Game_mode. & GM_MULTIcxx . . $ `Descent3/game.h:288:9`!)) { |
| 843 | damage_amount *= Playerscxx . . $ Players.[playerobj->idcxx . . $ object#id.].armor_scalarcxx . . $ player#armor_scalar.; |
| 844 | damage_amount *= Shipscxx . . $ Ships.[Playerscxx . . $ Players.[playerobj->idcxx . . $ object#id.].ship_indexcxx . . $ player#ship_index.].armor_scalarcxx . . $ ship#armor_scalar.; |
| 845 | |
| 846 | DecreasePlayerShieldscxx . . $ DecreasePlayerShields(43c79ee2f1b9aefe).(playerobj->idcxx . . $ object#id., damage_amount); |
| 847 | |
| 848 | if (damage_amount > 0 && playsound) |
| 849 | PlayPlayerDamageSoundcxx . . $ PlayPlayerDamageSound(766a1b7183ffa4b4).(playerobj, damage_type); |
| 850 | |
| 851 | if (Playerscxx . . $ Players.[playerobj->idcxx . . $ object#id.].guided_objcxx . . $ player#guided_obj. != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!) |
| 852 | ReleaseGuidedMissilecxx . . $ ReleaseGuidedMissile(d4f767463ce0a6b3).(playerobj->idcxx . . $ object#id.); |
| 853 | |
| 854 | if (Playerscxx . . $ Players.[playerobj->idcxx . . $ object#id.].user_timeout_objcxx . . $ player#user_timeout_obj. != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!) |
| 855 | ReleaseUserTimeoutMissilecxx . . $ ReleaseUserTimeoutMissile(d4f767463ce0a6b3).(playerobj->idcxx . . $ object#id.); |
| 856 | |
| 857 | if (weapon_id != 255) { |
| 858 | if (Weaponscxx . . $ Weapons.[weapon_id].flagscxx . . $ weapon#flags. & WF_MICROWAVEcxx . . $ `Descent3/weapon.h:237:9`!) |
| 859 | SetDeformDamageEffectcxx . . $ SetDeformDamageEffect(419c470199a90a97).(playerobj); |
| 860 | if (Weaponscxx . . $ Weapons.[weapon_id].flagscxx . . $ weapon#flags. & WF_FREEZEcxx . . $ `Descent3/weapon.h:243:9`!) |
| 861 | ApplyFreezeDamageEffectcxx . . $ ApplyFreezeDamageEffect(419c470199a90a97).(playerobj); |
| 862 | if (Weaponscxx . . $ Weapons.[weapon_id].flagscxx . . $ weapon#flags. & WF_NAPALMcxx . . $ `Descent3/weapon.h:238:9`!) |
| 863 | SetNapalmDamageEffectcxx . . $ SetNapalmDamageEffect(6964148eab73f28a).(playerobj, killer, weapon_id); |
| 864 | } |
| 865 | |
| 866 | if (playerobj->shieldscxx . . $ object#shields. < 0) { |
| 867 | KillPlayercxx . . $ KillPlayer(3a7735745f872cae).(playerobj, killer, damage_amount, weapon_id); |
| 868 | } |
| 869 | } else { |
| 870 | // If this is a peer to peer game, and its me taking damage, then ask the server to damage me! |
| 871 | if (Netgamecxx . . $ Netgame..local_rolecxx . . $ netgame_info#local_role. == LR_CLIENTcxx . . $ `Descent3/multi_external.h:128:9`! && (Netgamecxx . . $ Netgame..flagscxx . . $ netgame_info#flags. & NF_PEER_PEERcxx . . $ `Descent3/multi_external.h:230:9`!) && !server_says) { |
| 872 | if (playerobj->idcxx . . $ object#id. == Player_numcxx . . $ Player_num.) { |
| 873 | MultiSendRequestPeerDamagecxx . . $ MultiSendRequestPeerDamage(429600379706fe12).(killer, weapon_id, damage_type, damage_amount); |
| 874 | return true; |
| 875 | } |
| 876 | } |
| 877 | |
| 878 | if ((Netgamecxx . . $ Netgame..flagscxx . . $ netgame_info#flags. & NF_PEER_PEERcxx . . $ `Descent3/multi_external.h:230:9`!) && Netgamecxx . . $ Netgame..local_rolecxx . . $ netgame_info#local_role. == LR_SERVERcxx . . $ `Descent3/multi_external.h:129:9`! && !server_says) { |
| 879 | if (playerobj->idcxx . . $ object#id. != Player_numcxx . . $ Player_num.) |
| 880 | return true; |
| 881 | } |
| 882 | |
| 883 | if (Netgamecxx . . $ Netgame..local_rolecxx . . $ netgame_info#local_role. == LR_SERVERcxx . . $ `Descent3/multi_external.h:129:9`! || server_says) { |
| 884 | if (Netgamecxx . . $ Netgame..local_rolecxx . . $ netgame_info#local_role. == LR_SERVERcxx . . $ `Descent3/multi_external.h:129:9`!) { |
| 885 | // Check to see if we're on the same team |
| 886 | if (killer != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`! && killer->typecxx . . $ object#type. == OBJ_PLAYERcxx . . $ `Descent3/object_external.h:164:9`!) { |
| 887 | if (killer->idcxx . . $ object#id. != playerobj->idcxx . . $ object#id.) { |
| 888 | if (Playerscxx . . $ Players.[killer->idcxx . . $ object#id.].teamcxx . . $ player#team. == Playerscxx . . $ Players.[playerobj->idcxx . . $ object#id.].teamcxx . . $ player#team. && !(Netgamecxx . . $ Netgame..flagscxx . . $ netgame_info#flags. & NF_DAMAGE_FRIENDLYcxx . . $ `Descent3/multi_external.h:235:9`!)) |
| 889 | return false; // don't hurt players on your own team |
| 890 | } |
| 891 | |
| 892 | damage_amount *= Playerscxx . . $ Players.[killer->idcxx . . $ object#id.].damage_scalarcxx . . $ player#damage_scalar.; |
| 893 | } |
| 894 | |
| 895 | damage_amount *= Playerscxx . . $ Players.[playerobj->idcxx . . $ object#id.].armor_scalarcxx . . $ player#armor_scalar.; |
| 896 | damage_amount *= Shipscxx . . $ Ships.[Playerscxx . . $ Players.[playerobj->idcxx . . $ object#id.].ship_indexcxx . . $ player#ship_index.].armor_scalarcxx . . $ ship#armor_scalar.; |
| 897 | } |
| 898 | |
| 899 | DecreasePlayerShieldscxx . . $ DecreasePlayerShields(43c79ee2f1b9aefe).(playerobj->idcxx . . $ object#id., damage_amount); |
| 900 | if (damage_amount > 0 && playsound) |
| 901 | PlayPlayerDamageSoundcxx . . $ PlayPlayerDamageSound(766a1b7183ffa4b4).(playerobj, damage_type); |
| 902 | if (playerobj->idcxx . . $ object#id. == Player_numcxx . . $ Player_num. && Playerscxx . . $ Players.[playerobj->idcxx . . $ object#id.].guided_objcxx . . $ player#guided_obj. != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!) |
| 903 | ReleaseGuidedMissilecxx . . $ ReleaseGuidedMissile(d4f767463ce0a6b3).(playerobj->idcxx . . $ object#id.); |
| 904 | |
| 905 | if (playerobj->idcxx . . $ object#id. == Player_numcxx . . $ Player_num. && Playerscxx . . $ Players.[playerobj->idcxx . . $ object#id.].user_timeout_objcxx . . $ player#user_timeout_obj. != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!) |
| 906 | ReleaseUserTimeoutMissilecxx . . $ ReleaseUserTimeoutMissile(d4f767463ce0a6b3).(playerobj->idcxx . . $ object#id.); |
| 907 | |
| 908 | if (weapon_id != 255) { |
| 909 | if (Weaponscxx . . $ Weapons.[weapon_id].flagscxx . . $ weapon#flags. & WF_MICROWAVEcxx . . $ `Descent3/weapon.h:237:9`!) |
| 910 | SetDeformDamageEffectcxx . . $ SetDeformDamageEffect(419c470199a90a97).(playerobj); |
| 911 | if (Weaponscxx . . $ Weapons.[weapon_id].flagscxx . . $ weapon#flags. & WF_NAPALMcxx . . $ `Descent3/weapon.h:238:9`!) |
| 912 | SetNapalmDamageEffectcxx . . $ SetNapalmDamageEffect(6964148eab73f28a).(playerobj, killer, weapon_id); |
| 913 | if (Weaponscxx . . $ Weapons.[weapon_id].flagscxx . . $ weapon#flags. & WF_FREEZEcxx . . $ `Descent3/weapon.h:243:9`!) |
| 914 | ApplyFreezeDamageEffectcxx . . $ ApplyFreezeDamageEffect(419c470199a90a97).(playerobj); |
| 915 | } |
| 916 | |
| 917 | // Tell others about this tragic event |
| 918 | if (Netgamecxx . . $ Netgame..local_rolecxx . . $ netgame_info#local_role. == LR_SERVERcxx . . $ `Descent3/multi_external.h:129:9`!) { |
| 919 | if (weapon_id != 255) { |
| 920 | // If this is an electrical weapon then we should special case the damage |
| 921 | if (Weaponscxx . . $ Weapons.[weapon_id].flagscxx . . $ weapon#flags. & WF_ELECTRICALcxx . . $ `Descent3/weapon.h:222:9`!) { |
| 922 | Multi_additional_damagecxx . . $ Multi_additional_damage.[playerobj->idcxx . . $ object#id.] += damage_amount; |
| 923 | Multi_additional_damage_typecxx . . $ Multi_additional_damage_type.[playerobj->idcxx . . $ object#id.] = PD_ENERGY_WEAPONcxx . . $ `Descent3/damage_external.h:24:9`!; |
| 924 | } else |
| 925 | MultiSendDamagePlayercxx . . $ MultiSendDamagePlayer(3c27ae030892e7bf).(playerobj->idcxx . . $ object#id., weapon_id, damage_type, damage_amount); |
| 926 | } else { |
| 927 | if (weapon_obj != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!) |
| 928 | MultiSendDamagePlayercxx . . $ MultiSendDamagePlayer(3c27ae030892e7bf).(playerobj->idcxx . . $ object#id., 255, damage_type, damage_amount); |
| 929 | else { |
| 930 | Multi_additional_damagecxx . . $ Multi_additional_damage.[playerobj->idcxx . . $ object#id.] += damage_amount; |
| 931 | Multi_additional_damage_typecxx . . $ Multi_additional_damage_type.[playerobj->idcxx . . $ object#id.] = damage_type; |
| 932 | } |
| 933 | } |
| 934 | } |
| 935 | } |
| 936 | |
| 937 | if (Netgamecxx . . $ Netgame..local_rolecxx . . $ netgame_info#local_role. == LR_SERVERcxx . . $ `Descent3/multi_external.h:129:9`!) { |
| 938 | // Call DLL stuff |
| 939 | DLLInfocxx . . $ DLLInfo..me_handlecxx . . $ dllinfo#me_handle. = playerobj->handlecxx . . $ object#handle.; |
| 940 | if (killer != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!) |
| 941 | DLLInfocxx . . $ DLLInfo..it_handlecxx . . $ dllinfo#it_handle. = killer->handlecxx . . $ object#handle.; |
| 942 | else |
| 943 | DLLInfocxx . . $ DLLInfo..it_handlecxx . . $ dllinfo#it_handle. = OBJECT_HANDLE_NONEcxx . . $ `Descent3/object_external.h:156:9`!; |
| 944 | DLLInfocxx . . $ DLLInfo..fParamcxx . . $ dllinfo#fParam. = damage_amount; |
| 945 | CallGameDLLcxx . . $ CallGameDLL(32ca0c0c7dbc2fcf).(EVT_GAMEOBJECTSHIELDSCHANGEDcxx . . $ `lib/d3events.h:75:9`!, &DLLInfocxx . . $ DLLInfo.); |
| 946 | |
| 947 | if (playerobj->shieldscxx . . $ object#shields. < 0) { |
| 948 | KillPlayercxx . . $ KillPlayer(3a7735745f872cae).(playerobj, killer, damage_amount, weapon_id); |
| 949 | } |
| 950 | } |
| 951 | } |
| 952 | } |
| 953 | |
| 954 | return true; |
| 955 | } |
| 956 | |
| 957 | // Fills in death info to roughly appoximate the deaths from the old explosion system |
| 958 | void GenerateDefaultDeathcxx . . $ GenerateDefaultDeath(e3e8a27ff878be74).(objectcxx . . $ object# *obj, int *death_flags, float *delay_time) { |
| 959 | // Set some defaults |
| 960 | *death_flags = 0; |
| 961 | *delay_time = 0.0; |
| 962 | |
| 963 | if ((obj->typecxx . . $ object#type. != OBJ_ROBOTcxx . . $ `Descent3/object_external.h:162:9`! && !(obj->typecxx . . $ object#type. == OBJ_BUILDINGcxx . . $ `Descent3/object_external.h:176:9`! && obj->ai_infocxx . . $ object#ai_info.)) || |
| 964 | (obj->movement_typecxx . . $ object#movement_type. != MT_WALKINGcxx . . $ `Descent3/object_external.h:235:9`! && ((ps_randcxx . . $ ps_rand(b126dc7c1de90089).() % 3) != 0)) || |
| 965 | (obj->movement_typecxx . . $ object#movement_type. == MT_WALKINGcxx . . $ `Descent3/object_external.h:235:9`! && ((ps_randcxx . . $ ps_rand(b126dc7c1de90089).() % 10) > 5))) { |
| 966 | |
| 967 | // Quick death |
| 968 | *death_flags = 0; |
| 969 | *delay_time = 0.0; |
| 970 | |
| 971 | // Maybe set blast ring |
| 972 | if ((ps_randcxx . . $ ps_rand(b126dc7c1de90089).() % 3) == 0) |
| 973 | *death_flags |= DF_BLAST_RINGcxx . . $ `Descent3/deathinfo_external.h:79:9`!; |
| 974 | } else { // slow death |
| 975 | |
| 976 | int alternate_death = 0; |
| 977 | bool f_upsidedown_walker = (obj->movement_typecxx . . $ object#movement_type. == MT_WALKINGcxx . . $ `Descent3/object_external.h:235:9`!) && (obj->orientcxx . . $ object#orient..uveccxx . . $ matrix#uvec..ycxx . . $ vector#y. < 0.0f); |
| 978 | |
| 979 | if (!f_upsidedown_walker && (ps_randcxx . . $ ps_rand(b126dc7c1de90089).() % 2) == 1) { |
| 980 | *death_flags = DF_DELAY_SPARKScxx . . $ `Descent3/deathinfo_external.h:68:9`!; |
| 981 | alternate_death = 1; |
| 982 | } |
| 983 | |
| 984 | if (obj->typecxx . . $ object#type. == OBJ_ROBOTcxx . . $ `Descent3/object_external.h:162:9`! || (obj->typecxx . . $ object#type. == OBJ_BUILDINGcxx . . $ `Descent3/object_external.h:176:9`! && obj->ai_infocxx . . $ object#ai_info.)) { |
| 985 | if (alternate_death || (obj->movement_typecxx . . $ object#movement_type. != MT_PHYSICScxx . . $ `Descent3/object_external.h:234:9`! && obj->movement_typecxx . . $ object#movement_type. != MT_WALKINGcxx . . $ `Descent3/object_external.h:235:9`!) || |
| 986 | (obj->movement_typecxx . . $ object#movement_type. == MT_WALKINGcxx . . $ `Descent3/object_external.h:235:9`! && !f_upsidedown_walker)) { |
| 987 | *death_flags = DF_DELAY_SPARKScxx . . $ `Descent3/deathinfo_external.h:68:9`!; |
| 988 | *delay_time = 3.0f; |
| 989 | alternate_death = 1; |
| 990 | } else { |
| 991 | if (obj->movement_typecxx . . $ object#movement_type. != MT_WALKINGcxx . . $ `Descent3/object_external.h:235:9`!) |
| 992 | *death_flags = 0; |
| 993 | else |
| 994 | *death_flags = DF_DELAY_LOSES_ANTIGRAVcxx . . $ `Descent3/deathinfo_external.h:69:9`!; |
| 995 | } |
| 996 | |
| 997 | // Alternate death must last 3 seconds to correspond with sound effect |
| 998 | // If you change this assumption, tell Jerry |
| 999 | if (!alternate_death && Object_infocxx . . $ Object_info.[obj->idcxx . . $ object#id.].animcxx . . $ object_info#anim.) { |
| 1000 | if (obj->control_typecxx . . $ object#control_type. == CT_AIcxx . . $ `Descent3/object_external.h:217:9`! && |
| 1001 | Object_infocxx . . $ Object_info.[obj->idcxx . . $ object#id.].animcxx . . $ object_info#anim.[obj->ai_infocxx . . $ object#ai_info.->movement_typecxx . . $ ai_frame#movement_type.].elemcxx . . $ anim_elem#elem.[AS_DEATHcxx . . $ `Descent3/aistruct_external.h:410:9`!].tocxx . . $ anim_entry#to. != 0.0f) { |
| 1002 | // compute time remaining in current animation |
| 1003 | float extra_time = obj->rtypecxx . . $ object#rtype..pobj_infocxx . . $ object#$anonymous_type_10#pobj_info..anim_timecxx . . $ polyobj_info#anim_time. * |
| 1004 | (obj->rtypecxx . . $ object#rtype..pobj_infocxx . . $ object#$anonymous_type_10#pobj_info..anim_end_framecxx . . $ polyobj_info#anim_end_frame. - obj->rtypecxx . . $ object#rtype..pobj_infocxx . . $ object#$anonymous_type_10#pobj_info..anim_framecxx . . $ polyobj_info#anim_frame.) / |
| 1005 | (obj->rtypecxx . . $ object#rtype..pobj_infocxx . . $ object#$anonymous_type_10#pobj_info..anim_end_framecxx . . $ polyobj_info#anim_end_frame. - obj->rtypecxx . . $ object#rtype..pobj_infocxx . . $ object#$anonymous_type_10#pobj_info..anim_start_framecxx . . $ polyobj_info#anim_start_frame.); |
| 1006 | extra_time = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).<float>(extra_time, 3.0); // limit extra time to 3 seconds |
| 1007 | *delay_time = Object_infocxx . . $ Object_info.[obj->idcxx . . $ object#id.].animcxx . . $ object_info#anim.[obj->ai_infocxx . . $ object#ai_info.->movement_typecxx . . $ ai_frame#movement_type.].elemcxx . . $ anim_elem#elem.[AS_DEATHcxx . . $ `Descent3/aistruct_external.h:410:9`!].spccxx . . $ anim_entry#spc. + 0.25 + extra_time; |
| 1008 | // Walkers last a little longer |
| 1009 | if (obj->movement_typecxx . . $ object#movement_type. == MT_WALKINGcxx . . $ `Descent3/object_external.h:235:9`!) |
| 1010 | *delay_time += 2.0f; |
| 1011 | } else |
| 1012 | *delay_time = 2.0f; |
| 1013 | } |
| 1014 | } else { // If building, make it shoot up |
| 1015 | *death_flags |= DF_DELAY_FLYINGcxx . . $ `Descent3/deathinfo_external.h:71:9`!; |
| 1016 | if (obj->orientcxx . . $ object#orient..uveccxx . . $ matrix#uvec..ycxx . . $ vector#y. == 1.0f) |
| 1017 | *delay_time = 2.0f; |
| 1018 | else |
| 1019 | *delay_time = 0.7f; |
| 1020 | } |
| 1021 | |
| 1022 | // Some deaths get blast ring |
| 1023 | if ((ps_randcxx . . $ ps_rand(b126dc7c1de90089).() % 8) == 0) |
| 1024 | *death_flags |= DF_BLAST_RINGcxx . . $ `Descent3/deathinfo_external.h:79:9`!; |
| 1025 | } |
| 1026 | |
| 1027 | // Set flags for all deaths |
| 1028 | *death_flags |= DF_FIREBALLcxx . . $ `Descent3/deathinfo_external.h:77:9`! + DF_BREAKS_APARTcxx . . $ `Descent3/deathinfo_external.h:78:9`! + DF_CONTACT_FIREBALLcxx . . $ `Descent3/deathinfo_external.h:92:9`! + DF_CONTACT_BREAKS_APARTcxx . . $ `Descent3/deathinfo_external.h:93:9`! + DF_DEBRIS_SMOKEScxx . . $ `Descent3/deathinfo_external.h:98:9`! + |
| 1029 | DF_DEBRIS_FIREBALLcxx . . $ `Descent3/deathinfo_external.h:101:9`!; |
| 1030 | } |
| 1031 | |
| 1032 | // Applies a default death to an object |
| 1033 | // Parameters: objp - the object to destroy |
| 1034 | // killer - the object who is killing it, or NULL |
| 1035 | // damage - how much damage was applied in the death blow? |
| 1036 | void KillObjectcxx . . $ KillObject(bdb088234d4582fb).(objectcxx . . $ object# *objp, objectcxx . . $ object# *killer, float damage) { |
| 1037 | int death_flags = -1; |
| 1038 | float delay_time; |
| 1039 | |
| 1040 | // Make sure a valid type |
| 1041 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(IS_GENERICcxx . . $ `Descent3/object_external.h:190:9`!(objp->type) || (objp->type == OBJ_DOORcxx . . $ `Descent3/object_external.h:177:9`!)); |
| 1042 | |
| 1043 | // Bail if already dying or exploding |
| 1044 | if ((objp->flagscxx . . $ object#flags. & OF_DYINGcxx . . $ `Descent3/object_external.h:282:9`!) || (objp->flagscxx . . $ object#flags. & OF_DEADcxx . . $ `Descent3/object_external.h:270:9`!)) |
| 1045 | return; |
| 1046 | |
| 1047 | // Get death info from the object page |
| 1048 | if (IS_GENERICcxx . . $ `Descent3/object_external.h:190:9`!(objp->type)) { |
| 1049 | |
| 1050 | // Get random probability |
| 1051 | int r = (ps_randcxx . . $ ps_rand(b126dc7c1de90089).() * 100 / (D3_RAND_MAXcxx . . $ `misc/psrand.h:41:9`! + 1)) + 1; // in range 1 to 100 |
| 1052 | |
| 1053 | // Loop through death types looking for chosen one |
| 1054 | for (int i = 0; i < MAX_DEATH_TYPEScxx . . $ `Descent3/objinfo.h:388:9`!; i++) { |
| 1055 | int p = Object_infocxx . . $ Object_info.[objp->idcxx . . $ object#id.].death_probabilitiescxx . . $ object_info#death_probabilities.[i]; |
| 1056 | if (r <= p) { |
| 1057 | float delay_min, delay_max; |
| 1058 | |
| 1059 | death_flags = Object_infocxx . . $ Object_info.[objp->idcxx . . $ object#id.].death_typescxx . . $ object_info#death_types.[i].flagscxx . . $ death_info#flags.; |
| 1060 | |
| 1061 | delay_min = Object_infocxx . . $ Object_info.[objp->idcxx . . $ object#id.].death_typescxx . . $ object_info#death_types.[i].delay_mincxx . . $ death_info#delay_min.; |
| 1062 | delay_max = Object_infocxx . . $ Object_info.[objp->idcxx . . $ object#id.].death_typescxx . . $ object_info#death_types.[i].delay_maxcxx . . $ death_info#delay_max.; |
| 1063 | |
| 1064 | delay_time = delay_min + (delay_max - delay_min) * ps_randcxx . . $ ps_rand(b126dc7c1de90089).() / D3_RAND_MAXcxx . . $ `misc/psrand.h:41:9`!; |
| 1065 | |
| 1066 | mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Using %d\n", i); |
| 1067 | break; |
| 1068 | } |
| 1069 | r -= p; |
| 1070 | } |
| 1071 | } |
| 1072 | |
| 1073 | // If no death from page, generate default |
| 1074 | if (death_flags == -1) |
| 1075 | GenerateDefaultDeathcxx . . $ GenerateDefaultDeath(e3e8a27ff878be74).(objp, &death_flags, &delay_time); |
| 1076 | |
| 1077 | // Now kill the object |
| 1078 | KillObjectcxx . . $ KillObject(8f52e4200539b78).(objp, killer, damage, death_flags, delay_time); |
| 1079 | } |
| 1080 | |
| 1081 | // Sets the physics parameters for a falling object |
| 1082 | void SetFallingPhysicscxx . . $ SetFallingPhysics(419c470199a90a97).(objectcxx . . $ object# *objp) { |
| 1083 | // Set gravity & other parms |
| 1084 | objp->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..flagscxx . . $ physics_info#flags. = PF_GRAVITYcxx . . $ `Descent3/object_external.h:320:9`! | PF_BOUNCEcxx . . $ `Descent3/object_external.h:315:9`!; |
| 1085 | objp->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..num_bouncescxx . . $ physics_info#num_bounces. = 0; |
| 1086 | objp->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..coeff_restitutioncxx . . $ physics_info#coeff_restitution. = .03f; |
| 1087 | if (objp->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..masscxx . . $ physics_info#mass. < 20.0) |
| 1088 | objp->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..masscxx . . $ physics_info#mass. = 20.0f; |
| 1089 | objp->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..dragcxx . . $ physics_info#drag. = .00001f; |
| 1090 | objp->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..rotdragcxx . . $ physics_info#rotdrag. = .00001f; |
| 1091 | |
| 1092 | // Special stuff for walkers |
| 1093 | if (objp->movement_typecxx . . $ object#movement_type. == MT_WALKINGcxx . . $ `Descent3/object_external.h:235:9`!) { |
| 1094 | objp->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..rotvelcxx . . $ physics_info#$anonymous_type_1#rotvel. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). Zero_vectorcxx . . $ Zero_vector.; |
| 1095 | objp->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..flagscxx . . $ physics_info#flags. |= PF_POINT_COLLIDE_WALLScxx . . $ `Descent3/object_external.h:333:9`!; |
| 1096 | float proj = objp->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..velocitycxx . . $ physics_info#velocity. *cxx . . $ `operator*`(4a721543d64e126a). objp->orientcxx . . $ object#orient..uveccxx . . $ matrix#uvec.; |
| 1097 | if (proj < 0.0f) |
| 1098 | objp->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..velocitycxx . . $ physics_info#velocity. -=cxx . . $ `operator-=`(801a8d6f7ab7bef9). proj *cxx . . $ `operator*`(9d6577ff3e9faa29). objp->orientcxx . . $ object#orient..uveccxx . . $ matrix#uvec.; |
| 1099 | |
| 1100 | objp->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..velocitycxx . . $ physics_info#velocity. +=cxx . . $ `operator+=`(801a8d6f7ab7bef9). objp->orientcxx . . $ object#orient..uveccxx . . $ matrix#uvec. *cxx . . $ `operator*`(252247219a31502c). (3.0f + ((float)ps_randcxx . . $ ps_rand(b126dc7c1de90089).() / D3_RAND_MAXcxx . . $ `misc/psrand.h:41:9`!) * 5.0); |
| 1101 | objp->movement_typecxx . . $ object#movement_type. = MT_PHYSICScxx . . $ `Descent3/object_external.h:234:9`!; |
| 1102 | } else { // not a walker |
| 1103 | |
| 1104 | // If not spinning much, give the object a good spin |
| 1105 | if (vm_GetMagnitudecxx . . $ vm_GetMagnitude(4939a7e530383cd4).(&objp->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..rotvelcxx . . $ physics_info#$anonymous_type_1#rotvel.) < 4000.0f) { |
| 1106 | objp->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..rotvelcxx . . $ physics_info#$anonymous_type_1#rotvel..xcxx . . $ vector#x. = (float)((60000.0f * (float)(D3_RAND_MAXcxx . . $ `misc/psrand.h:41:9`! / 2 - ps_randcxx . . $ ps_rand(b126dc7c1de90089).())) / (float)(D3_RAND_MAXcxx . . $ `misc/psrand.h:41:9`! / 2)); |
| 1107 | objp->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..rotvelcxx . . $ physics_info#$anonymous_type_1#rotvel..ycxx . . $ vector#y. = (float)((60000.0f * (float)(D3_RAND_MAXcxx . . $ `misc/psrand.h:41:9`! / 2 - ps_randcxx . . $ ps_rand(b126dc7c1de90089).())) / (float)(D3_RAND_MAXcxx . . $ `misc/psrand.h:41:9`! / 2)); |
| 1108 | objp->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..rotvelcxx . . $ physics_info#$anonymous_type_1#rotvel..zcxx . . $ vector#z. = (float)((60000.0f * (float)(D3_RAND_MAXcxx . . $ `misc/psrand.h:41:9`! / 2 - ps_randcxx . . $ ps_rand(b126dc7c1de90089).())) / (float)(D3_RAND_MAXcxx . . $ `misc/psrand.h:41:9`! / 2)); |
| 1109 | } |
| 1110 | } |
| 1111 | } |
| 1112 | |
| 1113 | // Sets the physics parameters for an object the flies in the air when dies |
| 1114 | void SetFlyingPhysicscxx . . $ SetFlyingPhysics(674fac047436fc5b).(objectcxx . . $ object# *objp, bool tumbles) { |
| 1115 | // Set gravity & other parms |
| 1116 | objp->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..flagscxx . . $ physics_info#flags. = PF_GRAVITYcxx . . $ `Descent3/object_external.h:320:9`! | PF_NO_COLLIDEcxx . . $ `Descent3/object_external.h:331:9`!; |
| 1117 | objp->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..coeff_restitutioncxx . . $ physics_info#coeff_restitution. = .03f; |
| 1118 | objp->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..masscxx . . $ physics_info#mass. = 50000.0f; |
| 1119 | objp->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..dragcxx . . $ physics_info#drag. = .01f; |
| 1120 | objp->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..rotdragcxx . . $ physics_info#rotdrag. = .01f; |
| 1121 | |
| 1122 | objp->movement_typecxx . . $ object#movement_type. = MT_PHYSICScxx . . $ `Descent3/object_external.h:234:9`!; |
| 1123 | |
| 1124 | if (tumbles) { |
| 1125 | // Make y spin a little bit more that x or z |
| 1126 | objp->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..rotvelcxx . . $ physics_info#$anonymous_type_1#rotvel..xcxx . . $ vector#x. = (float)((40000.0f * (float)(D3_RAND_MAXcxx . . $ `misc/psrand.h:41:9`! / 2 - ps_randcxx . . $ ps_rand(b126dc7c1de90089).())) / (float)(D3_RAND_MAXcxx . . $ `misc/psrand.h:41:9`! / 2)); |
| 1127 | objp->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..rotvelcxx . . $ physics_info#$anonymous_type_1#rotvel..ycxx . . $ vector#y. = (float)((60000.0f * (float)(D3_RAND_MAXcxx . . $ `misc/psrand.h:41:9`! / 2 - ps_randcxx . . $ ps_rand(b126dc7c1de90089).())) / (float)(D3_RAND_MAXcxx . . $ `misc/psrand.h:41:9`! / 2)); |
| 1128 | objp->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..rotvelcxx . . $ physics_info#$anonymous_type_1#rotvel..zcxx . . $ vector#z. = (float)((40000.0f * (float)(D3_RAND_MAXcxx . . $ `misc/psrand.h:41:9`! / 2 - ps_randcxx . . $ ps_rand(b126dc7c1de90089).())) / (float)(D3_RAND_MAXcxx . . $ `misc/psrand.h:41:9`! / 2)); |
| 1129 | } |
| 1130 | |
| 1131 | if (objp->orientcxx . . $ object#orient..uveccxx . . $ matrix#uvec..ycxx . . $ vector#y. == 1.0f) { |
| 1132 | objp->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..velocitycxx . . $ physics_info#velocity..ycxx . . $ vector#y. = (float)(3 * (ps_randcxx . . $ ps_rand(b126dc7c1de90089).() % 15)) + 20.0; |
| 1133 | objp->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..velocitycxx . . $ physics_info#velocity..xcxx . . $ vector#x. = 0; |
| 1134 | objp->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..velocitycxx . . $ physics_info#velocity..zcxx . . $ vector#z. = 0; |
| 1135 | |
| 1136 | // Doubled the velocity on 4/30/99 to make Josh's pop machines cooler. -MT |
| 1137 | objp->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..velocitycxx . . $ physics_info#velocity..ycxx . . $ vector#y. *= 2.0; |
| 1138 | } else { |
| 1139 | objp->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..velocitycxx . . $ physics_info#velocity. =cxx . . $ vector#`operator=`(c0842353a20857d). objp->orientcxx . . $ object#orient..uveccxx . . $ matrix#uvec. *cxx . . $ `operator*`(252247219a31502c). ((float)(2.0f * (ps_randcxx . . $ ps_rand(b126dc7c1de90089).() % 15)) + 7.0f); |
| 1140 | } |
| 1141 | } |
| 1142 | |
| 1143 | // Figure out how long it will take the dying anim to play |
| 1144 | float GetDeathAnimTimecxx . . $ GetDeathAnimTime(9e89091ee687c4f3).(objectcxx . . $ object# *objp) { |
| 1145 | float death_time = 0.0; |
| 1146 | |
| 1147 | if (objp->control_typecxx . . $ object#control_type. == CT_AIcxx . . $ `Descent3/object_external.h:217:9`!) { |
| 1148 | |
| 1149 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(IS_GENERICcxx . . $ `Descent3/object_external.h:190:9`!(objp->type)); |
| 1150 | |
| 1151 | if (Object_infocxx . . $ Object_info.[objp->idcxx . . $ object#id.].animcxx . . $ object_info#anim.[objp->ai_infocxx . . $ object#ai_info.->movement_typecxx . . $ ai_frame#movement_type.].elemcxx . . $ anim_elem#elem.[AS_DEATHcxx . . $ `Descent3/aistruct_external.h:410:9`!].tocxx . . $ anim_entry#to. != 0) { |
| 1152 | |
| 1153 | // calculate how long for the object to finish its current animation before starting death anim |
| 1154 | float extra_time = objp->rtypecxx . . $ object#rtype..pobj_infocxx . . $ object#$anonymous_type_10#pobj_info..anim_timecxx . . $ polyobj_info#anim_time. * |
| 1155 | (objp->rtypecxx . . $ object#rtype..pobj_infocxx . . $ object#$anonymous_type_10#pobj_info..anim_end_framecxx . . $ polyobj_info#anim_end_frame. - objp->rtypecxx . . $ object#rtype..pobj_infocxx . . $ object#$anonymous_type_10#pobj_info..anim_framecxx . . $ polyobj_info#anim_frame.) / |
| 1156 | (objp->rtypecxx . . $ object#rtype..pobj_infocxx . . $ object#$anonymous_type_10#pobj_info..anim_end_framecxx . . $ polyobj_info#anim_end_frame. - objp->rtypecxx . . $ object#rtype..pobj_infocxx . . $ object#$anonymous_type_10#pobj_info..anim_start_framecxx . . $ polyobj_info#anim_start_frame.); |
| 1157 | extra_time = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).<float>(extra_time, 3.0); // limit extra time to 3 seconds |
| 1158 | mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "extra_time = %2f\n", extra_time); |
| 1159 | |
| 1160 | death_time = Object_infocxx . . $ Object_info.[objp->idcxx . . $ object#id.].animcxx . . $ object_info#anim.[objp->ai_infocxx . . $ object#ai_info.->movement_typecxx . . $ ai_frame#movement_type.].elemcxx . . $ anim_elem#elem.[AS_DEATHcxx . . $ `Descent3/aistruct_external.h:410:9`!].spccxx . . $ anim_entry#spc. + 0.25 + extra_time; |
| 1161 | } |
| 1162 | } |
| 1163 | |
| 1164 | return death_time; |
| 1165 | } |
| 1166 | |
| 1167 | // Kill an object |
| 1168 | // The caller can specify death information; if none is specified, a default death will be used. |
| 1169 | // Parameters: objp - the object to destroy |
| 1170 | // killer - the object who is killing it, or NULL |
| 1171 | // damage - how much damage was applied in the death blow |
| 1172 | // death_flags - how the object dies |
| 1173 | // delay_time - how long to delay, if from anim flag not set |
| 1174 | void KillObjectcxx . . $ KillObject(8f52e4200539b78).(objectcxx . . $ object# *objp, objectcxx . . $ object# *killer, float damage, int death_flags, float delay_time) { |
| 1175 | // Make sure a valid type |
| 1176 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(IS_GENERICcxx . . $ `Descent3/object_external.h:190:9`!(objp->type) || (objp->type == OBJ_DOORcxx . . $ `Descent3/object_external.h:177:9`!)); |
| 1177 | |
| 1178 | // Bail if already dying or exploding |
| 1179 | if ((objp->flagscxx . . $ object#flags. & OF_DYINGcxx . . $ `Descent3/object_external.h:282:9`!) || (objp->flagscxx . . $ object#flags. & OF_DEADcxx . . $ `Descent3/object_external.h:270:9`!)) |
| 1180 | return; |
| 1181 | |
| 1182 | // Send out multiplayer info |
| 1183 | if ((Game_modecxx . . $ Game_mode. & GM_MULTIcxx . . $ `Descent3/game.h:288:9`!) && (Netgamecxx . . $ Netgame..local_rolecxx . . $ netgame_info#local_role. == LR_SERVERcxx . . $ `Descent3/multi_external.h:129:9`!)) { |
| 1184 | int seed = ps_randcxx . . $ ps_rand(b126dc7c1de90089).(); |
| 1185 | MultiSendKillObjectcxx . . $ MultiSendKillObject(1833889a812a22e6).(objp, killer, damage, death_flags, delay_time, seed); |
| 1186 | ps_srandcxx . . $ ps_srand(cb2f890c2fdad230).(seed); |
| 1187 | } |
| 1188 | |
| 1189 | // Record demo |
| 1190 | if (Demo_flagscxx . . $ Demo_flags. == DF_RECORDINGcxx . . $ `lib/demofile.h:122:9`!) { |
| 1191 | int seed = ps_randcxx . . $ ps_rand(b126dc7c1de90089).(); |
| 1192 | DemoWriteKillObjectcxx . . $ DemoWriteKillObject(4f0d9746d70de433).(objp, killer, damage, death_flags, delay_time, seed); |
| 1193 | ps_srandcxx . . $ ps_srand(cb2f890c2fdad230).(seed); |
| 1194 | } |
| 1195 | |
| 1196 | // Say this this object is dying |
| 1197 | objp->flagscxx . . $ object#flags. |= OF_DYINGcxx . . $ `Descent3/object_external.h:282:9`!; |
| 1198 | |
| 1199 | // If object is a door, let the doorway system know |
| 1200 | if (objp->typecxx . . $ object#type. == OBJ_DOORcxx . . $ `Descent3/object_external.h:177:9`!) |
| 1201 | DoorwayDestroycxx . . $ DoorwayDestroy(419c470199a90a97).(objp); |
| 1202 | |
| 1203 | // Set the delay if from anim |
| 1204 | if (death_flags & DF_DELAY_FROM_ANIMcxx . . $ `Descent3/deathinfo_external.h:67:9`!) |
| 1205 | delay_time = GetDeathAnimTimecxx . . $ GetDeathAnimTime(9e89091ee687c4f3).(objp); |
| 1206 | |
| 1207 | // Check for delay |
| 1208 | if (delay_time == 0.0) { // No delay. Dies now |
| 1209 | |
| 1210 | // If blast rings set, create 0-2 delayed blast rings |
| 1211 | if (death_flags & DF_BLAST_RINGcxx . . $ `Descent3/deathinfo_external.h:79:9`!) { |
| 1212 | float ring_size = OBJECT_OUTSIDEcxx . . $ `lib/object_external_struct.h:130:9`!(objp) ? (objp->sizecxx . . $ object#size. * 3) : objp->sizecxx . . $ object#size.; |
| 1213 | int extras = ps_randcxx . . $ ps_rand(b126dc7c1de90089).() % 3; |
| 1214 | for (int i = 0; i < extras; i++) |
| 1215 | CreateNewEventcxx . . $ CreateNewEvent(85af21da76cb0316).(0, 0, (i * .1) + .1, objp, sizeof(*objp), DoBlastRingEventcxx . . $ DoBlastRingEvent(6ca3d68f5c5f0975).); |
| 1216 | } |
| 1217 | |
| 1218 | // Register a kill if the killer is a player |
| 1219 | if (killer && (killer->typecxx . . $ object#type. == OBJ_PLAYERcxx . . $ `Descent3/object_external.h:164:9`!) && IS_GENERICcxx . . $ `Descent3/object_external.h:190:9`!(objp->type)) |
| 1220 | PlayerScoreAddcxx . . $ PlayerScoreAdd(3e454b8ccf442868).(killer->idcxx . . $ object#id., Object_infocxx . . $ Object_info.[objp->idcxx . . $ object#id.].scorecxx . . $ object_info#score.); |
| 1221 | |
| 1222 | // Destroy the object now |
| 1223 | DestroyObjectcxx . . $ DestroyObject(a11214108e4e4480).(objp, damage * 3.0, death_flags); |
| 1224 | } else { // Some sort of delayed death |
| 1225 | |
| 1226 | // For upside-down walkers, force simple delay |
| 1227 | bool f_upsidedown_walker = (objp->movement_typecxx . . $ object#movement_type. == MT_WALKINGcxx . . $ `Descent3/object_external.h:235:9`!) && (objp->orientcxx . . $ object#orient..uveccxx . . $ matrix#uvec..ycxx . . $ vector#y. < 0.0f); |
| 1228 | if (f_upsidedown_walker) |
| 1229 | death_flags |= DF_DELAY_LOSES_ANTIGRAVcxx . . $ `Descent3/deathinfo_external.h:69:9`!; |
| 1230 | |
| 1231 | // Set dying control |
| 1232 | int old_control_type = objp->control_typecxx . . $ object#control_type.; |
| 1233 | SetObjectControlTypecxx . . $ SetObjectControlType(766a1b7183ffa4b4).(objp, CT_DYINGcxx . . $ `Descent3/object_external.h:229:9`!); |
| 1234 | |
| 1235 | // Set dying flags |
| 1236 | objp->ctypecxx . . $ object#ctype..dying_infocxx . . $ object#$anonymous_type_9#dying_info..death_flagscxx . . $ dying_info_s#death_flags. = death_flags; |
| 1237 | objp->ctypecxx . . $ object#ctype..dying_infocxx . . $ object#$anonymous_type_9#dying_info..last_smoke_timecxx . . $ dying_info_s#last_smoke_time. = -1; |
| 1238 | objp->ctypecxx . . $ object#ctype..dying_infocxx . . $ object#$anonymous_type_9#dying_info..last_spark_timecxx . . $ dying_info_s#last_spark_time. = -1; |
| 1239 | objp->ctypecxx . . $ object#ctype..dying_infocxx . . $ object#$anonymous_type_9#dying_info..last_fireball_timecxx . . $ dying_info_s#last_fireball_time. = -1; |
| 1240 | |
| 1241 | // If the killer is a player, save so can add score when the object dies |
| 1242 | if (killer && (killer->typecxx . . $ object#type. == OBJ_PLAYERcxx . . $ `Descent3/object_external.h:164:9`!) && IS_GENERICcxx . . $ `Descent3/object_external.h:190:9`!(objp->type)) |
| 1243 | objp->ctypecxx . . $ object#ctype..dying_infocxx . . $ object#$anonymous_type_9#dying_info..killer_playernumcxx . . $ dying_info_s#killer_playernum. = killer->idcxx . . $ object#id.; |
| 1244 | else |
| 1245 | objp->ctypecxx . . $ object#ctype..dying_infocxx . . $ object#$anonymous_type_9#dying_info..killer_playernumcxx . . $ dying_info_s#killer_playernum. = -1; |
| 1246 | |
| 1247 | // Set the timer |
| 1248 | objp->ctypecxx . . $ object#ctype..dying_infocxx . . $ object#$anonymous_type_9#dying_info..delay_timecxx . . $ dying_info_s#delay_time. = delay_time; |
| 1249 | |
| 1250 | // If loses anti-grav, set physics so object falls |
| 1251 | if (death_flags & DF_DELAY_LOSES_ANTIGRAVcxx . . $ `Descent3/deathinfo_external.h:69:9`!) |
| 1252 | SetFallingPhysicscxx . . $ SetFallingPhysics(419c470199a90a97).(objp); |
| 1253 | |
| 1254 | // Deal with some goal stuff. Ask Chris about this |
| 1255 | if ((objp->typecxx . . $ object#type. == OBJ_ROBOTcxx . . $ `Descent3/object_external.h:162:9`!) || ((objp->typecxx . . $ object#type. == OBJ_BUILDINGcxx . . $ `Descent3/object_external.h:176:9`!) && objp->ai_infocxx . . $ object#ai_info.)) { |
| 1256 | if ((old_control_type == CT_AIcxx . . $ `Descent3/object_external.h:217:9`!) && |
| 1257 | (Object_infocxx . . $ Object_info.[objp->idcxx . . $ object#id.].animcxx . . $ object_info#anim.[objp->ai_infocxx . . $ object#ai_info.->movement_typecxx . . $ ai_frame#movement_type.].elemcxx . . $ anim_elem#elem.[AS_DEATHcxx . . $ `Descent3/aistruct_external.h:410:9`!].tocxx . . $ anim_entry#to. != 0.0f)) { |
| 1258 | SetObjectControlTypecxx . . $ SetObjectControlType(766a1b7183ffa4b4).(objp, CT_DYING_AND_AIcxx . . $ `Descent3/object_external.h:230:9`!); |
| 1259 | int next_anim = AS_DEATHcxx . . $ `Descent3/aistruct_external.h:410:9`!; |
| 1260 | GoalAddGoalcxx . . $ GoalAddGoal(e0a3c222b6aee5c7).(objp, AIG_SET_ANIMcxx . . $ `Descent3/aistruct_external.h:196:9`!, (void *)&next_anim, ACTIVATION_BLEND_LEVELcxx . . $ `Descent3/aistruct_external.h:280:9`!); |
| 1261 | mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Start dying anim "); |
| 1262 | } |
| 1263 | } |
| 1264 | |
| 1265 | // Deal with objects that fly |
| 1266 | if (death_flags & DF_DELAY_FLYINGcxx . . $ `Descent3/deathinfo_external.h:71:9`!) { |
| 1267 | SetFlyingPhysicscxx . . $ SetFlyingPhysics(674fac047436fc5b).(objp, !(death_flags & DF_DELAY_NO_TUMBLE_FLYcxx . . $ `Descent3/deathinfo_external.h:74:9`!)); |
| 1268 | |
| 1269 | // Create a fireball |
| 1270 | if (death_flags & DF_FIREBALLcxx . . $ `Descent3/deathinfo_external.h:77:9`!) |
| 1271 | CreateObjectFireballcxx . . $ CreateObjectFireball(13824ead50669dc7).(objp); |
| 1272 | } |
| 1273 | |
| 1274 | // Deal with objects that fade out |
| 1275 | if (death_flags & DF_DELAY_FADE_AWAYcxx . . $ `Descent3/deathinfo_external.h:73:9`!) { |
| 1276 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(objp->effect_info != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!); |
| 1277 | objp->effect_infocxx . . $ object#effect_info.->type_flagscxx . . $ effect_info_s#type_flags. |= EF_FADING_OUTcxx . . $ `Descent3/object_external.h:207:9`!; |
| 1278 | objp->effect_infocxx . . $ object#effect_info.->fade_timecxx . . $ effect_info_s#fade_time. = objp->effect_infocxx . . $ object#effect_info.->fade_max_timecxx . . $ effect_info_s#fade_max_time. = objp->ctypecxx . . $ object#ctype..dying_infocxx . . $ object#$anonymous_type_9#dying_info..delay_timecxx . . $ dying_info_s#delay_time.; |
| 1279 | } |
| 1280 | |
| 1281 | // Play the sound now if flagged to do so |
| 1282 | if (death_flags & DF_DELAY_SOUNDcxx . . $ `Descent3/deathinfo_external.h:106:9`!) |
| 1283 | PlayObjectExplosionSoundcxx . . $ PlayObjectExplosionSound(419c470199a90a97).(objp); |
| 1284 | // else if (death_flags & DF_DELAY_SPARKS) //If no special sound & doing sparks, play sparks sound |
| 1285 | // Sound_system.Play3dSound(SOUND_ELECTRICAL_DEATH, SND_PRIORITY_NORMAL, objp); |
| 1286 | } |
| 1287 | } |
| 1288 | |
| 1289 | // Applies damage to robot objects. Handled differently than damage to players for obvious reasons. |
| 1290 | bool ApplyDamageToGenericcxx . . $ ApplyDamageToGeneric(5474b9d0c3697015).(objectcxx . . $ object# *hit_obj, objectcxx . . $ object# *killer, int damage_type, float damage, int server_says, |
| 1291 | int weapon_id) { |
| 1292 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(hit_obj != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!); |
| 1293 | |
| 1294 | if (hit_obj->typecxx . . $ object#type. == OBJ_DUMMYcxx . . $ `Descent3/object_external.h:181:9`!) { |
| 1295 | // as per ChrisP, dummies should be ignored here |
| 1296 | return false; |
| 1297 | } |
| 1298 | |
| 1299 | if (hit_obj->flagscxx . . $ object#flags. & OF_AI_DEATHcxx . . $ `Descent3/object_external.h:293:9`!) { |
| 1300 | return false; |
| 1301 | } |
| 1302 | |
| 1303 | // I don't think there's any problem with calling this function on an object that's not a generic |
| 1304 | // or a door, but I don't see why you would. |
| 1305 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(IS_GENERICcxx . . $ `Descent3/object_external.h:190:9`!(hit_obj->type) || (hit_obj->type == OBJ_DOORcxx . . $ `Descent3/object_external.h:177:9`!)); |
| 1306 | |
| 1307 | objectcxx . . $ object# *weapon_obj = killer; |
| 1308 | |
| 1309 | if (damage_type != GD_SCRIPTEDcxx . . $ `Descent3/damage_external.h:32:9`! && |
| 1310 | !(IS_GENERICcxx . . $ `Descent3/object_external.h:190:9`!(hit_obj->type) && (Object_infocxx . . $ Object_info.[hit_obj->idcxx . . $ object#id.].flagscxx . . $ object_info#flags. & OIF_NO_DIFF_SCALE_DAMAGEcxx . . $ `Descent3/objinfo.h:344:9`!))) |
| 1311 | damage *= Diff_robot_damagecxx . . $ Diff_robot_damage.[DIFF_LEVELcxx . . $ `Descent3/difficulty.h:29:9`!]; |
| 1312 | |
| 1313 | if (killer != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`! && killer->typecxx . . $ object#type. == OBJ_WEAPONcxx . . $ `Descent3/object_external.h:165:9`!) { |
| 1314 | killer = ObjGetUltimateParentcxx . . $ ObjGetUltimateParent(64a00b84ed3f82ee).(killer); |
| 1315 | |
| 1316 | if (!(Game_modecxx . . $ Game_mode. & GM_MULTIcxx . . $ `Descent3/game.h:288:9`!) || (Game_modecxx . . $ Game_mode. & GM_MULTIcxx . . $ `Descent3/game.h:288:9`! && Netgamecxx . . $ Netgame..local_rolecxx . . $ netgame_info#local_role. == LR_SERVERcxx . . $ `Descent3/multi_external.h:129:9`!)) |
| 1317 | weapon_id = weapon_obj->idcxx . . $ object#id.; |
| 1318 | } |
| 1319 | |
| 1320 | if (hit_obj->flagscxx . . $ object#flags. & OF_DESTROYABLEcxx . . $ `Descent3/object_external.h:279:9`! && (!(hit_obj->flagscxx . . $ object#flags. & OF_USE_DESTROYED_POLYMODELcxx . . $ `Descent3/object_external.h:283:9`!))) { |
| 1321 | if ((Game_modecxx . . $ Game_mode. & GM_MULTIcxx . . $ `Descent3/game.h:288:9`!) && (hit_obj->flagscxx . . $ object#flags. & OF_DESTROYEDcxx . . $ `Descent3/object_external.h:271:9`!)) { |
| 1322 | return false; // This object has already been sent to the server to be blown up! |
| 1323 | } |
| 1324 | |
| 1325 | if (hit_obj->typecxx . . $ object#type. == OBJ_POWERUPcxx . . $ `Descent3/object_external.h:167:9`! && (Game_modecxx . . $ Game_mode. & GM_MULTIcxx . . $ `Descent3/game.h:288:9`!)) |
| 1326 | return false; |
| 1327 | |
| 1328 | if ((!(Game_modecxx . . $ Game_mode. & GM_MULTIcxx . . $ `Descent3/game.h:288:9`!)) || server_says || ((Netgamecxx . . $ Netgame..local_rolecxx . . $ netgame_info#local_role. == LR_SERVERcxx . . $ `Descent3/multi_external.h:129:9`!) && (Game_modecxx . . $ Game_mode. & GM_MULTIcxx . . $ `Descent3/game.h:288:9`!))) { |
| 1329 | tOSIRISEventInfocxx . . $ tOSIRISEventInfo# ei; |
| 1330 | if (killer != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!) |
| 1331 | ei.evt_damagedcxx . . $ tOSIRISEventInfo#$anonymous_type_1#evt_damaged..it_handlecxx . . $ tOSIRISEVTDAMAGED#it_handle. = killer->handlecxx . . $ object#handle.; |
| 1332 | else |
| 1333 | ei.evt_damagedcxx . . $ tOSIRISEventInfo#$anonymous_type_1#evt_damaged..it_handlecxx . . $ tOSIRISEVTDAMAGED#it_handle. = OBJECT_HANDLE_NONEcxx . . $ `Descent3/object_external.h:156:9`!; |
| 1334 | |
| 1335 | if (weapon_obj) |
| 1336 | ei.evt_damagedcxx . . $ tOSIRISEventInfo#$anonymous_type_1#evt_damaged..weapon_handlecxx . . $ tOSIRISEVTDAMAGED#weapon_handle. = weapon_obj->handlecxx . . $ object#handle.; |
| 1337 | else |
| 1338 | ei.evt_damagedcxx . . $ tOSIRISEventInfo#$anonymous_type_1#evt_damaged..weapon_handlecxx . . $ tOSIRISEVTDAMAGED#weapon_handle. = OBJECT_HANDLE_NONEcxx . . $ `Descent3/object_external.h:156:9`!; |
| 1339 | |
| 1340 | ei.evt_damagedcxx . . $ tOSIRISEventInfo#$anonymous_type_1#evt_damaged..damage_typecxx . . $ tOSIRISEVTDAMAGED#damage_type. = damage_type; |
| 1341 | ei.evt_damagedcxx . . $ tOSIRISEventInfo#$anonymous_type_1#evt_damaged..damagecxx . . $ tOSIRISEVTDAMAGED#damage. = damage; |
| 1342 | Osiris_CallEventcxx . . $ Osiris_CallEvent(91e8d3045aa5549c).(hit_obj, EVT_DAMAGEDcxx . . $ `scripts/osiris_common.h:365:9`!, &ei); |
| 1343 | |
| 1344 | // This statement allows a robot to have special resistances or vulerabilites to damage types |
| 1345 | damage = ei.evt_damagedcxx . . $ tOSIRISEventInfo#$anonymous_type_1#evt_damaged..damagecxx . . $ tOSIRISEVTDAMAGED#damage.; |
| 1346 | if (damage == 0.0f) { |
| 1347 | return false; |
| 1348 | } |
| 1349 | |
| 1350 | hit_obj->shieldscxx . . $ object#shields. -= damage; |
| 1351 | |
| 1352 | if (Game_modecxx . . $ Game_mode. & GM_MULTIcxx . . $ `Descent3/game.h:288:9`!) { // only the server will be calling this |
| 1353 | if (killer != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!) |
| 1354 | DLLInfocxx . . $ DLLInfo..it_handlecxx . . $ dllinfo#it_handle. = killer->handlecxx . . $ object#handle.; |
| 1355 | else |
| 1356 | DLLInfocxx . . $ DLLInfo..it_handlecxx . . $ dllinfo#it_handle. = OBJECT_HANDLE_NONEcxx . . $ `Descent3/object_external.h:156:9`!; |
| 1357 | |
| 1358 | DLLInfocxx . . $ DLLInfo..me_handlecxx . . $ dllinfo#me_handle. = hit_obj->handlecxx . . $ object#handle.; |
| 1359 | DLLInfocxx . . $ DLLInfo..fParamcxx . . $ dllinfo#fParam. = damage; |
| 1360 | CallGameDLLcxx . . $ CallGameDLL(32ca0c0c7dbc2fcf).(EVT_GAMEOBJECTSHIELDSCHANGEDcxx . . $ `lib/d3events.h:75:9`!, &DLLInfocxx . . $ DLLInfo.); |
| 1361 | } |
| 1362 | } |
| 1363 | if ((Game_modecxx . . $ Game_mode. & GM_MULTIcxx . . $ `Descent3/game.h:288:9`!) && (Netgamecxx . . $ Netgame..local_rolecxx . . $ netgame_info#local_role. == LR_SERVERcxx . . $ `Descent3/multi_external.h:129:9`!)) { |
| 1364 | // Let everyone know about the damage |
| 1365 | MultiSendDamageObjectcxx . . $ MultiSendDamageObject(3a7735745f872cae).(hit_obj, killer, damage, weapon_id); |
| 1366 | } |
| 1367 | |
| 1368 | if ((hit_obj->shieldscxx . . $ object#shields. < 0) && (hit_obj->flagscxx . . $ object#flags. & OF_AI_DO_DEATHcxx . . $ `Descent3/object_external.h:275:9`!)) { |
| 1369 | hit_obj->shieldscxx . . $ object#shields. = 0; |
| 1370 | hit_obj->flagscxx . . $ object#flags. |= OF_AI_DEATHcxx . . $ `Descent3/object_external.h:293:9`!; |
| 1371 | } |
| 1372 | |
| 1373 | if ((hit_obj->shieldscxx . . $ object#shields. < 0) && !(hit_obj->flagscxx . . $ object#flags. & OF_DYINGcxx . . $ `Descent3/object_external.h:282:9`!)) { |
| 1374 | // CURRRENTLY - atttached objects remain attached when dying (it looks better) -- chrishack |
| 1375 | // if (!((Game_mode & GM_MULTI) && (Netgame.local_role == LR_CLIENT))) |
| 1376 | // { |
| 1377 | // // Attached objects have a 50% chance of falling off their parent when they die |
| 1378 | // if(ps_rand() >= (D3_RAND_MAX >> 1)) |
| 1379 | // { |
| 1380 | // UnattachFromParent(hit_obj); |
| 1381 | // } |
| 1382 | // } |
| 1383 | |
| 1384 | if (Game_modecxx . . $ Game_mode. & GM_MULTIcxx . . $ `Descent3/game.h:288:9`!) { |
| 1385 | |
| 1386 | DLLInfocxx . . $ DLLInfo..me_handlecxx . . $ dllinfo#me_handle. = hit_obj->handlecxx . . $ object#handle.; |
| 1387 | DLLInfocxx . . $ DLLInfo..it_handlecxx . . $ dllinfo#it_handle. = (killer) ? killer->handlecxx . . $ object#handle. : OBJECT_HANDLE_NONEcxx . . $ `Descent3/object_external.h:156:9`!; |
| 1388 | CallGameDLLcxx . . $ CallGameDLL(32ca0c0c7dbc2fcf).(EVT_GAMEOBJKILLEDcxx . . $ `lib/d3events.h:81:9`!, &DLLInfocxx . . $ DLLInfo.); |
| 1389 | |
| 1390 | if (Netgamecxx . . $ Netgame..local_rolecxx . . $ netgame_info#local_role. == LR_SERVERcxx . . $ `Descent3/multi_external.h:129:9`!) |
| 1391 | KillObjectcxx . . $ KillObject(bdb088234d4582fb).(hit_obj, killer, damage); |
| 1392 | } else { |
| 1393 | // music hook |
| 1394 | if (killer && killer->typecxx . . $ object#type. == OBJ_PLAYERcxx . . $ `Descent3/object_external.h:164:9`! && hit_obj->ai_infocxx . . $ object#ai_info.) { |
| 1395 | if (hit_obj->ai_infocxx . . $ object#ai_info.->awarenesscxx . . $ ai_frame#awareness. > AWARE_BARELYcxx . . $ `Descent3/aistruct_external.h:326:9`! && hit_obj->ai_infocxx . . $ object#ai_info.->target_handlecxx . . $ ai_frame#target_handle. == killer->handlecxx . . $ object#handle.) |
| 1396 | Game_music_infocxx . . $ Game_music_info..n_hostiles_player_killedcxx . . $ tMusicSeqInfo#n_hostiles_player_killed.++; |
| 1397 | } |
| 1398 | |
| 1399 | if (Demo_flagscxx . . $ Demo_flags. != DF_PLAYBACKcxx . . $ `lib/demofile.h:123:9`!) |
| 1400 | KillObjectcxx . . $ KillObject(bdb088234d4582fb).(hit_obj, killer, damage); |
| 1401 | } |
| 1402 | } |
| 1403 | |
| 1404 | if ((!(Game_modecxx . . $ Game_mode. & GM_MULTIcxx . . $ `Descent3/game.h:288:9`!)) || server_says || ((Netgamecxx . . $ Netgame..local_rolecxx . . $ netgame_info#local_role. == LR_SERVERcxx . . $ `Descent3/multi_external.h:129:9`!) && (Game_modecxx . . $ Game_mode. & GM_MULTIcxx . . $ `Descent3/game.h:288:9`!))) { |
| 1405 | if (weapon_id != 255) { |
| 1406 | if (Weaponscxx . . $ Weapons.[weapon_id].flagscxx . . $ weapon#flags. & WF_MICROWAVEcxx . . $ `Descent3/weapon.h:237:9`!) |
| 1407 | SetDeformDamageEffectcxx . . $ SetDeformDamageEffect(419c470199a90a97).(hit_obj); |
| 1408 | if (Weaponscxx . . $ Weapons.[weapon_id].flagscxx . . $ weapon#flags. & WF_NAPALMcxx . . $ `Descent3/weapon.h:238:9`!) |
| 1409 | SetNapalmDamageEffectcxx . . $ SetNapalmDamageEffect(6964148eab73f28a).(hit_obj, killer, weapon_id); |
| 1410 | if (Weaponscxx . . $ Weapons.[weapon_id].flagscxx . . $ weapon#flags. & WF_FREEZEcxx . . $ `Descent3/weapon.h:243:9`!) |
| 1411 | ApplyFreezeDamageEffectcxx . . $ ApplyFreezeDamageEffect(419c470199a90a97).(hit_obj); |
| 1412 | } |
| 1413 | return true; |
| 1414 | } |
| 1415 | return false; |
| 1416 | } else |
| 1417 | return false; |
| 1418 | } |
| 1419 | |
| 1420 | // Adds a bit of shake to the camera |
| 1421 | void AddToShakeMagnitudecxx . . $ AddToShakeMagnitude(9364e6e7bff7660).(float delta) { |
| 1422 | |
| 1423 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(delta >= 0.0); |
| 1424 | Shake_magnitudecxx . . $ Shake_magnitude. += delta; |
| 1425 | } |
| 1426 | |
| 1427 | // Sets a definite shake to the camera |
| 1428 | void SetShakeMagnitudecxx . . $ SetShakeMagnitude(9364e6e7bff7660).(float delta) { |
| 1429 | |
| 1430 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(delta >= 0.0); |
| 1431 | Shake_magnitudecxx . . $ Shake_magnitude. = delta; |
| 1432 | } |
| 1433 | |
| 1434 | #define MAX_SHAKE_MAGNITUDEcxx . . $ `Descent3/damage.cpp:1434:9`! 120 |
| 1435 | |
| 1436 | // Shakes player by some random amount |
| 1437 | void ShakePlayercxx . . $ ShakePlayer(49f6e7a06ebc5aa8).() { |
| 1438 | if (Shake_magnitudecxx . . $ Shake_magnitude. > MAX_SHAKE_MAGNITUDEcxx . . $ `Descent3/damage.cpp:1434:9`!) |
| 1439 | Shake_magnitudecxx . . $ Shake_magnitude. = MAX_SHAKE_MAGNITUDEcxx . . $ `Descent3/damage.cpp:1434:9`!; |
| 1440 | |
| 1441 | float mag = Shake_magnitudecxx . . $ Shake_magnitude.; |
| 1442 | |
| 1443 | uint16_tcxx . . $ uint16_t# pitch_adjust = ((ps_randcxx . . $ ps_rand(b126dc7c1de90089).() % 5) - 2) * mag; |
| 1444 | uint16_tcxx . . $ uint16_t# bank_adjust = ((ps_randcxx . . $ ps_rand(b126dc7c1de90089).() % 5) - 2) * mag; |
| 1445 | uint16_tcxx . . $ uint16_t# heading_adjust = ((ps_randcxx . . $ ps_rand(b126dc7c1de90089).() % 5) - 2) * mag; |
| 1446 | matrixcxx . . $ matrix# m, tempm; |
| 1447 | |
| 1448 | Old_player_orientcxx . . $ Old_player_orient. =cxx . . $ matrix#`operator=`(4c6f8b29806742). Player_objectcxx . . $ Player_object.->orientcxx . . $ object#orient.; |
| 1449 | |
| 1450 | if (Shake_magnitudecxx . . $ Shake_magnitude. < .00001) |
| 1451 | return; |
| 1452 | |
| 1453 | vm_AnglesToMatrixcxx . . $ vm_AnglesToMatrix(654fa9e3c9c3be99).(&m, pitch_adjust, heading_adjust, bank_adjust); |
| 1454 | |
| 1455 | DoForceForShakecxx . . $ DoForceForShake(9364e6e7bff7660).(Shake_magnitudecxx . . $ Shake_magnitude.); |
| 1456 | Shake_magnitudecxx . . $ Shake_magnitude. -= (Frametimecxx . . $ Frametime. * (MAX_SHAKE_MAGNITUDEcxx . . $ `Descent3/damage.cpp:1434:9`! / 3)); |
| 1457 | |
| 1458 | if (Shake_magnitudecxx . . $ Shake_magnitude. < 0) |
| 1459 | Shake_magnitudecxx . . $ Shake_magnitude. = 0.0; |
| 1460 | |
| 1461 | tempm =cxx . . $ matrix#`operator=`(e859ffc26b91394f). m *cxx . . $ `operator*`(683f8e040c904cb). Player_objectcxx . . $ Player_object.->orientcxx . . $ object#orient.; |
| 1462 | |
| 1463 | ObjSetOrientcxx . . $ ObjSetOrient(e1367e0f901c991f).(Player_objectcxx . . $ Player_object., &tempm); |
| 1464 | } |
| 1465 | |
| 1466 | // Restores the player orientation matrix after shaking |
| 1467 | void UnshakePlayercxx . . $ UnshakePlayer(49f6e7a06ebc5aa8).() { ObjSetOrientcxx . . $ ObjSetOrient(e1367e0f901c991f).(Player_objectcxx . . $ Player_object., &Old_player_orientcxx . . $ Old_player_orient.); } |
| 1468 | |
| 1469 | #include "terrain.h"cxx . . $ `<file>/Descent3/terrain.h`/ |
| 1470 | #include "collide.h"cxx . . $ `<file>/physics/collide.h`/ |
| 1471 | |
| 1472 | #define SHARD_MAX_EDGE_LENcxx . . $ `Descent3/damage.cpp:1472:9`! 3.0f |
| 1473 | |
| 1474 | // Break the specified (glass) face into shards |
| 1475 | // Parameters: rp, facenum - the face to break. The face must be a portal face. |
| 1476 | // hitpnt - the point on the face where the face shatters. If NULL, uses center |
| 1477 | // point of |
| 1478 | // face hitvec - the direction in which the thing that's breaking the glass is |
| 1479 | // moving. If NULL, uses the negative of the surface normal |
| 1480 | void BreakGlassFacecxx . . $ BreakGlassFace(13a53ec972efd3cd).(roomcxx . . $ room# *rp, int facenum, vectorcxx . . $ vector# *hitpnt, vectorcxx . . $ vector# *hitvec) { |
| 1481 | int roomnum; |
| 1482 | vectorcxx . . $ vector# t_hitpnt, t_hitvec; |
| 1483 | facecxx . . $ face# *fp = &rp->facescxx . . $ room#faces.[facenum]; |
| 1484 | |
| 1485 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(fp->portal_num != -1); |
| 1486 | portalcxx . . $ portal# *pp0 = &rp->portalscxx . . $ room#portals.[fp->portal_numcxx . . $ face#portal_num.]; |
| 1487 | portalcxx . . $ portal# *pp1 = &Roomscxx . . $ Rooms.[pp0->croomcxx . . $ portal#croom.].portalscxx . . $ room#portals.[pp0->cportalcxx . . $ portal#cportal.]; |
| 1488 | |
| 1489 | // If face already broken, bail |
| 1490 | if (!(pp0->flagscxx . . $ portal#flags. & PF_RENDER_FACEScxx . . $ `Descent3/room_external.h:155:9`!)) |
| 1491 | return; |
| 1492 | |
| 1493 | // Set hitpnt if not specified |
| 1494 | if (hitpnt == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!) { |
| 1495 | ComputeCenterPointOnFacecxx . . $ ComputeCenterPointOnFace(3ca293c02dfae4e1).(&t_hitpnt, rp, facenum); |
| 1496 | hitpnt = &t_hitpnt; |
| 1497 | } |
| 1498 | |
| 1499 | // Set hitvec if not specified |
| 1500 | if (hitvec == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!) { |
| 1501 | t_hitvec =cxx . . $ vector#`operator=`(c0842353a20857d). -cxx . . $ operator-(9e07539e219c6f20).fp->normalcxx . . $ face#normal.; |
| 1502 | hitvec = &t_hitvec; |
| 1503 | } |
| 1504 | |
| 1505 | // Get roomnum |
| 1506 | if (rp->flagscxx . . $ room#flags. & RF_EXTERNALcxx . . $ `Descent3/room_external.h:177:9`!) |
| 1507 | roomnum = MAKE_ROOMNUMcxx . . $ `lib/object_external_struct.h:124:9`!(GetTerrainCellFromPos(hitpnt)); |
| 1508 | else |
| 1509 | roomnum = ROOMNUMcxx . . $ `Descent3/room.h:411:9`!(rp); |
| 1510 | |
| 1511 | // Play sound |
| 1512 | pos_statecxx . . $ pos_state# pos; |
| 1513 | pos.positioncxx . . $ pos_state#position. = hitpnt; |
| 1514 | pos.orientcxx . . $ pos_state#orient. = (matrixcxx . . $ matrix# *)&Identity_matrixcxx . . $ Identity_matrix.; |
| 1515 | pos.roomnumcxx . . $ pos_state#roomnum. = roomnum; |
| 1516 | |
| 1517 | if (sound_override_glass_breakingcxx . . $ sound_override_glass_breaking. == -1) |
| 1518 | Sound_systemcxx . . $ Sound_system..Play3dSoundcxx . . $ hlsSystem#Play3dSound(cbd2c6aa1db9fc8a).(SOUND_BREAKING_GLASScxx . . $ `Descent3/sounds.h:110:9`!, SND_PRIORITY_HIGHcxx . . $ `sndlib/ssl_lib.h:283:9`!, &pos); |
| 1519 | else |
| 1520 | Sound_systemcxx . . $ Sound_system..Play3dSoundcxx . . $ hlsSystem#Play3dSound(cbd2c6aa1db9fc8a).(sound_override_glass_breakingcxx . . $ sound_override_glass_breaking., SND_PRIORITY_HIGHcxx . . $ `sndlib/ssl_lib.h:283:9`!, &pos); |
| 1521 | |
| 1522 | // Clear render flags |
| 1523 | pp0->flagscxx . . $ portal#flags. &= ~PF_RENDER_FACEScxx . . $ `Descent3/room_external.h:155:9`!; |
| 1524 | pp1->flagscxx . . $ portal#flags. &= ~PF_RENDER_FACEScxx . . $ `Descent3/room_external.h:155:9`!; |
| 1525 | |
| 1526 | // Get the UV for the hit point |
| 1527 | float hitpnt_u, hitpnt_v; |
| 1528 | FindHitpointUVcxx . . $ FindHitpointUV(7a2228cd553a361c).(&hitpnt_u, &hitpnt_v, hitpnt, rp, facenum); |
| 1529 | |
| 1530 | // Calculate shard movement vector |
| 1531 | vectorcxx . . $ vector# shardvec = *hitvec; |
| 1532 | vm_NormalizeVectorFastcxx . . $ vm_NormalizeVectorFast(4939a7e530383cd4).(&shardvec); |
| 1533 | |
| 1534 | // Create shards |
| 1535 | vectorcxx . . $ vector# prevpoint = rp->vertscxx . . $ room#verts.[fp->face_vertscxx . . $ face#face_verts.[fp->num_vertscxx . . $ face#num_verts. - 1]]; |
| 1536 | float prev_u = fp->face_uvlscxx . . $ face#face_uvls.[fp->num_vertscxx . . $ face#num_verts. - 1].ucxx . . $ roomUVL#u., prev_v = fp->face_uvlscxx . . $ face#face_uvls.[fp->num_vertscxx . . $ face#num_verts. - 1].vcxx . . $ roomUVL#v.; |
| 1537 | for (int vertnum = 0; vertnum < fp->num_vertscxx . . $ face#num_verts.;) { |
| 1538 | int objnum; |
| 1539 | vectorcxx . . $ vector# curpoint = rp->vertscxx . . $ room#verts.[fp->face_vertscxx . . $ face#face_verts.[vertnum]], center; |
| 1540 | float cur_u = fp->face_uvlscxx . . $ face#face_uvls.[vertnum].ucxx . . $ roomUVL#u., cur_v = fp->face_uvlscxx . . $ face#face_uvls.[vertnum].vcxx . . $ roomUVL#v.; |
| 1541 | |
| 1542 | // Check if should split edge |
| 1543 | if (vm_VectorDistanceQuickcxx . . $ vm_VectorDistanceQuick(a0b9c8659ecc16b8).(&prevpoint, &curpoint) > SHARD_MAX_EDGE_LENcxx . . $ `Descent3/damage.cpp:1472:9`!) { |
| 1544 | curpoint =cxx . . $ vector#`operator=`(c0842353a20857d). (curpoint +cxx . . $ operator+(b77b703cd1e43e33). prevpoint) /cxx . . $ `operator/`(252247219a31502c). 2; |
| 1545 | cur_u = (cur_u + prev_u) / 2; |
| 1546 | cur_v = (cur_v + prev_v) / 2; |
| 1547 | } else // no split |
| 1548 | vertnum++; |
| 1549 | |
| 1550 | // Calculate the center point |
| 1551 | center =cxx . . $ vector#`operator=`(c0842353a20857d). (curpoint +cxx . . $ operator+(b77b703cd1e43e33). prevpoint +cxx . . $ operator+(b77b703cd1e43e33). *hitpnt) /cxx . . $ `operator/`(252247219a31502c). 3.0; |
| 1552 | |
| 1553 | // Create the object |
| 1554 | objnum = ObjCreatecxx . . $ ObjCreate(849c3da80a4f387f).(OBJ_SHARDcxx . . $ `Descent3/object_external.h:163:9`!, 0, roomnum, ¢er, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!); |
| 1555 | |
| 1556 | // Setup shard info |
| 1557 | if (objnum != -1) { |
| 1558 | objectcxx . . $ object# *objp = &Objectscxx . . $ Objects.[objnum]; |
| 1559 | shard_info_scxx . . $ shard_info_s# *si = &objp->rtypecxx . . $ object#rtype..shard_infocxx . . $ object#$anonymous_type_10#shard_info.; |
| 1560 | |
| 1561 | si->pointscxx . . $ shard_info_s#points.[0] =cxx . . $ vector#`operator=`(c0842353a20857d). prevpoint -cxx . . $ operator-(b77b703cd1e43e33). objp->poscxx . . $ object#pos.; |
| 1562 | si->pointscxx . . $ shard_info_s#points.[1] =cxx . . $ vector#`operator=`(c0842353a20857d). curpoint -cxx . . $ operator-(b77b703cd1e43e33). objp->poscxx . . $ object#pos.; |
| 1563 | si->pointscxx . . $ shard_info_s#points.[2] =cxx . . $ vector#`operator=`(c0842353a20857d). *hitpnt -cxx . . $ operator-(b77b703cd1e43e33). objp->poscxx . . $ object#pos.; |
| 1564 | |
| 1565 | si->ucxx . . $ shard_info_s#u.[0] = prev_u; |
| 1566 | si->vcxx . . $ shard_info_s#v.[0] = prev_v; |
| 1567 | si->ucxx . . $ shard_info_s#u.[1] = cur_u; |
| 1568 | si->vcxx . . $ shard_info_s#v.[1] = cur_v; |
| 1569 | si->ucxx . . $ shard_info_s#u.[2] = hitpnt_u; |
| 1570 | si->vcxx . . $ shard_info_s#v.[2] = hitpnt_v; |
| 1571 | |
| 1572 | si->normalcxx . . $ shard_info_s#normal. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). fp->normalcxx . . $ face#normal.; |
| 1573 | si->tmapcxx . . $ shard_info_s#tmap. = fp->tmapcxx . . $ face#tmap.; |
| 1574 | |
| 1575 | // Set velocity |
| 1576 | objp->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..velocitycxx . . $ physics_info#velocity. =cxx . . $ vector#`operator=`(c0842353a20857d). shardvec *cxx . . $ `operator*`(252247219a31502c). (50.0 + 100.0 * (objnum % 3)); |
| 1577 | |
| 1578 | // Set rotational velocity |
| 1579 | objp->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..rotvelcxx . . $ physics_info#$anonymous_type_1#rotvel..xcxx . . $ vector#x. = 25000.0 * (objnum % 5); |
| 1580 | objp->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..rotvelcxx . . $ physics_info#$anonymous_type_1#rotvel..ycxx . . $ vector#y. = 25000.0 * (objnum % 2); |
| 1581 | objp->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..rotvelcxx . . $ physics_info#$anonymous_type_1#rotvel..zcxx . . $ vector#z. = 25000.0 * (objnum % 3); |
| 1582 | |
| 1583 | prevpoint =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). curpoint; |
| 1584 | prev_u = cur_u; |
| 1585 | prev_v = cur_v; |
| 1586 | } |
| 1587 | } |
| 1588 | |
| 1589 | // Do multiplayer stuff |
| 1590 | if ((Game_modecxx . . $ Game_mode. & GM_MULTIcxx . . $ `Descent3/game.h:288:9`!) && Netgamecxx . . $ Netgame..local_rolecxx . . $ netgame_info#local_role. == LR_SERVERcxx . . $ `Descent3/multi_external.h:129:9`!) { |
| 1591 | MultiSendBreakGlasscxx . . $ MultiSendBreakGlass(5c94b6ab436d91cf).(rp, facenum); |
| 1592 | |
| 1593 | if (Num_broke_glasscxx . . $ Num_broke_glass. != MAX_BROKE_GLASScxx . . $ `Descent3/multi.h:750:9`!) { |
| 1594 | Broke_glass_roomscxx . . $ Broke_glass_rooms.[Num_broke_glasscxx . . $ Num_broke_glass.] = rp - Roomscxx . . $ Rooms.; |
| 1595 | Broke_glass_facescxx . . $ Broke_glass_faces.[Num_broke_glasscxx . . $ Num_broke_glass.] = facenum; |
| 1596 | Num_broke_glasscxx . . $ Num_broke_glass.++; |
| 1597 | } |
| 1598 | } |
| 1599 | } |