Mercurial > mm7
changeset 2309:a07bf9afa652
ActorDamageFromMonster minor cleanups
author | Grumpy7 |
---|---|
date | Mon, 17 Mar 2014 22:49:54 +0100 |
parents | ca13c630ee2b |
children | 43af6c819e88 |
files | mm7_5.cpp |
diffstat | 1 files changed, 38 insertions(+), 47 deletions(-) [+] |
line wrap: on
line diff
--- a/mm7_5.cpp Sun Mar 16 21:05:41 2014 +0100 +++ b/mm7_5.cpp Mon Mar 17 22:49:54 2014 +0100 @@ -308,84 +308,75 @@ void ActorDamageFromMonster(signed int attacker_id, unsigned int actor_id, Vec3_int_ *pVelocity, signed int a4) { int v4; // ebx@1 - int v6; // eax@3 - __int64 v10; // qax@8 + int dmgToRecv; // qax@8 signed int v12; // ecx@20 - int v13; // ecx@22 - int v14; // edi@30 - signed int v17; // [sp+10h] [bp-4h]@1 - int v18; // [sp+20h] [bp+Ch]@34 + int finalDmg; // edi@30 + int pushDistance; // [sp+20h] [bp+Ch]@34 v4 = 0; - v17 = attacker_id; if ( PID_TYPE(attacker_id) == OBJECT_Item) { v4 = pSpriteObjects[PID_ID(attacker_id)].field_60_distance_related_prolly_lod; - v17 = pSpriteObjects[PID_ID(attacker_id)].spell_caster_pid; + attacker_id = pSpriteObjects[PID_ID(attacker_id)].spell_caster_pid; } - if ( PID_TYPE(v17) == OBJECT_Actor) + if ( PID_TYPE(attacker_id) == OBJECT_Actor) { - v6 = pActors[actor_id].IsNotAlive(); - if ( !v6 ) + if ( !pActors[actor_id].IsNotAlive() ) { - pActors[actor_id].uLastCharacterIDToHit = v17; + pActors[actor_id].uLastCharacterIDToHit = attacker_id; if ( pActors[actor_id].uAIState == Fleeing ) pActors[actor_id].uAttributes |= FACE_UNKNOW7; - if ( pActors[PID_ID(v17)]._4273BB_DoesHitOtherActor(&pActors[actor_id], v4, 0) ) + if ( pActors[PID_ID(attacker_id)]._4273BB_DoesHitOtherActor(&pActors[actor_id], v4, 0) ) { - v10 = (unsigned int)pActors[PID_ID(v17)]._43B3E0_CalcDamage(a4); - if ( (signed __int64)pActors[PID_ID(v17)].pActorBuffs[ACTOR_BUFF_SHRINK].uExpireTime > 0 ) + dmgToRecv = pActors[PID_ID(attacker_id)]._43B3E0_CalcDamage(a4); + if ( pActors[PID_ID(attacker_id)].pActorBuffs[ACTOR_BUFF_SHRINK].uExpireTime > 0 ) { - if ( pActors[PID_ID(v17)].pActorBuffs[ACTOR_BUFF_SHRINK].uPower ) - v10 = (signed int)v10 / (unsigned __int16)pActors[PID_ID(v17)].pActorBuffs[ACTOR_BUFF_SHRINK].uPower; + if ( pActors[PID_ID(attacker_id)].pActorBuffs[ACTOR_BUFF_SHRINK].uPower ) + dmgToRecv = dmgToRecv / pActors[PID_ID(attacker_id)].pActorBuffs[ACTOR_BUFF_SHRINK].uPower; } - if ( SHIDWORD(pActors[actor_id].pActorBuffs[ACTOR_BUFF_STONED].uExpireTime) >= SHIDWORD(v10) - && (SHIDWORD(pActors[actor_id].pActorBuffs[ACTOR_BUFF_STONED].uExpireTime) > SHIDWORD(v10) - || LODWORD(pActors[actor_id].pActorBuffs[ACTOR_BUFF_STONED].uExpireTime) > HIDWORD(v10)) ) - LODWORD(v10) = 0; - if ( a4 == HIDWORD(v10) ) - v12 = pActors[PID_ID(v17)].pMonsterInfo.uAttack1Type; - else if ( a4 - HIDWORD(v10) == 1 ) + if ( pActors[actor_id].pActorBuffs[ACTOR_BUFF_STONED].uExpireTime > 0 ) + dmgToRecv = 0; + if ( a4 == 0 ) + v12 = pActors[PID_ID(attacker_id)].pMonsterInfo.uAttack1Type; + else if ( a4 == 1 ) { - v12 = pActors[PID_ID(v17)].pMonsterInfo.uAttack2Type; - if ( SHIDWORD(pActors[actor_id].pActorBuffs[ACTOR_BUFF_SHIELD].uExpireTime) >= SHIDWORD(v10) - && (SHIDWORD(pActors[actor_id].pActorBuffs[ACTOR_BUFF_SHIELD].uExpireTime) > SHIDWORD(v10) - || LODWORD(pActors[actor_id].pActorBuffs[ACTOR_BUFF_SHIELD].uExpireTime) > HIDWORD(v10)) ) - LODWORD(v10) = (signed int)v10 / 2; + v12 = pActors[PID_ID(attacker_id)].pMonsterInfo.uAttack2Type; + if ( SHIDWORD(pActors[actor_id].pActorBuffs[ACTOR_BUFF_SHIELD].uExpireTime) > 0 ) + dmgToRecv = dmgToRecv / 2; } - else if ( a4 - HIDWORD(v10) == 2 ) - v12 = LOBYTE(pSpellStats->pInfos[pActors[actor_id].pMonsterInfo.uSpell1ID].uSchool); - else if ( a4 - HIDWORD(v10) == 3 ) - v12 = LOBYTE(pSpellStats->pInfos[pActors[actor_id].pMonsterInfo.uSpell2ID].uSchool); - else if ( a4 - HIDWORD(v10) == 4 ) - v12 = pActors[PID_ID(v17)].pMonsterInfo.field_3C_some_special_attack; + else if ( a4 == 2 ) + v12 = pSpellStats->pInfos[pActors[actor_id].pMonsterInfo.uSpell1ID].uSchool; + else if ( a4 == 3 ) + v12 = pSpellStats->pInfos[pActors[actor_id].pMonsterInfo.uSpell2ID].uSchool; + else if ( a4 == 4 ) + v12 = pActors[PID_ID(attacker_id)].pMonsterInfo.field_3C_some_special_attack; else v12 = 4; - v14 = pActors[actor_id].CalcMagicalDamageToActor((DAMAGE_TYPE)v12, v10); - pActors[actor_id].sCurrentHP -= v14; - if ( v14 ) + finalDmg = pActors[actor_id].CalcMagicalDamageToActor((DAMAGE_TYPE)v12, dmgToRecv); + pActors[actor_id].sCurrentHP -= finalDmg; + if ( finalDmg ) { if ( pActors[actor_id].sCurrentHP > 0 ) - Actor::AI_Stun(actor_id, v17, 0); + Actor::AI_Stun(actor_id, attacker_id, 0); else Actor::Die(actor_id); Actor::AggroSurroundingPeasants(actor_id, 0); - v18 = 20 * v14 / (signed int)pActors[actor_id].pMonsterInfo.uHP; - if ( 20 * v14 / (signed int)pActors[actor_id].pMonsterInfo.uHP > 10 ) - v18 = 10; + pushDistance = 20 * finalDmg / pActors[actor_id].pMonsterInfo.uHP; + if ( pushDistance > 10 ) + pushDistance = 10; if ( !MonsterStats::BelongsToSupertype(pActors[actor_id].pMonsterInfo.uID, MONSTER_SUPERTYPE_TREANT) ) { - pVelocity->x = fixpoint_mul(v18, pVelocity->x); - pVelocity->y = fixpoint_mul(v18, pVelocity->y); - pVelocity->z = fixpoint_mul(v18, pVelocity->z); + pVelocity->x = (int32)fixpoint_mul(pushDistance, pVelocity->x); + pVelocity->y = (int32)fixpoint_mul(pushDistance, pVelocity->y); + pVelocity->z = (int32)fixpoint_mul(pushDistance, pVelocity->z); pActors[actor_id].vVelocity.x = 50 * LOWORD(pVelocity->x); pActors[actor_id].vVelocity.y = 50 * LOWORD(pVelocity->y); pActors[actor_id].vVelocity.z = 50 * LOWORD(pVelocity->z); } - Actor::AddBloodsplatOnDamageOverlay(actor_id, 1, v14); + Actor::AddBloodsplatOnDamageOverlay(actor_id, 1, finalDmg); } else - Actor::AI_Stun(actor_id, v17, 0); + Actor::AI_Stun(actor_id, attacker_id, 0); return; } }