This will make your weapon more powerful, but for it you need to have a certain actionid on your weapon, that means it's not a regular one. However you get the actionid on the weapon is your descision, and you can turn it off also.
What does it do? Well, first of all you have a normal attack and a special attack. The special attack is working on charges, you can only have a certain amount of charges (I use 10 charges) and they are being regenerated after a certain interval (I use 30 seconds). You hit with a certain delay aswell (I use 3 seconds).
That means, when you have 10 charges in your weapon and hit the monster, it will turn into 9 charges and next hit will be a normal hit until you have waited 3 seconds you can hit the special attack again... And after 30 seconds you will get another charge. It cannot load over the max amount of charges.
So, here goes the code:
And the XML-part:
I did the code quite quickly and haven't debuged it 100%, so you could be kind to do it for me as well
Also I was in quite a rush to write this post so hope you understood it!
Enjoy,
Colandus
What does it do? Well, first of all you have a normal attack and a special attack. The special attack is working on charges, you can only have a certain amount of charges (I use 10 charges) and they are being regenerated after a certain interval (I use 30 seconds). You hit with a certain delay aswell (I use 3 seconds).
That means, when you have 10 charges in your weapon and hit the monster, it will turn into 9 charges and next hit will be a normal hit until you have waited 3 seconds you can hit the special attack again... And after 30 seconds you will get another charge. It cannot load over the max amount of charges.
So, here goes the code:
PHP:
---------------- CONFIG! -------------
local weaponId = 7390
-- Does the weapon need to have a actionid to become the Magical Justice Seeker?
local requireActionId = FALSE
local actionId = 100
-- How many charges you can have max at a time.
local charges = {
storageValue = 5667,
value = 10
}
-- How fast a charge will regenerate.
local regenerate = {
storageValue = 5668,
value = 30 -- in seconds
}
-- How often you may hit per second,
local hitDelay = {
storageValue = 5669,
value = 3 -- in seconds
}
---------------- END CONFIG! -------------
-- Normal mode
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_HITAREA)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_WHIRLWINDSWORD)
setCombatFormula(combat, COMBAT_FORMULA_LEVELMAGIC, -0.3, 0, -1.1, -10)
-- Berserk mode
local combat2 = createCombatObject()
setCombatParam(combat2, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat2, COMBAT_PARAM_EFFECT, CONST_ME_HITAREA)
setCombatFormula(combat2, COMBAT_FORMULA_LEVELMAGIC, -0.6, -30, -2.2, 0) -- exori damage
local arr = {
{1, 1, 1},
{1, 3, 1},
{1, 1, 1}
}
local area = createCombatArea(arr)
setCombatArea(combat2, area)
function onUseWeapon(cid, var)
do
local weaponRightHand = getPlayerSlotItem(cid, CONST_SLOT_RIGHTHAND)
local weaponLeftHand = getPlayerSlotItem(cid, CONST_SLOT_LEFTHAND)
local weapon = weaponRightHand.itemid == weaponId and weaponRightHand or weaponLeftHand.itemid == weaponId and weaponLeftHand
if(not weapon or requireActionId and weapon.actionid ~= actionId) then
return LUA_ERROR
end
end
local chargesLeft = getPlayerStorageValue(cid, charges.storageValue)
if chargesLeft == -1 then
setPlayerStorageValue(cid, charges.storageValue, charges.value)
setPlayerStorageValue(cid, regenerate.storageValue, os.time())
setPlayerStorageValue(cid, hitDelay.storageValue, os.time())
chargesLeft = charges.value
end
local canHit = (os.time() - getPlayerStorageValue(cid, hitDelay.storageValue)) / hitDelay.value > 1
local regenerateTime = getPlayerStorageValue(cid, regenerate.storageValue)
local addCharges = math.floor((os.time() - regenerateTime) / regenerate.value) - 1
chargesLeft = math.min(chargesLeft + addCharges, charges.value - 1)
if canHit and chargesLeft > 0 then
setPlayerStorageValue(cid, hitDelay.storageValue, os.time())
if chargesLeft == 1 then
setPlayerStorageValue(cid, regenerate.storageValue, os.time())
end
setPlayerStorageValue(cid, charges.storageValue, chargesLeft)
if addCharges >= 0 then
setPlayerStorageValue(cid, regenerate.storageValue, regenerateTime + ((addCharges + 1) * regenerate.value))
end
return doCombat(cid, combat2, var)
end
return doCombat(cid, combat, var)
end
And the XML-part:
Code:
<melee id="7390" lvl="100" enabled="1" exhaustion="0" script="justice seeker.lua">><vocation id="4"/><vocation id="8"/></melee>
I did the code quite quickly and haven't debuged it 100%, so you could be kind to do it for me as well
Also I was in quite a rush to write this post so hope you understood it!
Enjoy,
Colandus
Last edited: