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

Action [Item] Quiver

sebastianraszka

New Member
Joined
Oct 22, 2007
Messages
41
Reaction score
1
Quiver v0.2 (Beta)
Quiver is an container for ammunition. It should be hold in arrow slot.
http://en.wikipedia.org/wiki/Quiver

Follow tutorial
ots\data\weapons\lib\quiver\config.lua
PHP:
--quiver system by swiatcienia/sebastianraszka owner of cilohokla ots
dofile(getDataDir() .. "weapons/lib/quiver/bows.lua")
dofile(getDataDir() .. "weapons/lib/quiver/crossbows.lua")
ots\data\weapons\lib\quiver\bows.lua
PHP:
--quiver system by swiatcienia/sebastianraszka owner of cilohokla ots
arrowNormal = createCombatObject()
setCombatParam(arrowNormal, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(arrowNormal, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ARROW)
 function onGetFormulaArrowNormal(cid, skill) return onGetFormulaDefault(cid, skill) end
setCombatCallback(arrowNormal, CALLBACK_PARAM_SKILLVALUE, "onGetFormulaArrowNormal")

arrowFire = createCombatObject()
setCombatParam(arrowFire, COMBAT_PARAM_TYPE, COMBAT_FIREDAMAGE);
setCombatParam(arrowFire, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_FLAMMINGARROW)
 function onGetFormulaArrowFire(cid, skill) return onGetFormulaDefault(cid, skill) end
setCombatCallback(arrowFire, CALLBACK_PARAM_SKILLVALUE, "onGetFormulaArrowFire")

arrowIce = createCombatObject()
setCombatParam(arrowIce, COMBAT_PARAM_TYPE, COMBAT_ICEDAMAGE);
setCombatParam(arrowIce, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_SHIVERARROW)
 function onGetFormulaArrowIce(cid, skill) return onGetFormulaDefault(cid, skill) end
setCombatCallback(arrowIce, CALLBACK_PARAM_SKILLVALUE, "onGetFormulaArrowIce")

arrowEarth = createCombatObject()
setCombatParam(arrowEarth, COMBAT_PARAM_TYPE, COMBAT_EARTHDAMAGE);
setCombatParam(arrowEarth, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_EARTHARROW)
 function onGetFormulaArrowEarth(cid, skill) return onGetFormulaDefault(cid, skill) end
setCombatCallback(arrowEarth, CALLBACK_PARAM_SKILLVALUE, "onGetFormulaArrowEarth")

arrowEnergy = createCombatObject()
setCombatParam(arrowEnergy, COMBAT_PARAM_TYPE, COMBAT_ENERGYDAMAGE);
setCombatParam(arrowEnergy, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_FLASHARROW)
 function onGetFormulaArrowEnergy(cid, skill) return onGetFormulaDefault(cid, skill) end
setCombatCallback(arrowEnergy, CALLBACK_PARAM_SKILLVALUE, "onGetFormulaArrowEnergy")

arrowBurst = createCombatObject()
setCombatParam(arrowBurst, COMBAT_PARAM_BLOCKARMOR, 1)
setCombatParam(arrowBurst, COMBAT_PARAM_BLOCKSHIELD, 1)
setCombatParam(arrowBurst, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(arrowBurst, COMBAT_PARAM_EFFECT, CONST_ME_FIREAREA)
setCombatParam(arrowBurst, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_BURSTARROW)
function onGetFormulaArrowBurst(cid, skill) return onGetFormulaDefault(cid, skill) end
setCombatCallback(arrowBurst, CALLBACK_PARAM_SKILLVALUE, "onGetFormulaArrowBurst")

local area = createCombatArea( {     {1, 1, 1},
                                    {1, 3, 1},
                                    {1, 1, 1} } )
setCombatArea(arrowBurst, area)

arrowPoison = createCombatObject()
setCombatParam(arrowPoison, COMBAT_PARAM_BLOCKARMOR, 1)
setCombatParam(arrowPoison, COMBAT_PARAM_TYPE, COMBAT_POISONDAMAGE)
setCombatParam(arrowPoison, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_POISONARROW)
function onGetFormulaArrowPoison(cid, skill) return onGetFormulaDefault(cid, skill) end
setCombatCallback(arrowBurst, CALLBACK_PARAM_SKILLVALUE, "onGetFormulaArrowPoison")

arrowPoison_condition = createConditionObject(CONDITION_POISON)
setConditionParam(arrowPoison_condition, CONDITION_PARAM_DELAYED, 1)
addDamageCondition(arrowPoison_condition, 10, 2000, -1)
setCombatCondition(arrowPoison, arrowPoison_condition)

QuiverAmmoConfig[AMMO_ARROW]={--AMMO_ARROW
        [2544] = {active=1,atk=25,atk_type=arrowNormal},
        [7364] = {active=1,atk=28,atk_type=arrowNormal},--sniper
        [7365] = {active=1,atk=38,atk_type=arrowNormal},--onyx
        [2546] = {active=1,atk=22,atk_type=arrowBurst},
        [2545] = {active=1,atk=28,atk_type=arrowPoison},
        [7840] = {active=1,atk=25,atk_type=arrowFire},
        [7839] = {active=1,atk=25,atk_type=arrowIce},
        [7850] = {active=1,atk=25,atk_type=arrowEarth},
        [7838] = {active=1,atk=25,atk_type=arrowEnergy}
    }
   
DistanceConfig[2456] = {active=1,extra_atk=0,ammo=AMMO_ARROW}--bow
ots\data\weapons\lib\quiver\crossbows.lua
PHP:
--quiver system by swiatcienia/sebastianraszka owner of cilohokla ots
boltNormal = createCombatObject()
setCombatParam(boltNormal, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(boltNormal, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_BOLT)
 function onGetFormulaBoltNormal(cid, skill) return onGetFormulaDefault(cid, skill) end
setCombatCallback(boltNormal, CALLBACK_PARAM_SKILLVALUE, "onGetFormulaBoltNormal")

boltPower = createCombatObject()
setCombatParam(boltPower, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(boltPower, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_POWERBOLT)
 function onGetFormulaBoltPower(cid, skill) return onGetFormulaDefault(cid, skill) end
setCombatCallback(boltPower, CALLBACK_PARAM_SKILLVALUE, "onGetFormulaBoltPower")

boltInfernal = createCombatObject()
setCombatParam(boltInfernal, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(boltInfernal, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_INFERNALBOLT)
 function onGetFormulaBoltInfernal(cid, skill) return onGetFormulaDefault(cid, skill) end
setCombatCallback(boltInfernal, CALLBACK_PARAM_SKILLVALUE, "onGetFormulaBoltInfernal")

boltPiercing = createCombatObject()
setCombatParam(boltPiercing, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(boltPiercing, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_PIERCINGBOLT)
 function onGetFormulaBoltPiercing(cid, skill) return onGetFormulaDefault(cid, skill) end
setCombatCallback(boltPiercing, CALLBACK_PARAM_SKILLVALUE, "onGetFormulaBoltPiercing")

QuiverAmmoConfig[AMMO_BOLT]={--AMMO_BOLT
        [2543] = {active=1,atk=30,atk_type=boltNormal},
        [2547] = {active=1,atk=40,atk_type=boltPower},
        [6529] = {active=1,atk=43,atk_type=boltInfernal},
        [7363] = {active=1,atk=33,atk_type=boltPiercing},
    }
   
DistanceConfig[2455] = {active=1,extra_atk=0,ammo=AMMO_BOLT}--crossbow
ots\data\weapons\lib\quiver_config.lua *Add this
PHP:
--quiver system by swiatcienia/sebastianraszka owner of cilohokla ots
--config holders
QuiverConfig={}
QuiverAmmoConfig={}
DistanceConfig={}

--constant
AMMO_ARROW=1
AMMO_BOLT=2

--quivers
QuiverConfig = {
    [10047] = {active=1,extra_atk=5},
    [10048] = {active=1,extra_atk=10},
    [10049] = {active=1,extra_atk=15},
    [10050] = {active=1,extra_atk=20},
    [10051] = {active=1,extra_atk=25},
    [10052] = {active=1,extra_atk=35},
}
ots\data\weapons\lib\quiver_functions.lua
PHP:
--quiver system by swiatcienia/sebastianraszka owner of cilohokla ots
function onGetFormulaDefault(cid, skill)
 local aitem,quiver = getPlayerAmmo(cid)
 local witem = getPlayerWeapon(cid, TRUE)
 local wconfig = DistanceConfig[witem.itemid]
 local ammolist = QuiverAmmoConfig[wconfig.ammo]
 local level = getPlayerLevel(cid)
 local atk= ammolist[aitem.itemid].atk
 local atkx=wconfig.extra_atk
 if (quiver~=nil) then atkx=atkx+quiver.extra_atk end
 atk=atk+atkx
 --doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, atk)
    min = level*0.2;
    max = (0.85*skill*(atk)+4*skill+level*2)*0.1;
    return -min, -max
end


function getPlayerAmmo(cid)
    local witem = getPlayerWeapon(cid, TRUE)
        local wconfig = DistanceConfig[witem.itemid]
        local ammolist = QuiverAmmoConfig[wconfig.ammo]
    local aslot = getPlayerSlotItem(cid, 10)
    if (aslot.uid==0) then
    return LUA_ERROR
    end
    local aitem = aslot
    local quiver = QuiverConfig[aslot.itemid]
    if ((quiver ~= nil) and (quiver.active == 1)) then
        local aitems,iitems = getAllContainerItems(cid, aslot, ammolist)
            if (iitems==0) then
            return LUA_ERROR
            end
        aitem = aitems[1] -- get first item on the list change 1 to iitems to get the last one
        return aitem,quiver
    else
        if ((ammolist[aslot.itemid] == nil) or (ammolist[aslot.itemid].active ~= 1)) then
        return LUA_ERROR
        end
    end
   
   
    return aitem,nil
end

function executeShoot(cid, var, weapon, ammo, quiver)
        local wconfig = DistanceConfig[weapon.itemid]
        local aconfig = QuiverAmmoConfig[wconfig.ammo][ammo.itemid]
        if (wconfig==nil) then return LUA_ERROR end
        if (aconfig==nil) then return LUA_ERROR end
        local ret = doCombat(cid, aconfig.atk_type, var)
        if(ret ~= LUA_NO_ERROR) then
            return LUA_ERROR
        end
        if ((aconfig.atk_type2~=nil)and(aconfig.atk_type2~=FALSE)) then
            ret = doCombat(cid, aconfig.atk_type2, var)
            if(ret ~= LUA_NO_ERROR) then
                return LUA_ERROR
            end
        end
    return ret
end
ots\data\weapons\lib\weapons.lua
PHP:
--quiver system by swiatcienia/sebastianraszka owner of cilohokla ots
dofile(getDataDir() .. "weapons/lib/quiver_config.lua")
dofile(getDataDir() .. "weapons/lib/quiver/config.lua")
dofile(getDataDir() .. "weapons/lib/quiver_functions.lua")
ots\data\weapons\scripts\quiver.lua
PHP:
function onUseWeapon(cid, var)
--quiver system by swiatcienia/sebastianraszka owner of cilohokla ots
    local aitem,quiver = getPlayerAmmo(cid)
    local witem = getPlayerWeapon(cid, TRUE)
    if (aitem==LUA_ERROR) then return LUA_ERROR end
    if (executeShoot(cid, var, witem, aitem, quiver)==LUA_ERROR) then return LUA_ERROR end
    doRemoveItem(aitem.uid,1)
    return ret
end
Add this at the end of GLOBAL functions
PHP:
    function getAllContainerItems(cid, containeritem, itemlist)
        --function by swiatcienia/sebastianraszka owner of cilohokla ots
            local container = containeritem.uid
            local size=getContainerSize(container)
            local items = {}
            local i = 0
            local i2 = 0
            if (itemlist==nil) then
                while(i2 < (size)) do
                table.insert(items, getContainerItem(container, i2))
                i2 = i2 + 1
                end
                i=i2
            else
                while(i2 < (size)) do
                local citem=getContainerItem(container, i2)
                    if ((itemlist[citem.itemid] ~= nil) and (itemlist[citem.itemid].active == 1)) then
                    table.insert(items, citem)
                    i = i + 1
                    end
                i2 = i2 + 1
                end
            end
        return items , i
    end
Add this to weapons.xml
PHP:
     <!-- Quiver -->
    <distance id="2455" event="script" value="quiver.lua"/>
    <distance id="2456" event="script" value="quiver.lua"/>
And comment all the arrow and bolt scripts


You need to do this for all distance weapons
items.xml
add this in all distance weapons and delete ammo type from it
PHP:
        <attribute key="attack" value="15"/>
example bow:
PHP:
    <item id="2456" article="a" name="bow">
        <attribute key="weight" value="3100"/>
        <attribute key="attack" value="15"/>
        <!--<attribute key="hitChance" value="90"/> could use but not needed-->
        <attribute key="weaponType" value="distance"/>
        <attribute key="slotType" value="two-handed"/>
        <!--<attribute key="ammoType" value="arrow"/> delete this*you have to-->
        <attribute key="range" value="6"/>
    </item>

To Do list:
Multiple bow (different extra attack)
All arrows (different extra attack,type,extra attack2,type2)
Formulas
Xbow + Bolts
Configuration [Global] (attack types, bow, arrows, xbow, bolts)
Final version will include:
Configuration for bow, arrow, xbow, bolts
All bow and xbow types
Attack types: normal, ice, earth, fire, energy
Attack types2: posion, burn ...
Extra:
Gun, ammo for guns (custom items)
 
Last edited:
quiver is a container for arrows and bolt.
As there is no quiver in tibia I've used custom items.
For now there are all arrow and bolt.
And bow and Crossbow.
Bows and Crossbow can add extra attack to normal arrow attack and quiver can also add attack to them.
In file: ots\data\weapons\lib\quiver_config.lua
there is configuration for quivers
and at the end of:
ots\data\weapons\lib\quiver\bows.lua
and
ots\data\weapons\lib\quiver\crossbows.lua
there is configuration for bows/crossbows
This script also allows custom bow/crossbow/other distance weapons.
Custom quivers and custom ammunition.
Is you don't want quiver as custom item just set it to some container in quiver configuration file.
 
Quiver v0.2 (Beta)
Quiver is an container for ammunition. It should be hold in arrow slot.
Quiver - Wikipedia (http://en.wikipedia.org/wiki/Quiver)

Follow tutorial
ots\data\weapons\lib\quiver\config.lua
PHP:
--quiver system by swiatcienia/sebastianraszka owner of cilohokla ots
dofile(getDataDir() .. "weapons/lib/quiver/bows.lua")
dofile(getDataDir() .. "weapons/lib/quiver/crossbows.lua")
ots\data\weapons\lib\quiver\bows.lua
PHP:
--quiver system by swiatcienia/sebastianraszka owner of cilohokla ots
arrowNormal = createCombatObject()
setCombatParam(arrowNormal, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(arrowNormal, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ARROW)
 function onGetFormulaArrowNormal(cid, skill) return onGetFormulaDefault(cid, skill) end
setCombatCallback(arrowNormal, CALLBACK_PARAM_SKILLVALUE, "onGetFormulaArrowNormal")

arrowFire = createCombatObject()
setCombatParam(arrowFire, COMBAT_PARAM_TYPE, COMBAT_FIREDAMAGE);
setCombatParam(arrowFire, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_FLAMMINGARROW)
 function onGetFormulaArrowFire(cid, skill) return onGetFormulaDefault(cid, skill) end
setCombatCallback(arrowFire, CALLBACK_PARAM_SKILLVALUE, "onGetFormulaArrowFire")

arrowIce = createCombatObject()
setCombatParam(arrowIce, COMBAT_PARAM_TYPE, COMBAT_ICEDAMAGE);
setCombatParam(arrowIce, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_SHIVERARROW)
 function onGetFormulaArrowIce(cid, skill) return onGetFormulaDefault(cid, skill) end
setCombatCallback(arrowIce, CALLBACK_PARAM_SKILLVALUE, "onGetFormulaArrowIce")

arrowEarth = createCombatObject()
setCombatParam(arrowEarth, COMBAT_PARAM_TYPE, COMBAT_EARTHDAMAGE);
setCombatParam(arrowEarth, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_EARTHARROW)
 function onGetFormulaArrowEarth(cid, skill) return onGetFormulaDefault(cid, skill) end
setCombatCallback(arrowEarth, CALLBACK_PARAM_SKILLVALUE, "onGetFormulaArrowEarth")

arrowEnergy = createCombatObject()
setCombatParam(arrowEnergy, COMBAT_PARAM_TYPE, COMBAT_ENERGYDAMAGE);
setCombatParam(arrowEnergy, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_FLASHARROW)
 function onGetFormulaArrowEnergy(cid, skill) return onGetFormulaDefault(cid, skill) end
setCombatCallback(arrowEnergy, CALLBACK_PARAM_SKILLVALUE, "onGetFormulaArrowEnergy")

arrowBurst = createCombatObject()
setCombatParam(arrowBurst, COMBAT_PARAM_BLOCKARMOR, 1)
setCombatParam(arrowBurst, COMBAT_PARAM_BLOCKSHIELD, 1)
setCombatParam(arrowBurst, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(arrowBurst, COMBAT_PARAM_EFFECT, CONST_ME_FIREAREA)
setCombatParam(arrowBurst, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_BURSTARROW)
function onGetFormulaArrowBurst(cid, skill) return onGetFormulaDefault(cid, skill) end
setCombatCallback(arrowBurst, CALLBACK_PARAM_SKILLVALUE, "onGetFormulaArrowBurst")

local area = createCombatArea( {     {1, 1, 1},
                                    {1, 3, 1},
                                    {1, 1, 1} } )
setCombatArea(arrowBurst, area)

arrowPoison = createCombatObject()
setCombatParam(arrowPoison, COMBAT_PARAM_BLOCKARMOR, 1)
setCombatParam(arrowPoison, COMBAT_PARAM_TYPE, COMBAT_POISONDAMAGE)
setCombatParam(arrowPoison, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_POISONARROW)
function onGetFormulaArrowPoison(cid, skill) return onGetFormulaDefault(cid, skill) end
setCombatCallback(arrowBurst, CALLBACK_PARAM_SKILLVALUE, "onGetFormulaArrowPoison")

arrowPoison_condition = createConditionObject(CONDITION_POISON)
setConditionParam(arrowPoison_condition, CONDITION_PARAM_DELAYED, 1)
addDamageCondition(arrowPoison_condition, 10, 2000, -1)
setCombatCondition(arrowPoison, arrowPoison_condition)

QuiverAmmoConfig[AMMO_ARROW]={--AMMO_ARROW
        [2544] = {active=1,atk=25,atk_type=arrowNormal},
        [7364] = {active=1,atk=28,atk_type=arrowNormal},--sniper
        [7365] = {active=1,atk=38,atk_type=arrowNormal},--onyx
        [2546] = {active=1,atk=22,atk_type=arrowBurst},
        [2545] = {active=1,atk=28,atk_type=arrowPoison},
        [7840] = {active=1,atk=25,atk_type=arrowFire},
        [7839] = {active=1,atk=25,atk_type=arrowIce},
        [7850] = {active=1,atk=25,atk_type=arrowEarth},
        [7838] = {active=1,atk=25,atk_type=arrowEnergy}
    }
  
DistanceConfig[2456] = {active=1,extra_atk=0,ammo=AMMO_ARROW}--bow
ots\data\weapons\lib\quiver\crossbows.lua
PHP:
--quiver system by swiatcienia/sebastianraszka owner of cilohokla ots
boltNormal = createCombatObject()
setCombatParam(boltNormal, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(boltNormal, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_BOLT)
 function onGetFormulaBoltNormal(cid, skill) return onGetFormulaDefault(cid, skill) end
setCombatCallback(boltNormal, CALLBACK_PARAM_SKILLVALUE, "onGetFormulaBoltNormal")

boltPower = createCombatObject()
setCombatParam(boltPower, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(boltPower, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_POWERBOLT)
 function onGetFormulaBoltPower(cid, skill) return onGetFormulaDefault(cid, skill) end
setCombatCallback(boltPower, CALLBACK_PARAM_SKILLVALUE, "onGetFormulaBoltPower")

boltInfernal = createCombatObject()
setCombatParam(boltInfernal, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(boltInfernal, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_INFERNALBOLT)
 function onGetFormulaBoltInfernal(cid, skill) return onGetFormulaDefault(cid, skill) end
setCombatCallback(boltInfernal, CALLBACK_PARAM_SKILLVALUE, "onGetFormulaBoltInfernal")

boltPiercing = createCombatObject()
setCombatParam(boltPiercing, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(boltPiercing, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_PIERCINGBOLT)
 function onGetFormulaBoltPiercing(cid, skill) return onGetFormulaDefault(cid, skill) end
setCombatCallback(boltPiercing, CALLBACK_PARAM_SKILLVALUE, "onGetFormulaBoltPiercing")

QuiverAmmoConfig[AMMO_BOLT]={--AMMO_BOLT
        [2543] = {active=1,atk=30,atk_type=boltNormal},
        [2547] = {active=1,atk=40,atk_type=boltPower},
        [6529] = {active=1,atk=43,atk_type=boltInfernal},
        [7363] = {active=1,atk=33,atk_type=boltPiercing},
    }
  
DistanceConfig[2455] = {active=1,extra_atk=0,ammo=AMMO_BOLT}--crossbow
ots\data\weapons\lib\quiver_config.lua *Add this
PHP:
--quiver system by swiatcienia/sebastianraszka owner of cilohokla ots
--config holders
QuiverConfig={}
QuiverAmmoConfig={}
DistanceConfig={}

--constant
AMMO_ARROW=1
AMMO_BOLT=2

--quivers
QuiverConfig = {
    [10047] = {active=1,extra_atk=5},
    [10048] = {active=1,extra_atk=10},
    [10049] = {active=1,extra_atk=15},
    [10050] = {active=1,extra_atk=20},
    [10051] = {active=1,extra_atk=25},
    [10052] = {active=1,extra_atk=35},
}
ots\data\weapons\lib\quiver_functions.lua
PHP:
--quiver system by swiatcienia/sebastianraszka owner of cilohokla ots
function onGetFormulaDefault(cid, skill)
 local aitem,quiver = getPlayerAmmo(cid)
 local witem = getPlayerWeapon(cid, TRUE)
 local wconfig = DistanceConfig[witem.itemid]
 local ammolist = QuiverAmmoConfig[wconfig.ammo]
 local level = getPlayerLevel(cid)
 local atk= ammolist[aitem.itemid].atk
 local atkx=wconfig.extra_atk
 if (quiver~=nil) then atkx=atkx+quiver.extra_atk end
 atk=atk+atkx
 --doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, atk)
    min = level*0.2;
    max = (0.85*skill*(atk)+4*skill+level*2)*0.1;
    return -min, -max
end


function getPlayerAmmo(cid)
    local witem = getPlayerWeapon(cid, TRUE)
        local wconfig = DistanceConfig[witem.itemid]
        local ammolist = QuiverAmmoConfig[wconfig.ammo]
    local aslot = getPlayerSlotItem(cid, 10)
    if (aslot.uid==0) then
    return LUA_ERROR
    end
    local aitem = aslot
    local quiver = QuiverConfig[aslot.itemid]
    if ((quiver ~= nil) and (quiver.active == 1)) then
        local aitems,iitems = getAllContainerItems(cid, aslot, ammolist)
            if (iitems==0) then
            return LUA_ERROR
            end
        aitem = aitems[1] -- get first item on the list change 1 to iitems to get the last one
        return aitem,quiver
    else
        if ((ammolist[aslot.itemid] == nil) or (ammolist[aslot.itemid].active ~= 1)) then
        return LUA_ERROR
        end
    end
  
  
    return aitem,nil
end

function executeShoot(cid, var, weapon, ammo, quiver)
        local wconfig = DistanceConfig[weapon.itemid]
        local aconfig = QuiverAmmoConfig[wconfig.ammo][ammo.itemid]
        if (wconfig==nil) then return LUA_ERROR end
        if (aconfig==nil) then return LUA_ERROR end
        local ret = doCombat(cid, aconfig.atk_type, var)
        if(ret ~= LUA_NO_ERROR) then
            return LUA_ERROR
        end
        if ((aconfig.atk_type2~=nil)and(aconfig.atk_type2~=FALSE)) then
            ret = doCombat(cid, aconfig.atk_type2, var)
            if(ret ~= LUA_NO_ERROR) then
                return LUA_ERROR
            end
        end
    return ret
end
ots\data\weapons\lib\weapons.lua
PHP:
--quiver system by swiatcienia/sebastianraszka owner of cilohokla ots
dofile(getDataDir() .. "weapons/lib/quiver_config.lua")
dofile(getDataDir() .. "weapons/lib/quiver/config.lua")
dofile(getDataDir() .. "weapons/lib/quiver_functions.lua")
ots\data\weapons\scripts\quiver.lua
PHP:
function onUseWeapon(cid, var)
--quiver system by swiatcienia/sebastianraszka owner of cilohokla ots
    local aitem,quiver = getPlayerAmmo(cid)
    local witem = getPlayerWeapon(cid, TRUE)
    if (aitem==LUA_ERROR) then return LUA_ERROR end
    if (executeShoot(cid, var, witem, aitem, quiver)==LUA_ERROR) then return LUA_ERROR end
    doRemoveItem(aitem.uid,1)
    return ret
end
Add this at the end of GLOBAL functions
PHP:
    function getAllContainerItems(cid, containeritem, itemlist)
        --function by swiatcienia/sebastianraszka owner of cilohokla ots
            local container = containeritem.uid
            local size=getContainerSize(container)
            local items = {}
            local i = 0
            local i2 = 0
            if (itemlist==nil) then
                while(i2 < (size)) do
                table.insert(items, getContainerItem(container, i2))
                i2 = i2 + 1
                end
                i=i2
            else
                while(i2 < (size)) do
                local citem=getContainerItem(container, i2)
                    if ((itemlist[citem.itemid] ~= nil) and (itemlist[citem.itemid].active == 1)) then
                    table.insert(items, citem)
                    i = i + 1
                    end
                i2 = i2 + 1
                end
            end
        return items , i
    end
Add this to weapons.xml
PHP:
     <!-- Quiver -->
    <distance id="2455" event="script" value="quiver.lua"/>
    <distance id="2456" event="script" value="quiver.lua"/>
And comment all the arrow and bolt scripts


You need to do this for all distance weapons
items.xml
add this in all distance weapons and delete ammo type from it
PHP:
        <attribute key="attack" value="15"/>
example bow:
PHP:
    <item id="2456" article="a" name="bow">
        <attribute key="weight" value="3100"/>
        <attribute key="attack" value="15"/>
        <!--<attribute key="hitChance" value="90"/> could use but not needed-->
        <attribute key="weaponType" value="distance"/>
        <attribute key="slotType" value="two-handed"/>
        <!--<attribute key="ammoType" value="arrow"/> delete this*you have to-->
        <attribute key="range" value="6"/>
    </item>

To Do list:
Multiple bow (different extra attack)
All arrows (different extra attack,type,extra attack2,type2)
Formulas
Xbow + Bolts
Configuration [Global] (attack types, bow, arrows, xbow, bolts)
Final version will include:
Configuration for bow, arrow, xbow, bolts
All bow and xbow types
Attack types: normal, ice, earth, fire, energy
Attack types2: posion, burn ...
Extra:
Gun, ammo for guns (custom items)
Lua Script Error: [Weapon Interface]
data/weapons/lib/weapons.lua
data/weapons/lib/weapons.lua:2: attempt to call global 'getDataDir' (a nil value)
stack traceback:
[C]: in function 'getDataDir'
data/weapons/lib/weapons.lua:2: in main chunk
[Warning - BaseEvents::loadFromXml] Can not load weapons lib/weapons.lua

Lua Script Error: [Test Interface]
data/weapons/lib/weapons.lua
data/weapons/lib/weapons.lua:2: attempt to call global 'getDataDir' (a nil value)
stack traceback:
[C]: in function 'getDataDir'
data/weapons/lib/weapons.lua:2: in main chunk
[Warning - Event::checkScript] Can not load weapons lib/weapons.lua

Lua Script Error: [Test Interface]
data/weapons/lib/weapons.lua
data/weapons/lib/weapons.lua:2: attempt to call global 'getDataDir' (a nil value)
stack traceback:
[C]: in function 'getDataDir'
data/weapons/lib/weapons.lua:2: in main chunk
[Warning - Event::checkScript] Can not load weapons lib/weapons.lua

Lua Script Error: [Test Interface]
data/weapons/lib/weapons.lua
data/weapons/lib/weapons.lua:2: attempt to call global 'getDataDir' (a nil value)
stack traceback:
[C]: in function 'getDataDir'
data/weapons/lib/weapons.lua:2: in main chunk
[Warning - Event::checkScript] Can not load weapons lib/weapons.lua
 
Lua Script Error: [Weapon Interface]
data/weapons/lib/weapons.lua
data/weapons/lib/weapons.lua:2: attempt to call global 'getDataDir' (a nil value)
stack traceback:
[C]: in function 'getDataDir'
data/weapons/lib/weapons.lua:2: in main chunk
[Warning - BaseEvents::loadFromXml] Can not load weapons lib/weapons.lua

Lua Script Error: [Test Interface]
data/weapons/lib/weapons.lua
data/weapons/lib/weapons.lua:2: attempt to call global 'getDataDir' (a nil value)
stack traceback:
[C]: in function 'getDataDir'
data/weapons/lib/weapons.lua:2: in main chunk
[Warning - Event::checkScript] Can not load weapons lib/weapons.lua

Lua Script Error: [Test Interface]
data/weapons/lib/weapons.lua
data/weapons/lib/weapons.lua:2: attempt to call global 'getDataDir' (a nil value)
stack traceback:
[C]: in function 'getDataDir'
data/weapons/lib/weapons.lua:2: in main chunk
[Warning - Event::checkScript] Can not load weapons lib/weapons.lua

Lua Script Error: [Test Interface]
data/weapons/lib/weapons.lua
data/weapons/lib/weapons.lua:2: attempt to call global 'getDataDir' (a nil value)
stack traceback:
[C]: in function 'getDataDir'
data/weapons/lib/weapons.lua:2: in main chunk
[Warning - Event::checkScript] Can not load weapons lib/weapons.lua
This post is from 2009 btw. 😝
 
Back
Top