• 🏆 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] Channel ability on item

Status
Not open for further replies.
Level 2
Joined
Jun 19, 2018
Messages
7
  • TP
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Teleport
    • Actions
      • Set TP = (TP + 1)
      • Set Target[TP] = (Target unit of ability being cast)
      • Unit Group - Add (Triggering unit) to Group
      • Unit - Set the custom value of (Triggering unit) to TP
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Custom value of Target[TP]) Equal to 0
        • Then - Actions
          • Unit - Add Armor Bonus (+99999999999999) to Target[TP]
        • Else - Actions
      • Unit - Set the custom value of Target[TP] to ((Custom value of Target[TP]) + 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • TP Greater than 100
        • Then - Actions
          • Set TP = 0
        • Else - Actions
          • Do nothing
  • TP Cast
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in Group and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Target[(Custom value of (Picked unit))] is alive) Equal to True
              • ((Picked unit) is alive) Equal to True
            • Then - Actions
              • Set TPCast[(Custom value of (Picked unit))] = (TPCast[(Custom value of (Picked unit))] + 1)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Current order of (Picked unit)) Equal to (Order(channel))
                • Then - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • TPCast[(Custom value of (Picked unit))] Greater than or equal to TPTime
                    • Then - Actions
                      • Unit - Set the custom value of Target[(Custom value of (Picked unit))] to ((Custom value of Target[(Custom value of (Picked unit))]) - 1)
                      • Set TempPoint = (Position of Target[(Custom value of (Picked unit))])
                      • Unit - Move (Picked unit) instantly to TempPoint
                      • Custom script: call RemoveLocation(udg_TempPoint)
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Custom value of Target[(Custom value of (Picked unit))]) Less than or equal to 0
                        • Then - Actions
                          • Unit - Remove Armor Bonus (+99999999999999) from Target[(Custom value of (Picked unit))]
                          • Unit - Set the custom value of (Picked unit) to 0
                          • Unit Group - Remove (Picked unit) from Group
                        • Else - Actions
                          • Unit - Set the custom value of (Picked unit) to 0
                          • Unit Group - Remove (Picked unit) from Group
                    • Else - Actions
                • Else - Actions
                  • Unit - Set the custom value of Target[(Custom value of (Picked unit))] to ((Custom value of Target[(Custom value of (Picked unit))]) - 1)
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Custom value of Target[(Custom value of (Picked unit))]) Less than or equal to 0
                    • Then - Actions
                      • Unit - Remove Armor Bonus (+99999999999999) from Target[(Custom value of (Picked unit))]
                      • Unit - Set the custom value of (Picked unit) to 0
                      • Unit Group - Remove (Picked unit) from Group
                    • Else - Actions
                      • Unit - Set the custom value of (Picked unit) to 0
                      • Unit Group - Remove (Picked unit) from Group
            • Else - Actions
              • Unit Group - Remove (Picked unit) from Group
I'm making a "Channel" ability based spell which is "Teleport" ability in this case to act as a regular
"Scroll of Town Portal" ability but gives armor buff during 3 seconds casting time to allied structure all seems fun when i cast it from my hero.

When i set the ability on my item "Scroll of Town Portal" and give it to my hero to use it just doesn't function as my triggers, not sure why though.
Any help on how to make a trigger for my "Teleport" ability spell part for the item would be greatly appreciated!
 
Last edited:
Level 9
Joined
Apr 23, 2011
Messages
527
How exactly does it not work? The trigger doesn't fire at all?

You could, alternatively, not trigger the teleport and create a dummy with Devotion aura with an expiration timer equal to the channel time at the position of the target unit.
 
Level 2
Joined
Jun 19, 2018
Messages
7
@Light My hero just stand still and doesn't fire the start channel order. Does channel based ability not able to work on the item? It's my first time messing around with the ability channel.

As of now, i'm trying out your method see how it goes.

I've also attached a test map you can see what i meant.
 

Attachments

  • test.w3x
    20.1 KB · Views: 23
I'm seeing a weird case here:
Assuming you're not using a Unit Indexer (or GUI Unit Event)

  • Unit - Set the custom value of Target[TP] to ((Custom value of Target[TP]) + 1)
This would be interpreted as the following..

JASS:
call SetUnitUserData(udg_Target[udg_TP], GetUnitUserData(udg_Target[udg_TP]) + 1)

GetUnitUserData in this case would return 0. I presume it to be the case with the rest of the units; the appropriate user data of each unit in the spell after the native call is 1.

By that notion, it could be deduced that the second trigger malfunctions as a result of the first being faulty. In your case, each picked unit will have a custom value of 1 and not your intended unique index.

To remedy this, you can change the line above to the following (again, under the presumption of not using an Indexer)

  • Unit - Set the custom value of Target[TP] to TP
 
Level 2
Joined
Jun 19, 2018
Messages
7
@MyPad
I'm not using a Unit Indexer/GUI Unit Event on the test map at least but, either way, Teleport ability works from casting it directly from my hero not when i use it from the item on both my actual map (which i used a Unit Indexer) and the test map.

By setting the first trigger line:

  • Unit - Set the custom value of Target[TP] to ((Custom value of Target[TP]) + 1)
To this trigger line:

  • Unit - Set the custom value of Target[TP] to TP
Basically, it does nothing as my ability Teleport works with both the previous trigger line or, the latter on my hero casting it.

I'm not so sure as to why it doesn't fire the trigger off from my item Scroll of Town Portal.
 
  • Unit - Set the custom value of (Triggering unit) to TP
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (Custom value of Target[TP]) Equal to 0
    • Then - Actions
      • Unit - Add Armor Bonus (+99999999999999) to Target[TP]
    • Else - Actions
  • Unit - Set the custom value of Target[TP] to ((Custom value of Target[TP]) + 1)
I think the case of faulty behavior above is now in the section of triggers which I posted. In this case, assume TP = 1. We then set the custom data of the unit to TP. Afterwards, we compare if the value of the unit's custom data == 0 (which does not happen and will not likely happen). After that conditional statement, we set the custom data to 1 + 1 (2).

In the second trigger, assuming we are concerned with the same unit, the data the unit is going to be pointing to would be incorrect one (2), where we know it should be 1.

^^

As for the above situation, try adding another event, A unit uses an item. If you need to filter out which event fired, you can use this (I think there isn't a GUI equivalent, unless proven otherwise).

JASS:
if GetTriggerEventId() == EVENT_PLAYER_UNIT_SPELL_EFFECT then

Note that you have to manually affix an endif below that line, but that is already in JASS.

Edit:

Sorry, didn't notice that you were using different handles. I will further edit this later.
 
Level 39
Joined
Feb 27, 2007
Messages
4,989
As for the above situation, try adding another event, A unit uses an item. If you need to filter out which event fired, you can use this (I think there isn't a GUI equivalent, unless proven otherwise).
MyPad is correct, you simply don't have the correct event to catch the spell cast from the item. Triggering Unit will work properly with the item manipulation event but you'll need a replacement for "target unit of ability being cast" and off the top of my head I don't remember what that's gonna be but search enough and you'll find it.
 
Status
Not open for further replies.
Top