sabodden
Member
- Joined
- Sep 27, 2019
- Messages
- 138
- Reaction score
- 18
Code:
[0:9:04.831] [Error - Weapon Interface]
[0:9:04.832] data/weapons/scripts/wands_n_rods/multielements_staff.lua:onUseWeapon
[0:9:04.832] Description:
[0:9:04.832] .../scripts/wands_n_rods/multielements_staff.lua:54: attempt to concatenate upvalue 'maximum' (a nil value)
[0:9:04.832] stack traceback:
[0:9:04.832] .../scripts/wands_n_rods/multielements_staff.lua:54: in function <.../scripts/wands_n_rods/multielements_staff.lua:32>
what should i done to put it to work:
Code:
local wands = {
[12031] = {ef = 36, sh = 3, dmg = COMBAT_FIREDAMAGE},
[12032] = {ef = 42, sh = 28, dmg = COMBAT_ICEDAMAGE},
[12033] = {ef = 45, sh = 38, dmg = COMBAT_POISONDAMAGE},
[12034] = {ef = 17, sh = 31, dmg = COMBAT_DEATHDAMAGE},
[12035] = {ef = 11, sh = 35, dmg = COMBAT_ENERGYDAMAGE},
[12036] = {ef = 49, sh = 37, dmg = COMBAT_HOLYDAMAGE}
}
-- out of the onGetFormulaValues to be used in onUseWeapon
local minimum
local maximum
function onGetFormulaValues(cid, level, skill, attack, factor)
local factorMultipler = 1
if factor == 1.0 then -- player_fight_mode = offensive
factorMultipler = 3
elseif factor == 2.0 then -- player_fight_mode = defensive
factorMultipler = 1
else -- player_fight_mode = balanced
factorMultipler = 2
end
min = ( (spellcfg_wandnrods_min * factorMultipler) + (attack * factorMultipler * spellcfg_wand_atkMultipler) ) * -0.50
max = ( (spellcfg_wandnrods_max * factorMultipler) + (attack * factorMultipler * spellcfg_wand_atkMultipler) ) * -1.00
minimum = min
maximum = max
print("[1] minimum: " .. minimum .. "maximum " .. maximum)
return min, max
end
setCombatCallback(combat, CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")
function onUseWeapon(cid, var)
local item1 = getPlayerSlotItem(cid, CONST_SLOT_LEFT)
local item2 = getPlayerSlotItem(cid, CONST_SLOT_RIGHT)
local staffatk, 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
staffatk = hand1
else
staffatk = hand2
end
local attackValue = staffatk
local target = getCreatureTarget(cid)
for str, info in pairs (wands) do
if getPlayerStorageValue(cid, str) > 0 then
if target ~= nil then
doSendDistanceShoot(getThingPos(cid), getThingPos(target), info.sh)
print("[2] minimum: " .. minimum .. "maximum " .. maximum)
aaddEvent(doAreaCombatHealth, 100, cid, info.dmg, getThingPos(target), 0, -minimum, -maximum, info.ef)
end
end
end
return true
end