SpiritShard.lua 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. --[[
  2. Script Name : SpawnScripts/Generic/SpiritShard.lua
  3. Script Purpose : Spirit Shard
  4. --]]
  5. function spawn(NPC)
  6. local DebtToRemovePct = GetRuleFlagFloat("R_Combat", "ShardDebtRecoveryPercent")
  7. if GetRuleFlagBool("R_Combat", "ShardRecoveryByRadius") == true then
  8. SetPlayerProximityFunction(NPC, 10.0, "recovershard")
  9. end
  10. AddPrimaryEntityCommand(nil,NPC,"Recover Spirit Shard",10.0,"recovershard","",0,0,1)
  11. local charID = GetShardCharID(NPC)
  12. SetAccessToEntityCommandByCharID(NPC, charID, "recovershard", true)
  13. end
  14. function recovershard(NPC, Spawn)
  15. local charid = GetShardCharID(NPC)
  16. if GetCharacterID(Spawn) == charid then
  17. local DebtToRemovePct = GetRuleFlagFloat("R_Combat", "ShardDebtRecoveryPercent")
  18. local DeathXPDebt = GetRuleFlagFloat("R_Combat", "DeathExperienceDebt")
  19. local debt = GetInfoStructFloat(Spawn, "xp_debt")
  20. local DebtToRemove = (DebtToRemovePct/100.0)*(DeathXPDebt/100.0);
  21. if debt > DebtToRemove then
  22. SetInfoStructFloat(Spawn, "xp_debt", debt - DebtToRemove)
  23. else
  24. SetInfoStructFloat(Spawn, "xp_debt", 0.0)
  25. end
  26. SendMessage(Spawn, "You recover a spirit shard and recovered some experience debt.", "white")
  27. SetCharSheetChanged(Spawn, true)
  28. local shardid = GetShardID(NPC)
  29. DeleteDBShardID(shardid)
  30. Despawn(NPC)
  31. end
  32. end--[[
  33. Script Name : SpawnScripts/Generic/SpiritShard.lua
  34. Script Purpose : Spirit Shard
  35. --]]
  36. function spawn(NPC)
  37. local DebtToRemovePct = GetRuleFlagFloat("R_Combat", "ShardDebtRecoveryPercent")
  38. if GetRuleFlagBool("R_Combat", "ShardRecoveryByRadius") == true then
  39. SetPlayerProximityFunction(NPC, 10.0, "recovershard")
  40. end
  41. AddPrimaryEntityCommand(nil,NPC,"Recover Spirit Shard",10.0,"recovershard","",0,0,1)
  42. local charID = GetShardCharID(NPC)
  43. SetAccessToEntityCommandByCharID(NPC, charID, "recovershard", true)
  44. end
  45. function recovershard(NPC, Spawn)
  46. local charid = GetShardCharID(NPC)
  47. if GetCharacterID(Spawn) == charid then
  48. local DebtToRemovePct = GetRuleFlagFloat("R_Combat", "ShardDebtRecoveryPercent")
  49. local DeathXPDebt = GetRuleFlagFloat("R_Combat", "DeathExperienceDebt")
  50. local debt = GetInfoStructFloat(Spawn, "xp_debt")
  51. local DebtToRemove = (DebtToRemovePct/100.0)*(DeathXPDebt/100.0);
  52. if debt > DebtToRemove then
  53. SetInfoStructFloat(Spawn, "xp_debt", debt - DebtToRemove)
  54. else
  55. SetInfoStructFloat(Spawn, "xp_debt", 0.0)
  56. end
  57. SendMessage(Spawn, "You recover a spirit shard and recovered some experience debt.", "white")
  58. SetCharSheetChanged(Spawn, true)
  59. local shardid = GetShardID(NPC)
  60. DeleteDBShardID(shardid)
  61. Despawn(NPC)
  62. end
  63. end