Page 1 of 2
Temporary potion effects [solved]
Posted: Wed Dec 17, 2014 1:27 pm
by Aisuu
So I looked everywhere but didnt find solution for this.
It would by nice to have sortiment of potions with temporary effect, like strenght, dextirity etc..
I know we have rage potion but its hard coded?
I tryed to come up with my own sript solution. This is what I have so far, but dont work

Champion gain +1 strengh but stat wont return to original value.
It should return to original value after 20 sec.
Code: Select all
onUseItem = function(self, champion)
local basestr = champion:getBaseStat("strength")
spawn("timer",party.level,party.x,party.y,party.facing,party.elevation,"strtimer")
spawn("counter",party.level,party.x,party.y,party.facing,party.elevation,"strcounter")
strtimer.timer:addConnector("onActivate","strcounter","increment")
strtimer.timer:setTimerInterval(1)
strcounter.counter:setValue(1)
strtimer.timer:start()
local cvalue = strcounter.counter:getValue()
if cvalue <=20 then
champion:upgradeBaseStat("strength", 1)
else
champion:setBaseStat("strength",basestr)
--stoping and destroy timer/counter
end
end,
Re: Temporary potion effects [not solved]
Posted: Wed Dec 17, 2014 1:49 pm
by Drakkan
just an idea (maybe little "hard" solution, but could work)- what about just making regular potion to gain some stat (for example STR - champion:upgradeBaseStat("strength", 1) ) and put into onUse hook to activate ingame timer (for example called PluStrenght), which after time run out is going to activate another in-game script, which will decrease that stat (champion:upgradeBaseStat("strength", -1) . there need to be some checks which champion used that potion and to whom then decrease that stat, but you have the idea...
Re: Temporary potion effects [not solved]
Posted: Wed Dec 17, 2014 2:08 pm
by Aisuu
I was thinking about such solution, but it seems sooo complicated. Lets just say it wouldn't be ideal if you want to create many such different potions. Thats why I was trying doing it in single onUseItem function. Later I wanted to create trait/condition that indicate you have str potion effect on and prevent champion to drink more then one potion at one time.
Re: Temporary potion effects [not solved]
Posted: Wed Dec 17, 2014 3:51 pm
by THOM
isn't it possible to use delayedCall(self.go.id, <timeInSeconds>, <"Event"> )
Re: Temporary potion effects [not solved]
Posted: Wed Dec 17, 2014 5:16 pm
by Aisuu
I was think about that too. But I dont know how to hook it to external script nor to function itself.
Normaly delayCall is used like this:
function myfunction()
delayedCall(self.go.id,"time","myotherfunction")
end
function myotherfunction()
--do delayed staff here
end
But how to use it within onUseItem function?
EDIT:
Nevermind that, Iam fool

I successfully delayed onUseItem to external script... I let you know final result...
Re: Temporary potion effects [not solved]
Posted: Wed Dec 17, 2014 5:22 pm
by cameronC
THOM wrote:isn't it possible to use delayedCall(self.go.id, <timeInSeconds>, <"Event"> )
I haven't seen this work on a script component of an item, plus since the potion is consumed onUse I don't know if that would work either.
Setting the stat bonuses via trait works, when you go that route, but the traits still need to be removed on a timer so it's the same core issue.
Edit: Yeah, delaying to a separate script entity is probably the simplest way right now. Functional, but not the best way, probably
Re: Temporary potion effects [not solved]
Posted: Wed Dec 17, 2014 5:29 pm
by Aisuu
It is possible, only problem is to somehow identify champion who used potion and send values via delayedCall function to external script. Thats what Iam trying figuring right now
EDIT:
Just to let you know, this doesnt work
Code: Select all
onUseItem = function(self, champion)
delayedCall(self.go.id,2,"callback")
local callback = function()
--do staff
end
end,
Re: Temporary potion effects [not solved]
Posted: Wed Dec 17, 2014 6:04 pm
by Batty
You can add arguments/parameters to delayedCall, so something like:
Code: Select all
delayedCall("script ID", time, "method", champion:getOrdinal())
Re: Temporary potion effects [solved]
Posted: Wed Dec 17, 2014 8:41 pm
by Aisuu
Thx Batty. With your help and inspirations of others I was able to solve it

Here is complete solution and example for adding +1 strenght to champion for 20 seconds.
Add this into potion onUseItem function
Code: Select all
champion:upgradeBaseStat("strength", 1)
delayedCall("yourscript",20,"yourfunction",champion:getOrdinal())
And name your script entity "yourscript" with this function:
Code: Select all
function yourfunction(champ)
local ch = party.party:getChampion(champ)
local modi = ch:getBaseStat("strength")
local base = modi -1
ch:setBaseStat("strength",base)
end
Re: Temporary potion effects [solved]
Posted: Sun Apr 26, 2015 9:08 pm
by Drakkan
Aisuu wrote:Thx Batty. With your help and inspirations of others I was able to solve it

Here is complete solution and example for adding +1 strenght to champion for 20 seconds.
Add this into potion onUseItem function
Code: Select all
champion:upgradeBaseStat("strength", 1)
delayedCall("yourscript",20,"yourfunction",champion:getOrdinal())
And name your script entity "yourscript" with this function:
Code: Select all
function yourfunction(champ)
local ch = party.party:getChampion(champ)
local modi = ch:getBaseStat("strength")
local base = modi -1
ch:setBaseStat("strength",base)
end
could please somebody extend this script so it will return point to the champion which used the potion ? In case you move champion to some other slot, script does not detect it and return point to another one. thanks a lot