fyalhed
Member
- Joined
- Nov 18, 2017
- Messages
- 156
- Reaction score
- 20
I'm trying to do a auto recharge for my assassin star...
Why it don't work?
No errors, just do not work
Why it don't work?
No errors, just do not work
Code:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_BLOCKARMOR, 1)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, 18)
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
local function autoRechargeAmmo(cid)
-- get hand slot
local ammo_in_slot
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
ammo_in_slot = getPlayerSlotItem(cid, CONST_SLOT_LEFT)
bowattack = hand1
else
ammo_in_slot = getPlayerSlotItem(cid, CONST_SLOT_RIGHT)
end
--
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
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
min = ((damagebase_min) * (attack) * (skill)) * -0.10
max = ((damagebase_max) * (attack) * (skill)) * -1.00
return min, max
end
setCombatCallback(combat, CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")
function onUseWeapon(cid, var)
autoRechargeAmmo(cid)
return doCombat(cid, combat, var)
end