Browse Source

Spirit shards now decay per request from premierio <3

Emagi 1 year ago
parent
commit
ec247da687

+ 1 - 0
EQ2/source/WorldServer/Rules/Rules.cpp

@@ -239,6 +239,7 @@ void RuleManager::Init()
 	RULE_INIT(R_Combat, SpiritShardSpawnScript, "SpawnScripts/Generic/SpiritShard.lua");
 	RULE_INIT(R_Combat, ShardDebtRecoveryPercent, "25.00"); // recovered percentage of debt upon obtainig shard, 25/100 means 25%.  If there is .5 DeathExperienceDebt, .5*25% = .125,  .5 - .125 = .375
 	RULE_INIT(R_Combat, ShardRecoveryByRadius, "1"); // allow shards to auto pick up by radius, not requiring to click/right click the shard
+	RULE_INIT(R_Combat, ShardLifetime, "86400"); // default: 86400 seconds (one day)
 	RULE_INIT(R_Combat, EffectiveMitigationCapLevel, "80"); // level multiplier for max effective cap, level * 80 (default)
 	RULE_INIT(R_Combat, CalculatedMitigationCapLevel, "100"); // The cap to calculate your mitigation from is [level*100].
 	RULE_INIT(R_Combat, MitigationLevelEffectivenessMax, "1.5"); // ratio victim level / attacker level for max effectiveness, when victim is higher level cap can reach 1.5

+ 1 - 0
EQ2/source/WorldServer/Rules/Rules.h

@@ -97,6 +97,7 @@ enum RuleType {
 	SpiritShardSpawnScript,
 	ShardDebtRecoveryPercent,
 	ShardRecoveryByRadius,
+	ShardLifetime,
 	EffectiveMitigationCapLevel,
 	CalculatedMitigationCapLevel,
 	MitigationLevelEffectivenessMax,

+ 23 - 0
server/SpawnScripts/Generic/SpiritShard.lua

@@ -14,6 +14,8 @@ function spawn(NPC)
 	
 	local charID = GetShardCharID(NPC)
 	SetAccessToEntityCommandByCharID(NPC, charID, "recovershard", true)
+
+	CheckShardExpired(NPC) -- update 4/22/2023 to remove long standing shards
 end
 
 function recovershard(NPC, Spawn)
@@ -37,4 +39,25 @@ function recovershard(NPC, Spawn)
 		DeleteDBShardID(shardid)
 		Despawn(NPC)
 	end
+end
+
+function CheckShardExpired(NPC)
+	local creationStamp = GetShardCreatedTimestamp(NPC)
+	local year_ = string.sub(creationStamp, 0, 4)
+	local month_ = string.sub(creationStamp, 5, 6)
+	local day_ = string.sub(creationStamp, 7, 8)
+	local hour_ = string.sub(creationStamp, 9, 10)
+	local min_ = string.sub(creationStamp, 11, 12)
+	local sec_ = string.sub(creationStamp, 13, 14)
+	local currentUTCTime = os.time(os.date('!*t'))
+	local creationTime = os.time{year=year_, month=month_, day=day_, hour=hour_, min=min_,sec=sec_}
+	
+	local resultDiff = currentUTCTime - creationTime;
+	local shardLifeTime = GetRuleFlagFloat("R_Combat", "ShardLifetime")
+	
+	if shardLifeTime > 0 and resultDiff > shardLifeTime then
+		local shardid = GetShardID(NPC)
+		DeleteDBShardID(shardid) -- you could alternatively choose to not delete from DB, but for now it only holds XP debt recovery not items
+		Despawn(NPC)
+	end
 end