comparison Player.cpp @ 1297:5450af4f57ef

moving files mm7_x ending
author Ritor1
date Wed, 19 Jun 2013 17:06:58 +0600
parents 86a83e12d795
children 0665a061132b
comparison
equal deleted inserted replaced
1296:c423f946dc99 1297:5450af4f57ef
27 #include "Awards.h" 27 #include "Awards.h"
28 #include "texts.h" 28 #include "texts.h"
29 29
30 #include "mm7_data.h" 30 #include "mm7_data.h"
31 #include "MM7.h" 31 #include "MM7.h"
32 32 #include "SpriteObject.h"
33 #include "DecalBuilder.h"
33 34
34 35
35 36
36 37
37 38
9560 return uActiveCharacter; 9561 return uActiveCharacter;
9561 } 9562 }
9562 } 9563 }
9563 return result; 9564 return result;
9564 } 9565 }
9566 //----- (0043EE77) --------------------------------------------------------
9567 bool __fastcall sub_43EE77_ProbablyIfUnderwaterSuitIsEquipped(signed int a1)
9568 {
9569 bool result; // eax@0
9570 Player *v2; // edx@3
9571 int v3; // ecx@3
9572 Player **pPlayers; // esi@8
9573 unsigned int v5; // ecx@8
9574 Player *v6; // edx@9
9575
9576 if ( a1 < 1 || a1 > 4 )
9577 {
9578 if ( !a1 )
9579 {
9580 pPlayers = &::pPlayers[1];
9581 v5 = 604;
9582 while ( 1 )
9583 {
9584 result = Player_has_item(v5, *pPlayers, 0);
9585 if ( !result )
9586 break;
9587 result = v6->pEquipment.uArmor;
9588 if ( !result )
9589 break;
9590 result *= 9;
9591 if ( *(int *)&v6->spellbook.pDarkSpellbook.bIsSpellAvailable[4 * result + 5] != v5 )
9592 break;
9593 ++pPlayers;
9594 if ( (signed int)pPlayers >= (signed int)&qword_A750D8 )
9595 goto LABEL_13;
9596 }
9597 }
9598 goto LABEL_6;
9599 }
9600 result = Player_has_item(604u, ::pPlayers[a1], 0);
9601 if ( !result
9602 || (result = v2->pEquipment.uArmor) == 0
9603 || (result *= 9, *(int *)&v2->spellbook.pDarkSpellbook.bIsSpellAvailable[4 * result + 5] != v3) )
9604 {
9605 LABEL_6:
9606 LOBYTE(result) = 0;
9607 return result;
9608 }
9609 LABEL_13:
9610 LOBYTE(result) = 1;
9611 return result;
9612 }
9613 //----- (0043EE15) --------------------------------------------------------
9614 bool __fastcall Player_has_item(unsigned int uItemID, Player *pPlayer, char a3)
9615 {
9616 if ( !a3 || pParty->pPickedItem.uItemID != uItemID )
9617 {
9618 for ( uint i = 0; i < 126; ++i )
9619 {
9620 if ( pPlayer->pInventoryIndices[i] > 0 )
9621 {
9622 if ( (unsigned int)pPlayer->pInventoryItems[pPlayer->pInventoryIndices[i] - 1].uItemID == uItemID )
9623 return true;
9624 }
9625 }
9626 for ( uint i = 0; i < 16; ++i )
9627 {
9628 if ( pPlayer->pEquipment.pIndices[i] )
9629 {
9630 if ( (unsigned int)pPlayer->pInventoryItems[pPlayer->pEquipment.pIndices[i] - 1].uItemID == uItemID )
9631 return true;
9632 }
9633 }
9634 }
9635 return false;
9636 }
9637 //----- (0043EDB9) --------------------------------------------------------
9638 bool __thiscall sub_43EDB9_get_some_race_sex_relation_2(unsigned int a1)
9639 {
9640 unsigned int pNum; // ebp@1
9641 Player **pPlayer; // ebx@1
9642 Player *pPlayer2; // esi@2
9643 enum CHARACTER_RACE pRace; // edi@2
9644 bool pSex; // eax@2
9645 char v6; // zf@7
9646
9647 //pPlayer = &pPlayers[1];
9648 /*pNum = a1;
9649
9650 while ( 1 )
9651 {
9652 pPlayer2 = *pPlayer;
9653 pRace = pPlayer2->GetRace();
9654 pSex = pPlayer2->GetSexByVoice();
9655 if ( !pRace )
9656 break;
9657 if ( pRace == 1 || pRace == 2 )
9658 break;
9659 if ( !pSex && pNum == 2 )//
9660 //goto LABEL_15;
9661 {
9662 pSex = 1;
9663 return pSex;
9664 }
9665 v6 = pNum == 3;//
9666 LABEL_11:
9667 if ( v6 )
9668 //goto LABEL_15;
9669 {
9670 pSex = 1;
9671 return pSex;
9672 }
9673 ++pPlayer;
9674 if ( (signed int)pPlayer >= (signed int)&qword_A750D8 )//
9675 {
9676 pSex = 0;
9677 return pSex;
9678 }
9679 }
9680 if ( pSex || pNum )
9681 {
9682 v6 = pNum == 1;
9683 goto LABEL_11;
9684 }
9685 //LABEL_15:
9686 pSex = 1;
9687 return pSex;*/
9688 for (uint i = 1; i <= 4; ++i)
9689 {
9690 pRace = pPlayers[i]->GetRace();
9691 pSex = pPlayers[i]->GetSexByVoice();
9692 if (pRace == 0 || pRace == 1 || pRace == 2 || pSex == 0 )
9693 return 1;
9694 }
9695 return 0;
9696 }
9697 //----- (0043ED6F) --------------------------------------------------------
9698 bool _43ED6F_check_party_races(bool a1)
9699 {
9700 bool v6; // zf@5
9701
9702 for (uint i = 0; i < 4; ++i)
9703 {
9704 auto player = pParty->pPlayers + i;
9705 auto race = player->GetRace();
9706
9707 if (race != CHARACTER_RACE_HUMAN &&
9708 race != CHARACTER_RACE_ELF &&
9709 race != CHARACTER_RACE_GOBLIN)
9710 v6 = a1 == 1;
9711 else
9712 v6 = !a1;
9713
9714 if (v6)
9715 return true;
9716 }
9717 return false;
9718 }
9719 //----- (00439FCB) --------------------------------------------------------
9720 void __fastcall DamagePlayerFromMonster(unsigned int uObjID, int a2, Vec3_int_ *pPos, unsigned int a4)
9721 {
9722 signed int v4; // esi@1
9723 unsigned int v5; // ecx@1
9724 Player *v6; // ebx@3
9725 Actor *v7; // esi@3
9726 unsigned int v8; // eax@4
9727 char *v9; // eax@5
9728 signed int v10; // eax@6
9729 int v11; // edx@8
9730 int v12; // edx@9
9731 int v13; // edx@10
9732 int v14; // edx@16
9733 int v15; // edx@17
9734 int v16; // edx@18
9735 enum SoundID v17; // eax@24
9736 int v18; // eax@26
9737 unsigned __int8 v19; // zf@26
9738 unsigned __int8 v20; // sf@26
9739 unsigned __int16 v21; // ax@29
9740 signed int v22; // edi@36
9741 int v23; // eax@38
9742 signed int v24; // eax@44
9743 unsigned __int16 v25; // cx@47
9744 signed int v26; // eax@49
9745 int v27; // eax@54
9746 float v28; // ST18_4@58
9747 double v29; // st7@58
9748 float v30; // ST08_4@58
9749 double v31; // st7@58
9750 float v32; // ST04_4@58
9751 float v33; // ST00_4@58
9752 int v34; // edi@61
9753 int v35; // eax@70
9754 double v36; // st7@70
9755 SpriteObject *v37; // ebx@77
9756 int v38; // edi@77
9757 int v39; // esi@77
9758 int v40; // eax@77
9759 int v41; // eax@77
9760 int v42; // eax@78
9761 Player *v43; // eax@81
9762 Actor *v44; // esi@82
9763 Player *v45; // edi@84
9764 unsigned __int16 v46; // ax@84
9765 int v47; // ebx@105
9766 int v48; // eax@107
9767 unsigned __int16 v49; // ax@116
9768 int v50; // ebx@123
9769 unsigned __int16 v51; // ax@124
9770 char v52; // bl@124
9771 int v53; // eax@128
9772 signed int v54; // eax@134
9773 unsigned __int16 v55; // cx@137
9774 signed int v56; // eax@139
9775 int v57; // eax@144
9776 float v58; // ST18_4@148
9777 double v59; // st7@148
9778 float v60; // ST08_4@148
9779 double v61; // st7@148
9780 float v62; // ST04_4@148
9781 float v63; // ST00_4@148
9782 int v64; // ebx@151
9783 int v65; // eax@161
9784 double v66; // st7@161
9785 signed int v67; // ecx@164
9786 signed int v68; // eax@170
9787 int v69; // ecx@170
9788 int v70; // eax@171
9789 enum SoundID v71; // [sp+20h] [bp-34h]@12
9790 int v72; // [sp+30h] [bp-24h]@164
9791 double v73; // [sp+40h] [bp-14h]@72
9792 signed int v74; // [sp+44h] [bp-10h]@1
9793 unsigned int v75; // [sp+48h] [bp-Ch]@3
9794 unsigned int uActorID; // [sp+4Ch] [bp-8h]@1
9795 int v77; // [sp+50h] [bp-4h]@26
9796 signed int a4a; // [sp+60h] [bp+Ch]@162
9797 Player *a4b; // [sp+60h] [bp+Ch]@168
9798
9799 v4 = PID_ID(uObjID);
9800 v5 = PID_TYPE(uObjID) - 2;
9801 v74 = a2;
9802 uActorID = v4;
9803 if ( v5 )
9804 {
9805 if ( v5 != 1
9806 || (v6 = &pParty->pPlayers[a4], v7 = &pActors[v4],
9807 v75 = v6->sHealth,
9808 !stru_50C198.ActorHitOrMiss(v7, v6)) )
9809 return;
9810 v8 = v6->pEquipment.uArmor;
9811 if ( !v8
9812 || (v9 = (char *)v6 + 36 * v8, v9[516] & 2)
9813 || (v10 = pItemsTable->pItems[*((int *)v9 + 124)].uSkillType, v10 < 10)
9814 || v10 > 11 )
9815 {
9816 v14 = rand() % 4;
9817 if ( !v14 )
9818 {
9819 v71 = (SoundID)108;
9820 goto LABEL_24;
9821 }
9822 v15 = v14 - 1;
9823 if ( !v15 )
9824 {
9825 v71 = (SoundID)109;
9826 goto LABEL_24;
9827 }
9828 v16 = v15 - 1;
9829 if ( !v16 )
9830 {
9831 v71 = (SoundID)110;
9832 goto LABEL_24;
9833 }
9834 if ( v16 == 1 )
9835 {
9836 v71 = (SoundID)44;
9837 goto LABEL_24;
9838 }
9839 }
9840 else
9841 {
9842 v11 = rand() % 4;
9843 if ( !v11 )
9844 {
9845 v71 = (SoundID)105;
9846 goto LABEL_24;
9847 }
9848 v12 = v11 - 1;
9849 if ( !v12 )
9850 {
9851 v71 = (SoundID)106;
9852 goto LABEL_24;
9853 }
9854 v13 = v12 - 1;
9855 if ( !v13 )
9856 {
9857 v71 = (SoundID)107;
9858 goto LABEL_24;
9859 }
9860 if ( v13 == 1 )
9861 {
9862 v71 = (SoundID)45;
9863 LABEL_24:
9864 v17 = v71;
9865 goto LABEL_26;
9866 }
9867 }
9868 v17 = (SoundID)a4;
9869 LABEL_26:
9870 pAudioPlayer->PlaySound(v17, PID(OBJECT_Player,a4 + 80), 0, -1, 0, 0, 0, 0);
9871 v18 = Actor::_43B3E0_CalcDamage(v7, v74);
9872 v19 = HIDWORD(v7->pActorBuffs[3].uExpireTime) == 0;
9873 v20 = SHIDWORD(v7->pActorBuffs[3].uExpireTime) < 0;
9874 v77 = v18;
9875 if ( !v20 && (!(v20 | v19) || LODWORD(v7->pActorBuffs[3].uExpireTime) > 0) )
9876 {
9877 v21 = v7->pActorBuffs[3].uPower;
9878 if ( v21 )
9879 v77 /= (signed int)v21;
9880 }
9881 if ( v74 )
9882 {
9883 if ( v74 == 1 )
9884 {
9885 v22 = v7->pMonsterInfo.uAttack2Type;
9886 }
9887 else
9888 {
9889 if ( v74 == 2 )
9890 {
9891 v23 = v7->pMonsterInfo.uSpell1ID;
9892 }
9893 else
9894 {
9895 if ( v74 != 3 )
9896 {
9897 if ( v74 == 4 )
9898 v22 = v7->pMonsterInfo.field_3C_some_special_attack;
9899 else
9900 v22 = 4;
9901 goto LABEL_43;
9902 }
9903 v23 = v7->pMonsterInfo.uSpell2ID;
9904 }
9905 v22 = LOBYTE(pSpellStats->pInfos[v23].uSchool);
9906 }
9907 }
9908 else
9909 {
9910 v22 = v7->pMonsterInfo.uAttack1Type;
9911 }
9912 LABEL_43:
9913 if ( !(dword_6BE368_debug_settings_2 & 0x10) )
9914 {
9915 v24 = v6->ReceiveDamage(v77, (DAMAGE_TYPE)v22);
9916 if ( SHIDWORD(v6->pPlayerBuffs[10].uExpireTime) >= 0
9917 && (SHIDWORD(v6->pPlayerBuffs[10].uExpireTime) > 0 || LODWORD(v6->pPlayerBuffs[10].uExpireTime)) )
9918 {
9919 v25 = v7->uAIState;
9920 if ( v25 != 5 )
9921 {
9922 if ( v25 != 4 )
9923 {
9924 v26 = stru_50C198.CalcMagicalDamageToActor(v7, v22, v24);
9925 v7->sCurrentHP -= v26;
9926 if ( v26 )
9927 {
9928 if ( v7->sCurrentHP >= 1 )
9929 {
9930 Actor::AI_Stun(uActorID, PID(OBJECT_Player,a4), 0);
9931 Actor::AggroSurroundingPeasants(uActorID, 1);
9932 }
9933 else
9934 {
9935 if ( pMonsterStats->pInfos[v7->pMonsterInfo.uID].bQuestMonster & 1 )
9936 {
9937 v27 = byte_4D864C && BYTE2(pGame->uFlags) & 8 ? 10 * v7->uActorRadius : v7->uActorRadius;
9938 v74 = v27;
9939 if ( pRenderer->pRenderD3D )
9940 {
9941 if ( pGame->uFlags2 & GAME_FLAGS_2_DRAW_BLOODSPLATS )
9942 {
9943 v28 = (double)v74;
9944 v74 = v7->vPosition.z;
9945 v29 = (double)v74;
9946 v74 = v7->vPosition.y;
9947 v30 = v29;
9948 v31 = (double)v74;
9949 v74 = v7->vPosition.x;
9950 v32 = v31;
9951 v33 = (double)v74;
9952 pDecalBuilder->AddBloodsplat(v33, v32, v30, 1.0, 0.0, 0.0, v28, 0, 0);
9953 }
9954 }
9955 }
9956 Actor::Die(uActorID);
9957 Actor::ApplyFineForKillingPeasant(uActorID);
9958 Actor::AggroSurroundingPeasants(uActorID, 1);
9959 if ( v7->pMonsterInfo.uExp )
9960 GivePartyExp(pMonsterStats->pInfos[v7->pMonsterInfo.uID].uExp);
9961 v34 = SPEECH_51;
9962 if ( rand() % 100 < 20 )
9963 v34 = ((signed int)v7->pMonsterInfo.uHP >= 100) + 1;
9964 v6->PlaySound((PlayerSpeech)v34, 0);
9965 }
9966 }
9967 }
9968 }
9969 }
9970 if ( !(dword_6BE368_debug_settings_2 & 0x10)
9971 && v7->pMonsterInfo.uSpecialAttack
9972 && rand() % 100 < v7->pMonsterInfo.uLevel * v7->pMonsterInfo.uSpecialAttackType )
9973 v6->_48DCF6(v7->pMonsterInfo.uSpecialAttack, v7);
9974 }
9975 if ( !pParty->bTurnBasedModeOn )
9976 {
9977 v35 = v6->GetActualEndurance();
9978 v36 = (double)(20 - v6->GetParameterBonus(v35)) * flt_6BE3A4_debug_recmod1 * 2.133333333333333;
9979 v6->SetRecoveryTime((signed __int64)v36);
9980 }
9981 if ( v77 )
9982 {
9983 v73 = (double)(signed int)v75;
9984 if ( (double)v6->GetMaxHealth() * 0.25 < v73 )
9985 {
9986 if ( v6->sHealth > 0 )
9987 {
9988 if ( (double)v6->GetMaxHealth() * 0.25 >= (double)v6->sHealth )
9989 v6->PlaySound(SPEECH_48, 0);
9990 }
9991 }
9992 }
9993 viewparams->bRedrawGameUI = 1;
9994 return;
9995 }
9996 v37 = &pSpriteObjects[uActorID];
9997 v38 = PID_TYPE(v37->spell_caster_pid);
9998 v39 = PID_ID(v37->spell_caster_pid);
9999 v40 = PID_TYPE(v37->spell_caster_pid);
10000 uActorID = PID_ID(v37->spell_caster_pid);
10001 v41 = v40 - 2;
10002 if ( !v41 )
10003 goto LABEL_80;
10004 v42 = v41 - 1;
10005 if ( !v42 )
10006 {
10007 v44 = &pActors[v39];
10008 if ( a4 == -1 )
10009 a4 = stru_50C198.which_player_would_attack(v44);
10010 v45 = &pParty->pPlayers[a4];
10011 v77 = Actor::_43B3E0_CalcDamage(v44, v74);
10012 v46 = v37->uType;
10013 if ( v37->uType == 545 )
10014 {
10015 LOBYTE(v51) = v45->GetActualSkillLevel(PLAYER_SKILL_UNARMED);
10016 v52 = v51;
10017 if ( (signed int)SkillToMastery(v51) >= 4 && rand() % 100 < (v52 & 0x3F) )
10018 {
10019 sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[637], v45->pName);
10020 ShowStatusBarString(pTmpBuf.data(), 2u);
10021 v45->PlaySound(SPEECH_6, 0);
10022 return;
10023 }
10024 }
10025 else
10026 {
10027 if ( v46 != 555
10028 && v46 != 510
10029 && v46 != 500
10030 && v46 != 515
10031 && v46 != 505
10032 && v46 != 530
10033 && v46 != 525
10034 && v46 != 520
10035 && v46 != 535
10036 && v46 != 540 )
10037 goto LABEL_115;
10038 }
10039 if ( !stru_50C198.ActorHitOrMiss(v44, v45) )
10040 return;
10041 if ( (signed __int64)v45->pPlayerBuffs[13].uExpireTime > 0 )
10042 v77 >>= 1;
10043 if ( v45->HasEnchantedItemEquipped(36) )
10044 v77 >>= 1;
10045 if ( v45->HasEnchantedItemEquipped(69) )
10046 v77 >>= 1;
10047 if ( v45->HasItemEquipped(EQUIP_ARMOUR)
10048 && *(_DWORD *)&v45->pInventoryItems[v45->pEquipment.uArmor-1] == 504 )
10049 v77 >>= 1;
10050 v75 = 0;
10051 v47 = (int)&v45->pEquipment;
10052 do
10053 {
10054 if ( v45->HasItemEquipped((ITEM_EQUIP_TYPE)v75) )
10055 {
10056 v48 = *(int *)&v45[36 * *(int *)v47 + 496];
10057 if ( v48 == 520 )
10058 v77 >>= 1;
10059 if ( v48 == 531 )
10060 v77 >>= 1;
10061 if ( v45->GetEquippedItemEquipType((ITEM_EQUIP_TYPE)v75) == EQUIP_SHIELD && SkillToMastery(v45->pActiveSkills[PLAYER_SKILL_SHIELD]) == 4 )
10062 v77 >>= 1;
10063 }
10064 ++v75;
10065 v47 += 4;
10066 }
10067 while ( (signed int)v75 <= 1 );
10068 LABEL_115:
10069 if ( (signed __int64)v44->pActorBuffs[3].uExpireTime > 0 )
10070 {
10071 v49 = v44->pActorBuffs[3].uPower;
10072 if ( v49 )
10073 v77 /= (signed int)v49;
10074 }
10075 if ( !v74 )
10076 {
10077 v50 = v44->pMonsterInfo.uAttack1Type;
10078 goto LABEL_133;
10079 }
10080 if ( v74 == 1 )
10081 {
10082 v50 = v44->pMonsterInfo.uAttack2Type;
10083 goto LABEL_133;
10084 }
10085 if ( v74 == 2 )
10086 {
10087 v53 = v44->pMonsterInfo.uSpell1ID;
10088 }
10089 else
10090 {
10091 if ( v74 != 3 )
10092 {
10093 if ( v74 == 4 )
10094 v50 = v44->pMonsterInfo.field_3C_some_special_attack;
10095 else
10096 v50 = 4;
10097 LABEL_133:
10098 if ( !(dword_6BE368_debug_settings_2 & 0x10) )
10099 {
10100 v54 = v45->ReceiveDamage(v77, (DAMAGE_TYPE)v50);
10101 if ( SHIDWORD(v45->pPlayerBuffs[10].uExpireTime) >= 0 )
10102 {
10103 if ( SHIDWORD(v45->pPlayerBuffs[10].uExpireTime) > 0 || LODWORD(v45->pPlayerBuffs[10].uExpireTime) )
10104 {
10105 v55 = v44->uAIState;
10106 if ( v55 != 5 )
10107 {
10108 if ( v55 != 4 )
10109 {
10110 v56 = stru_50C198.CalcMagicalDamageToActor(v44, v50, v54);
10111 v44->sCurrentHP -= v56;
10112 if ( v56 )
10113 {
10114 if ( v44->sCurrentHP >= 1 )
10115 {
10116 Actor::AI_Stun(uActorID, PID(OBJECT_Player,a4), 0);
10117 Actor::AggroSurroundingPeasants(uActorID, 1);
10118 }
10119 else
10120 {
10121 if ( pMonsterStats->pInfos[v44->pMonsterInfo.uID].bQuestMonster & 1 )
10122 {
10123 v57 = byte_4D864C && BYTE2(pGame->uFlags) & 8 ? 10 * v44->uActorRadius : v44->uActorRadius;
10124 v75 = v57;
10125 if ( pRenderer->pRenderD3D )
10126 {
10127 if ( pGame->uFlags2 & GAME_FLAGS_2_DRAW_BLOODSPLATS )
10128 {
10129 v58 = (double)(signed int)v75;
10130 v75 = v44->vPosition.z;
10131 v59 = (double)(signed int)v75;
10132 v75 = v44->vPosition.y;
10133 v60 = v59;
10134 v61 = (double)(signed int)v75;
10135 v75 = v44->vPosition.x;
10136 v62 = v61;
10137 v63 = (double)(signed int)v75;
10138 pDecalBuilder->AddBloodsplat(v63, v62, v60, 1.0, 0.0, 0.0, v58, 0, 0);
10139 }
10140 }
10141 }
10142 Actor::Die(uActorID);
10143 Actor::ApplyFineForKillingPeasant(uActorID);
10144 Actor::AggroSurroundingPeasants(uActorID, 1);
10145 if ( v44->pMonsterInfo.uExp )
10146 GivePartyExp(pMonsterStats->pInfos[v44->pMonsterInfo.uID].uExp);
10147 v64 = SPEECH_51;
10148 if ( rand() % 100 < 20 )
10149 v64 = ((signed int)v44->pMonsterInfo.uHP >= 100) + 1;
10150 v45->PlaySound((PlayerSpeech)v64, 0);
10151 }
10152 }
10153 }
10154 }
10155 }
10156 }
10157 }
10158 if ( !v74
10159 && !(dword_6BE368_debug_settings_2 & 0x10)
10160 && v44->pMonsterInfo.uSpecialAttack
10161 && rand() % 100 < v44->pMonsterInfo.uLevel * v44->pMonsterInfo.uSpecialAttackType )
10162 v45->_48DCF6(v44->pMonsterInfo.uSpecialAttack, v44);
10163 if ( !pParty->bTurnBasedModeOn )
10164 {
10165 v65 = v45->GetActualEndurance();
10166 v66 = (double)(20 - v45->GetParameterBonus(v65))
10167 * flt_6BE3A4_debug_recmod1
10168 * 2.133333333333333;
10169 v45->SetRecoveryTime((signed __int64)v66);
10170 }
10171 return;
10172 }
10173 v53 = v44->pMonsterInfo.uSpell2ID;
10174 }
10175 v50 = LOBYTE(pSpellStats->pInfos[v53].uSchool);
10176 goto LABEL_133;
10177 }
10178 if ( v42 != 1 )
10179 return;
10180 LABEL_80:
10181 if ( a4 != -1 )
10182 {
10183 v43 = &pParty->pPlayers[a4];
10184 LABEL_168:
10185 a4b = v43;
10186 if ( v38 != OBJECT_Player || v37->spell_id != SPELL_BOW_ARROW)
10187 {
10188 v70 = v43->GetMaxHealth();
10189 v68 = _43AFE3_calc_spell_damage(v37->spell_id, v37->spell_level, v37->spell_skill, v70);
10190 v69 = LOBYTE(pSpellStats->pInfos[v37->spell_id].uSchool);
10191 }
10192 else
10193 {
10194 v68 = pParty->pPlayers[uActorID].CalculateRangedDamageTo(0);
10195 v69 = 0;
10196 }
10197 a4b->ReceiveDamage(v68, (DAMAGE_TYPE)v69);
10198 if ( v38 == OBJECT_Player && !qword_A750D8 )
10199 {
10200 qword_A750D8 = 256i64;
10201 word_A750E0 = 44;
10202 word_A750E2 = uActorID + 1;
10203 }
10204 return;
10205 }
10206 v74 = 0;
10207 a4a = 1;
10208 do
10209 {
10210 if ( pPlayers[a4a]->CanAct() )
10211 {
10212 v67 = v74++;
10213 *(&v72 + v67) = a4a;
10214 }
10215 ++a4a;
10216 }
10217 while ( a4a <= 4 );
10218 if ( v74 )
10219 {
10220 v43 = &pParty->pPlayers[*(&v72+rand()%v74)-1];//&stru_AA1058[3].pSounds[6972 * *(&v72 + rand() % v74) + 40552];
10221 goto LABEL_168;
10222 }
10223 }
10224 //----- (00421EA6) --------------------------------------------------------
10225 void __cdecl OnInventoryLeftClick()
10226 {
10227 Player *v0; // ebx@1
10228 signed int v1; // eax@2
10229 signed int v2; // ecx@2
10230 int v3; // eax@2
10231 char v4; // sf@2
10232 int v5; // eax@2
10233 unsigned int v6; // eax@7
10234 unsigned int v7; // esi@12
10235 unsigned int v8; // eax@12
10236 unsigned int v9; // eax@16
10237 unsigned int v10; // eax@18
10238 ItemGen this_; // [sp+Ch] [bp-3Ch]@1
10239 POINT a2; // [sp+30h] [bp-18h]@4
10240 unsigned int v13; // [sp+38h] [bp-10h]@13
10241 unsigned int pY; // [sp+3Ch] [bp-Ch]@2
10242 unsigned int pX; // [sp+40h] [bp-8h]@2
10243 int a4; // [sp+44h] [bp-4h]@2
10244
10245 v0 = pPlayers[uActiveCharacter];
10246 if ( pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] == 103 )
10247 {
10248 pMouse->GetClickPos(&pX, &pY);
10249 pY = pY - 17;
10250 v2 =pX - 14;
10251 pX = v2;
10252 v3 = 14 * (pY >> 5);
10253 v2 >>= 5;
10254 v4 = v2 + v3 < 0;
10255 v5 = v2 + v3;
10256 a4 = v5;
10257 if ( !v4 )
10258 {
10259 if ( v5 <= 126 && pMouse->GetCursorPos(&a2)->x < 462
10260 && pMouse->GetCursorPos(&a2)->x >= 14 )
10261 {
10262 if ( unk_50C9A0 )
10263 {
10264 v6 = v0->GetItemIDAtInventoryIndex(&a4);
10265 if ( v6 )
10266 {
10267 *((char *)pGUIWindow_Settings->ptr_1C + 8) &= 0x7Fu;
10268 *((short *)pGUIWindow_Settings->ptr_1C + 2) = uActiveCharacter - 1;
10269 *((int *)pGUIWindow_Settings->ptr_1C + 3) = v6 - 1;
10270 *((short *)pGUIWindow_Settings->ptr_1C + 3) = a4;
10271 ptr_50C9A4 = (ItemGen *)&v0->pInventoryItems[v6-1];
10272 unk_50C9A0 = 0;
10273 if ( pMessageQueue_50CBD0->uNumMessages )
10274 pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
10275 pMouse->SetCursorBitmap("MICON1");
10276 dword_50C9D0 = 113;
10277 dword_50C9D4 = 0;
10278 dword_50C9D8 = 256;
10279 }
10280 return;
10281 }
10282 if ( ptr_50C9A4 )
10283 return;
10284 v7 = pParty->pPickedItem.uItemID;
10285 v8 = v0->GetItemIDAtInventoryIndex(&a4);
10286 if ( !v7 )
10287 {
10288 if ( !v8 )
10289 return;
10290 memcpy(&pParty->pPickedItem, &v0->pInventoryItems[v8-1], sizeof(pParty->pPickedItem));
10291 v0->RemoveItemAtInventoryIndex(a4);
10292 v9 = pParty->pPickedItem.uItemID;
10293 pMouse->SetCursorBitmap(pItemsTable->pItems[v9].pIconName);
10294 return;
10295 }
10296 v13 = v8;
10297 if ( v8 )
10298 {
10299 a2.y = (LONG)&v0->pInventoryItems[v8-1];
10300 memcpy(&this_, (const void *)a2.y, sizeof(this_));
10301 v0->RemoveItemAtInventoryIndex(a4);
10302 pX = v0->AddItem2(a4, &pParty->pPickedItem);
10303 if ( !pX )
10304 {
10305 pX = v0->AddItem2(0xFFFFFFFFu, &pParty->pPickedItem);
10306 if ( !pX )
10307 {
10308 v0->PutItemArInventoryIndex(&this_, v13 - 1, a4);
10309 memcpy((void *)a2.y, &this_, sizeof(ItemGen));
10310 return;
10311 }
10312 }
10313 v9 = this_.uItemID;
10314 memcpy(&pParty->pPickedItem, &this_, sizeof(pParty->pPickedItem));
10315 pMouse->SetCursorBitmap(pItemsTable->pItems[v9].pIconName);
10316 return;
10317 }
10318 v10 = v0->AddItem(a4, v7);
10319 pX = v10;
10320 if ( v10 || (v10 = v0->AddItem(-1, pParty->pPickedItem.uItemID), (pX = v10) != 0) )
10321 {
10322 memcpy(&v0->pInventoryItems[v10-1], &pParty->pPickedItem, 0x24u);
10323 pMouse->RemoveHoldingItem();
10324 }
10325 }
10326 }
10327 }
10328 }