Cornwallis
Member
- Joined
- Jan 3, 2010
- Messages
- 480
- Reaction score
- 16
So basically I'm trying to use getDistanceBetween(firstPosition, secondPosition) to set a range, but when I attack with the weapon it acts as if it's not there, it just trains fist fighting. No errors in console, just not working. I deleted the range="" from items.xml, which could be the reason.
LUA:
function onUseWeapon(cid, var)
local position = getCreaturePosition(cid)
local target = variantToNumber(var)
local playerTarget = getCreatureTarget(cid)
local level = getPlayerLevel(cid)
if(target ~= 0) then
if (getPlayerVocation(cid) == 1 and getDistanceBetween(getCreaturePosition(cid), getCreaturePosition(playerTarget) <= 4) then
local dmgMin = (300 + (level * 1.5))
local dmgMax = (350 + (level * 1.8))
ret = doTargetCombatHealth(cid, playerTarget, COMBAT_PHYSICALDAMAGE, -dmgMin, -dmgMax, CONST_ME_TELEPORT) and doSendDistanceShoot(position, getCreaturePosition(playerTarget), CONST_ANI_ENERGYBALL)
end
if (getPlayerVocation(cid) == 2 and getDistanceBetween(getCreaturePosition(cid), getCreaturePosition(playerTarget) <= 4) then
local dmgMin = (300 + (level * 1.5))
local dmgMax = (350 + (level * 1.8))
ret = doTargetCombatHealth(cid, playerTarget, COMBAT_PHYSICALDAMAGE, -dmgMin, -dmgMax, CONST_ME_SMALLPLANTS) and doSendDistanceShoot(position, getCreaturePosition(playerTarget), CONST_ANI_POISON)
end
if (getPlayerVocation(cid) == 3 and getDistanceBetween(getCreaturePosition(cid), getCreaturePosition(playerTarget) <= 7) then
local dmgMin = (260 + (level * 2.1))
local dmgMax = (360 + (level * 2.3))
ret = doTargetCombatHealth(cid, playerTarget, COMBAT_PHYSICALDAMAGE, -dmgMin, -dmgMax, CONST_ME_HOLYDAMAGE) and doSendDistanceShoot(position, getCreaturePosition(playerTarget), CONST_ANI_SMALLHOLY)
end
if (getPlayerVocation(cid) == 4 and getDistanceBetween(getCreaturePosition(cid), getCreaturePosition(playerTarget) <= 2) then
local dmgMin = (310 +(level * 2.7))
local dmgMax = (420 +(level * 3.2))
ret = doTargetCombatHealth(cid, playerTarget, COMBAT_PHYSICALDAMAGE, -dmgMin, -dmgMax, CONST_ME_GROUNDSHAKER) and doSendDistanceShoot(position, getCreaturePosition(playerTarget), CONST_ANI_SMALLEARTH)
end
end
return ret
end