short CMagicProcess::GetMagicDamage(int tid, int total_hit, int attribute, int dexpoint, int righthand_damage) { short damage = 0, temp_hit = 0 ; int random = 0, total_r = 0 ; uint8 result; bool bSign = true; if( tid < NPC_BAND || tid > INVALID_BAND) return 0; // Check if target id is valid. CNpc* pNpc = g_pMain->m_arNpc.GetData(tid); if (pNpc == nullptr || pNpc->isDead() || pNpc->isNonAttackingObject()) return 0; //result = m_pSrcUser->GetHitRate(m_pSrcUser->m_fHitrate / pNpc->m_sEvadeRate ); result = SUCCESS; if (result != FAIL) { // In case of SUCCESS (and SUCCESS only!) .... switch (attribute) { case FIRE_R : total_r = pNpc->m_byFireR; break; case COLD_R : total_r = pNpc->m_byColdR; break; case LIGHTNING_R : total_r = pNpc->m_byLightningR ; break; case MAGIC_R : total_r = pNpc->m_byMagicR ; break; case DISEASE_R : total_r = pNpc->m_byDiseaseR ; break; case POISON_R : total_r = pNpc->m_byPoisonR ; break; } total_hit = (total_hit * (dexpoint + 20)) / 170; if(total_hit < 0) { total_hit = abs(total_hit); bSign = false; } damage = (short)(total_hit - (0.7f * total_hit * total_r / 200)) ; random = myrand (0, damage) ; damage = (short)((0.7f * (total_hit - (0.9f * total_hit * total_r / 200))) + 0.2f * random); // damage = damage + (3 * righthand_damage); damage = damage + righthand_damage; } else damage = 0 ; if (!bSign && damage != 0) { damage = -damage; } // Apply boost for skills matching weather type. // This isn't actually used officially, but I think it's neat... GetWeatherDamage(damage, attribute); //return 1; return damage; }
short CMagicProcess::GetMagicDamage(int tid, int total_hit, int attribute, int dexpoint, int righthand_damage) { short damage = 0, temp_hit = 0 ; int random = 0, total_r = 0 ; BYTE result; BOOL bSign = TRUE; // FALSE이면 -, TRUE이면 + if( tid < NPC_BAND || tid > INVALID_BAND) return 0; // Check if target id is valid. CNpc* pNpc = NULL; pNpc = g_pMain.m_arNpc.GetData(tid-NPC_BAND); if(pNpc == NULL || pNpc->m_NpcState == NPC_DEAD || pNpc->m_iHP == 0) return 0; if(pNpc->m_proto->m_tNpcType == NPC_ARTIFACT||pNpc->m_proto->m_tNpcType == NPC_PHOENIX_GATE || pNpc->m_proto->m_tNpcType == NPC_GATE_LEVER || pNpc->m_proto->m_tNpcType == NPC_SPECIAL_GATE ) return 0; //result = m_pSrcUser->GetHitRate(m_pSrcUser->m_fHitrate / pNpc->m_sEvadeRate ); result = SUCCESS; if (result != FAIL) { // In case of SUCCESS (and SUCCESS only!) .... switch (attribute) { case FIRE_R : total_r = pNpc->m_byFireR; break; case COLD_R : total_r = pNpc->m_byColdR; break; case LIGHTNING_R : total_r = pNpc->m_byLightningR ; break; case MAGIC_R : total_r = pNpc->m_byMagicR ; break; case DISEASE_R : total_r = pNpc->m_byDiseaseR ; break; case POISON_R : total_r = pNpc->m_byPoisonR ; break; } total_hit = (total_hit * (dexpoint + 20)) / 170; if(total_hit < 0) { total_hit = abs(total_hit); bSign = FALSE; } damage = (short)(total_hit - (0.7f * total_hit * total_r / 200)) ; random = myrand (0, damage) ; damage = (short)((0.7f * (total_hit - (0.9f * total_hit * total_r / 200))) + 0.2f * random); // damage = damage + (3 * righthand_damage); damage = damage + righthand_damage; } else damage = 0 ; if(bSign == FALSE && damage != 0) { damage = - damage; } // Apply boost for skills matching weather type. // This isn't actually used officially, but I think it's neat... GetWeatherDamage(damage, attribute); //return 1; return damage; }