Mercurial > mm7
changeset 1850:521ffedabe19
sub_448518_npc_set_item using body of cleaned up Actor::GiveItem
author | Grumpy7 |
---|---|
date | Sun, 13 Oct 2013 10:45:48 +0200 |
parents | 794f6ac640f4 |
children | 80e897fc2438 |
files | Actor.cpp |
diffstat | 1 files changed, 23 insertions(+), 71 deletions(-) [+] |
line wrap: on
line diff
--- a/Actor.cpp Sun Oct 13 08:03:14 2013 +0200 +++ b/Actor.cpp Sun Oct 13 10:45:48 2013 +0200 @@ -114,25 +114,7 @@ { if (pActors[uNumActors].sNPC_ID == npc) { - Actor* currActor = &pActors[i]; - if ( a3 ) - { - if ( currActor->uCarriedItemID == 0) - currActor->uCarriedItemID = item; - else if ( currActor->array_000234[0].uItemID == 0) - currActor->array_000234[0].uItemID = item; - else if ( currActor->array_000234[1].uItemID == 0) - currActor->array_000234[1].uItemID = item; - } - else - { - if ( currActor->uCarriedItemID == item ) - currActor->uCarriedItemID = 0; - else if ( currActor->array_000234[0].uItemID == item ) - currActor->array_000234[0].Reset(); - else if ( currActor->array_000234[1].uItemID == item ) - currActor->array_000234[1].Reset(); - } + Actor::GiveItem(i, item, a3); } } } @@ -140,48 +122,26 @@ //----- (004485A7) -------------------------------------------------------- void Actor::GiveItem(signed int uActorID, unsigned int uItemID, unsigned int bGive) { - unsigned int v3; // eax@3 - char *v4; // ecx@3 - int *v5; // eax@8 - ItemGen *v6; // ecx@12 - if ( (uActorID >= 0) && (signed int)uActorID <= (signed int)(uNumActors - 1) ) { - v3 = uActorID; - v4 = (char *)&pActors[uActorID].uCarriedItemID; + Actor* currActor = &pActors[uActorID]; if ( bGive ) { - if ( *(short *)v4 ) - { - if ( pActors[v3].array_000234[0].uItemID ) - { - v5 = &pActors[v3].array_000234[1].uItemID; - if ( !*v5 ) - *v5 = uItemID; - } - else - { - pActors[v3].array_000234[0].uItemID = uItemID; - } - } - else - { - *(short *)v4 = uItemID; - } + if ( currActor->uCarriedItemID == 0) + currActor->uCarriedItemID = uItemID; + else if ( currActor->array_000234[0].uItemID == 0) + currActor->array_000234[0].uItemID = uItemID; + else if ( currActor->array_000234[1].uItemID == 0) + currActor->array_000234[1].uItemID = uItemID; } else { - if ( *(short *)v4 == uItemID ) - { - *(short *)v4 = 0; - } - else - { - v6 = pActors[v3].array_000234; - if ( pActors[v3].array_000234[0].uItemID == uItemID - || (v6 = &pActors[v3].array_000234[1], pActors[v3].array_000234[1].uItemID == uItemID) ) - v6->Reset(); - } + if ( currActor->uCarriedItemID == uItemID ) + currActor->uCarriedItemID = 0; + else if ( currActor->array_000234[0].uItemID == uItemID ) + currActor->array_000234[0].Reset(); + else if ( currActor->array_000234[1].uItemID == uItemID ) + currActor->array_000234[1].Reset(); } } } @@ -191,7 +151,7 @@ { bool isparalyzed; // esi@1 bool isstoned; // edi@2 - unsigned __int16 v3; // ax@6 + AIState v3; // ax@6 isstoned = (signed __int64)this->pActorBuffs[5].uExpireTime > 0;// stoned isparalyzed = (signed __int64)this->pActorBuffs[6].uExpireTime > 0;// paralyzed @@ -203,48 +163,40 @@ bool Actor::IsNotAlive() { bool isstoned; // esi@1 - //unsigned __int16 v2; // ax@3 isstoned = (signed __int64)this->pActorBuffs[5].uExpireTime > 0;// stoned - //v2 = this->uAIState; return (isstoned || (uAIState == Dying) || (uAIState == Dead) || (uAIState == Removed) || (uAIState == Summoned) || (uAIState == Disabled)); } //----- (004086E9) -------------------------------------------------------- void Actor::SetRandomGoldIfTheresNoItem() { - Actor *v1; // esi@1 int v2; // edi@1 - signed int v3; // ebx@2 unsigned __int8 v4; // al@7 - v1 = this; v2 = 0; if ( !this->array_000234[3].uItemID ) { - v3 = 0; if ( this->pMonsterInfo.uTreasureDiceRolls ) { - do + for (int i = 0; i < this->pMonsterInfo.uTreasureDiceRolls; i++) { - ++v3; - v2 += rand() % v1->pMonsterInfo.uTreasureDiceSides + 1; + v2 += rand() % this->pMonsterInfo.uTreasureDiceSides + 1; } - while ( v3 < v1->pMonsterInfo.uTreasureDiceRolls ); if ( v2 ) { - v1->array_000234[3].uItemID = 197; - v1->array_000234[3].uSpecEnchantmentType = v2; + this->array_000234[3].uItemID = 197; + this->array_000234[3].uSpecEnchantmentType = v2; //actual gold amount } } } - if ( rand() % 100 < v1->pMonsterInfo.uTreasureDropChance ) + if ( rand() % 100 < this->pMonsterInfo.uTreasureDropChance ) { - v4 = v1->pMonsterInfo.uTreasureLevel; + v4 = this->pMonsterInfo.uTreasureLevel; if ( v4 ) - pItemsTable->GenerateItem(v4, v1->pMonsterInfo.uTreasureType, &v1->array_000234[2]); + pItemsTable->GenerateItem(v4, this->pMonsterInfo.uTreasureType, &this->array_000234[2]); } - v1->uAttributes |= 0x800000; + this->uAttributes |= 0x800000; } //----- (00404AC7) --------------------------------------------------------