Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function isSummon(cid)
- if not isMonster(cid) then
- return false
- end
- return getCreatureMaster(cid) ~= cid
- end
- local function canAttack(cid, target, isFriend)
- if cid == target then
- return isFriend
- end
- local _cid = {creature = isCreature(cid), player = isPlayer(cid), monster = isMonster(cid)}
- local _target = {creature = isCreature(target), player = isPlayer(target), monster = isMonster(target)}
- if not _target.creature or not _cid.creature then
- return isFriend
- end
- if getCreatureCondition(target, CONDITION_ATTRIBUTES, 169) then
- return isFriend
- end
- if _cid.monster and _target.monster then
- local master = getCreatureMaster(cid)
- if not isCreature(master) or master == getCreatureMaster(target) then
- return isFriend
- end
- end
- if isSummon(target) and getCreatureMaster(target) == cid then
- return isFriend
- end
- if getTilePzInfo(getThingPos(target)) or getTilePzInfo(getThingPos(cid)) then
- return isFriend
- end
- if _cid.player and isInParty(cid) then
- local party = getPlayerParty(cid)
- if _target.player and party and party == getPlayerParty(target) then
- return isFriend
- end
- if isSummon(target) then
- local master = getCreatureMaster(target)
- if isPlayer(master) and party == getPlayerParty(master) then
- return isFriend
- end
- end
- end
- if _target.player and isPlayerGhost(target) then
- return isFriend
- end
- if isSummon(cid) then
- local master = getCreatureMaster(cid)
- if master == target then
- return isFriend
- end
- if isSummon(target) then
- target = getCreatureMaster(target)
- end
- if isPlayer(master) and _target.player and isInParty(master) and getPlayerParty(master) == getPlayerParty(target) then
- return isFriend
- end
- end
- return not isFriend
- end
- local function stopCreature(cid, target, time)
- if canAttack(cid, target, true) then
- return false
- end
- if isMonster(target) then
- doChangeSpeed(target, -getCreatureSpeed(target))
- addEvent(function()
- if isMonster(target) then
- doChangeSpeed(target, getCreatureBaseSpeed(target))
- end
- end, time * 1000)
- else
- doCreatureSetNoMove(target, true)
- addEvent(function()
- if isPlayer(target) then
- doCreatureSetNoMove(target, false)
- end
- end, time * 1000)
- end
- end
- local combat = createCombatObject()
- setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_ENERGYDAMAGE)
- setCombatParam(combat, COMBAT_PARAM_EFFECT, 80)
- setCombatFormula(combat, COMBAT_FORMULA_LEVELMAGIC, -5.0, 0, -5.5, 0)
- function onTargetCombat(cid, target)
- return stopCreature(cid, target, 2)
- end
- arr = {
- {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
- {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
- {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
- {0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0},
- {0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0},
- {0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0},
- {0, 0, 1, 1, 1, 2, 1, 1, 1, 0, 0},
- {0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0},
- {0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0},
- {0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0},
- {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
- {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
- {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
- }
- local area = createCombatArea(arr)
- setCombatArea(combat, area)
- setCombatCallback(combat, CALLBACK_PARAM_TARGETCREATURE, 'onTargetCombat')
- function onCastSpell(cid, var)
- if not isPlayer(cid) then
- return doCombat(cid, combat, var)
- end
- return doCombat(cid, combat, var)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement