[Trigger] Courier Teleport

Status
Not open for further replies.
Level 10
Joined
Dec 16, 2017
Messages
416
Hello guys. i am trying to make my courier to teleport back to the hero if he surpasses 400 Distance, what i do wrong here?
Also, i use this on an ORPG, when i tier up, shall i reset hero position to positon of last created unit again after every tier up?

  • Courier
    • Events
      • Unit - A unit Sells an item (from shop)
    • Conditions
      • (Item-type of (Sold Item)) Equal to Skull of Gul'dan
      • Courier_Alive[(Player number of (Triggering player))] Equal to False
    • Actions
      • Set Courier_YourHero[(Player number of (Triggering player))] = (Buying unit)
      • Set Courier_Your_HeroTempPoint[(Player number of (Triggering player))] = (Position of Courier_YourHero[(Player number of (Triggering player))])
      • Unit - Create 1 Courier for (Owner of Courier_YourHero[(Player number of (Triggering player))]) at Courier_Your_HeroTempPoint[(Player number of (Triggering player))] facing Default building facing degrees
      • Set Courier_YourCourier[(Player number of (Triggering player))] = (Last created unit)
      • Set Courier_Your_CourierFirstPoint[(Player number of (Triggering player))] = (Position of Courier_YourCourier[(Player number of (Triggering player))])
      • Set Courier_Alive[(Player number of (Triggering player))] = True
      • Visibility - Disable fog of war
      • Visibility - Disable black mask
      • Trigger - Turn on Courier Travel <gen>
  • Courier Travel
    • Events
      • Time - Every 0.50 seconds of game time
    • Conditions
    • Actions
      • Set Courier_Your_HeroTempPoint[(Player number of (Triggering player))] = (Position of Courier_YourHero[(Player number of (Triggering player))])
      • Set Courier_Your_CourierFirstPoint[(Player number of (Triggering player))] = (Position of Courier_YourCourier[(Player number of (Triggering player))])
      • Set Courier_DistanceToHero[(Player number of (Triggering player))] = (Angle from Courier_Your_HeroTempPoint[(Player number of (Triggering player))] to Courier_Your_CourierFirstPoint[(Player number of (Triggering player))])
      • Set Courier_Distance[(Player number of (Triggering player))] = (Courier_Your_HeroTempPoint[(Player number of (Triggering player))] offset by 45.00 towards Courier_DistanceToHero[(Player number of (Triggering player))] degrees)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Integer((Distance between Courier_Your_HeroTempPoint[(Player number of (Triggering player))] and Courier_Your_CourierFirstPoint[(Player number of (Triggering player))]))) Greater than or equal to 400
        • Then - Actions
          • Unit - Move Courier_YourCourier[(Player number of (Triggering player))] instantly to Courier_Your_HeroTempPoint[(Player number of (Triggering player))]
        • Else - Actions
 
Last edited:
Level 25
Joined
Mar 29, 2020
Messages
1,465
I'm not exactly sure what you have going there. I would do this:

  • courier travel
    • Events
      • Time - Every 0.50 seconds of game time
    • Conditions
    • Actions
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • Set VariableSet CurrentHero = Heroes[(Player number of (Picked player))]
          • Set VariableSet CurrentCourier = Couriers[(Player number of (Picked player))]
          • Set VariableSet CourierPoint = (Position of CurrentCourier)
          • Set VariableSet HeroPoint = (Position of CurrentHero)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Distance between CourierPoint and HeroPoint) Greater than or equal to 400.00
            • Then - Actions
              • Unit - Move CurrentCourier instantly to HeroPoint
            • Else - Actions
          • Custom script: call RemoveLocation(udg_CourierPoint)
          • Custom script: call RemoveLocation(udg_HeroPoint)
of course this is assuming you have one hero per player, and that you are storing the heroes and couriers in unit arrays.

edit: - maybe this is intentional, but 400 distance is not very far. this means the couriers would pretty much be useless...
 
Level 10
Joined
Dec 16, 2017
Messages
416
This is exactly what i tried to do..

Yeah, i have them saved in arrays, it showed in first trigger from first post

Edit: seems like it doesn't work with your version aswell..hmm..what could it be..

  • Courier
    • Events
      • Unit - A unit Sells an item (from shop)
    • Conditions
      • (Item-type of (Sold Item)) Equal to |c0066FF00Courier|r (|cffffcc00R|r)
      • Courier_Alive[(Player number of (Triggering player))] Equal to False
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Courier_Alive[(Player number of (Triggering player))] Equal to True
        • Then - Actions
          • Player - Add 75 to (Triggering player) Current gold
        • Else - Actions
          • Set Courier_YourHero[(Player number of (Triggering player))] = (Buying unit)
          • Set Courier_Your_HeroTempPoint[(Player number of (Triggering player))] = (Position of Courier_YourHero[(Player number of (Triggering player))])
          • Unit - Create 1 Courier for (Owner of Courier_YourHero[(Player number of (Triggering player))]) at Courier_Your_HeroTempPoint[(Player number of (Triggering player))] facing Default building facing degrees
          • Set Courier_YourCourier[(Player number of (Triggering player))] = (Last created unit)
          • Set Courier_Your_CourierFirstPoint[(Player number of (Triggering player))] = (Position of Courier_YourCourier[(Player number of (Triggering player))])
          • Set Courier_Alive[(Player number of (Triggering player))] = True
          • Visibility - Disable fog of war
          • Visibility - Disable black mask
          • Trigger - Turn on Courier Travel <gen>
  • Courier Travel
    • Events
      • Time - Every 0.50 seconds of game time
    • Conditions
    • Actions
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • Set Courier_CurrentHero = Courier_YourHero[(Player number of (Picked player))]
          • Set Courier_CurrentCourier = Courier_YourCourier[(Player number of (Picked player))]
          • Set Courier_CourierPosition = (Position of Courier_CurrentCourier)
          • Set Courier_HeroPosition = (Position of Courier_CurrentHero)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Integer((Distance between Courier_CourierPosition and Courier_HeroPosition))) Greater than or equal to 700
            • Then - Actions
              • Unit - Move Courier_CurrentCourier instantly to Courier_HeroPosition
            • Else - Actions
          • Custom script: call RemoveLocation(udg_Courier_CourierPosition)
          • Custom script: call RemoveLocation(udg_Courier_HeroPosition)
 
Last edited:
Level 10
Joined
Dec 16, 2017
Messages
416
Thanks a lot !

If someone searches this and needs it, here is the final version of the triggers

  • Courier
    • Events
      • Unit - A unit Sells an item (from shop)
    • Conditions
      • (Item-type of (Sold Item)) Equal to |c0066FF00Courier|r (|cffffcc00R|r)
      • Courier_Alive[(Player number of (Owner of (Buying unit)))] Equal to False
    • Actions
      • Set Courier_YourHero[(Player number of (Owner of (Buying unit)))] = (Buying unit)
      • Set Courier_Your_HeroTempPoint[(Player number of (Owner of (Buying unit)))] = (Position of Courier_YourHero[(Player number of (Owner of (Buying unit)))])
      • Unit - Create 1 Courier for (Owner of Courier_YourHero[(Player number of (Owner of (Buying unit)))]) at Courier_Your_HeroTempPoint[(Player number of Courier_Player)] facing Default building facing degrees
      • Set Courier_YourCourier[(Player number of (Owner of (Buying unit)))] = (Last created unit)
      • Set Courier_Your_CourierFirstPoint[(Player number of (Owner of (Buying unit)))] = (Position of Courier_YourCourier[(Player number of (Owner of (Buying unit)))])
      • Set Courier_Alive[(Player number of (Owner of (Buying unit)))] = True
      • Visibility - Disable fog of war
      • Visibility - Disable black mask
      • Trigger - Turn on Courier Travel <gen>
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Courier_Alive[(Player number of (Owner of (Buying unit)))] Equal to True
        • Then - Actions
          • Player - Add 75 to (Owner of (Buying unit)) Current gold
        • Else - Actions
  • Courier Travel
    • Events
      • Time - Every 0.50 seconds of game time
    • Conditions
    • Actions
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • Set Courier_CurrentHero = Courier_YourHero[(Player number of (Picked player))]
          • Set Courier_CurrentCourier = Courier_YourCourier[(Player number of (Picked player))]
          • Set Courier_CourierPosition = (Position of Courier_CurrentCourier)
          • Set Courier_HeroPosition = (Position of Courier_CurrentHero)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Integer((Distance between Courier_CourierPosition and Courier_HeroPosition))) Greater than or equal to 700
            • Then - Actions
              • Unit - Move Courier_CurrentCourier instantly to Courier_HeroPosition
            • Else - Actions
          • Custom script: call RemoveLocation(udg_Courier_CourierPosition)
          • Custom script: call RemoveLocation(udg_Courier_HeroPosition)

Edit:
I use this in an ORPG, after i tier up, shall i set the hero again to the variable, so the courier still moves after the hero? Because when i tier up, the initial hero get's removed from game, and another one is created, so i set
  • Set Courier_YourHero[(Player number of (Owner of (Buying unit)))] = (Buying unit)
    • Set Courier_Your_HeroTempPoint[(Player number of (Owner of (Buying unit)))] = (Position of Courier_YourHero[(Player number of (Owner of (Buying unit)))])
to last created unit

Like this:

  • Thief Job 1 01
    • Events
      • Unit - A unit enters Chang Job Thief <gen>
    • Conditions
      • ((Triggering unit) is A Hero) Equal to True
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Triggering unit)) Equal to |cffFF0000Novice|r
          • (Hero level of (Triggering unit)) Greater than or equal to 15
          • ((Triggering unit) has an item of type |c00fEBA0ELetter of Success) Equal to True
        • Then - Actions
          • Hero - Drop the item from slot 1 of (Triggering unit)
          • Set Item[1] = (Last dropped item)
          • Hero - Drop the item from slot 2 of (Triggering unit)
          • Set Item[2] = (Last dropped item)
          • Hero - Drop the item from slot 3 of (Triggering unit)
          • Set Item[3] = (Last dropped item)
          • Hero - Drop the item from slot 4 of (Triggering unit)
          • Set Item[4] = (Last dropped item)
          • Hero - Drop the item from slot 5 of (Triggering unit)
          • Set Item[5] = (Last dropped item)
          • Hero - Drop the item from slot 6 of (Triggering unit)
          • Set Item[6] = (Last dropped item)
          • Unit - Remove (Triggering unit) from the game
          • Unit - Create 1 |c0000FF7F[Thief] - |c008A2BE2[Job 1]|r for (Owner of (Triggering unit)) at QuestsThief_Position[1] facing Default building facing degrees
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Courier_Alive[(Player number of (Triggering player))] Equal to True
            • Then - Actions
              • Set Courier_YourHero[(Player number of (Triggering player))] = (Last created unit)
            • Else - Actions
          • Selection - Select (Last created unit) for (Owner of (Triggering unit))
          • Game - Display to (All players) for 30.00 seconds the text: ((Player_Color[(Player number of (Owner of (Triggering unit)))] + ((Name of (Owner of (Triggering unit))) + |r)) + ( got enough knowledge to change his job into + (Name of (Last created unit))))
          • Camera - Pan camera for (Owner of (Triggering unit)) to QuestsThief_Position[1] over 0.30 seconds
          • Special Effect - Create a special effect attached to the origin of (Last created unit) using Abilities\Spells\Human\Resurrect\ResurrectCaster.mdl
          • Special Effect - Destroy (Last created special effect)
          • Special Effect - Create a special effect attached to the origin of (Last created unit) using Abilities\Spells\Human\Resurrect\ResurrectTarget.mdl
          • Special Effect - Destroy (Last created special effect)
          • Hero - Give Item[1] to (Last created unit)
          • Hero - Give Item[2] to (Last created unit)
          • Hero - Give Item[3] to (Last created unit)
          • Hero - Give Item[4] to (Last created unit)
          • Hero - Give Item[5] to (Last created unit)
          • Hero - Give Item[6] to (Last created unit)
          • Hero - Make (Owner of (Last created unit)) Heroes gain 125.00% experience from future kills
          • Player - Add -75 to (Owner of (Last created unit)) Current lumber
          • Item - Remove (Item carried by (Last created unit) of type |c00fEBA0ELetter of Success)
        • Else - Actions
 
Last edited:

Uncle

Warcraft Moderator
Level 71
Joined
Aug 10, 2018
Messages
7,640
You can ditch the Courier_CurrentHero and Courier_CurrentCourier variables seeing as how they're just copies of variables you already have.

Also, in your first trigger, you were referencing (Triggering player) in a Periodic Event trigger. Who exactly would that player be? How would the game know which player you're referring to?

Event Responses are set in response to Events:
A unit dies -> Dying unit
A unit is attacked -> Attacked unit, Attacking unit
Player X types a chat message -> Triggering player

Without an Event that involves a player, there is no (Triggering player).
 
Status
Not open for further replies.
Top