Skip to content

Instantly share code, notes, and snippets.

@Rochet2

Rochet2/GMS.diff Secret

Created January 23, 2015 17:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Rochet2/e15e5567934220e759aa to your computer and use it in GitHub Desktop.
Save Rochet2/e15e5567934220e759aa to your computer and use it in GitHub Desktop.
diff --git a/merc.lua b/merc.lua
index cdf4220..35265f7 100644
--- a/merc.lua
+++ b/merc.lua
@@ -70,11 +70,10 @@ local function initMercenary(player, creature)
end
mercTable[creature:GetGUIDLow()] = { guid = player:GetGUIDLow() };
end
--- Function that will get a map userdata and return
+-- Function that will return
-- the userdata connected to that guid on that specific
-- map, returns nil if it doesn't exist.
-local function getUserdata(guid, mapId)
- local map = GetMapById(mapId);
+local function getUserdata(guid, map)
return map:GetWorldObject(guid);
end
-- Function that will return the userdata of the
@@ -91,7 +90,7 @@ local function getWorldObject(object)
else
return false;
end
- return getUserdata(objectGUID, object:GetMapId());
+ return getUserdata(objectGUID, object:GetMap());
end
------------------------------------
-- REGISTER MODULE
diff --git a/mercAI.lua b/mercAI.lua
index 3ab3aac..e9f2ec9 100644
--- a/mercAI.lua
+++ b/mercAI.lua
@@ -305,7 +305,7 @@ local function mercOnAIUpdate(_, creature, diff)
end
-- Making sure the player doesn't get to far away.
if creature:GetDistance(player) >= 40 then
- creature:NearTeleport(table.unpack({player:GetLocation()}));
+ creature:NearTeleport(player:GetLocation());
end
end
------------------------------------
@@ -315,7 +315,7 @@ end
-- # Allowing the option to revive the merc.
------------------------------------
local EVENT_ON_DEATH = 4;
-local function mercOnLeaveCombat(event, creature)
+local function mercOnDeath(event, creature)
if creature:IsMounted() then
creature:Dismount();
end
@@ -325,7 +325,7 @@ end
local function registerEvents()
for entry in pairs(mercs) do
RegisterCreatureEvent(entry, EVENT_ON_AIUPDATE, mercOnAIUpdate);
- RegisterCreatureEvent(entry, EVENT_ON_DEATH, mercOnLeaveCombat);
+ RegisterCreatureEvent(entry, EVENT_ON_DEATH, mercOnDeath);
end
end
CreateLuaEvent(registerEvents, 1000, 1);
@@ -346,9 +346,9 @@ local function onTeleport(_, player)
-- Cleaning up the old mercenary and giving the player
-- a new one, unless in instance / raid.
mercTable[lowGuid] = nil;
- if player:GetInstanceId() == 0 then
+ --if player:GetInstanceId() == 0 then
addMerc(player, id);
- end
+ --end
end
RegisterPlayerEvent(PLAYER_EVENT_ON_UPDATE_ZONE, onTeleport);
------------------------------------
@@ -357,7 +357,7 @@ RegisterPlayerEvent(PLAYER_EVENT_ON_UPDATE_ZONE, onTeleport);
-- # Cleaning up the mercenary
-- # AIupdate will take care of despawning.
------------------------------------
-local PLAYER_EVENT_ON_UPDATE_ZONE = 4;
+local PLAYER_EVENT_ON_LOGOUT = 4;
local function onLogout(_, player)
if not hasMerc(player) then return; end
local creature = getWorldObject(player);
@@ -367,7 +367,7 @@ local function onLogout(_, player)
end
creature:DespawnOrUnsummon();
end
-RegisterPlayerEvent(PLAYER_EVENT_ON_UPDATE_ZONE, onLogout);
+RegisterPlayerEvent(PLAYER_EVENT_ON_LOGOUT, onLogout);
------------------------------------
-- On level change hook:
-- # Leveling up the mercenary.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment