| 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/physics/Collide.cpp $ |
| 21 | * $Revision: 239 $ |
| 22 | * $Date: 9/20/01 5:33p $ |
| 23 | * $Author: Matt $ |
| 24 | * |
| 25 | * Descent III collision code |
| 26 | * |
| 27 | * $Log: /DescentIII/Main/physics/Collide.cpp $ |
| 28 | * |
| 29 | * 239 9/20/01 5:33p Matt |
| 30 | * Fixed weird omega cannon bugs (I hope) by only letting the omega |
| 31 | * particles collide from inside AquireElectricalTarget(). |
| 32 | * |
| 33 | * 238 11/04/99 5:35p Chris |
| 34 | * Levels with forcefields with a custom bouce sound don't cause damage |
| 35 | * |
| 36 | * 237 10/20/99 5:40p Chris |
| 37 | * Added the Red Guidebot |
| 38 | * |
| 39 | * 236 10/08/99 4:29p Chris |
| 40 | * Added the forcefield and glass breaking override options |
| 41 | * |
| 42 | * 235 5/24/99 1:26a Matt |
| 43 | * Correctly deal with hit_info == NULL being passed to collision |
| 44 | * routines. |
| 45 | * |
| 46 | * 234 5/21/99 2:55a Matt |
| 47 | * When an object is bounced-out and needs to be killed, call |
| 48 | * DestroyObject() if it's already dying. Before the code just set the |
| 49 | * dead flag, which caused robots to disappear if they bumped into |
| 50 | * something while dying. |
| 51 | * |
| 52 | * 233 5/20/99 9:03p Matt |
| 53 | * Changed trigger system so that collisions with rendered portals don't |
| 54 | * set off triggers on the portals. |
| 55 | * |
| 56 | * 232 5/19/99 1:23p Matt |
| 57 | * Fixed (hopefully) yet more collision problems introduced by my recent |
| 58 | * changes. |
| 59 | * |
| 60 | * 231 5/18/99 10:15p Matt |
| 61 | * Fixed bug with weapon spawning that I introduced last night. |
| 62 | * |
| 63 | * 230 5/18/99 10:57a Chris |
| 64 | * Various bug fixes |
| 65 | * |
| 66 | * 229 5/17/99 9:09p Matt |
| 67 | * Made objects with lava behave like walls with lava; flares don't stick, |
| 68 | * player catches on fire. |
| 69 | * |
| 70 | * 228 5/17/99 6:07p Chris |
| 71 | * GB doesn't damage players - PF_LOCK_MASK objects always do... |
| 72 | * |
| 73 | * 227 5/11/99 5:50p Chris |
| 74 | * Buildings don't collide with each other |
| 75 | * |
| 76 | * 226 5/08/99 4:27p Chris |
| 77 | * Hearing code |
| 78 | * |
| 79 | * 225 5/08/99 3:31p Matt |
| 80 | * Deal with weapons hitting water. |
| 81 | * |
| 82 | * 224 5/07/99 10:56p Chris |
| 83 | * GB avoids forcefields, lava, and volatile surfaces... If he accidently |
| 84 | * hits one of these, he ignores the collision (i.e. no effects). It make |
| 85 | * him look smarter. |
| 86 | * |
| 87 | * 223 4/30/99 3:28p Matt |
| 88 | * Weapons now make a special sound when colliding with lava & volatile |
| 89 | * surfaces, instead of the standard hit-wall sound. |
| 90 | * |
| 91 | * 222 4/29/99 6:48p Matt |
| 92 | * Made volatile surfaces apply damage and lava surfaces catch the player |
| 93 | * on fire. Both now generate the steam puff effect. |
| 94 | * |
| 95 | * 221 4/29/99 2:17a Samir |
| 96 | * adjusted some sound priority stuff |
| 97 | * |
| 98 | * 220 4/23/99 6:44p Matt |
| 99 | * Changed weapons to keep going after breaking glass. |
| 100 | * |
| 101 | * 219 4/21/99 4:27p Chris |
| 102 | * |
| 103 | * 218 4/21/99 3:45p Chris |
| 104 | * |
| 105 | * 217 4/21/99 3:43p Chris |
| 106 | * |
| 107 | * 216 4/21/99 2:56p Chris |
| 108 | * Made player-player collisions almost complete in-elastic |
| 109 | * |
| 110 | * 215 4/21/99 1:30p Matt |
| 111 | * Make breakable glass use the new breakable flag, instead of |
| 112 | * piggybacking on the destroyable flag. |
| 113 | * |
| 114 | * 214 4/21/99 11:06a Kevin |
| 115 | * new ps_rand and ps_srand to replace rand & srand |
| 116 | * |
| 117 | * 213 4/21/99 10:12a Chris |
| 118 | * Tweaked robot/player damage |
| 119 | * |
| 120 | * 212 4/21/99 3:33a Chris |
| 121 | * Collisions between robots and players cause damage to both robots and |
| 122 | * players (robots get more damage) |
| 123 | * |
| 124 | * 211 4/19/99 12:03p Jason |
| 125 | * added checking for fireball collisions |
| 126 | * |
| 127 | * 210 4/19/99 4:02a Jeff |
| 128 | * fixed min/max for Linux |
| 129 | * |
| 130 | * 209 4/18/99 10:55p Chris |
| 131 | * Added ignore own concussive blasts |
| 132 | * |
| 133 | * 208 4/16/99 8:18p Jason |
| 134 | * make impact spawning weapons work with doors |
| 135 | * |
| 136 | * 207 4/14/99 1:42a Jeff |
| 137 | * fixed case mismatched #includes |
| 138 | * |
| 139 | * 206 4/12/99 6:15p Samir |
| 140 | * Sound priorities pass 1 |
| 141 | * |
| 142 | * 205 4/06/99 6:24p Jason |
| 143 | * various fixes for multiplayer |
| 144 | * |
| 145 | * 204 3/23/99 4:10p Jason |
| 146 | * more tweaks for line sparks |
| 147 | * |
| 148 | * 203 3/23/99 12:50p Jason |
| 149 | * added line sparks |
| 150 | * |
| 151 | * 202 3/22/99 6:41p Jason |
| 152 | * fixed client side weapons not reacting correctly to bouncing code |
| 153 | * |
| 154 | * 201 3/22/99 1:47p Matt |
| 155 | * Moved breaking glass code from collide.cpp to damage.cpp |
| 156 | * |
| 157 | * 200 3/16/99 4:16p Matt |
| 158 | * Made mass driver spin the victim more. (Jason had reduced it from 0.25 |
| 159 | * to 0.05; I've moved it back up to 0.12 at Andy's request.) |
| 160 | * |
| 161 | * 199 3/12/99 7:46p Jeff |
| 162 | * record wall hit collisions to demo file |
| 163 | * |
| 164 | * 198 3/11/99 5:55p Jason |
| 165 | * fixed player spin with mass driver |
| 166 | * |
| 167 | * 197 3/05/99 2:12p Matt |
| 168 | * Fixed bug (in a slightly hacky way) where energy weapons would cause |
| 169 | * glass to switch to the damaged texture. For a real fix, we need a |
| 170 | * separate breakable glass flag for textures. |
| 171 | * |
| 172 | * 196 3/03/99 10:52a Chris |
| 173 | * Energy weapons push again |
| 174 | * |
| 175 | * 195 3/03/99 5:44a Chris |
| 176 | * Max secondary burn time of 10 seconds |
| 177 | * |
| 178 | * 194 3/01/99 3:18p Jason |
| 179 | * made powerups work correctly in multiplayer |
| 180 | * |
| 181 | * 193 2/28/99 11:29p Chris |
| 182 | * Improved robot-wall reactions |
| 183 | * |
| 184 | * 192 2/22/99 2:03p Jason |
| 185 | * added different damages for players and generics |
| 186 | * |
| 187 | * 191 2/21/99 4:35p Chris |
| 188 | * Improving the level goal system... Not done. |
| 189 | * |
| 190 | * 190 2/20/99 10:31a Kevin |
| 191 | * OEM Beta 1 fixs |
| 192 | * |
| 193 | * 189 2/19/99 12:35p Chris |
| 194 | * Player can fly through markers |
| 195 | * |
| 196 | * 188 2/17/99 4:50p Jason |
| 197 | * fixed destroyable face/breakable glass bug |
| 198 | * |
| 199 | * 187 2/17/99 1:26p Matt |
| 200 | * Fixed the die angle system for weapons (changing it around a little in |
| 201 | * the process: now all non-weapons (which don't use the system) should |
| 202 | * have dot == -1, weapons that die at any angle have dot == 0, and |
| 203 | * setting dot == 1 means it never dies). |
| 204 | * |
| 205 | * 186 2/16/99 8:16a Chris |
| 206 | * Fixed a bug - THANKS! |
| 207 | * |
| 208 | * 185 2/10/99 1:48p Matt |
| 209 | * Changed object handle symbolic constants |
| 210 | * |
| 211 | * 184 2/09/99 2:38p Jason |
| 212 | * added destroyable faces |
| 213 | * |
| 214 | * 183 2/02/99 8:44a Chris |
| 215 | * I made buildings with AI work correctly (ie really big robots should be |
| 216 | * buildings) |
| 217 | * anim to and from states are now shorts instead of bytes |
| 218 | * |
| 219 | * 182 1/31/99 7:26p Matt |
| 220 | * Renamed a bunch of functions to have HUD capitalized |
| 221 | * |
| 222 | * 181 1/29/99 5:09p Chris |
| 223 | * Made changes for ROCKS |
| 224 | * |
| 225 | * 180 1/28/99 6:17p Jason |
| 226 | * added markers |
| 227 | * |
| 228 | * 179 1/26/99 6:39p Jason |
| 229 | * added wall effects code |
| 230 | * |
| 231 | * 178 1/25/99 5:59p Matt |
| 232 | * Patched the masses of objects |
| 233 | * |
| 234 | * 177 1/24/99 8:18p Chris |
| 235 | * Updated AI and OSIRIS. Externalized fireball constants for spew and |
| 236 | * sparks. Added CreateRandomSparks to OSIRIS, renamed a bunch of AI |
| 237 | * Notify names to use underscores. Fixed a memory access leak in the |
| 238 | * matcen effect code. |
| 239 | * |
| 240 | * 176 1/23/99 5:16p Chris |
| 241 | * Bounds fixed acos and asin stuff (-1.0000000000001 could cause really |
| 242 | * bad things to happen with rot. vels) |
| 243 | * |
| 244 | * 175 1/20/99 10:50a Jason |
| 245 | * added new terrain |
| 246 | * |
| 247 | * 174 1/20/99 2:13a Chris |
| 248 | * It is now possible for robots to have special immunities, resistances, |
| 249 | * and vunerabilities |
| 250 | * |
| 251 | * 173 1/18/99 12:12a Jeff |
| 252 | * removed weapon collide event, combined it in general collide event. |
| 253 | * general collide event handles more collides. Added a room collide |
| 254 | * event |
| 255 | * |
| 256 | * 172 1/15/99 3:59a Jeff |
| 257 | * added two new multiplayer DLL events for weapon collisions. Added two |
| 258 | * new fields to DLLInfo data, point and normal, which are filled out for |
| 259 | * collision events. |
| 260 | * |
| 261 | * 170 1/10/99 7:35p Matt |
| 262 | * Added missing break to DO_COLLISION macor |
| 263 | * |
| 264 | * 169 1/10/99 6:49a Jeff |
| 265 | * Some initial work to get linux version to compile |
| 266 | * |
| 267 | * 168 1/08/99 2:56p Samir |
| 268 | * Ripped out OSIRIS1. |
| 269 | * |
| 270 | * 167 1/01/99 4:10p Chris |
| 271 | * Added some const parameters, improved ray cast object collide/rejection |
| 272 | * code |
| 273 | * |
| 274 | * 166 12/21/98 10:50a Chris |
| 275 | * You can now push walking objects |
| 276 | * |
| 277 | * 165 12/17/98 12:08p Jeff |
| 278 | * first checkin of new implementation of OSIRIS (old OSIRIS no longer |
| 279 | * works) |
| 280 | * |
| 281 | * 164 11/19/98 3:54p Chris |
| 282 | * |
| 283 | * 163 11/19/98 3:51p Chris |
| 284 | * Shooting dying robots makes them blow up faster (but now not as |
| 285 | * quickly) |
| 286 | * |
| 287 | * 162 11/13/98 4:25p Jason |
| 288 | * changes for better weapon effects |
| 289 | * |
| 290 | * 161 11/13/98 1:00p Chris |
| 291 | * Fixed a math problem with the new collision response code. Zero rad |
| 292 | * particles where causing i1 or i2 to be zero. c1 = c1/i1 -> it was |
| 293 | * going to infinity. So, I made a floor threshold for i1 and i2 |
| 294 | * |
| 295 | * 160 11/11/98 2:46p Kevin |
| 296 | * Demo recording system work |
| 297 | * |
| 298 | * 159 11/10/98 5:17p Jeff |
| 299 | * peppered in some more forcefeedback effects |
| 300 | * |
| 301 | * 158 10/30/98 5:17p Chris |
| 302 | * Players only get 1/4 the rotational velocity of an impulse |
| 303 | * |
| 304 | * 157 10/29/98 1:45p Chris |
| 305 | * Checked in the better collision response code |
| 306 | * |
| 307 | * 156 10/22/98 12:57p Chris |
| 308 | * Added sounds to player/player and player/robot collisions |
| 309 | * |
| 310 | * 155 10/20/98 1:26p Jason |
| 311 | * took out spawning on direct hits |
| 312 | * |
| 313 | * 154 10/20/98 12:10p Chris |
| 314 | * |
| 315 | * 153 10/19/98 8:38p Matt |
| 316 | * Don't make a sound when colliding with lava, since the lava will start |
| 317 | * you on fire, which will make sound. |
| 318 | * |
| 319 | * 152 10/19/98 7:19p Matt |
| 320 | * Added system to support different types of damage to the player and |
| 321 | * have these different types make different sounds. |
| 322 | * |
| 323 | * 151 10/18/98 2:09p Matt |
| 324 | * Made the backquote/flare thing go away in release versions, and made it |
| 325 | * work for terrain cells. |
| 326 | * |
| 327 | * 150 10/17/98 12:25p Chris |
| 328 | * Fixed attached flares |
| 329 | * |
| 330 | * 149 10/16/98 5:25p Chris |
| 331 | * Fixed sticky code |
| 332 | * |
| 333 | * 148 10/16/98 4:33p Chris |
| 334 | * |
| 335 | * 147 10/16/98 4:18p Chris |
| 336 | * Fixed the 'flare thing' |
| 337 | * |
| 338 | * 146 10/16/98 3:39p Chris |
| 339 | * Improved the object linking system and AI and physics |
| 340 | * |
| 341 | * 145 10/15/98 4:51p Chris |
| 342 | * Speed up dying for player too |
| 343 | * |
| 344 | * 144 10/15/98 4:49p Chris |
| 345 | * Speed up dying if the robot is getting hit |
| 346 | * |
| 347 | * 143 10/12/98 2:27p Matt |
| 348 | * Fixed code to print room:face when backquote/tilde held down and flare |
| 349 | * hits the wall. |
| 350 | * |
| 351 | * 142 10/12/98 10:04a Chris |
| 352 | * Wall hits cannot kill the player |
| 353 | * |
| 354 | * 141 10/09/98 7:57p Chris |
| 355 | * Added the flare room/wall cheat |
| 356 | * |
| 357 | * 140 10/09/98 7:47p Chris |
| 358 | * Added ObjSetDeadFlag |
| 359 | * |
| 360 | * 139 10/08/98 12:00p Kevin |
| 361 | * Demo system work |
| 362 | * |
| 363 | * 138 10/05/98 7:23p Jason |
| 364 | * implemented destroyable lights (first draft) |
| 365 | * |
| 366 | * 137 10/01/98 6:56p Jason |
| 367 | * turned off energy weapon hit effects if the object getting hit is the |
| 368 | * viewer - this helps cut down on the general clutter in heavy combat |
| 369 | * |
| 370 | * 136 9/29/98 4:48p Chris |
| 371 | * Working on multiplayer collisions |
| 372 | * |
| 373 | * 135 9/23/98 5:04p Chris |
| 374 | * Raised the collide wall damage threshold |
| 375 | * |
| 376 | * 134 9/23/98 3:47p Chris |
| 377 | * Increased the speed to cause damage from wall hits |
| 378 | * |
| 379 | * 133 9/22/98 12:23p Chris |
| 380 | * Further improvements to wall hitting |
| 381 | * |
| 382 | * 132 9/21/98 8:32p Chris |
| 383 | * Another improvement to the forcefield stuff |
| 384 | * |
| 385 | * 131 9/21/98 8:19p Chris |
| 386 | * Improved volatile and forcefield hits |
| 387 | * |
| 388 | * 130 9/21/98 1:08p Chris |
| 389 | * Improved lava handling |
| 390 | * |
| 391 | * 129 9/21/98 1:04p Chris |
| 392 | * |
| 393 | * 128 9/21/98 1:03p Chris |
| 394 | * |
| 395 | * 127 9/21/98 1:01p Chris |
| 396 | * Fixed more volatile problems |
| 397 | * |
| 398 | * 126 9/21/98 11:44a Chris |
| 399 | * Fixed the volatile terrain crash bug |
| 400 | * |
| 401 | * 125 9/18/98 7:45p Chris |
| 402 | * Lava works - needs tweaking. |
| 403 | * |
| 404 | * 124 8/25/98 7:27p Chris |
| 405 | * Improved the scorch code |
| 406 | * |
| 407 | * 123 8/25/98 7:23p Chris |
| 408 | * Made weapons explode even if they break glass |
| 409 | * |
| 410 | * 122 8/25/98 12:35p Chris |
| 411 | * Fixed a small reversed normal bug |
| 412 | * |
| 413 | * 121 8/19/98 2:48p Jason |
| 414 | * fixed some weapon firing and weapon exploding bugs |
| 415 | * |
| 416 | * 120 8/18/98 7:12p Chris |
| 417 | * Improved FUSION behavior. |
| 418 | * |
| 419 | * 119 8/12/98 12:26p Chris |
| 420 | * |
| 421 | * 118 8/05/98 11:16a Matt |
| 422 | * Added trigger checks when weapons and the player collide with walls. |
| 423 | * |
| 424 | * 117 8/03/98 5:56p Jason |
| 425 | * got fusion cannon working correctly |
| 426 | * |
| 427 | * 116 7/31/98 11:52a Chris |
| 428 | * Weapons can be persistent. Added ability for objects to be manually |
| 429 | * set for no object collisions. |
| 430 | * |
| 431 | * 115 7/30/98 11:09a Jason |
| 432 | * added weapons that freeze and deform terrain |
| 433 | * |
| 434 | * 114 7/22/98 4:36p Jason |
| 435 | * took out bugs from observer mode |
| 436 | * |
| 437 | * 113 7/17/98 10:12a Chris |
| 438 | * |
| 439 | * 112 7/01/98 12:56p Jason |
| 440 | * more changes for countermeasures |
| 441 | * |
| 442 | * 111 7/01/98 12:12p Jason |
| 443 | * added countermeasures |
| 444 | * |
| 445 | * 110 6/24/98 3:56p Jason |
| 446 | * added code for new omega cannon |
| 447 | * |
| 448 | * 109 6/15/98 3:23p Chris |
| 449 | * Single point walker update |
| 450 | * |
| 451 | * 108 6/15/98 7:53a Chris |
| 452 | * Fixed a comment'ed out variable |
| 453 | * |
| 454 | * 107 6/15/98 7:52a Chris |
| 455 | * Removed the new "cool" physics |
| 456 | * |
| 457 | * 106 6/11/98 12:48p Jason |
| 458 | * added better spewing weapons |
| 459 | * |
| 460 | * 105 6/04/98 12:00p Matt |
| 461 | * Took out Napalm Rocket hack that I added for the E3 demo. |
| 462 | * |
| 463 | * 104 6/02/98 10:43p Chris |
| 464 | * Multipoint collision detection enabled |
| 465 | * |
| 466 | * 103 6/01/98 9:23p Chris |
| 467 | * Fixed a bunch of collision problems |
| 468 | * |
| 469 | * 102 5/27/98 6:18p Matt |
| 470 | * Super hack to reduce impact damage of napalm rocket (for E3 only) |
| 471 | * |
| 472 | * 101 5/27/98 6:08p Chris |
| 473 | * Added weapon to generic sound |
| 474 | * |
| 475 | * 100 5/26/98 4:17p Jason |
| 476 | * made scripts/dlls not collide every single frame |
| 477 | * |
| 478 | * 99 5/26/98 3:58p Matt |
| 479 | * Only matter weapons now break glass. |
| 480 | * |
| 481 | * 98 5/25/98 8:36p Matt |
| 482 | * Added code to set different sizes for different weapon scorch marks. |
| 483 | * Also, don't leave scorch marks on lights. |
| 484 | * |
| 485 | * 97 5/22/98 12:34p Matt |
| 486 | * Added scorch mark/bullet hole system. |
| 487 | * |
| 488 | * 96 5/22/98 11:59a Chris |
| 489 | * Fixed improper uses of FindSoundName and made the proper static sounds |
| 490 | * |
| 491 | * 95 5/19/98 4:42a Chris |
| 492 | * Added shockwave's -- enjoy. :) |
| 493 | * |
| 494 | * 94 5/07/98 2:52p Chris |
| 495 | * Removed a bounce mprintf |
| 496 | * |
| 497 | * 93 5/07/98 2:40p Chris |
| 498 | * Added death_dot and bounce sound for weapons |
| 499 | * |
| 500 | * 92 5/07/98 2:22p Chris |
| 501 | * Hit die dot |
| 502 | * |
| 503 | * 91 5/06/98 7:07p Samir |
| 504 | * when player is completely dead, don't call script too. |
| 505 | * |
| 506 | * 90 5/05/98 3:42p Chris |
| 507 | * Code cleanup and fixed the collide_XXX_with_wall code. The wall_normal |
| 508 | * was know by fvi; so, it is passed to the function (instead of |
| 509 | * generating it again) |
| 510 | * |
| 511 | * 89 5/04/98 3:51p Matt |
| 512 | * Finished (for now) with breaking glass. |
| 513 | * |
| 514 | * 88 5/04/98 1:00p Jason |
| 515 | * changed the way weapon explosions work |
| 516 | * |
| 517 | * 87 5/04/98 12:47p Matt |
| 518 | * Improvements to the breaking glass system, though I don't consider it |
| 519 | * anywhere near done yet. |
| 520 | * |
| 521 | * 86 5/03/98 10:24p Matt |
| 522 | * Partially completed breaking glass code, checked in so Chris can fix a |
| 523 | * bug |
| 524 | * |
| 525 | * 85 4/23/98 7:14p Chris |
| 526 | * Changed non-moving objects to player collisions |
| 527 | * |
| 528 | * 84 4/22/98 9:43p Chris |
| 529 | * More AI improvements |
| 530 | * |
| 531 | * 83 4/22/98 3:25p Jason |
| 532 | * changes for multiplayer debugging |
| 533 | * |
| 534 | * 82 4/20/98 4:47p Chris |
| 535 | * Made collision stuff more accurate |
| 536 | * |
| 537 | * 81 4/17/98 2:00p Jason |
| 538 | * added cool object effects |
| 539 | * |
| 540 | * 80 4/15/98 12:56p Chris |
| 541 | * Reformatted some code |
| 542 | * |
| 543 | * 79 4/09/98 5:18p Jason |
| 544 | * got guided working in multiplayer |
| 545 | * |
| 546 | * 78 4/09/98 12:05p Chris |
| 547 | * Added parenting for all object types. :) |
| 548 | * |
| 549 | * 77 4/08/98 11:16a Chris |
| 550 | * Fixed powerup pickup bug |
| 551 | * |
| 552 | * 76 4/07/98 4:25p Chris |
| 553 | * Added support for buddy bot |
| 554 | * |
| 555 | * 75 4/06/98 11:59a Chris |
| 556 | * Fixed powerup/powerup hack |
| 557 | * |
| 558 | * 74 3/31/98 5:56p Jason |
| 559 | * changes for multiplay |
| 560 | * |
| 561 | * 73 3/30/98 5:12p Jason |
| 562 | * more changes for game/dll integration |
| 563 | * |
| 564 | * 72 3/20/98 9:34p Jason |
| 565 | * added SetObjectDeadFlag inlined function |
| 566 | * |
| 567 | * 71 3/20/98 6:39p Jason |
| 568 | * 100.0 to 1.0 for volume |
| 569 | * |
| 570 | * 70 3/20/98 3:54p Chris |
| 571 | * Working on adding sounds to the game. :) |
| 572 | * |
| 573 | * 69 3/20/98 3:21p Chris |
| 574 | * Added player hit by weapon sound. |
| 575 | * |
| 576 | * 68 3/20/98 2:59p Chris |
| 577 | * Added a wall hit sound for the player and added support for a base |
| 578 | * volume for 3d sounds |
| 579 | * |
| 580 | * 67 3/19/98 7:15p Jason |
| 581 | * more changes for multiplayer |
| 582 | * |
| 583 | * 66 3/19/98 3:44p Chris |
| 584 | * Multiplayer enchancement for collisions |
| 585 | * |
| 586 | * 65 3/19/98 3:27p Chris |
| 587 | * Did some collision code for multiplayer. |
| 588 | * |
| 589 | * 64 3/18/98 5:45p Jason |
| 590 | * more multiplayer script integration |
| 591 | * |
| 592 | * 63 3/17/98 6:17p Jason |
| 593 | * added gamemode collide stuff |
| 594 | * |
| 595 | * 62 3/17/98 11:27a Chris |
| 596 | * Added object bump notifies for AI |
| 597 | * |
| 598 | * 61 3/13/98 5:55p Chris |
| 599 | * Added the new collision spheres |
| 600 | * |
| 601 | * 60 2/23/98 5:46p Chris |
| 602 | * Removed some old code. |
| 603 | * |
| 604 | * 59 2/18/98 11:48a Craig |
| 605 | * |
| 606 | * 58 2/11/98 4:10p Jason |
| 607 | * got spawning impact weapons working |
| 608 | * |
| 609 | * 57 2/05/98 2:54p Jason |
| 610 | * changes for explosions |
| 611 | * |
| 612 | * 56 2/05/98 2:02p Chris |
| 613 | * Fixed the hitseg and hitwall in collide_object_with_wall and |
| 614 | * scrape_object_with_wall |
| 615 | * |
| 616 | * 55 2/04/98 6:09p Matt |
| 617 | * Changed object room number to indicate a terrain cell via a flag. Got |
| 618 | * rid of the object flag which used to indicate terrain. |
| 619 | * |
| 620 | * 54 1/30/98 2:54p Matt |
| 621 | * Took script calls out of bump_two_objects, since they alread existed in |
| 622 | * collide_two_objects |
| 623 | * |
| 624 | * 53 1/29/98 5:48p Matt |
| 625 | * Got rid of marker objects |
| 626 | * |
| 627 | * 52 1/29/98 4:16p Matt |
| 628 | * Fixed some problems from my last changes |
| 629 | * |
| 630 | * 51 1/29/98 3:11p Matt |
| 631 | * Clean up a bit: deleted commented-out code, removed leftover D1/D2 |
| 632 | * stuff, removed references to hostage objects |
| 633 | * |
| 634 | * 50 1/28/98 12:00p Jason |
| 635 | * more changes for multiplayer |
| 636 | * |
| 637 | * 49 1/26/98 11:01a Jason |
| 638 | * incremental checkin for multiplayer |
| 639 | * |
| 640 | * 48 1/23/98 11:21a Jason |
| 641 | * incremental multiplayer checkin |
| 642 | * |
| 643 | * 47 1/21/98 6:09p Jason |
| 644 | * Got player deaths working in multiplayer |
| 645 | * |
| 646 | * 46 1/21/98 3:05p Samir |
| 647 | * Changed a function call to StartPlayerExplosion |
| 648 | * |
| 649 | * 45 1/21/98 1:11p Jason |
| 650 | * incremental checkin for multiplayer |
| 651 | * |
| 652 | * 44 1/20/98 12:10p Jason |
| 653 | * implemented vis effect system |
| 654 | * |
| 655 | * 43 1/19/98 10:04a Matt |
| 656 | * Added new object handle system |
| 657 | * |
| 658 | * 42 1/14/98 7:57p Chris |
| 659 | * Improving the awareness system |
| 660 | * |
| 661 | * 41 1/14/98 1:23p Jason |
| 662 | * made ApplyDamageToGeneric send the weapons parent as the killer |
| 663 | * |
| 664 | * 40 1/09/98 4:13p Chris |
| 665 | * Reformatted some code |
| 666 | * |
| 667 | * 39 1/09/98 4:11p Chris |
| 668 | * Removed a mprintf |
| 669 | * |
| 670 | * 38 12/22/97 6:19p Chris |
| 671 | * Moved weapon battery firing sound off the projectile (weapon) and into |
| 672 | * the weapon battery. |
| 673 | * |
| 674 | * 37 12/15/97 11:03a Jason |
| 675 | * make sparks only when successfully hit |
| 676 | * |
| 677 | * 36 12/12/97 6:13p Jason |
| 678 | * added sparks |
| 679 | * |
| 680 | * 35 12/10/97 2:36p Jason |
| 681 | * added random small explosions |
| 682 | * |
| 683 | * 34 12/04/97 12:15p Jason |
| 684 | * gave designers the ability to set their own weapon-to-wall hit vclips |
| 685 | * |
| 686 | * 33 12/01/97 9:54a Chris |
| 687 | * Added support for concussive forces, generalized robot collisions to |
| 688 | * generic collisions |
| 689 | * |
| 690 | * 32 11/20/97 1:38p Chris |
| 691 | * No rotation is applied to player objects |
| 692 | * |
| 693 | * 31 11/13/97 5:06p Chris |
| 694 | * Added support for clutter to weapon collisions |
| 695 | * |
| 696 | * 30 11/05/97 6:42p Jason |
| 697 | * took out stupid blast ring |
| 698 | * |
| 699 | * 29 10/29/97 1:29p Chris |
| 700 | * Added PF_STICK for weapons |
| 701 | * |
| 702 | * 28 10/24/97 2:30p Jason |
| 703 | * more changes for explosions |
| 704 | * |
| 705 | * 27 10/23/97 11:14a Jason |
| 706 | * changed some fireball DEFINEs |
| 707 | * |
| 708 | * 26 10/22/97 7:26p Samir |
| 709 | * Player death mostly working. Damn hangup still occurs. Freaky. |
| 710 | * |
| 711 | * 25 10/22/97 4:30p Chris |
| 712 | * We can now slew between the mine and the terrain |
| 713 | * |
| 714 | * 24 10/22/97 11:44a Jason |
| 715 | * changes for explosion system |
| 716 | * |
| 717 | * 23 10/21/97 4:15p Chris |
| 718 | * Incremental integration of the fvi/physics/collide code |
| 719 | * |
| 720 | * 22 10/20/97 4:46p Jason |
| 721 | * changes for explosions |
| 722 | * |
| 723 | * 21 10/20/97 11:55a Chris |
| 724 | * Added some support for the new collide system. |
| 725 | * |
| 726 | * 20 10/16/97 3:46p Chris |
| 727 | * Incremental improvements |
| 728 | * |
| 729 | * 19 10/03/97 3:47p Chris |
| 730 | * Moved script calls to bump two objects (so building can have scripts) |
| 731 | * |
| 732 | * 18 10/03/97 3:45p Chris |
| 733 | * Added some bumping force by weapons |
| 734 | * |
| 735 | * 17 10/03/97 3:18p Samir |
| 736 | * Added script hook to bump_this_object |
| 737 | * |
| 738 | * 16 10/02/97 11:34a Chris |
| 739 | * Added support for external room collisions |
| 740 | * |
| 741 | * 15 10/01/97 4:51p Samir |
| 742 | * Include damage.h |
| 743 | * |
| 744 | * 14 9/19/97 9:37p Chris |
| 745 | * Attempted to fix door collisions -- almost there, but not quite |
| 746 | * |
| 747 | * 13 9/15/97 5:17a Chris |
| 748 | * Removed the Explosion Vclips since they do not play correctly in |
| 749 | * Hardware |
| 750 | * Added support for building collisons. |
| 751 | * working on SPhere to non-moving sphere collisions |
| 752 | * |
| 753 | * 12 9/12/97 6:36p Chris |
| 754 | * Added building collisions |
| 755 | * |
| 756 | * 11 9/05/97 12:27p Samir |
| 757 | * Player takes damage and set death if needed. |
| 758 | * |
| 759 | * 10 9/04/97 12:03p Matt |
| 760 | * Got rid of warnings |
| 761 | * |
| 762 | * 9 9/03/97 2:13p Chris |
| 763 | * Working on improving the debris system and partical explosions |
| 764 | * |
| 765 | * 8 8/21/97 7:53p Chris |
| 766 | * |
| 767 | * 7 8/21/97 7:52p Chris |
| 768 | * |
| 769 | * 6 8/18/97 1:46a Chris |
| 770 | * Allowed for robot damage and destoyable objects. |
| 771 | * Also, allowed weapons to bounce |
| 772 | * |
| 773 | * 5 8/14/97 11:44a Samir |
| 774 | * Don't kill powerups. Let script do it. |
| 775 | * |
| 776 | * 4 8/12/97 3:32p Samir |
| 777 | * collisions call script code now too. |
| 778 | * |
| 779 | * 3 8/11/97 1:54p Matt |
| 780 | * Ripped out robot & powerup pages, and added generic page |
| 781 | * |
| 782 | * 2 7/28/97 1:16p Chris |
| 783 | * Allow for player and robots to be hit by weapons and correct parenting |
| 784 | * of weapons. |
| 785 | * |
| 786 | * 16 5/19/97 5:39 PM Jeremy |
| 787 | * removed "we hit a robot" mprintf |
| 788 | * |
| 789 | * 15 5/15/97 6:09p Chris |
| 790 | * |
| 791 | * 14 5/13/97 5:52p Chris |
| 792 | * Added ability to exit and enter mine. Also did some |
| 793 | * incremental improvements. |
| 794 | * |
| 795 | * 13 5/05/97 5:41a Chris |
| 796 | * Added some better polygon collision code. It is still rough though. |
| 797 | * |
| 798 | * 12 4/29/97 8:03a Chris |
| 799 | * Improved the sound code. High-level sound now |
| 800 | * fully uses the flags in the sound page and it |
| 801 | * resulted in a simpilier coding interface :) |
| 802 | * |
| 803 | * 11 4/24/97 5:42p Jason |
| 804 | * got fireball vclips working |
| 805 | * |
| 806 | * 10 4/24/97 12:28p Jason |
| 807 | * added sound when weapon hits a wall |
| 808 | * |
| 809 | * 9 4/24/97 3:25a Chris |
| 810 | * // Added some more support for 3d sounds |
| 811 | * |
| 812 | * 8 4/23/97 6:34p Chris |
| 813 | * // Incremental collision stuff. |
| 814 | * |
| 815 | * 7 4/23/97 6:06p Jason |
| 816 | * made player ship and weapons work correctly together (first pass) |
| 817 | * |
| 818 | * 6 4/17/97 3:10p Chris |
| 819 | * Added edge of world object delete. Also did some incremental |
| 820 | * improvements. |
| 821 | * |
| 822 | * 5 4/11/97 3:05a Chris |
| 823 | * Allowed robot sphere collision |
| 824 | * |
| 825 | * 4 3/15/97 1:29p Chris |
| 826 | * |
| 827 | * $NoKeywords: $ |
| 828 | */ |
| 829 | |
| 830 | #include <algorithm> |
| 831 | #include <cmath> |
| 832 | #include <cstdio> |
| 833 | |
| 834 | #include "AIMain.h" |
| 835 | #include "collide.h" |
| 836 | #include "D3ForceFeedback.h" |
| 837 | #include "ddio_common.h" |
| 838 | #include "damage.h" |
| 839 | #include "demofile.h" |
| 840 | #include "fireball.h" |
| 841 | #include "game.h" |
| 842 | #include "game2dll.h" |
| 843 | #include "hlsoundlib.h" |
| 844 | #include "hud.h" |
| 845 | #include "levelgoal.h" |
| 846 | #include "lighting.h" |
| 847 | #include "marker.h" |
| 848 | #include "mono.h" |
| 849 | #include "multi.h" |
| 850 | #include "object.h" |
| 851 | #include "osiris_dll.h" |
| 852 | #include "physics.h" |
| 853 | #include "player.h" |
| 854 | #include "polymodel.h" |
| 855 | #include "pserror.h" |
| 856 | #include "psrand.h" |
| 857 | #include "scorch.h" |
| 858 | #include "sounds.h" |
| 859 | #include "trigger.h" |
| 860 | #include "vecmat.h" |
| 861 | #include "weapon.h" |
| 862 | |
| 863 | #define PLAYER_ROTATION_BY_FORCE_SCALAR 0.12f |
| 864 | #define NONPLAYER_ROTATION_BY_FORCE_SCALAR 1.0f |
| 865 | |
| 866 | uint8_t CollisionResult[MAX_OBJECT_TYPES][MAX_OBJECT_TYPES]; |
| 867 | uint8_t CollisionRayResult[MAX_OBJECT_TYPES]; |
| 868 | |
| 869 | static bool IsOKToApplyForce(object *objp); |
| 870 | //! Creates some effects where a weapon has collided with a wall. |
| 871 | static void DoWallEffects(object *weapon, int surface_tmap); |
| 872 | //! Check for lava, volatile, or water surface. If contact, make special sound & kill the weapon. |
| 873 | static void check_for_special_surface(object *weapon, int surface_tmap, vector *surface_normal, float hit_dot); |
| 874 | /// Process a collision between a weapon and a wall. |
| 875 | /// - Returns: true if the weapon hits the wall, and false if should keep going though the wall (for breakable glass). |
| 876 | static bool collide_weapon_and_wall(object *weapon, fix hitspeed, int hitseg, int hitwall, vector *hitpnt, |
| 877 | vector *wall_normal, float hit_dot); |
| 878 | /// Prints out a marker hud message if needed. |
| 879 | static void collide_player_and_marker(object *playerobj, object *marker_obj, vector *collision_point, |
| 880 | vector *collision_normal, bool f_reverse_normal, fvi_info *hit_info); |
| 881 | static void collide_player_and_wall(object *playerobj, float hitspeed, int hitseg, int hitwall, vector *hitpt, |
| 882 | vector *wall_normal, float hit_dot); |
| 883 | static void collide_generic_and_wall(object *genericobj, float hitspeed, int hitseg, int hitwall, vector *hitpt, |
| 884 | vector *wall_normal, float hit_dot); |
| 885 | static void CollideAnglesToMatrix(matrix *m, float p, float h, float b); |
| 886 | static vector *CollideExtractAnglesFromMatrix(vector *a, matrix *m); |
| 887 | static void bump_two_objects(object *object0, object *object1, vector *collision_point, vector *collision_normal, |
| 888 | int damage_flag); |
| 889 | static void collide_player_and_player(object *p1, object *p2, vector *collision_point, vector *collision_normal, |
| 890 | bool f_reverse_normal, fvi_info *hit_info); |
| 891 | static void collide_generic_and_player(object *robotobj, object *playerobj, vector *collision_point, |
| 892 | vector *collision_normal, bool f_reverse_normal, fvi_info *hit_info); |
| 893 | static void MakeWeaponStick(object *weapon, object *parent, fvi_info *hit_info); |
| 894 | static void check_lg_inform(object *A, object *B); |
| 895 | |
| 896 | bool IsOKToApplyForce(object *objp) { |
| 897 | if (Game_mode & GM_MULTI) { |
| 898 | if (objp->type == OBJ_PLAYER) { |
| 899 | if (objp != Player_object) |
| 900 | return false; |
| 901 | } else { |
| 902 | if (objp->type != OBJ_WEAPON && objp->type != OBJ_POWERUP && Netgame.local_role != LR_SERVER) |
| 903 | return false; |
| 904 | } |
| 905 | } |
| 906 | |
| 907 | if (objp->mtype.phys_info.mass == 0.0) |
| 908 | return false; |
| 909 | |
| 910 | if (objp->movement_type != MT_PHYSICS && objp->movement_type != MT_WALKING) |
| 911 | return false; |
| 912 | |
| 913 | if (objp->mtype.phys_info.flags & PF_PERSISTENT) |
| 914 | return false; |
| 915 | |
| 916 | if (objp->mtype.phys_info.flags & PF_LOCK_MASK) // Not done! |
| 917 | return false; |
| 918 | |
| 919 | return true; |
| 920 | } |
| 921 | |
| 922 | struct vec2d { |
| 923 | float i, j; |
| 924 | }; |
| 925 | |
| 926 | #define cross(v0, v1) (((v0)->i * (v1)->j) - ((v0)->j * (v1)->i)) |
| 927 | |
| 928 | // finds the uv coords of the given point on the given seg & side |
| 929 | // fills in u & v. if l is non-NULL fills it in also |
| 930 | void FindHitpointUV(float *u, float *v, vector *point, room *rp, int facenum) { |
| 931 | face *fp = &rp->faces[facenum]; |
| 932 | int ii, jj; |
| 933 | vec2d pnt[3], checkp, vec0, vec1; |
| 934 | float *t; |
| 935 | float k0, k1; |
| 936 | int i; |
| 937 | |
| 938 | // 1. find what plane to project this wall onto to make it a 2d case |
| 939 | |
| 940 | GetIJ(&fp->normal, &ii, &jj); |
| 941 | |
| 942 | // 2. compute u,v of intersection point |
| 943 | |
| 944 | // Copy face points into 2d verts array |
| 945 | for (i = 0; i < 3; i++) { |
| 946 | t = &rp->verts[fp->face_verts[i]].x; |
| 947 | pnt[i].i = t[ii]; |
| 948 | pnt[i].j = t[jj]; |
| 949 | } |
| 950 | t = &point->x; |
| 951 | checkp.i = t[ii]; |
| 952 | checkp.j = t[jj]; |
| 953 | |
| 954 | // vec from 1 -> 0 |
| 955 | vec0.i = pnt[0].i - pnt[1].i; |
| 956 | vec0.j = pnt[0].j - pnt[1].j; |
| 957 | |
| 958 | // vec from 1 -> 2 |
| 959 | vec1.i = pnt[2].i - pnt[1].i; |
| 960 | vec1.j = pnt[2].j - pnt[1].j; |
| 961 | |
| 962 | k1 = -((cross(&checkp, &vec0) + cross(&vec0, &pnt[1])) / cross(&vec0, &vec1)); |
| 963 | if (fabsf(vec0.i) > fabsf(vec0.j)) |
| 964 | k0 = ((-k1 * vec1.i) + checkp.i - pnt[1].i) / vec0.i; |
| 965 | else |
| 966 | k0 = ((-k1 * vec1.j) + checkp.j - pnt[1].j) / vec0.j; |
| 967 | |
| 968 | // mprintf(0," k0,k1 = %x,%x\n",k0,k1); |
| 969 | |
| 970 | *u = fp->face_uvls[1].u + (k0 * (fp->face_uvls[0].u - fp->face_uvls[1].u)) + |
| 971 | (k1 * (fp->face_uvls[2].u - fp->face_uvls[1].u)); |
| 972 | *v = fp->face_uvls[1].v + (k0 * (fp->face_uvls[0].v - fp->face_uvls[1].v)) + |
| 973 | (k1 * (fp->face_uvls[2].v - fp->face_uvls[1].v)); |
| 974 | |
| 975 | // mprintf(0," u,v = %x,%x\n",*u,*v); |
| 976 | } |
| 977 | |
| 978 | // Creates some effects where a weapon has collided with a wall |
| 979 | void DoWallEffects(object *weapon, int surface_tmap) { |
| 980 | texture *texp = &GameTextures[surface_tmap]; |
| 981 | |
| 982 | if (texp->flags & (TF_VOLATILE + TF_LAVA + TF_WATER)) { |
| 983 | // Create some lava steam |
| 984 | if ((texp->flags & TF_WATER) || ((ps_rand() % 4) == 0)) { |
| 985 | int visnum = VisEffectCreate(VIS_FIREBALL, MED_SMOKE_INDEX, weapon->roomnum, &weapon->pos); |
| 986 | if (visnum >= 0) { |
| 987 | vis_effect *vis = &VisEffects[visnum]; |
| 988 | |
| 989 | vis->lifetime = .9f; |
| 990 | vis->lifeleft = .9f; |
| 991 | |
| 992 | vis->movement_type = MT_PHYSICS; |
| 993 | vis->size = 3.0; |
| 994 | vm_MakeZero(&vis->velocity); |
| 995 | vis->velocity.y = 10; |
| 996 | } |
| 997 | } |
| 998 | } else if (texp->flags & TF_RUBBLE) { |
| 999 | if ((ps_rand() % 4) == 0) { |
| 1000 | int num_rubble = (ps_rand() % 3) + 1; |
| 1001 | int bm_handle = GetTextureBitmap(texp - GameTextures, 0); |
| 1002 | uint16_t *data = bm_data(bm_handle, 0); |
| 1003 | |
| 1004 | uint16_t color = data[(bm_w(bm_handle, 0) * (bm_h(bm_handle, 0) / 2)) + (bm_w(bm_handle, 0) / 2)]; |
| 1005 | |
| 1006 | for (int i = 0; i < num_rubble; i++) { |
| 1007 | int visnum; |
| 1008 | |
| 1009 | visnum = VisEffectCreate(VIS_FIREBALL, RUBBLE1_INDEX + (ps_rand() % 2), weapon->roomnum, &weapon->pos); |
| 1010 | |
| 1011 | if (visnum >= 0) { |
| 1012 | vis_effect *vis = &VisEffects[visnum]; |
| 1013 | |
| 1014 | vis->movement_type = MT_PHYSICS; |
| 1015 | vis->mass = 100; |
| 1016 | vis->drag = .1f; |
| 1017 | |
| 1018 | vis->phys_flags |= PF_GRAVITY | PF_NO_COLLIDE; |
| 1019 | |
| 1020 | if ((ps_rand() % 3) == 0) { |
| 1021 | vis->velocity.x = (ps_rand() % 100) - 50; |
| 1022 | vis->velocity.y = -((ps_rand() % 200) - 30); |
| 1023 | vis->velocity.z = (ps_rand() % 100) - 50; |
| 1024 | } else { |
| 1025 | vis->velocity.x = (ps_rand() % 300) - 50; |
| 1026 | vis->velocity.y = -((ps_rand() % 200) - 30); |
| 1027 | vis->velocity.z = (ps_rand() % 300) - 50; |
| 1028 | } |
| 1029 | |
| 1030 | vm_NormalizeVectorFast(&vis->velocity); |
| 1031 | vis->velocity *= 4 + (ps_rand() % 20); |
| 1032 | vis->size = .5 + (((ps_rand() % 11) - 5) * .05); |
| 1033 | vis->flags |= VF_USES_LIFELEFT; |
| 1034 | float lifetime = 1.0 + (((ps_rand() % 11) - 5) * .1); |
| 1035 | vis->lifeleft = lifetime; |
| 1036 | vis->lifetime = lifetime; |
| 1037 | vis->lighting_color = color; |
| 1038 | } |
| 1039 | } |
| 1040 | } |
| 1041 | } |
| 1042 | } |
| 1043 | |
| 1044 | #define FORCEFIELD_DAMAGE 5.0f |
| 1045 | |
| 1046 | extern void DeformTerrain(vector *pos, int depth, float size); |
| 1047 | |
| 1048 | // Check for lava, volatile, or water surface. If contact, make special sound & kill the weapon |
| 1049 | void check_for_special_surface(object *weapon, int surface_tmap, vector *surface_normal, float hit_dot) { |
| 1050 | bool f_forcefield, f_volatile, f_lava, f_water; |
| 1051 | |
| 1052 | f_forcefield = (GameTextures[surface_tmap].flags & TF_FORCEFIELD) != 0; |
| 1053 | f_volatile = (GameTextures[surface_tmap].flags & TF_VOLATILE) != 0; |
| 1054 | f_lava = (GameTextures[surface_tmap].flags & TF_LAVA) != 0; |
| 1055 | f_water = (GameTextures[surface_tmap].flags & TF_WATER) != 0; |
| 1056 | |
| 1057 | // Kill the weapon if the surface is volatile, lava, or water |
| 1058 | if (f_volatile || f_lava || f_water) { |
| 1059 | int snd; |
| 1060 | ain_hear hear; |
| 1061 | hear.f_directly_player = false; |
| 1062 | |
| 1063 | if (f_water) { |
| 1064 | snd = SOUND_WEAPON_HIT_WATER; |
| 1065 | hear.hostile_level = 0.2f; |
| 1066 | hear.curiosity_level = 0.3f; |
| 1067 | } else if (f_volatile || f_lava) { |
| 1068 | snd = SOUND_WEAPON_HIT_LAVA; |
| 1069 | hear.hostile_level = 0.1f; |
| 1070 | hear.curiosity_level = 0.5f; |
| 1071 | } else |
| 1072 | Int3(); |
| 1073 | |
| 1074 | hear.max_dist = Sounds[snd].max_distance; |
| 1075 | Sound_system.Play3dSound(snd, SND_PRIORITY_NORMAL, weapon); |
| 1076 | AINotify(weapon, AIN_HEAR_NOISE, (void *)&hear); |
| 1077 | |
| 1078 | if (!f_water) |
| 1079 | DoWeaponExploded(weapon, surface_normal); |
| 1080 | |
| 1081 | SetObjectDeadFlag(weapon); |
| 1082 | } |
| 1083 | } |
| 1084 | |
| 1085 | // Process a collision between a weapon and a wall |
| 1086 | // Returns true if the weapon hits the wall, and false if should keep going though the wall (for breakable glass) |
| 1087 | bool collide_weapon_and_wall(object *weapon, fix hitspeed, int hitseg, int hitwall, vector *hitpnt, vector *wall_normal, |
| 1088 | float hit_dot) { |
| 1089 | bool f_forcefield; |
| 1090 | bool f_volatile, f_lava, f_water; |
| 1091 | // mprintf(0, "Weapon hit wall, how nice.\n"); |
| 1092 | |
| 1093 | // #ifndef RELEASE |
| 1094 | if ((stricmp(Weapons[weapon->id].name, "Yellow flare") == 0) && (weapon->parent_handle == Player_object->handle) && |
| 1095 | (KEY_STATE(KEY_LAPOSTRO))) { |
| 1096 | if (ROOMNUM_OUTSIDE(hitseg)) { |
| 1097 | AddHUDMessage("Terrain cell %d", CELLNUM(hitseg)); |
| 1098 | } else { |
| 1099 | AddHUDMessage("Room %d face %d", hitseg, hitwall); |
| 1100 | } |
| 1101 | } |
| 1102 | // #endif |
| 1103 | |
| 1104 | // Check if forcefield |
| 1105 | int tmap; |
| 1106 | if (!ROOMNUM_OUTSIDE(hitseg)) // Make sure we've hit a wall, and not terrain |
| 1107 | { |
| 1108 | tmap = Rooms[hitseg].faces[hitwall].tmap; |
| 1109 | } else { |
| 1110 | tmap = Terrain_tex_seg[Terrain_seg[CELLNUM(hitseg)].texseg_index].tex_index; |
| 1111 | } |
| 1112 | f_forcefield = (GameTextures[tmap].flags & TF_FORCEFIELD) != 0; |
| 1113 | f_volatile = (GameTextures[tmap].flags & TF_VOLATILE) != 0; |
| 1114 | f_lava = (GameTextures[tmap].flags & TF_LAVA) != 0; |
| 1115 | f_water = (GameTextures[tmap].flags & TF_WATER) != 0; |
| 1116 | |
| 1117 | if (f_forcefield && !(Weapons[weapon->id].flags & WF_MATTER_WEAPON)) { |
| 1118 | ain_hear hear; |
| 1119 | hear.f_directly_player = false; |
| 1120 | hear.hostile_level = 0.9f; |
| 1121 | hear.curiosity_level = 0.1f; |
| 1122 | |
| 1123 | if (sound_override_force_field == -1) |
| 1124 | hear.max_dist = Sounds[SOUND_FORCEFIELD_BOUNCE].max_distance; |
| 1125 | else |
| 1126 | hear.max_dist = Sounds[sound_override_force_field].max_distance; |
| 1127 | |
| 1128 | AINotify(weapon, AIN_HEAR_NOISE, (void *)&hear); |
| 1129 | |
| 1130 | if (sound_override_force_field == -1) |
| 1131 | Sound_system.Play3dSound(SOUND_FORCEFIELD_BOUNCE, SND_PRIORITY_HIGH, weapon); |
| 1132 | else |
| 1133 | Sound_system.Play3dSound(sound_override_force_field, SND_PRIORITY_HIGH, weapon); |
| 1134 | |
| 1135 | return true; |
| 1136 | } |
| 1137 | |
| 1138 | // Check for destroyable or breakable face |
| 1139 | if (!ROOMNUM_OUTSIDE(hitseg)) // First, make sure we've hit a wall, and not terrain |
| 1140 | { |
| 1141 | room *rp = &Rooms[hitseg]; |
| 1142 | face *fp = &rp->faces[hitwall]; |
| 1143 | |
| 1144 | // Check for a trigger on this wall |
| 1145 | CheckTrigger(hitseg, hitwall, weapon, TT_COLLIDE); |
| 1146 | |
| 1147 | // Check for a destroyable face |
| 1148 | if ((GameTextures[fp->tmap].flags & TF_DESTROYABLE) && !(fp->flags & FF_DESTROYED)) { |
| 1149 | int visnum = CreateFireball(hitpnt, SHATTER_INDEX + (ps_rand() % 2), hitseg, VISUAL_FIREBALL); |
| 1150 | |
| 1151 | if (visnum >= 0) { |
| 1152 | // Alter the size of this explosion based on the face size |
| 1153 | vector verts[MAX_VERTS_PER_FACE]; |
| 1154 | vector center; |
| 1155 | for (int t = 0; t < fp->num_verts; t++) |
| 1156 | verts[t] = rp->verts[fp->face_verts[t]]; |
| 1157 | |
| 1158 | float size = sqrt(vm_GetCentroid(¢er, verts, fp->num_verts)); |
| 1159 | VisEffects[visnum].size = (size / 2); |
| 1160 | } |
| 1161 | |
| 1162 | CreateRandomSparks(20, hitpnt, hitseg); |
| 1163 | |
| 1164 | if (sound_override_glass_breaking == -1) |
| 1165 | Sound_system.Play3dSound(SOUND_BREAKING_GLASS, SND_PRIORITY_HIGH, weapon); |
| 1166 | else |
| 1167 | Sound_system.Play3dSound(sound_override_glass_breaking, SND_PRIORITY_HIGH, weapon); |
| 1168 | |
| 1169 | fp->flags |= FF_DESTROYED; |
| 1170 | } |
| 1171 | |
| 1172 | // Check for a breakable face: If the texture is breakable and it's on a portal |
| 1173 | // and hit with a matter weapon, break it |
| 1174 | if ((fp->portal_num != -1) && (GameTextures[fp->tmap].flags & TF_BREAKABLE) && |
| 1175 | (Weapons[weapon->id].flags & WF_MATTER_WEAPON)) { |
| 1176 | |
| 1177 | // Do the breaking glass stuff |
| 1178 | if (!((Game_mode & GM_MULTI) && Netgame.local_role == LR_CLIENT)) |
| 1179 | BreakGlassFace(rp, hitwall, hitpnt, &weapon->mtype.phys_info.velocity); |
| 1180 | |
| 1181 | ain_hear hear; |
| 1182 | hear.f_directly_player = false; |
| 1183 | hear.hostile_level = 0.9f; |
| 1184 | hear.curiosity_level = 1.0f; |
| 1185 | if (sound_override_glass_breaking == -1) |
| 1186 | hear.max_dist = Sounds[SOUND_BREAKING_GLASS].max_distance; |
| 1187 | else |
| 1188 | hear.max_dist = Sounds[sound_override_glass_breaking].max_distance; |
| 1189 | AINotify(weapon, AIN_HEAR_NOISE, (void *)&hear); |
| 1190 | |
| 1191 | return false; |
| 1192 | } |
| 1193 | } |
| 1194 | |
| 1195 | // Add a scorch |
| 1196 | if ((Weapons[weapon->id].scorch_handle != -1) && !f_water && !f_volatile && !f_lava) |
| 1197 | AddScorch(hitseg, hitwall, hitpnt, Weapons[weapon->id].scorch_handle, Weapons[weapon->id].scorch_size); |
| 1198 | |
| 1199 | if (ROOMNUM_OUTSIDE(hitseg)) { |
| 1200 | if (Weapons[weapon->id].terrain_damage_size > 0 && Weapons[weapon->id].terrain_damage_depth > 0) { |
| 1201 | DeformTerrain(&weapon->pos, Weapons[weapon->id].terrain_damage_depth, Weapons[weapon->id].terrain_damage_size); |
| 1202 | } |
| 1203 | } |
| 1204 | |
| 1205 | // Do special smoke, etc. |
| 1206 | DoWallEffects(weapon, tmap); |
| 1207 | |
| 1208 | // look for lava, volatile, water |
| 1209 | check_for_special_surface(weapon, tmap, wall_normal, hit_dot); |
| 1210 | |
| 1211 | // If dead, we're done |
| 1212 | if (weapon->flags & OF_DEAD) |
| 1213 | return true; |
| 1214 | |
| 1215 | // If done bouncing, kill the weapon |
| 1216 | if ((weapon->mtype.phys_info.num_bounces <= 0) && !(weapon->mtype.phys_info.flags & PF_STICK) && |
| 1217 | (hit_dot > weapon->mtype.phys_info.hit_die_dot)) { |
| 1218 | int snd; |
| 1219 | ain_hear hear; |
| 1220 | hear.f_directly_player = false; |
| 1221 | |
| 1222 | snd = Weapons[weapon->id].sounds[WSI_IMPACT_WALL]; |
| 1223 | hear.hostile_level = 0.9f; |
| 1224 | hear.curiosity_level = 0.1f; |
| 1225 | |
| 1226 | if (snd != SOUND_NONE_INDEX) { |
| 1227 | hear.max_dist = Sounds[snd].max_distance; |
| 1228 | Sound_system.Play3dSound(snd, SND_PRIORITY_NORMAL, weapon); |
| 1229 | AINotify(weapon, AIN_HEAR_NOISE, (void *)&hear); |
| 1230 | } |
| 1231 | |
| 1232 | // Check to see if we should spawn |
| 1233 | if ((Weapons[weapon->id].flags & WF_SPAWNS_IMPACT) && Weapons[weapon->id].spawn_count > 0 && |
| 1234 | Weapons[weapon->id].spawn_handle >= 0) |
| 1235 | CreateImpactSpawnFromWeapon(weapon, wall_normal); |
| 1236 | |
| 1237 | if ((Weapons[weapon->id].flags & WF_SPAWNS_ROBOT) && (Weapons[weapon->id].flags & WF_COUNTERMEASURE) && |
| 1238 | Weapons[weapon->id].robot_spawn_handle >= 0) |
| 1239 | CreateRobotSpawnFromWeapon(weapon); |
| 1240 | |
| 1241 | DoWeaponExploded(weapon, wall_normal); |
| 1242 | |
| 1243 | SetObjectDeadFlag(weapon); |
| 1244 | } else { // weapon is bouncing |
| 1245 | |
| 1246 | if (Weapons[weapon->id].sounds[WSI_BOUNCE] != SOUND_NONE_INDEX) { |
| 1247 | Sound_system.Play3dSound(Weapons[weapon->id].sounds[WSI_BOUNCE], SND_PRIORITY_HIGH, weapon); |
| 1248 | |
| 1249 | if (Weapons[weapon->id].sounds[WSI_BOUNCE] > -1) { |
| 1250 | ain_hear hear; |
| 1251 | hear.f_directly_player = false; |
| 1252 | hear.hostile_level = 0.20f; |
| 1253 | hear.curiosity_level = 0.6f; |
| 1254 | hear.max_dist = Sounds[Weapons[weapon->id].sounds[WSI_BOUNCE]].max_distance; |
| 1255 | AINotify(weapon, AIN_HEAR_NOISE, (void *)&hear); |
| 1256 | } |
| 1257 | } |
| 1258 | } |
| 1259 | |
| 1260 | return true; |
| 1261 | } |
| 1262 | |
| 1263 | // Prints out a marker hud message if needed |
| 1264 | void collide_player_and_marker(object *playerobj, object *marker_obj, vector *collision_point, vector *collision_normal, |
| 1265 | bool f_reverse_normal, fvi_info *hit_info) { |
| 1266 | if (playerobj->id == Player_num) { |
| 1267 | char str[100]; |
| 1268 | snprintf(str, sizeof(str), "Marker: %s", MarkerMessages[marker_obj->id]); |
| 1269 | AddHUDMessage(str); |
| 1270 | } |
| 1271 | } |
| 1272 | |
| 1273 | #define MIN_WALL_HIT_SOUND_VEL 40.0f |
| 1274 | #define MAX_WALL_HIT_SOUND_VEL 120.0f |
| 1275 | #define MIN_PLAYER_WALL_SOUND_TIME .1f |
| 1276 | #define WALL_DAMAGE 0.5f |
| 1277 | #define MIN_WALL_HIT_DAMAGE_SHIELDS 5 |
| 1278 | #define MIN_WALL_DAMAGE_SPEED 65.0 |
| 1279 | |
| 1280 | #define VOLATILE_DAMAGE 7.0f // damage per hit |
| 1281 | |
| 1282 | void collide_player_and_wall(object *playerobj, float hitspeed, int hitseg, int hitwall, vector *hitpt, |
| 1283 | vector *wall_normal, float hit_dot) { |
| 1284 | float volume = MAX_GAME_VOLUME; |
| 1285 | bool f_volatile, f_lava; |
| 1286 | bool f_forcefield; |
| 1287 | int tmap; |
| 1288 | |
| 1289 | if (playerobj->flags & OF_DYING) |
| 1290 | playerobj->ctype.dying_info.delay_time *= 0.9f; |
| 1291 | |
| 1292 | // Check for a trigger on this wall |
| 1293 | if (!ROOMNUM_OUTSIDE(hitseg)) // Make sure we've hit a wall, and not terrain |
| 1294 | { |
| 1295 | CheckTrigger(hitseg, hitwall, playerobj, TT_COLLIDE); |
| 1296 | tmap = Rooms[hitseg].faces[hitwall].tmap; |
| 1297 | } else { |
| 1298 | tmap = Terrain_tex_seg[Terrain_seg[CELLNUM(hitseg)].texseg_index].tex_index; |
| 1299 | } |
| 1300 | f_lava = (GameTextures[tmap].flags & TF_LAVA) != 0; |
| 1301 | f_volatile = (GameTextures[tmap].flags & TF_VOLATILE) != 0; |
| 1302 | f_forcefield = (GameTextures[tmap].flags & TF_FORCEFIELD) != 0; |
| 1303 | |
| 1304 | if (f_lava) { |
| 1305 | if (!((Game_mode & GM_MULTI) && (Netgame.local_role == LR_CLIENT))) { |
| 1306 | int id = FindWeaponName("NapalmBlob"); |
| 1307 | if (id >= 0) |
| 1308 | SetNapalmDamageEffect(playerobj, nullptr, id); |
| 1309 | else |
| 1310 | Int3(); |
| 1311 | } |
| 1312 | } |
| 1313 | |
| 1314 | // If volatile, make the sound & apply damage |
| 1315 | if (f_volatile) { |
| 1316 | if (playerobj == Player_object) { |
| 1317 | if ((!(Game_mode & GM_MULTI)) || Netgame.local_role == LR_SERVER) |
| 1318 | ApplyDamageToPlayer(playerobj, playerobj, PD_VOLATILE_HISS, VOLATILE_DAMAGE); |
| 1319 | else { |
| 1320 | Multi_requested_damage_type = PD_VOLATILE_HISS; |
| 1321 | Multi_requested_damage_amount += (VOLATILE_DAMAGE); |
| 1322 | } |
| 1323 | } |
| 1324 | } |
| 1325 | |
| 1326 | if (f_forcefield) { |
| 1327 | if (playerobj == Player_object && sound_override_force_field == -1) { |
| 1328 | if ((!(Game_mode & GM_MULTI)) || Netgame.local_role == LR_SERVER) |
| 1329 | ApplyDamageToPlayer(playerobj, playerobj, PD_ENERGY_WEAPON, FORCEFIELD_DAMAGE); |
| 1330 | else { |
| 1331 | Multi_requested_damage_type = PD_ENERGY_WEAPON; |
| 1332 | Multi_requested_damage_amount += (FORCEFIELD_DAMAGE); |
| 1333 | } |
| 1334 | } |
| 1335 | |
| 1336 | if (sound_override_force_field == -1) |
| 1337 | Sound_system.Play3dSound(SOUND_FORCEFIELD_BOUNCE, SND_PRIORITY_HIGH, playerobj, MAX_GAME_VOLUME); |
| 1338 | else |
| 1339 | Sound_system.Play3dSound(sound_override_force_field, SND_PRIORITY_HIGH, playerobj, MAX_GAME_VOLUME); |
| 1340 | } |
| 1341 | |
| 1342 | if (f_forcefield || f_lava || f_volatile) { |
| 1343 | ain_hear hear; |
| 1344 | hear.f_directly_player = true; |
| 1345 | hear.hostile_level = 0.90f; |
| 1346 | hear.curiosity_level = 0.6f; |
| 1347 | if (sound_override_force_field == -1) |
| 1348 | hear.max_dist = Sounds[SOUND_FORCEFIELD_BOUNCE].max_distance; |
| 1349 | else |
| 1350 | hear.max_dist = Sounds[sound_override_force_field].max_distance; |
| 1351 | AINotify(playerobj, AIN_HEAR_NOISE, (void *)&hear); |
| 1352 | } |
| 1353 | |
| 1354 | // Do sound stuff when a player hits a wall |
| 1355 | if (!f_forcefield && !f_volatile && !f_lava && hitspeed > MIN_WALL_HIT_SOUND_VEL && |
| 1356 | Players[playerobj->id].last_hit_wall_sound_time + MIN_PLAYER_WALL_SOUND_TIME < Gametime) { |
| 1357 | if (hitspeed < MAX_WALL_HIT_SOUND_VEL) { |
| 1358 | volume = |
| 1359 | MAX_GAME_VOLUME * (hitspeed - MIN_WALL_HIT_SOUND_VEL) / (MAX_WALL_HIT_SOUND_VEL - MIN_WALL_HIT_SOUND_VEL); |
| 1360 | } |
| 1361 | |
| 1362 | if (hitspeed > MIN_WALL_DAMAGE_SPEED) { |
| 1363 | if (playerobj == Player_object && playerobj->shields >= MIN_WALL_HIT_DAMAGE_SHIELDS) { |
| 1364 | if ((!(Game_mode & GM_MULTI)) || Netgame.local_role == LR_SERVER) |
| 1365 | ApplyDamageToPlayer(playerobj, playerobj, PD_WALL_HIT, WALL_DAMAGE); |
| 1366 | else { |
| 1367 | Multi_requested_damage_type = PD_WALL_HIT; |
| 1368 | Multi_requested_damage_amount += (WALL_DAMAGE); |
| 1369 | } |
| 1370 | } |
| 1371 | } |
| 1372 | |
| 1373 | Sound_system.Play3dSound(SOUND_PLAYER_HIT_WALL, SND_PRIORITY_NORMAL, playerobj, volume); |
| 1374 | if (Demo_flags == DF_RECORDING) |
| 1375 | DemoWrite3DSound(SOUND_PLAYER_HIT_WALL, OBJNUM(playerobj), 1, volume); |
| 1376 | |
| 1377 | ain_hear hear; |
| 1378 | hear.f_directly_player = true; |
| 1379 | hear.hostile_level = 0.10f; |
| 1380 | hear.curiosity_level = 0.5f; |
| 1381 | hear.max_dist = Sounds[SOUND_PLAYER_HIT_WALL].max_distance * volume; |
| 1382 | AINotify(playerobj, AIN_HEAR_NOISE, (void *)&hear); |
| 1383 | |
| 1384 | Players[playerobj->id].last_hit_wall_sound_time = Gametime; |
| 1385 | } |
| 1386 | |
| 1387 | if (Players[playerobj->id].flags & PLAYER_FLAGS_DYING) |
| 1388 | StartPlayerExplosion(playerobj->id); |
| 1389 | |
| 1390 | // Do ForceFeedback |
| 1391 | //---------------- |
| 1392 | if (playerobj->id == Player_num && ForceIsEnabled()) { |
| 1393 | DoForceForWall(playerobj, hitspeed, hitseg, hitwall, wall_normal); |
| 1394 | } |
| 1395 | |
| 1396 | return; |
| 1397 | } |
| 1398 | |
| 1399 | void collide_generic_and_wall(object *genericobj, float hitspeed, int hitseg, int hitwall, vector *hitpt, |
| 1400 | vector *wall_normal, float hit_dot) { |
| 1401 | bool f_volatile, f_lava; |
| 1402 | bool f_forcefield; |
| 1403 | float volume = MAX_GAME_VOLUME; |
| 1404 | |
| 1405 | // Check for a trigger on this wall |
| 1406 | int tmap; |
| 1407 | if (!ROOMNUM_OUTSIDE(hitseg)) // Make sure we've hit a wall, and not terrain |
| 1408 | { |
| 1409 | CheckTrigger(hitseg, hitwall, genericobj, TT_COLLIDE); |
| 1410 | tmap = Rooms[hitseg].faces[hitwall].tmap; |
| 1411 | } else { |
| 1412 | tmap = Terrain_tex_seg[Terrain_seg[CELLNUM(hitseg)].texseg_index].tex_index; |
| 1413 | } |
| 1414 | f_forcefield = (GameTextures[tmap].flags & TF_FORCEFIELD) != 0; |
| 1415 | f_volatile = (GameTextures[tmap].flags & TF_VOLATILE) != 0; |
| 1416 | f_lava = (GameTextures[tmap].flags & TF_LAVA) != 0; |
| 1417 | |
| 1418 | if (IS_GUIDEBOT(genericobj)) { |
| 1419 | f_forcefield = false; |
| 1420 | f_volatile = false; |
| 1421 | f_lava = false; |
| 1422 | } |
| 1423 | |
| 1424 | if (f_lava) { |
| 1425 | if (!((Game_mode & GM_MULTI) && (Netgame.local_role == LR_CLIENT))) { |
| 1426 | int id = FindWeaponName("NapalmBlob"); |
| 1427 | if (id >= 0) |
| 1428 | SetNapalmDamageEffect(genericobj, nullptr, id); |
| 1429 | else |
| 1430 | Int3(); |
| 1431 | } |
| 1432 | } |
| 1433 | |
| 1434 | // If volatile, make the sound & apply damage |
| 1435 | if (f_volatile && !((Game_mode & GM_MULTI) && (Netgame.local_role == LR_CLIENT))) { |
| 1436 | ApplyDamageToGeneric(genericobj, genericobj, GD_VOLATILE_HISS, VOLATILE_DAMAGE); |
| 1437 | Sound_system.Play3dSound(SOUND_VOLATILE_HISS, SND_PRIORITY_HIGHEST, genericobj, MAX_GAME_VOLUME); |
| 1438 | } |
| 1439 | |
| 1440 | if (f_forcefield && !((Game_mode & GM_MULTI) && (Netgame.local_role == LR_CLIENT))) { |
| 1441 | if (sound_override_force_field == -1) { |
| 1442 | Sound_system.Play3dSound(SOUND_FORCEFIELD_BOUNCE, SND_PRIORITY_LOW, genericobj, MAX_GAME_VOLUME); |
| 1443 | ApplyDamageToGeneric(genericobj, genericobj, GD_ENERGY, FORCEFIELD_DAMAGE); |
| 1444 | } else { |
| 1445 | Sound_system.Play3dSound(sound_override_force_field, SND_PRIORITY_LOW, genericobj, MAX_GAME_VOLUME); |
| 1446 | } |
| 1447 | } |
| 1448 | |
| 1449 | if (genericobj->control_type != CT_AI) { |
| 1450 | if (!f_forcefield && !f_volatile && !f_lava && hitspeed > MIN_WALL_HIT_SOUND_VEL) { |
| 1451 | if (hitspeed < MAX_WALL_HIT_SOUND_VEL) { |
| 1452 | volume = |
| 1453 | MAX_GAME_VOLUME * (hitspeed - MIN_WALL_HIT_SOUND_VEL) / (MAX_WALL_HIT_SOUND_VEL - MIN_WALL_HIT_SOUND_VEL); |
| 1454 | } |
| 1455 | |
| 1456 | if (hitspeed > MIN_WALL_DAMAGE_SPEED) { |
| 1457 | if ((!(Game_mode & GM_MULTI)) || Netgame.local_role == LR_SERVER) { |
| 1458 | ApplyDamageToGeneric(genericobj, genericobj, GD_PHYSICS, WALL_DAMAGE); |
| 1459 | } |
| 1460 | } |
| 1461 | |
| 1462 | Sound_system.Play3dSound(SOUND_PLAYER_HIT_WALL, SND_PRIORITY_LOW, genericobj, volume); |
| 1463 | if (Demo_flags == DF_RECORDING) |
| 1464 | DemoWrite3DSound(SOUND_PLAYER_HIT_WALL, OBJNUM(genericobj), 1, volume); |
| 1465 | } |
| 1466 | } |
| 1467 | } |
| 1468 | |
| 1469 | void CollideAnglesToMatrix(matrix *m, float p, float h, float b) { |
| 1470 | float sinp, cosp, sinb, cosb, sinh, cosh; |
| 1471 | |
| 1472 | sinp = sin(p); |
| 1473 | cosp = cos(p); |
| 1474 | sinb = sin(b); |
| 1475 | cosb = cos(b); |
| 1476 | sinh = sin(h); |
| 1477 | cosh = cos(h); |
| 1478 | |
| 1479 | m->rvec.x = cosb * cosh; |
| 1480 | m->rvec.y = cosb * sinp * sinh - cosp * sinb; |
| 1481 | m->rvec.z = cosb * cosp * sinh + sinb * sinp; |
| 1482 | |
| 1483 | m->uvec.x = cosh * sinb; |
| 1484 | m->uvec.y = sinb * sinp * sinh + cosp * cosb; |
| 1485 | m->uvec.z = sinb * cosp * sinh - cosb * sinp; |
| 1486 | |
| 1487 | m->fvec.x = -sinh; |
| 1488 | m->fvec.y = sinp * cosh; |
| 1489 | m->fvec.z = cosp * cosh; |
| 1490 | } |
| 1491 | |
| 1492 | vector *CollideExtractAnglesFromMatrix(vector *a, matrix *m) { |
| 1493 | float sinh, cosh, sinp, sinb; |
| 1494 | |
| 1495 | sinh = -m->fvec.x; |
| 1496 | if (sinh < -1.0f) |
| 1497 | sinh = -1.0f; |
| 1498 | else if (sinh > 1.0f) |
| 1499 | sinh = 1.0f; |
| 1500 | a->y = asin(sinh); |
| 1501 | |
| 1502 | cosh = cos(a->y); |
| 1503 | ASSERT(cosh != 0.0); |
| 1504 | |
| 1505 | sinp = m->fvec.y / cosh; |
| 1506 | if (sinp < -1.0f) |
| 1507 | sinp = -1.0f; |
| 1508 | else if (sinp > 1.0f) |
| 1509 | sinp = 1.0f; |
| 1510 | |
| 1511 | sinb = m->uvec.x / cosh; |
| 1512 | if (sinb < -1.0f) |
| 1513 | sinb = -1.0f; |
| 1514 | else if (sinb > 1.0f) |
| 1515 | sinb = 1.0f; |
| 1516 | |
| 1517 | a->x = asin(sinp); |
| 1518 | a->z = asin(sinb); |
| 1519 | |
| 1520 | return a; |
| 1521 | } |
| 1522 | |
| 1523 | void ConvertEulerToAxisAmount(vector *e, vector *n, float *w) { |
| 1524 | float rotspeed = vm_GetMagnitude(e); |
| 1525 | matrix rotmat; |
| 1526 | vector e_n; |
| 1527 | float scale = rotspeed / .0001f; |
| 1528 | |
| 1529 | // If there isn't a rotation, return something valid |
| 1530 | if (rotspeed == 0.0f || scale == 0.0f) { |
| 1531 | *n = Zero_vector; |
| 1532 | n->y = 1.0f; |
| 1533 | *w = 0.0f; |
| 1534 | |
| 1535 | return; |
| 1536 | } |
| 1537 | |
| 1538 | e_n = *e / scale; |
| 1539 | |
| 1540 | CollideAnglesToMatrix(&rotmat, e_n.x, e_n.y, e_n.z); |
| 1541 | |
| 1542 | // This is from Graphics Gems 1 p.467 I am converting from a angle vector |
| 1543 | // to the normal of that rotation (you can also get the angle about that normal, but |
| 1544 | // we don't need it) |
| 1545 | n->x = rotmat.uvec.z - rotmat.fvec.y; |
| 1546 | n->y = rotmat.fvec.x - rotmat.rvec.z; |
| 1547 | n->z = rotmat.rvec.y - rotmat.uvec.x; |
| 1548 | |
| 1549 | if (*n != Zero_vector) { |
| 1550 | vm_NormalizeVector(n); |
| 1551 | |
| 1552 | float ct = (rotmat.rvec.x + rotmat.uvec.y + rotmat.fvec.z - 1.0f) / 2.0f; |
| 1553 | if (ct < -1.0f) |
| 1554 | ct = -1.0f; |
| 1555 | else if (ct > 1.0f) |
| 1556 | ct = 1.0f; |
| 1557 | |
| 1558 | float v = acos(ct); |
| 1559 | float z = sin(v); |
| 1560 | |
| 1561 | *w = rotspeed * ((2.0f * PI) / (65535.0f)); |
| 1562 | |
| 1563 | if (z >= 0.0f) |
| 1564 | *n *= -1.0f; |
| 1565 | } else { |
| 1566 | *w = 0.0f; |
| 1567 | } |
| 1568 | } |
| 1569 | |
| 1570 | void ConvertAxisAmountToEuler(vector *n, float *w, vector *e) { |
| 1571 | float s; |
| 1572 | float c; |
| 1573 | float t; |
| 1574 | |
| 1575 | float scale = *w / .0001f; |
| 1576 | float w_n = .0001f; |
| 1577 | vector s_result; |
| 1578 | |
| 1579 | if (*w == 0.0f) { |
| 1580 | *e = Zero_vector; |
| 1581 | return; |
| 1582 | } |
| 1583 | |
| 1584 | s = sin(.0001f); |
| 1585 | c = cos(.0001f); |
| 1586 | t = 1.0f - c; |
| 1587 | |
| 1588 | matrix rotmat; |
| 1589 | const float sx = s * n->x; |
| 1590 | const float sy = s * n->y; |
| 1591 | const float sz = s * n->z; |
| 1592 | const float txy = t * n->x * n->y; |
| 1593 | const float txz = t * n->x * n->z; |
| 1594 | const float tyz = t * n->y * n->z; |
| 1595 | const float txx = t * n->x * n->x; |
| 1596 | const float tyy = t * n->y * n->y; |
| 1597 | const float tzz = t * n->z * n->z; |
| 1598 | |
| 1599 | rotmat.rvec.x = txx + c; |
| 1600 | rotmat.rvec.y = txy - sz; |
| 1601 | rotmat.rvec.z = txz + sy; |
| 1602 | rotmat.uvec.x = txy + sz; |
| 1603 | rotmat.uvec.y = tyy + c; |
| 1604 | rotmat.uvec.z = tyz - sx; |
| 1605 | rotmat.fvec.x = txz - sy; |
| 1606 | rotmat.fvec.y = tyz + sx; |
| 1607 | rotmat.fvec.z = tzz + c; |
| 1608 | |
| 1609 | CollideExtractAnglesFromMatrix(&s_result, &rotmat); |
| 1610 | |
| 1611 | e->x = (s_result.x) * scale * (65535.0f / (2.0 * PI)); |
| 1612 | e->y = (s_result.y) * scale * (65535.0f / (2.0 * PI)); |
| 1613 | e->z = (s_result.z) * scale * (65535.0f / (2.0 * PI)); |
| 1614 | } |
| 1615 | |
| 1616 | void bump_obj_against_fixed(object *obj, vector *collision_point, vector *collision_normal) { |
| 1617 | ASSERT(std::isfinite(obj->mtype.phys_info.rotvel.x)); |
| 1618 | ASSERT(std::isfinite(obj->mtype.phys_info.rotvel.y)); |
| 1619 | ASSERT(std::isfinite(obj->mtype.phys_info.rotvel.z)); |
| 1620 | ASSERT(std::isfinite(obj->mtype.phys_info.velocity.x)); |
| 1621 | ASSERT(std::isfinite(obj->mtype.phys_info.velocity.y)); |
| 1622 | ASSERT(std::isfinite(obj->mtype.phys_info.velocity.z)); |
| 1623 | |
| 1624 | if (!IsOKToApplyForce(obj)) |
| 1625 | return; |
| 1626 | |
| 1627 | vector r1 = *collision_point - obj->pos; |
| 1628 | vector w1; |
| 1629 | vector n1; |
| 1630 | float temp1; |
| 1631 | |
| 1632 | float j; |
| 1633 | |
| 1634 | matrix o_t1 = obj->orient; |
| 1635 | vm_TransposeMatrix(&o_t1); |
| 1636 | |
| 1637 | vector cmp1 = obj->mtype.phys_info.rotvel * o_t1; |
| 1638 | |
| 1639 | ConvertEulerToAxisAmount(&cmp1, &n1, &temp1); |
| 1640 | |
| 1641 | n1 *= temp1; |
| 1642 | |
| 1643 | if (temp1 != 0.0f) { |
| 1644 | vm_CrossProduct(&w1, &n1, &r1); |
| 1645 | } else { |
| 1646 | w1 = Zero_vector; |
| 1647 | } |
| 1648 | |
| 1649 | vector p1 = obj->mtype.phys_info.velocity + w1; |
| 1650 | float v_rel; |
| 1651 | |
| 1652 | float m1 = obj->mtype.phys_info.mass; |
| 1653 | |
| 1654 | ASSERT(m1 != 0.0f); |
| 1655 | if (m1 <= 0.0f) |
| 1656 | m1 = 0.00000001f; |
| 1657 | |
| 1658 | v_rel = *collision_normal * (p1); |
| 1659 | |
| 1660 | float e = obj->mtype.phys_info.coeff_restitution; |
| 1661 | |
| 1662 | vector c1; |
| 1663 | vector cc1; |
| 1664 | float cv1; |
| 1665 | |
| 1666 | // matrix i1; |
| 1667 | // matrix i2; |
| 1668 | float i1 = (2.0f / 5.0f) * m1 * obj->size * obj->size; |
| 1669 | |
| 1670 | if (i1 < .0000001) |
| 1671 | i1 = .0000001f; |
| 1672 | |
| 1673 | vm_CrossProduct(&c1, &r1, collision_normal); |
| 1674 | |
| 1675 | c1 = c1 / i1; |
| 1676 | |
| 1677 | vm_CrossProduct(&cc1, &c1, &r1); |
| 1678 | |
| 1679 | cv1 = (*collision_normal) * c1; |
| 1680 | |
| 1681 | j = (-(1.0f + e)) * v_rel; |
| 1682 | j /= (1 / m1 + cv1); |
| 1683 | |
| 1684 | obj->mtype.phys_info.velocity += ((j * (*collision_normal)) / m1); |
| 1685 | |
| 1686 | vector jcn = j * (*collision_normal); |
| 1687 | |
| 1688 | vm_CrossProduct(&c1, &r1, &jcn); |
| 1689 | |
| 1690 | n1 = (c1) / i1; |
| 1691 | |
| 1692 | temp1 = vm_NormalizeVector(&n1); |
| 1693 | |
| 1694 | vector txx1; |
| 1695 | |
| 1696 | ConvertAxisAmountToEuler(&n1, &temp1, &txx1); |
| 1697 | |
| 1698 | obj->mtype.phys_info.rotvel += (txx1 * obj->orient); |
| 1699 | |
| 1700 | ASSERT(std::isfinite(obj->mtype.phys_info.rotvel.x)); |
| 1701 | ASSERT(std::isfinite(obj->mtype.phys_info.rotvel.y)); |
| 1702 | ASSERT(std::isfinite(obj->mtype.phys_info.rotvel.z)); |
| 1703 | ASSERT(std::isfinite(obj->mtype.phys_info.velocity.x)); |
| 1704 | ASSERT(std::isfinite(obj->mtype.phys_info.velocity.y)); |
| 1705 | ASSERT(std::isfinite(obj->mtype.phys_info.velocity.z)); |
| 1706 | } |
| 1707 | |
| 1708 | void bump_two_objects(object *object0, object *object1, vector *collision_point, vector *collision_normal, |
| 1709 | int damage_flag) { |
| 1710 | object *t = nullptr; |
| 1711 | object *other = nullptr; |
| 1712 | |
| 1713 | // Determine if a moving object hits a non-moving object |
| 1714 | if ((object0->movement_type != MT_PHYSICS && object0->movement_type != MT_WALKING) || |
| 1715 | (object0->movement_type == MT_PHYSICS && object0->mtype.phys_info.velocity == Zero_vector && |
| 1716 | (object0->mtype.phys_info.flags & PF_LOCK_MASK) && (object0->mtype.phys_info.flags & PF_POINT_COLLIDE_WALLS))) { |
| 1717 | t = object1; |
| 1718 | other = object0; |
| 1719 | *collision_normal *= -1.0f; |
| 1720 | } |
| 1721 | if ((object1->movement_type != MT_PHYSICS && object1->movement_type != MT_WALKING) || |
| 1722 | (object1->movement_type == MT_PHYSICS && object1->mtype.phys_info.velocity == Zero_vector && |
| 1723 | (object1->mtype.phys_info.flags & PF_LOCK_MASK) && (object1->mtype.phys_info.flags & PF_POINT_COLLIDE_WALLS))) { |
| 1724 | t = object0; |
| 1725 | other = object1; |
| 1726 | } |
| 1727 | |
| 1728 | // If we hit a non-moving object... |
| 1729 | if (t) { |
| 1730 | // chrishack -- walker hack |
| 1731 | if (t->movement_type != MT_PHYSICS && t->movement_type != MT_WALKING) { |
| 1732 | t->mtype.phys_info.velocity = Zero_vector; |
| 1733 | return; |
| 1734 | } |
| 1735 | |
| 1736 | if (t->mtype.phys_info.flags & PF_PERSISTENT) |
| 1737 | return; |
| 1738 | |
| 1739 | vector moved_v; |
| 1740 | float wall_part; |
| 1741 | |
| 1742 | float luke_test; |
| 1743 | |
| 1744 | if (t->type == OBJ_PLAYER) { |
| 1745 | luke_test = vm_GetMagnitude(&t->mtype.phys_info.velocity); |
| 1746 | } |
| 1747 | |
| 1748 | if (!(t->flags & OF_DEAD)) { |
| 1749 | // Find hit speed |
| 1750 | moved_v = t->pos - t->last_pos; |
| 1751 | wall_part = *collision_normal * t->mtype.phys_info.velocity; |
| 1752 | |
| 1753 | if (t->mtype.phys_info.flags & PF_BOUNCE) { |
| 1754 | wall_part *= 2.0; // Subtract out wall part twice to achieve bounce |
| 1755 | |
| 1756 | // New bounceness code |
| 1757 | if ((t->mtype.phys_info.flags & PF_BOUNCE) && (t->mtype.phys_info.num_bounces != PHYSICS_UNLIMITED_BOUNCE)) { |
| 1758 | if (t->mtype.phys_info.num_bounces == 0) { |
| 1759 | ASSERT(t->type != OBJ_PLAYER); |
| 1760 | if (t->flags & OF_DYING) { |
| 1761 | ASSERT((t->control_type == CT_DYING) || (t->control_type == CT_DYING_AND_AI)); |
| 1762 | DestroyObject(t, 50.0, t->ctype.dying_info.death_flags); |
| 1763 | } else |
| 1764 | SetObjectDeadFlag(t); |
| 1765 | } |
| 1766 | } |
| 1767 | t->mtype.phys_info.num_bounces--; |
| 1768 | |
| 1769 | t->mtype.phys_info.velocity += *collision_normal * (wall_part * -1.0f); |
| 1770 | |
| 1771 | if (t->mtype.phys_info.coeff_restitution != 1.0f) |
| 1772 | t->mtype.phys_info.velocity -= (t->mtype.phys_info.velocity * (1.0f - t->mtype.phys_info.coeff_restitution)); |
| 1773 | } else { |
| 1774 | float wall_force; |
| 1775 | |
| 1776 | wall_force = t->mtype.phys_info.thrust * *collision_normal; |
| 1777 | t->mtype.phys_info.thrust += |
| 1778 | *collision_normal * (wall_force * -1.001); // 1.001 so that we are not quite tangential |
| 1779 | |
| 1780 | // Update velocity from wall hit. |
| 1781 | t->mtype.phys_info.velocity += |
| 1782 | *collision_normal * (wall_part * -1.001); // 1.001 so that we are not quite tangential |
| 1783 | if (t->type == OBJ_PLAYER) { |
| 1784 | float real_vel; |
| 1785 | |
| 1786 | real_vel = vm_NormalizeVector(&t->mtype.phys_info.velocity); |
| 1787 | t->mtype.phys_info.velocity *= ((real_vel + luke_test) / 2.0f); |
| 1788 | // obj->mtype.phys_info.velocity *= (luke_test); |
| 1789 | } |
| 1790 | } |
| 1791 | |
| 1792 | // Weapons should face their new heading. This is so missiles are pointing in the correct direct. |
| 1793 | if (t->type == OBJ_WEAPON && (t->mtype.phys_info.flags & (PF_BOUNCE | PF_GRAVITY | PF_WIND))) |
| 1794 | vm_VectorToMatrix(&t->orient, &t->mtype.phys_info.velocity, &t->orient.uvec, nullptr); |
| 1795 | } |
| 1796 | |
| 1797 | // Return it to the original direction |
| 1798 | if (object0->movement_type != MT_PHYSICS && object0->movement_type != MT_WALKING) { |
| 1799 | *collision_normal *= -1.0f; |
| 1800 | } |
| 1801 | |
| 1802 | // Do ForceFeedback stuff for non-moving objects |
| 1803 | //----------------------------------------- |
| 1804 | if (ForceIsEnabled()) { |
| 1805 | |
| 1806 | if (object0->type == OBJ_PLAYER && object0->id == Player_num) { |
| 1807 | } |
| 1808 | } |
| 1809 | return; |
| 1810 | } |
| 1811 | |
| 1812 | ASSERT(std::isfinite(object1->mtype.phys_info.rotvel.x)); |
| 1813 | ASSERT(std::isfinite(object1->mtype.phys_info.rotvel.y)); |
| 1814 | ASSERT(std::isfinite(object1->mtype.phys_info.rotvel.z)); |
| 1815 | ASSERT(std::isfinite(object0->mtype.phys_info.rotvel.x)); |
| 1816 | ASSERT(std::isfinite(object0->mtype.phys_info.rotvel.y)); |
| 1817 | ASSERT(std::isfinite(object0->mtype.phys_info.rotvel.z)); |
| 1818 | ASSERT(std::isfinite(object1->mtype.phys_info.velocity.x)); |
| 1819 | ASSERT(std::isfinite(object1->mtype.phys_info.velocity.y)); |
| 1820 | ASSERT(std::isfinite(object1->mtype.phys_info.velocity.z)); |
| 1821 | ASSERT(std::isfinite(object0->mtype.phys_info.velocity.x)); |
| 1822 | ASSERT(std::isfinite(object0->mtype.phys_info.velocity.y)); |
| 1823 | ASSERT(std::isfinite(object0->mtype.phys_info.velocity.z)); |
| 1824 | |
| 1825 | vector r1 = *collision_point - object0->pos; |
| 1826 | vector r2 = *collision_point - object1->pos; |
| 1827 | vector w1; |
| 1828 | vector w2; |
| 1829 | vector n1; |
| 1830 | vector n2; |
| 1831 | float temp1; |
| 1832 | float temp2; |
| 1833 | |
| 1834 | float j; |
| 1835 | |
| 1836 | matrix o_t1 = object0->orient; |
| 1837 | matrix o_t2 = object1->orient; |
| 1838 | |
| 1839 | vm_TransposeMatrix(&o_t1); |
| 1840 | vm_TransposeMatrix(&o_t2); |
| 1841 | |
| 1842 | vector cmp1 = object0->mtype.phys_info.rotvel * o_t1; |
| 1843 | vector cmp2 = object1->mtype.phys_info.rotvel * o_t2; |
| 1844 | |
| 1845 | ConvertEulerToAxisAmount(&cmp1, &n1, &temp1); |
| 1846 | ConvertEulerToAxisAmount(&cmp2, &n2, &temp2); |
| 1847 | |
| 1848 | n1 *= temp1; |
| 1849 | n2 *= temp2; |
| 1850 | |
| 1851 | if (temp1 != 0.0f) { |
| 1852 | vm_CrossProduct(&w1, &n1, &r1); |
| 1853 | } else { |
| 1854 | w1 = Zero_vector; |
| 1855 | } |
| 1856 | |
| 1857 | if (temp2 != 0.0f) { |
| 1858 | vm_CrossProduct(&w2, &n2, &r2); |
| 1859 | } else { |
| 1860 | w2 = Zero_vector; |
| 1861 | } |
| 1862 | |
| 1863 | vector p1 = object0->mtype.phys_info.velocity + w1; |
| 1864 | vector p2 = object1->mtype.phys_info.velocity + w2; |
| 1865 | float v_rel; |
| 1866 | |
| 1867 | float m1 = object0->mtype.phys_info.mass; |
| 1868 | float m2 = object1->mtype.phys_info.mass; |
| 1869 | |
| 1870 | bool f_force_1 = IsOKToApplyForce(object0); |
| 1871 | bool f_force_2 = IsOKToApplyForce(object1); |
| 1872 | |
| 1873 | ASSERT(m1 != 0.0f && m2 != 0.0f); |
| 1874 | if (m1 <= 0.0f) |
| 1875 | m1 = 0.00000001f; |
| 1876 | if (m2 <= 0.0f) |
| 1877 | m2 = 0.00000001f; |
| 1878 | |
| 1879 | v_rel = *collision_normal * (p1 - p2); |
| 1880 | |
| 1881 | float e; |
| 1882 | |
| 1883 | if (object0->type == OBJ_PLAYER && object1->type == OBJ_PLAYER) |
| 1884 | e = 0.015f; |
| 1885 | else if ((object0->type == OBJ_WEAPON || object1->type == OBJ_WEAPON) && |
| 1886 | (object0->type != OBJ_PLAYER && object1->type != OBJ_PLAYER)) |
| 1887 | e = 1.0f; |
| 1888 | else if ((object0->type == OBJ_CLUTTER && object1->type == OBJ_PLAYER) || |
| 1889 | (object0->type == OBJ_PLAYER && object1->type == OBJ_CLUTTER)) |
| 1890 | e = 0.5f; |
| 1891 | else |
| 1892 | e = 0.1f; |
| 1893 | |
| 1894 | vector c1; |
| 1895 | vector c2; |
| 1896 | vector cc1; |
| 1897 | vector cc2; |
| 1898 | float cv1; |
| 1899 | float cv2; |
| 1900 | |
| 1901 | // matrix i1; |
| 1902 | // matrix i2; |
| 1903 | float i1 = (2.0f / 5.0f) * m1 * object0->size * object0->size; |
| 1904 | float i2 = (2.0f / 5.0f) * m2 * object1->size * object1->size; |
| 1905 | |
| 1906 | if (i1 < .0000001) |
| 1907 | i1 = .0000001f; |
| 1908 | if (i2 < .0000001) |
| 1909 | i2 = .0000001f; |
| 1910 | |
| 1911 | vm_CrossProduct(&c1, &r1, collision_normal); |
| 1912 | vm_CrossProduct(&c2, &r2, collision_normal); |
| 1913 | |
| 1914 | c1 = c1 / i1; |
| 1915 | c2 = c2 / i2; |
| 1916 | |
| 1917 | vm_CrossProduct(&cc1, &c1, &r1); |
| 1918 | vm_CrossProduct(&cc2, &c2, &r2); |
| 1919 | |
| 1920 | cv1 = (*collision_normal) * c1; |
| 1921 | cv2 = (*collision_normal) * c2; |
| 1922 | |
| 1923 | j = (-(1.0f + e)) * v_rel; |
| 1924 | j /= (1 / m1 + 1 / m2 + cv1 + cv2); |
| 1925 | |
| 1926 | if (f_force_1) |
| 1927 | object0->mtype.phys_info.velocity += ((j * (*collision_normal)) / m1); |
| 1928 | |
| 1929 | if (f_force_2) |
| 1930 | object1->mtype.phys_info.velocity -= ((j * (*collision_normal)) / m2); |
| 1931 | |
| 1932 | vector jcn = j * (*collision_normal); |
| 1933 | |
| 1934 | vm_CrossProduct(&c1, &r1, &jcn); |
| 1935 | vm_CrossProduct(&c2, &r2, &jcn); |
| 1936 | |
| 1937 | n1 = (c1) / i1; |
| 1938 | n2 = (c2) / i2; |
| 1939 | |
| 1940 | temp1 = vm_NormalizeVector(&n1); |
| 1941 | temp2 = vm_NormalizeVector(&n2); |
| 1942 | |
| 1943 | vector txx1; |
| 1944 | vector txx2; |
| 1945 | |
| 1946 | ConvertAxisAmountToEuler(&n1, &temp1, &txx1); |
| 1947 | ConvertAxisAmountToEuler(&n2, &temp2, &txx2); |
| 1948 | |
| 1949 | float rotscale1, rotscale2; |
| 1950 | |
| 1951 | if (object0->type == OBJ_PLAYER) |
| 1952 | rotscale1 = PLAYER_ROTATION_BY_FORCE_SCALAR; |
| 1953 | else |
| 1954 | rotscale1 = NONPLAYER_ROTATION_BY_FORCE_SCALAR; |
| 1955 | |
| 1956 | if (object1->type == OBJ_PLAYER) |
| 1957 | rotscale2 = PLAYER_ROTATION_BY_FORCE_SCALAR; |
| 1958 | else |
| 1959 | rotscale2 = NONPLAYER_ROTATION_BY_FORCE_SCALAR; |
| 1960 | |
| 1961 | if (f_force_1) |
| 1962 | object0->mtype.phys_info.rotvel += (txx1 * object0->orient) * rotscale1; |
| 1963 | |
| 1964 | if (f_force_2) |
| 1965 | object1->mtype.phys_info.rotvel += (txx2 * object1->orient) * rotscale2; |
| 1966 | |
| 1967 | ASSERT(std::isfinite(object1->mtype.phys_info.rotvel.x)); |
| 1968 | ASSERT(std::isfinite(object1->mtype.phys_info.rotvel.y)); |
| 1969 | ASSERT(std::isfinite(object1->mtype.phys_info.rotvel.z)); |
| 1970 | ASSERT(std::isfinite(object0->mtype.phys_info.rotvel.x)); |
| 1971 | ASSERT(std::isfinite(object0->mtype.phys_info.rotvel.y)); |
| 1972 | ASSERT(std::isfinite(object0->mtype.phys_info.rotvel.z)); |
| 1973 | ASSERT(std::isfinite(object1->mtype.phys_info.velocity.x)); |
| 1974 | ASSERT(std::isfinite(object1->mtype.phys_info.velocity.y)); |
| 1975 | ASSERT(std::isfinite(object1->mtype.phys_info.velocity.z)); |
| 1976 | ASSERT(std::isfinite(object0->mtype.phys_info.velocity.x)); |
| 1977 | ASSERT(std::isfinite(object0->mtype.phys_info.velocity.y)); |
| 1978 | ASSERT(std::isfinite(object0->mtype.phys_info.velocity.z)); |
| 1979 | |
| 1980 | // Do ForceFeedback stuff for moving objects |
| 1981 | //----------------------------------------- |
| 1982 | if (ForceIsEnabled()) { |
| 1983 | |
| 1984 | if (object0->type == OBJ_PLAYER && object0->id == Player_num) { |
| 1985 | // v is the force vector |
| 1986 | vector v; |
| 1987 | v = -1.0f * v_rel * (*collision_normal); |
| 1988 | |
| 1989 | // Was it weapon->player collide |
| 1990 | switch (object1->type) { |
| 1991 | case OBJ_WEAPON: |
| 1992 | // Do force effect for player/weapon collision |
| 1993 | DoForceForWeapon(object0, object1, &v); |
| 1994 | break; |
| 1995 | default: |
| 1996 | break; |
| 1997 | } |
| 1998 | } |
| 1999 | } |
| 2000 | |
| 2001 | // Catch things on fire if possible |
| 2002 | if (object0->effect_info && object1->effect_info) { |
| 2003 | // One of these objects must be burning |
| 2004 | if ((object0->effect_info->type_flags & EF_NAPALMED) || (object1->effect_info->type_flags & EF_NAPALMED)) { |
| 2005 | // Both cannot be burning |
| 2006 | if (!(object0->effect_info->type_flags & EF_NAPALMED) || !(object1->effect_info->type_flags & EF_NAPALMED)) { |
| 2007 | object *src_obj, *dest_obj; |
| 2008 | if (object0->effect_info->type_flags & EF_NAPALMED) { |
| 2009 | src_obj = object0; |
| 2010 | dest_obj = object1; |
| 2011 | } else { |
| 2012 | src_obj = object1; |
| 2013 | dest_obj = object0; |
| 2014 | } |
| 2015 | |
| 2016 | dest_obj->effect_info->type_flags |= EF_NAPALMED; |
| 2017 | |
| 2018 | dest_obj->effect_info->damage_time = std::max(1.0f, src_obj->effect_info->damage_time / 3.0f); |
| 2019 | dest_obj->effect_info->damage_per_second = src_obj->effect_info->damage_per_second; |
| 2020 | |
| 2021 | // We need this cap (as the gb burns forever |
| 2022 | if (dest_obj->effect_info->damage_time > 10.0f) { |
| 2023 | dest_obj->effect_info->damage_time = 10.0f; |
| 2024 | } |
| 2025 | |
| 2026 | dest_obj->effect_info->last_damage_time = 0; |
| 2027 | |
| 2028 | dest_obj->effect_info->damage_handle = src_obj->handle; |
| 2029 | |
| 2030 | if (dest_obj->effect_info->sound_handle == SOUND_NONE_INDEX) |
| 2031 | dest_obj->effect_info->sound_handle = |
| 2032 | Sound_system.Play3dSound(SOUND_PLAYER_BURNING, SND_PRIORITY_HIGHEST, dest_obj); |
| 2033 | } |
| 2034 | } |
| 2035 | } |
| 2036 | } |
| 2037 | |
| 2038 | void collide_player_and_player(object *p1, object *p2, vector *collision_point, vector *collision_normal, |
| 2039 | bool f_reverse_normal, fvi_info *hit_info) { |
| 2040 | if (f_reverse_normal) |
| 2041 | *collision_normal *= -1.0f; |
| 2042 | |
| 2043 | vector rvel = p1->mtype.phys_info.velocity - p2->mtype.phys_info.velocity; |
| 2044 | float speed = vm_NormalizeVector(&rvel); |
| 2045 | float scalar; |
| 2046 | |
| 2047 | if (speed <= MIN_WALL_HIT_SOUND_VEL) { |
| 2048 | scalar = 0.0f; |
| 2049 | } else if (speed >= MAX_WALL_HIT_SOUND_VEL) { |
| 2050 | scalar = 1.0f; |
| 2051 | } else { |
| 2052 | scalar = (speed - MIN_WALL_HIT_SOUND_VEL) / (MAX_WALL_HIT_SOUND_VEL - MIN_WALL_HIT_SOUND_VEL); |
| 2053 | } |
| 2054 | |
| 2055 | if (scalar > .01) { |
| 2056 | pos_state cur_pos; |
| 2057 | cur_pos.position = collision_point; |
| 2058 | cur_pos.orient = &p1->orient; |
| 2059 | cur_pos.roomnum = p1->roomnum; |
| 2060 | |
| 2061 | Sound_system.Play3dSound(SOUND_PLAYER_HIT_WALL, SND_PRIORITY_HIGHEST, &cur_pos, MAX_GAME_VOLUME * scalar); |
| 2062 | } |
| 2063 | |
| 2064 | bump_two_objects(p1, p2, collision_point, collision_normal, 1); |
| 2065 | } |
| 2066 | |
| 2067 | void collide_generic_and_player(object *robotobj, object *playerobj, vector *collision_point, vector *collision_normal, |
| 2068 | bool f_reverse_normal, fvi_info *hit_info) { |
| 2069 | if (f_reverse_normal) |
| 2070 | *collision_normal *= -1.0f; |
| 2071 | |
| 2072 | vector rvel; |
| 2073 | if (robotobj->movement_type == MT_PHYSICS || robotobj->movement_type == MT_WALKING) { |
| 2074 | rvel = robotobj->mtype.phys_info.velocity; |
| 2075 | } else { |
| 2076 | rvel = Zero_vector; |
| 2077 | } |
| 2078 | rvel -= playerobj->mtype.phys_info.velocity; |
| 2079 | float speed = vm_NormalizeVector(&rvel); |
| 2080 | float scalar; |
| 2081 | |
| 2082 | if (speed <= MIN_WALL_HIT_SOUND_VEL) { |
| 2083 | scalar = 0.0f; |
| 2084 | } else if (speed >= MAX_WALL_HIT_SOUND_VEL) { |
| 2085 | scalar = 1.0f; |
| 2086 | } else { |
| 2087 | scalar = (speed - MIN_WALL_HIT_SOUND_VEL) / (MAX_WALL_HIT_SOUND_VEL - MIN_WALL_HIT_SOUND_VEL); |
| 2088 | } |
| 2089 | |
| 2090 | // Check for lava surface on an object |
| 2091 | if ((robotobj->type == OBJ_BUILDING) && hit_info) { |
| 2092 | poly_model *pm = GetPolymodelPointer(robotobj->rtype.pobj_info.model_num); |
| 2093 | int tmap = pm->textures[pm->submodel[hit_info->hit_subobject[0]].faces[hit_info->hit_face[0]].texnum]; |
| 2094 | |
| 2095 | if (GameTextures[tmap].flags & TF_LAVA) { |
| 2096 | if (!((Game_mode & GM_MULTI) && (Netgame.local_role == LR_CLIENT))) { |
| 2097 | int id = FindWeaponName("NapalmBlob"); |
| 2098 | if (id >= 0) |
| 2099 | SetNapalmDamageEffect(playerobj, nullptr, id); |
| 2100 | else |
| 2101 | Int3(); |
| 2102 | } |
| 2103 | scalar = 0; // don't make collide sound |
| 2104 | } |
| 2105 | } |
| 2106 | |
| 2107 | if (scalar > .01 || (robotobj->mtype.phys_info.flags & PF_LOCK_MASK)) { |
| 2108 | pos_state cur_pos; |
| 2109 | cur_pos.position = collision_point; |
| 2110 | cur_pos.orient = &playerobj->orient; |
| 2111 | cur_pos.roomnum = playerobj->roomnum; |
| 2112 | |
| 2113 | Sound_system.Play3dSound(SOUND_PLAYER_HIT_WALL, SND_PRIORITY_HIGHEST, &cur_pos, MAX_GAME_VOLUME * scalar); |
| 2114 | |
| 2115 | ain_hear hear; |
| 2116 | hear.f_directly_player = true; |
| 2117 | hear.hostile_level = 0.10f; |
| 2118 | hear.curiosity_level = 0.5f; |
| 2119 | hear.max_dist = Sounds[SOUND_PLAYER_HIT_WALL].max_distance * scalar; |
| 2120 | AINotify(playerobj, AIN_HEAR_NOISE, (void *)&hear); |
| 2121 | |
| 2122 | if ((scalar > .25f && (robotobj->movement_type == MT_WALKING || robotobj->movement_type == MT_PHYSICS)) || |
| 2123 | ((robotobj->mtype.phys_info.flags & PF_LOCK_MASK) && |
| 2124 | (robotobj->mtype.phys_info.flags & PF_POINT_COLLIDE_WALLS))) { |
| 2125 | if (!(IS_GUIDEBOT(robotobj))) { |
| 2126 | if (robotobj->shields <= 1.0f) { |
| 2127 | ApplyDamageToGeneric(robotobj, playerobj, GD_PHYSICS, 2.0f); |
| 2128 | } else { |
| 2129 | ApplyDamageToGeneric(robotobj, playerobj, GD_PHYSICS, 5.0f * Frametime * scalar); |
| 2130 | } |
| 2131 | if (scalar < 1.0f && (robotobj->mtype.phys_info.flags & PF_LOCK_MASK) && |
| 2132 | (robotobj->mtype.phys_info.flags & PF_POINT_COLLIDE_WALLS)) |
| 2133 | scalar = 1.0f; |
| 2134 | |
| 2135 | ApplyDamageToPlayer(playerobj, playerobj, PD_WALL_HIT, 2.0f * Frametime * scalar); |
| 2136 | } |
| 2137 | } |
| 2138 | } |
| 2139 | |
| 2140 | if (robotobj->control_type == CT_AI) { |
| 2141 | AINotify(robotobj, AIN_BUMPED_OBJ, (void *)playerobj); |
| 2142 | } |
| 2143 | |
| 2144 | bump_two_objects(robotobj, playerobj, collision_point, collision_normal, 1); |
| 2145 | } |
| 2146 | |
| 2147 | void MakeWeaponStick(object *weapon, object *parent, fvi_info *hit_info) { |
| 2148 | weapon->mtype.obj_link_info.parent_handle = parent->handle; |
| 2149 | weapon->mtype.obj_link_info.fvec = hit_info->hit_subobj_fvec; |
| 2150 | weapon->mtype.obj_link_info.uvec = hit_info->hit_subobj_uvec; |
| 2151 | weapon->mtype.obj_link_info.pos = hit_info->hit_subobj_pos; |
| 2152 | weapon->mtype.obj_link_info.sobj_index = hit_info->hit_subobject[0]; |
| 2153 | weapon->movement_type = MT_OBJ_LINKED; |
| 2154 | } |
| 2155 | |
| 2156 | void collide_generic_and_weapon(object *robotobj, object *weapon, vector *collision_point, vector *collision_normal, |
| 2157 | bool f_reverse_normal, fvi_info *hit_info) { |
| 2158 | object *parent_obj; |
| 2159 | float damage_to_apply; |
| 2160 | uint8_t electrical = (Weapons[weapon->id].flags & WF_ELECTRICAL) ? 1 : 0; |
| 2161 | bool f_stick = ((weapon->mtype.phys_info.flags & PF_STICK) != 0); |
| 2162 | bool f_energy = ((Weapons[weapon->id].flags & WF_MATTER_WEAPON) == 0); |
| 2163 | int damage_type; |
| 2164 | |
| 2165 | // Check for lava & volatile surfaces on an object |
| 2166 | if ((robotobj->type == OBJ_BUILDING) && hit_info) { |
| 2167 | poly_model *pm = GetPolymodelPointer(robotobj->rtype.pobj_info.model_num); |
| 2168 | int tmap = pm->textures[pm->submodel[hit_info->hit_subobject[0]].faces[hit_info->hit_face[0]].texnum]; |
| 2169 | vector *normal = &hit_info->hit_wallnorm[0]; |
| 2170 | |
| 2171 | DoWallEffects(weapon, tmap); |
| 2172 | |
| 2173 | check_for_special_surface(weapon, tmap, normal, 1.0); |
| 2174 | |
| 2175 | // If object died, stop processing |
| 2176 | if (weapon->flags & OF_DEAD) |
| 2177 | return; |
| 2178 | } |
| 2179 | |
| 2180 | if (Weapons[weapon->id].flags & WF_NAPALM) |
| 2181 | damage_type = GD_FIRE; |
| 2182 | else if (Weapons[weapon->id].flags & WF_MATTER_WEAPON) |
| 2183 | damage_type = GD_MATTER; |
| 2184 | else if (Weapons[weapon->id].flags & WF_ELECTRICAL) |
| 2185 | damage_type = GD_ELECTRIC; |
| 2186 | else |
| 2187 | damage_type = GD_ENERGY; |
| 2188 | |
| 2189 | if (f_reverse_normal) |
| 2190 | *collision_normal *= -1.0f; |
| 2191 | |
| 2192 | if (robotobj->flags & OF_DYING) |
| 2193 | robotobj->ctype.dying_info.delay_time *= 0.975f; |
| 2194 | |
| 2195 | if (Weapons[weapon->id].sounds[WSI_IMPACT_WALL] != SOUND_NONE_INDEX) { |
| 2196 | Sound_system.Play3dSound(Weapons[weapon->id].sounds[WSI_IMPACT_WALL], SND_PRIORITY_HIGH, weapon); |
| 2197 | |
| 2198 | ain_hear hear; |
| 2199 | hear.f_directly_player = false; |
| 2200 | if (robotobj->control_type == CT_AI) { |
| 2201 | hear.hostile_level = 1.0f; |
| 2202 | hear.curiosity_level = 0.1f; |
| 2203 | } else if (robotobj->type == OBJ_DOOR) { |
| 2204 | hear.hostile_level = 0.5f; |
| 2205 | hear.curiosity_level = 1.0f; |
| 2206 | } else { |
| 2207 | hear.hostile_level = .9f; |
| 2208 | hear.curiosity_level = 0.5f; |
| 2209 | } |
| 2210 | |
| 2211 | hear.max_dist = Sounds[Weapons[weapon->id].sounds[WSI_IMPACT_WALL]].max_distance; |
| 2212 | AINotify(weapon, AIN_HEAR_NOISE, (void *)&hear); |
| 2213 | } |
| 2214 | |
| 2215 | // Do weapon explosion stuff |
| 2216 | DoWeaponExploded(weapon, collision_normal, collision_point); |
| 2217 | |
| 2218 | // Check to see if we should spawn |
| 2219 | if (robotobj->type == OBJ_DOOR && !(Game_mode & GM_MULTI)) { |
| 2220 | if ((Weapons[weapon->id].flags & WF_SPAWNS_IMPACT) && Weapons[weapon->id].spawn_count > 0 && |
| 2221 | Weapons[weapon->id].spawn_handle >= 0) |
| 2222 | CreateImpactSpawnFromWeapon(weapon, collision_normal); |
| 2223 | } |
| 2224 | |
| 2225 | if ((Weapons[weapon->id].flags & WF_SPAWNS_ROBOT) && (Weapons[weapon->id].flags & WF_COUNTERMEASURE) && |
| 2226 | Weapons[weapon->id].robot_spawn_handle >= 0) |
| 2227 | CreateRobotSpawnFromWeapon(weapon); |
| 2228 | |
| 2229 | parent_obj = ObjGet(weapon->parent_handle); |
| 2230 | |
| 2231 | if ((parent_obj) && (parent_obj->control_type == CT_AI)) { |
| 2232 | AINotify(parent_obj, AIN_WHIT_OBJECT, (void *)robotobj); |
| 2233 | } |
| 2234 | |
| 2235 | if (robotobj->control_type == CT_AI) { |
| 2236 | AINotify(robotobj, AIN_HIT_BY_WEAPON, (void *)weapon); |
| 2237 | } |
| 2238 | |
| 2239 | if (electrical) { |
| 2240 | damage_to_apply = Weapons[weapon->id].generic_damage * Frametime; |
| 2241 | } else |
| 2242 | damage_to_apply = Weapons[weapon->id].generic_damage; |
| 2243 | |
| 2244 | // Factor in multiplier |
| 2245 | damage_to_apply *= weapon->ctype.laser_info.multiplier; |
| 2246 | |
| 2247 | if (ApplyDamageToGeneric(robotobj, weapon, damage_type, damage_to_apply)) { |
| 2248 | if (Weapons[weapon->id].sounds[WSI_IMPACT_ROBOT] != SOUND_NONE_INDEX) { |
| 2249 | Sound_system.Play3dSound(Weapons[weapon->id].sounds[WSI_IMPACT_ROBOT], SND_PRIORITY_HIGHEST, weapon); |
| 2250 | } |
| 2251 | if (!electrical) { |
| 2252 | light_info *li = &Weapons[weapon->id].lighting_info; |
| 2253 | uint16_t color = GR_RGB16(li->red_light2 * 255, li->green_light2 * 255, li->blue_light2 * 255); |
| 2254 | CreateRandomLineSparks(3 + ps_rand() % 6, &weapon->pos, weapon->roomnum, color); |
| 2255 | } |
| 2256 | } |
| 2257 | #if 0 |
| 2258 | if(Demo_flags == DF_RECORDING) |
| 2259 | { |
| 2260 | DemoWriteCollideGenericWeapon( robotobj, weapon, collision_point, collision_normal, f_reverse_normal, hit_info ); |
| 2261 | } |
| 2262 | else if(Demo_flags == DF_PLAYBACK) |
| 2263 | { |
| 2264 | //During playback we don't need the code below (actually it won't work) |
| 2265 | return; |
| 2266 | } |
| 2267 | #endif |
| 2268 | |
| 2269 | if (!electrical) { |
| 2270 | |
| 2271 | bump_two_objects(robotobj, weapon, collision_point, collision_normal, 0); |
| 2272 | |
| 2273 | if (!f_stick || (hit_info == nullptr)) { |
| 2274 | if ((robotobj->lighting_render_type == LRT_LIGHTMAPS) || !(weapon->mtype.phys_info.flags & PF_PERSISTENT)) |
| 2275 | SetObjectDeadFlag(weapon); |
| 2276 | } else { |
| 2277 | MakeWeaponStick(weapon, robotobj, hit_info); |
| 2278 | } |
| 2279 | } |
| 2280 | } |
| 2281 | |
| 2282 | void collide_player_and_weapon(object *playerobj, object *weapon, vector *collision_point, vector *collision_normal, |
| 2283 | bool f_reverse_normal, fvi_info *hit_info) { |
| 2284 | object *parent_obj; |
| 2285 | float damage_to_apply; |
| 2286 | uint8_t electrical = Weapons[weapon->id].flags & WF_ELECTRICAL ? 1 : 0; |
| 2287 | bool f_stick = ((weapon->mtype.phys_info.flags & PF_STICK) != 0); |
| 2288 | |
| 2289 | if (f_reverse_normal) |
| 2290 | *collision_normal *= -1.0f; |
| 2291 | |
| 2292 | parent_obj = ObjGet(weapon->parent_handle); |
| 2293 | |
| 2294 | if ((parent_obj) && (parent_obj->control_type == CT_AI)) { |
| 2295 | AINotify(parent_obj, AIN_WHIT_OBJECT, (void *)playerobj); |
| 2296 | } |
| 2297 | |
| 2298 | // Do weapon explosion stuff |
| 2299 | DoWeaponExploded(weapon, collision_normal, collision_point, playerobj); |
| 2300 | |
| 2301 | // Check to see if we should spawn |
| 2302 | /*if ((Weapons[weapon->id].flags & WF_SPAWNS_IMPACT) && Weapons[weapon->id].spawn_count>0 && |
| 2303 | Weapons[weapon->id].spawn_handle>=0) CreateImpactSpawnFromWeapon (weapon,collision_normal);*/ |
| 2304 | |
| 2305 | if ((Weapons[weapon->id].flags & WF_SPAWNS_ROBOT) && (Weapons[weapon->id].flags & WF_COUNTERMEASURE) && |
| 2306 | Weapons[weapon->id].robot_spawn_handle >= 0) |
| 2307 | CreateRobotSpawnFromWeapon(weapon); |
| 2308 | |
| 2309 | if (electrical) |
| 2310 | damage_to_apply = Weapons[weapon->id].player_damage * Frametime; |
| 2311 | else |
| 2312 | damage_to_apply = Weapons[weapon->id].player_damage; |
| 2313 | |
| 2314 | // Factor in multiplier |
| 2315 | damage_to_apply *= weapon->ctype.laser_info.multiplier; |
| 2316 | |
| 2317 | int damage_type = electrical ? PD_ENERGY_WEAPON : PD_MATTER_WEAPON; |
| 2318 | |
| 2319 | if (ApplyDamageToPlayer(playerobj, weapon, damage_type, damage_to_apply)) { |
| 2320 | // we were damaged! |
| 2321 | if (Weapons[weapon->id].sounds[WSI_IMPACT_ROBOT] != SOUND_NONE_INDEX) |
| 2322 | Sound_system.Play3dSound(Weapons[weapon->id].sounds[WSI_IMPACT_ROBOT], SND_PRIORITY_NORMAL, weapon); |
| 2323 | } |
| 2324 | #if 0 |
| 2325 | if(Demo_flags == DF_RECORDING) |
| 2326 | { |
| 2327 | DemoWriteCollidePlayerWeapon( playerobj, weapon, collision_point, collision_normal, f_reverse_normal, hit_info ); |
| 2328 | } |
| 2329 | else if(Demo_flags == DF_PLAYBACK) |
| 2330 | { |
| 2331 | //During playback we don't need the code below (actually it won't work) |
| 2332 | return; |
| 2333 | } |
| 2334 | #endif |
| 2335 | |
| 2336 | if (!electrical) { |
| 2337 | bump_two_objects(playerobj, weapon, collision_point, collision_normal, 0); |
| 2338 | |
| 2339 | if (!f_stick || (hit_info == nullptr)) { |
| 2340 | if (!(weapon->mtype.phys_info.flags & PF_PERSISTENT)) |
| 2341 | SetObjectDeadFlag(weapon); |
| 2342 | } else { |
| 2343 | MakeWeaponStick(weapon, playerobj, hit_info); |
| 2344 | } |
| 2345 | } |
| 2346 | } |
| 2347 | |
| 2348 | #define COLLISION_OF(a, b) (((a) << 8) + (b)) |
| 2349 | |
| 2350 | #define DO_COLLISION(type1, type2, collision_function) \ |
| 2351 | case COLLISION_OF((type1), (type2)): \ |
| 2352 | (collision_function)((A), (B), collision_point, collision_normal, false, hit_info); \ |
| 2353 | break; \ |
| 2354 | case COLLISION_OF((type2), (type1)): \ |
| 2355 | (collision_function)((B), (A), collision_point, collision_normal, true, hit_info); \ |
| 2356 | break; |
| 2357 | |
| 2358 | #define DO_SAME_COLLISION(type1, type2, collision_function) \ |
| 2359 | case COLLISION_OF((type1), (type1)): \ |
| 2360 | (collision_function)((A), (B), collision_point, collision_normal, false, hit_info); \ |
| 2361 | break; |
| 2362 | |
| 2363 | #define NO_COLLISION(type1, type2) \ |
| 2364 | case COLLISION_OF((type1), (type2)): \ |
| 2365 | case COLLISION_OF((type2), (type1)): \ |
| 2366 | break; |
| 2367 | |
| 2368 | void check_lg_inform(object *A, object *B) { |
| 2369 | if (A->flags & (OF_INFORM_PLAYER_COLLIDE_TO_LG | OF_INFORM_PLAYER_WEAPON_COLLIDE_TO_LG)) { |
| 2370 | if (B->type == OBJ_PLAYER) { |
| 2371 | bool f_pwc = (A->flags & OF_INFORM_PLAYER_WEAPON_COLLIDE_TO_LG) != 0; |
| 2372 | int type; |
| 2373 | |
| 2374 | if (f_pwc) { |
| 2375 | type = OF_INFORM_PLAYER_WEAPON_COLLIDE_TO_LG; |
| 2376 | } else { |
| 2377 | type = OF_INFORM_PLAYER_COLLIDE_TO_LG; |
| 2378 | } |
| 2379 | |
| 2380 | Level_goals.Inform(LIT_OBJECT, type, A->handle); |
| 2381 | } |
| 2382 | } |
| 2383 | |
| 2384 | if (A->flags & OF_INFORM_PLAYER_WEAPON_COLLIDE_TO_LG) { |
| 2385 | if (B->type == OBJ_WEAPON) { |
| 2386 | object *parent = ObjGetUltimateParent(B); |
| 2387 | |
| 2388 | if (parent && parent->type == OBJ_PLAYER) { |
| 2389 | Level_goals.Inform(LIT_OBJECT, OF_INFORM_PLAYER_WEAPON_COLLIDE_TO_LG, A->handle); |
| 2390 | } |
| 2391 | } |
| 2392 | } |
| 2393 | } |
| 2394 | |
| 2395 | void collide_two_objects(object *A, object *B, vector *collision_point, vector *collision_normal, fvi_info *hit_info) { |
| 2396 | int collision_type; |
| 2397 | int a_num = A - Objects; |
| 2398 | int b_num = B - Objects; |
| 2399 | uint8_t a_good = 0, b_good = 0; |
| 2400 | uint8_t a_hittime_good = 1, b_hittime_good = 1; |
| 2401 | |
| 2402 | // Only do omega particle collisions if specifically allowed |
| 2403 | extern bool Enable_omega_collions; |
| 2404 | if (((A->type == OBJ_WEAPON) && (A->id == OMEGA_INDEX)) || ((B->type == OBJ_WEAPON) && (B->id == OMEGA_INDEX))) |
| 2405 | if (!Enable_omega_collions) |
| 2406 | return; |
| 2407 | |
| 2408 | ASSERT(CollisionResult[A->type][B->type] != RESULT_NOTHING); |
| 2409 | |
| 2410 | collision_type = COLLISION_OF(A->type, B->type); |
| 2411 | |
| 2412 | check_lg_inform(A, B); |
| 2413 | check_lg_inform(B, A); |
| 2414 | |
| 2415 | // mprintf( (0, "Object %d of type %d collided with object %d of type %d\n", A-Objects,A->type, B-Objects, B->type )); |
| 2416 | |
| 2417 | // COLLISION SCRIPT HOOK |
| 2418 | if (Game_mode & GM_MULTI) { |
| 2419 | ASSERT(!(A->flags & OF_DEAD)); |
| 2420 | ASSERT(!(B->flags & OF_DEAD)); |
| 2421 | |
| 2422 | // Make sure we have good scripts to call |
| 2423 | if (A->type == OBJ_PLAYER || A->type == OBJ_ROBOT || A->type == OBJ_POWERUP || A->type == OBJ_WEAPON || |
| 2424 | A->type == OBJ_BUILDING || A->type == OBJ_DOOR || A->type == OBJ_CLUTTER) |
| 2425 | a_good = 1; |
| 2426 | if (B->type == OBJ_PLAYER || B->type == OBJ_ROBOT || B->type == OBJ_POWERUP || B->type == OBJ_WEAPON || |
| 2427 | B->type == OBJ_BUILDING || B->type == OBJ_DOOR || B->type == OBJ_CLUTTER) |
| 2428 | b_good = 1; |
| 2429 | |
| 2430 | if (A->type == OBJ_PLAYER && (Players[A->id].flags & (PLAYER_FLAGS_DYING | PLAYER_FLAGS_DEAD))) |
| 2431 | a_good = 0; |
| 2432 | if (B->type == OBJ_PLAYER && (Players[B->id].flags & (PLAYER_FLAGS_DYING | PLAYER_FLAGS_DEAD))) |
| 2433 | b_good = 0; |
| 2434 | |
| 2435 | if (A->type == OBJ_POWERUP && A->effect_info->last_object_hit == b_num && |
| 2436 | (Gametime - A->effect_info->last_object_hit_time) < 1) { |
| 2437 | a_good = 0; |
| 2438 | a_hittime_good = 0; |
| 2439 | } |
| 2440 | |
| 2441 | if (B->type == OBJ_POWERUP && B->effect_info->last_object_hit == a_num && |
| 2442 | (Gametime - B->effect_info->last_object_hit_time) < 1) { |
| 2443 | b_good = 0; |
| 2444 | b_hittime_good = 0; |
| 2445 | } |
| 2446 | |
| 2447 | if (a_good && b_good) { |
| 2448 | DLLInfo.me_handle = A->handle; |
| 2449 | DLLInfo.it_handle = B->handle; |
| 2450 | DLLInfo.collide_info.point.x = collision_point->x; |
| 2451 | DLLInfo.collide_info.point.y = collision_point->y; |
| 2452 | DLLInfo.collide_info.point.z = collision_point->z; |
| 2453 | DLLInfo.collide_info.normal.x = collision_normal->x; |
| 2454 | DLLInfo.collide_info.normal.y = collision_normal->y; |
| 2455 | DLLInfo.collide_info.normal.z = collision_normal->z; |
| 2456 | CallGameDLL(EVT_GAMECOLLIDE, &DLLInfo); |
| 2457 | |
| 2458 | DLLInfo.me_handle = B->handle; |
| 2459 | DLLInfo.it_handle = A->handle; |
| 2460 | CallGameDLL(EVT_GAMECOLLIDE, &DLLInfo); |
| 2461 | |
| 2462 | // Update static variables |
| 2463 | if (A->type == OBJ_POWERUP) { |
| 2464 | A->effect_info->last_object_hit = b_num; |
| 2465 | A->effect_info->last_object_hit_time = Gametime; |
| 2466 | } |
| 2467 | if (B->type == OBJ_POWERUP) { |
| 2468 | B->effect_info->last_object_hit = a_num; |
| 2469 | B->effect_info->last_object_hit_time = Gametime; |
| 2470 | } |
| 2471 | } |
| 2472 | } |
| 2473 | |
| 2474 | // Call script only if its ok to |
| 2475 | int ok_to_call_script = 1; |
| 2476 | if (A->type == OBJ_PLAYER && (Players[A->id].flags & (PLAYER_FLAGS_DYING | PLAYER_FLAGS_DEAD))) |
| 2477 | ok_to_call_script = 0; |
| 2478 | if (B->type == OBJ_PLAYER && (Players[B->id].flags & (PLAYER_FLAGS_DYING | PLAYER_FLAGS_DEAD))) |
| 2479 | ok_to_call_script = 0; |
| 2480 | |
| 2481 | // Check to see if we should call the script |
| 2482 | if ((Game_mode & GM_MULTI)) { |
| 2483 | if ((A->type == OBJ_POWERUP || B->type == OBJ_POWERUP) && (a_hittime_good == 0 || b_hittime_good == 0)) |
| 2484 | ok_to_call_script = 0; |
| 2485 | } |
| 2486 | |
| 2487 | if (ok_to_call_script) { |
| 2488 | |
| 2489 | if (!(Game_mode & GM_MULTI)) { |
| 2490 | ASSERT(!(A->flags & OF_DEAD)); |
| 2491 | ASSERT(!(B->flags & OF_DEAD)); |
| 2492 | } |
| 2493 | tOSIRISEventInfo ei; |
| 2494 | ei.evt_collide.it_handle = B->handle; |
| 2495 | Osiris_CallEvent(A, EVT_COLLIDE, &ei); |
| 2496 | |
| 2497 | ei.evt_collide.it_handle = A->handle; |
| 2498 | Osiris_CallEvent(B, EVT_COLLIDE, &ei); |
| 2499 | } |
| 2500 | |
| 2501 | switch (collision_type) { |
| 2502 | DO_COLLISION(OBJ_PLAYER, OBJ_WEAPON, collide_player_and_weapon) |
| 2503 | DO_COLLISION(OBJ_PLAYER, OBJ_MARKER, collide_player_and_marker) |
| 2504 | |
| 2505 | DO_COLLISION(OBJ_ROBOT, OBJ_PLAYER, collide_generic_and_player) |
| 2506 | DO_COLLISION(OBJ_BUILDING, OBJ_PLAYER, collide_generic_and_player) |
| 2507 | DO_COLLISION(OBJ_DOOR, OBJ_PLAYER, collide_generic_and_player) |
| 2508 | DO_COLLISION(OBJ_ROOM, OBJ_VIEWER, collide_generic_and_player) |
| 2509 | DO_COLLISION(OBJ_ROOM, OBJ_PLAYER, collide_generic_and_player) |
| 2510 | DO_COLLISION(OBJ_CLUTTER, OBJ_PLAYER, collide_generic_and_player) |
| 2511 | |
| 2512 | DO_COLLISION(OBJ_ROBOT, OBJ_WEAPON, collide_generic_and_weapon) |
| 2513 | DO_COLLISION(OBJ_CLUTTER, OBJ_WEAPON, collide_generic_and_weapon) |
| 2514 | DO_COLLISION(OBJ_BUILDING, OBJ_WEAPON, collide_generic_and_weapon) |
| 2515 | DO_COLLISION(OBJ_ROOM, OBJ_WEAPON, collide_generic_and_weapon) |
| 2516 | DO_COLLISION(OBJ_DOOR, OBJ_WEAPON, collide_generic_and_weapon) |
| 2517 | |
| 2518 | DO_SAME_COLLISION(OBJ_PLAYER, OBJ_PLAYER, collide_player_and_player) |
| 2519 | |
| 2520 | // Handled by the script, so no code |
| 2521 | NO_COLLISION(OBJ_PLAYER, OBJ_POWERUP) |
| 2522 | NO_COLLISION(OBJ_POWERUP, OBJ_WEAPON) |
| 2523 | |
| 2524 | default: |
| 2525 | bump_two_objects(A, B, collision_point, collision_normal, 1); |
| 2526 | } |
| 2527 | |
| 2528 | if ((A->type == OBJ_PLAYER && B->type == OBJ_POWERUP && (B->flags & OF_DEAD)) || |
| 2529 | (B->type == OBJ_PLAYER && A->type == OBJ_POWERUP && (A->flags & OF_DEAD))) { |
| 2530 | ain_hear hear; |
| 2531 | hear.f_directly_player = true; |
| 2532 | hear.hostile_level = 0.05f; |
| 2533 | hear.curiosity_level = 1.0f; |
| 2534 | |
| 2535 | hear.max_dist = Sounds[SOUND_POWERUP_PICKUP].max_distance; |
| 2536 | if (A->type == OBJ_PLAYER) |
| 2537 | AINotify(A, AIN_HEAR_NOISE, (void *)&hear); |
| 2538 | else |
| 2539 | AINotify(B, AIN_HEAR_NOISE, (void *)&hear); |
| 2540 | } |
| 2541 | } |
| 2542 | |
| 2543 | #define ENABLE_COLLISION_SPHERE_SPHERE(type1, type2) \ |
| 2544 | CollisionResult[type1][type2] = RESULT_CHECK_SPHERE_SPHERE; \ |
| 2545 | CollisionResult[type2][type1] = RESULT_CHECK_SPHERE_SPHERE; |
| 2546 | |
| 2547 | #define ENABLE_COLLISION_SPHERE_POLY(type1, type2) \ |
| 2548 | CollisionResult[type1][type2] = RESULT_CHECK_SPHERE_POLY; \ |
| 2549 | CollisionResult[type2][type1] = RESULT_CHECK_POLY_SPHERE; |
| 2550 | |
| 2551 | #define ENABLE_COLLISION_POLY_SPHERE(type1, type2) \ |
| 2552 | CollisionResult[type1][type2] = RESULT_CHECK_POLY_SPHERE; \ |
| 2553 | CollisionResult[type2][type1] = RESULT_CHECK_SPHERE_POLY; |
| 2554 | |
| 2555 | #define ENABLE_COLLISION_BBOX_POLY(type1, type2) \ |
| 2556 | CollisionResult[type1][type2] = RESULT_CHECK_BBOX_POLY; \ |
| 2557 | CollisionResult[type2][type1] = RESULT_CHECK_POLY_BBOX; |
| 2558 | |
| 2559 | #define ENABLE_COLLISION_POLY_BBOX(type1, type2) \ |
| 2560 | CollisionResult[type1][type2] = RESULT_CHECK_POLY_BBOX; \ |
| 2561 | CollisionResult[type2][type1] = RESULT_CHECK_BBOX_POLY; |
| 2562 | |
| 2563 | #define ENABLE_COLLISION_BBOX_BBOX(type1, type2) \ |
| 2564 | CollisionResult[type1][type2] = RESULT_CHECK_BBOX_BBOX; \ |
| 2565 | CollisionResult[type2][type1] = RESULT_CHECK_BBOX_BBOX; |
| 2566 | |
| 2567 | #define ENABLE_COLLISION_BBOX_SPHERE(type1, type2) \ |
| 2568 | CollisionResult[type1][type2] = RESULT_CHECK_BBOX_SPHERE; \ |
| 2569 | CollisionResult[type2][type1] = RESULT_CHECK_SPHERE_BBOX; |
| 2570 | |
| 2571 | #define ENABLE_COLLISION_SPHERE_BBOX(type1, type2) \ |
| 2572 | CollisionResult[type1][type2] = RESULT_CHECK_SPHERE_BBOX; \ |
| 2573 | CollisionResult[type2][type1] = RESULT_CHECK_BBOX_SPHERE; |
| 2574 | |
| 2575 | #define ENABLE_COLLISION_SPHERE_ROOM(type1, type2) \ |
| 2576 | CollisionResult[type1][type2] = RESULT_CHECK_SPHERE_ROOM; \ |
| 2577 | CollisionResult[type2][type1] = RESULT_CHECK_SPHERE_ROOM; |
| 2578 | |
| 2579 | #define ENABLE_COLLISION_BBOX_ROOM(type1, type2) \ |
| 2580 | CollisionResult[type1][type2] = RESULT_CHECK_BBOX_ROOM; \ |
| 2581 | CollisionResult[type2][type1] = RESULT_CHECK_BBOX_ROOM; |
| 2582 | |
| 2583 | #define DISABLE_COLLISION(type1, type2) \ |
| 2584 | CollisionResult[type1][type2] = RESULT_NOTHING; \ |
| 2585 | CollisionResult[type2][type1] = RESULT_NOTHING; |
| 2586 | |
| 2587 | void CollideInit() { |
| 2588 | int i, j; |
| 2589 | |
| 2590 | for (i = 0; i < MAX_OBJECT_TYPES; i++) |
| 2591 | for (j = 0; j < MAX_OBJECT_TYPES; j++) { |
| 2592 | CollisionResult[i][j] = RESULT_NOTHING; |
| 2593 | } |
| 2594 | |
| 2595 | for (i = 0; i < MAX_OBJECT_TYPES; i++) { |
| 2596 | CollisionRayResult[i] = RESULT_NOTHING; |
| 2597 | } |
| 2598 | CollisionRayResult[OBJ_ROBOT] = RESULT_CHECK_SPHERE_POLY; |
| 2599 | CollisionRayResult[OBJ_PLAYER] = RESULT_CHECK_SPHERE_POLY; |
| 2600 | CollisionRayResult[OBJ_WEAPON] = RESULT_CHECK_SPHERE_POLY; |
| 2601 | CollisionRayResult[OBJ_POWERUP] = RESULT_CHECK_SPHERE_POLY; |
| 2602 | CollisionRayResult[OBJ_CLUTTER] = RESULT_CHECK_SPHERE_POLY; |
| 2603 | CollisionRayResult[OBJ_BUILDING] = RESULT_CHECK_SPHERE_POLY; |
| 2604 | CollisionRayResult[OBJ_DOOR] = RESULT_CHECK_SPHERE_POLY; |
| 2605 | CollisionRayResult[OBJ_ROOM] = RESULT_CHECK_SPHERE_POLY; |
| 2606 | |
| 2607 | for (i = 0; i < MAX_OBJECT_TYPES; i++) { |
| 2608 | ENABLE_COLLISION_SPHERE_ROOM(i, OBJ_ROOM) |
| 2609 | } |
| 2610 | |
| 2611 | ENABLE_COLLISION_POLY_SPHERE(OBJ_WALL, OBJ_ROBOT) |
| 2612 | ENABLE_COLLISION_POLY_SPHERE(OBJ_WALL, OBJ_WEAPON) |
| 2613 | ENABLE_COLLISION_POLY_SPHERE(OBJ_WALL, OBJ_PLAYER) |
| 2614 | ENABLE_COLLISION_SPHERE_SPHERE(OBJ_ROBOT, OBJ_ROBOT) |
| 2615 | // ENABLE_COLLISION_SPHERE_SPHERE( OBJ_BUILDING, OBJ_BUILDING ) |
| 2616 | ENABLE_COLLISION_POLY_SPHERE(OBJ_PLAYER, OBJ_FIREBALL) |
| 2617 | ENABLE_COLLISION_SPHERE_SPHERE(OBJ_PLAYER, OBJ_PLAYER) |
| 2618 | ENABLE_COLLISION_SPHERE_SPHERE(OBJ_PLAYER, OBJ_MARKER) |
| 2619 | ENABLE_COLLISION_SPHERE_SPHERE(OBJ_MARKER, OBJ_PLAYER) |
| 2620 | ENABLE_COLLISION_SPHERE_SPHERE(OBJ_WEAPON, OBJ_WEAPON) |
| 2621 | ENABLE_COLLISION_POLY_SPHERE(OBJ_ROBOT, OBJ_PLAYER) |
| 2622 | // ENABLE_COLLISION_SPHERE_SPHERE( OBJ_ROBOT, OBJ_PLAYER ) |
| 2623 | ENABLE_COLLISION_POLY_SPHERE(OBJ_ROBOT, OBJ_WEAPON) |
| 2624 | |
| 2625 | ENABLE_COLLISION_POLY_SPHERE(OBJ_PLAYER, OBJ_WEAPON) |
| 2626 | ENABLE_COLLISION_SPHERE_SPHERE(OBJ_PLAYER, OBJ_POWERUP) |
| 2627 | ENABLE_COLLISION_SPHERE_SPHERE(OBJ_POWERUP, OBJ_WALL) |
| 2628 | ENABLE_COLLISION_SPHERE_POLY(OBJ_WEAPON, OBJ_CLUTTER) |
| 2629 | ENABLE_COLLISION_SPHERE_POLY(OBJ_PLAYER, OBJ_CLUTTER) |
| 2630 | ENABLE_COLLISION_SPHERE_SPHERE(OBJ_CLUTTER, OBJ_CLUTTER) |
| 2631 | ENABLE_COLLISION_SPHERE_POLY(OBJ_ROBOT, OBJ_CLUTTER) |
| 2632 | ENABLE_COLLISION_SPHERE_POLY(OBJ_PLAYER, OBJ_BUILDING) |
| 2633 | ENABLE_COLLISION_SPHERE_POLY(OBJ_ROBOT, OBJ_BUILDING) |
| 2634 | ENABLE_COLLISION_SPHERE_POLY(OBJ_WEAPON, OBJ_BUILDING) |
| 2635 | ENABLE_COLLISION_SPHERE_POLY(OBJ_CLUTTER, OBJ_BUILDING) |
| 2636 | ENABLE_COLLISION_SPHERE_POLY(OBJ_CLUTTER, OBJ_DOOR) |
| 2637 | ENABLE_COLLISION_SPHERE_POLY(OBJ_BUILDING, OBJ_DOOR) |
| 2638 | |
| 2639 | ENABLE_COLLISION_SPHERE_ROOM(OBJ_PLAYER, OBJ_ROOM) |
| 2640 | ENABLE_COLLISION_SPHERE_ROOM(OBJ_ROBOT, OBJ_ROOM) |
| 2641 | ENABLE_COLLISION_SPHERE_ROOM(OBJ_WEAPON, OBJ_ROOM) |
| 2642 | ENABLE_COLLISION_SPHERE_ROOM(OBJ_VIEWER, OBJ_ROOM) |
| 2643 | |
| 2644 | ENABLE_COLLISION_SPHERE_POLY(OBJ_PLAYER, OBJ_DOOR) |
| 2645 | ENABLE_COLLISION_SPHERE_POLY(OBJ_ROBOT, OBJ_DOOR) |
| 2646 | ENABLE_COLLISION_SPHERE_POLY(OBJ_WEAPON, OBJ_DOOR) |
| 2647 | DISABLE_COLLISION(OBJ_POWERUP, OBJ_POWERUP) |
| 2648 | } |
| 2649 | |
| 2650 | // Process a collision between an object and a wall |
| 2651 | // Returns true if the object hits the wall, and false if should keep going though the wall (for breakable glass) |
| 2652 | bool collide_object_with_wall(object *A, float hitspeed, int hitseg, int hitwall, vector *hitpt, vector *wall_normal, |
| 2653 | float hit_dot) { |
| 2654 | uint8_t do_event = 0; |
| 2655 | bool ret = true; |
| 2656 | |
| 2657 | switch (A->type) { |
| 2658 | case OBJ_NONE: |
| 2659 | Error("A object of type NONE hit a wall!\n"); |
| 2660 | break; |
| 2661 | case OBJ_PLAYER: |
| 2662 | collide_player_and_wall(A, hitspeed, hitseg, hitwall, hitpt, wall_normal, hit_dot); |
| 2663 | do_event = 1; |
| 2664 | break; |
| 2665 | case OBJ_WEAPON: |
| 2666 | ret = collide_weapon_and_wall(A, hitspeed, hitseg, hitwall, hitpt, wall_normal, hit_dot); |
| 2667 | do_event = 1; |
| 2668 | break; |
| 2669 | case OBJ_DEBRIS: |
| 2670 | break; // chrishack -- collide_debris_and_wall(A,hitspeed,hitseg,hitwall,hitpt); break; |
| 2671 | case OBJ_FIREBALL: |
| 2672 | break; // collide_fireball_and_wall(A,hitspeed,hitseg,hitwall,hitpt); |
| 2673 | case OBJ_CLUTTER: |
| 2674 | case OBJ_BUILDING: |
| 2675 | case OBJ_ROBOT: |
| 2676 | collide_generic_and_wall(A, hitspeed, hitseg, hitwall, hitpt, wall_normal, hit_dot); |
| 2677 | do_event = 1; |
| 2678 | break; |
| 2679 | case OBJ_VIEWER: |
| 2680 | break; // collide_camera_and_wall(A,hitspeed,hitseg,hitwall,hitpt); |
| 2681 | case OBJ_POWERUP: |
| 2682 | break; // collide_powerup_and_wall(A,hitspeed,hitseg,hitwall,hitpt); |
| 2683 | case OBJ_GHOST: |
| 2684 | break; // do nothing |
| 2685 | case OBJ_OBSERVER: |
| 2686 | break; // do nothing |
| 2687 | case OBJ_SPLINTER: |
| 2688 | break; |
| 2689 | case OBJ_MARKER: |
| 2690 | break; |
| 2691 | case OBJ_SHARD: |
| 2692 | if (sound_override_glass_breaking == -1) |
| 2693 | Sound_system.Play3dSound(SOUND_BREAKING_GLASS, SND_PRIORITY_NORMAL, A, MAX_GAME_VOLUME / 10); |
| 2694 | else |
| 2695 | Sound_system.Play3dSound(sound_override_glass_breaking, SND_PRIORITY_NORMAL, A, MAX_GAME_VOLUME / 10); |
| 2696 | break; |
| 2697 | |
| 2698 | default: |
| 2699 | mprintf(0, "Unhandled collision of object type %d and wall\n", A->type); |
| 2700 | // Error( "Unhandled object type hit wall in collide.c\n" ); |
| 2701 | } |
| 2702 | |
| 2703 | if (do_event && (Game_mode & GM_MULTI)) { |
| 2704 | // call multiplayer event |
| 2705 | DLLInfo.me_handle = A->handle; |
| 2706 | DLLInfo.it_handle = OBJECT_HANDLE_NONE; |
| 2707 | DLLInfo.collide_info.point.x = hitpt->x; |
| 2708 | DLLInfo.collide_info.point.y = hitpt->y; |
| 2709 | DLLInfo.collide_info.point.z = hitpt->z; |
| 2710 | DLLInfo.collide_info.normal.x = wall_normal->x; |
| 2711 | DLLInfo.collide_info.normal.y = wall_normal->y; |
| 2712 | DLLInfo.collide_info.normal.z = wall_normal->z; |
| 2713 | DLLInfo.collide_info.hitspeed = hitspeed; |
| 2714 | DLLInfo.collide_info.hit_dot = hit_dot; |
| 2715 | DLLInfo.collide_info.hitseg = hitseg; |
| 2716 | DLLInfo.collide_info.hitwall = hitwall; |
| 2717 | CallGameDLL(EVT_GAMEWALLCOLLIDE, &DLLInfo); |
| 2718 | } |
| 2719 | |
| 2720 | return ret; |
| 2721 | } |