12345678910111213141516171819202122232425262728293031323334353637383940 |
- --[[
- Script Name : SpawnScripts/Generic/SpiritShard.lua
- Script Purpose : Spirit Shard
- --]]
- function spawn(NPC)
- local DebtToRemovePct = GetRuleFlagFloat("R_Combat", "ShardDebtRecoveryPercent")
-
- if GetRuleFlagBool("R_Combat", "ShardRecoveryByRadius") == true then
- SetPlayerProximityFunction(NPC, 10.0, "recovershard")
- end
-
- AddPrimaryEntityCommand(nil,NPC,"Recover Spirit Shard",10.0,"recovershard","",0,0,1)
-
- local charID = GetShardCharID(NPC)
- SetAccessToEntityCommandByCharID(NPC, charID, "recovershard", true)
- end
- function recovershard(NPC, Spawn)
- local charid = GetShardCharID(NPC)
-
- if GetCharacterID(Spawn) == charid then
- local DebtToRemovePct = GetRuleFlagFloat("R_Combat", "ShardDebtRecoveryPercent")
- local DeathXPDebt = GetRuleFlagFloat("R_Combat", "DeathExperienceDebt")
-
- local debt = GetInfoStructFloat(Spawn, "xp_debt")
- local DebtToRemove = (DebtToRemovePct/100.0)*(DeathXPDebt/100.0);
- if debt > DebtToRemove then
- SetInfoStructFloat(Spawn, "xp_debt", debt - DebtToRemove)
- else
- SetInfoStructFloat(Spawn, "xp_debt", 0.0)
- end
- PlaySound(Spawn,"sounds/ui/shard_absorb.wav", GetX(NPC), GetY(NPC), GetZ(NPC))
- SendMessage(Spawn, "You recover a spirit shard and recovered some experience debt.", "white")
- SetCharSheetChanged(Spawn, true)
- local shardid = GetShardID(NPC)
- DeleteDBShardID(shardid)
- Despawn(NPC)
- end
- end
|