• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Solved] Random Teleport

Status
Not open for further replies.
Level 11
Joined
Jun 20, 2017
Messages
380
I have 28 item in map, when my unit cast a spell, then unit move to random item.
this way is right?
  • RandomTeleport
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to (==) RandomTeleport [Human]
    • Actions
      • Game - Display to (All players matching ((Matching player) Equal to (==) (Picked player))) the text: (String_PlayerColors[(Player number of (Picked player))] + you've survived for 12 minutes, all the surviving Humans have now gained 2 gold.)
      • Set RandomTeleport = (Random integer number between 1 and 28)
        • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (Item-type of (Target item of ability being cast)) Equal to (==) Bundle of Lumber
            • RandomTeleport Greater than or equal to (>=) 1
          • Then - Actions
            • Set RandomItemTel = (Random item in (Playable map area))
            • Unit - Move (Casting unit) instantly to (Position of RandomItemTel)
          • Else - Actions
      • Wait 60.00 seconds
      • Set UnitGroup = (Units in (Playable map area))
      • Unit Group - Pick every unit in UnitGroup and do (Actions)
        • Loop - Actions
          • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Multiple ConditionsOr - Any (Conditions) are true
                • Conditions
                  • (Unit-type of (Picked unit)) Equal to (==) Builder (Male)
                  • (Unit-type of (Picked unit)) Equal to (==) Builder (Female)
            • Then - Actions
              • Unit - Remove RandomTeleport [Human] from (Picked unit)
              • Unit - Add Teleport [Human] to (Picked unit)
            • Else - Actions
      • Custom script: call DestroyGroup(udg_UnitGroup)
 
Last edited:
  • The random integer seems not to affect something
  • (Picked Player) is unlikely to be wanted. Probably (Triggering Player) was meant?
  • The item type comparison for "Bundle of Lumber" seems a bit off, as it could maybe come before
  • The item's location leaks
It's hard to judge something is right, not knowing all expectations.
 
Level 11
Joined
Jun 20, 2017
Messages
380
It works, but has it leaks?
  • RandomTeleport
    • Events
      • Unit - A unit Finishes casting an ability
    • Conditions
      • (Ability being cast) Equal to (==) RandomTeleport [Human]
    • Actions
      • Game - Display to (All players matching ((Matching player) Equal to (==) (Triggering player))) the text: (String_PlayerColors[(Player number of (Triggering player))] + <Empty String>)
      • Set Item_RandomTeleport = (Random item in (Playable map area))
        • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (Item-type of Item_RandomTeleport) Equal to (==) Bundle of Lumber
          • Then - Actions
            • Unit - Move (Casting unit) instantly to (Position of Item_RandomTeleport)
          • Else - Actions
      • Set UnitGroup = (Units in (Playable map area))
      • Unit Group - Pick every unit in UnitGroup and do (Actions)
        • Loop - Actions
          • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Multiple ConditionsOr - Any (Conditions) are true
                • Conditions
                  • (Unit-type of (Picked unit)) Equal to (==) Builder (Male)
                  • (Unit-type of (Picked unit)) Equal to (==) Builder (Female)
            • Then - Actions
              • Unit - Remove RandomTeleport [Human] from (Picked unit)
              • Unit - Add Teleport [Human] to (Picked unit)
            • Else - Actions
      • Custom script: call DestroyGroup(udg_UnitGroup)
 
Status
Not open for further replies.
Top