Jump to content

[Scripting] Avoid Looping in GameMode


revolucion09

Recommended Posts

I Want to add certain items to a character when he reaches certain XP points. The fact is that i want to add a big list of items.

 

I wish to design a script which adds different items after certain XP Values. The matter is that, the only Way i can do it, is through IF statements which turns off when the item was given. but the task is boring if I want to add more than 20 items,

 

i want to avoid this: (which, without the DoOnce variables, the item would be added infinite times after XP value)

 

Begin GameMode ; fquestdelytime 0.001

if DoOnce1 == 0

if CharXP >= 100
Player.AddItem Sword1
set DoOnce1 to 1
endif

endif

if DoOnce2 == 0

if CharXP >= 150
Player.AddItem Sword2
set DoOnce2 to 1
endif

endif

end

 

if there is a way to give the Item only once without having to create a DoOnce variable for each item, i would appreciate the help

 

thanks

Link to comment
Share on other sites

I Want to add certain items to a character when he reaches certain XP points. The fact is that i want to add a big list of items.

 

I wish to design a script which adds different items after certain XP Values. The matter is that, the only Way i can do it, is through IF statements which turns off when the item was given. but the task is boring if I want to add more than 20 items,

 

i want to avoid this: (which, without the DoOnce variables, the item would be added infinite times after XP value)

 

....

if there is a way to give the Item only once without having to create a DoOnce variable for each item, i would appreciate the help

 

thanks

 

Not precisely what you asked for, but if you considered adding the items per player level instead of per so many XPs then you could create a leveled list with your items in it then just add from your leveled list each time - would still have the DoOnce lock, but only one which you could reset when the player levels up - or alternatively simply add the item from the leveled list when the player levels up (on menumode # where # is the levelup menu).

Link to comment
Share on other sites

Instead of lots of DoOnce variables, you could just have a NextXP variable, initially set at 100, as follows:

 

if CharXP >= NextXP

if NextXP = 100

additem Sword1

set NextXP to 150

elseif NextXP = 150

additem sword2

set NextXP to 200

elseif ......

......

endif

endif

 

This should also make your script more efficient, as it will only have one 'if' to check most of the time.

Link to comment
Share on other sites

Thank you, that is very usefull.

 

I will add it to the next hundred of stuff I want to add, the ones done will remain as before.

 

the fact is that I use many checks (not only CharXP, but skills such as blade, armorer, restoration, etc)

 

but it will be a lot easier

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...