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

Gesior.pl

Mega Noob&LOL 2012
Senator
Joined
Sep 18, 2007
Messages
2,966
Solutions
99
Reaction score
3,383
Location
Poland
GitHub
gesior
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
 
Last edited:
A correction

Code:
[COLOR=#000000][COLOR=#007700]<[/COLOR][COLOR=#0000BB]distance id[/COLOR][COLOR=#007700]=[/COLOR][COLOR=#DD0000]"7735" [/COLOR][COLOR=#0000BB]script[/COLOR][COLOR=#007700]=[/COLOR][COLOR=#DD0000]"starshoter.lua"[/COLOR][COLOR=#007700]>
    <[/COLOR][COLOR=#0000BB]vocation name[/COLOR][COLOR=#007700]=[/COLOR][COLOR=#DD0000]"Druid"[/COLOR][COLOR=#007700]/><[/COLOR][COLOR=#0000BB]vocation name[/COLOR][COLOR=#007700]=[/COLOR][COLOR=#DD0000]"Elder Druid"[/COLOR][COLOR=#007700]/>
    <[/COLOR][COLOR=#0000BB]vocation name[/COLOR][COLOR=#007700]=[/COLOR][COLOR=#DD0000]"Sorcerer"[/COLOR][COLOR=#007700]/><[/COLOR][COLOR=#0000BB]vocation name[/COLOR][COLOR=#007700]=[/COLOR][COLOR=#DD0000]"Master Sorcerer"[/COLOR][COLOR=#007700]/>
</[/COLOR][COLOR=#0000BB]distance[/COLOR][COLOR=#007700]> [/COLOR][/COLOR]

The player advance distance fighting

Code:
[COLOR=#000000][COLOR=#007700]<[/COLOR][COLOR=#0000BB]wand id[/COLOR][COLOR=#007700]=[/COLOR][COLOR=#DD0000]"7735" [/COLOR][COLOR=#0000BB]script[/COLOR][COLOR=#007700]=[/COLOR][COLOR=#DD0000]"starshoter.lua"[/COLOR][COLOR=#007700]>
    <[/COLOR][COLOR=#0000BB]vocation name[/COLOR][COLOR=#007700]=[/COLOR][COLOR=#DD0000]"Druid"[/COLOR][COLOR=#007700]/><[/COLOR][COLOR=#0000BB]vocation name[/COLOR][COLOR=#007700]=[/COLOR][COLOR=#DD0000]"Elder Druid"[/COLOR][COLOR=#007700]/>
    <[/COLOR][COLOR=#0000BB]vocation name[/COLOR][COLOR=#007700]=[/COLOR][COLOR=#DD0000]"Sorcerer"[/COLOR][COLOR=#007700]/><[/COLOR][COLOR=#0000BB]vocation name[/COLOR][COLOR=#007700]=[/COLOR][COLOR=#DD0000]"Master Sorcerer"[/COLOR][COLOR=#007700]/>
</[/COLOR][COLOR=#0000BB]wand[/COLOR][COLOR=#007700]> [/COLOR][/COLOR]

The player advance magic level :D

 
does'nt work for me;
[31/10/2008 09:47:33] Lua Script Error: [Weapon Interface]
[31/10/2008 09:47:33] data/weapons/scripts/starshoter.lua:eek:nUseWeapon

[31/10/2008 09:47:33] data/weapons/scripts/starshoter.lua:34: attempt to call global 'doCreatureAddMana' (a nil value)
[31/10/2008 09:47:33] stack traceback:
[31/10/2008 09:47:33] data/weapons/scripts/starshoter.lua:34: in function <data/weapons/scripts/starshoter.lua:28>

using roxor server 8,22
 
does'nt work for me;
[31/10/2008 09:47:33] Lua Script Error: [Weapon Interface]
[31/10/2008 09:47:33] data/weapons/scripts/starshoter.lua:eek:nUseWeapon

[31/10/2008 09:47:33] data/weapons/scripts/starshoter.lua:34: attempt to call global 'doCreatureAddMana' (a nil value)
[31/10/2008 09:47:33] stack traceback:
[31/10/2008 09:47:33] data/weapons/scripts/starshoter.lua:34: in function <data/weapons/scripts/starshoter.lua:28>

using roxor server 8,22

Change doCreatureAddMana to doPlayerAddMana.
 
thanks, i also got a error with that, so i had to change something else also, but then it worked, thanks ^^
 
copy function to your global.lua from tfs
Code:
doCreatureAddMana

Edit: Oooops, too late :pP
 
Nice script, I'll use it ^^ Thank you!

One bug, you can use the wand without any mana but when you have you lose mana.
 
Last edited:
copy function to your global.lua from tfs
Code:
doCreatureAddMana

Edit: Oooops, too late :pP

Thats not any function o_O

He'll have to copy something like this:
Code:
function doCreatureAddMana(cid, mana)
    return doPlayerAddMana(cid, mana)
end
:w00t:
 
When i open the server..

Warning: [Event::loadScript] Event onUseWeapon not found. data/weapons/scripts/starshoter.lua

How i can fix it?

(I'm using TFS 8.2 modified by Gesior)
 
Back
Top