• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Lua Distance Scatter Weapon -Need Fixed-

RosOT

Who am i?
Joined
Feb 12, 2013
Messages
714
Reaction score
137
Location
Canada
Well, The scatter part works but it hits really low i hit ruffly 1-13 Damage Should be based on skills and level.
The test character was lvl 11 distance 35. And when ever it does not scatter it does not hit and its kinda annoying.

PHP:
function onGetPlayerMinMaxValues(cid, weaponSkill, weaponAttack, attackStrength)
    local attack = 25
    local skill = getPlayerSkill(cid, CONST_SKILL_DISTANCE)
    local level = getPlayerLevel(cid)
    local damage = -(attack / 20 * skill * 5 + attack + level / 10) / 10 * 1

    return 0, damage
end
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_BLOCKARMOR, 1)
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_BLOCKHIT)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_SPEAR)
setCombatCallback(combat, CALLBACK_PARAM_SKILLVALUE, "onGetPlayerMinMaxValues")

local manaNeededPerTarget = 0
local hitExtraTargets = 4 -- number of extra targets, so it should attack our target + X other monsters/players
local hitExtraTargetsInRange = 2 -- distance to 'extra target' from our target


function onUseWeapon(cid, var)
local ret = doCombat(cid, combat, var)
if(ret == LUA_ERROR) then
return LUA_ERROR
end
local manaSpent = manaNeededPerTarget
local target = variantToNumber(var)
local hitplayers = false
if(target ~= 0) then
if(isPlayer(target)) then
hitplayers = true
end
local otherTargets = getSpectators(getCreaturePosition(target), hitExtraTargetsInRange, hitExtraTargetsInRange, false)
if(#otherTargets > 0) then
local i = 1
while(i ~= #otherTargets) do
local pid = otherTargets
if(isNpc(pid) or pid == cid or pid == target or (isPlayer(pid) and (not hitplayers or getTileInfo(getCreaturePosition(pid)).protection))) then
table.remove(otherTargets, i)
else
i = i + 1
end
end
end
for i = 1, hitExtraTargets do
if(#otherTargets > 0 and getCreatureMana(cid) >= manaSpent + manaNeededPerTarget) then
local randomId = math.random(1, #otherTargets)
local nowHit = otherTargets[randomId]
table.remove(otherTargets, randomId)
ret = doCombat(cid, combat, numberToVariant(nowHit))
if(ret ~= LUA_ERROR) then
manaSpent = manaSpent + manaNeededPerTarget
doSendAnimatedText(getPlayerPosition(cid),"Scatter", TEXTCOLOR_YELLOW)
end
else
break
end
end
end
doPlayerAddSpentMana(cid, manaSpent)
doCreatureAddMana(cid, -manaSpent)
return true
end
 
Back
Top