warriorfrog
Active Member
- Joined
- Jul 29, 2015
- Messages
- 334
- Reaction score
- 35
I found this two spells that push and pull:
pull.lua
push.lua
but there are two problems making this so much OP and idk how to adjust
1- PUSH/PULL only one time, if the creature is 1 sqm on right 3 times, it should be only one
2- how to don't allow the push/pull if there is a item on tile like honeyflower or parcel on target tile position?
pull.lua
Code:
local function doPullCreature(target, cid)
if target > 0 then
if not isNpc(target) then
local position = getThingPosition(cid)
local fromPosition = getThingPosition(target)
local x = ((fromPosition.x - position.x) < 0 and 1 or ((fromPosition.x - position.x) == 0 and 0 or -1))
local y = ((fromPosition.y - position.y) < 0 and 1 or ((fromPosition.y - position.y) == 0 and 0 or -1))
local toPosition = {x = fromPosition.x + x, y = fromPosition.y + y, z = fromPosition.z}
if doTileQueryAdd(target, toPosition) == 1 and getTileInfo(toPosition).house == false then
doTeleportThing(target, toPosition, true)
end
end
end
end
local spell = {}
spell.config = {
[3] = {
damageType = 1,
areaEffect = 2,
area = {
{0, 0, 1, 1, 1, 0, 0},
{0, 1, 1, 1, 1, 1, 0},
{1, 1, 1, 1, 1, 1, 1},
{1, 1, 1, 3, 1, 1, 1},
{1, 1, 1, 1, 1, 1, 1},
{0, 1, 1, 1, 1, 1, 0},
{0, 0, 1, 1, 1, 0, 0}
}
},
[2] = {
damageType = 1,
areaEffect = 2,
area = {
{0, 0, 0, 0, 0, 0, 0},
{0, 0, 1, 1, 1, 0, 0},
{0, 1, 1, 1, 1, 1, 0},
{0, 1, 1, 3, 1, 1, 0},
{0, 1, 1, 1, 1, 1, 0},
{0, 0, 1, 1, 1, 0, 0},
{0, 0, 0, 0, 0, 0, 0}
}
},
[1] = {
damageType = 1,
areaEffect = 2,
area = {
{0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0},
{0, 0, 1, 1, 1, 0, 0},
{0, 0, 1, 3, 1, 0, 0},
{0, 0, 1, 1, 1, 0, 0},
{0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0}
}
}
}
spell.combats = {}
for _, config in ipairs(spell.config) do
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, config.damageType)
setCombatParam(combat, COMBAT_PARAM_EFFECT, config.areaEffect)
function onTargetCreature(cid, target)
doPullCreature(target, cid)
end
setCombatCallback(combat, CALLBACK_PARAM_TARGETCREATURE, "onTargetCreature")
setCombatArea(combat, createCombatArea(config.area))
table.insert(spell.combats, combat)
end
function onCastSpell(cid, var)
for n = 1, #spell.combats do
addEvent(doCombat, (n * 150) - 150, cid, spell.combats[n], var)
end
return true
end
push.lua
Code:
local function doPushCreature(target, cid)
if target > 0 then
if not isNpc(target) then
local position = getThingPosition(cid)
local fromPosition = getThingPosition(target)
local x = ((fromPosition.x - position.x) < 0 and -1 or ((fromPosition.x - position.x) == 0 and 0 or 1))
local y = ((fromPosition.y - position.y) < 0 and -1 or ((fromPosition.y - position.y) == 0 and 0 or 1))
local toPosition = {x = fromPosition.x + x, y = fromPosition.y + y, z = fromPosition.z}
if doTileQueryAdd(target, toPosition) == 1 and getTileInfo(toPosition).house == false then
doTeleportThing(target, toPosition, true)
end
end
end
end
local spell = {}
spell.config = {
[3] = {
damageType = 1,
areaEffect = 2,
area = {
{0, 0, 1, 1, 1, 0, 0},
{0, 1, 1, 1, 1, 1, 0},
{1, 1, 1, 1, 1, 1, 1},
{1, 1, 1, 3, 1, 1, 1},
{1, 1, 1, 1, 1, 1, 1},
{0, 1, 1, 1, 1, 1, 0},
{0, 0, 1, 1, 1, 0, 0}
}
},
[2] = {
damageType = 1,
areaEffect = 2,
area = {
{0, 0, 0, 0, 0, 0, 0},
{0, 0, 1, 1, 1, 0, 0},
{0, 1, 1, 1, 1, 1, 0},
{0, 1, 1, 3, 1, 1, 0},
{0, 1, 1, 1, 1, 1, 0},
{0, 0, 1, 1, 1, 0, 0},
{0, 0, 0, 0, 0, 0, 0}
}
},
[1] = {
damageType = 1,
areaEffect = 2,
area = {
{0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0},
{0, 0, 1, 1, 1, 0, 0},
{0, 0, 1, 3, 1, 0, 0},
{0, 0, 1, 1, 1, 0, 0},
{0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0}
}
}
}
spell.combats = {}
for _, config in ipairs(spell.config) do
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, config.damageType)
setCombatParam(combat, COMBAT_PARAM_EFFECT, config.areaEffect)
function onTargetCreature(cid, target)
doPushCreature(target, cid)
end
setCombatCallback(combat, CALLBACK_PARAM_TARGETCREATURE, "onTargetCreature")
setCombatArea(combat, createCombatArea(config.area))
table.insert(spell.combats, combat)
end
function onCastSpell(cid, var)
for n = 1, #spell.combats do
addEvent(doCombat, (n * 150) - 150, cid, spell.combats[n], var)
end
return true
end
but there are two problems making this so much OP and idk how to adjust
1- PUSH/PULL only one time, if the creature is 1 sqm on right 3 times, it should be only one
2- how to don't allow the push/pull if there is a item on tile like honeyflower or parcel on target tile position?