| | 1 | #include "system.h" |
| | 2 | #include "prototyp.h" |
| | 3 | #include "stratdef.h" |
| | 4 | #include "npc_predator.h" |
| | 5 | #include "weapons.h" |
| | 6 | #include "pldghost.h" |
| | 7 | #include "kshape.h" |
| | 8 | #include "paintball.h" |
| | 9 | #include "userprofile.h" |
| | 10 | #include "savegame.h" |
| | 11 | #include "bh_types.h" |
| | 12 | #include "userprofile.h" |
| | 13 | #include <stdio.h> |
| | 14 | #include <assert.h> |
| | 15 | |
| | 16 | #define MAX_NO_OF_FIXED_DECALS 1024 |
| | 17 | #define DECAL_Z_OFFSET 0 |
| | 18 | |
| | 19 | int NumActiveDecals, current_decal_index, NumFixedDecalsBackup, NumFixedDecals, CurrentFixedDecalIndex; |
| | 20 | |
| | 21 | static DECAL DecalStorage[MAX_NO_OF_DECALS]; |
| | 22 | FIXED_DECAL FixedDecalStorage[MAX_NO_OF_FIXED_DECALS]; |
| | 23 | THREE_LASER_DOT_DESC PredatorLaserSights[NET_MAXPLAYERS]; |
| | 24 | |
| | 25 | DECAL_DESC DecalDescription[MAX_NO_OF_DECAL_IDS] = |
| | 26 | { |
| | 27 | /* DECAL_FMV */ |
| | 28 | { |
| | 29 | //int StartU; |
| | 30 | 0, |
| | 31 | //int StartV; |
| | 32 | 0, |
| | 33 | //int EndU; |
| | 34 | (127)<<16, |
| | 35 | //int EndV; |
| | 36 | (95)<<16, |
| | 37 | |
| | 38 | //int MinSize; |
| | 39 | 3000, |
| | 40 | //int MaxSize; |
| | 41 | 3000, |
| | 42 | //int GrowthRate; |
| | 43 | 0, |
| | 44 | |
| | 45 | //int MaxSubclassNumber; |
| | 46 | 0, |
| | 47 | //int UOffsetForSubclass; |
| | 48 | 0, |
| | 49 | |
| | 50 | TRANSLUCENCY_NORMAL, |
| | 51 | |
| | 52 | //unsigned char Alpha; |
| | 53 | 96, |
| | 54 | //unsigned char RedScale; |
| | 55 | {255, 255, 0, 255, 255}, |
| | 56 | //unsigned char GreenScale; |
| | 57 | {255, 255, 255, 0, 0}, |
| | 58 | //unsigned char BlueScale; |
| | 59 | {255, 255, 0, 255, 0}, |
| | 60 | |
| | 61 | //unsigned char IsLit:1; |
| | 62 | 0, |
| | 63 | //unsigned char CanCombine:1; |
| | 64 | 0, |
| | 65 | }, |
| | 66 | /* DECAL_SCORCHED */ |
| | 67 | { |
| | 68 | //int StartU; |
| | 69 | 0, |
| | 70 | //int StartV; |
| | 71 | 64<<16, |
| | 72 | //int EndU; |
| | 73 | 63<<16, |
| | 74 | //int EndV; |
| | 75 | 127<<16, |
| | 76 | |
| | 77 | //int MinSize; |
| | 78 | 20, |
| | 79 | //int MaxSize; |
| | 80 | 200, |
| | 81 | //int GrowthRate; |
| | 82 | 300, |
| | 83 | |
| | 84 | //int MaxSubclassNumber; |
| | 85 | 0, |
| | 86 | //int UOffsetForSubclass; |
| | 87 | 0, |
| | 88 | |
| | 89 | TRANSLUCENCY_INVCOLOUR, |
| | 90 | |
| | 91 | //unsigned char Alpha; |
| | 92 | 255, |
| | 93 | //unsigned char RedScale; |
| | 94 | {128,128,128,128,128}, |
| | 95 | //unsigned char GreenScale; |
| | 96 | {128,128,128,128,128}, |
| | 97 | //unsigned char BlueScale; |
| | 98 | {128,128,128,128,128}, |
| | 99 | |
| | 100 | //unsigned char IsLit:1; |
| | 101 | 0, |
| | 102 | //unsigned char CanCombine:1; |
| | 103 | 0, |
| | 104 | |
| | 105 | }, |
| | 106 | /* DECAL_BULLETHOLE */ |
| | 107 | { |
| | 108 | //int StartU; |
| | 109 | 224<<16, |
| | 110 | //int StartV; |
| | 111 | 224<<16, |
| | 112 | //int EndU; |
| | 113 | 255<<16, |
| | 114 | //int EndV; |
| | 115 | 255<<16, |
| | 116 | |
| | 117 | //int MinSize; |
| | 118 | 32, |
| | 119 | //int MaxSize; |
| | 120 | 32, |
| | 121 | //int GrowthRate; |
| | 122 | 0, |
| | 123 | |
| | 124 | //int MaxSubclassNumber; |
| | 125 | 0, |
| | 126 | //int UOffsetForSubclass; |
| | 127 | 0, |
| | 128 | |
| | 129 | TRANSLUCENCY_INVCOLOUR, |
| | 130 | |
| | 131 | //unsigned char Alpha; |
| | 132 | 255, |
| | 133 | //unsigned char RedScale; |
| | 134 | {255,255,255,255,255}, |
| | 135 | //unsigned char GreenScale; |
| | 136 | {255,255,255,255,255}, |
| | 137 | //unsigned char BlueScale; |
| | 138 | {255,255,255,255,255}, |
| | 139 | |
| | 140 | //unsigned char IsLit:1; |
| | 141 | 0, |
| | 142 | //unsigned char CanCombine:1; |
| | 143 | 0, |
| | 144 | }, |
| | 145 | |
| | 146 | /* DECAL_PREDATOR_BLOOD */ |
| | 147 | { |
| | 148 | //int StartU; |
| | 149 | 0, |
| | 150 | //int StartV; |
| | 151 | 224<<16, |
| | 152 | //int EndU; |
| | 153 | (31)<<16, |
| | 154 | //int EndV; |
| | 155 | 255<<16, |
| | 156 | |
| | 157 | //int MinSize; |
| | 158 | 20, |
| | 159 | //int MaxSize; |
| | 160 | 400, |
| | 161 | //int GrowthRate; |
| | 162 | 100, |
| | 163 | |
| | 164 | //int MaxSubclassNumber; |
| | 165 | 3, |
| | 166 | //int UOffsetForSubclass; |
| | 167 | 32<<16, |
| | 168 | |
| | 169 | TRANSLUCENCY_GLOWING, |
| | 170 | |
| | 171 | //unsigned char Alpha; |
| | 172 | 128, |
| | 173 | //unsigned char RedScale; |
| | 174 | {0, 0, 192, 0, 255}, |
| | 175 | //unsigned char GreenScale; |
| | 176 | {255, 255, 255, 255, 0}, |
| | 177 | //unsigned char BlueScale; |
| | 178 | {0, 0, 192, 255, 0}, |
| | 179 | |
| | 180 | //unsigned char IsLit:1; |
| | 181 | 0, |
| | 182 | //unsigned char CanCombine:1; |
| | 183 | 1, |
| | 184 | }, |
| | 185 | /* DECAL_ALIEN_BLOOD */ |
| | 186 | { |
| | 187 | //int StartU; |
| | 188 | 0, |
| | 189 | //int StartV; |
| | 190 | 64<<16, |
| | 191 | //int EndU; |
| | 192 | 63<<16, |
| | 193 | //int EndV; |
| | 194 | 127<<16, |
| | 195 | |
| | 196 | //int MinSize; |
| | 197 | 20, |
| | 198 | //int MaxSize; |
| | 199 | 400, |
| | 200 | //int GrowthRate; |
| | 201 | 100, |
| | 202 | |
| | 203 | //int MaxSubclassNumber; |
| | 204 | 0, |
| | 205 | //int UOffsetForSubclass; |
| | 206 | 0, |
| | 207 | |
| | 208 | TRANSLUCENCY_GLOWING, |
| | 209 | |
| | 210 | //unsigned char Alpha; |
| | 211 | 128, |
| | 212 | //unsigned char RedScale; |
| | 213 | {255, 255, 0, 128, 128}, |
| | 214 | //unsigned char GreenScale; |
| | 215 | {255, 255, 255, 128, 128}, |
| | 216 | //unsigned char BlueScale; |
| | 217 | {0, 0, 0, 128, 128}, |
| | 218 | |
| | 219 | //unsigned char IsLit:1; |
| | 220 | 1, |
| | 221 | //unsigned char CanCombine:1; |
| | 222 | 1, |
| | 223 | |
| | 224 | }, |
| | 225 | /* DECAL_HUMAN_BLOOD */ |
| | 226 | { |
| | 227 | //int StartU; |
| | 228 | 0, |
| | 229 | //int StartV; |
| | 230 | 224<<16, |
| | 231 | //int EndU; |
| | 232 | (31)<<16, |
| | 233 | //int EndV; |
| | 234 | 255<<16, |
| | 235 | |
| | 236 | //int MinSize; |
| | 237 | 20, |
| | 238 | //int MaxSize; |
| | 239 | 400, |
| | 240 | //int GrowthRate; |
| | 241 | 100, |
| | 242 | |
| | 243 | //int MaxSubclassNumber; |
| | 244 | 4, |
| | 245 | //int UOffsetForSubclass; |
| | 246 | 32<<16, |
| | 247 | |
| | 248 | TRANSLUCENCY_INVCOLOUR,//GLOWING, |
| | 249 | |
| | 250 | //unsigned char Alpha; |
| | 251 | 255, |
| | 252 | //unsigned char RedScale; |
| | 253 | {64, 64, 255, 0, 0}, |
| | 254 | //unsigned char GreenScale; |
| | 255 | {192, 192, 192, 112, 112}, |
| | 256 | //unsigned char BlueScale; |
| | 257 | {192, 192, 255, 112, 112}, |
| | 258 | |
| | 259 | //unsigned char IsLit:1; |
| | 260 | 0, |
| | 261 | //unsigned char CanCombine:1; |
| | 262 | 1, |
| | 263 | |
| | 264 | }, |
| | 265 | /* DECAL_ANDROID_BLOOD */ |
| | 266 | { |
| | 267 | //int StartU; |
| | 268 | 0, |
| | 269 | //int StartV; |
| | 270 | 224<<16, |
| | 271 | //int EndU; |
| | 272 | (31)<<16, |
| | 273 | //int EndV; |
| | 274 | 255<<16, |
| | 275 | |
| | 276 | //int MinSize; |
| | 277 | 20, |
| | 278 | //int MaxSize; |
| | 279 | 400, |
| | 280 | //int GrowthRate; |
| | 281 | 100, |
| | 282 | |
| | 283 | //int MaxSubclassNumber; |
| | 284 | 3, |
| | 285 | //int UOffsetForSubclass; |
| | 286 | 32<<16, |
| | 287 | |
| | 288 | TRANSLUCENCY_GLOWING, |
| | 289 | |
| | 290 | //unsigned char Alpha; |
| | 291 | 128, |
| | 292 | //unsigned char RedScale; |
| | 293 | {255, 255, 255, 255, 255}, |
| | 294 | //unsigned char GreenScale; |
| | 295 | {255, 255, 255, 255, 255}, |
| | 296 | //unsigned char BlueScale; |
| | 297 | {255, 255, 255, 255, 255}, |
| | 298 | |
| | 299 | //unsigned char IsLit:1; |
| | 300 | 1, |
| | 301 | //unsigned char CanCombine:1; |
| | 302 | 1, |
| | 303 | }, |
| | 304 | |
| | 305 | // DECAL_PREDATOR_BLOOD_SPLASH |
| | 306 | { |
| | 307 | //int StartU; |
| | 308 | 0<<16, |
| | 309 | //int StartV; |
| | 310 | 224<<16, |
| | 311 | //int EndU; |
| | 312 | (31)<<16, |
| | 313 | //int EndV; |
| | 314 | 255<<16, |
| | 315 | |
| | 316 | //int MinSize; |
| | 317 | 20, |
| | 318 | //int MaxSize; |
| | 319 | 400, |
| | 320 | //int GrowthRate; |
| | 321 | 0, |
| | 322 | |
| | 323 | //int MaxSubclassNumber; |
| | 324 | 3, |
| | 325 | //int UOffsetForSubclass; |
| | 326 | 32<<16, |
| | 327 | |
| | 328 | TRANSLUCENCY_GLOWING, |
| | 329 | |
| | 330 | //unsigned char Alpha; |
| | 331 | 128, |
| | 332 | //unsigned char RedScale; |
| | 333 | {0, 0, 192, 0, 255}, |
| | 334 | //unsigned char GreenScale; |
| | 335 | {255, 255, 255, 255, 0}, |
| | 336 | //unsigned char BlueScale; |
| | 337 | {0, 0, 192, 255, 0}, |
| | 338 | |
| | 339 | //unsigned char IsLit:1; |
| | 340 | 0, |
| | 341 | //unsigned char CanCombine:1; |
| | 342 | 1, |
| | 343 | }, |
| | 344 | // DECAL_ALIEN_BLOOD_SPLASH |
| | 345 | { |
| | 346 | //int StartU; |
| | 347 | 0<<16, |
| | 348 | //int StartV; |
| | 349 | 64<<16, |
| | 350 | //int EndU; |
| | 351 | 63<<16, |
| | 352 | //int EndV; |
| | 353 | 127<<16, |
| | 354 | |
| | 355 | //int MinSize; |
| | 356 | 20, |
| | 357 | //int MaxSize; |
| | 358 | 400, |
| | 359 | //int GrowthRate; |
| | 360 | 0, |
| | 361 | |
| | 362 | //int MaxSubclassNumber; |
| | 363 | 0, |
| | 364 | //int UOffsetForSubclass; |
| | 365 | 0, |
| | 366 | |
| | 367 | TRANSLUCENCY_GLOWING, |
| | 368 | |
| | 369 | //unsigned char Alpha; |
| | 370 | 128, |
| | 371 | //unsigned char RedScale; |
| | 372 | {255, 255, 0, 128, 128}, |
| | 373 | //unsigned char GreenScale; |
| | 374 | {255, 255, 255, 128, 128}, |
| | 375 | //unsigned char BlueScale; |
| | 376 | {0, 0, 0, 128, 128}, |
| | 377 | |
| | 378 | //unsigned char IsLit:1; |
| | 379 | 1, |
| | 380 | //unsigned char CanCombine:1; |
| | 381 | 1, |
| | 382 | |
| | 383 | }, |
| | 384 | // DECAL_HUMAN_BLOOD_SPLASH |
| | 385 | { |
| | 386 | //int StartU; |
| | 387 | 0<<16, |
| | 388 | //int StartV; |
| | 389 | 224<<16, |
| | 390 | //int EndU; |
| | 391 | (31)<<16, |
| | 392 | //int EndV; |
| | 393 | 255<<16, |
| | 394 | |
| | 395 | //int MinSize; |
| | 396 | //20, |
| | 397 | 400, |
| | 398 | //int MaxSize; |
| | 399 | 400, |
| | 400 | //int GrowthRate; |
| | 401 | 0, |
| | 402 | |
| | 403 | //int MaxSubclassNumber; |
| | 404 | 4, |
| | 405 | //int UOffsetForSubclass; |
| | 406 | 32<<16, |
| | 407 | |
| | 408 | TRANSLUCENCY_INVCOLOUR,//GLOWING, |
| | 409 | |
| | 410 | //unsigned char Alpha; |
| | 411 | 255, |
| | 412 | //unsigned char RedScale; |
| | 413 | {64, 64, 255, 0, 0}, |
| | 414 | //unsigned char GreenScale; |
| | 415 | {192, 192, 192, 112, 112}, |
| | 416 | //unsigned char BlueScale; |
| | 417 | {192, 192, 255, 112, 112}, |
| | 418 | |
| | 419 | //unsigned char IsLit:1; |
| | 420 | 0, |
| | 421 | //unsigned char CanCombine:1; |
| | 422 | 1, |
| | 423 | |
| | 424 | }, |
| | 425 | // DECAL_ANDROID_BLOOD_SPLASH |
| | 426 | { |
| | 427 | //int StartU; |
| | 428 | 0<<16, |
| | 429 | //int StartV; |
| | 430 | 224<<16, |
| | 431 | //int EndU; |
| | 432 | (31)<<16, |
| | 433 | //int EndV; |
| | 434 | 255<<16, |
| | 435 | |
| | 436 | //int MinSize; |
| | 437 | 20, |
| | 438 | //int MaxSize; |
| | 439 | 400, |
| | 440 | //int GrowthRate; |
| | 441 | 0, |
| | 442 | |
| | 443 | //int MaxSubclassNumber; |
| | 444 | 3, |
| | 445 | //int UOffsetForSubclass; |
| | 446 | 32<<16, |
| | 447 | |
| | 448 | TRANSLUCENCY_GLOWING, |
| | 449 | |
| | 450 | //unsigned char Alpha; |
| | 451 | 128, |
| | 452 | //unsigned char RedScale; |
| | 453 | {255, 255, 255, 255, 255}, |
| | 454 | //unsigned char GreenScale; |
| | 455 | {255, 255, 255, 255, 255}, |
| | 456 | //unsigned char BlueScale; |
| | 457 | {255, 255, 255, 255, 255}, |
| | 458 | |
| | 459 | //unsigned char IsLit:1; |
| | 460 | 1, |
| | 461 | //unsigned char CanCombine:1; |
| | 462 | 1, |
| | 463 | }, |
| | 464 | /* DECAL_LASERTARGET */ |
| | 465 | { |
| | 466 | //int StartU; |
| | 467 | 0<<16, |
| | 468 | //int StartV; |
| | 469 | 0<<16, |
| | 470 | //int EndU; |
| | 471 | 63<<16, |
| | 472 | //int EndV; |
| | 473 | 63<<16, |
| | 474 | |
| | 475 | //int MinSize; |
| | 476 | 20, |
| | 477 | //int MaxSize; |
| | 478 | 20, |
| | 479 | //int GrowthRate; |
| | 480 | 0, |
| | 481 | |
| | 482 | //int MaxSubclassNumber; |
| | 483 | 0, |
| | 484 | //int UOffsetForSubclass; |
| | 485 | 0, |
| | 486 | |
| | 487 | TRANSLUCENCY_GLOWING, |
| | 488 | |
| | 489 | //unsigned char Alpha; |
| | 490 | 255, |
| | 491 | //unsigned char RedScale; |
| | 492 | {255, 255, 255, 255, 255}, |
| | 493 | //unsigned char GreenScale; |
| | 494 | {0, 0, 255, 255, 255}, |
| | 495 | //unsigned char BlueScale; |
| | 496 | {0, 0, 255, 255, 255}, |
| | 497 | |
| | 498 | //unsigned char IsLit:1; |
| | 499 | 0, |
| | 500 | //unsigned char CanCombine:1; |
| | 501 | 0, |
| | 502 | |
| | 503 | }, |
| | 504 | /* DECAL_SHAFTOFLIGHT */ |
| | 505 | { |
| | 506 | //int StartU; |
| | 507 | 0, |
| | 508 | //int StartV; |
| | 509 | 0, |
| | 510 | //int EndU; |
| | 511 | 0, |
| | 512 | //int EndV; |
| | 513 | 0, |
| | 514 | |
| | 515 | //int MinSize; |
| | 516 | 0, |
| | 517 | //int MaxSize; |
| | 518 | 0, |
| | 519 | //int GrowthRate; |
| | 520 | 0, |
| | 521 | |
| | 522 | //int MaxSubclassNumber; |
| | 523 | 0, |
| | 524 | //int UOffsetForSubclass; |
| | 525 | 0, |
| | 526 | |
| | 527 | TRANSLUCENCY_GLOWING, |
| | 528 | |
| | 529 | //unsigned char Alpha; |
| | 530 | 64, |
| | 531 | //unsigned char RedScale; |
| | 532 | {255,255,255,255}, |
| | 533 | //unsigned char GreenScale; |
| | 534 | {255,255,255,255}, |
| | 535 | //unsigned char BlueScale; |
| | 536 | {192,192,192,192}, |
| | 537 | |
| | 538 | //unsigned char IsLit:1; |
| | 539 | 0, |
| | 540 | //unsigned char CanCombine:1; |
| | 541 | 0, |
| | 542 | |
| | 543 | }, |
| | 544 | /* DECAL_SHAFTOFLIGHT_OUTER */ |
| | 545 | { |
| | 546 | //int StartU; |
| | 547 | 0, |
| | 548 | //int StartV; |
| | 549 | 0, |
| | 550 | //int EndU; |
| | 551 | 0, |
| | 552 | //int EndV; |
| | 553 | 0, |
| | 554 | |
| | 555 | //int MinSize; |
| | 556 | 0, |
| | 557 | //int MaxSize; |
| | 558 | 0, |
| | 559 | //int GrowthRate; |
| | 560 | 0, |
| | 561 | |
| | 562 | //int MaxSubclassNumber; |
| | 563 | 0, |
| | 564 | //int UOffsetForSubclass; |
| | 565 | 0, |
| | 566 | |
| | 567 | TRANSLUCENCY_GLOWING, |
| | 568 | |
| | 569 | //unsigned char Alpha; |
| | 570 | 32, |
| | 571 | //unsigned char RedScale; |
| | 572 | {255,255,255,255}, |
| | 573 | //unsigned char GreenScale; |
| | 574 | {255,255,255,255}, |
| | 575 | //unsigned char BlueScale; |
| | 576 | {192,192,192,192}, |
| | 577 | |
| | 578 | //unsigned char IsLit:1; |
| | 579 | 0, |
| | 580 | //unsigned char CanCombine:1; |
| | 581 | 0, |
| | 582 | } |
| | 583 | }; |
| | 584 | |
| | 585 | FIXED_DECAL* AllocateFixedDecal() |
| | 586 | { |
| | 587 | if (CurrentFixedDecalIndex >= MAX_NO_OF_FIXED_DECALS) |
| | 588 | CurrentFixedDecalIndex = 0; |
| | 589 | else |
| | 590 | NumFixedDecals++; |
| | 591 | |
| | 592 | return &FixedDecalStorage[CurrentFixedDecalIndex++]; |
| | 593 | } |
| | 594 | |
| | 595 | void RemoveFixedDecal() |
| | 596 | { |
| | 597 | if (CurrentFixedDecalIndex > 0) |
| | 598 | { |
| | 599 | CurrentFixedDecalIndex--; |
| | 600 | NumFixedDecals--; |
| | 601 | } |
| | 602 | } |
| | 603 | |
| | 604 | void check_preplaced_decal_modules() |
| | 605 | { |
| | 606 | extern SCENEMODULE MainScene; |
| | 607 | int i; |
| | 608 | |
| | 609 | NumFixedDecals = NumFixedDecalsBackup; |
| | 610 | |
| | 611 | for(i=0; i < NumFixedDecals; i++) |
| | 612 | { |
| | 613 | FIXED_DECAL* fd = &FixedDecalStorage[i]; |
| | 614 | |
| | 615 | MODULE* mod = MainScene.sm_marray[fd->ModuleIndex]; |
| | 616 | mod = ModuleFromPosition(&fd->Vertices[0], mod); |
| | 617 | |
| | 618 | if(mod) |
| | 619 | fd->ModuleIndex = mod->m_index; |
| | 620 | } |
| | 621 | } |
| | 622 | |
| | 623 | void RemoveAllDecals() |
| | 624 | { |
| | 625 | /* pretty drastic */ |
| | 626 | NumFixedDecalsBackup = NumFixedDecals; |
| | 627 | CurrentFixedDecalIndex = NumFixedDecals = NumActiveDecals = 0; |
| | 628 | } |
| | 629 | |
| | 630 | #define MAX_NO_OF_SIMILAR_DECALS_IN_ONE_PLACE 4 |
| | 631 | #define INCREMENT_IN_DECAL_SIZE (25*4) |
| | 632 | |
| | 633 | static int TooManyDecalsOfThisType(enum DECAL_ID decalID, VECTORCH *positionPtr) |
| | 634 | { |
| | 635 | int i = NumActiveDecals; |
| | 636 | DECAL *decalPtr = DecalStorage; |
| | 637 | DECAL *similarDecalsPtr[MAX_NO_OF_SIMILAR_DECALS_IN_ONE_PLACE]; |
| | 638 | |
| | 639 | int decalsOfThisType = 0; |
| | 640 | int decalSize = DecalDescription[decalID].MaxSize; |
| | 641 | int minX = positionPtr->vx - decalSize; |
| | 642 | int maxX = positionPtr->vx + decalSize; |
| | 643 | int minY = positionPtr->vy - decalSize; |
| | 644 | int maxY = positionPtr->vy + decalSize; |
| | 645 | int minZ = positionPtr->vz - decalSize; |
| | 646 | int maxZ = positionPtr->vz + decalSize; |
| | 647 | |
| | 648 | while(i--) |
| | 649 | { |
| | 650 | if (decalPtr->DecalID == decalID) |
| | 651 | { |
| | 652 | if ( |
| | 653 | (decalPtr->Centre.vx > minX && decalPtr->Centre.vx < maxX) |
| | 654 | && |
| | 655 | (decalPtr->Centre.vy > minY && decalPtr->Centre.vy < maxY) |
| | 656 | && |
| | 657 | (decalPtr->Centre.vz > minZ && decalPtr->Centre.vz < maxZ) |
| | 658 | ) |
| | 659 | { |
| | 660 | similarDecalsPtr[decalsOfThisType++] = decalPtr; |
| | 661 | |
| | 662 | if (decalsOfThisType >= MAX_NO_OF_SIMILAR_DECALS_IN_ONE_PLACE) |
| | 663 | { |
| | 664 | if (DecalDescription[decalID].CanCombine) |
| | 665 | { |
| | 666 | int j; |
| | 667 | for (j=0; j < MAX_NO_OF_SIMILAR_DECALS_IN_ONE_PLACE; j++) |
| | 668 | { |
| | 669 | if (similarDecalsPtr[j]->TargetSize >= DecalDescription[decalID].MaxSize) |
| | 670 | { |
| | 671 | similarDecalsPtr[j]->TargetSize = DecalDescription[decalID].MaxSize; |
| | 672 | break; |
| | 673 | } |
| | 674 | else |
| | 675 | { |
| | 676 | similarDecalsPtr[j]->TargetSize += INCREMENT_IN_DECAL_SIZE; |
| | 677 | } |
| | 678 | } |
| | 679 | } |
| | 680 | return 1; |
| | 681 | } |
| | 682 | } |
| | 683 | } |
| | 684 | |
| | 685 | decalPtr++; |
| | 686 | } |
| | 687 | |
| | 688 | return 0; |
| | 689 | } |
| | 690 | |
| | 691 | |
| | 692 | void AddDecal(enum DECAL_ID decalID, VECTORCH *normalPtr, VECTORCH *positionPtr, int moduleIndex) |
| | 693 | { |
| | 694 | DECAL *decalPtr; |
| | 695 | |
| | 696 | if (NumActiveDecals < UserProfile.GameOptions.NumberOfDecals) |
| | 697 | { |
| | 698 | decalPtr = &DecalStorage[NumActiveDecals++]; |
| | 699 | } |
| | 700 | else |
| | 701 | { |
| | 702 | if(current_decal_index >= NumActiveDecals) |
| | 703 | current_decal_index = 0; |
| | 704 | |
| | 705 | decalPtr = &DecalStorage[current_decal_index++]; |
| | 706 | } |
| | 707 | |
| | 708 | { |
| | 709 | MATRIXCH orientation; |
| | 710 | int decalSize; |
| | 711 | int theta = FastRandom() & 4095; |
| | 712 | int sin = GetSin(theta); |
| | 713 | int cos = GetCos(theta); |
| | 714 | |
| | 715 | MakeMatrixFromDirection(normalPtr, &orientation); |
| | 716 | |
| | 717 | decalPtr->DecalID = decalID; |
| | 718 | decalPtr->Centre = *positionPtr; |
| | 719 | |
| | 720 | if(DecalDescription[decalID].GrowthRate) |
| | 721 | { |
| | 722 | decalSize = ONE_FIXED; |
| | 723 | decalPtr->Direction[0].vx = MUL_FIXED(-decalSize,cos) - MUL_FIXED(-decalSize,sin); |
| | 724 | decalPtr->Direction[0].vy = MUL_FIXED(-decalSize,sin) + MUL_FIXED(-decalSize,cos); |
| | 725 | decalPtr->Direction[0].vz = DECAL_Z_OFFSET; |
| | 726 | RotateVector(&decalPtr->Direction[0], &orientation); |
| | 727 | Normalise(&decalPtr->Direction[0]); |
| | 728 | |
| | 729 | decalPtr->Direction[1].vx = MUL_FIXED(decalSize,cos) - MUL_FIXED(-decalSize,sin); |
| | 730 | decalPtr->Direction[1].vy = MUL_FIXED(decalSize,sin) + MUL_FIXED(-decalSize,cos); |
| | 731 | decalPtr->Direction[1].vz = DECAL_Z_OFFSET; |
| | 732 | RotateVector(&decalPtr->Direction[1], &orientation); |
| | 733 | Normalise(&decalPtr->Direction[1]); |
| | 734 | |
| | 735 | decalPtr->Direction[2].vx = MUL_FIXED(decalSize,cos) - MUL_FIXED(decalSize,sin); |
| | 736 | decalPtr->Direction[2].vy = MUL_FIXED(decalSize,sin) + MUL_FIXED(decalSize,cos); |
| | 737 | decalPtr->Direction[2].vz = DECAL_Z_OFFSET; |
| | 738 | RotateVector(&decalPtr->Direction[2], &orientation); |
| | 739 | Normalise(&decalPtr->Direction[2]); |
| | 740 | |
| | 741 | decalPtr->Direction[3].vx = MUL_FIXED(-decalSize,cos) - MUL_FIXED(decalSize,sin); |
| | 742 | decalPtr->Direction[3].vy = MUL_FIXED(-decalSize,sin) + MUL_FIXED(decalSize,cos); |
| | 743 | decalPtr->Direction[3].vz = DECAL_Z_OFFSET; |
| | 744 | RotateVector(&decalPtr->Direction[3], &orientation); |
| | 745 | Normalise(&decalPtr->Direction[3]); |
| | 746 | decalPtr->CurrentSize = DecalDescription[decalID].MinSize; |
| | 747 | decalPtr->TargetSize = DecalDescription[decalID].MaxSize; |
| | 748 | |
| | 749 | if (DecalDescription[decalID].CanCombine) |
| | 750 | decalPtr->TargetSize /= 4; |
| | 751 | } |
| | 752 | else |
| | 753 | { |
| | 754 | decalSize = DecalDescription[decalID].MinSize; |
| | 755 | decalPtr->Vertices[0].vx = MUL_FIXED(-decalSize,cos) - MUL_FIXED(-decalSize,sin); |
| | 756 | decalPtr->Vertices[0].vy = MUL_FIXED(-decalSize,sin) + MUL_FIXED(-decalSize,cos); |
| | 757 | decalPtr->Vertices[0].vz = DECAL_Z_OFFSET; |
| | 758 | RotateVector(&decalPtr->Vertices[0], &orientation); |
| | 759 | decalPtr->Vertices[0].vx += positionPtr->vx; |
| | 760 | decalPtr->Vertices[0].vy += positionPtr->vy; |
| | 761 | decalPtr->Vertices[0].vz += positionPtr->vz; |
| | 762 | |
| | 763 | decalPtr->Vertices[1].vx = MUL_FIXED(decalSize,cos) - MUL_FIXED(-decalSize,sin); |
| | 764 | decalPtr->Vertices[1].vy = MUL_FIXED(decalSize,sin) + MUL_FIXED(-decalSize,cos); |
| | 765 | decalPtr->Vertices[1].vz = DECAL_Z_OFFSET; |
| | 766 | RotateVector(&decalPtr->Vertices[1], &orientation); |
| | 767 | decalPtr->Vertices[1].vx += positionPtr->vx; |
| | 768 | decalPtr->Vertices[1].vy += positionPtr->vy; |
| | 769 | decalPtr->Vertices[1].vz += positionPtr->vz; |
| | 770 | |
| | 771 | decalPtr->Vertices[2].vx = MUL_FIXED(decalSize,cos) - MUL_FIXED(decalSize,sin); |
| | 772 | decalPtr->Vertices[2].vy = MUL_FIXED(decalSize,sin) + MUL_FIXED(decalSize,cos); |
| | 773 | decalPtr->Vertices[2].vz = DECAL_Z_OFFSET; |
| | 774 | RotateVector(&decalPtr->Vertices[2], &orientation); |
| | 775 | decalPtr->Vertices[2].vx += positionPtr->vx; |
| | 776 | decalPtr->Vertices[2].vy += positionPtr->vy; |
| | 777 | decalPtr->Vertices[2].vz += positionPtr->vz; |
| | 778 | |
| | 779 | decalPtr->Vertices[3].vx = MUL_FIXED(-decalSize,cos) - MUL_FIXED(decalSize,sin); |
| | 780 | decalPtr->Vertices[3].vy = MUL_FIXED(-decalSize,sin) + MUL_FIXED(decalSize,cos); |
| | 781 | decalPtr->Vertices[3].vz = DECAL_Z_OFFSET; |
| | 782 | RotateVector(&decalPtr->Vertices[3], &orientation); |
| | 783 | decalPtr->Vertices[3].vx += positionPtr->vx; |
| | 784 | decalPtr->Vertices[3].vy += positionPtr->vy; |
| | 785 | decalPtr->Vertices[3].vz += positionPtr->vz; |
| | 786 | } |
| | 787 | |
| | 788 | decalPtr->ModuleIndex = moduleIndex; |
| | 789 | |
| | 790 | switch (decalID) |
| | 791 | { |
| | 792 | case DECAL_HUMAN_BLOOD: |
| | 793 | case DECAL_PREDATOR_BLOOD: |
| | 794 | case DECAL_ANDROID_BLOOD: |
| | 795 | { |
| | 796 | //decalPtr->UOffset = (FastRandom() & 1) * (32 << 16); |
| | 797 | decalPtr->UOffset = 0; |
| | 798 | //decalPtr->UOffset = 64 << 16; |
| | 799 | //decalPtr->UOffset = 32 << 16; |
| | 800 | //decalPtr->UOffset = 96 << 16; |
| | 801 | //decalPtr->UOffset = 64 << 16; // fill blood |
| | 802 | //decalPtr->UOffset = 96 << 16; // fill blood |
| | 803 | |
| | 804 | //if(0) |
| | 805 | if (normalPtr->vy < -32768) |
| | 806 | { |
| | 807 | decalPtr->UOffset += 64 << 16; |
| | 808 | } |
| | 809 | else |
| | 810 | { |
| | 811 | decalPtr->TargetSize = DecalDescription[decalID].MaxSize; |
| | 812 | decalPtr->CurrentSize = decalPtr->TargetSize - 1; |
| | 813 | } |
| | 814 | } |
| | 815 | break; |
| | 816 | case DECAL_HUMAN_BLOOD_SPLASH: |
| | 817 | case DECAL_PREDATOR_BLOOD_SPLASH: |
| | 818 | case DECAL_ANDROID_BLOOD_SPLASH: |
| | 819 | decalPtr->UOffset = (FastRandom() & 1) ? (32 << 16) : 0; |
| | 820 | break; |
| | 821 | case DECAL_BULLETHOLE: |
| | 822 | MakeImpactSmoke(&orientation, positionPtr); |
| | 823 | default: |
| | 824 | decalPtr->UOffset = 0; |
| | 825 | } |
| | 826 | } |
| | 827 | } |
| | 828 | |
| | 829 | void MakeDecal(enum DECAL_ID decalID, VECTORCH *normalPtr, VECTORCH *positionPtr, int moduleIndex) |
| | 830 | { |
| | 831 | if (!TooManyDecalsOfThisType(decalID, positionPtr)) |
| | 832 | { |
| | 833 | AddDecal(decalID, normalPtr, positionPtr, moduleIndex); |
| | 834 | |
| | 835 | /* no blood across network? */ |
| | 836 | if(SinglePlayer != AvP.PlayMode) |
| | 837 | { |
| | 838 | if(netGameData.sendDecals) |
| | 839 | { |
| | 840 | switch (decalID) |
| | 841 | { |
| | 842 | case DECAL_BULLETHOLE: |
| | 843 | case DECAL_SCORCHED: |
| | 844 | AddNetMsg_MakeDecal(decalID, normalPtr, positionPtr, moduleIndex); |
| | 845 | default: |
| | 846 | break; |
| | 847 | } |
| | 848 | } |
| | 849 | } |
| | 850 | } |
| | 851 | } |
| | 852 | |
| | 853 | void RenderLaserTarget(THREE_LASER_DOT_DESC *laserTargetPtr) |
| | 854 | { |
| | 855 | int i = 2; |
| | 856 | |
| | 857 | do |
| | 858 | { |
| | 859 | DECAL decal; |
| | 860 | MATRIXCH orientation; |
| | 861 | VECTORCH *positionPtr = &laserTargetPtr->Position[i]; |
| | 862 | |
| | 863 | MakeMatrixFromDirection(&laserTargetPtr->Normal[i], &orientation); |
| | 864 | |
| | 865 | decal.DecalID = DECAL_LASERTARGET; |
| | 866 | int decalSize = DecalDescription[DECAL_LASERTARGET].MaxSize; |
| | 867 | |
| | 868 | decal.Vertices[0].vx = -decalSize; |
| | 869 | decal.Vertices[0].vy = -decalSize; |
| | 870 | decal.Vertices[0].vz = DECAL_Z_OFFSET; |
| | 871 | RotateVector(&decal.Vertices[0], &orientation); |
| | 872 | decal.Vertices[0].vx += positionPtr->vx; |
| | 873 | decal.Vertices[0].vy += positionPtr->vy; |
| | 874 | decal.Vertices[0].vz += positionPtr->vz; |
| | 875 | |
| | 876 | decal.Vertices[1].vx = decalSize; |
| | 877 | decal.Vertices[1].vy = -decalSize; |
| | 878 | decal.Vertices[1].vz = DECAL_Z_OFFSET; |
| | 879 | RotateVector(&decal.Vertices[1], &orientation); |
| | 880 | decal.Vertices[1].vx += positionPtr->vx; |
| | 881 | decal.Vertices[1].vy += positionPtr->vy; |
| | 882 | decal.Vertices[1].vz += positionPtr->vz; |
| | 883 | |
| | 884 | decal.Vertices[2].vx = decalSize; |
| | 885 | decal.Vertices[2].vy = decalSize; |
| | 886 | decal.Vertices[2].vz = DECAL_Z_OFFSET; |
| | 887 | RotateVector(&decal.Vertices[2], &orientation); |
| | 888 | decal.Vertices[2].vx += positionPtr->vx; |
| | 889 | decal.Vertices[2].vy += positionPtr->vy; |
| | 890 | decal.Vertices[2].vz += positionPtr->vz; |
| | 891 | |
| | 892 | decal.Vertices[3].vx = -decalSize; |
| | 893 | decal.Vertices[3].vy = decalSize; |
| | 894 | decal.Vertices[3].vz = DECAL_Z_OFFSET; |
| | 895 | RotateVector(&decal.Vertices[3], &orientation); |
| | 896 | decal.Vertices[3].vx += positionPtr->vx; |
| | 897 | decal.Vertices[3].vy += positionPtr->vy; |
| | 898 | decal.Vertices[3].vz += positionPtr->vz; |
| | 899 | |
| | 900 | decal.ModuleIndex = PlayerStatus.sbptr->containingModule->m_index; |
| | 901 | decal.UOffset = 0; |
| | 902 | if(2 == ModuleCurrVisArray[decal.ModuleIndex]) |
| | 903 | RenderDecal(&decal); |
| | 904 | |
| | 905 | } while(i--); |
| | 906 | } |
| | 907 | |
| | 908 | void HandleDecalSystem() |
| | 909 | { |
| | 910 | int i; |
| | 911 | |
| | 912 | { |
| | 913 | i = NumActiveDecals; |
| | 914 | DECAL *decalPtr = DecalStorage; |
| | 915 | // printf("Decals Active: %d\n",i); |
| | 916 | |
| | 917 | while(i--) |
| | 918 | { |
| | 919 | DECAL_DESC *decalDescPtr = &DecalDescription[decalPtr->DecalID]; |
| | 920 | |
| | 921 | if (decalDescPtr->GrowthRate && (decalPtr->CurrentSize < decalPtr->TargetSize)) |
| | 922 | { |
| | 923 | int i=0; |
| | 924 | decalPtr->CurrentSize += MUL_FIXED(decalDescPtr->GrowthRate, NormalFrameTime); |
| | 925 | |
| | 926 | if (decalPtr->CurrentSize > decalPtr->TargetSize) |
| | 927 | decalPtr->CurrentSize = decalPtr->TargetSize; |
| | 928 | |
| | 929 | for (; i < 4; i++) |
| | 930 | { |
| | 931 | decalPtr->Vertices[i].vx = MUL_FIXED(decalPtr->Direction[i].vx, decalPtr->CurrentSize); |
| | 932 | decalPtr->Vertices[i].vy = MUL_FIXED(decalPtr->Direction[i].vy, decalPtr->CurrentSize); |
| | 933 | decalPtr->Vertices[i].vz = MUL_FIXED(decalPtr->Direction[i].vz, decalPtr->CurrentSize); |
| | 934 | decalPtr->Vertices[i].vx += decalPtr->Centre.vx; |
| | 935 | decalPtr->Vertices[i].vy += decalPtr->Centre.vy; |
| | 936 | decalPtr->Vertices[i].vz += decalPtr->Centre.vz; |
| | 937 | } |
| | 938 | } |
| | 939 | |
| | 940 | if(2 == ModuleCurrVisArray[decalPtr->ModuleIndex]) |
| | 941 | RenderDecal(decalPtr); |
| | 942 | |
| | 943 | decalPtr++; |
| | 944 | } |
| | 945 | } |
| | 946 | |
| | 947 | i = NumFixedDecals; |
| | 948 | //printf("Fixed Decals Active: %d\n",i); |
| | 949 | |
| | 950 | while(i--) |
| | 951 | { |
| | 952 | if(2 == ModuleCurrVisArray[FixedDecalStorage[i].ModuleIndex]) |
| | 953 | RenderDecal(&FixedDecalStorage[i]); |
| | 954 | } |
| | 955 | |
| | 956 | { |
| | 957 | extern struct KObject VisibleObjects[]; |
| | 958 | extern int numVisObjs; |
| | 959 | int numOfObjects = numVisObjs; |
| | 960 | |
| | 961 | while(numOfObjects--) |
| | 962 | { |
| | 963 | DISPLAYBLOCK *objectPtr = VisibleObjects[numOfObjects].DispPtr; |
| | 964 | STRATEGYBLOCK *sbPtr = objectPtr->ObStrategyBlock; |
| | 965 | |
| | 966 | if (sbPtr) |
| | 967 | { |
| | 968 | switch(sbPtr->type) |
| | 969 | { |
| | 970 | case I_BehaviourNetGhost: |
| | 971 | { |
| | 972 | NETGHOSTDATABLOCK *ghostData = (NETGHOSTDATABLOCK *)sbPtr->dataptr; |
| | 973 | |
| | 974 | if (ghostData->type == I_BehaviourPredatorPlayer) |
| | 975 | { |
| | 976 | extern int AVPDPNetID; |
| | 977 | int playerIndex = PlayerIdInPlayerList(ghostData->playerId); |
| | 978 | |
| | 979 | if(playerIndex == NET_IDNOTINPLAYERLIST) |
| | 980 | continue; |
| | 981 | |
| | 982 | switch(ghostData->CurrentWeapon) |
| | 983 | { |
| | 984 | case WEAPON_PRED_RIFLE: |
| | 985 | case WEAPON_PRED_SHOULDERCANNON: |
| | 986 | break; |
| | 987 | default: |
| | 988 | continue; |
| | 989 | } |
| | 990 | |
| | 991 | if (AVPDPNetID == PredatorLaserSights[playerIndex].TargetID) |
| | 992 | { |
| | 993 | SECTION_DATA *plasma_muzzle = GetThisSectionData(ghostData->HModelController.section_data, "dum flash"); |
| | 994 | |
| | 995 | if (plasma_muzzle != NULL) |
| | 996 | RenderLightFlare(&plasma_muzzle->World_Offset, 0xffff0000); |
| | 997 | } |
| | 998 | else |
| | 999 | { |
| | 1000 | RenderLaserTarget(&PredatorLaserSights[playerIndex]); |
| | 1001 | } |
| | 1002 | } |
| | 1003 | } |
| | 1004 | break; |
| | 1005 | case I_BehaviourPredator: |
| | 1006 | { |
| | 1007 | PREDATOR_STATUS_BLOCK *statusPtr = (PREDATOR_STATUS_BLOCK *)sbPtr->dataptr; |
| | 1008 | //RenderLightFlare(&sbPtr->DynPtr->Position, 0x7fffffff); |
| | 1009 | |
| | 1010 | if(statusPtr->Pred_Laser_On) |
| | 1011 | { |
| | 1012 | if (statusPtr->Pred_Laser_Sight.DotIsOnPlayer) |
| | 1013 | RenderLightFlare(&statusPtr->Pred_Laser_Sight.LightSource, 0xffff0000); |
| | 1014 | else |
| | 1015 | RenderLaserTarget(&statusPtr->Pred_Laser_Sight); |
| | 1016 | } |
| | 1017 | } |
| | 1018 | default: |
| | 1019 | break; |
| | 1020 | } |
| | 1021 | } |
| | 1022 | } |
| | 1023 | } |
| | 1024 | } |
| | 1025 | |
| | 1026 | void AddDecalToHModel(VECTORCH *normalPtr, VECTORCH *positionPtr, SECTION_DATA *sectionDataPtr) |
| | 1027 | { |
| | 1028 | if (UserProfile.GameOptions.DecalsOnCharacters) |
| | 1029 | { |
| | 1030 | enum DECAL_ID decalID; |
| | 1031 | MATRIXCH orientation; |
| | 1032 | VECTORCH v; |
| | 1033 | int theta = FastRandom() & 4095; |
| | 1034 | int sin = GetSin(theta); |
| | 1035 | int cos = GetCos(theta); |
| | 1036 | |
| | 1037 | assert(sectionDataPtr->NumberOfDecals <= MAX_NO_OF_DECALS_PER_HIERARCHICAL_SECTION); |
| | 1038 | |
| | 1039 | { |
| | 1040 | MATRIXCH mat = sectionDataPtr->SecMat; |
| | 1041 | VECTORCH n = *normalPtr; |
| | 1042 | |
| | 1043 | TransposeMatrixCH(&mat); |
| | 1044 | |
| | 1045 | RotateVector(&n,&mat); |
| | 1046 | MakeMatrixFromDirection(&n,&orientation); |
| | 1047 | |
| | 1048 | v = *positionPtr; |
| | 1049 | v.vx -= sectionDataPtr->World_Offset.vx; |
| | 1050 | v.vy -= sectionDataPtr->World_Offset.vy; |
| | 1051 | v.vz -= sectionDataPtr->World_Offset.vz; |
| | 1052 | RotateVector(&v,&mat); |
| | 1053 | } |
| | 1054 | |
| | 1055 | { |
| | 1056 | SECTION *sectionPtr = sectionDataPtr->sempai; |
| | 1057 | |
| | 1058 | if(sectionPtr->flags & section_sprays_blood) |
| | 1059 | { |
| | 1060 | decalID = DECAL_HUMAN_BLOOD; |
| | 1061 | } |
| | 1062 | else if(sectionPtr->flags & section_sprays_predoblood) |
| | 1063 | { |
| | 1064 | decalID = DECAL_PREDATOR_BLOOD; |
| | 1065 | } |
| | 1066 | else if(sectionPtr->flags & section_sprays_acid) |
| | 1067 | { |
| | 1068 | decalID = DECAL_ALIEN_BLOOD; |
| | 1069 | } |
| | 1070 | else |
| | 1071 | { |
| | 1072 | decalID = DECAL_BULLETHOLE; |
| | 1073 | } |
| | 1074 | } |
| | 1075 | |
| | 1076 | OBJECT_DECAL *decalPtr = §ionDataPtr->Decals[sectionDataPtr->NextDecalToUse]; |
| | 1077 | |
| | 1078 | if (sectionDataPtr->NextDecalToUse >= MAX_NO_OF_DECALS_PER_HIERARCHICAL_SECTION-1) |
| | 1079 | sectionDataPtr->NextDecalToUse = 0; |
| | 1080 | else |
| | 1081 | sectionDataPtr->NextDecalToUse++; |
| | 1082 | |
| | 1083 | if (sectionDataPtr->NumberOfDecals < MAX_NO_OF_DECALS_PER_HIERARCHICAL_SECTION) |
| | 1084 | sectionDataPtr->NumberOfDecals++; |
| | 1085 | |
| | 1086 | decalPtr->DecalID = decalID; |
| | 1087 | int decalSize = 40;//DecalDescription[decalID].MaxSize; |
| | 1088 | |
| | 1089 | decalPtr->Centre = v; |
| | 1090 | |
| | 1091 | decalPtr->Vertices[0].vx = MUL_FIXED(-decalSize,cos) - MUL_FIXED(-decalSize,sin); |
| | 1092 | decalPtr->Vertices[0].vy = MUL_FIXED(-decalSize,sin) + MUL_FIXED(-decalSize,cos); |
| | 1093 | decalPtr->Vertices[0].vz = DECAL_Z_OFFSET; |
| | 1094 | RotateVector(&decalPtr->Vertices[0], &orientation); |
| | 1095 | decalPtr->Vertices[0].vx += v.vx; |
| | 1096 | decalPtr->Vertices[0].vy += v.vy; |
| | 1097 | decalPtr->Vertices[0].vz += v.vz; |
| | 1098 | |
| | 1099 | decalPtr->Vertices[1].vx = MUL_FIXED(decalSize,cos) - MUL_FIXED(-decalSize,sin); |
| | 1100 | decalPtr->Vertices[1].vy = MUL_FIXED(decalSize,sin) + MUL_FIXED(-decalSize,cos); |
| | 1101 | decalPtr->Vertices[1].vz = DECAL_Z_OFFSET; |
| | 1102 | RotateVector(&decalPtr->Vertices[1], &orientation); |
| | 1103 | decalPtr->Vertices[1].vx += v.vx; |
| | 1104 | decalPtr->Vertices[1].vy += v.vy; |
| | 1105 | decalPtr->Vertices[1].vz += v.vz; |
| | 1106 | |
| | 1107 | decalPtr->Vertices[2].vx = MUL_FIXED(decalSize,cos) - MUL_FIXED(decalSize,sin); |
| | 1108 | decalPtr->Vertices[2].vy = MUL_FIXED(decalSize,sin) + MUL_FIXED(decalSize,cos); |
| | 1109 | decalPtr->Vertices[2].vz = DECAL_Z_OFFSET; |
| | 1110 | RotateVector(&decalPtr->Vertices[2], &orientation); |
| | 1111 | decalPtr->Vertices[2].vx += v.vx; |
| | 1112 | decalPtr->Vertices[2].vy += v.vy; |
| | 1113 | decalPtr->Vertices[2].vz += v.vz; |
| | 1114 | |
| | 1115 | decalPtr->Vertices[3].vx = MUL_FIXED(-decalSize,cos) - MUL_FIXED(decalSize,sin); |
| | 1116 | decalPtr->Vertices[3].vy = MUL_FIXED(-decalSize,sin) + MUL_FIXED(decalSize,cos); |
| | 1117 | decalPtr->Vertices[3].vz = DECAL_Z_OFFSET; |
| | 1118 | RotateVector(&decalPtr->Vertices[3], &orientation); |
| | 1119 | decalPtr->Vertices[3].vx += v.vx; |
| | 1120 | decalPtr->Vertices[3].vy += v.vy; |
| | 1121 | decalPtr->Vertices[3].vz += v.vz; |
| | 1122 | } |
| | 1123 | } |
| | 1124 | |
| | 1125 | void ScanHModelForDecals(DISPLAYBLOCK *objectPtr, SECTION_DATA *sectionDataPtr) |
| | 1126 | { |
| | 1127 | SECTION *sectionPtr = sectionDataPtr->sempai; |
| | 1128 | |
| | 1129 | /* Unreal things aren't drawn... */ |
| | 1130 | if (!(sectionDataPtr->flags & section_data_notreal) && (sectionPtr->Shape != NULL) && sectionDataPtr->NumberOfDecals) |
| | 1131 | { |
| | 1132 | int d; |
| | 1133 | for(d = 0; d < sectionDataPtr->NumberOfDecals; d++) |
| | 1134 | { |
| | 1135 | int i; |
| | 1136 | DECAL decal; |
| | 1137 | decal.DecalID = sectionDataPtr->Decals[d].DecalID; |
| | 1138 | decal.ModuleIndex = PlayerStatus.sbptr->containingModule->m_index; |
| | 1139 | decal.UOffset = 0; |
| | 1140 | |
| | 1141 | for(i = 0; i < 5; i++) |
| | 1142 | { |
| | 1143 | decal.Vertices[i] = sectionDataPtr->Decals[d].Vertices[i]; |
| | 1144 | RotateVector(&decal.Vertices[i], §ionDataPtr->SecMat); |
| | 1145 | decal.Vertices[i].vx += sectionDataPtr->World_Offset.vx; |
| | 1146 | decal.Vertices[i].vy += sectionDataPtr->World_Offset.vy; |
| | 1147 | decal.Vertices[i].vz += sectionDataPtr->World_Offset.vz; |
| | 1148 | } |
| | 1149 | |
| | 1150 | RenderDecal(&decal); |
| | 1151 | } |
| | 1152 | } |
| | 1153 | |
| | 1154 | /* Now call recursion... */ |
| | 1155 | if (sectionDataPtr->First_Child != NULL) |
| | 1156 | { |
| | 1157 | SECTION_DATA *childrenListPtr = sectionDataPtr->First_Child; |
| | 1158 | |
| | 1159 | while (childrenListPtr != NULL) |
| | 1160 | { |
| | 1161 | ScanHModelForDecals(objectPtr, childrenListPtr); |
| | 1162 | childrenListPtr = childrenListPtr->Next_Sibling; |
| | 1163 | } |
| | 1164 | } |
| | 1165 | } |
| | 1166 | |
| | 1167 | /*------------------** |
| | 1168 | ** Load/Save Decals ** |
| | 1169 | **------------------*/ |
| | 1170 | |
| | 1171 | typedef struct decal_save_block_header |
| | 1172 | { |
| | 1173 | SAVE_BLOCK_HEADER header; |
| | 1174 | |
| | 1175 | int NumActiveDecals; |
| | 1176 | |
| | 1177 | //followed by array of decals |
| | 1178 | |
| | 1179 | } DECAL_SAVE_BLOCK_HEADER; |
| | 1180 | |
| | 1181 | void Load_Decals(SAVE_BLOCK_HEADER* header) |
| | 1182 | { |
| | 1183 | int i = 0; |
| | 1184 | DECAL_SAVE_BLOCK_HEADER* block = (DECAL_SAVE_BLOCK_HEADER*) header; |
| | 1185 | DECAL* saved_decal = (DECAL*) (block+1); |
| | 1186 | //make sure the block is the correct size |
| | 1187 | int expected_size = sizeof(*block); |
| | 1188 | expected_size += sizeof(DECAL) * block->NumActiveDecals; |
| | 1189 | |
| | 1190 | if(header->size != expected_size) |
| | 1191 | return; |
| | 1192 | |
| | 1193 | for(; i < block->NumActiveDecals; i++) |
| | 1194 | { |
| | 1195 | if (NumActiveDecals < UserProfile.GameOptions.NumberOfDecals) |
| | 1196 | { |
| | 1197 | DecalStorage[NumActiveDecals++] = *saved_decal++; |
| | 1198 | } |
| | 1199 | else |
| | 1200 | { |
| | 1201 | break; // this will most likely not happen |
| | 1202 | } |
| | 1203 | } |
| | 1204 | } |
| | 1205 | |
| | 1206 | void Save_Decals() |
| | 1207 | { |
| | 1208 | if(NumActiveDecals > 0) |
| | 1209 | { |
| | 1210 | DECAL_SAVE_BLOCK_HEADER* block; |
| | 1211 | int i = 0; |
| | 1212 | GET_SAVE_BLOCK_POINTER(block); |
| | 1213 | |
| | 1214 | //fill in header |
| | 1215 | block->header.type = SaveBlock_Decals; |
| | 1216 | block->header.size = sizeof(*block) + NumActiveDecals * sizeof(DECAL); |
| | 1217 | |
| | 1218 | block->NumActiveDecals = NumActiveDecals; |
| | 1219 | |
| | 1220 | for(; i < NumActiveDecals; i++) |
| | 1221 | { |
| | 1222 | DECAL* decal = GET_SAVE_BLOCK_POINTER(decal); |
| | 1223 | *decal = DecalStorage[i]; |
| | 1224 | } |
| | 1225 | } |
| | 1226 | } |