• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Trigger] Linking 2 unit variables

Status
Not open for further replies.
Level 18
Joined
Aug 23, 2008
Messages
2,319
I've got 2 arrayed unit Variables.
Character with 12 arrays (Indicates the characters in the game you can control)
BattleUnit with 4 arrays (These are 4 units from Character that you take along into battle)

The BattleUnit arrays can be changed by the player in-game at any time. So BattleUnit[1] can be Character[5], BattleUnit[2] can be Character[12], BattleUnit[3] can be Character[7] and BattleUnit[4] can be Character[2].
The problem is: When I add a statistic like 'Annoyed[2] equal to True' (It means BattleUnit[2] is annoyed by the problem I'm telling you about now :gg:), It's easy to attach it to BattleUnit[2]. But at the moment BattleUnit[2] switches with another BattleUnit or goes from Character[12] to Character[3], I need to make the Annoyed statistic to stay with Character[12] instead of BattleUnit[2].

Does anybody know how I could do this?
 
Level 18
Joined
Aug 23, 2008
Messages
2,319
Then I can't even add the statistics to the BattleUnits! There will stay 4 arrays in BattleUnit no matter what, because if that changes, I'll have this status problem (which is about 10% of my game mechanics) transferred to the other 90% of my game!
 
Level 9
Joined
Apr 3, 2008
Messages
700
2 ways:

1. Turn off triggers that changes variable values when you don't need to change them.
2. Set 12 array as i wrote and add more conditions to statistic trigger (like if index of BUnit >=1, <=3; then do: <...>, elseif index of BUnit >=4, <=6, <...>)
 
Level 18
Joined
Aug 23, 2008
Messages
2,319
That could become a problem. Since a buff can only be added with an ability, and I got hundreds of statusses that require a method like this, I need to base them of hundreds of different abilities (because if you base them of the same ability, you'll activate them both. Even if there are enough abilities for that, I'll have to neutralise every effect of every single one of them to prevent any unwanted effects)

It's probably a last possible solution.
 
Level 21
Joined
Aug 21, 2005
Messages
3,699
Isn't there a really obvious and easy solution?

Character [12] unit array
Annoyed[12] whatever array
BattleUnit [4] integer array

Battleunit[0] contains the index of one of the 12 units in Character[12]. You have 12 units stored in Character[12], and only 4 of those can battle and the index of Character[12] is stored in BattleUnit[4]
Annoyed[12] corresponds with 12 annoyed statuses of the 12 characters.

e.g.
Character[0] = A
Character[1] = B
etc.

BattleUnit[0] = 1 ==> Character[1] = B
BattleUnit[1] = 5 ==> Character[5] = F

If you're annoying BattleUnit[1], you're annoying Character[5] (since battleunit[1] links to character[5]), so you simply set Annoyed[BattleUnit[1]] = true or something.
 
Level 18
Joined
Aug 23, 2008
Messages
2,319
Linking BattleUnit to Character is the problem. When you set up the party, you choose the number of the Character array to set as BattleUnit[1]. After that, there's nothing that links back. Everything is connected to BattleUnit[1], since everything is statistically. BattleUnit is just a copy of the unit-type of Character.
 
Level 18
Joined
Aug 23, 2008
Messages
2,319
Character and BattleUnit are both Unit Variables. It's just that when you choose the party, you'll get a copy of Character as BattleUnit to prevent anything unwanted to happen to Character.

So everything happens to BattleUnit, but nothing happens to Character. I want the info (in this sample Annoyed) attached to BattleUnit[x] to also be attached to the Character of that. Damage and such are stuff I don't want with Character, but I do want with BattleUnit.
 
Level 21
Joined
Aug 21, 2005
Messages
3,699
@Eleandor: It's a different unit. It's created from Character[x], but how do I refer back to it?

Well then the very simple solution is to do what I said: link everything to Characters instead to BattleUnits

For example:
Characters[0] = A
Characters[1] = B
Characters[2] = C

Annoyed[0] = The annoyance of unit prototype A (i.e. Characters[0])
Annoyed[1] = The annoyance of unit prototype B (i.e. Characters[1])

BattleUnits[0] = Unit based on prototype C
BattleCharacters[0] = The index of the Character[] on which BattleUnits[0] is based on. In this case: 2 because Characters[2] = C

If you need to know the annoyance of BattleUnits[0], you check:
Annoyed[BattleCharacters[0]]
If you need to know the annoyance of BattleUnits[1], you check:
Annoyed[BattleCharacters[1]]
etc.

@GhostWolf: What... The... ......?
Ghost, I thought it was pretty obvious he has no clue of jass?
 
Level 12
Joined
Apr 27, 2008
Messages
1,228
Isn't there a really obvious and easy solution?

Character [12] unit array
Annoyed[12] whatever array
BattleUnit [4] integer array

Battleunit[0] contains the index of one of the 12 units in Character[12]. You have 12 units stored in Character[12], and only 4 of those can battle and the index of Character[12] is stored in BattleUnit[4]
Annoyed[12] corresponds with 12 annoyed statuses of the 12 characters.

e.g.
Character[0] = A
Character[1] = B
etc.

BattleUnit[0] = 1 ==> Character[1] = B
BattleUnit[1] = 5 ==> Character[5] = F

If you're annoying BattleUnit[1], you're annoying Character[5] (since battleunit[1] links to character[5]), so you simply set Annoyed[BattleUnit[1]] = true or something.

This is a valid solution.
Only thing to note is that BattleUnit is an integer array in the solution, but should not be a problem.
 
Level 18
Joined
Aug 23, 2008
Messages
2,319
Oh wait, I misinterpreted your post. You mean that I should make an Integer variable BattleCharacters where it's set to the Character's array and has the array of BattleUnit's array.

Yes, that's exactly what I was looking for! Thank you very much and +rep :thumbs_up:
 
Status
Not open for further replies.
Top