9
3

BurningFireinvisiblecube.lua 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. --[[
  2. Script Name : SpawnScripts/Caves/BurningFireinvisiblecube.lua
  3. Script Author : Dorbin
  4. Script Date : 2022.10.12 09:10:48
  5. Script Purpose :
  6. :
  7. --]]
  8. function spawn(NPC)
  9. SetPlayerProximityFunction(NPC, 1, "InRange", "LeaveRange")
  10. end
  11. function respawn(NPC)
  12. spawn(NPC)
  13. end
  14. function InRange(NPC,Spawn,Zone)
  15. if GetDistance(NPC,Spawn)<1 then
  16. SpawnSet(Spawn,"visual_state",492)
  17. TakeFireDamage(Spawn)
  18. SendMessage(Spawn, "You are burning!", "red")
  19. AddTimer(NPC,3000,"InRange",1,Spawn)
  20. end
  21. end
  22. function LeaveRange(NPC,Spawn)
  23. SpawnSet(Spawn,"visual_state",0)
  24. end
  25. function TakeFireDamage(Spawn)
  26. local invul = IsInvulnerable(Spawn)
  27. if invul == true then
  28. return 0
  29. end
  30. local hp = GetHP(Spawn)
  31. local damage = GetMaxHP(Spawn)*0.05
  32. local damageToTake = damage * 1
  33. -- if we don't have enough HP make them die to pain and suffering not self
  34. if hp <= damageToTake then
  35. KillSpawn(Spawn, null, 1)
  36. else
  37. DamageSpawn(Spawn, Spawn, 192, 3, damageToTake, damageToTake, "Fire!", 0, 0, 1, 1)
  38. end
  39. end
  40. function Tick(Zone, Spawn, RegionType)
  41. TakeFireDamage(Spawn)
  42. -- returning 1 would stop the Tick process until Spawn leaves/re-enters region
  43. return 0
  44. end