aGuardDog.lua 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. --[[
  2. Script Name : SpawnScripts/Cache/aGuardDog.lua
  3. Script Author : Dorbin
  4. Script Date : 2022.12.05 04:12:01
  5. Script Purpose :
  6. :
  7. --]]
  8. require "SpawnScripts/Generic/CombatModule"
  9. function spawn(NPC, Spawn)
  10. combatModule(NPC, Spawn)
  11. SetPlayerProximityFunction(NPC, 7, "InRange", "LeaveRange")
  12. SetTempVariable(NPC, "OnGuard", "true")
  13. end
  14. function InRange(NPC,Spawn)
  15. if GetTempVariable(NPC,"OnGuard")=="true" and not IsInCombat(NPC) and GetY(Spawn) <=2 then
  16. FaceTarget(NPC,Spawn)
  17. SetTempVariable(NPC, "OnGuard", "false")
  18. AddTimer(NPC,1500,"Checking",1,Spawn)
  19. AddTimer(NPC,6000,"Checking",1,Spawn)
  20. AddTimer(NPC,8000,"Checking",1,Spawn)
  21. AddTimer(NPC,10000,"ResetGuard",1,Spawn)
  22. AddTimer(NPC,9000,"ResetGuardEmote",1,Spawn)
  23. choice = MakeRandomInt(1,2)
  24. if choice ==1 then
  25. SendMessage(Spawn,"The dog lets out a low growl.")
  26. elseif choice ==2 then
  27. SendMessage(Spawn,"The dog's ears twitch.")
  28. end
  29. end
  30. end
  31. function LeaveRange(NPC,Spawn)
  32. if GetTempVariable(NPC,"OnGuard")=="false" then
  33. SetTempVariable(NPC, "OnGuard", "true")
  34. end
  35. end
  36. function Checking(NPC,Spawn)
  37. if GetDistance(NPC,Spawn) <=8 and HasMoved(Spawn) then
  38. Attack(NPC,Spawn)
  39. end
  40. end