• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Trigger] Indexing of Units who have Casted a Spell

Status
Not open for further replies.
Level 3
Joined
Jun 9, 2009
Messages
38
  • PT
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Transfer Energy (Neutral Hostile)
      • ((Triggering unit) is A structure) Equal to True
    • Actions
      • Set integers[1] = (integers[1] + 1)
      • Set turnoff[integers[1]] = False
      • Set casting[integers[1]] = (Triggering unit)
      • Set casted[integers[1]] = (Target unit of ability being cast)
      • Lightning - Create a Chain Lightning - Secondary lightning effect from source (Position of casting[integers[1]]) to target (Position of casted[integers[1]])
      • Set lightning[integers[1]] = (Last created lightning effect)
      • Trigger - Turn on loop <gen>
  • loop
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
      • turnoff[integers[1]] Equal to False
      • (Mana of casting[integers[1]]) Greater than or equal to 5.00
    • Actions
      • For each (Integer integers[2]) from 1 to integers[1], do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • turnoff[integers[2]] Equal to False
            • Then - Actions
              • Unit - Set mana of casted[integers[2]] to ((Mana of casted[integers[2]]) + 1.00)
              • Unit - Set mana of casting[integers[2]] to ((Mana of casting[integers[2]]) - 1.00)
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • turnoff[integers[2]] Equal to True
            • Then - Actions
              • Lightning - Destroy lightning[integers[2]]
              • Custom script: call SetUnitPosition(GetTriggerUnit(), GetUnitX(GetTriggerUnit()), GetUnitY(GetTriggerUnit()))
              • Set integers[1] = (integers[1] - 1)
            • Else - Actions
  • PTCancel
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Cancel Transfers
      • ((Triggering unit) is A structure) Equal to True
    • Actions
      • Set turnoff[integers[1]] = True
With those triggers, it just cancels the most recently made link.

I've gotten help from various sources for making those triggers. However I think I need a new one to index who has and who hasn't casted the spell to create a link between two buildings. Someone explained to me that the cancel skill would loop through the index till it finds the same link as the unit who casted the cancel unit.

It sounds perfect. But I have no idea how to do this.

Thanks in advance.
 
Level 3
Joined
Jun 9, 2009
Messages
38
Isn't that what I did with this?

  • Actions
    • Set integers[1] = (integers[1] + 1)
Or shall I make another one to keep count.
 
Level 12
Joined
Jul 27, 2008
Messages
1,181
No, you need more like:

  • PT
  • Events
    • Unit - A unit Starts the effect of an ability
  • Conditions
    • (Ability being cast) Equal to Transfer Energy (Neutral Hostile)
    • ((Triggering unit) is A structure) Equal to True
  • Actions
    • Set Count = (Count + 1)
    • Set turnoff[Count] = False
    • Set casting[Count] = (Triggering unit)
    • Set casted[Count] = (Target unit of ability being cast)
    • Lightning - Create a Chain Lightning - Secondary lightning effect from source (Position of casting[Count]) to target (Position of casted[integers[1]])
    • Set lightning[Count] = (Last created lightning effect)
    • Trigger - Turn on loop <gen>
Basically Count is just a name, but no need for an array integer.
 
Level 3
Joined
Jun 9, 2009
Messages
38
So basically, I didn't need to make all my variables arrays in my triggers. I was kinda just doin what the guy said to do. Thanks.

Still need to address how to delete a specific link. Maybe have to somehow make sure the index knows it is the start of the link. Any ideas?
 
Level 3
Joined
Jun 9, 2009
Messages
38
No no. Links are the transferring of mana between two buildings. The way I have it set up right now only deletes the most recently made link. I want to delete specific links.
 
Level 3
Joined
Jun 9, 2009
Messages
38
But I don't understand where it would check is the correct integer. Is it stored somewhere in the unit?

Also an example would be very useful. :smile:
 
Level 3
Joined
Jun 9, 2009
Messages
38
OH WOW. I totally understand what alot of this means now.

  • Actions
    • For each (Integer integers[2]) from 1 to integers[1], do (Actions)
That basically for all created integers. Thank you so much, I'll post in this thread if I figure it out.
 
Level 3
Joined
Jun 9, 2009
Messages
38
  • asd
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
      • (Ability being cast) Equal to Cancel Transfers
    • Actions
      • For each (Integer integers[2]) from 1 to 8192, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Casting unit) Equal to casting[2]
            • Then - Actions
              • Lightning - Destroy lightning[integers[2]]
              • Custom script: call SetUnitPosition(GetTriggerUnit(), GetUnitX(GetTriggerUnit()), GetUnitY(GetTriggerUnit()))
              • Set integers[1] = (integers[1] - 1)
            • Else - Actions
I think I only thought I had something. What do you see wrong?
 
Level 12
Joined
Jul 27, 2008
Messages
1,181
No, change the loop to:

  • For each (Integer A) from 1 to 8192, do (Actions)
    • Loop - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Casting unit) Equal to casting[Integer A]
        • Then - Actions
          • Lightning - Destroy lightning[Integer A]
          • Custom script: call SetUnitPosition(GetTriggerUnit(), GetUnitX(GetTriggerUnit()), GetUnitY(GetTriggerUnit()))
        • Else - Actions
Not a variable loop, just an integer a (or b).
 
Level 3
Joined
Jun 9, 2009
Messages
38
  • asd
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
      • (Ability being cast) Equal to Cancel Transfers
    • Actions
      • For each (Integer integers[2]) from 1 to 8192, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Casting unit) Equal to casting[(Integer A)]
            • Then - Actions
              • Lightning - Destroy lightning[(Integer A)]
              • Custom script: call SetUnitPosition(GetTriggerUnit(), GetUnitX(GetTriggerUnit()), GetUnitY(GetTriggerUnit()))
            • Else - Actions
I believe I have it set up correctly now. The lightning still doesn't get cancelled though.

(Sorry for leaving earlier, I had to go to sleep as it was 4am.)
 
Level 3
Joined
Jun 9, 2009
Messages
38
Do you mean no other loops inside that trigger? Cause there was another in another trigger.

EDIT: Slight success, I think it is cancelling the transfer but not the lightning animation. It might also be cancelling ALL transfers though.

EDIT2:Nevermind, had my other trigger enabled. (PTCancel)
 
Last edited:
Status
Not open for further replies.
Top