Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local VARIABLE_NONE = 0
- local VARIABLE_WALL = 1
- local VARIABLE_PLAYER = 2
- local VARIABLE_DAMAGE = 3
- local wallEffect = CONST_ME_BIGPLANTS
- local playerEffect = 215
- local damageEffect = 79
- local itemId = 1498
- local delay = 2 * 1000
- local damageDelay = 0.4 * 1000
- local config = {
- {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
- {0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
- {0, 1, 3, 3, 3, 3, 3, 3, 3, 1, 0},
- {0, 1, 3, 3, 3, 3, 3, 3, 3, 1, 0},
- {0, 1, 3, 3, 3, 3, 3, 3, 3, 1, 0},
- {0, 1, 3, 3, 3, 2, 3, 3, 3, 1, 0},
- {0, 1, 3, 3, 3, 3, 3, 3, 3, 1, 0},
- {0, 1, 3, 3, 3, 3, 3, 3, 3, 1, 0},
- {0, 1, 3, 3, 3, 3, 3, 3, 3, 1, 0},
- {0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
- {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
- }
- local function doRemoveWallItem(position)
- local item = getTileItemById(position, itemId)
- if item.uid > 0 then
- if wallEffect ~= CONST_ME_NONE then
- doSendMagicEffect(position, wallEffect)
- end
- doRemoveItem(item.uid)
- end
- end
- local function canCreate(pos)
- local item = getTileThingByPos({x = pos.x, y = pos.y, z = pos.z, stackpos = STACKPOS_GROUND})
- if item.uid == 0 then
- return false
- end
- local info = getTileInfo(pos)
- if info.protection or info.nopvp then
- return false
- end
- for it = 0, info.items do
- item = getTileThingByPos({x = pos.x, y = pos.y, z = pos.z, stackpos = it})
- local floorChange = getItemInfo(item.itemid)
- if not floorChange then
- return true
- end
- for i = NORTH, NORTHEAST + 1 do
- if floorChange.floorChange[i] then
- return false
- end
- end
- end
- return true
- end
- local function doCreateWalls(position)
- for _, pos in pairs(position) do
- local item = getTileItemById(pos, itemId)
- if item.uid == 0 then
- if canCreate(pos) then
- doCreateItem(itemId, pos)
- if wallEffect ~= CONST_ME_NONE then
- doSendMagicEffect(pos, wallEffect)
- end
- addEvent(doRemoveWallItem, delay, pos)
- end
- end
- end
- end
- local function doSendEffect(position)
- if playerEffect == CONST_ME_NONE then
- return true
- end
- for _, pos in pairs(position) do
- doSendMagicEffect({x = pos.x + 3, y = pos.y + 4, z = pos.z}, playerEffect)
- end
- end
- local function canAttack(cid, target)
- if not cid then
- return true
- end
- if isNpc(target) then
- return false
- end
- if cid == target or not isCreature(target) then
- return false
- end
- if isSummon(target) and getCreatureMaster(target) == cid then
- return false
- end
- if getTilePzInfo(getThingPos(target)) then
- return false
- end
- if isPlayer(cid) then
- if isInParty(cid) then
- if isPlayer(target) and getPlayerParty(cid) == getPlayerParty(target) then
- return false
- end
- end
- if isSummon(target) then
- local master = getCreatureMaster(target)
- if master == cid then
- return false
- end
- if isInParty(cid) then
- if isPlayer(master) and getPlayerParty(cid) == getPlayerParty(master) then
- return false
- end
- end
- end
- end
- if isPlayer(target) and (isPlayerGhost(target) or getPlayerLevel(target) <= getConfigValue('protectionLevel')) then
- return false
- end
- if isSummon(cid) then
- local master = getCreatureMaster(cid)
- if master == target then
- return false
- end
- if isSummon(target) then
- target = getCreatureMaster(target)
- end
- if isPlayer(master) and isPlayer(target) and isInParty(master) and getPlayerParty(master) == getPlayerParty(target) then
- return false
- end
- end
- return true
- end
- local function doDamage(cid, position, n)
- for _, pos in pairs(position) do
- if canCreate(pos) then
- if damageEffect ~= CONST_ME_NONE then
- doSendMagicEffect(pos, damageEffect)
- end
- local target = getTopCreature(pos).uid
- if canAttack(cid, target) then
- local health = -(getCreatureMaxHealth(target) * 0.1)
- doTargetCombatHealth(0, target, COMBAT_ENERGYDAMAGE, health, health, CONST_ME_NONE)
- end
- end
- end
- if n > 0 then
- addEvent(doDamage, damageDelay, cid, position, n - 1)
- end
- end
- function onCastSpell(cid, var)
- local pos = getThingPos(cid)
- local positions = {}
- positions[VARIABLE_WALL] = {}
- positions[VARIABLE_PLAYER] = {}
- positions[VARIABLE_DAMAGE] = {}
- for py = 1, #config do
- for px = 1, #config[py] do
- local var = config[py][px]
- if var ~= VARIABLE_NONE then
- local pos = {x = pos.x + (px - ((#config - 1) / 2) - 1), y = pos.y + (py - ((#config - 1) / 2) - 1), z = pos.z}
- if var == VARIABLE_WALL then
- table.insert(positions[VARIABLE_WALL], pos)
- elseif var == VARIABLE_PLAYER then
- table.insert(positions[VARIABLE_PLAYER], pos)
- elseif var == VARIABLE_DAMAGE then
- table.insert(positions[VARIABLE_DAMAGE], pos)
- end
- end
- end
- end
- doCreatureSetNoMove(cid, true)
- doCreateWalls(positions[VARIABLE_WALL])
- doSendEffect(positions[VARIABLE_PLAYER])
- doDamage(cid, positions[VARIABLE_DAMAGE], delay / damageDelay)
- addEvent(function()
- if isPlayer(cid) then
- doCreatureSetNoMove(cid, false)
- end
- end, delay)
- return true
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement