• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

[Action] Fluids Heals over Time.

Eldin

Eldin Projects
Premium User
Joined
Jun 12, 2008
Messages
1,334
Reaction score
613
Location
Sweden
Dear Scripters and Readers!

After a long time away from OTs ive got a new idea for a server and will therefor need some help to finish the first steps to find out if the server will work or not.

An important thing for the server would be to have potions in wich heals over time.

Normal Health Potion Script:
Code:
local MIN = 30
local MAX = 30
local EMPTY_POTION = 7636

local exhaust = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, (getConfigInfo('timeBetweenExActions') - 100))

function onUse(cid, item, fromPosition, itemEx, toPosition)
	if isPlayer(itemEx.uid) == FALSE then
		return FALSE
	end

	if hasCondition(cid, CONDITION_EXHAUST_HEAL) == TRUE then
		doPlayerSendDefaultCancel(cid, RETURNVALUE_YOUAREEXHAUSTED)
		return TRUE
	end

	if doCreatureAddHealth(itemEx.uid, math.random(MIN, MAX)) == LUA_ERROR then
		return FALSE
	end

	doAddCondition(cid, exhaust)
	doSendMagicEffect(getThingPos(itemEx.uid), CONST_ME_MAGIC_BLUE)
	doCreatureSay(itemEx.uid, "Aaaah...", TALKTYPE_ORANGE_1)
	doTransformItem(item.uid, EMPTY_POTION)
	return TRUE
end

What I need exactly is for the script to heal the player over time, as for example:
10HP every second to a maximum of 30HP. (So basicly 10HP 3 Times)
Note: Its important that its being a potions and not a rune.

Thank You for atleast reading.

Kind Regards,
Eldin
.
 
Code:
local condition = createConditionObject()
setConditionParam(condition, CONDITION_PARAM_DELAYED, true)
setConditionParam(condition, CONDITION_PARAM_FORCEUPDATE, true)
addDamageCondition(condition, 3, 1000, 10)
Code:
	            doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
				doAddCondition(cid, condition)
hmm maybe it work
 
@Dixtro -
Ive tryed to remove the other lines and add yours, didn't work, however, Im probaly doing something wrong as it was along time ago since I scripted.

@Damadger -
As I said, to long time ago, where should I add your code?

Please be patience, I will probaly be into it in a few days again. :)

Kind Regards,
Eldin.
 
Code:
local MIN = 0
local MAX = 0
local EMPTY_POTION = 7636

local condition = createConditionObject()
setConditionParam(condition, CONDITION_PARAM_DELAYED, true)
setConditionParam(condition, CONDITION_PARAM_FORCEUPDATE, true)
addDamageCondition(condition, 3, 1000, 10)

local exhaust = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, (getConfigInfo('timeBetweenExActions') - 100))

function onUse(cid, item, fromPosition, itemEx, toPosition)
	if isPlayer(itemEx.uid) == FALSE then
		return FALSE
	end

	if hasCondition(cid, CONDITION_EXHAUST_HEAL) == TRUE then
		doPlayerSendDefaultCancel(cid, RETURNVALUE_YOUAREEXHAUSTED)
		return TRUE
	end

	if doCreatureAddHealth(itemEx.uid, math.random(MIN, MAX)) == LUA_ERROR then
		return FALSE
	end

	doAddCondition(cid, exhaust)
	doSendMagicEffect(getThingPos(itemEx.uid), CONST_ME_MAGIC_BLUE)
	doCreatureSay(itemEx.uid, "Aaaah...", TALKTYPE_ORANGE_1)
	doTransformItem(item.uid, EMPTY_POTION)
				doAddCondition(cid, condition)

	return TRUE
end
 
?? this is for mana potions
Lua:
local managain = 30
local EMPTY_POTION = 7636
 
local exhaust = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, (getConfigInfo('timeBetweenExActions') - 100))
 
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if isPlayer(itemEx.uid) == FALSE then
		return FALSE
	end
 
	if hasCondition(cid, CONDITION_EXHAUST_HEAL) == TRUE then
		doPlayerSendDefaultCancel(cid, RETURNVALUE_YOUAREEXHAUSTED)
		return TRUE
	end
 
 
 
for i = 1,3 do
   addEvent(doPlayerAddMana,i * 1000, cid,managain)
end
 
	doAddCondition(cid, exhaust)
	doSendMagicEffect(getThingPos(itemEx.uid), CONST_ME_MAGIC_BLUE)
	doCreatureSay(itemEx.uid, "Aaaah...", TALKTYPE_ORANGE_1)
	doTransformItem(item.uid, EMPTY_POTION)
	return TRUE
end
 
Code:
for i = 1, 3 do
	addEvent(function(cid) if isPlayer(cid) then doCreatureAddHealth(cid, math.random(MIN, MAX)) end end, i * 1000, cid)
end

Cyko style. ^_^
 
@Dixtro -

Ive got this in the logg from yours:
Code:
[29/08/2010 23:39:10] Lua Script Error: [Action Interface] 
[29/08/2010 23:39:10] data/actions/scripts/liquids/health_potion.lua

@Damadger -
It worked for the mana fluid. :D
PS: I didn,t add anything as you already had the if isPlayer function, like I said, It worked!

REP on the way for they who helped.

Kind Regards,
Eldin.
 
Feeling quite stupid now, Health Potions wont work.

Code:
local healthgain = 10
local EMPTY_POTION = 7636
 
local exhaust = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, (getConfigInfo('timeBetweenExActions') - 100))
 
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if isPlayer(itemEx.uid) == FALSE then
		return FALSE
	end
 
	if hasCondition(cid, CONDITION_EXHAUST_HEAL) == TRUE then
		doPlayerSendDefaultCancel(cid, RETURNVALUE_YOUAREEXHAUSTED)
		return TRUE
	end
 
for i = 1,3 do
   addEvent(doPlayerAddHealth,i * 1000, cid,healthgain)
end
 
	doAddCondition(cid, exhaust)
	doSendMagicEffect(getThingPos(itemEx.uid), CONST_ME_MAGIC_BLUE)
	doCreatureSay(itemEx.uid, "Aaaah...", TALKTYPE_ORANGE_1)
	doTransformItem(item.uid, EMPTY_POTION)
	return TRUE
end

To late now, gotta sleep.

Kind Regards,
Eldin.
 
Back
Top