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

smart projectiles

Just guessing:
The way projectiles are drawn is different, because thy are slow, cant really tell about that. BBut to make it move, you may try to change

Try to recalculate the position of the spell target with an event? Never tried.
 
Last edited by a moderator:
Just guessing:
The way projectiles are drawn is different, because thy are slow, cant really tell about that. BBut to make it move, you may try to change

What?!

Ontopic. Try to recalculate the position of the spell target with an event? Never tried.
I think I need to rewrite the part about the client's missiles, maybe I can change the missel coordinate via server protocol
 
the problem is you are asking on otland dont waste your time just go to tibiaking people are actually uploading stuff there for free instead of 5$ foer my OT PLX
so much for a fucking open source community when people will eat you like lizards for uploading content like CAST system because men i was making some monis for my scripts
I really did not know, what is allowed to post links or make references to other forums...
 
I tried to do this but in the end it looked very buggy! I started with adding a speed variable inside tfs sources and for otclient, with that i can make projectiles faster or slower. The issue is when you make them slower it wont follow the target since thats not how missiles are coded, u have to make pathfinding and make them into actual "things"

But even if u manage to just make them slower u can have them as custom spells animations, animations for quuests and what not. (Where the missiles aren't supposed to follow the target but instead should go to a certain position) But if you want to make them actually follow targets and such it's quite advanced.
 
Hello Friends :) I see my video up there.

Here is the code I used, it's for TFS 0.X (not TFS 1.X) so you are using the new TFS you'll have to edit it to make it work probably.
Code:
function shootProjectileTo(cid, pos, oldpos, disteffect, count, speed, combat, area, min, max, effect, aggressive)
    if isCreature(cid) then
        local target = pos
        if isCreature(target) then
            pos = getCreaturePosition(target)
        end
        if not oldpos then oldpos = getCreaturePosition(cid) end
        local newPos = getPositionByDirection({x=oldpos.x, y=oldpos.y, z=oldpos.z}, getDirectionTo(oldpos, pos, true), 1)
        newPos.stackpos = 1
        local hit = false
        if getDistanceBetween(newPos, pos) <= 0 then
            hit = true
        elseif isTile(newPos) then
            while newPos.stackpos < 256 and hit == false do
                local thing = getThingFromPosition(newPos)
                if thing.uid == 0 and newPos.stackpos == 0 then
                    newPos.stackpos = 256
                elseif thing.uid == 0 and newPos.stackpos > 3 and newPos.stackpos < 255 then
                    newPos.stackpos = 255
                else
                    newPos.stackpos = newPos.stackpos + 1
                end
                if thing.uid > 0 then
                    if isCreature(thing.uid) then
                        hit = true
                    elseif thing.itemid > 0 then
                        local thingInfo = getItemInfo(thing.itemid)
                        if thingInfo.blockSolid == true and math.random(1, 100) < 50 then
                            hit = true
                        end
                        if thingInfo.blockProjectile == true then
                            newPos = oldpos
                            hit = true
                        end
                    end
                end
            end
        end
       
        if hit and combat then
            if isCreature(cid) then
                doAreaCombatHealth(cid, combat, newPos, area, min, max, effect, aggressive)
            else
                doSendMagicEffect(newPos, 55)
            end
            return true
        end
        doSendDistanceShoot(oldpos, newPos, disteffect, false, speed)
        if not count then count = 1 end
        count = count - 1
        if count > 0 then
            addEvent(shootProjectileTo, speed, cid, target, newPos, disteffect, count, speed, combat, area, min, max, effect, aggressive)
            return true
        end
    end
    return true
end

Also, you may notice my function has a new variable:

Code:
  doSendDistanceShoot(oldpos, newPos, disteffect, false, speed)

Speed is not included in the original doSendDistanceShoot, I added this to make the projectile slow down and look better.

You can use this function without any edits by just removing the speed variable from this line.
 
Last edited by a moderator:
Hello Friends :) I see my video up there.

Here is the code I used, it's for TFS 0.X (not TFS 1.X) so you are using the new TFS you'll have to edit it to make it work probably.
Code:
function shootProjectileTo(cid, pos, oldpos, disteffect, count, speed, combat, area, min, max, effect, aggressive)
    if isCreature(cid) then
        local target = pos
        if isCreature(target) then
            pos = getCreaturePosition(target)
        end
        if not oldpos then oldpos = getCreaturePosition(cid) end
        local newPos = getPositionByDirection({x=oldpos.x, y=oldpos.y, z=oldpos.z}, getDirectionTo(oldpos, pos, true), 1)
        newPos.stackpos = 1
        local hit = false
        if getDistanceBetween(newPos, pos) <= 0 then
            hit = true
        elseif isTile(newPos) then
            while newPos.stackpos < 256 and hit == false do
                local thing = getThingFromPosition(newPos)
                if thing.uid == 0 and newPos.stackpos == 0 then
                    newPos.stackpos = 256
                elseif thing.uid == 0 and newPos.stackpos > 3 and newPos.stackpos < 255 then
                    newPos.stackpos = 255
                else
                    newPos.stackpos = newPos.stackpos + 1
                end
                if thing.uid > 0 then
                    if isCreature(thing.uid) then
                        hit = true
                    elseif thing.itemid > 0 then
                        local thingInfo = getItemInfo(thing.itemid)
                        if thingInfo.blockSolid == true and math.random(1, 100) < 50 then
                            hit = true
                        end
                        if thingInfo.blockProjectile == true then
                            newPos = oldpos
                            hit = true
                        end
                    end
                end
            end
        end
      
        if hit and combat then
            if isCreature(cid) then
                doAreaCombatHealth(cid, combat, newPos, area, min, max, effect, aggressive)
            else
                doSendMagicEffect(newPos, 55)
            end
            return true
        end
        doSendDistanceShoot(oldpos, newPos, disteffect, false, speed)
        if not count then count = 1 end
        count = count - 1
        if count > 0 then
            addEvent(shootProjectileTo, speed, cid, target, newPos, disteffect, count, speed, combat, area, min, max, effect, aggressive)
            return true
        end
    end
    return true
end
You're an amazing person, I really appreciate your contributions.
Btw is OTC required to change the speed of projectiles? I think I read a while back that the normal tibia client can't do it
 
yes, the tibia client uses a default function, you can't send a new speed.

I think the Tibia Client uses something like (100+10*dist) = time for projectile to reach destination

The OtClient has a similar function, but it is easy to just send the speed and choose it yourself.
If you don't send the speed, just let it use the default.
 
thanks @Flatlander, this was my attempt to replicate the effect, before seeing your code

Lua:
function shootProjectileTo(cid, pos, oldPos, effect, count)
    if not count then
        count = 1
    end
    local backCount = count+1
    local path = getPathToPos(cid, pos)
    if path ~= false then
        local newPos = getPositionByDirection(oldPos, path[count], 1)
        if count == #path then
            doSendDistanceShoot(getCreaturePosition(cid), newPos, effect)
        end
        if count < #path then
            if isWalkable(newPos, true, false, true) then
                shootProjectileTo(cid, pos, newPos, effect, count+1)
            else
                doSendDistanceShoot(getCreaturePosition(cid), newPos, effect)
            end
        end
    end
end
 
Yea that wouldn't work :p

You need it to re-check each tile to update the path, the best way is to just move the projectile 1 tile at a time in the direction of the target.
 
Back
Top