Mercurial > mm7
diff Actor.cpp @ 1859:f135ff4decbb
Actor::AI_SpellAttack finishing cleanup
author | Grumpy7 |
---|---|
date | Mon, 14 Oct 2013 03:17:25 +0200 |
parents | d7c028a6a084 |
children | 3186f469323a |
line wrap: on
line diff
--- a/Actor.cpp Mon Oct 14 02:12:01 2013 +0200 +++ b/Actor.cpp Mon Oct 14 03:17:25 2013 +0200 @@ -202,7 +202,7 @@ //----- (00404AC7) -------------------------------------------------------- void __fastcall Actor::AI_SpellAttack(unsigned int uActorID, AIDirection *pDir, int uSpellID, int a4, unsigned int uSkillLevel) { - Actor *v5; // esi@1 + Actor *actorPtr; // esi@1 unsigned int realPoints; // edi@1 unsigned int masteryLevel; // eax@1 int v8; // edi@16 @@ -237,8 +237,6 @@ int v94; // ecx@208 int v96; // ecx@217 int pitch; // [sp+2Ch] [bp-A4h]@51 - int v111; // [sp+38h] [bp-98h]@41 - int v113; // [sp+40h] [bp-90h]@41 int v114; // [sp+48h] [bp-88h]@41 SpriteObject a1; // [sp+4Ch] [bp-84h]@1 int v116; // [sp+BCh] [bp-14h]@49 @@ -253,44 +251,35 @@ int a1c; // [sp+E0h] [bp+10h]@184 - LODWORD(v120) = uActorID; - v5 = &pActors[uActorID]; + actorPtr = &pActors[uActorID]; realPoints = uSkillLevel & 0x3F; masteryLevel = SkillToMastery(uSkillLevel); - + switch (uSpellID) { - case 2: - case 6: - case 11: - case 18: - case 26: - case 29: - case 39: - case 41: - case 57: - case 65: - case 70: - case 78: - case 90: - case 97: + case SPELL_FIRE_FIRE_BOLT: + case SPELL_FIRE_FIREBALL: + case SPELL_FIRE_INCINERATE: + case SPELL_AIR_LIGHNING_BOLT: + case SPELL_WATER_ICE_BOLT: + case SPELL_WATER_ACID_BURST: + case SPELL_EARTH_BLADES: + case SPELL_EARTH_ROCK_BLAST: + case SPELL_MIND_MIND_BLAST: + case SPELL_MIND_PSYCHIC_SHOCK: + case SPELL_BODY_HARM: + case SPELL_LIGHT_LIGHT_BOLT: + case SPELL_DARK_TOXIC_CLOUD: + case SPELL_DARK_DRAGON_BREATH: a1.uType = stru_4E3ACC[uSpellID].uType; - a1.uObjectDescID = 0; - for (int i = 0; i < pObjectList->uNumObjects; i++) - { - if (a1.uType == pObjectList->pObjects[i].uObjectID) - { - a1.uObjectDescID = i; - break; - } - } + a1.uObjectDescID = GetObjDescId(uSpellID); a1.stru_24.Reset(); a1.spell_id = uSpellID; a1.spell_level = uSkillLevel; - a1.vPosition.x = v5->vPosition.x; + a1.vPosition.x = actorPtr->vPosition.x; a1.spell_skill = 0; - a1.vPosition.y = v5->vPosition.y; - a1.vPosition.z = v5->vPosition.z + ((signed int)v5->uActorHeight >> 1); + a1.vPosition.y = actorPtr->vPosition.y; + a1.vPosition.z = actorPtr->vPosition.z + ((signed int)actorPtr->uActorHeight >> 1); a1.uFacing = LOWORD(pDir->uYawAngle); a1.uSoundID = 0; a1.uAttributes = 0; @@ -322,7 +311,7 @@ return; break; - case 5: + case SPELL_FIRE_HASTE: if (masteryLevel == 1 || masteryLevel == 2) v39 = 60 * (realPoints + 60); else if (masteryLevel == 3 ) @@ -331,23 +320,20 @@ v39 = 240 * (realPoints + 15); else v39 = 0; - v5->pActorBuffs[19].Apply( + actorPtr->pActorBuffs[19].Apply( pParty->uTimePlayed + (signed int)(signed __int64)((double)(v39 << 7) * 0.033333335), masteryLevel, 0, 0, 0); - pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(v5, 0xFF3C1Eu); + pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(actorPtr, 0xFF3C1Eu); pAudioPlayer->PlaySound((SoundID)10040, PID(OBJECT_Actor, uActorID), 0, -1, 0, 0, 0, 0); return; - case 9: + case SPELL_FIRE_METEOR_SHOWER: if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) return; - v118 = pParty->vPosition.z; - v111 = pParty->vPosition.x; v114 = pParty->vPosition.z + 2500; - v113 = pParty->vPosition.y; v23 = 8; if (masteryLevel == 2) v23 = 10; @@ -360,7 +346,7 @@ { v28 = (double)spellnumb; v30 = rand() % 1000; - spellnumc = v30 + pParty->vPosition.z - v114; + spellnumc = v30 - 2500; v120 = v28 * v28; v119 = spellnumb * spellnumb; if ( sqrt(spellnumc * spellnumc + v119 + v120) <= 1.0 ) @@ -375,16 +361,8 @@ pitch = stru_5C6E00->Atan2(v31, (int)spellnumc); } a1.stru_24.Reset(); - a1.uType = stru_4E3ACC[9].uType; - a1.uObjectDescID = 0; - for (int i = 0; i < pObjectList->uNumObjects; i++) - { - if (pObjectList->pObjects[i].uObjectID == a1.uType) - { - a1.uObjectDescID = i; - break; - } - } + a1.uType = stru_4E3ACC[uSpellID].uType; + a1.uObjectDescID = GetObjDescId(uSpellID); a1.spell_level = uSkillLevel; a1.vPosition.x = pParty->vPosition.x; a1.vPosition.y = pParty->vPosition.y; @@ -422,7 +400,8 @@ return; break; - case 15:if (masteryLevel == 2 ) + case SPELL_AIR_SPARKS: + if (masteryLevel == 2 ) v10 = 5; else if (masteryLevel == 3 ) v10 = 7; @@ -431,29 +410,22 @@ else v10 = 3; spellnuma = (signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360; - a1.uType = stru_4E3ACC[15].uType; + a1.uType = stru_4E3ACC[uSpellID].uType; v118 = (signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360 / (v10 - 1); - a1.uObjectDescID = 0; - for (unsigned int i = 0; i < pObjectList->uNumObjects; i++) - { - if (stru_4E3ACC[15].uType == pObjectList->pObjects[i].uObjectID) - { - a1.uObjectDescID = i; - break; - } - } + a1.uObjectDescID = GetObjDescId(uSpellID); + a1.stru_24.Reset(); a1.spell_id = SPELL_AIR_SPARKS; a1.spell_level = uSkillLevel; - a1.vPosition.x = v5->vPosition.x; + a1.vPosition.x = actorPtr->vPosition.x; a1.spell_skill = 0; - a1.vPosition.y = v5->vPosition.y; - a1.vPosition.z = v5->vPosition.z + ((signed int)v5->uActorHeight >> 1); + a1.vPosition.y = actorPtr->vPosition.y; + a1.vPosition.z = actorPtr->vPosition.z + ((signed int)actorPtr->uActorHeight >> 1); a1.uFacing = pDir->uYawAngle; a1.uSoundID = 0; a1.uAttributes = 0; a1.uSectorID = pIndoor->GetSector(a1.vPosition.x, a1.vPosition.y, a1.vPosition.z); - a1.spell_caster_pid = PID(OBJECT_Actor, LODWORD(v120)); + a1.spell_caster_pid = PID(OBJECT_Actor, uActorID); a1.uSpriteFrameID = 0; a1.spell_target_pid = 0; a1.field_60_distance_related_prolly_lod = 3; @@ -485,7 +457,7 @@ return; break; - case 17: + case SPELL_AIR_SHIELD: if (masteryLevel == 1 || masteryLevel == 2) v8 = 300 * realPoints + 3840; else if (masteryLevel == 3 ) @@ -494,7 +466,7 @@ v8 = 3600 * (realPoints + 64); else v8 = 0; - v5->pActorBuffs[15].Apply( + actorPtr->pActorBuffs[15].Apply( pParty->uTimePlayed + (signed int)(signed __int64)((double)(v8 << 7) * 0.033333335), masteryLevel, 0, @@ -502,7 +474,7 @@ 0); return; - case 38: + case SPELL_EARTH_STONESKIN: if (masteryLevel == 1 || masteryLevel == 2) v44 = 300 * realPoints + 3840; else if (masteryLevel == 3 ) @@ -511,17 +483,17 @@ v44 = 3600 * (realPoints + 64); else v44 = 0; - v5->pActorBuffs[16].Apply( + actorPtr->pActorBuffs[16].Apply( pParty->uTimePlayed + (signed int)(signed __int64)((double)(v44 << 7) * 0.033333335), masteryLevel, realPoints + 5, 0, 0); - pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(v5,0x5C310Eu); + pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(actorPtr,0x5C310Eu); pAudioPlayer->PlaySound((SoundID)13040, PID(OBJECT_Actor,uActorID), 0, -1, 0, 0, 0, 0); return; - case 46: + case SPELL_SPIRIT_BLESS: if (masteryLevel == 1 || masteryLevel == 2) v42 = 300 * realPoints + 3840; else if (masteryLevel == 3 ) @@ -530,18 +502,18 @@ v42 = 1200 * realPoints + 3840; else v42 = 0; - v5->pActorBuffs[17].Apply( + actorPtr->pActorBuffs[17].Apply( pParty->uTimePlayed + (signed int)(signed __int64)((double)(v42 << 7) * 0.033333335), masteryLevel, realPoints + 5, 0, 0); - pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(v5,0xC8C805u); + pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(actorPtr,0xC8C805u); pAudioPlayer->PlaySound((SoundID)14010, PID(OBJECT_Actor,uActorID), 0, -1, 0, 0, 0, 0); return; break; - case 47: + case SPELL_SPIRIT_FATE: if (masteryLevel == 1 || masteryLevel == 2) v48 = 2 * realPoints + 40; else if (masteryLevel == 3 ) @@ -550,12 +522,12 @@ v48 = 2 * (3 * realPoints + 60); else v48 = 0; - v5->pActorBuffs[11].Apply(pParty->uTimePlayed + 1280, masteryLevel, v48, 0, 0); - pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(v5,0xC8C805u); + actorPtr->pActorBuffs[11].Apply(pParty->uTimePlayed + 1280, masteryLevel, v48, 0, 0); + pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(actorPtr,0xC8C805u); pAudioPlayer->PlaySound((SoundID)14020, PID(OBJECT_Actor, uActorID), 0, -1, 0, 0, 0, 0); return; - case 51: + case SPELL_SPIRIT_HEROISM: if (masteryLevel == 1 || masteryLevel == 2) v54 = 300 * realPoints + 3840; else if (masteryLevel == 3 ) @@ -564,40 +536,40 @@ v54 = 1200 * realPoints + 3840; else v54 = 0; - v5->pActorBuffs[18].Apply( + actorPtr->pActorBuffs[18].Apply( pParty->uTimePlayed + (signed int)(signed __int64)((double)(v54 << 7) * 0.033333335), masteryLevel, realPoints + 5, 0, 0); - pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(v5,0xC8C805u); + pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(actorPtr,0xC8C805u); pAudioPlayer->PlaySound((SoundID)14060, PID(OBJECT_Actor,uActorID), 0, -1, 0, 0, 0, 0); return; - case 73: + case SPELL_BODY_HAMMERHANDS: if ( (signed int)masteryLevel <= 0 || (signed int)masteryLevel > 4 ) v51 = 0; else v51 = 3600 * realPoints; - v5->pActorBuffs[21].Apply( + actorPtr->pActorBuffs[21].Apply( pParty->uTimePlayed + (signed int)(signed __int64)((double)(v51 << 7) * 0.033333335), masteryLevel, realPoints, 0, 0); - pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(v5, 0xA81376u); + pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(actorPtr, 0xA81376u); pAudioPlayer->PlaySound((SoundID)16060, PID(OBJECT_Actor, uActorID), 0, -1, 0, 0, 0, 0); return; - case 77: - v5->sCurrentHP += 5 * realPoints + 10; - if ( v5->sCurrentHP >= (signed int)v5->pMonsterInfo.uHP ) - v5->sCurrentHP = LOWORD(v5->pMonsterInfo.uHP); - pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(v5, 0xA81376u); + case SPELL_BODY_POWER_CURE: + actorPtr->sCurrentHP += 5 * realPoints + 10; + if ( actorPtr->sCurrentHP >= (signed int)actorPtr->pMonsterInfo.uHP ) + actorPtr->sCurrentHP = LOWORD(actorPtr->pMonsterInfo.uHP); + pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(actorPtr, 0xA81376u); pAudioPlayer->PlaySound((SoundID)14020, PID(OBJECT_Actor, uActorID), 0, -1, 0, 0, 0, 0); return; - case 80: + case SPELL_LIGHT_DISPEL_MAGIC: for (int i = 0; i < 20; i++ ) { pParty->pPartyBuffs[i].Reset(); @@ -623,7 +595,7 @@ pAudioPlayer->PlaySound((SoundID)word_4EE088_sound_ids[80], PID(OBJECT_Actor, uActorID), 0, -1, 0, 0, 0, 0); return; - case 85: + case SPELL_LIGHT_DAY_OF_PROTECTION: if (masteryLevel == 1 || masteryLevel == 2) { v96 = 300 * realPoints + 3840; @@ -643,17 +615,17 @@ LOWORD(realPoints) = uSkillLevel; v96 = 0; } - v5->pActorBuffs[13].Apply( + actorPtr->pActorBuffs[13].Apply( pParty->uTimePlayed + (signed int)(signed __int64)((double)(v96 << 7) * 0.033333335), masteryLevel, realPoints, 0, 0); - pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(v5, 0xFFFFFFu); + pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(actorPtr, 0xFFFFFFu); pAudioPlayer->PlaySound((SoundID)17070, PID(OBJECT_Actor, uActorID), 0, -1, 0, 0, 0, 0); return; - case 86: + case SPELL_LIGHT_HOUR_OF_POWER: if (masteryLevel == 1 || masteryLevel == 2) v94 = 300 * realPoints + 3840; else if (masteryLevel == 3) @@ -662,17 +634,17 @@ v94 = 1200 * realPoints + 3840; else v94 = 0; - v5->pActorBuffs[14].Apply( + actorPtr->pActorBuffs[14].Apply( pParty->uTimePlayed + (signed int)(signed __int64)((double)(v94 << 7) * 0.033333335), masteryLevel, realPoints + 5, 0, 0); - pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(v5, 0xFFFFFFu); + pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(actorPtr, 0xFFFFFFu); pAudioPlayer->PlaySound((SoundID)17080, PID(OBJECT_Actor, uActorID), 0, -1, 0, 0, 0, 0); return; - case 93: + case SPELL_DARK_SHARPMETAL: if (masteryLevel == 2) v70 = 5; else if (masteryLevel == 3) @@ -683,24 +655,16 @@ v70 = 3; spellnume = (signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360; - a1.uType = stru_4E3ACC[SPELL_DARK_SHARPMETAL].uType; + a1.uType = stru_4E3ACC[uSpellID].uType; v116 = (signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360 / (v70 - 1); - a1.uObjectDescID = 0; - for (int i = 0; i < pObjectList->uNumObjects; i++) - { - if (pObjectList->pObjects[i].uObjectID == stru_4E3ACC[SPELL_DARK_SHARPMETAL].uType) - { - a1.uObjectDescID = i; - break; - } - } + a1.uObjectDescID = GetObjDescId(uSpellID); a1.stru_24.Reset(); - a1.spell_id = SPELL_DARK_SHARPMETAL; + a1.spell_id = uSpellID; a1.spell_level = uSkillLevel; - a1.vPosition.x = v5->vPosition.x; + a1.vPosition.x = actorPtr->vPosition.x; a1.spell_skill = 0; - a1.vPosition.y = v5->vPosition.y; - a1.vPosition.z = v5->vPosition.z + ((signed int)v5->uActorHeight >> 1); + a1.vPosition.y = actorPtr->vPosition.y; + a1.vPosition.z = actorPtr->vPosition.z + ((signed int)actorPtr->uActorHeight >> 1); a1.uFacing = pDir->uYawAngle; a1.uSoundID = 0; a1.uAttributes = 0; @@ -737,26 +701,42 @@ return; break; - case 95: + case SPELL_DARK_PAIN_REFLECTION: if (masteryLevel == 0) v68 = 0; else if (masteryLevel == 1 || (masteryLevel == 2) || (masteryLevel == 3)) v68 = 300 * realPoints + 3840; else v68 = 900 * realPoints + 3840; - v5->pActorBuffs[20].Apply( + actorPtr->pActorBuffs[20].Apply( pParty->uTimePlayed + (signed int)(signed __int64)((double)(v68 << 7) * 0.033333335), masteryLevel, 0, 0, 0); - pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(v5,0x7E7E7Eu); + pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(actorPtr,0x7E7E7Eu); pAudioPlayer->PlaySound((SoundID)18060, PID(OBJECT_Actor, uActorID), 0, -1, 0, 0, 0, 0); return; } } + +//----- (new func) -------------------------------------------------------- +unsigned short Actor::GetObjDescId( int spellId ) +{ + for (unsigned int i = 0; i < pObjectList->uNumObjects; i++) + { + if (stru_4E3ACC[spellId].uType == pObjectList->pObjects[i].uObjectID) + { + return i; + break; + } + } + return 0; +} + + //----- (0043ABB0) -------------------------------------------------------- bool Actor::ArePeasantsOfSameFaction(Actor *a1, Actor *a2) {