• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Lua Problem new damage system (distance - bows/crossbows)

dudie

Member
Joined
May 23, 2016
Messages
128
Reaction score
12
I made this script with help to you from forum to new damage system
weapons/scripts/distance_damage.lua
Code:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_BLOCKARMOR, 1)
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)

function onGetFormulaValues(cid, level, skill, attack, factor)
   --min = ((0.08) * (attack) * (skill)) * -1
   --max = ((0.08) * (attack) * (skill)) * -1
   --print(skill)
   print(attack)
   min = ((attack) * (100)) * -1
   max = ((attack) * (100)) * -1
   return min, max
end
setCombatCallback(combat, CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")

function onUseWeapon(cid, var)
   return doCombat(cid, combat, var)
end

It's work fine to royal spears for exemple... print fine (35)
Assassin star print 65, fine work too


But bows and arrows i have a problem...
I want attack be arrow attack + bow attack

Using bow
Code:
16:44 You see a bow (Range:6, Atk +1).
It weighs 31.00 oz.
ItemID: [2456].

Code:
<item id="2544" article="an" name="arrow" plural="arrows">
   <attribute key="weight" value="10" />
   <attribute key="slotType" value="ammo" />
   <attribute key="attack" value="30" />
   <attribute key="maxHitChance" value="90" />
   <attribute key="weaponType" value="ammunition" />
   <attribute key="ammoType" value="arrow" />
   <attribute key="shootType" value="arrow" />
   <attribute key="ammoAction" value="removecount" />
</item>

print only 30 and not 31

I want print bow atk + arrow atk

For exemple if bow is attack 20 and arrow is attack 30...
Total attack on script is 50


weapons.xml
Code:
   <!-- mage & paladin -->
   <distance id="2456" unproperly="1" swing="true" event="script" value="distance_damage.lua" /> <!-- bow -->
   <!-- paladin -->
   <distance id="2455" unproperly="1" swing="true" event="script" value="distance_damage.lua"> <!-- crossbow -->
     <vocation id="3"/>
     <vocation id="7" showInDescription="0"/>
     <vocation id="11" showInDescription="0"/>
   </distance>
   <distance id="7438" unproperly="1" swing="true" event="script" value="distance_damage.lua"> <!-- elvish bow -->
     <vocation id="3"/>
     <vocation id="7" showInDescription="0"/>
     <vocation id="11" showInDescription="0"/>
   </distance>
   <distance id="5803" unproperly="1" swing="true" event="script" value="distance_damage.lua" /> <!-- arbalest -->
   <distance id="5907" unproperly="1" swing="true" event="script" value="distance_damage.lua" /> <!-- slingshot -->
   <distance id="1294" unproperly="1" swing="true" event="script" value="distance_damage.lua" /> <!-- small stone -->
   
   <distance id="8849" unproperly="1" swing="true" event="function" value="default"> <!-- Modified Crossbow -->
     <vocation id="3"/>
     <vocation id="7" showInDescription="0"/>
     <vocation id="11" showInDescription="0"/>
   </distance>
   <distance id="8850" unproperly="1" swing="true" event="function" value="default"> <!-- Chain Bolter -->
     <vocation id="3"/>
     <vocation id="7" showInDescription="0"/>
     <vocation id="11" showInDescription="0"/>
   </distance>
   <distance id="8853" unproperly="1" swing="true" event="function" value="default"> <!-- Ironworker -->
     <vocation id="3"/>
     <vocation id="7" showInDescription="0"/>
     <vocation id="11" showInDescription="0"/>
   </distance>
   <distance id="8852" unproperly="1" swing="true" event="function" value="default"> <!-- Devileye -->
     <vocation id="3"/>
     <vocation id="7" showInDescription="0"/>
     <vocation id="11" showInDescription="0"/>
   </distance>
   <distance id="8851" unproperly="1" swing="true" event="function" value="default"> <!-- Royal Crossbow -->
     <vocation id="3"/>
     <vocation id="7" showInDescription="0"/>
     <vocation id="11" showInDescription="0"/>
   </distance>
   <distance id="8857" unproperly="1" swing="true" event="function" value="default"> <!-- Silkweaver Bow -->
     <vocation id="3"/>
     <vocation id="7" showInDescription="0"/>
     <vocation id="11" showInDescription="0"/>
   </distance>
   <distance id="8855" unproperly="1" swing="true" event="function" value="default"> <!-- Composite Hornbow -->
     <vocation id="3"/>
     <vocation id="7" showInDescription="0"/>
     <vocation id="11" showInDescription="0"/>
   </distance>
   <distance id="8858" unproperly="1" swing="true" event="function" value="default"> <!-- Elethriel's Elemental Bow -->
     <vocation id="3"/>
     <vocation id="7" showInDescription="0"/>
     <vocation id="11" showInDescription="0"/>
   </distance>
   <distance id="8854" unproperly="1" swing="true" event="function" value="default"> <!-- Warsinger Bow -->
     <vocation id="3"/>
     <vocation id="7" showInDescription="0"/>
     <vocation id="11" showInDescription="0"/>
   </distance>

   <!-- Ammunition -->
   <distance id="2545" swing="true" event="script" value="poison_arrow.lua"/>
   <distance id="2546" swing="true" event="script" value="burst_arrow.lua"/>
   <distance id="7366" swing="true" event="script" value="viper_star.lua"/>
   <distance id="7838" swing="true" type="energy" event="script" value="distance_damage.lua"/>
   <distance id="7839" swing="true" type="ice" event="script" value="distance_damage.lua"/>
   <distance id="7840" swing="true" type="fire" event="script" value="distance_damage.lua"/>
   <distance id="7850" swing="true" type="earth" event="script" value="distance_damage.lua"/>
   <distance id="3965" swing="true" event="script" value="distance_damage.lua"/> <!-- Hunting Spear -->
   <distance id="7378" swing="true" event="script" value="distance_damage.lua"/> <!-- Royal Spear -->
   <distance id="7367" swing="true" event="script" value="distance_damage.lua"/> <!-- Enchanted Spear -->
   <distance id="7368" swing="true" event="script" value="distance_damage.lua"/> <!-- Assassin Star -->
   <distance id="7364" swing="true" event="script" value="distance_damage.lua"/> <!-- Sniper Arrow -->
   <distance id="7365" swing="true" event="script" value="distance_damage.lua"/> <!-- Onyx Arrow -->
   <distance id="7363" swing="true" event="script" value="distance_damage.lua"/> <!-- Piercing Bolt -->
   <distance id="2547" swing="true" event="script" value="distance_damage.lua"/> <!-- Power Bolt -->
   <distance id="6529" swing="false" event="script" value="distance_damage.lua"/> <!-- Infernal Bolt -->
   <distance id="2544" swing="true" event="script" value="distance_damage.lua"/> <!-- Arrow -->
   <distance id="2543" swing="true" event="script" value="distance_damage.lua"/> <!-- Bolt -->
 
Can't figure out why it won't set combat params, if anyone can figure out how to fix the combat params, script should work.
Code:
function onGetFormulaValues(cid, level, skill, attack, factor)
    local ML = getPlayerMagLevel(cid)
    local Ammo = getPlayerSlotItem(cid, CONST_SLOT_AMMO)
    local AmmoID = Ammo.itemid

    local Properties = {
    [1] = {ID = 2545, DistanceEffect = CONST_ANI_POISONARROW, DamageType = COMBAT_POISONDAMAGE},
    [2] = {ID = 2544, DistanceEffect = CONST_ANI_ARROW, DamageType = COMBAT_PHYSICALDAMAGE},
    [3] = {ID = 7364, DistanceEffect = CONST_ANI_SNIPERARROW, DamageType = COMBAT_PHYSICALDAMAGE},
    [4] = {ID = 7365, DistanceEffect = CONST_ANI_ONYXARROW, DamageType = COMBAT_PHYSICALDAMAGE},
    [5] = {ID = 7839, DistanceEffect = CONST_ANI_SHIVERARROW, DamageType = COMBAT_ICEDAMAGE},
    [6] = {ID = 7850, DistanceEffect = CONST_ANI_EARTHARROW, DamageType = COMBAT_EARTHDAMAGE},
    [7] = {ID = 7838, DistanceEffect = CONST_ANI_FLASHARROW, DamageType = COMBAT_ENERGYDAMAGE},
    [8] = {ID = 7840, DistanceEffect = CONST_ANI_FLAMMINGARROW, DamageType = COMBAT_FIREDAMAGE},
    [9] = {ID = 2543, DistanceEffect = CONST_ANI_BOLT, DamageType = COMBAT_PHYSICALDAMAGE},
    [10] = {ID = 7363, DistanceEffect = CONST_ANI_PIERCINGBOLT, DamageType = COMBAT_PHYSICALDAMAGE},
    [11] = {ID = 2547, DistanceEffect = CONST_ANI_POWERBOLT, DamageType = COMBAT_PHYSICALDAMAGE},
    [12] = {ID = 6529, DistanceEffect = CONST_ANI_INFERNALBOLT, DamageType = COMBAT_PHYSICALDAMAGE},
    [13] = {ID = 2389, DistanceEffect = CONST_ANI_SPEAR, DamageType = COMBAT_PHYSICALDAMAGE},
    [14] = {ID = 3965, DistanceEffect = CONST_ANI_HUNTINGSPEAR, DamageType = COMBAT_PHYSICALDAMAGE},
    [15] = {ID = 7367, DistanceEffect = CONST_ANI_ENCHANTEDSPEAR, DamageType = COMBAT_PHYSICALDAMAGE},
    [16] = {ID = 7378, DistanceEffect = CONST_ANI_ROYALSPEAR, DamageType = COMBAT_PHYSICALDAMAGE},
    [17] = {ID = 7367, DistanceEffect = CONST_ANI_REDSTAR, DamageType = COMBAT_PHYSICALDAMAGE},
    [18] = {ID = 7366, DistanceEffect = CONST_ANI_GREENSTAR, DamageType = COMBAT_PHYSICALDAMAGE},
    [19] = {ID = 2399, DistanceEffect = CONST_ANI_THROWINGSTAR, DamageType = COMBAT_PHYSICALDAMAGE},
    [20] = {ID = 2410, DistanceEffect = CONST_ANI_THROWINGKNIFE, DamageType = COMBAT_PHYSICALDAMAGE},
    [21] = {ID = 1294, DistanceEffect = CONST_ANI_SMALLSTONE, DamageType = COMBAT_PHYSICALDAMAGE}
}
local combat = createCombatObject()
for k,v in pairs(Properties) do
if AmmoID == v.ID then
    setCombatParam(combat, COMBAT_PARAM_TYPE, v.DamageType) -- HERE
    setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, v.DistanceEffect) -- HERE
    min = attack + ML + getItemInfo(AmmoID).attack
    max = attack + ML + getItemInfo(AmmoID).attack
    return -min, -max
end
end
end
setCombatCallback(combat, CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")

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

setCombatArea(combat, area)

function onUseWeapon(cid, var)
    local Ammo = getPlayerSlotItem(cid, CONST_SLOT_AMMO)
    local AmmoID = Ammo.itemid
    if AmmoID == 0 then
        return false
    end
    if AmmoID ~= 0 then
    if getItemInfo(AmmoID).weaponType ~= 8 then
    return false
end
end
   return doCombat(cid, combat, var)
end
I suck at scripting :(
 
Back
Top