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

[weapon]Multitarget wand 'star shoter'

Sorry for bumping this thread after 5 years.
But i found a bug with it
If i attack player/monster and the other players/monsters blocked by wall, i still can hit them.
 
Lua Script Error: [Weapon Interface]
data/weapons/scripts/starshoter.lua:eek:nUseWeapon
data/weapons/scripts/starshoter.lua:39: attempt to call global 'getCreatureMana' (a nil value)
stack traceback:
[C]: in function 'getCreatureMana'
data/weapons/scripts/starshoter.lua:39: in function <data/weapons/scripts/starshoter.lua:14>
someone help?
 
Lua Script Error: [Weapon Interface]
data/weapons/scripts/starshoter.lua:eek:nUseWeapon
data/weapons/scripts/starshoter.lua:39: attempt to call global 'getCreatureMana' (a nil value)
stack traceback:
[C]: in function 'getCreatureMana'
data/weapons/scripts/starshoter.lua:39: in function <data/weapons/scripts/starshoter.lua:14>
someone help?

This script was written for another era. If you want it updated, the place to ask is in requests.
 
My extra noob weapon :D
It's wand that can hit few targets in same time.
If player attack other player it hit this player and monsters/players near him. If player attack monster it hit only monsters, so player can hunt with blocker and doesn't hit him.
In data/weapons/weapons.xml add:
PHP:
<distance id="7735" script="starshoter.lua">
    <vocation name="Druid"/><vocation name="Elder Druid"/>
    <vocation name="Sorcerer"/><vocation name="Master Sorcerer"/>
</distance>
In data/items/items.xml find item 7735 and set attributes:
PHP:
    <item id="7735" article="the" name="star wand">
        <attribute key="description" value="This holy wand radiates huge ammount of light."/>
        <attribute key="weight" value="20"/>
        <attribute key="attack" value="1"/>
        <attribute key="hitChance" value="100"/>
        <attribute key="weaponType" value="distance"/>
        <attribute key="range" value="7"/>
    </item>
In data/weapons/scripts/ make file starshoter.lua and paste:
Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_BLOCKARMOR, 0)
setCombatParam(combat, COMBAT_PARAM_BLOCKSHIELD, 0)
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_HOLYDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_HOLYDAMAGE)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_HOLY)
setCombatFormula(combat, COMBAT_FORMULA_LEVELMAGIC, -0.2, -25, -0.2, -3)

local manaNeededPerTarget = 20
local hitExtraTargets = 2 -- number of extra targets, so it should attack our target + X other monsters/players
local hitExtraTargetsInRange = 2 -- distance to 'extra target' from our target


function onUseWeapon(cid, var)
    local ret = doCombat(cid, combat, var)
    if(ret == LUA_ERROR) then
        return LUA_ERROR
    end
    local manaSpent = manaNeededPerTarget
    local target = variantToNumber(var)
    local hitplayers = false
    if(target ~= 0) then
        if(isPlayer(target)) then
            hitplayers = true
        end
        local otherTargets = getSpectators(getCreaturePosition(target), hitExtraTargetsInRange, hitExtraTargetsInRange, false)
        if(#otherTargets > 0) then
            local i = 1
            while(i ~= #otherTargets) do
                local pid = otherTargets[i]
                if(isNpc(pid) or pid == cid or pid == target or (isPlayer(pid) and (not hitplayers or getTileInfo(getCreaturePosition(pid)).protection))) then
                    table.remove(otherTargets, i)
                else
                    i = i + 1
                end
            end
        end
        for i = 1, hitExtraTargets do
            if(#otherTargets > 0 and getCreatureMana(cid) >= manaSpent + manaNeededPerTarget) then   
                local randomId = math.random(1, #otherTargets)
                local nowHit = otherTargets[randomId]
                table.remove(otherTargets, randomId)
                ret = doCombat(cid, combat, numberToVariant(nowHit))
                if(ret ~= LUA_ERROR) then
                    manaSpent = manaSpent + manaNeededPerTarget
                end
            else
                break
            end
        end
    end
    doPlayerAddSpentMana(cid, manaSpent)
    doCreatureAddMana(cid, -manaSpent)
    return true
end
Screen (with config like above):
starshoterjb3.png

Nice thx!
 
Back
Top