Untitled
unknown
lua
2 years ago
2.4 kB
5
Indexable
local function executeDaggers(casterId, targets, daggers, executions) executions = executions or 0 if daggers <= 0 or #targets == 0 then return end local caster = Creature(casterId) if not caster then return end local target = Creature(targets[1]) if target and casterId ~= target:getId() then local tile = Tile(target:getPosition()) if tile and not tile:hasFlag(TILESTATE_PROTECTIONZONE) and caster:getPosition():isSightClear(target:getPosition()) then local sameTargetCount = 0 local maxHitsTarget = math.random(config.maxHitsPerTarget[1], config.maxHitsPerTarget[2]) repeat if (daggers <= 0 or sameTargetCount >= maxHitsTarget) then break end daggers = daggers - 1 addEvent(function(casterId, targetId) local caster = Player(casterId) if not caster then return end local target = Creature(targetId) if not target then return end local tile = Tile(target:getPosition()) if not tile then return end if not tile:hasFlag(TILESTATE_PROTECTIONZONE) and caster:getPosition():isSightClear(target:getPosition()) then caster:getPosition():sendDistanceEffect(target:getPosition(), config.distEffect) local min, max = getInternalFormula(caster) doTargetCombatHealth(caster, target, config.mainTypeDamage, -min, -max) if math.random(100) <= config.chanceBleed then local condition = Condition(config.typeBleed) condition:setParameter(CONDITION_PARAM_OWNER, caster:getId()) condition:setParameter(CONDITION_PARAM_DELAYED, true) condition:setParameter(CONDITION_PARAM_SUBID, config.subIdBleed) condition:addDamage(config.roundsBleed, config.timeBetweenRounds * 1000, -config.damageBleed) if target:getCondition(config.typeBleed, CONDITIONID_COMBAT, config.subIdBleed) then target:removeCondition(CONDITION_ATTRIBUTES, CONDITIONID_COMBAT, config.subIdBleed) end target:addCondition(condition) end end end, sameTargetCount * config.timeBetweenDaggers, casterId, target:getId()) sameTargetCount = sameTargetCount + 1 until (math.random(100) >= config.daggerChance) end end table.remove(targets, 1) addEvent(executeDaggers, executions * config.timeBetweenTargets, casterId, targets, daggers, executions + 1) end
Editor is loading...