My extra noob weapon
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:
In data/items/items.xml find item 7735 and set attributes:
In data/weapons/scripts/ make file starshoter.lua and paste:
Screen (with config like above):
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>
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>
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
Last edited: