Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix soul fire #306

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions data/spells/lib/spells.lua
Original file line number Diff line number Diff line change
Expand Up @@ -208,3 +208,42 @@ CORPSES = {

-- This array contains all destroyable field items
FIELDS = {1487,1488,1489,1490,1491,1492,1493,1494,1495,1496,1500,1501,1502,1503,1504}

function Creature:addDamageCondition(target, conditionType, listType, damage, time, rounds)
local condition = Condition(conditionType)
condition:setParameter(CONDITION_PARAM_OWNER, self:getId())
condition:setParameter(CONDITION_PARAM_DELAYED, true)

if listType == 0 then
local exponent, value = -10, 0
while value < damage do
value = math.floor(10 * 1.2 ^ exponent + 0.5)
condition:addDamage(1, time or 4000, -value)

if value >= damage then
local permille = math.random(10, 1200) / 1000
condition:addDamage(1, time or 4000, -math.max(1, math.floor(value * permille + 0.5)))
else
exponent = exponent + 1
end
end
elseif listType == 1 then
rounds = rounds or RANGE
if rounds[damage] then
condition:addDamage(math.random(1, rounds[damage][2]), time or 4000, -damage)
damage = damage - 1
end

while damage > 0 do
condition:addDamage(rounds[damage] and math.random(rounds[damage][1], rounds[damage][2]) or 1, time or 4000, -damage)
damage = damage - (damage > 21 and math.floor(damage / 20) + math.random(0, 1) or 1)
end
elseif listType == 2 then
for _ = 1, rounds do
condition:addDamage(1, math.random(time[1], time[2]) * 1000, -damage)
end
end

target:addCondition(condition)
return true
end
19 changes: 12 additions & 7 deletions data/spells/scripts/attack/soul fire.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,16 @@ combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_FIREDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_HITBYFIRE)
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_FIRE)

local condition = Condition(CONDITION_FIRE)
condition:setParameter(CONDITION_PARAM_DELAYED, 1)
condition:addDamage(10, 2000, -10)
combat:setCondition(condition)
function onTargetCreature(creature, target)
local min = (creature:getLevel() / 80) + (creature:getMagicLevel() * 0.3) + 2
local max = (creature:getLevel() / 80) + (creature:getMagicLevel() * 0.55) + 4
local rounds = math.random(math.floor(min), math.floor(max))
creature:addDamageCondition(target, CONDITION_FIRE, 2, target:isPlayer() and 5 or 10, {8, 10}, rounds)
return true
end

function onCastSpell(creature, var, isHotkey)
return combat:execute(creature, var)
end
combat:setCallback(CALLBACK_PARAM_TARGETCREATURE, "onTargetCreature")

function onCastSpell(creature, variant, isHotkey)
return combat:execute(creature, variant)
end