Untitled diff

Created Diff never expires
0 removals
52 lines
10 additions
62 lines
CombatDamage Combat::getCombatDamage(Creature* creature, Creature* target) const
CombatDamage Combat::getCombatDamage(Creature* creature, Creature* target) const
{
{
CombatDamage damage;
CombatDamage damage;
damage.origin = params.origin;
damage.origin = params.origin;
damage.primary.type = params.combatType;
damage.primary.type = params.combatType;
if (formulaType == COMBAT_FORMULA_DAMAGE) {
if (formulaType == COMBAT_FORMULA_DAMAGE) {
damage.primary.value = normal_random(
damage.primary.value = normal_random(
static_cast<int32_t>(mina),
static_cast<int32_t>(mina),
static_cast<int32_t>(maxa)
static_cast<int32_t>(maxa)
);
);
} else if (creature) {
} else if (creature) {
int32_t min, max;
int32_t min, max;
if (creature->getCombatValues(min, max)) {
if (creature->getCombatValues(min, max)) {
damage.primary.value = normal_random(min, max);
damage.primary.value = normal_random(min, max);
} else if (Player* player = creature->getPlayer()) {
} else if (Player* player = creature->getPlayer()) {
if (params.valueCallback) {
if (params.valueCallback) {
params.valueCallback->getMinMaxValues(player, damage, params.useCharges);
params.valueCallback->getMinMaxValues(player, damage, params.useCharges);
} else if (formulaType == COMBAT_FORMULA_LEVELMAGIC) {
} else if (formulaType == COMBAT_FORMULA_LEVELMAGIC) {
int32_t levelFormula = player->getLevel() * 2 + player->getMagicLevel() * 3;
int32_t levelFormula = player->getLevel() * 2 + player->getMagicLevel() * 3;
damage.primary.value = normal_random(
damage.primary.value = normal_random(
static_cast<int32_t>(levelFormula * mina + minb),
static_cast<int32_t>(levelFormula * mina + minb),
static_cast<int32_t>(levelFormula * maxa + maxb)
static_cast<int32_t>(levelFormula * maxa + maxb)
);
);
} else if (formulaType == COMBAT_FORMULA_SKILL) {
} else if (formulaType == COMBAT_FORMULA_SKILL) {
Item* tool = player->getWeapon();
Item* tool = player->getWeapon();
const Weapon* weapon = g_weapons->getWeapon(tool);
const Weapon* weapon = g_weapons->getWeapon(tool);
if (weapon) {
if (weapon) {
damage.primary.value = normal_random(
damage.primary.value = normal_random(
static_cast<int32_t>(minb),
static_cast<int32_t>(minb),
static_cast<int32_t>(weapon->getWeaponDamage(player, target, tool, true) * maxa + maxb)
static_cast<int32_t>(weapon->getWeaponDamage(player, target, tool, true) * maxa + maxb)
);
);


damage.secondary.type = weapon->getElementType();
damage.secondary.type = weapon->getElementType();
damage.secondary.value = weapon->getElementDamage(player, target, tool);
damage.secondary.value = weapon->getElementDamage(player, target, tool);
if (params.useCharges) {
if (params.useCharges) {
uint16_t charges = tool->getCharges();
uint16_t charges = tool->getCharges();
if (charges != 0) {
if (charges != 0) {
g_game.transformItem(tool, tool->getID(), charges - 1);
g_game.transformItem(tool, tool->getID(), charges - 1);
}
}
}
}
} else {
} else {
damage.primary.value = normal_random(
damage.primary.value = normal_random(
static_cast<int32_t>(minb),
static_cast<int32_t>(minb),
static_cast<int32_t>(maxb)
static_cast<int32_t>(maxb)
);
);
}
}
}
}
}
}
}
}

//custom edit: passive damage bonus // ONLY DAMAGE, NOT INCREASE HEALING
if (creature->getPlayer()) // caster is player
{
if (params.combatType != COMBAT_HEALING)
{
damage.primary.value += ((damage.primary.value / 100)*creature->getPlayer()->getPassiveDamageBonus());
damage.secondary.value += ((damage.secondary.value / 100)*creature->getPlayer()->getPassiveDamageBonus());
}
}
return damage;
return damage;
}
}