comparison Engine/Objects/Actor.cpp @ 2567:d569340b05ff

Few constants changed into enum values
author a.parshin
date Thu, 21 May 2015 01:50:59 +0200
parents 30eb6dcac768
children 0c67be4ec900
comparison
equal deleted inserted replaced
2566:30eb6dcac768 2567:d569340b05ff
7 #include "Engine/Engine.h" 7 #include "Engine/Engine.h"
8 8
9 #include "../Graphics/PaletteManager.h" 9 #include "../Graphics/PaletteManager.h"
10 #include "../Graphics/DecalBuilder.h" 10 #include "../Graphics/DecalBuilder.h"
11 #include "../Graphics/Sprites.h" 11 #include "../Graphics/Sprites.h"
12 #include "../../stru6.h" 12 #include "Engine/stru6.h"
13 #include "Actor.h" 13 #include "Actor.h"
14 #include "../OurMath.h" 14 #include "../OurMath.h"
15 #include "../Graphics/Outdoor.h" 15 #include "../Graphics/Outdoor.h"
16 #include "Media/Audio/AudioPlayer.h" 16 #include "Media/Audio/AudioPlayer.h"
17 #include "ObjectList.h" 17 #include "ObjectList.h"
142 { 142 {
143 if ( (uActorID >= 0) && (signed int)uActorID <= (signed int)(uNumActors - 1) ) 143 if ( (uActorID >= 0) && (signed int)uActorID <= (signed int)(uNumActors - 1) )
144 { 144 {
145 if ( bGive ) 145 if ( bGive )
146 { 146 {
147 if ( pActors[uActorID].uCarriedItemID == 0) 147 if (pActors[uActorID].uCarriedItemID == ITEM_NULL)
148 pActors[uActorID].uCarriedItemID = uItemID; 148 pActors[uActorID].uCarriedItemID = uItemID;
149 else if ( pActors[uActorID].ActorHasItems[0].uItemID == 0) 149 else if (pActors[uActorID].ActorHasItems[0].uItemID == ITEM_NULL)
150 pActors[uActorID].ActorHasItems[0].uItemID = uItemID; 150 pActors[uActorID].ActorHasItems[0].uItemID = uItemID;
151 else if ( pActors[uActorID].ActorHasItems[1].uItemID == 0) 151 else if (pActors[uActorID].ActorHasItems[1].uItemID == ITEM_NULL)
152 pActors[uActorID].ActorHasItems[1].uItemID = uItemID; 152 pActors[uActorID].ActorHasItems[1].uItemID = uItemID;
153 } 153 }
154 else 154 else
155 { 155 {
156 if ( pActors[uActorID].uCarriedItemID == uItemID ) 156 if ( pActors[uActorID].uCarriedItemID == uItemID )
157 pActors[uActorID].uCarriedItemID = 0; 157 pActors[uActorID].uCarriedItemID = ITEM_NULL;
158 else if ( pActors[uActorID].ActorHasItems[0].uItemID == uItemID ) 158 else if ( pActors[uActorID].ActorHasItems[0].uItemID == uItemID )
159 pActors[uActorID].ActorHasItems[0].Reset(); 159 pActors[uActorID].ActorHasItems[0].Reset();
160 else if ( pActors[uActorID].ActorHasItems[1].uItemID == uItemID ) 160 else if ( pActors[uActorID].ActorHasItems[1].uItemID == uItemID )
161 pActors[uActorID].ActorHasItems[1].Reset(); 161 pActors[uActorID].ActorHasItems[1].Reset();
162 } 162 }
185 } 185 }
186 186
187 //----- (004086E9) -------------------------------------------------------- 187 //----- (004086E9) --------------------------------------------------------
188 void Actor::SetRandomGoldIfTheresNoItem() 188 void Actor::SetRandomGoldIfTheresNoItem()
189 { 189 {
190 int v2; // edi@1 190 int v2; // edi@1
191 191
192 v2 = 0; 192 v2 = 0;
193 if ( !this->ActorHasItems[3].uItemID ) 193 if (!this->ActorHasItems[3].uItemID)
194 { 194 {
195 if ( this->pMonsterInfo.uTreasureDiceRolls ) 195 if (this->pMonsterInfo.uTreasureDiceRolls)
196 { 196 {
197 for (int i = 0; i < this->pMonsterInfo.uTreasureDiceRolls; i++) 197 for (int i = 0; i < this->pMonsterInfo.uTreasureDiceRolls; i++)
198 v2 += rand() % this->pMonsterInfo.uTreasureDiceSides + 1; 198 v2 += rand() % this->pMonsterInfo.uTreasureDiceSides + 1;
199 if ( v2 ) 199 if (v2)
200 { 200 {
201 this->ActorHasItems[3].uItemID = 197; 201 this->ActorHasItems[3].uItemID = ITEM_GOLD_SMALL;
202 this->ActorHasItems[3].uSpecEnchantmentType = v2; //actual gold amount 202 this->ActorHasItems[3].special_enchantment = (ITEM_ENCHANTMENT)v2; //actual gold amount
203 } 203 }
204 } 204 }
205 } 205 }
206 if ( rand() % 100 < this->pMonsterInfo.uTreasureDropChance ) 206 if (rand() % 100 < this->pMonsterInfo.uTreasureDropChance)
207 { 207 {
208 if ( this->pMonsterInfo.uTreasureLevel ) 208 if (this->pMonsterInfo.uTreasureLevel)
209 pItemsTable->GenerateItem(this->pMonsterInfo.uTreasureLevel, this->pMonsterInfo.uTreasureType, &this->ActorHasItems[2]); 209 pItemsTable->GenerateItem(this->pMonsterInfo.uTreasureLevel, this->pMonsterInfo.uTreasureType, &this->ActorHasItems[2]);
210 } 210 }
211 this->uAttributes |= ACTOR_HAS_ITEM; 211 this->uAttributes |= ACTOR_HAS_ITEM;
212 } 212 }
213 213
214 //----- (00404AC7) -------------------------------------------------------- 214 //----- (00404AC7) --------------------------------------------------------
215 void Actor::AI_SpellAttack(unsigned int uActorID, AIDirection *pDir, int uSpellID, int a4, unsigned int uSkillLevel) 215 void Actor::AI_SpellAttack(unsigned int uActorID, AIDirection *pDir, int uSpellID, int a4, unsigned int uSkillLevel)
216 { 216 {
1966 case MONSTER_HARPY_1: case MONSTER_HARPY_2: case MONSTER_HARPY_3: 1966 case MONSTER_HARPY_1: case MONSTER_HARPY_2: case MONSTER_HARPY_3:
1967 drop.uItemID = ITEM_HARPY_FEATHER; 1967 drop.uItemID = ITEM_HARPY_FEATHER;
1968 break; 1968 break;
1969 1969
1970 case MONSTER_OOZE_1: case MONSTER_OOZE_2: case MONSTER_OOZE_3: 1970 case MONSTER_OOZE_1: case MONSTER_OOZE_2: case MONSTER_OOZE_3:
1971 drop.uItemID = ITEM_OOZE_ECTOPLASM_BOTTLE; 1971 drop.uItemID = ITEM_OOZE_ENDOPLASM_VIAL;
1972 break; 1972 break;
1973 1973
1974 case MONSTER_TROLL_1: case MONSTER_TROLL_2: case MONSTER_TROLL_3: 1974 case MONSTER_TROLL_1: case MONSTER_TROLL_2: case MONSTER_TROLL_3:
1975 drop.uItemID = ITEM_TROLL_BLOOD; 1975 drop.uItemID = ITEM_TROLL_BLOOD;
1976 break; 1976 break;
3608 attackElement = DMGT_PHISYCAL; 3608 attackElement = DMGT_PHISYCAL;
3609 uDamageAmount = player->CalculateRangedDamageTo(pMonster->word_000086_some_monster_id); 3609 uDamageAmount = player->CalculateRangedDamageTo(pMonster->word_000086_some_monster_id);
3610 if ( pMonster->pActorBuffs[ACTOR_BUFF_SHIELD].uExpireTime > 0 ) 3610 if ( pMonster->pActorBuffs[ACTOR_BUFF_SHIELD].uExpireTime > 0 )
3611 uDamageAmount /= 2; 3611 uDamageAmount /= 2;
3612 IsAdditionalDamagePossible = true; 3612 IsAdditionalDamagePossible = true;
3613 if (projectileSprite->containing_item.uItemID != 0 && projectileSprite->containing_item.uSpecEnchantmentType == 3) //of carnage 3613 if (projectileSprite->containing_item.uItemID != 0 && projectileSprite->containing_item.special_enchantment == 3) //of carnage
3614 { 3614 {
3615 attackElement = DMGT_FIRE; 3615 attackElement = DMGT_FIRE;
3616 } 3616 }
3617 else if ( !player->PlayerHitOrMiss( pMonster, v61, a4) ) 3617 else if ( !player->PlayerHitOrMiss( pMonster, v61, a4) )
3618 { 3618 {
3641 uDamageAmount = v61; 3641 uDamageAmount = v61;
3642 if ( IsAdditionalDamagePossible ) 3642 if ( IsAdditionalDamagePossible )
3643 { 3643 {
3644 if ( projectileSprite ) 3644 if ( projectileSprite )
3645 { 3645 {
3646 a4 = projectileSprite->containing_item._439DF3_get_additional_damage((int*)&attackElement, &isLifeStealing); 3646 a4 = projectileSprite->containing_item._439DF3_get_additional_damage(&attackElement, &isLifeStealing);
3647 if ( isLifeStealing && pMonster->sCurrentHP > 0 ) 3647 if ( isLifeStealing && pMonster->sCurrentHP > 0 )
3648 { 3648 {
3649 player->sHealth += v61 / 5; 3649 player->sHealth += v61 / 5;
3650 if ( player->sHealth > player->GetMaxHealth() ) 3650 if ( player->sHealth > player->GetMaxHealth() )
3651 player->sHealth = player->GetMaxHealth(); 3651 player->sHealth = player->GetMaxHealth();
3661 ItemGen* item; 3661 ItemGen* item;
3662 if (i == 0) 3662 if (i == 0)
3663 item = player->GetOffHandItem(); 3663 item = player->GetOffHandItem();
3664 else 3664 else
3665 item = player->GetMainHandItem(); 3665 item = player->GetMainHandItem();
3666 a4 = item->_439DF3_get_additional_damage((int*)&attackElement, &isLifeStealing); 3666 a4 = item->_439DF3_get_additional_damage(&attackElement, &isLifeStealing);
3667 if ( isLifeStealing && pMonster->sCurrentHP > 0 ) 3667 if ( isLifeStealing && pMonster->sCurrentHP > 0 )
3668 { 3668 {
3669 player->sHealth += v61 / 5; 3669 player->sHealth += v61 / 5;
3670 if ( player->sHealth > player->GetMaxHealth() ) 3670 if ( player->sHealth > player->GetMaxHealth() )
3671 player->sHealth = player->GetMaxHealth(); 3671 player->sHealth = player->GetMaxHealth();
3723 } 3723 }
3724 if ( pMonster->pActorBuffs[ACTOR_BUFF_PAIN_REFLECTION].uExpireTime > 0 3724 if ( pMonster->pActorBuffs[ACTOR_BUFF_PAIN_REFLECTION].uExpireTime > 0
3725 && uDamageAmount != 0 ) 3725 && uDamageAmount != 0 )
3726 player->ReceiveDamage(uDamageAmount, attackElement); 3726 player->ReceiveDamage(uDamageAmount, attackElement);
3727 int knockbackValue = 20 * v61 / (signed int)pMonster->pMonsterInfo.uHP; 3727 int knockbackValue = 20 * v61 / (signed int)pMonster->pMonsterInfo.uHP;
3728 if ( (player->GetSpecialItemBonus(24) || hit_will_stun) && pMonster->DoesDmgTypeDoDamage(DMGT_EARTH) ) 3728 if ((player->GetSpecialItemBonus(ITEM_ENCHANTMENT_OF_FORCE) || hit_will_stun) && pMonster->DoesDmgTypeDoDamage(DMGT_EARTH))
3729 { 3729 {
3730 extraRecoveryTime = 20; 3730 extraRecoveryTime = 20;
3731 knockbackValue = 10; 3731 knockbackValue = 10;
3732 if ( !pParty->bTurnBasedModeOn ) 3732 if ( !pParty->bTurnBasedModeOn )
3733 extraRecoveryTime = (int)(flt_6BE3A8_debug_recmod2 * 42.66666666666666); 3733 extraRecoveryTime = (int)(flt_6BE3A8_debug_recmod2 * 42.66666666666666);
3763 pMonster->vVelocity.y = 50 * LOWORD(pVelocity->y); 3763 pMonster->vVelocity.y = 50 * LOWORD(pVelocity->y);
3764 pMonster->vVelocity.z = 50 * LOWORD(pVelocity->z); 3764 pMonster->vVelocity.z = 50 * LOWORD(pVelocity->z);
3765 } 3765 }
3766 Actor::AddBloodsplatOnDamageOverlay(uActorID_Monster, 1, v61); 3766 Actor::AddBloodsplatOnDamageOverlay(uActorID_Monster, 1, v61);
3767 } 3767 }
3768
3769
3770
3768 //----- (004BBF61) -------------------------------------------------------- 3771 //----- (004BBF61) --------------------------------------------------------
3769 void Actor::Arena_summon_actor( int monster_id, __int16 x, int y, int z ) 3772 void Actor::Arena_summon_actor( int monster_id, __int16 x, int y, int z )
3770 { 3773 {
3771 int v12; // ebx@7 3774 int v12; // ebx@7
3772 int v13; // eax@8 3775 int v13; // eax@8
4149 } 4152 }
4150 else 4153 else
4151 { 4154 {
4152 if ( this->ActorHasItems[3].uItemID != 0 && this->ActorHasItems[3].GetItemEquipType() == EQUIP_GOLD ) 4155 if ( this->ActorHasItems[3].uItemID != 0 && this->ActorHasItems[3].GetItemEquipType() == EQUIP_GOLD )
4153 { 4156 {
4154 v14 = this->ActorHasItems[3].uSpecEnchantmentType; 4157 v14 = this->ActorHasItems[3].special_enchantment;
4155 this->ActorHasItems[3].Reset(); 4158 this->ActorHasItems[3].Reset();
4156 if ( v14 ) 4159 if ( v14 )
4157 { 4160 {
4158 pParty->PartyFindsGold(v14, 0); 4161 pParty->PartyFindsGold(v14, 0);
4159 viewparams->bRedrawGameUI = 1; 4162 viewparams->bRedrawGameUI = 1;