Page 1 of 1

Energy Regeneration

Posted: Sun Dec 09, 2012 7:29 pm
by LordGarth
I was hoping to make some necklaces that increase health and energy regeneration.

Does anyone know how to do this.

Thx,

LG

Re: Energy Regeneration

Posted: Sun Dec 09, 2012 9:07 pm
by Diarmuid
Until we get onEquipItem next update, you can set up a constant timer then call a function that checks if the amulet is worn and add health & energy to champions at the intervals you want. (For example, if you wish your Amulet of Regeneration to add 1hp every 30s, check every 30s).

For example, I have the following script in my dungeon which checks every 5s if an Amulet of Darkness is worn, and if there is a light spell on, puts it back in the inventory or on the ground if there's no space. Storywise, the idea is that the item is powerful, but the tradeoff is that ih has an "evil" aura which prevents you from casting light spells or wearing it while a light spell is active. You can adapt the search function to suit your needs, I took the code from somewhere in these forums:

Code: Select all

function amuletDark()
	local champion
	local slot
	local champID
	local placed = false
	local currentItem
	for champID=1,4 do
 		champion = party:getChampion(champID)
		currentItem = champion:getItem(6)
		if currentItem ~= nil and currentItem.name == "amulet_dark" then
			if lightTracker.lightLevel > 0 then
				champion:removeItem(6)
				hudPrint("You cannot wear the Amulet of Darkness while a light spell is active.")
				for slot =11,31 do
					currentItem = champion:getItem(slot)
					if currentItem == nil and placed == false then
						champion:insertItem(slot, spawn("amulet_dark"))
						placed = true
					end
					if placed == false then
						spawn("amulet_dark",party.level, party.x, party.y, party.facing)
					end				
				end
			end
   		end
	end
end