Mercurial > mm7
comparison Actor.cpp @ 1853:4ae5b7e7a920
Actor::AI_SpellAttack unnesting ifs, simplifying cycles
author | Grumpy7 |
---|---|
date | Mon, 14 Oct 2013 00:24:28 +0200 |
parents | 979380004db2 |
children | 51e9b4621d0a |
comparison
equal
deleted
inserted
replaced
1852:979380004db2 | 1853:4ae5b7e7a920 |
---|---|
251 int v52; // eax@132 | 251 int v52; // eax@132 |
252 int v53; // ecx@137 | 252 int v53; // ecx@137 |
253 int v54; // ecx@138 | 253 int v54; // ecx@138 |
254 int v55; // eax@142 | 254 int v55; // eax@142 |
255 SpellBuff *v56; // esi@143 | 255 SpellBuff *v56; // esi@143 |
256 Player **v57; // esi@145 | 256 Player *v57; // esi@145 |
257 int v58; // eax@146 | 257 int v58; // eax@146 |
258 int v59; // edi@146 | 258 int v59; // edi@146 |
259 int v60; // eax@146 | 259 int v60; // eax@146 |
260 int v61; // edi@146 | 260 int v61; // edi@146 |
261 int v62; // eax@146 | 261 int v62; // eax@146 |
370 0, | 370 0, |
371 0, | 371 0, |
372 0); | 372 0); |
373 return; | 373 return; |
374 } | 374 } |
375 v10 = 3; | 375 if (masteryLevel <= 1) |
376 if ( uSkillLevel & 0x0100 ) | 376 v10 = 3; |
377 { | 377 else if (masteryLevel == 2 ) |
378 v105 = 9; | 378 v10 = 5; |
379 } | 379 else if (masteryLevel == 3 ) |
380 else | 380 v10 = 7; |
381 { | 381 else if (masteryLevel == 4 ) |
382 if ( (uSkillLevel & 0x80u) == 0 ) | 382 v10 = 9; |
383 { | |
384 if ( !(uSkillLevel & 0x40) ) | |
385 goto LABEL_29; | |
386 v105 = 5; | |
387 } | |
388 else | |
389 { | |
390 v105 = 7; | |
391 } | |
392 } | |
393 v10 = v105; | |
394 LABEL_29: | |
395 spellnuma = (signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360; | 383 spellnuma = (signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360; |
396 a1.uType = stru_4E3ACC[15].uType; | 384 a1.uType = stru_4E3ACC[15].uType; |
397 v118 = (signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360 / (v10 - 1); | 385 v118 = (signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360 / (v10 - 1); |
398 v11 = 0; | 386 v11 = 0; |
399 if ( (signed int)pObjectList->uNumObjects <= 0 ) | 387 for (unsigned int i = 0; i < pObjectList->uNumObjects; i++) |
400 { | 388 { |
401 LABEL_33: | 389 if (stru_4E3ACC[15].uType == pObjectList->pObjects[i].uObjectID) |
402 LOWORD(v11) = 0; | |
403 } | |
404 else | |
405 { | |
406 v12 = &pObjectList->pObjects->uObjectID; | |
407 while ( stru_4E3ACC[15].uType != *v12 ) | |
408 { | 390 { |
409 ++v11; | 391 v11 = i; |
410 v12 += 28; | 392 break; |
411 if ( v11 >= (signed int)pObjectList->uNumObjects ) | |
412 goto LABEL_33; | |
413 } | 393 } |
414 } | 394 } |
415 a1.uObjectDescID = v11; | 395 a1.uObjectDescID = v11; |
416 a1.stru_24.Reset(); | 396 a1.stru_24.Reset(); |
417 a1.spell_id = SPELL_AIR_SPARKS; | 397 a1.spell_id = SPELL_AIR_SPARKS; |
466 return; | 446 return; |
467 } | 447 } |
468 LABEL_159: | 448 LABEL_159: |
469 a1.uType = stru_4E3ACC[uSpellID].uType; | 449 a1.uType = stru_4E3ACC[uSpellID].uType; |
470 v119 = 0.0; | 450 v119 = 0.0; |
471 if ( (signed int)pObjectList->uNumObjects <= 0 ) | 451 v82 = 0; |
452 for (int i = 0; i < pObjectList->uNumObjects; i++) | |
472 { | 453 { |
473 LABEL_191: | 454 if (a1.uType == pObjectList->pObjects[i].uObjectID) |
474 v82 = 0; | |
475 } | |
476 else | |
477 { | |
478 v66 = (char *)&pObjectList->pObjects->uObjectID; | |
479 while ( (short)a1.uType != *(short *)v66 ) | |
480 { | 455 { |
481 ++LODWORD(v119); | 456 v82 = i; |
482 v66 += 56; | 457 break; |
483 if ( SLODWORD(v119) >= (signed int)pObjectList->uNumObjects ) | |
484 goto LABEL_191; | |
485 } | 458 } |
486 v82 = LOWORD(v119); | |
487 } | 459 } |
488 a1.uObjectDescID = v82; | 460 a1.uObjectDescID = v82; |
489 a1.stru_24.Reset(); | 461 a1.stru_24.Reset(); |
490 a1.spell_id = uSpellID; | 462 a1.spell_id = uSpellID; |
491 v83 = v5->vPosition.x; | 463 v83 = v5->vPosition.x; |
506 a1.uSectorID = v88; | 478 a1.uSectorID = v88; |
507 LODWORD(v119) = v89; | 479 LODWORD(v119) = v89; |
508 a1.uSpriteFrameID = 0; | 480 a1.uSpriteFrameID = 0; |
509 a1.spell_caster_pid = PID(OBJECT_Actor, LODWORD(v120)); | 481 a1.spell_caster_pid = PID(OBJECT_Actor, LODWORD(v120)); |
510 a1.spell_target_pid = 0; | 482 a1.spell_target_pid = 0; |
511 a1.field_60_distance_related_prolly_lod = 3; | 483 if ((double)v89 < 307.2 ) |
512 if ( (double)v89 >= 307.2 ) | |
513 { | |
514 if ( v89 >= 1024 ) | |
515 { | |
516 if ( v89 >= 2560 ) | |
517 { | |
518 if ( v89 < 5120 ) | |
519 a1.field_60_distance_related_prolly_lod = 3; | |
520 } | |
521 else | |
522 { | |
523 a1.field_60_distance_related_prolly_lod = 2; | |
524 } | |
525 } | |
526 else | |
527 { | |
528 a1.field_60_distance_related_prolly_lod = 1; | |
529 } | |
530 } | |
531 else | |
532 { | |
533 a1.field_60_distance_related_prolly_lod = 0; | 484 a1.field_60_distance_related_prolly_lod = 0; |
534 } | 485 else if ( v89 < 1024 ) |
486 a1.field_60_distance_related_prolly_lod = 1; | |
487 else if ( v89 < 2560 ) | |
488 a1.field_60_distance_related_prolly_lod = 2; | |
489 else | |
490 a1.field_60_distance_related_prolly_lod = 3; | |
491 | |
535 a1.field_61 = 2; | 492 a1.field_61 = 2; |
536 v91 = a1.Create( | 493 v91 = a1.Create( |
537 v86->uYawAngle, | 494 v86->uYawAngle, |
538 v86->uPitchAngle, | 495 v86->uPitchAngle, |
539 pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed, | 496 pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed, |
555 v118 = pParty->vPosition.z; | 512 v118 = pParty->vPosition.z; |
556 v111 = pParty->vPosition.x; | 513 v111 = pParty->vPosition.x; |
557 v114 = pParty->vPosition.z + 2500; | 514 v114 = pParty->vPosition.z + 2500; |
558 v113 = pParty->vPosition.y; | 515 v113 = pParty->vPosition.y; |
559 v23 = 8; | 516 v23 = 8; |
560 if ( uSkillLevel & 0x0100 ) | 517 if (masteryLevel == 2) |
561 { | 518 v23 = 10; |
562 v107 = 14; | 519 else if (masteryLevel == 3) |
563 } | 520 v23 = 12; |
564 else | 521 else if (masteryLevel == 4) |
565 { | 522 v23 = 14; |
566 if ( (uSkillLevel & 0x80u) == 0 ) | |
567 { | |
568 if ( !(uSkillLevel & 0x40) ) | |
569 goto LABEL_48; | |
570 v107 = 10; | |
571 } | |
572 else | |
573 { | |
574 v107 = 12; | |
575 } | |
576 } | |
577 v23 = v107; | |
578 LABEL_48: | |
579 v119 = 0.0; | 523 v119 = 0.0; |
580 spellnumb = 0; | 524 spellnumb = 0; |
581 if ( v23 > 0 ) | 525 if ( v23 > 0 ) |
582 { | 526 { |
583 v24 = (double)v118; | 527 v24 = (double)v118; |
607 v32 = stru_5C6E00->Atan2((signed __int64)v110, (signed __int64)v29); | 551 v32 = stru_5C6E00->Atan2((signed __int64)v110, (signed __int64)v29); |
608 pitch = stru_5C6E00->Atan2(v31, (signed __int64)spellnumc); | 552 pitch = stru_5C6E00->Atan2(v31, (signed __int64)spellnumc); |
609 } | 553 } |
610 a1.stru_24.Reset(); | 554 a1.stru_24.Reset(); |
611 a1.uType = stru_4E3ACC[9].uType; | 555 a1.uType = stru_4E3ACC[9].uType; |
612 spellnumd = 0; | 556 v34 = 0; |
613 if ( (signed int)pObjectList->uNumObjects <= 0 ) | 557 for (int i = 0; i < pObjectList->uNumObjects; i++) |
614 { | 558 { |
615 LABEL_57: | 559 if (pObjectList->pObjects[i].uObjectID == a1.uType) |
616 v34 = 0; | |
617 } | |
618 else | |
619 { | |
620 v33 = (char *)&pObjectList->pObjects->uObjectID; | |
621 while ( (short)a1.uType != *(short *)v33 ) | |
622 { | 560 { |
623 ++spellnumd; | 561 v34 = i; |
624 v33 += 56; | 562 break; |
625 if ( spellnumd >= (signed int)pObjectList->uNumObjects ) | |
626 goto LABEL_57; | |
627 } | 563 } |
628 v34 = spellnumd; | |
629 } | 564 } |
630 a1.uObjectDescID = v34; | 565 a1.uObjectDescID = v34; |
631 a1.spell_level = uSkillLevel; | 566 a1.spell_level = uSkillLevel; |
632 a1.vPosition.x = v111; | 567 a1.vPosition.x = v111; |
633 a1.vPosition.y = v113; | 568 a1.vPosition.y = v113; |
642 a1.field_60_distance_related_prolly_lod = stru_50C198._427546(v30 + 2500); | 577 a1.field_60_distance_related_prolly_lod = stru_50C198._427546(v30 + 2500); |
643 a1.uFacing = v32; | 578 a1.uFacing = v32; |
644 a1.uSoundID = 0; | 579 a1.uSoundID = 0; |
645 v35 = v117->uDistance; | 580 v35 = v117->uDistance; |
646 LODWORD(v119) = v117->uDistance; | 581 LODWORD(v119) = v117->uDistance; |
647 if ( (double)SLODWORD(v119) >= 307.2 ) | 582 if ((double)v119 < 307.2 ) |
648 { | |
649 if ( v35 >= 1024 ) | |
650 { | |
651 if ( v35 >= 2560 ) | |
652 { | |
653 if ( v35 < 5120 ) | |
654 a1.field_60_distance_related_prolly_lod = 3; | |
655 } | |
656 else | |
657 { | |
658 a1.field_60_distance_related_prolly_lod = 2; | |
659 } | |
660 } | |
661 else | |
662 { | |
663 a1.field_60_distance_related_prolly_lod = 1; | |
664 } | |
665 } | |
666 else | |
667 { | |
668 a1.field_60_distance_related_prolly_lod = 0; | 583 a1.field_60_distance_related_prolly_lod = 0; |
669 } | 584 else if ( v119 < 1024 ) |
585 a1.field_60_distance_related_prolly_lod = 1; | |
586 else if ( v119 < 2560 ) | |
587 a1.field_60_distance_related_prolly_lod = 2; | |
588 else | |
589 a1.field_60_distance_related_prolly_lod = 3; | |
670 a1.field_61 = 2; | 590 a1.field_61 = 2; |
671 v36 = a1.Create( | 591 v36 = a1.Create( |
672 v32, | 592 v32, |
673 pitch, | 593 pitch, |
674 pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed, | 594 pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed, |
822 } | 742 } |
823 if ( uSpellID <= 80 ) | 743 if ( uSpellID <= 80 ) |
824 { | 744 { |
825 if ( uSpellID == 80 ) | 745 if ( uSpellID == 80 ) |
826 { | 746 { |
827 v56 = pParty->pPartyBuffs; | 747 for (int i = 0; i < 20; i++ ) |
828 do | |
829 { | 748 { |
830 v56->Reset(); | 749 pParty->pPartyBuffs[i].Reset(); |
831 ++v56; | |
832 } | 750 } |
833 while ( (signed int)v56 < (signed int)pParty->pPlayers ); | 751 for (int i = 1; i <= 4; i++) |
834 a1b = 1; | |
835 v57 = &pPlayers[1]; | |
836 do | |
837 { | 752 { |
838 v58 = (*v57)->GetActualWillpower(); | 753 v57 = pPlayers[i]; |
839 v59 = (*v57)->GetParameterBonus(v58); | 754 v58 = (v57)->GetActualWillpower(); |
840 v60 = (*v57)->GetActualIntelligence(); | 755 v59 = (v57)->GetParameterBonus(v58); |
841 v61 = ((*v57)->GetParameterBonus(v60) + v59) >> 1; | 756 v60 = (v57)->GetActualIntelligence(); |
842 v62 = (*v57)->GetActualLuck(); | 757 v61 = ((v57)->GetParameterBonus(v60) + v59) >> 1; |
843 v63 = v61 + (*v57)->GetParameterBonus(v62) + 30; | 758 v62 = (v57)->GetActualLuck(); |
759 v63 = v61 + (v57)->GetParameterBonus(v62) + 30; | |
844 if ( rand() % v63 < 30 ) | 760 if ( rand() % v63 < 30 ) |
845 { | 761 { |
846 v64 = 6048; | 762 for (int k = 0; k < v57->pPlayerBuffs.size(); k++) |
847 do | |
848 { | 763 { |
849 ((SpellBuff *)((char *)*v57 + v64))->Reset(); | 764 v57->pPlayerBuffs[k].Reset(); |
850 v64 += 16; | |
851 } | 765 } |
852 while ( v64 < 6432 ); | 766 pOtherOverlayList->_4418B1(11210, i + 99, 0, 65536); |
853 pOtherOverlayList->_4418B1(11210, a1b + 99, 0, 65536); | |
854 } | 767 } |
855 ++a1b; | |
856 ++v57; | |
857 } | 768 } |
858 while ( (signed int)v57 <= (signed int)&pPlayers[4] ); | |
859 v65 = 8 * LODWORD(v120); | 769 v65 = 8 * LODWORD(v120); |
860 LOBYTE(v65) = PID(OBJECT_Actor,LOBYTE(v120)); | 770 LOBYTE(v65) = PID(OBJECT_Actor,LOBYTE(v120)); |
861 v99 = v65; | 771 v99 = v65; |
862 v22 = (SoundID)word_4EE088_sound_ids[80]; | 772 v22 = (SoundID)word_4EE088_sound_ids[80]; |
863 v98 = v22; | 773 v98 = v22; |
899 v99 = v50; | 809 v99 = v50; |
900 v98 = (SoundID)14020; | 810 v98 = (SoundID)14020; |
901 pAudioPlayer->PlaySound(v98, v99, 0, -1, 0, 0, 0, 0); | 811 pAudioPlayer->PlaySound(v98, v99, 0, -1, 0, 0, 0, 0); |
902 return; | 812 return; |
903 } | 813 } |
904 v49 = uSpellID == 78; | 814 if ( uSpellID != 78 ) |
905 LABEL_158: | |
906 if ( !v49 ) | |
907 return; | 815 return; |
908 goto LABEL_159; | 816 goto LABEL_159; |
909 } | 817 } |
910 if (masteryLevel == 0) | 818 if (masteryLevel == 0) |
911 { | 819 { |
1014 goto LABEL_159; | 922 goto LABEL_159; |
1015 if ( uSpellID != 93 ) | 923 if ( uSpellID != 93 ) |
1016 { | 924 { |
1017 if ( uSpellID != 95 ) | 925 if ( uSpellID != 95 ) |
1018 { | 926 { |
1019 v49 = uSpellID == 97; | 927 if ( uSpellID != 97 ) |
1020 goto LABEL_158; | 928 return; |
929 goto LABEL_159; | |
1021 } | 930 } |
1022 if (masteryLevel == 0) | 931 if (masteryLevel == 0) |
1023 v68 = 0; | 932 v68 = 0; |
1024 else if (masteryLevel == 1 || (masteryLevel == 2) || (masteryLevel == 3)) | 933 else if (masteryLevel == 1 || (masteryLevel == 2) || (masteryLevel == 3)) |
1025 { | 934 { |
1043 v99 = v69; | 952 v99 = v69; |
1044 v98 = (SoundID)18060; | 953 v98 = (SoundID)18060; |
1045 pAudioPlayer->PlaySound(v98, v99, 0, -1, 0, 0, 0, 0); | 954 pAudioPlayer->PlaySound(v98, v99, 0, -1, 0, 0, 0, 0); |
1046 return; | 955 return; |
1047 } | 956 } |
957 | |
1048 v70 = 3; | 958 v70 = 3; |
1049 if ( uSkillLevel & 0x100 ) | 959 if (masteryLevel == 2) |
1050 { | 960 v108 = 5; |
961 else if (masteryLevel == 3) | |
962 v108 = 7; | |
963 else if (masteryLevel == 4) | |
1051 v108 = 9; | 964 v108 = 9; |
1052 } | 965 |
1053 else | |
1054 { | |
1055 if ( (uSkillLevel & 0x80u) == 0 ) | |
1056 { | |
1057 if ( !(uSkillLevel & 0x40) ) | |
1058 goto LABEL_179; | |
1059 v108 = 5; | |
1060 } | |
1061 else | |
1062 { | |
1063 v108 = 7; | |
1064 } | |
1065 } | |
1066 v70 = v108; | |
1067 LABEL_179: | |
1068 spellnume = (signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360; | 966 spellnume = (signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360; |
1069 a1.uType = stru_4E3ACC[SPELL_DARK_SHARPMETAL].uType; | 967 a1.uType = stru_4E3ACC[SPELL_DARK_SHARPMETAL].uType; |
1070 v116 = (signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360 / (v70 - 1); | 968 v116 = (signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360 / (v70 - 1); |
1071 v71 = 0; | 969 v71 = 0; |
1072 if ( (signed int)pObjectList->uNumObjects <= 0 ) | 970 for (int i = 0; i < pObjectList->uNumObjects; i++) |
1073 { | 971 { |
1074 LABEL_183: | 972 if (pObjectList->pObjects[i].uObjectID == stru_4E3ACC[SPELL_DARK_SHARPMETAL].uType) |
1075 LOWORD(v71) = 0; | 973 { |
1076 } | 974 v71 = i; |
1077 else | 975 break; |
1078 { | |
1079 v72 = &pObjectList->pObjects->uObjectID; | |
1080 while ( stru_4E3ACC[SPELL_DARK_SHARPMETAL].uType != *v72 ) | |
1081 { | |
1082 ++v71; | |
1083 v72 += 28; | |
1084 if ( v71 >= (signed int)pObjectList->uNumObjects ) | |
1085 goto LABEL_183; | |
1086 } | 976 } |
1087 } | 977 } |
1088 a1.uObjectDescID = v71; | 978 a1.uObjectDescID = v71; |
1089 a1.stru_24.Reset(); | 979 a1.stru_24.Reset(); |
1090 a1.spell_id = SPELL_DARK_SHARPMETAL; | 980 a1.spell_id = SPELL_DARK_SHARPMETAL; |