Hashtable Issue

Klein~

TH.net Regular
Reaction score
0
I was doubt how can I make a casting unit dependance custom skill and give it to more than 2 units.

I know it may not be well explained, but here I go:

Let's say I have a skill that set a variable for casting unit and I have another trigger that picks this variable unit and do the actions.

If I cast this skill with one unit, this will be normal, but if two units cast this same skill, the variable won't be set for the first to cast.

You'll tell me to add the casting unit to a group and pick the units into this group and do the actions, ok I know it, but the goal of this thread is other.

I want to set a variable for each caster and I want to run the same trigger with every caster separated.

I don't have any idea of how to collect the number of times that the trigger runned or the identification for each diferent unit that triggers.

To be more specific, I'll give a example of this kind of trouble. Let's say a skill that starts a timer(not only timer, can be a variable++) for every unit and time it is cast:

0 second game time:
Unit A -> cast Skill -> trigger save time.
Initial time for 1st cast = 0 second.

1 second game time:
Unit A -> cast Skill -> trigger save time.
Initial time for 2nd cast = 0 second.
Time of 1st cast updated = 1 second.

2 seconds game time:
Unit A -> cast Skill -> trigger save time.
Initial time for 3rd cast = 0 second.
Time of 2nd cast updated = 1 second.
Time of 1st cast updated = 2 second.

3 seconds game time:
Time of 3rd cast updated = 1 second.
Time of 2nd cast updated = 2 second.
Time of 1st cast updated = 3 second.
 

ultimate11

Active Member
Reaction score
25
where:
H_id = integer variable
Real = real variable /this define the amount of seconds u want to last your spell
Hashtable = hashtable variable
Skill_group = unit group

Trigger:
  • Untitled Trigger 001
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set Hashtable = (Last created hashtable)

Trigger:
  • cast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Animate Dead
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Triggering unit) is in Skill_group) Equal to True
        • Then - Actions
          • Set H_id = (Key (Triggering unit))
          • Set Real = (Load 1 of H_id from Hashtable)
          • Hashtable - Save (Real + 1.00) as 1 of H_id in Hashtable
        • Else - Actions
          • Set H_id = (Key (Triggering unit))
          • Set Real = 1.00
          • Hashtable - Save Real as 1 of H_id in Hashtable
          • Unit Group - Add (Triggering unit) to Skill_group

The 0.25 event define how many actions are execuyted in one second.For this event 4 istance are happened.
Trigger:
  • event
    • Events
      • Time - Every 0.25 seconds of game time
    • Conditions
      • (Number of units in Skill_group) Greater than or equal to 1
    • Actions
      • Unit Group - Pick every unit in Skill_group and do (Actions)
        • Loop - Actions
          • Set Unit = (Picked unit)
          • Set H_id = (Key (Picked unit))
          • Set Real = (Load 1 of H_id from Hashtable)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Real Greater than or equal to 0.25
            • Then - Actions
              • Animation - Change Unit's vertex coloring to ((Random real number between 0.00 and 100.00)%, (Random real number between 0.00 and 100.00)%, 100.00%) with 0.00% transparency
              • Hashtable - Save (Real - 1.00) as 1 of H_id in Hashtable
            • Else - Actions
              • Hashtable - Clear all child hashtables of child H_id in Hashtable
              • Unit Group - Remove Unit from Skill_group
 

ultimate11

Active Member
Reaction score
25
Study those triggers I posted for u and u will learn how to use easily hashtable.Is quite simple.
The second trigger will consume "the stacks" of your spell time but if u dont one ,or u only want to remeber how many time have the unit casted the skill remove the
Trigger:
  • <span style="font-size: 12px"><span style="font-family: 'Tahoma'">Hashtable - Clear all child hashtables of child H_id in Hashtable</span></span>
.In this way the skill will last longer and longer for a small ex:
1s first time 2s secondt time etc or u can manipulate the actions that u want to happen.
 

Klein~

TH.net Regular
Reaction score
0
Thanks ultimate11, this example is clear and simple to understand what I wanted to do. Any case of doubt I'll reply.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top