Need "award EXP script"

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
User avatar
Grimwold
Posts: 511
Joined: Thu Sep 13, 2012 11:45 pm
Location: A Dungeon somewhere in the UK

Re: Need "award EXP script"

Post 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.

Code: Select all

global_scripts.grantExp(1000)
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.
imjodokast
Posts: 3
Joined: Wed Oct 17, 2012 6:59 am

Re: Need "award EXP script"

Post 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?
User avatar
msyblade
Posts: 792
Joined: Fri Oct 12, 2012 4:40 am
Location: New Mexico, USA
Contact:

Re: Need "award EXP script"

Post by msyblade »

I just make sure to tie them to a lock, or hidden plate set activate once one step inside the granted area
Currently conspiring with many modders on the "Legends of the Northern Realms"project.

"You have been captured by a psychopathic diety who needs a new plaything to torture."
Hotel Hades
User avatar
Grimwold
Posts: 511
Joined: Thu Sep 13, 2012 11:45 pm
Location: A Dungeon somewhere in the UK

Re: Need "award EXP script"

Post 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.
User avatar
vidarfreyr
Posts: 71
Joined: Sat Oct 20, 2012 4:40 am

Re: Need "award EXP script"

Post 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
hyteria
Posts: 266
Joined: Sat Dec 29, 2012 8:22 pm

Re: Need "award EXP script"

Post 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
User avatar
Komag
Posts: 3659
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: Need "award EXP script"

Post 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)
Finished Dungeons - complete mods to play
hyteria
Posts: 266
Joined: Sat Dec 29, 2012 8:22 pm

Re: Need "award EXP script"

Post by hyteria »

ok thx komag for your answer
Post Reply