Hello, here is a little funny script i made in couple minutes.
Code:
local config = {
shootRange = 7,
damage = {50, 100}, -- min/max
shootEffect = CONST_ANI_HUNTINGSPEAR,
impactEffect = CONST_ME_HITAREA,
exhaustOnUse = 300, -- miliseconds
direction = {
[5692] = DIRECTION_NORTH,
[5701] = DIRECTION_EAST,
[5698] = DIRECTION_WEST,
[5695] = DIRECTION_SOUTH
}
}
local exhaust = Condition(CONDITION_EXHAUST_WEAPON)
exhaust:setParameter(CONDITION_PARAM_TICKS, config.exhaustOnUse)
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
if player:getCondition(CONDITION_EXHAUST_WEAPON) then
player:sendTextMessage(MESSAGE_STATUS_SMALL, Game.getReturnMessage(RETURNVALUE_YOUAREEXHAUSTED))
return true
end
player:addCondition(exhaust)
for i = 1, config.shootRange do
local nextPosition = item:getPosition()
nextPosition:getNextPosition(config.direction[item.itemid], i)
local tile = Tile(nextPosition)
if tile then
local topCreature = tile:getTopCreature()
if topCreature then
toPosition:sendDistanceEffect(topCreature:getPosition(), config.shootEffect)
doTargetCombatHealth(player, topCreature, COMBAT_PHYSICALDAMAGE, -config.damage[1] * i, -config.damage[2] * i, config.impactEffect)
return true
end
end
end
local nextPosition = item:getPosition()
nextPosition:getNextPosition(config.direction[item.itemid], config.shootRange)
toPosition:sendDistanceEffect(nextPosition, config.shootEffect)
return true
end