arcemu/arcemu — Issue #16: SetUnitToFollow() On Leave Combat
Author: Lokenn
Created: 2011-11-14 01:51:06+00:00
State: open

SetUnitToFollow() seems to work, but when unit leaves combat first return to his spawnpoint and then will follow the player again. This is very uggly...

TEST = {}

function TEST.OnSpeak( unit, event, player )
unit:GossipCreateMenu( 9955, player, 0 );
unit:GossipMenuAddItem( 0, "YES!", 1, 0 );
unit:GossipMenuAddItem( 0, "NO!", 3, 0 );
unit:GossipSendMenu(player);
end

function TEST.OnSelection( unit, event, player, id, intid, code )
if( intid == 1 ) then
unit:SetUnitToFollow(player, math.random(1,8), 1)
player:GossipComplete();
elseif( intid == 3 ) then
player:GossipComplete();
end
end

function TEST.OnLeave( unit, event, player)
target = unit:GetClosestPlayer()
unit:SetUnitToFollow(target, math.random(1,8), 1)
end

RegisterUnitEvent( 999999, 2, "TEST.OnLeave" );
RegisterUnitGossipEvent( 999999, 1, "TEST.OnSpeak" );
RegisterUnitGossipEvent( 999999, 2, "TEST.OnSelection" );