- Joined
- Jul 29, 2011
- Messages
- 90
I apologize if this seems a silly question, but hashtables are fairly new to me, and they honestly give me a huge headache to try to fully figure out. Granted, I've come a long way in my understanding of them, but there's a feature about them that I would very much like to utilize, but I don't know how or if I even can.
What I would like to know is whether or not there is a way to scan a hashtable to find out in which value a particular unit's ID Handle has been stored. Maybe something like:
"Check Hashtable for Triggering Unit's ID Handle and store the matching keys' value in VariableX and VariableY."
I find the vocabulary involved with hashtables to be kind of esoteric as well, so like I said, I apologize if this seems like a silly question, but I can't see a means of utilizing a non-finitely generated custom birth animation and actually being able to account for cancellations without such a function, and I can't seem to find it. Or, if I have found it, then I didn't understand what I found, and therefore didn't realize that I'd found it.
Thanks for any help in regards to this.
EDIT: Something that would allow me to define one of the two hashtable keys, and then scan the other hashtable key for the matching slot that's tied to triggering unit (as triggering unit has already had its ID saved in a hashtable in a different trigger, but there are many different related unit IDs in said hashtable, and so it needs to know which one to reference) would be good as well.
EDIT: It occurs to me that I should offer more information on how the whole thing is working so far.
So the goal here is that I have stationary units which "evolve" into regular units (very much akin to the Zerg Larvae from Starcraft). When the "upgrade" begins from egg to unit, the model changes from egg model to unit model at the *start* of the upgrade instead of *after* it. So I'm applying something of a "custom birth animation" for these units during the hatching cycle. The way it's working is thusly:
Event:
- A unit begins an Upgrade
Conditions:
- Or (Any Conditions are true)
- - Conditions:
- - - Unit type of Triggering Unit equal to PossibilityA
- - - Unit type of Triggering Unit equal to PossibilityB
- - - Etc.
Actions
- If (All conditions are true)
- - Conditions:
- - - Unit type of Triggering Unit equal to PossibilityA
- - Then:
- - - Set: HatchingCount_PossibilityA = HatchingCount_PossibilityA + 1
- - - Create Animation at Location of Triggering Unit using EggAnimation
- - - Hashtable: Store EffectID of Last Created Special Effect in (HatchingCount_PossibilityA of 0 in EggsEffectTable)
- - - Set: HatchingUnitID_PossibilityA = HatchingUnitID_PossibilityA + 1
- - - Hashtable: Store UnitID of TriggeringUnit in (HatchingUnitID_PossibilityA of 0 in EggsUnitTable)
- - - If (All conditions are true)
- - - - Conditions:
- - - - - HatchingCount_PossibilityA Greater than 1
- - - - Then:
- - - - - Set: HatchingAdditional_PossibilityA equal to HatchingAdditional_PossibilityA + 1
- - - - Else:
- - - - - Do Nothing
- - - Animation: Change Triggering Unit's Vertex coloring to 100% 100% 100% with 100% transparency
- - - Wait (insert PossibilityA's build time here)
- - - Animation: Change (Load (HatchingUnitID_PossibilityA - HatchingAdditional_PossibilityA) of 0 in EggsUnitTable) to (insert PossibilityA's tinting %s here) with 0% transparency
- - - Animation: Destroy (Load (HatchingCount_PossibilityA - HatchingAdditional_PossibilityA) of 0 in EggsEffectTable)
- - - Animation: Play Triggering Unit's birth Animation
- - - Set Rally Point for Triggering Unit to (Load 1 of (Owner of Triggering Unit's Player Number) in EggsRallyPointTable) (defined in a different trigger whenever a player uses the rally point ability)
- - - Unit: Order Triggering Unit to move to Rally Point of Triggering Unit as a point
- - - If: (All conditions are true)
- - - - Conditions:
- - - - - HatchingAdditional_PossibilityA greater than 0
- - - - Then:
- - - - - Set: HatchingAdditional_PossibilityA equal to HatchingAdditional_PossibilityA - 1
- - - - Else:
- - - - - Set: HatchingCount_PossibilityA equal to 0
- - - - - Set: HatchingUnitID_PossibilityA equal to 0
And then it repeats with every other unit possibility, with every instance of "PossibilityA" changed with its respective possibility, and with every instance of "of 0" that appears in a Hashtable being changed to its respective number (Possibility B would yield "of 1" for example).
Now the problem I'm having, specifically, is that I'm beginning the "Event - A unit cancels an upgrade" trigger, and I have no idea how to have it find out which animation to destroy unless I can scan a hashtable to find which value of the first key that has the triggering unit's ID saved to it. I hope that someone out there can help with this.
EDIT: Corrected a mistake in the above coding transcription.
EDIT: In case of confusion, I want to point out that I did not post this in "Triggers and Scripts" because it's not the above coding that I'm having any problems with. It's a fresh trigger that I'm inquiring about which is simply related to the above trigger, and I don't know how to get it started.
What I would like to know is whether or not there is a way to scan a hashtable to find out in which value a particular unit's ID Handle has been stored. Maybe something like:
"Check Hashtable for Triggering Unit's ID Handle and store the matching keys' value in VariableX and VariableY."
I find the vocabulary involved with hashtables to be kind of esoteric as well, so like I said, I apologize if this seems like a silly question, but I can't see a means of utilizing a non-finitely generated custom birth animation and actually being able to account for cancellations without such a function, and I can't seem to find it. Or, if I have found it, then I didn't understand what I found, and therefore didn't realize that I'd found it.
Thanks for any help in regards to this.
EDIT: Something that would allow me to define one of the two hashtable keys, and then scan the other hashtable key for the matching slot that's tied to triggering unit (as triggering unit has already had its ID saved in a hashtable in a different trigger, but there are many different related unit IDs in said hashtable, and so it needs to know which one to reference) would be good as well.
EDIT: It occurs to me that I should offer more information on how the whole thing is working so far.
So the goal here is that I have stationary units which "evolve" into regular units (very much akin to the Zerg Larvae from Starcraft). When the "upgrade" begins from egg to unit, the model changes from egg model to unit model at the *start* of the upgrade instead of *after* it. So I'm applying something of a "custom birth animation" for these units during the hatching cycle. The way it's working is thusly:
Event:
- A unit begins an Upgrade
Conditions:
- Or (Any Conditions are true)
- - Conditions:
- - - Unit type of Triggering Unit equal to PossibilityA
- - - Unit type of Triggering Unit equal to PossibilityB
- - - Etc.
Actions
- If (All conditions are true)
- - Conditions:
- - - Unit type of Triggering Unit equal to PossibilityA
- - Then:
- - - Set: HatchingCount_PossibilityA = HatchingCount_PossibilityA + 1
- - - Create Animation at Location of Triggering Unit using EggAnimation
- - - Hashtable: Store EffectID of Last Created Special Effect in (HatchingCount_PossibilityA of 0 in EggsEffectTable)
- - - Set: HatchingUnitID_PossibilityA = HatchingUnitID_PossibilityA + 1
- - - Hashtable: Store UnitID of TriggeringUnit in (HatchingUnitID_PossibilityA of 0 in EggsUnitTable)
- - - If (All conditions are true)
- - - - Conditions:
- - - - - HatchingCount_PossibilityA Greater than 1
- - - - Then:
- - - - - Set: HatchingAdditional_PossibilityA equal to HatchingAdditional_PossibilityA + 1
- - - - Else:
- - - - - Do Nothing
- - - Animation: Change Triggering Unit's Vertex coloring to 100% 100% 100% with 100% transparency
- - - Wait (insert PossibilityA's build time here)
- - - Animation: Change (Load (HatchingUnitID_PossibilityA - HatchingAdditional_PossibilityA) of 0 in EggsUnitTable) to (insert PossibilityA's tinting %s here) with 0% transparency
- - - Animation: Destroy (Load (HatchingCount_PossibilityA - HatchingAdditional_PossibilityA) of 0 in EggsEffectTable)
- - - Animation: Play Triggering Unit's birth Animation
- - - Set Rally Point for Triggering Unit to (Load 1 of (Owner of Triggering Unit's Player Number) in EggsRallyPointTable) (defined in a different trigger whenever a player uses the rally point ability)
- - - Unit: Order Triggering Unit to move to Rally Point of Triggering Unit as a point
- - - If: (All conditions are true)
- - - - Conditions:
- - - - - HatchingAdditional_PossibilityA greater than 0
- - - - Then:
- - - - - Set: HatchingAdditional_PossibilityA equal to HatchingAdditional_PossibilityA - 1
- - - - Else:
- - - - - Set: HatchingCount_PossibilityA equal to 0
- - - - - Set: HatchingUnitID_PossibilityA equal to 0
And then it repeats with every other unit possibility, with every instance of "PossibilityA" changed with its respective possibility, and with every instance of "of 0" that appears in a Hashtable being changed to its respective number (Possibility B would yield "of 1" for example).
Now the problem I'm having, specifically, is that I'm beginning the "Event - A unit cancels an upgrade" trigger, and I have no idea how to have it find out which animation to destroy unless I can scan a hashtable to find which value of the first key that has the triggering unit's ID saved to it. I hope that someone out there can help with this.
EDIT: Corrected a mistake in the above coding transcription.
EDIT: In case of confusion, I want to point out that I did not post this in "Triggers and Scripts" because it's not the above coding that I'm having any problems with. It's a fresh trigger that I'm inquiring about which is simply related to the above trigger, and I don't know how to get it started.
Last edited: