Page 2 of 2
Re: Need "award EXP script"
Posted: Thu Oct 18, 2012 10:34 am
by Grimwold
Here's another example of a function to grant experience that makes use of variables.
Code: Select all
function grantExp(amount)
for i = 1,4 do
party:getChampion(i):gainExp(amount)
end
end
place this in a script entiy (say called global_scripts) and whenever you want to award the party some experience, as part of another script, call the function with the amount you want to give.
e.g.
if you are calling it from a different script entity, be sure to include the name of the script where the experience function is stored, as I have done in the example above.
Note this will not work with connectors, only with scripts, because you cannot pass the variable "amount" from a connector.
Re: Need "award EXP script"
Posted: Thu Oct 18, 2012 10:51 am
by imjodokast
Well now I can't figure out a way to stop re-awarding exp. Right now I have it to award exp when 4 torch holders have torch. But removing a torch and putting it back will award the exp again. Should I be doing a separate script to award the exp that gets removed somehow? Or are you able to make the EXP number a variable that gets changed to "0" after the first award?
Re: Need "award EXP script"
Posted: Thu Oct 18, 2012 11:13 am
by msyblade
I just make sure to tie them to a lock, or hidden plate set activate once one step inside the granted area
Re: Need "award EXP script"
Posted: Thu Oct 18, 2012 11:21 am
by Grimwold
imjodokast wrote:Well now I can't figure out a way to stop re-awarding exp. Right now I have it to award exp when 4 torch holders have torch. But removing a torch and putting it back will award the exp again. Should I be doing a separate script to award the exp that gets removed somehow? Or are you able to make the EXP number a variable that gets changed to "0" after the first award?
I've only really used activate once pressure plates for granting XP, but you could use a counter with initial value 1 that is decremented when the puzzle is solved (but not incremented when it is unsolved). Link the counter to the exp script and it will activate when it hits 0... if the puzzle is re-solved the counter will not reactivate.
An alternative way to do it could be to use a variable.
Code: Select all
4torch_exp = 250 -- initialise variable at the start
function 4torchAward()
global_scripts.grantExp(4torch_exp)
4torch_exp = 0
end
Make sure you change
global_scripts to the name of the script entity where you have the grantExp() function.
Trigger this script when the 4 torches are in and after the first activation the exp is set to 0.
Re: Need "award EXP script"
Posted: Sat Jan 05, 2013 11:28 am
by vidarfreyr
Here is what I did in a similar situation. This script awards EXP for taking item off an altar. For this to work you need only one ScriptEntity and one counter + the altar ofcourse with some item on it. The altar is connected to the script entity so that when it is activated it activates the script. Thats it.
Code: Select all
function xpaltar()
if altar_name:getItemCount() == 0 then
counter_name:increment()
end
if counter_name:getValue() == 1 then
hudPrint ("Gained 1500 exp.")
for i=1,4 do
party:getChampion(i):gainExp(1500)
end
counter_name:increment()
playSound("secret")
end
end
If i had 4 altars (same concept applies for 4 torch holders):
Code: Select all
function xpaltarx4()
if altar_1:getItemCount() == 0 and
altar_2:getItemCount() == 0 and
altar_3:getItemCount() == 0 and
altar_4:getItemCount() == 0 then
counter_name:increment()
end
if counter_name:getValue() == 1 then
hudPrint ("Gained 1500 exp.")
for i=1,4 do
party:getChampion(i):gainExp(1500)
end
counter_name:increment()
playSound("secret")
end
end
..and connect all altars to script entity
Re: Need "award EXP script"
Posted: Mon Jan 21, 2013 11:13 pm
by hyteria
its is possible to have same script but for a loss exp ? like to punish someone who destroy too much tapestry or something like that ? :p
Re: Need "award EXP script"
Posted: Tue Jan 22, 2013 12:00 am
by Komag
You can't steal XP but you could lower a stat (careful about that though, almost all players will just be ticked off and reload if it's not a temporary thing)
Re: Need "award EXP script"
Posted: Tue Jan 22, 2013 12:02 am
by hyteria
ok thx komag for your answer