• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

LUA Script Target Avoid Spell

Watchdog87

Member
Joined
Mar 2, 2014
Messages
30
Solutions
1
Reaction score
5
Hello! I'm trying to convert this script so that it doesn't hit the target, but the tile that the target is on so that it can avoid the spell if it happens to move before impact.

This spell is called Quake and was taken from Sharing knowledge on Lua possibilities (https://otland.net/threads/sharing-knowledge-on-lua-possibilities.277266/)
I have tried to solve this on my own but unfortunately I have minor knowledge. I have found someone who has done this before with another script: Solved - Confused about this spell following target. (https://otland.net/threads/confused-about-this-spell-following-target.227656/)

If someone could help me with this, it would be much appreciated. Thanks in advance!

local config = {
target = true,
jumps = 50,
walktime = 50
}

local function spinRotate(uid, spins, delay)
local creature = Creature(uid)
if creature then
look = creature:getDirection()
for i = 1, (4* spins) + 1 do
addEvent(function()
if isCreature(uid) then
if i <= (4 * spins) then
look = look < 3 and look + 1 or 0
doCreatureSetLookDir(uid, look)
end
end
end, delay * i)
end
end
return true
end

local combat = Combat()
combat:setParameter(COMBAT_PARAM_TARGETCASTERORTOPMOST, true)
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_EARTHDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, 35)
function onGetFormulaValues(cid, level, maglevel)
min = -((level * 2) + (maglevel * 2)) * 0.9
max = -((level * 2) + (maglevel * 2)) * 1.5
return min, max
end
combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")
local condition = Condition(CONDITION_PARALYZE)
condition:setParameter(CONDITION_PARAM_TICKS, 1000)
condition:setFormula(-1, 1, -1, 1)
combat:addCondition(condition)


local function castSpell(uid, pos, counter)
local counter = counter or 0
if (counter < config.jumps) then
local player = Player(uid)
if player then
local pos = pos and Position(pos) or player:getPosition()
local target = player:getTarget()

local dir
if config.target and target then
dir = getDirectionTo(pos, target:getPosition())
else
dir = player:getDirection()
end
pos:getNextPosition(dir)

if not Tile(pos) or (getTopCreature(pos).uid == 0 and Tile(pos):queryAdd(uid) ~= 0) then
return false
end
combat:execute(player, positionToVariant(pos))
if getTopCreature(pos).uid ~= 0 then
pos:sendMagicEffect(55)
spinRotate(getTopCreature(pos).uid, 15, 100)
return false
end
addEvent(castSpell, config.walktime, uid, pos, counter + 1)
end
end
end




function onCastSpell(cid)
castSpell(cid.uid)
return true
end
 
Back
Top