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

Spell Rain of Arrows

Gilahof

RepzorMe
Joined
Dec 11, 2007
Messages
87
Reaction score
1
Location
Brazil
Name: Rain of arrows
Version: 8.4x+
Server Tested: TFS
Author: Legend Link

Spell-based class archer ragnarok

Spends a certain amount of arrow and
As you level rises it increases the amount of shots

between 0 and 19 = 2 shots
between 20 and 49 = 3 shots
more than 50 = 3 normal shots and 1 shot stronger

Create a rain_arrow.lua inside atack folder with this:
Code:
local combat1 = createCombatObject()
setCombatFormula(combat1, COMBAT_FORMULA_SKILL, 0, 0, 0, 0)

local combat2 = createCombatObject()
setCombatParam(combat2, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat2, COMBAT_PARAM_EFFECT, CONST_ME_HITAREA)
setCombatParam(combat2, COMBAT_PARAM_DISTANCEEFFECT, 2)
setCombatFormula(combat2, COMBAT_FORMULA_SKILL, 0, -20, 0.8, 0)

local combat3 = createCombatObject()
setCombatParam(combat3, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat3, COMBAT_PARAM_EFFECT, 3)
setCombatParam(combat3, COMBAT_PARAM_DISTANCEEFFECT, 2)
setCombatFormula(combat3, COMBAT_FORMULA_SKILL, 0, -200, 0.8, 0)


local function onCastSpell1(parameters)
doCombat(parameters.cid, parameters.combat1, parameters.var)
end

local function onCastSpell2(parameters)
doCombat(parameters.cid, parameters.combat2, parameters.var)
end

local function onCastSpell3(parameters)
doCombat(parameters.cid, parameters.combat3, parameters.var)
end

function onCastSpell(cid, var)
local parameters = { cid = cid, var = var, combat1 = combat1, combat2 = combat2, combat3 = combat3}

if getPlayerItemCount(cid, [COLOR="Red"]2544[/COLOR]) < 3 then
doPlayerSendTextMessage(cid, 26, "[COLOR="Blue"]I need 3 arrows to cast spell[/COLOR]")
else
if getPlayerItemCount(cid, [COLOR="Red"]2544[/COLOR]) >= 3 then
if getPlayerLevel(cid) < 20 then
doPlayerRemoveItem(cid, [COLOR="Red"]2544[/COLOR], 3)
addEvent(onCastSpell2, 0, parameters)
addEvent(onCastSpell2, 100, parameters)
else
if getPlayerItemCount(cid, [COLOR="Red"]2544[/COLOR]) >= 4 then
if getPlayerLevel(cid) >= 50 then
doPlayerRemoveItem(cid, [COLOR="Red"]2544[/COLOR], 4)
addEvent(onCastSpell2, 0, parameters)
addEvent(onCastSpell2, 300, parameters)
addEvent(onCastSpell2, 600, parameters)
addEvent(onCastSpell3, 1500, parameters)
else
if getPlayerItemCount(cid, 2544) >= 3 then
if getPlayerLevel(cid) <= 49 then
doPlayerRemoveItem(cid, 2544, 3)
addEvent(onCastSpell2, 0, parameters)
addEvent(onCastSpell2, 100, parameters)
addEvent(onCastSpell2, 200, parameters)



end
end
end
end
end
end
end

return doCombat(cid, combat1, var)
end

Add on spells.xml:
Code:
<instant name="Rain Arrow" words="exori mas con" lvl="0" mana="0" prem="0" range="7" needtarget="1" blockwalls="1" exhaustion="1000" needlearn="0" event="script" value="[COLOR="DarkOrchid"]attack/rain_arrow.lua[/COLOR]">
<vocation name="paladin"/>
<vocation name="royal paladin"/>
</instant>

in RED - id of arrow
in BLUE - message will appear if the player does not have enough arrows


I didn't made this script.. :)
 
seems to be a good code.
thanks +1
 
Help with tables and function

Well i modified it a bit but i'm having problem with the tables..
could anybody help me with the bows config in the function "isItemEquipped"

PHP:
....

local bows = {
             [1] = {itemid = 2456},
             [2] = {itemid = 7438},
             [3] = {itemid = 8854},
             [4] = {itemid = 8855},
             [5] = {itemid = 8856},
             [6] = {itemid = 8857},
             [7] = {itemid = 8858}
                                        }

local function isItemEquipped(cid, slot, itemid) 
    -- Function by Colandus
    if(isPlayer(cid) == FALSE) then
        return LUA_ERROR
    end

    return (getPlayerSlotItem(cid, slot).itemid == itemid) and TRUE or FALSE
end

if isItemEquipped(cid, CONST_SLOT_LEFT, bows.itemid) or isItemEquipped(cid, CONST_SLOT_RIGHT, bows.itemid) then

	if getPlayerItemCount(cid, 10040) < 3 then
		doPlayerSendTextMessage(cid, 26, "you need at least 3 infernal arrows to cast the spell")
	elseif getPlayerItemCount(cid, 10040) >= 3 and getPlayerLevel(cid) < 20 then
		doPlayerRemoveItem(cid, 10040, 3)
		addEvent(onCastSpell2, 0, parameters)
		addEvent(onCastSpell2, 100, parameters)
	elseif getPlayerItemCount(cid, 10040) >= 3 and getPlayerLevel(cid) > 20 and getPlayerLevel(cid) < 50 then
		doPlayerRemoveItem(cid, 10040, 3)
		addEvent(onCastSpell2, 0, parameters)
		addEvent(onCastSpell2, 100, parameters)
		addEvent(onCastSpell2, 200, parameters)
	elseif getPlayerItemCount(cid, 10040) >= 4 and getPlayerLevel(cid) >= 50 then
		doPlayerRemoveItem(cid, 10040, 4)
		addEvent(onCastSpell2, 0, parameters)
		addEvent(onCastSpell2, 300, parameters)
		addEvent(onCastSpell2, 600, parameters)
		addEvent(onCastSpell3, 1500, parameters)
	end
else
doPlayerSendTextMessage(cid, 26, "Equip a bow before casting this spell")
end

return doCombat(cid, combat1, var)
end
 
Dont have exhausted S:


Code:
<instant name="Rain Arrow" words="exori mas con" lvl="0" mana="0" prem="0" range="7" needtarget="1" blockwalls="1" [COLOR="Red"]exhaustion="1000"[/COLOR] needlearn="0" event="script" value="attack/rain_arrow.lua">
<vocation name="paladin"/>
<vocation name="royal paladin"/>
</instant>

Edit the ~[ exhaustion="1000" ]~
o_O
 
Well i modified it a bit but i'm having problem with the tables..
could anybody help me with the bows config in the function "isItemEquipped"

PHP:
....

local bows = {
             [1] = {itemid = 2456},
             [2] = {itemid = 7438},
             [3] = {itemid = 8854},
             [4] = {itemid = 8855},
             [5] = {itemid = 8856},
             [6] = {itemid = 8857},
             [7] = {itemid = 8858}
                                        }

local function isItemEquipped(cid, slot, itemid) 
    -- Function by Colandus
    if(isPlayer(cid) == FALSE) then
        return LUA_ERROR
    end

    return (getPlayerSlotItem(cid, slot).itemid == itemid) and TRUE or FALSE
end

if isItemEquipped(cid, CONST_SLOT_LEFT, bows.itemid) or isItemEquipped(cid, CONST_SLOT_RIGHT, bows.itemid) then

	if getPlayerItemCount(cid, 10040) < 3 then
		doPlayerSendTextMessage(cid, 26, "you need at least 3 infernal arrows to cast the spell")
	elseif getPlayerItemCount(cid, 10040) >= 3 and getPlayerLevel(cid) < 20 then
		doPlayerRemoveItem(cid, 10040, 3)
		addEvent(onCastSpell2, 0, parameters)
		addEvent(onCastSpell2, 100, parameters)
	elseif getPlayerItemCount(cid, 10040) >= 3 and getPlayerLevel(cid) > 20 and getPlayerLevel(cid) < 50 then
		doPlayerRemoveItem(cid, 10040, 3)
		addEvent(onCastSpell2, 0, parameters)
		addEvent(onCastSpell2, 100, parameters)
		addEvent(onCastSpell2, 200, parameters)
	elseif getPlayerItemCount(cid, 10040) >= 4 and getPlayerLevel(cid) >= 50 then
		doPlayerRemoveItem(cid, 10040, 4)
		addEvent(onCastSpell2, 0, parameters)
		addEvent(onCastSpell2, 300, parameters)
		addEvent(onCastSpell2, 600, parameters)
		addEvent(onCastSpell3, 1500, parameters)
	end
else
doPlayerSendTextMessage(cid, 26, "Equip a bow before casting this spell")
end

return doCombat(cid, combat1, var)
end
Are you using TFS 0.2?

Anyway, try this:
Code:
-- Don't forget to add combat !

local bows = {2456, 7438, 8854, 8855, 8856, 8857, 8858}

local function isItemEquipped(cid, slot, itemid) 
	-- Function by Colandus
	if(isPlayer(cid) == FALSE) then
		return LUA_ERROR
	end

	return (getPlayerSlotItem(cid, slot).itemid == itemid)
end

function onCastSpell(cid, var)
	local failed = true
	for i = 1, #bows do
		if isItemEquipped(cid, CONST_SLOT_LEFT, bows[i]) or isItemEquipped(cid, CONST_SLOT_RIGHT, bows[i]) then
			failed = false
			break
		end
	end
	if(not(failed)) then
		local arrows = getPlayerLevel(cid) < 50 and 3 or 4
		if getPlayerItemCount(cid, 10040) < arrows then
			doPlayerSendTextMessage(cid, 26, "You need at least " .. arrows .. " infernal arrows to cast the spell.")
			return false
		else
			if getPlayerLevel(cid) < 20 then
				doPlayerRemoveItem(cid, 10040, arrows)
				addEvent(onCastSpell2, 0, parameters)
				addEvent(onCastSpell2, 100, parameters)
			elseif getPlayerLevel(cid) >= 20 and getPlayerLevel(cid) < 50 then
				doPlayerRemoveItem(cid, 10040, arrows)
				addEvent(onCastSpell2, 0, parameters)
				addEvent(onCastSpell2, 100, parameters)
				addEvent(onCastSpell2, 200, parameters)
			elseif getPlayerLevel(cid) >= 50 then
				doPlayerRemoveItem(cid, 10040, arrows)
				addEvent(onCastSpell2, 0, parameters)
				addEvent(onCastSpell2, 300, parameters)
				addEvent(onCastSpell2, 600, parameters)
				addEvent(onCastSpell3, 1500, parameters)
			end
		end
	else
		doPlayerSendTextMessage(cid, 26, "Equip a bow before casting this spell")
		return false
	end
	return doCombat(cid, combat1, var)
end
 
Last edited:
Back
Top