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

The Magical Justice Seeker!

Colandus

Advanced OT User
Senator
Joined
Jun 6, 2007
Messages
2,434
Solutions
19
Reaction score
219
Location
Sweden
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:
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:
This is a nice script ;) one of my real friends told me i had to put a special paralyze attack in a sword which after 15 seconds paralyze.
Im not hosting a server anymore but i start maybe soon again
 
[01/11/2008 17:09:28] Lua Script Error: [Weapon Interface]
[01/11/2008 17:09:28] data/weapons/scripts/justice seeker.lua

[01/11/2008 17:09:28] luaSetCombatFormula(). Combat not found

:(
 
Hmm i just noticed you got some problem..
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_WHIRLWINDSWORD)
setCombatFormula(combat1, COMBAT_FORMULA_LEVELMAGIC, -0.3, 0, -1.1, -10)

the combat1 needs to be edited..
 
@up
maybe this?:
Code:
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_WHIRLWINDSWORD)
setCombatFormula(combat, COMBAT_FORMULA_LEVELMAGIC, -0.3, 0, -1.1, -10)
 
yes exactly because otherwise it wouldn't do damage.. and since there is no combat1 it gives a error..
 
oi how i put the action id in the weapon i can do it in game? or it has to be in the map editor

oi it doesn't do anything i put the script in weapons is there where suppose to be? but it doesn't tell me any errors
 
Last edited:
Hold on, I see the script is a bit bugged I'll solve it right now.
 
Compatible with? TFS 0.3.6? 0.2? It looks great. :)
 
Back
Top