Skip to content

Commit

Permalink
Merge branch 'main' into fixDoor
Browse files Browse the repository at this point in the history
  • Loading branch information
dudantas authored Dec 7, 2023
2 parents 449540a + 0e1143f commit 712a04e
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 74 deletions.
22 changes: 11 additions & 11 deletions data-otservbr-global/monster/quests/forgotten_knowledge/icicle.lua
Original file line number Diff line number Diff line change
Expand Up @@ -70,20 +70,20 @@ monster.defenses = {
defense = 199,
armor = 199,
mitigation = 0.50,
{ name = "icicle heal", interval = 2000, chance = 25, target = false },
{ name = "icicle heal", interval = 2000, chance = 60, target = false },
}

monster.elements = {
{ type = COMBAT_PHYSICALDAMAGE, percent = 0 },
{ type = COMBAT_ENERGYDAMAGE, percent = 0 },
{ type = COMBAT_EARTHDAMAGE, percent = 0 },
{ type = COMBAT_FIREDAMAGE, percent = 0 },
{ type = COMBAT_LIFEDRAIN, percent = 0 },
{ type = COMBAT_MANADRAIN, percent = 0 },
{ type = COMBAT_DROWNDAMAGE, percent = 0 },
{ type = COMBAT_ICEDAMAGE, percent = 0 },
{ type = COMBAT_HOLYDAMAGE, percent = 0 },
{ type = COMBAT_DEATHDAMAGE, percent = 0 },
{ type = COMBAT_PHYSICALDAMAGE, percent = 100 },
{ type = COMBAT_ENERGYDAMAGE, percent = 100 },
{ type = COMBAT_EARTHDAMAGE, percent = 100 },
{ type = COMBAT_FIREDAMAGE, percent = 100 },
{ type = COMBAT_LIFEDRAIN, percent = 100 },
{ type = COMBAT_MANADRAIN, percent = 100 },
{ type = COMBAT_DROWNDAMAGE, percent = 100 },
{ type = COMBAT_ICEDAMAGE, percent = 100 },
{ type = COMBAT_HOLYDAMAGE, percent = 100 },
{ type = COMBAT_DEATHDAMAGE, percent = 100 },
}

monster.immunities = {
Expand Down
21 changes: 11 additions & 10 deletions data-otservbr-global/scripts/spells/monster/icicle_heal.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,17 @@ combat:setParameter(COMBAT_PARAM_AGGRESSIVE, 0)
combat:setArea(createCombatArea(AREA_CIRCLE3X3))

function onTargetCreature(creature, target)
local min = 400
local max = 600

local master = target:getMaster()
if target:isPlayer() and not master or master and master:isPlayer() then
return true
local spectators, spectator = Game.getSpectators(creature:getPosition(), false, false, 3, 3, 3, 3)
for i = 1, #spectators do
spectator = spectators[i]
if spectator:isMonster() and spectator:getName():lower() == "dragon egg" then
creature:setTarget("dragon egg")
if target:getName():lower() == "dragon egg" then
target:addHealth(-100)
return true
end
end
end

doTargetCombatHealth(0, target, COMBAT_HEALING, min, max, CONST_ME_NONE)
return true
end

combat:setCallback(CALLBACK_PARAM_TARGETCREATURE, "onTargetCreature")
Expand All @@ -29,5 +30,5 @@ spell:words("###436")
spell:isAggressive(true)
spell:blockWalls(true)
spell:needLearn(true)
spell:isSelfTarget(true)
spell:isSelfTarget(false)
spell:register()
2 changes: 2 additions & 0 deletions data/items/items.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61565,6 +61565,7 @@
<item id="36666" article="a" name="eldritch quiver">
<attribute key="primarytype" value="quivers"/>
<attribute key="slotType" value="right-hand"/>
<attribute key="showattributes" value="1"/>
<attribute key="containersize" value="8"/>
<attribute key="weight" value="2200"/>
<attribute key="perfectshotdamage" value="20"/>
Expand Down Expand Up @@ -65289,6 +65290,7 @@
<item id="39150" article="an" name="alicorn quiver">
<attribute key="primarytype" value="quivers"/>
<attribute key="slotType" value="right-hand"/>
<attribute key="showattributes" value="1"/>
<attribute key="containersize" value="12"/>
<attribute key="weight" value="2000"/>
<attribute key="magiclevelpoints" value="1"/>
Expand Down
103 changes: 50 additions & 53 deletions src/game/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5990,6 +5990,31 @@ bool Game::combatBlockHit(CombatDamage &damage, std::shared_ptr<Creature> attack
std::shared_ptr<Player> targetPlayer = target->getPlayer();

if (damage.primary.type != COMBAT_NONE) {

damage.primary.value = -damage.primary.value;
// Damage healing primary
if (attacker) {
if (target->getMonster()) {
uint32_t primaryHealing = target->getMonster()->getHealingCombatValue(damage.primary.type);
if (primaryHealing > 0) {
damageHeal.primary.value = std::ceil((damage.primary.value) * (primaryHealing / 100.));
canHeal = true;
}
}
if (targetPlayer && attacker->getAbsorbPercent(damage.primary.type) != 0) {
damageAbsorbMessage = true;
}
if (attacker->getPlayer() && attacker->getIncreasePercent(damage.primary.type) != 0) {
damageIncreaseMessage = true;
}
damage.primary.value *= attacker->getBuff(BUFF_DAMAGEDEALT) / 100.;
}
damage.primary.value *= target->getBuff(BUFF_DAMAGERECEIVED) / 100.;

primaryBlockType = target->blockHit(attacker, damage.primary.type, damage.primary.value, checkDefense, checkArmor, field);

damage.primary.value = -damage.primary.value;
InternalGame::sendBlockEffect(primaryBlockType, damage.primary.type, target->getPosition(), attacker);
// Damage reflection primary
if (!damage.extension && attacker) {
if (targetPlayer && attacker->getMonster() && damage.primary.type != COMBAT_HEALING) {
Expand Down Expand Up @@ -6028,57 +6053,12 @@ bool Game::combatBlockHit(CombatDamage &damage, std::shared_ptr<Creature> attack
}
}
}
damage.primary.value = -damage.primary.value;
// Damage healing primary
if (attacker) {
if (target->getMonster()) {
uint32_t primaryHealing = target->getMonster()->getHealingCombatValue(damage.primary.type);
if (primaryHealing > 0) {
damageHeal.primary.value = std::ceil((damage.primary.value) * (primaryHealing / 100.));
canHeal = true;
}
}
if (targetPlayer && attacker->getAbsorbPercent(damage.primary.type) != 0) {
damageAbsorbMessage = true;
}
if (attacker->getPlayer() && attacker->getIncreasePercent(damage.primary.type) != 0) {
damageIncreaseMessage = true;
}
damage.primary.value *= attacker->getBuff(BUFF_DAMAGEDEALT) / 100.;
}
damage.primary.value *= target->getBuff(BUFF_DAMAGERECEIVED) / 100.;

primaryBlockType = target->blockHit(attacker, damage.primary.type, damage.primary.value, checkDefense, checkArmor, field);

damage.primary.value = -damage.primary.value;
InternalGame::sendBlockEffect(primaryBlockType, damage.primary.type, target->getPosition(), attacker);
} else {
primaryBlockType = BLOCK_NONE;
}

if (damage.secondary.type != COMBAT_NONE) {
// Damage reflection secondary
if (!damage.extension && attacker && target->getMonster()) {
uint32_t secondaryReflectPercent = target->getReflectPercent(damage.secondary.type, true);
uint32_t secondaryReflectFlat = target->getReflectFlat(damage.secondary.type, true);
if (secondaryReflectPercent > 0 || secondaryReflectFlat > 0) {
if (!canReflect) {
damageReflected.primary.type = damage.secondary.type;
damageReflected.primary.value = std::ceil(damage.secondary.value * secondaryReflectPercent / 100.) + std::max(-static_cast<int32_t>(std::ceil(attacker->getMaxHealth() * 0.01)), std::max(damage.secondary.value, -(static_cast<int32_t>(secondaryReflectFlat))));
if (!damageReflected.exString.empty()) {
damageReflected.exString += ", ";
}
damageReflected.extension = true;
damageReflected.exString += "damage reflection";
damageReflectedParams.combatType = damage.primary.type;
damageReflectedParams.aggressive = true;
canReflect = true;
} else {
damageReflected.secondary.type = damage.secondary.type;
damageReflected.primary.value = std::ceil(damage.secondary.value * secondaryReflectPercent / 100.) + std::max(-static_cast<int32_t>(std::ceil(attacker->getMaxHealth() * 0.01)), std::max(damage.secondary.value, -(static_cast<int32_t>(secondaryReflectFlat))));
}
}
}

damage.secondary.value = -damage.secondary.value;
// Damage healing secondary
if (attacker && target->getMonster()) {
Expand All @@ -6102,9 +6082,32 @@ bool Game::combatBlockHit(CombatDamage &damage, std::shared_ptr<Creature> attack

damage.secondary.value = -damage.secondary.value;
InternalGame::sendBlockEffect(secondaryBlockType, damage.secondary.type, target->getPosition(), attacker);

if (!damage.extension && attacker && target->getMonster()) {
int32_t secondaryReflectPercent = target->getReflectPercent(damage.secondary.type, true);
int32_t secondaryReflectFlat = target->getReflectFlat(damage.secondary.type, true);
if (secondaryReflectPercent > 0 || secondaryReflectFlat > 0) {
if (!canReflect) {
damageReflected.primary.type = damage.secondary.type;
damageReflected.primary.value = std::ceil(damage.secondary.value * secondaryReflectPercent / 100.) + std::max(-static_cast<int32_t>(std::ceil(attacker->getMaxHealth() * 0.01)), std::max(damage.secondary.value, -(static_cast<int32_t>(secondaryReflectFlat))));
if (!damageReflected.exString.empty()) {
damageReflected.exString += ", ";
}
damageReflected.extension = true;
damageReflected.exString += "damage reflection";
damageReflectedParams.combatType = damage.primary.type;
damageReflectedParams.aggressive = true;
canReflect = true;
} else {
damageReflected.secondary.type = damage.secondary.type;
damageReflected.primary.value = std::ceil(damage.secondary.value * secondaryReflectPercent / 100.) + std::max(-static_cast<int32_t>(std::ceil(attacker->getMaxHealth() * 0.01)), std::max(damage.secondary.value, -(static_cast<int32_t>(secondaryReflectFlat))));
}
}
}
} else {
secondaryBlockType = BLOCK_NONE;
}
// Damage reflection secondary

if (damage.primary.type == COMBAT_HEALING) {
damage.primary.value *= target->getBuff(BUFF_HEALINGRECEIVED) / 100.;
Expand Down Expand Up @@ -7223,13 +7226,7 @@ bool Game::combatChangeMana(std::shared_ptr<Creature> attacker, std::shared_ptr<
}

target->drainMana(attacker, manaLoss);
if (targetPlayer) {
std::string cause = "(other)";
if (attacker) {
cause = attacker->getName();
}
targetPlayer->updateInputAnalyzer(damage.primary.type, damage.primary.value * -1, cause);
}

std::stringstream ss;

std::string damageString = std::to_string(manaLoss);
Expand Down

0 comments on commit 712a04e

Please sign in to comment.