mr:dash_spell

Dash Spell - Code References

Java Classes

This entity is implemented in Lua and does not have a Java class implementation.

JSON Configuration

This entity does not use JSON configuration.

String Resources

<string name="DashSpell_Name">Dash</string>
<string name="DashSpell_Info">Dash towards a specified direction while colliding with enemies, dealing damage and causing maim.</string>
<string name="DashSpell_OnSelf">I can\'t dash on the spot.</string>
<string name="DashSpell_TooFar">I can\'t dash that far.</string>

Lua Scripts

local RPD = require "scripts/lib/commonClasses"
 
local spell = require "scripts/lib/spell"
 
return spell.init{
    desc  = function ()
        return {
            image         = 2,
            imageFile     = "spellsIcons/warrior.png",
            name          = "DashSpell_Name",
            info          = "DashSpell_Info",
            magicAffinity = "Combat",
            targetingType = "cell",
            level         = 3,
            spellCost     = 10,
            cooldown      = 30,
            castTime      = 0.5
        }
    end,
    castOnCell = function(self, spell, caster, cell)
 
        local level = caster:level()
 
        local ownPos = caster:getPos()
 
        local dist = level:distance(ownPos, cell)
 
        caster:detachBuff("Roots")
 
        if ownPos == cell then
            RPD.glogn("DashSpell_OnSelf")
            return false
        end
 
        if dist  > 2 then
            RPD.glogn("DashSpell_TooFar")
            return false
        end
 
        local dst = RPD.Ballistica:cast(ownPos, cell, false, true, true)
 
        local char = RPD.Actor:findChar(dst)
 
        if char and char ~= caster then
            RPD.affectBuff(char, RPD.Buffs.Vertigo, caster:skillLevel())
            local newPos = char:getPos()
            if char:push(caster) then
                dst = newPos
            else
                dst = level:getEmptyCellNextTo(newPos)
            end
        end
 
        if not level:cellValid(dst) then
            return true
        end
 
        local object = level:getTopLevelObject(dst)
 
        if object then
            local newPos = object:getPos()
            if object:push(caster) then
                dst = newPos
            else
                dst = level:getEmptyCellNextTo(newPos)
            end
        end
 
        if not level:cellValid(dst) then
            return true
        end
 
        local items = caster:getBelongings()
 
        local function hitCell(cell)
            local victim = RPD.Actor:findChar(cell)
            if victim and victim ~= caster then
                local dmg = caster:effectiveSTR() - 5;
                if items.weapon then
                    dmg = dmg + items.weapon:damageRoll(caster)
                end
                dmg = victim:defenseProc(caster, dmg)
                victim:damage(dmg, caster)
                RPD.Sfx.Wound:hit(victim)
            end
        end
 
        RPD.forCellsAround(dst, hitCell)
 
        RPD.playSound("dash")
        RPD.zapEffect(ownPos,dst,"dash")
        caster:getSprite():dash(ownPos,dst)
        caster:move(dst)
 
        return true
    end
}

mr/dash_spell.txt · Last modified: by 127.0.0.1