• This is a read only backup of the old Emudevs forum. If you want to have anything removed, please message me on Discord: KittyKaev

Eluna script

Status
Not open for further replies.

Nirelz

Epic Member
Code:
local entry = 44011
local T =
{
    {1122.253174, -1785.297729, 60.963055, "Let's begin our journey"},
    {1106.852173, -1792.795776, 60.794872, "Test2"}, -- this text is just to see if it actually loaded correctly
    {1078.978149, -1803.456421, 65.286316, "Test3"}, -- this text is just to see if it actually loaded correctly
}

local function Move(creature, id)
    creature:MoveClear()
    if(not id) then
        id = 1
    elseif(#T < id) then -- last point reached, dont do anything
        return
    end

    local x,y,z,text = table.unpack(T[id])
    creature:MoveTo(id, x, y, z)
    if(text) then
        creature:SendUnitSay(text, 0)
    end
end

local function QuestAccept(event, player, creature, quest)
    if(quest:GetId() == 30006) then
        Move(creature) -- start moving
    end
end

local function ReachedPoint(event, creature, Type, id)
    if(Type == 8) then
        Move(creature, id+1) -- move to next point
    end
end
 
RegisterCreatureEvent(entry, 31, QuestAccept)
RegisterCreatureEvent(entry, 6, ReachedPoint)

When reached reached first waypoint he stops and tells "test2" "test3" but he dosnt move to the waypoint i added in on it
Anyone got any idea why?

side-note: talked with Rochet alot regarding this and couldnt rly figure out why he didnt move on reaching first waypoint
 
Last edited:

Tommy

Founder
I've had my fair share of fights with their waypoint system. If I remember correctly, reaching the last waypoint never worked for me. I don't remember; however, I'll check it out.
 

Tommy

Founder
Taken the logic from one of my projects, I remember that I had trouble using the MovementInform function when having multiple waypoints. As I tried everything else, I had to use this method:

Example (Paste2)
Example (Pastebin)

And here is your code.

GREEN = ADDED

Code:
local entry = 44011
[COLOR=#006400]local pointId = 0
local canMove = false;[/COLOR]
local T =
{
    {1122.253174, -1785.297729, 60.963055, "Let's begin our journey"},
    {1106.852173, -1792.795776, 60.794872, "Test2"}, -- this text is just to see if it actually loaded correctly
    {1078.978149, -1803.456421, 65.286316, "Test3"}, -- this text is just to see if it actually loaded correctly
}

local function Move(creature, id)
    creature:MoveClear()
    if(not id) then
        id = 1
    elseif(#T < id) then -- last point reached, dont do anything
        return
    end

    local x,y,z,text = table.unpack(T[id])
    creature:MoveTo(id, x, y, z)
    [COLOR=#006400]pointId = id[/COLOR]
    if(text) then
        creature:SendUnitSay(text, 0)
    end
end

local function QuestAccept(event, player, creature, quest)
    if(quest:GetId() == 30006) then
        Move(creature) -- start moving
    end
end

local function ReachedPoint(event, creature, Type, id)
    if(Type == 8) then
[COLOR=#006400]        pointId = id
        canMove = true[/COLOR]
    end
end

[COLOR=#006400]local function UpdateAI(event, creature, diff)
    if (pointId == 1 and canMove) then
        Move(creature, pointId+1)
        canMove = false
    elseif (pointId == 2 and canMove) then
        Move(creature, pointId+1)
        canMove = false
    end
end[/COLOR]
 
RegisterCreatureEvent(entry, 31, QuestAccept)
RegisterCreatureEvent(entry, 6, ReachedPoint)
[COLOR=#006400]RegisterCreatureEvent(entry, 7, UpdateAI)[/COLOR]


And I must say, it works like a charm:

lgt4d2f.png


He ran too fast for me to catch the chat bubble with 'Test3' in it, but he did reach the last WP:

N94zvyq.jpg



Perhaps there is a better way? If there is, I never found it, nor did I really look into it.


Anyway, I hope this helps.
 

Rochet2

Moderator / Eluna Dev
After some testing it seems that the hook fires before the moving to the point is finished totally or something similar.
The point movements need to be timed beforehand or they need a small timed event before firing the next move:

Code:
local entry = 44011
local T =
{
    {1122.253174, -1785.297729, 60.963055, "Let's begin our journey"},
    {1106.852173, -1792.795776, 60.794872, "Test2"}, -- this text is just to see if it actually loaded correctly
    {1078.978149, -1803.456421, 65.286316, "Test3"}, -- this text is just to see if it actually loaded correctly
}

local function Move(creature, id)
    creature:MoveClear()
    if(not id) then
        id = 1
    elseif(#T < id) then -- last point reached, dont do anything
        return
    end

    local x,y,z,text = table.unpack(T[id])
    creature:MoveTo(id, x, y, z)
    if(text) then
        creature:SendUnitSay(text, 0)
    end
end

local function QuestAccept(event, player, creature, quest)
    if(quest:GetId() == 30006) then
        Move(creature) -- start moving
    end
end

local function ReachedPoint(event, creature, Type, id)
    if(Type == 8) then -- move point type
        [COLOR="#FF0000"]creature:RegisterEvent(function() [/COLOR]Move(creature, id+1)[COLOR="#FF0000"] end, 0, 1)[/COLOR] -- move to next point (smallest delay possible)
    end
end
 
RegisterCreatureEvent(entry, 31, QuestAccept)
RegisterCreatureEvent(entry, 6, ReachedPoint)
 

Tommy

Founder
Thank you, Tommy

What i dont understand is the canMove part, why is it required?

So the code in 'UpdateAI' won't spam.


After some testing it seems that the hook fires before the moving to the point is finished totally or something similar.
The point movements need to be timed beforehand or they need a small timed event before firing the next move:

Code:
local entry = 44011
local T =
{
    {1122.253174, -1785.297729, 60.963055, "Let's begin our journey"},
    {1106.852173, -1792.795776, 60.794872, "Test2"}, -- this text is just to see if it actually loaded correctly
    {1078.978149, -1803.456421, 65.286316, "Test3"}, -- this text is just to see if it actually loaded correctly
}

local function Move(creature, id)
    creature:MoveClear()
    if(not id) then
        id = 1
    elseif(#T < id) then -- last point reached, dont do anything
        return
    end

    local x,y,z,text = table.unpack(T[id])
    creature:MoveTo(id, x, y, z)
    if(text) then
        creature:SendUnitSay(text, 0)
    end
end

local function QuestAccept(event, player, creature, quest)
    if(quest:GetId() == 30006) then
        Move(creature) -- start moving
    end
end

local function ReachedPoint(event, creature, Type, id)
    if(Type == 8) then -- move point type
        [COLOR=#FF0000]creature:RegisterEvent(function() [/COLOR]Move(creature, id+1)[COLOR=#FF0000] end, 0, 1)[/COLOR] -- move to next point (smallest delay possible)
    end
end
 
RegisterCreatureEvent(entry, 31, QuestAccept)
RegisterCreatureEvent(entry, 6, ReachedPoint)

Interesting. :p
 
Status
Not open for further replies.
Top