Exactly.like nautilus Q? nice idea![]()
Hmm.. I'll see what I can do. Thanks!Copy a fishing rod script actually. You need allowfaruse flag (actions.xml) andplayer:teleportTo(toPos)
local reqActnId = 8927 -- Action id the hookshot will work on
local maxDstnce = 15 -- Max hookshot stretch lenght (in SQ)
function grappleAnim(parameters)
if (parameters.counter == 10) then
local fromPosition = getCreaturePosition(parameters.cid)
doTeleportThing(parameters.cid, parameters.toPosition, FALSE)
doSendMagicEffect(fromPosition, CONST_ME_POFF)
return TRUE
end
parameters.counter = parameters.counter + 1
doSendDistanceShoot(getCreaturePosition(parameters.cid), parameters.toPosition, CONST_ANI_THROWINGSTAR)
doSendDistanceShoot(getCreaturePosition(parameters.cid), parameters.toPosition, CONST_ANI_ARROW)
doSendDistanceShoot(getCreaturePosition(parameters.cid), parameters.toPosition, CONST_ANI_SMALLSTONE)
addEvent(grappleAnim, 100, parameters)
end
local useWorms = FALSE
local waterIds = {1549}
function onUse(cid, item, fromPosition, itemEx, toPosition)
if isInArray(waterIds, itemEx.itemid) == TRUE then
if itemEx.itemid ~= 1549 then
if useWorms == FALSE or useWorms == TRUE and doPlayerRemoveItem(cid, ITEM_WORM, 1) == TRUE then
if math.random(1, (100 + (getPlayerSkill(cid, SKILL_FISHING) / 10))) <= getPlayerSkill(cid, SKILL_FISHING) then
player:teleportTo(toPos)
end
doPlayerAddSkillTry(cid, SKILL_FISHING, 1)
end
end
doSendMagicEffect(toPosition, CONST_ME_LOSEENERGY)
return TRUE
end
if (itemEx.actionid == reqActnId and getDistanceBetween(getCreaturePosition(cid), toPosition) <= maxDstnce) then
doSendDistanceShoot(fromPosition, toPosition, CONST_ANI_HUNTINGSPEAR)
doSendMagicEffect(toPosition, CONST_ME_BLOCKHIT)
doTeleportThing(parameters.cid, parameters.toPosition, FALSE)
local parameters = {cid = cid, toPosition = toPosition, counter = 0}
addEvent(grappleAnim, 100, parameters)
else
doPlayerSendCancel(cid, "Nothing to hook to in range.")
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
end
return TRUE
end
local reqActnId = 8927 -- Action id the hookshot will work on
LUA:-- >> Stuff -- local reqActnId = 11111 -- Action id the hookshot will work on local maxDstnce = 15 -- Max hookshot stretch lenght (in SQ) -- Stuff << -- function grappleAnim(parameters) if (parameters.counter == 10) then local fromPosition = getCreaturePosition(parameters.cid) doTeleportThing(parameters.cid, parameters.toPosition, FALSE) doSendMagicEffect(fromPosition, CONST_ME_POFF) return TRUE end parameters.counter = parameters.counter + 1 doSendDistanceShoot(getCreaturePosition(parameters.cid), parameters.toPosition, CONST_ANI_THROWINGSTAR) doSendDistanceShoot(getCreaturePosition(parameters.cid), parameters.toPosition, CONST_ANI_ARROW) doSendDistanceShoot(getCreaturePosition(parameters.cid), parameters.toPosition, CONST_ANI_SMALLSTONE) addEvent(grappleAnim, 100, parameters) end local useWorms = FALSE local waterIds = {493, 4608, 4609, 4610, 4611, 4612, 4613, 4614, 4615, 4616, 4617, 4618, 4619, 4620, 4621, 4622, 4623, 4624, 4625, 7236, 10499} function onUse(cid, item, fromPosition, itemEx, toPosition) if isInArray(waterIds, itemEx.itemid) == TRUE then if itemEx.itemid ~= 493 then if useWorms == FALSE or useWorms == TRUE and doPlayerRemoveItem(cid, ITEM_WORM, 1) == TRUE then if math.random(1, (100 + (getPlayerSkill(cid, SKILL_FISHING) / 10))) <= getPlayerSkill(cid, SKILL_FISHING) then doPlayerAddItem(cid, ITEM_FISH, 1) end doPlayerAddSkillTry(cid, SKILL_FISHING, 1) end end doSendMagicEffect(toPosition, CONST_ME_LOSEENERGY) return TRUE end if (itemEx.actionid == reqActnId and getDistanceBetween(getCreaturePosition(cid), toPosition) <= maxDstnce) then doSendDistanceShoot(fromPosition, toPosition, CONST_ANI_HUNTINGSPEAR) doSendMagicEffect(toPosition, CONST_ME_BLOCKHIT) local parameters = {cid = cid, toPosition = toPosition, counter = 0} addEvent(grappleAnim, 100, parameters) else doPlayerSendCancel(cid, "Nothing to hook to in range.") doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF) end return TRUE end
The script is working but only if I am right beside the object to hookshot. It seems the Distance is not working even 2 squares away I cannot hookshot It is acting like a melee weapon must be right beside it to work. How can I get it to work at a distance Pole -Water-Water-Pole = Not working Pole-Pole = Working
Im sorry but what are you guys actually trying to do here im extremly confused... it seems like you only copied a script for fishing and tried to make something out of it....Exactly.
Hmm.. I'll see what I can do. Thanks!
Post automatically merged:
Can't seem to get it to work. My character doesnt get teleported. Do you see the mistakes? Used script made from Molinero but it's been a long time ago. Made some changes as the original one didnt work for me either. ID 1549 is the pillar I wanna be able to jump to.
LUA:local reqActnId = 8927 -- Action id the hookshot will work on local maxDstnce = 15 -- Max hookshot stretch lenght (in SQ) function grappleAnim(parameters) if (parameters.counter == 10) then local fromPosition = getCreaturePosition(parameters.cid) doTeleportThing(parameters.cid, parameters.toPosition, FALSE) doSendMagicEffect(fromPosition, CONST_ME_POFF) return TRUE end parameters.counter = parameters.counter + 1 doSendDistanceShoot(getCreaturePosition(parameters.cid), parameters.toPosition, CONST_ANI_THROWINGSTAR) doSendDistanceShoot(getCreaturePosition(parameters.cid), parameters.toPosition, CONST_ANI_ARROW) doSendDistanceShoot(getCreaturePosition(parameters.cid), parameters.toPosition, CONST_ANI_SMALLSTONE) addEvent(grappleAnim, 100, parameters) end local useWorms = FALSE local waterIds = {1549} function onUse(cid, item, fromPosition, itemEx, toPosition) if isInArray(waterIds, itemEx.itemid) == TRUE then if itemEx.itemid ~= 1549 then if useWorms == FALSE or useWorms == TRUE and doPlayerRemoveItem(cid, ITEM_WORM, 1) == TRUE then if math.random(1, (100 + (getPlayerSkill(cid, SKILL_FISHING) / 10))) <= getPlayerSkill(cid, SKILL_FISHING) then player:teleportTo(toPos) end doPlayerAddSkillTry(cid, SKILL_FISHING, 1) end end doSendMagicEffect(toPosition, CONST_ME_LOSEENERGY) return TRUE end if (itemEx.actionid == reqActnId and getDistanceBetween(getCreaturePosition(cid), toPosition) <= maxDstnce) then doSendDistanceShoot(fromPosition, toPosition, CONST_ANI_HUNTINGSPEAR) doSendMagicEffect(toPosition, CONST_ME_BLOCKHIT) doTeleportThing(parameters.cid, parameters.toPosition, FALSE) local parameters = {cid = cid, toPosition = toPosition, counter = 0} addEvent(grappleAnim, 100, parameters) else doPlayerSendCancel(cid, "Nothing to hook to in range.") doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF) end return TRUE end
local hook = Action()
local HOOK_ACTION_ID = 3333 -- Put this action id on the objects that you want to be "hookable"
local MAX_HOOK_DISTANCE = 7 -- range for using the item.
function hook.onUse(player, item, fromPosition, target, toPosition, isHotkey)
if not target or target.actionid ~= HOOK_ACTION_ID then
player:sendCancelMessage("You cant hook to this!")
return true
end
local playerPos = player:getPosition()
local targetPos = target:getPosition()
local distanceX = math.abs(playerPos.x - targetPos.x)
local distanceY = math.abs(playerPos.y - targetPos.y)
if math.max(distanceX, distanceY) > MAX_HOOK_DISTANCE then
player:sendCancelMessage("The target is too far away")
return true
end
if player:getCondition(CONDITION_EXHAUST, CONDITIONID_DEFAULT) then
player:sendCancelMessage("You must wait before using the hook again.")
return true
end
local exhaust = Condition(CONDITION_EXHAUST, CONDITIONID_DEFAULT)
exhaust:setParameter(CONDITION_PARAM_TICKS, 5000) -- 5 seconds exhaust timer (people cant spam hook)
player:addCondition(exhaust)
playerPos:sendDistanceEffect(targetPos, CONST_ANI_ARROW) -- effect for shooting the hook
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "bang u shoot ur hook like a madlad") -- message for using the item on the object. (can be removed)
local targetTile = Tile(targetPos)
local targetId = target:getId()
addEvent(function(playerId, targetPos, targetId)
local player = Player(playerId)
if not player then return end
-- checks around the object to find empty space (could be written better idk, dont care - works.)
local teleportPos
local checks = {
{x = 1, y = 0}, {x = -1, y = 0},
{x = 0, y = 1}, {x = 0, y = -1},
{x = 1, y = 1}, {x = -1, y = -1},
{x = 1, y = -1}, {x = -1, y = 1}
}
for _, offset in ipairs(checks) do
local checkPos = Position(targetPos.x + offset.x, targetPos.y + offset.y, targetPos.z)
local tile = Tile(checkPos)
if tile and tile:getGround() and not tile:hasFlag(TILESTATE_BLOCKSOLID) and not tile:getTopCreature() then
teleportPos = checkPos
break
end
end
if not teleportPos then
player:sendCancelMessage("There's no free space around the object broski") -- message for not finding an empty space
return
end
player:teleportTo(teleportPos)
teleportPos:sendMagicEffect(CONST_ME_TELEPORT)
player:say("Whoosh!", TALKTYPE_MONSTER_SAY) -- you can change message after teleporting.
end, 1000, player:getId(), targetPos, targetId)
return true
end
hook:id(2294) -- put your itemID for the hook
hook:allowFarUse(true)
hook:blockWalls(true)
hook:register()