Mercurial > mm7
comparison Player.cpp @ 1682:3c451fd02fcf
OnInventoryLeftClick cleanup
author | Grumpy7 |
---|---|
date | Fri, 20 Sep 2013 10:23:54 +0200 |
parents | 406872881eb6 |
children | 96d567a7d15f |
comparison
equal
deleted
inserted
replaced
1681:406872881eb6 | 1682:3c451fd02fcf |
---|---|
7470 void __fastcall DamagePlayerFromMonster(unsigned int uObjID, int element, Vec3_int_ *pPos, unsigned int a4) | 7470 void __fastcall DamagePlayerFromMonster(unsigned int uObjID, int element, Vec3_int_ *pPos, unsigned int a4) |
7471 { | 7471 { |
7472 Player *playerPtr; // ebx@3 | 7472 Player *playerPtr; // ebx@3 |
7473 Actor *actorPtr; // esi@3 | 7473 Actor *actorPtr; // esi@3 |
7474 unsigned int v8; // eax@4 | 7474 unsigned int v8; // eax@4 |
7475 signed int v22; // edi@36 | |
7476 int spellId; // eax@38 | 7475 int spellId; // eax@38 |
7477 signed int recvdMagicDmg; // eax@139 | 7476 signed int recvdMagicDmg; // eax@139 |
7478 int v72[4]; // [sp+30h] [bp-24h]@164 | 7477 int v72[4]; // [sp+30h] [bp-24h]@164 |
7479 int healthBeforeRecvdDamage; // [sp+48h] [bp-Ch]@3 | 7478 int healthBeforeRecvdDamage; // [sp+48h] [bp-Ch]@3 |
7480 unsigned int uActorID; // [sp+4Ch] [bp-8h]@1 | 7479 unsigned int uActorID; // [sp+4Ch] [bp-8h]@1 |
7523 { | 7522 { |
7524 __int16 spellPower = actorPtr->pActorBuffs[3].uPower; | 7523 __int16 spellPower = actorPtr->pActorBuffs[3].uPower; |
7525 if ( spellPower ) | 7524 if ( spellPower ) |
7526 dmgToReceive /= (signed int)spellPower; | 7525 dmgToReceive /= (signed int)spellPower; |
7527 } | 7526 } |
7527 int damageType; | |
7528 switch (element) | 7528 switch (element) |
7529 { | 7529 { |
7530 case 0: v22 = actorPtr->pMonsterInfo.uAttack1Type; | 7530 case 0: damageType = actorPtr->pMonsterInfo.uAttack1Type; |
7531 break; | 7531 break; |
7532 case 1: v22 = actorPtr->pMonsterInfo.uAttack2Type; | 7532 case 1: damageType = actorPtr->pMonsterInfo.uAttack2Type; |
7533 break; | 7533 break; |
7534 case 2: spellId = actorPtr->pMonsterInfo.uSpell1ID; | 7534 case 2: spellId = actorPtr->pMonsterInfo.uSpell1ID; |
7535 v22 = LOBYTE(pSpellStats->pInfos[spellId].uSchool); | 7535 damageType = LOBYTE(pSpellStats->pInfos[spellId].uSchool); |
7536 break; | 7536 break; |
7537 case 3: spellId = actorPtr->pMonsterInfo.uSpell2ID; | 7537 case 3: spellId = actorPtr->pMonsterInfo.uSpell2ID; |
7538 v22 = LOBYTE(pSpellStats->pInfos[spellId].uSchool); | 7538 damageType = LOBYTE(pSpellStats->pInfos[spellId].uSchool); |
7539 break; | 7539 break; |
7540 case 4: v22 = actorPtr->pMonsterInfo.field_3C_some_special_attack; | 7540 case 4: damageType = actorPtr->pMonsterInfo.field_3C_some_special_attack; |
7541 break; | 7541 break; |
7542 default: | 7542 default: |
7543 case 5: v22 = 4; //yes, the original just assigned the value 4 | 7543 case 5: damageType = 4; //yes, the original just assigned the value 4 |
7544 break; | 7544 break; |
7545 } | 7545 } |
7546 if ( !(dword_6BE368_debug_settings_2 & 0x10) ) | 7546 if ( !(dword_6BE368_debug_settings_2 & 0x10) ) |
7547 { | 7547 { |
7548 dmgToReceive = playerPtr->ReceiveDamage(dmgToReceive, (DAMAGE_TYPE)v22); | 7548 dmgToReceive = playerPtr->ReceiveDamage(dmgToReceive, (DAMAGE_TYPE)damageType); |
7549 if ( playerPtr->pPlayerBuffs[10].uExpireTime > 0 ) | 7549 if ( playerPtr->pPlayerBuffs[10].uExpireTime > 0 ) |
7550 { | 7550 { |
7551 int actorState = actorPtr->uAIState; | 7551 int actorState = actorPtr->uAIState; |
7552 if ( actorState != Dying && actorState != Dead) | 7552 if ( actorState != Dying && actorState != Dead) |
7553 { | 7553 { |
7554 int reflectedDamage = stru_50C198.CalcMagicalDamageToActor(actorPtr, v22, dmgToReceive); | 7554 int reflectedDamage = stru_50C198.CalcMagicalDamageToActor(actorPtr, damageType, dmgToReceive); |
7555 actorPtr->sCurrentHP -= reflectedDamage; | 7555 actorPtr->sCurrentHP -= reflectedDamage; |
7556 if ( reflectedDamage >= 0 ) | 7556 if ( reflectedDamage >= 0 ) |
7557 { | 7557 { |
7558 if ( actorPtr->sCurrentHP >= 1 ) | 7558 if ( actorPtr->sCurrentHP >= 1 ) |
7559 { | 7559 { |
7560 Actor::AI_Stun(uActorID, PID(OBJECT_Player,a4), 0); | 7560 Actor::AI_Stun(uActorID, PID(OBJECT_Player,a4), 0); //todo extract this branch to a function once Actor::functions are changed to nonstatic actor functions |
7561 Actor::AggroSurroundingPeasants(uActorID, 1); | 7561 Actor::AggroSurroundingPeasants(uActorID, 1); |
7562 } | 7562 } |
7563 else | 7563 else |
7564 { | 7564 { |
7565 if ( pMonsterStats->pInfos[actorPtr->pMonsterInfo.uID].bQuestMonster & 1 && pRenderer->pRenderD3D && pGame->uFlags2 & GAME_FLAGS_2_DRAW_BLOODSPLATS) | 7565 if ( pMonsterStats->pInfos[actorPtr->pMonsterInfo.uID].bQuestMonster & 1 && pRenderer->pRenderD3D && pGame->uFlags2 & GAME_FLAGS_2_DRAW_BLOODSPLATS) |
7795 } | 7795 } |
7796 //----- (00421EA6) -------------------------------------------------------- | 7796 //----- (00421EA6) -------------------------------------------------------- |
7797 void OnInventoryLeftClick() | 7797 void OnInventoryLeftClick() |
7798 { | 7798 { |
7799 Player *v0; // ebx@1 | 7799 Player *v0; // ebx@1 |
7800 signed int v1; // eax@2 | |
7801 signed int v2; // ecx@2 | 7800 signed int v2; // ecx@2 |
7802 int v3; // eax@2 | 7801 int v3; // eax@2 |
7803 char v4; // sf@2 | 7802 int invMatrixIndex; // eax@2 |
7804 int v5; // eax@2 | |
7805 unsigned int v6; // eax@7 | 7803 unsigned int v6; // eax@7 |
7806 unsigned int v7; // esi@12 | 7804 unsigned int pickedItemId; // esi@12 |
7807 unsigned int v8; // eax@12 | 7805 unsigned int invItemIndex; // eax@12 |
7808 unsigned int v9; // eax@16 | 7806 unsigned int v9; // eax@16 |
7809 unsigned int v10; // eax@18 | 7807 unsigned int v10; // eax@18 |
7810 ItemGen this_; // [sp+Ch] [bp-3Ch]@1 | 7808 ItemGen tmpItem; // [sp+Ch] [bp-3Ch]@1 |
7811 POINT a2; // [sp+30h] [bp-18h]@4 | 7809 POINT a2; // [sp+30h] [bp-18h]@4 |
7812 unsigned int v13; // [sp+38h] [bp-10h]@13 | |
7813 unsigned int pY; // [sp+3Ch] [bp-Ch]@2 | 7810 unsigned int pY; // [sp+3Ch] [bp-Ch]@2 |
7814 unsigned int pX; // [sp+40h] [bp-8h]@2 | 7811 unsigned int pX; // [sp+40h] [bp-8h]@2 |
7815 int a4; // [sp+44h] [bp-4h]@2 | |
7816 | 7812 |
7817 v0 = pPlayers[uActiveCharacter]; | 7813 v0 = pPlayers[uActiveCharacter]; |
7818 if ( pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] == 103 ) | 7814 if ( pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] == 103 ) |
7819 { | 7815 { |
7820 pMouse->GetClickPos(&pX, &pY); | 7816 pMouse->GetClickPos(&pX, &pY); |
7821 pY = pY - 17; | 7817 v3 = Player::INVETORYSLOTSWIDTH * ((pY - 17) / 32); |
7822 v2 =pX - 14; | 7818 v2 = (pX - 14) / 32; |
7823 pX = v2; | 7819 invMatrixIndex = v2 + v3; |
7824 v3 = 14 * (pY >> 5); | 7820 if ( v2 + v3 >= 0 ) |
7825 v2 >>= 5; | 7821 { |
7826 v4 = v2 + v3 < 0; | 7822 if ( invMatrixIndex <= 126 && pMouse->GetCursorPos(&a2)->x < 462 |
7827 v5 = v2 + v3; | |
7828 a4 = v5; | |
7829 if ( !v4 ) | |
7830 { | |
7831 if ( v5 <= 126 && pMouse->GetCursorPos(&a2)->x < 462 | |
7832 && pMouse->GetCursorPos(&a2)->x >= 14 ) | 7823 && pMouse->GetCursorPos(&a2)->x >= 14 ) |
7833 { | 7824 { |
7834 if ( unk_50C9A0 ) | 7825 if ( _50C9A0_IsEnchantingInProgress ) |
7835 { | 7826 { |
7836 v6 = v0->GetItemIDAtInventoryIndex(&a4); | 7827 v6 = v0->GetItemIDAtInventoryIndex(&invMatrixIndex); |
7837 if ( v6 ) | 7828 if ( v6 ) |
7838 { | 7829 { |
7839 *((char *)pGUIWindow_Settings->ptr_1C + 8) &= 0x7Fu; | 7830 *((char *)pGUIWindow_Settings->ptr_1C + 8) &= 0x7Fu; |
7840 *((short *)pGUIWindow_Settings->ptr_1C + 2) = uActiveCharacter - 1; | 7831 *((short *)pGUIWindow_Settings->ptr_1C + 2) = uActiveCharacter - 1; |
7841 *((int *)pGUIWindow_Settings->ptr_1C + 3) = v6 - 1; | 7832 *((int *)pGUIWindow_Settings->ptr_1C + 3) = v6 - 1; |
7842 *((short *)pGUIWindow_Settings->ptr_1C + 3) = a4; | 7833 *((short *)pGUIWindow_Settings->ptr_1C + 3) = invMatrixIndex; |
7843 ptr_50C9A4 = (ItemGen *)&v0->pInventoryItemList[v6-1]; | 7834 ptr_50C9A4_ItemToEnchant = &v0->pInventoryItemList[v6-1]; |
7844 unk_50C9A0 = 0; | 7835 _50C9A0_IsEnchantingInProgress = 0; |
7845 if ( pMessageQueue_50CBD0->uNumMessages ) | 7836 if ( pMessageQueue_50CBD0->uNumMessages ) |
7846 pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; | 7837 pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; |
7847 pMouse->SetCursorBitmap("MICON1"); | 7838 pMouse->SetCursorBitmap("MICON1"); |
7848 dword_50C9D0 = 113; | 7839 _50C9D0_AfterEnchClickEventId = 113; |
7849 dword_50C9D4 = 0; | 7840 _50C9D4_AfterEnchClickEventSecondParam = 0; |
7850 dword_50C9D8 = 256; | 7841 _50C9D8_AfterEnchClickEventTimeout = 256; |
7851 } | 7842 } |
7852 return; | 7843 return; |
7853 } | 7844 } |
7854 if ( ptr_50C9A4 ) | 7845 if ( ptr_50C9A4_ItemToEnchant ) |
7855 return; | 7846 return; |
7856 v7 = pParty->pPickedItem.uItemID; | 7847 pickedItemId = pParty->pPickedItem.uItemID; |
7857 v8 = v0->GetItemIDAtInventoryIndex(&a4); | 7848 invItemIndex = v0->GetItemIDAtInventoryIndex(&invMatrixIndex); |
7858 if ( !v7 ) | 7849 if (!pickedItemId) |
7859 { | 7850 { |
7860 if ( !v8 ) | 7851 if ( !invItemIndex ) |
7861 return; | 7852 return; |
7862 memcpy(&pParty->pPickedItem, &v0->pInventoryItemList[v8-1], sizeof(pParty->pPickedItem)); | 7853 else |
7863 v0->RemoveItemAtInventoryIndex(a4); | 7854 { |
7864 v9 = pParty->pPickedItem.uItemID; | 7855 memcpy(&pParty->pPickedItem, &v0->pInventoryItemList[invItemIndex-1], sizeof(pParty->pPickedItem)); |
7865 pMouse->SetCursorBitmap(pItemsTable->pItems[v9].pIconName); | 7856 v0->RemoveItemAtInventoryIndex(invMatrixIndex); |
7866 return; | 7857 v9 = pParty->pPickedItem.uItemID; |
7858 pMouse->SetCursorBitmap(pItemsTable->pItems[v9].pIconName); | |
7859 return; | |
7860 } | |
7867 } | 7861 } |
7868 v13 = v8; | 7862 else |
7869 if ( v8 ) | |
7870 { | 7863 { |
7871 a2.y = (LONG)&v0->pInventoryItemList[v8-1]; | 7864 if ( invItemIndex ) |
7872 memcpy(&this_, (const void *)a2.y, sizeof(this_)); | |
7873 v0->RemoveItemAtInventoryIndex(a4); | |
7874 pX = v0->AddItem2(a4, &pParty->pPickedItem); | |
7875 if ( !pX ) | |
7876 { | 7865 { |
7877 pX = v0->AddItem2(0xFFFFFFFFu, &pParty->pPickedItem); | 7866 ItemGen* invItemPtr = &v0->pInventoryItemList[invItemIndex-1]; |
7878 if ( !pX ) | 7867 memcpy(&tmpItem, invItemPtr, sizeof(tmpItem)); |
7868 v0->RemoveItemAtInventoryIndex(invMatrixIndex); | |
7869 int emptyIndex = v0->AddItem2(invMatrixIndex, &pParty->pPickedItem); | |
7870 if ( !emptyIndex ) | |
7879 { | 7871 { |
7880 v0->PutItemArInventoryIndex(this_.uItemID, v13 - 1, a4); | 7872 emptyIndex = v0->AddItem2(-1, &pParty->pPickedItem); |
7881 memcpy((void *)a2.y, &this_, sizeof(ItemGen)); | 7873 if ( !emptyIndex ) |
7874 { | |
7875 v0->PutItemArInventoryIndex(tmpItem.uItemID, invItemIndex - 1, invMatrixIndex); | |
7876 memcpy(invItemPtr, &tmpItem, sizeof(ItemGen)); | |
7877 return; | |
7878 } | |
7879 } | |
7880 v9 = tmpItem.uItemID; | |
7881 memcpy(&pParty->pPickedItem, &tmpItem, sizeof(ItemGen)); | |
7882 pMouse->SetCursorBitmap(pItemsTable->pItems[pParty->pPickedItem.uItemID].pIconName); | |
7883 return; | |
7884 } | |
7885 else | |
7886 { | |
7887 v10 = v0->AddItem(invMatrixIndex, pickedItemId); | |
7888 if ( v10 ) | |
7889 { | |
7890 memcpy(&v0->pInventoryItemList[v10-1], &pParty->pPickedItem, sizeof(ItemGen)); | |
7891 pMouse->RemoveHoldingItem(); | |
7892 return; | |
7893 } | |
7894 v10 = v0->AddItem(-1, pickedItemId); | |
7895 if ( v10 ) | |
7896 { | |
7897 memcpy(&v0->pInventoryItemList[v10-1], &pParty->pPickedItem, sizeof(ItemGen)); | |
7898 pMouse->RemoveHoldingItem(); | |
7882 return; | 7899 return; |
7883 } | 7900 } |
7884 } | 7901 } |
7885 v9 = this_.uItemID; | |
7886 memcpy(&pParty->pPickedItem, &this_, sizeof(pParty->pPickedItem)); | |
7887 pMouse->SetCursorBitmap(pItemsTable->pItems[v9].pIconName); | |
7888 return; | |
7889 } | 7902 } |
7890 v10 = v0->AddItem(a4, v7); | |
7891 pX = v10; | |
7892 if ( v10 || (v10 = v0->AddItem(-1, pParty->pPickedItem.uItemID), (pX = v10) != 0) ) | |
7893 { | |
7894 memcpy(&v0->pInventoryItemList[v10-1], &pParty->pPickedItem, 0x24u); | |
7895 pMouse->RemoveHoldingItem(); | |
7896 } | |
7897 } | 7903 } |
7898 } | 7904 } |
7899 } | 7905 } |
7900 } | 7906 } |
7901 | 7907 |