• 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!

Arrow attack dont miss a lot

zabuzo

Well-Known Member
Joined
Jun 10, 2016
Messages
237
Reaction score
54
My arrow script is missing so much shots...
I don't want it, how to fix?

arrow.lua
Code:
local function autoRechargeAmmo(cid)
    local ammo_in_slot = getPlayerSlotItem(cid, CONST_SLOT_AMMO).uid
    if ammo_in_slot == 0 then
        return false
    end
    ammo_in_slot = getPlayerSlotItem(cid, CONST_SLOT_AMMO).type
    if ammo_in_slot ~= 1 then
        return false
    end
   
    local ammo_itemid = getPlayerSlotItem(cid, CONST_SLOT_AMMO).itemid
    local ammo_count = getPlayerItemCount(cid, ammo_itemid) - 1
    ammo_count = ammo_count >= 100 and 100 or ammo_count
    addEvent (
        function ()
            doPlayerRemoveItem(cid, ammo_itemid, ammo_count)
            doPlayerAddItem(cid, ammo_itemid, ammo_count)
        end, 1
    )
    return true
end
 
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_BLOCKARMOR, 1)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, 2)
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
 
function onGetFormulaValues(cid, level, skill, attack, factor)
    -- get attack mode
    local damagebase_min = wbdmg_distance_min
    local damagebase_max = wbdmg_distance_max
    if factor == 1.0 then -- player_fight_mode = offensive
        damagebase_min = damagebase_min * 3
        damagebase_max = damagebase_max * 3
    elseif factor == 2.0 then -- player_fight_mode = defensive
        damagebase_min = damagebase_min * 1
        damagebase_max = damagebase_max * 1
    else  -- player_fight_mode = balanced
        damagebase_min = damagebase_min * 2
        damagebase_max = damagebase_max * 2
    end
    -- get weapon attack (bow/crossbow)
    local item1 = getPlayerSlotItem(cid, CONST_SLOT_LEFT)
    local item2 = getPlayerSlotItem(cid, CONST_SLOT_RIGHT)
    local bowattack, hand1, hand2 = 0, 0, 0
    if item1.uid ~= 0 then
        hand1 = getItemInfo(item1.itemid).attack
    end
    if item2.uid ~= 0 then
        hand2 = getItemInfo(item2.itemid).attack
    end
    if hand1 > hand2 then
        bowattack = hand1
    else
        bowattack = hand2
    end
    local atktotal = bowattack + attack -- attack total = bow attack + arrow attack
    skill = getPlayerSkill(cid, SKILL_DISTANCE)
    
    local min_atk_bonus = math.ceil(math.random(6, 12))
    min = ( ((damagebase_min) * (atktotal * 9) * (skill * 3)) + min_atk_bonus ) * -0.10
    max = ( ((damagebase_max) * (atktotal * 9) * (skill * 3)) + min_atk_bonus ) * -1.00
    return min, max
end
setCombatCallback(combat, CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")
 
function onUseWeapon(cid, var)
    autoRechargeAmmo(cid)
    return doCombat(cid, combat, var)
end
 
Top