Well, I thought I'd try to create an NPC that would follow a player around in an instance and heal them (for lack of players on a server). However, of course, I am confronting a couple of problems. Here is my script so far.
Code:
warrior = 1
pally = 2
druid = 11
function On_Gossip(unit, event, player)
unit:GossipCreateMenu(12674, player, 0)
unit:GossipMenuAddItem(2, "Who Are You?", 1, 0)
unit:GossipSendMenu(player)
end
function Gossip_Submenus(unit, event, player, id, intid, code)
if(intid == 2) then
unit:GossipCreateMenu(12674, player, 0)
unit:GossipMenuAddItem(2, "Who Are You?", 1, 0)
unit:GossipSendMenu(player)
end
if(intid == 1) then
unit:GossipCreateMenu(12675, player, 0)
unit:GossipMenuAddItem(2, "Yes, please help me", 8, 0)
unit:GossipMenuAddItem(2, "No thanks we're set", 9, 0)
unit:GossipSendMenu(player)
end
if(intid == 9) then
unit:GossipCreateMenu(12676, player, 0)
unit:GossipSendMenu(player)
end
if(intid == 8) then
unit:GossipCreateMenu(12671, player, 0)
unit:GossipSendMenu(player)
unit:MoveTo(-229.042, 2111.88, 76.8898, 5.08992)
unit:SendChatMessage(12, 0, "The first group of enemies lie ahead. ATTACK!")
unit:GossipComplete(player)
end
end
function Select_Target(unit, Event)
unit:GetClosestPlayer()
if unit:GetPlayerRace() == warrior then
unit:SetUnitToFollow(target)
end
if unit:GetPlayerRace() == druid then
unit:SetUnitToFollow(target)
end
if unit:GetPlayerRace() == pally then
unit:SetUnitToFollow(target)
end
end
RegisterUnitGossipEvent(1000015, 1, "On_Gossip")
RegisterUnitGossipEvent(1000015, 2, "Gossip_Submenus")
RegisterUnitEvent(1000015, 18, "Select_Target")
When I enter the instance and wait about a minute, I find that absolutely nothing happens. I have tried to remove:
Code:
if unit:GetPlayerRace() == warrior then
if unit:GetPlayerRace() == pally then
unit:SetUnitToFollow(target)
if unit:GetPlayerRace() == druid then
unit:SetUnitToFollow(target)
so the script now became:
Code:
warrior = 1
pally = 2
druid = 11
function On_Gossip(unit, event, player)
unit:GossipCreateMenu(12674, player, 0)
unit:GossipMenuAddItem(2, "Who Are You?", 1, 0)
unit:GossipSendMenu(player)
end
function Gossip_Submenus(unit, event, player, id, intid, code)
if(intid == 2) then
unit:GossipCreateMenu(12674, player, 0)
unit:GossipMenuAddItem(2, "Who Are You?", 1, 0)
unit:GossipSendMenu(player)
end
if(intid == 1) then
unit:GossipCreateMenu(12675, player, 0)
unit:GossipMenuAddItem(2, "Yes, please help me", 8, 0)
unit:GossipMenuAddItem(2, "No thanks we're set", 9, 0)
unit:GossipSendMenu(player)
end
if(intid == 9) then
unit:GossipCreateMenu(12676, player, 0)
unit:GossipSendMenu(player)
end
if(intid == 8) then
unit:GossipCreateMenu(12671, player, 0)
unit:GossipSendMenu(player)
unit:MoveTo(-229.042, 2111.88, 76.8898, 5.08992)
unit:SendChatMessage(12, 0, "The first group of enemies lie ahead. ATTACK!")
unit:GossipComplete(player)
end
end
function Select_Target(unit, Event)
unit:GetClosestPlayer()
unit:SetUnitToFollow(target)
end
RegisterUnitGossipEvent(1000015, 1, "On_Gossip")
RegisterUnitGossipEvent(1000015, 2, "Gossip_Submenus")
RegisterUnitEvent(1000015, 18, "Select_Target")
but then I get an error message that the unit that the target the Healer NPC is supposed to follow is "nil" (doesnt exist). I have also tried this, just as a test:
Code:
function Select_Target(unit, Event)
unit:GetClosestPlayer()
unit:RegisterEvent("Cast_Fireball", 10000, 1)
end
function Cast_Fireball(unit, Event)
unit:FullCastSpellOnTarget(133, target)
end
However, I (again) get a message that no target is found. Has anybody else been having problems with NPCs selecting characters using LUA? or is there something wrong with the script.
Thanks!