From 093ac51d31b5ec42becddcc99ac44b5a1882e25c Mon Sep 17 00:00:00 2001 From: ErikasKontenis Date: Fri, 16 Oct 2020 11:05:13 +0300 Subject: [PATCH] introduce hits counter in physical damage and introduce poison strike spell --- data/spells/scripts/spells/poison strike.lua | 20 ++++++++++++++++++++ data/spells/spells.xml | 6 ++++++ data/talkactions/scripts/physical_damage.lua | 12 ++++++++++++ 3 files changed, 38 insertions(+) create mode 100644 data/spells/scripts/spells/poison strike.lua diff --git a/data/spells/scripts/spells/poison strike.lua b/data/spells/scripts/spells/poison strike.lua new file mode 100644 index 0000000..906dc58 --- /dev/null +++ b/data/spells/scripts/spells/poison strike.lua @@ -0,0 +1,20 @@ +local combat = Combat() +combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_EARTHDAMAGE) +combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_GREEN_RINGS) + +function onGetFormulaValues(player, level, maglevel) + local base = 45 + local variation = 10 + + local formula = 3 * maglevel + (2 * level) + + local min = (formula * (base - variation)) / 100 + local max = (formula * (base + variation)) / 100 + return -min, -max +end + +combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues") + +function onCastSpell(creature, variant) + return combat:execute(creature, variant) +end \ No newline at end of file diff --git a/data/spells/spells.xml b/data/spells/spells.xml index 699a351..14e0cc3 100644 --- a/data/spells/spells.xml +++ b/data/spells/spells.xml @@ -140,6 +140,12 @@ + + + + + + diff --git a/data/talkactions/scripts/physical_damage.lua b/data/talkactions/scripts/physical_damage.lua index 4514034..5fe8ba9 100644 --- a/data/talkactions/scripts/physical_damage.lua +++ b/data/talkactions/scripts/physical_damage.lua @@ -281,9 +281,21 @@ function onSay(player, words, param) message = message .. "Min: " .. defensiveDamageContainer[1] .. ", Max: " .. defensiveDamageContainer[2] .. "\n" message = message .. "\nFirst 100 Hits Damage Simulator in Offensive Fighting\n" + local creatureHealth = creature:getType():getMaxHealth() + local creatureHitsTillDeath = 1 for i=1,100 do local damageContainer = getTotalDamage(creature, weapon, ammunition, vocation, attack, skillValue, FIGHTMODE_ATTACK) message = message .. "Hit: " .. i .. ", Damage: " .. damageContainer[0] .. "\n" + creatureHealth = creatureHealth + damageContainer[0] + if creatureHealth > 0 then + creatureHitsTillDeath = creatureHitsTillDeath + 1 + end + end + + if creatureHealth <= 0 then + message = message .. "\nIt would take you approximately " .. creatureHitsTillDeath .. " hits to slain " .. creature:getName() .. ".\n" + else + message = message .. "\nIt would take you more than 100 hits to slain " .. creature:getName() .. ".\n" end player:showTextDialog(weapon and weapon:getId() or 2950, message, false) return false