mirror of
				https://github.com/ErikasKontenis/SabrehavenServer.git
				synced 2025-10-31 03:56:22 +01:00 
			
		
		
		
	refactor chests rewards description to show enchant value
This commit is contained in:
		| @@ -51,39 +51,60 @@ function onUse(player, item, fromPosition, target, toPosition) | ||||
| 	if rewardClone:getType():getAttack() > 0 then | ||||
| 		rewardClone:setAttribute(ITEM_ATTRIBUTE_ATTACK, rewardClone:getType():getAttack() + attackAttribute) | ||||
| 		local description = rewardClone:hasAttribute(ITEM_ATTRIBUTE_DESCRIPTION) and rewardClone:getAttribute(ITEM_ATTRIBUTE_DESCRIPTION) or rewardClone:getType():getDescription() | ||||
| 		if description ~= nil and description ~= '' then | ||||
| 			description = description .. ". " | ||||
| 		end | ||||
| 		 | ||||
| 		if attackAttribute == 5 then | ||||
| 			if description == nil or description == '' then | ||||
| 				rewardClone:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, description .. "Enchanted with perfect attack.") | ||||
| 			else | ||||
| 				rewardClone:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, description .. ". Enchanted with perfect attack.") | ||||
| 			rewardClone:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, description .. "Enchanted with perfect attack.") | ||||
| 		else | ||||
| 			if attackAttribute ~= 0 then | ||||
| 				rewardClone:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, description .. "Enchanted with " .. attackAttribute .. " attack.") | ||||
| 			end | ||||
| 		end | ||||
| 	end | ||||
| 	 | ||||
| 	local defenseAttribute = math.random(-2, 5) | ||||
| 	if rewardClone:getType():getDefense() > 0 then | ||||
| 		rewardClone:setAttribute(ITEM_ATTRIBUTE_DEFENSE, rewardClone:getType():getDefense() + defenseAttribute) | ||||
| 		local description = rewardClone:hasAttribute(ITEM_ATTRIBUTE_DESCRIPTION) and rewardClone:getAttribute(ITEM_ATTRIBUTE_DESCRIPTION) or rewardClone:getType():getDescription() | ||||
| 		if defenseAttribute == 5 then | ||||
| 			if attackAttribute == 5 and rewardClone:getType():getAttack() > 0 then | ||||
| 		 | ||||
| 		if rewardClone:getType():getAttack() > 0 and attackAttribute ~= 0 then | ||||
| 			if defenseAttribute == 5 then | ||||
| 				rewardClone:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, description .. " Enchanted with perfect defense.") | ||||
| 			else | ||||
| 				if description == nil or description == '' then | ||||
| 					rewardClone:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, description .. "Enchanted with perfect defense.") | ||||
| 				else | ||||
| 					rewardClone:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, description .. ". Enchanted with perfect defense.") | ||||
| 				if defenseAttribute ~= 0 then | ||||
| 					rewardClone:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, description .. " Enchanted with " .. defenseAttribute .. " defense.") | ||||
| 				end | ||||
| 			end | ||||
| 		else | ||||
| 			if description ~= nil and description ~= '' then | ||||
| 				description = description .. ". " | ||||
| 			end | ||||
| 			 | ||||
| 			if defenseAttribute == 5 then | ||||
| 				rewardClone:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, description .. "Enchanted with perfect defense.") | ||||
| 			else | ||||
| 				if defenseAttribute ~= 0 then | ||||
| 					rewardClone:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, description .. "Enchanted with " .. defenseAttribute .. " defense.") | ||||
| 				end | ||||
| 			end | ||||
| 		end | ||||
| 	end | ||||
| 	 | ||||
| 	local armorAttribute = math.random(-1, 2) | ||||
| 	if rewardClone:getType():getArmor() > 0 then | ||||
| 		rewardClone:setAttribute(ITEM_ATTRIBUTE_ARMOR, rewardClone:getType():getArmor() + armorAttribute) | ||||
| 		local description = rewardClone:hasAttribute(ITEM_ATTRIBUTE_DESCRIPTION) and rewardClone:getAttribute(ITEM_ATTRIBUTE_DESCRIPTION) or rewardClone:getType():getDescription() | ||||
| 		if description ~= nil and description ~= '' then | ||||
| 			description = description .. ". " | ||||
| 		end | ||||
| 		 | ||||
| 		if armorAttribute == 2 then | ||||
| 			if description == nil or description == '' then | ||||
| 				rewardClone:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, description .. "Enchanted with perfect armor protection.") | ||||
| 			else | ||||
| 				rewardClone:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, description .. ". Enchanted with perfect armor protection.") | ||||
| 			rewardClone:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, description .. "Enchanted with perfect armor protection.") | ||||
| 		else | ||||
| 			if armorAttribute ~= 0 then | ||||
| 				rewardClone:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, description .. "Enchanted with " .. armorAttribute .. " armor protection.") | ||||
| 			end | ||||
| 		end | ||||
| 	end | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 ErikasKontenis
					ErikasKontenis