How to track and set a specific value in an array variable

Solu9

You can change this now in User CP.
Reaction score
216
The title may be misleading.

Lets say I assign 5 different units to an array unit variable:
set Unit_Array[1] to Monster-A
set Unit_Array[2] to Monster-B
set Unit_Array[3] to Monster-C
set Unit_Array[4] to Monster-D
set Unit_Array[5] to Monster-E

Great!
Now I want a variable which stores a real for use to calculate how fast a timer will count later on.
set TimeSpeed_Array[1] to 1
set TimeSpeed_Array[2] to 1
set TimeSpeed_Array[3] to 1
set TimeSpeed_Array[4] to 1
set TimeSpeed_Array[5] to 1

Awesome!
Now if Unit_Array[X] picks up Boots of Speed then the TimeSpeed_Array for that specific unit will be set to (TimeSpeed[X] - 0.25) (that's 0.75 in case it was too hard to calculate yourself)

Now to the tricky part.

Events - a unit acquire an item
Conditions - item acquired equal to Boots of Speed
Actions -
If-
acquiring unit equal to Unit_Array[?]
Then-
set TimeSpeed_Array[?] to (TimeSpeed_Array[X] - 0.25)
Else-

You notice the two question marks up there? Thats the question.
----------------------------------------------------------------------------------------------------------


The timer that expires is run in a different trigger and there is a timer for each of the units involved. I take this can be set in a timer array variable as well. But let's leave that for now.
 

maxou

You can change this now in User CP.
Reaction score
15
2 ways to do it :

1st way :

when you save units :

set Unit_Array[1] to Monster-A
set Unit_Array[2] to Monster-B

add this line

Save 1 as custom value of Monster-A
Save 2 as custom value of Monster-B

Then the [ ? ] becomes [Custom value of acquiring unit]


2nd way :

for each (integer A) from 1 to 5
Actions -
If-
acquiring unit equal to Unit_Array[Integer A]
Then-
set TimeSpeed_Array[Integer A] to (TimeSpeed_Array[X] - 0.25)
Else-

Skip remaining actions (this action is placed after the if/then/else, in the (for each) loop.
 

KaerfNomekop

Swim, fishies. Swim through the veil of steel.
Reaction score
613
Tbh using a For loop seems more efficient if you're only using it for a few units. Otherwise hashtables would be faster.
 

thorhunter

You can change this now in User CP.
Reaction score
32
The timer that expires is run in a different trigger and there is a timer for each of the units involved. I take this can be set in a timer array variable as well. But let's leave that for now.

I don't think you even need seperate timers for each unit, franky I wouldn't even use a timer for this one. Just a trigger that keeps running itself, unless you want to create some sort of time gaps between turns, in this case one universal timer will suffice (unless you want to display timers, but there are better ways to do it).

2nd way :

for each (integer A) from 1 to 5
Actions -
If-
acquiring unit equal to Unit_Array[Integer A]
Then-
set TimeSpeed_Array[Integer A] to (TimeSpeed_Array[X] - 0.25)
Else-

Skip remaining actions (this action is placed after the if/then/else, in the (for each) loop.
This is the way I basically do things up (no idea why you need to skip remaining actions, could you explain that?) I've never experienced any process problems, even upon reaching editor's 100k operation limit (used about 6 loops one within another), and game was smooth on multiplayer, so I think this is the last thing you should worry about when choosing a way that you feel comfortable with.
 

Solu9

You can change this now in User CP.
Reaction score
216
I don't think you even need seperate timers for each unit, franky I wouldn't even use a timer for this one. Just a trigger that keeps running itself, unless you want to create some sort of time gaps between turns, in this case one universal timer will suffice (unless you want to display timers, but there are better ways to do it).

Each unit will have different timers based on circumstances.
I'll forward you to the thread about the actual system if you are interested.
http://www.thehelper.net/threads/turn-based-map-test.156716/
 

thorhunter

You can change this now in User CP.
Reaction score
32
I probably misunderstood, I thought you refer to 'countdown timers' while you actually refer to integer array, is that correct?
 

Solu9

You can change this now in User CP.
Reaction score
216
I probably misunderstood, I thought you refer to 'countdown timers' while you actually refer to integer array, is that correct?

The real variable controls how fast an expiring timer will... well, expire. The reason it's a real is so it can be imported to the "set timer" without any work arounds. I guess.
 

thorhunter

You can change this now in User CP.
Reaction score
32
Yes, I see what you did there but in this case instead of using seperate timers for each unit you can have like one trigger that loops every second and decreases all real timer values by 'timer speed' value (each character has it individually), then - depending if the value reaches some point - allows action for this unit and resets its 'timer' variable. I checked the map and there's an issue of unpaused unit that I don't take action with counterattacking every enemy that comes nearby.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • WildTurkey WildTurkey:
    is there a stephen green in the house?
    +1
  • The Helper The Helper:
    What is up WildTurkey?
  • The Helper The Helper:
    Looks like Google fixed whatever mistake that made the recipes on the site go crazy and we are no longer trending towards a recipe site lol - I don't care though because it motivated me to spend alot of time on the site improving it and at least now the content people are looking at is not stupid and embarrassing like it was when I first got back into this like 5 years ago.
  • The Helper The Helper:
    Plus - I have a pretty bad ass recipe collection now! That section of the site is 10 thousand times better than it was before
  • The Helper The Helper:
    We now have a web designer at my job. A legit talented professional! I am going to get him to redesign the site theme. It is time.
  • Varine Varine:
    I got one more day of community service and then I'm free from this nonsense! I polished a cop car today for a funeral or something I guess
  • Varine Varine:
    They also were digging threw old shit at the sheriff's office and I tried to get them to give me the old electronic stuff, but they said no. They can't give it to people because they might use it to impersonate a cop or break into their network or some shit? idk but it was a shame to see them take a whole bunch of radios and shit to get shredded and landfilled
  • The Helper The Helper:
    whatever at least you are free
  • Monovertex Monovertex:
    How are you all? :D
    +1
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top