• 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!

Shinra Tensei (area)

Shortened, untested... Try it :)
Lua:
function getDistance(cid)
    local tile = {{20, 1},{40, 2},{60, 3},{80, 4},{100, 5}}
    table.sort(tile, function(a, b) return a[1] > b[1] end)
    for _, t in ipairs(tile) do    
        if(getPlayerLevel(cid) >= t[1]) then
            return t[2]
        end
    end
    return tile[1][2]
end
 
function onCastSpell(cid, var)
    local dist = getDistance(cid)
    local areaPosition = {
        {x=getCreaturePosition(cid).x-dist, y=getCreaturePosition(cid).y-dist, z=getCreaturePosition(cid).z, stackpos = 255},
        {x=getCreaturePosition(cid).x+dist, y=getCreaturePosition(cid).y+dist, z=getCreaturePosition(cid).z, stackpos = 255}
    }
    local players = getPlayersOnline()
    local dmg = math.random(10, getPlayerLevel(cid)+10)
 
    for i= 1, dist do
        for _, pid in ipairs(players) do
            if isInRange(getCreaturePosition(pid), areaPosition[1], areaPosition[2]) then
                local tp = getCreaturePosition(pid)
                local pos = getCreaturePosition(cid)
                tp.x = tp.x + math.max(math.min(1, tp.x - pos.x), -1)
                tp.y = tp.y + math.max(math.min(1, tp.y - pos.y), -1)

                if isWalkable(tp, true) and not getTileInfo(tp).protection then
                    doSendMagicEffect(getCreaturePosition(pid), 34)
                    doTeleportThing(pid, tp, true)
                    doTargetCombatHealth(cid, pid, COMBAT_PHYSICALDAMAGE, -dmg, -dmg, CONST_ME_BLOCKHIT)
                    doSendMagicEffect(getCreaturePosition(pid), 34)
                else    
                    doSendMagicEffect(getCreaturePosition(pid), CONST_ME_POFF)
                end
            end
        end
    end
    return true
end



Optionally you could use this version, with a better config for distance:
Lua:
local startLevelDistance = 40 -- at this level he will get his first distance advance (2 distance), until that it will remain as minDistance
local levelPerDistance = 20 -- each 20 level he gets another distance
local minDistance = 1 -- the distance you start with
local maxDistance = 5 -- At level 140 (startLevelDistance + levelPerDistance * maxDistance) he will have his max distance (5 in this case).

function onCastSpell(cid, var)
    local dist = math.max(minDistance, math.min(maxDistance, math.floor((getPlayerLevel(cid) - startLevelDistance) / levelPerDistance) + minDistance))
    local areaPosition = {
        {x=getCreaturePosition(cid).x-dist, y=getCreaturePosition(cid).y-dist, z=getCreaturePosition(cid).z, stackpos = 255},
        {x=getCreaturePosition(cid).x+dist, y=getCreaturePosition(cid).y+dist, z=getCreaturePosition(cid).z, stackpos = 255}
    }
    local players = getPlayersOnline()
    local dmg = math.random(10, getPlayerLevel(cid)+10)
 
    for i= 1, dist do
        for _, pid in ipairs(players) do
            if isInRange(getCreaturePosition(pid), areaPosition[1], areaPosition[2]) then
                local tp = getCreaturePosition(pid)
                local pos = getCreaturePosition(cid)
                tp.x = tp.x + math.max(math.min(1, tp.x - pos.x), -1)
                tp.y = tp.y + math.max(math.min(1, tp.y - pos.y), -1)

                if isWalkable(tp, true) and not getTileInfo(tp).protection then
                    doSendMagicEffect(getCreaturePosition(pid), 34)
                    doTeleportThing(pid, tp, true)
                    doTargetCombatHealth(cid, pid, COMBAT_PHYSICALDAMAGE, -dmg, -dmg, CONST_ME_BLOCKHIT)
                    doSendMagicEffect(getCreaturePosition(pid), 34)
                else    
                    doSendMagicEffect(getCreaturePosition(pid), CONST_ME_POFF)
                end
            end
        end
    end
    return true
end
 
Last edited:
on the entire area or only on players repelled? if its only on players its already done
 
i used col's second script and it works perfectly i love it. it doesnt move ppl in PZ and it doesnt move ppl into PZ.

1 small set back it still moves GM's even tho i added the check for the players access level
 
the problem with monsters is that I don't know how to get a table with all creatures around to make 'for'
i'll try another way later
 
well I did it based on second colandus' version of the script, for repel all creatures (players, npcs, monsters, ...)

Lua:
local startLevelDistance = 40 -- at this level he will get his first distance advance (2 distance), until that it will remain as minDistance
local levelPerDistance = 20 -- each 20 level he gets another distance
local minDistance = 1 -- the distance you start with
local maxDistance = 5 -- At level 140 (startLevelDistance + levelPerDistance * maxDistance) he will have his max distance (5 in this case).
 
function onCastSpell(cid, var)
    local dist = math.max(minDistance, math.min(maxDistance, math.floor((getPlayerLevel(cid) - startLevelDistance) / levelPerDistance) + minDistance))
    local areaPosition = {
        {x=getCreaturePosition(cid).x-dist, y=getCreaturePosition(cid).y-dist, z=getCreaturePosition(cid).z, stackpos = 255},
        {x=getCreaturePosition(cid).x+dist, y=getCreaturePosition(cid).y+dist, z=getCreaturePosition(cid).z, stackpos = 255}
    }
    local dmg = math.random(10, getPlayerLevel(cid)+10)
	
	local monsters = {}
	pos=getCreaturePosition(cid)
	for x=1,9 do
		for y=1,9 do
			getpos={x=pos.x-5+x,y=pos.y-5+y,z=pos.z,stackpos=STACKPOS_TOP_CREATURE}
			if isCreature(getTopCreature(getpos).uid) == TRUE then
			table.insert(monsters, getTopCreature(getpos).uid)
			end
		end
	end
	
    for i= 1, dist do
        for _, pid in ipairs(monsters) do
            if isInRange(getCreaturePosition(pid), areaPosition[1], areaPosition[2]) then
                local tp = getCreaturePosition(pid)
                local pos = getCreaturePosition(cid)
                tp.x = tp.x + math.max(math.min(1, tp.x - pos.x), -1)
                tp.y = tp.y + math.max(math.min(1, tp.y - pos.y), -1)
 
                if isWalkable(tp, true) and not getTileInfo(tp).protection then
                    doSendMagicEffect(getCreaturePosition(pid), 34)
                    doTeleportThing(pid, tp, true)
                    doTargetCombatHealth(cid, pid, COMBAT_PHYSICALDAMAGE, -dmg, -dmg, CONST_ME_BLOCKHIT)
                    doSendMagicEffect(getCreaturePosition(pid), 34)
                else    
                    doSendMagicEffect(getCreaturePosition(pid), CONST_ME_POFF)
                end
            end
        end
    end
    return true
end
 
well I did it based on second colandus' version of the script, for repel all creatures (players, npcs, monsters, ...)

Lua:
local startLevelDistance = 40 -- at this level he will get his first distance advance (2 distance), until that it will remain as minDistance
local levelPerDistance = 20 -- each 20 level he gets another distance
local minDistance = 1 -- the distance you start with
local maxDistance = 5 -- At level 140 (startLevelDistance + levelPerDistance * maxDistance) he will have his max distance (5 in this case).
 
function onCastSpell(cid, var)
    local dist = math.max(minDistance, math.min(maxDistance, math.floor((getPlayerLevel(cid) - startLevelDistance) / levelPerDistance) + minDistance))
    local areaPosition = {
        {x=getCreaturePosition(cid).x-dist, y=getCreaturePosition(cid).y-dist, z=getCreaturePosition(cid).z, stackpos = 255},
        {x=getCreaturePosition(cid).x+dist, y=getCreaturePosition(cid).y+dist, z=getCreaturePosition(cid).z, stackpos = 255}
    }
    local dmg = math.random(10, getPlayerLevel(cid)+10)
	
	local monsters = {}
	pos=getCreaturePosition(cid)
	for x=1,9 do
		for y=1,9 do
			getpos={x=pos.x-5+x,y=pos.y-5+y,z=pos.z,stackpos=STACKPOS_TOP_CREATURE}
			if isCreature(getTopCreature(getpos).uid) == TRUE then
			table.insert(monsters, getTopCreature(getpos).uid)
			end
		end
	end
	
    for i= 1, dist do
        for _, pid in ipairs(monsters) do
            if isInRange(getCreaturePosition(pid), areaPosition[1], areaPosition[2]) then
                local tp = getCreaturePosition(pid)
                local pos = getCreaturePosition(cid)
                tp.x = tp.x + math.max(math.min(1, tp.x - pos.x), -1)
                tp.y = tp.y + math.max(math.min(1, tp.y - pos.y), -1)
 
                if isWalkable(tp, true) and not getTileInfo(tp).protection then
                    doSendMagicEffect(getCreaturePosition(pid), 34)
                    doTeleportThing(pid, tp, true)
                    doTargetCombatHealth(cid, pid, COMBAT_PHYSICALDAMAGE, -dmg, -dmg, CONST_ME_BLOCKHIT)
                    doSendMagicEffect(getCreaturePosition(pid), 34)
                else    
                    doSendMagicEffect(getCreaturePosition(pid), CONST_ME_POFF)
                end
            end
        end
    end
    return true
end

any way to avoid it moving NPC's?
 
try adding
Lua:
if not isNpc
or
Lua:
if isNpc == FALSE

i dont mean to flame b/c i rlly love the spell and love that its being updated & fixed. but why dont u just add some of that stuff by default? not allowing it to move GM's or NPC's should be default to the spell. you should just add it instead of saying how to edit it.

anyway sorry about that it just doesnt make sense to me.

@up & ontopic
thanks i didnt even realize there was an isNPC function. awesome spell i love it. i dont wanna jump the gun but its perfect now.
 
well I'm the kind of person who prefers to say how to do things instead of do it for 'you',
as a proverb says (my translation is not fully correct): give a fish to a fisherman and he'll have a fish for 1 day, teach him how to fish, and he'll have fishes for all his life
 
Back
Top