NygusDB
Advanced User
- Dołączył
- Marzec 5, 2013
- Posty
- 164
- Liczba reakcji
- 7
Witam. Oto ma?y skrypcik, dzi?ki kt?remu nasza posta? nie trafi, je?li przeciwnik jest zbyt daleko. Reszta opisana w komentarzach, my?l? ?e to zrozumia?e.
Potrzeba funkcja :
[LUA]function getTargetDistance(cid,target)
local tPos = getCreaturePosition(target)
local pPos = getCreaturePosition(cid)
local posX = pPos.x - tPos.x
if posX < 0 then
posX = posX * -1
end
local posY = pPos.y - tPos.y
local w_pos = nil
if posY < 0 then
posY = posY * -1
end
if posX == posY then
w_pos = posX
else
if posX > posY then
w_pos = posX
else
w_pos = posY
end
end
return w_pos
end[/LUA]
Czar:
[LUA]local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_ENERGYDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, 1)
setAttackFormula(combat, COMBAT_FORMULA_LEVELMAGIC, 1, 1, 10, 10)
function onCastSpell(cid, var)
-- config
-- jesli odleglosc od celu bedzie wieksza niz minDistance , zawsze nie trafi
-- jesli mniejsza, szansa wynosi odleglosc * 10
local minDistance = 4
local distanceEffect = 2 -- wyglad lecacego czaru
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
local target = getCreatureTarget(cid)
local pos = getCreaturePosition(cid)
local pos_t = getCreaturePosition(target)
local tmpX = math.random(-1,1)
local tmpY = math.random(-1,1)
local pos_T = {x=pos_t.x+tmpX, y = pos_t.y+tmpY, z = pos_t.z}
local chance = math.random(1,100)
local distance = getTargetDistance(cid,target)
local missChance = nil
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
if distance > minDistance then
missChance = 100
else
missChance = distance * 10
end
if (chance >= missChance) then
doCombat(cid,combat,var)
doSendDistanceShoot(pos, pos_t, distanceEffect)
else
doSendDistanceShoot(pos, pos_T, distanceEffect)
doSendAnimatedText(pos_t,'missed!',215)
end
end[/LUA]
Potrzeba funkcja :
[LUA]function getTargetDistance(cid,target)
local tPos = getCreaturePosition(target)
local pPos = getCreaturePosition(cid)
local posX = pPos.x - tPos.x
if posX < 0 then
posX = posX * -1
end
local posY = pPos.y - tPos.y
local w_pos = nil
if posY < 0 then
posY = posY * -1
end
if posX == posY then
w_pos = posX
else
if posX > posY then
w_pos = posX
else
w_pos = posY
end
end
return w_pos
end[/LUA]
Czar:
[LUA]local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_ENERGYDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, 1)
setAttackFormula(combat, COMBAT_FORMULA_LEVELMAGIC, 1, 1, 10, 10)
function onCastSpell(cid, var)
-- config
-- jesli odleglosc od celu bedzie wieksza niz minDistance , zawsze nie trafi
-- jesli mniejsza, szansa wynosi odleglosc * 10
local minDistance = 4
local distanceEffect = 2 -- wyglad lecacego czaru
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
local target = getCreatureTarget(cid)
local pos = getCreaturePosition(cid)
local pos_t = getCreaturePosition(target)
local tmpX = math.random(-1,1)
local tmpY = math.random(-1,1)
local pos_T = {x=pos_t.x+tmpX, y = pos_t.y+tmpY, z = pos_t.z}
local chance = math.random(1,100)
local distance = getTargetDistance(cid,target)
local missChance = nil
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
if distance > minDistance then
missChance = 100
else
missChance = distance * 10
end
if (chance >= missChance) then
doCombat(cid,combat,var)
doSendDistanceShoot(pos, pos_t, distanceEffect)
else
doSendDistanceShoot(pos, pos_T, distanceEffect)
doSendAnimatedText(pos_t,'missed!',215)
end
end[/LUA]