• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[Spell] How can i made this system to work for each courier simultaneos?

Status
Not open for further replies.
Level 11
Joined
Sep 11, 2013
Messages
327
Greetings!
My friend helped me to do this trigger and i have 2 little problem with it..

  • Transfer Items
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Trasfer Items SHADE
    • Actions
      • Set VariableSet TempIntegerTT[1] = (Player number of (Owner of (Triggering unit)))
      • Set VariableSet Trasport_ActiveTT[TempIntegerTT[1]] = True
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Casting unit)) Equal to Shade
        • Then - Actions
          • Set VariableSet TransferCasterTT[TempIntegerTT[1]] = (Casting unit)
          • Set VariableSet TransferTargetTT[TempIntegerTT[1]] = (Random unit from (Units owned by (Player(TempIntegerTT[1])) matching (((Matching unit) is A Hero) Equal to True).))
          • Set VariableSet TempPointTT[1] = (Position of TransferTargetTT[TempIntegerTT[1]])
          • Unit - Order TransferCasterTT[TempIntegerTT[1]] to Follow TransferTargetTT[TempIntegerTT[1]]
          • Trigger - Turn on Transfer Items Loop Check <gen>
          • Custom script: call RemoveLocation(udg_TempPointTT[1])
        • Else - Actions


  • Transfer Items Loop Check
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Set VariableSet TempIntegerTT[1] = 0
      • Set VariableSet TransferIterationTT = (TransferIterationTT + 1)
      • For each (Integer IntegerAAA) from 1 to 12, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Trasport_ActiveTT[IntegerAAA] Equal to True
            • Then - Actions
              • Set VariableSet TempPointTT[1] = (Position of TransferCasterTT[IntegerAAA])
              • Set VariableSet TempPointTT[2] = (Position of TransferTargetTT[IntegerAAA])
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • TransferIterationTT Greater than or equal to 3
                • Then - Actions
                  • Unit - Order TransferCasterTT[(Integer A)] to Move To TempPointTT[2]
                • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Distance between TempPointTT[1] and TempPointTT[2]) Less than or equal to 200.00
                • Then - Actions
                  • Unit - Order TransferCasterTT[IntegerAAA] to Stop.
                  • For each (Integer IntegerBBB) from 1 to 3, do (Actions)
                    • Loop - Actions
                      • Hero - Give (Item carried by TransferCasterTT[IntegerAAA] in slot IntegerBBB) to TransferTargetTT[IntegerAAA]
                  • Set VariableSet Trasport_ActiveTT[IntegerAAA] = False
                • Else - Actions
              • Custom script: call RemoveLocation(udg_TempPointTT[1])
              • Custom script: call RemoveLocation(udg_TempPointTT[2])
            • Else - Actions
              • Set VariableSet TempIntegerTT[1] = (TempIntegerTT[1] + 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • TempIntegerTT[1] Greater than or equal to 12
        • Then - Actions
          • Trigger - Turn off (This trigger)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • TransferIterationTT Greater than or equal to 3
        • Then - Actions
          • Set VariableSet TransferIterationTT = 0
        • Else - Actions
At first i need to say that this is only for team 2 which is made by 3 players (each player will have to chose only 1 hero of 3 and each player can pick, if they want, the same hero)

Each hero can make permanent Shades (1 shade/minute) and those Shades has 3 slots of inventory and can Trasfer Items. (there can be a lot of shades on the map at the end ~150)

Each shade i want to be able to transfer items like a normal courier..

Shades can die if that is important.

PROBLEMS..

1.With that trigger, if i have for example 3 Shades (from 1 hero/player) and each shade has for example 1 item and i press the spell (transfer items) on each one. Only the last one who received the order will send the items. The other 2 shades will just follow the hero.

***I want each shade to transfer items not only the last one i order..

2.If i send for example 1 shade to transfer items and before transferring them I stop the shade(courier) or move in other direction, The second trigger will never stop and will check if the hero is near courier to send items. This is annyoing because if i get closer to shade with hero, the shade will still transfer items even if i don't want it anymore.

***How can i stop the shade to transfer items if i want to close the last order?

The help will be appreciated!:peasant-bowing:
 
Last edited:
Level 20
Joined
Feb 27, 2019
Messages
599
The main problem is that there can only be one shade per player. Each time the same player casts a spell, that players variables get overwritten.

Since each player only has one hero it doesnt seem important to keep track of each individual shade. A simple way to remedy the problem is to add units to a unit group and do stuff with the units in the group in another trigger, using each picked unit to restore some missing information such as the units player number, as well as using the unit group as a boolean check. Here is a simple version of that.
  • Transfer Cast
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Channel (Instant)
    • Actions
      • Unit Group - Add (Triggering unit) to TransferGroup
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in TransferGroup) Equal to 1
        • Then - Actions
          • Trigger - Turn on Transfer Periodic <gen>
          • Trigger - Turn on Transfer Stop <gen>
        • Else - Actions
  • Transfer Periodic
    • Events
      • Time - Every 0.25 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in TransferGroup and do (Actions)
        • Loop - Actions
          • Set VariableSet TempUnit = (Picked unit)
          • Set VariableSet PN = (Player number of (Owner of TempUnit))
          • Set VariableSet TempPoint[0] = (Position of (Picked unit))
          • Set VariableSet TempPoint[1] = (Position of Hero[PN])
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Distance between TempPoint[0] and TempPoint[1]) Less than or equal to 200.00
            • Then - Actions
              • For each (Integer A) from 1 to 3, do (Actions)
                • Loop - Actions
                  • Hero - Give (Item carried by TempUnit in slot (Integer A)) to Hero[PN]
              • Unit - Order TempUnit to Stop.
              • Unit Group - Remove TempUnit from TransferGroup.
            • Else - Actions
              • Trigger - Turn off Transfer Stop <gen>
              • Unit - Order TempUnit to Move To TempPoint[1]
              • Trigger - Turn on Transfer Stop <gen>
          • Custom script: call RemoveLocation(udg_TempPoint[0])
          • Custom script: call RemoveLocation(udg_TempPoint[1])
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in TransferGroup) Equal to 0
        • Then - Actions
          • Trigger - Turn off Transfer Periodic <gen>
          • Trigger - Turn off Transfer Stop <gen>
        • Else - Actions
  • Transfer Stop
    • Events
      • Unit - A unit Is issued an order targeting an object
      • Unit - A unit Is issued an order targeting a point
      • Unit - A unit Is issued an order with no target
      • Unit - A unit Dies
    • Conditions
      • ((Triggering unit) is in TransferGroup.) Equal to True
    • Actions
      • Unit Group - Remove (Triggering unit) from TransferGroup.
A way to store and extract even more data is to use a unit indexer GUI Unit Indexer 1.4.0.0
Then you can use the units unique custom value to store information on a seperate variable containing to the spell, such as target. Just remember to clean up leaks.
  • Transfer Cast
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Channel (Instant)
    • Actions
      • Set VariableSet Index = (Custom value of (Triggering unit))
      • Set VariableSet TransferTarget[Index] = Hero[PN]
      • Unit Group - Add (Triggering unit) to TransferGroup
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in TransferGroup) Equal to 1
        • Then - Actions
          • Trigger - Turn on Transfer Periodic <gen>
          • Trigger - Turn on Transfer Stop <gen>
        • Else - Actions
However there is a more efficient way instead of relying on unit groups and that is to use dynamic indexing. Visualize: Dynamic Indexing

These techniques have a bit in common so if you get the hang of one, the other will make sense too.

For your case I did find another solution relying a bit more on the game itself. I attached a test map so you can look through everything. It probably fails from spells like hex, silence or stun though.
  • Transfer Setup
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • Player - Disable Channel (Unit) for (Player(1))
      • Set VariableSet Hero[1] = Mountain King 0001 <gen>
  • Transfer Start
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Channel (Instant)
    • Actions
      • Set VariableSet PN = (Player number of (Triggering player))
      • Player - Enable Channel (Unit) for (Player(PN))
      • Unit - Order (Triggering unit) to Undead Crypt Fiend - Web Hero[PN]
      • Player - Disable Channel (Unit) for (Player(PN))
  • Transfer Complete
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Channel (Unit)
    • Actions
      • Set VariableSet PN = (Player number of (Triggering player))
      • Set VariableSet TempUnit = (Triggering unit)
      • For each (Integer A) from 1 to 3, do (Actions)
        • Loop - Actions
          • Hero - Give (Item carried by TempUnit in slot (Integer A)) to Hero[PN]
      • Unit - Order TempUnit to Stop.
 

Attachments

  • transfer.w3m
    19 KB · Views: 2
Level 11
Joined
Sep 11, 2013
Messages
327
It work perfect, wow!
i just change this trigger to fit on my map and all seems to work just fine!
  • Transfer Setup
    • Events
      • Time - Elapsed game time is 13.00 seconds
    • Conditions
    • Actions
      • For each (Integer A) from 10 to 12, do (Actions)
        • Loop - Actions
          • Player - Disable Channel (Unit) for (Player((Integer A)))
          • Set VariableSet HeroTT[(Integer A)] = (Random unit from (Units owned by (Player((Integer A))) matching (((Matching unit) is A Hero) Equal to True).))
Thank you so much!
 
Level 20
Joined
Feb 27, 2019
Messages
599
Good to hear.

I did find fixes for the Hex, Silence and Stun. Not perfect ones but if those things become a problem (Shades stop when affected by those things) the fixes can be implemented. If the Shade has the Ghost ability it cant be targeted by Hex. If the Transfer abilities have Universal cast ticked they arnt affected by Silence. If the ability is not enabled/disabled in any of the triggers the Shade will continue after a Stun.
 
Status
Not open for further replies.
Top