Turn Back the Boats v4

This bundle is marked as useful / simple. Simplicity is bliss, low effort and/or may contain minor bugs.
  • Like
Reactions: Imadori
Sends a boat to target location picking up to 1/3/5 heroes (refugees) sailing for 800/1200/1600 range. Boat drops them then explodes dealing 100/200/300 damage in an area.

Importing:
  • Human Transport Ship (custom unit)
  • AOE damage upon death (boat)
  • Turn Back the Boats (hero ability)
Tested it for MUI and spamming...hopefully no bugs.

Credits

Gismo359 for fixing my indexing recycling (http://www.hiveworkshop.com/forums/triggers-scripts-269/spell-progress-gui-turn-back-boats-259717/)
Also credits to the worst Australian PM ever....Tony Abbott for "turning back the boats" as a way to solve the asylum seeker crisis.
I mean no offense to actual refugees or immigrants.

Triggers
  • TBB Setup
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set TBB_speed[1] = 12.00
      • Set TBB_speed[2] = 24.00
      • Set TBB_speed[3] = 36.00
      • Set TBB_detection[1] = 275.00
      • Set TBB_detection[2] = 300.00
      • Set TBB_detection[3] = 325.00
      • Set TBB_refugees[1] = 1
      • Set TBB_refugees[2] = 3
      • Set TBB_refugees[3] = 5
      • Set TBB_Dumm = Human Transport Ship
  • TBB Cast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Turn Back the Boats
    • Actions
      • Set TBB_Index = (TBB_Index + 1)
      • Set TBB_Caster[TBB_Index] = (Triggering unit)
      • Set TBB_CasterLoc = (Position of TBB_Caster[TBB_Index])
      • Set TBB_TargetLoc = (Target point of ability being cast)
      • Set TBB_player[TBB_Index] = (Triggering player)
      • Set TBB_Level[TBB_Index] = (Level of Turn Back the Boats for TBB_Caster[TBB_Index])
      • -------- Creating Boat Dummy --------
      • Set TBB_Angle[TBB_Index] = (Angle from TBB_CasterLoc to TBB_TargetLoc)
      • Unit - Create 1 TBB_Dumm for TBB_player[TBB_Index] at TBB_CasterLoc facing TBB_Angle[TBB_Index] degrees
      • Set TBB_Dummy[TBB_Index] = (Last created unit)
      • Unit - Set level of AOE damage upon death (boat) for TBB_Dummy[TBB_Index] to TBB_Level[TBB_Index]
      • Set TBB_distance[TBB_Index] = 0.00
      • Set TBB_maxdistance[TBB_Index] = (400.00 + (400.00 x (Real(TBB_Level[TBB_Index]))))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • TBB_Index Equal to 1
        • Then - Actions
          • Trigger - Turn on TBB Loop <gen>
        • Else - Actions
      • Custom script: call RemoveLocation(udg_TBB_CasterLoc)
      • Custom script: call RemoveLocation(udg_TBB_TargetLoc)
  • TBB Loop
    • Events
      • Time - Every 0.02 seconds of game time
    • Conditions
    • Actions
      • For each (Integer TBB_Loop) from 1 to TBB_Index, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • TBB_distance[TBB_Loop] Greater than or equal to TBB_maxdistance[TBB_Loop]
            • Then - Actions
              • Set TBB_TempPoint[TBB_Loop] = (Position of TBB_Dummy[TBB_Loop])
              • Unit Group - Pick every unit in TBB_GroupSel[TBB_Loop] and do (Actions)
                • Loop - Actions
                  • Set TBB_TempUnit = (Picked unit)
                  • Unit - Unhide TBB_TempUnit
                  • Unit - Move TBB_TempUnit instantly to TBB_TempPoint[TBB_Loop]
                  • Unit - Unpause TBB_TempUnit
              • Unit - Kill TBB_Dummy[TBB_Loop]
              • Special Effect - Create a special effect at TBB_TempPoint[TBB_Loop] using Abilities\Spells\Human\FlameStrike\FlameStrike1.mdl
              • Special Effect - Destroy (Last created special effect)
              • Custom script: call RemoveLocation(udg_TBB_TempPoint[udg_TBB_Loop])
              • Custom script: call DestroyGroup(udg_TBB_GroupSel[udg_TBB_Loop])
              • -------- Nulling Variables --------
              • Set TBB_Angle[TBB_Loop] = TBB_Angle[TBB_Index]
              • Set TBB_distance[TBB_Loop] = TBB_distance[TBB_Index]
              • Set TBB_maxdistance[TBB_Loop] = TBB_maxdistance[TBB_Index]
              • Set TBB_Caster[TBB_Loop] = TBB_Caster[TBB_Index]
              • Set TBB_Loaded[TBB_Loop] = TBB_Loaded[TBB_Index]
              • Set TBB_Dummy[TBB_Loop] = TBB_Dummy[TBB_Index]
              • Set TBB_Level[TBB_Loop] = TBB_Level[TBB_Index]
              • Set TBB_Angle[TBB_Index] = 0.00
              • Set TBB_distance[TBB_Index] = 0.00
              • Set TBB_maxdistance[TBB_Index] = 0.00
              • Set TBB_Caster[TBB_Index] = No unit
              • Set TBB_Loaded[TBB_Index] = False
              • Set TBB_Dummy[TBB_Index] = No unit
              • Set TBB_Level[TBB_Index] = 0
              • -------- Recycling Indexes --------
              • Set TBB_Index = (TBB_Index - 1)
              • Set TBB_Loop = (TBB_Loop - 1)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • TBB_Index Equal to 0
                • Then - Actions
                  • Set TBB_TempUnit = No unit
                  • Trigger - Turn off (This trigger)
                • Else - Actions
            • Else - Actions
              • -------- Moving the Boat --------
              • Set TBB_TempPoint[TBB_Loop] = (Position of TBB_Dummy[TBB_Loop])
              • Set TBB_Point2[TBB_Loop] = (TBB_TempPoint[TBB_Loop] offset by TBB_speed[TBB_Level[TBB_Loop]] towards TBB_Angle[TBB_Loop] degrees)
              • Set TBB_distance[TBB_Loop] = (TBB_distance[TBB_Loop] + TBB_speed[TBB_Level[TBB_Loop]])
              • Unit - Move TBB_Dummy[TBB_Loop] instantly to TBB_Point2[TBB_Loop]
              • Custom script: call RemoveLocation(udg_TBB_TempPoint[udg_TBB_Loop])
              • Custom script: call RemoveLocation(udg_TBB_Point2[udg_TBB_Loop])
              • -------- Making sure loading occurs only once --------
              • Set TBB_TempPoint[TBB_Loop] = (Position of TBB_Dummy[TBB_Loop])
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • TBB_Loaded[TBB_Loop] Equal to False
                • Then - Actions
                  • Set TBB_Group[TBB_Loop] = (Units within TBB_detection[TBB_Level[TBB_Loop]] of TBB_TempPoint[TBB_Loop] matching ((((Matching unit) belongs to an enemy of TBB_player[TBB_Loop]) Equal to True) and ((((Matching unit) is alive) Equal to True) and (((Matching unit) is A Hero) Equal to True)
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (TBB_Group[TBB_Loop] is empty) Equal to False
                    • Then - Actions
                      • Set TBB_GroupSel[TBB_Loop] = (Random TBB_refugees[TBB_Level[TBB_Loop]] units from TBB_Group[TBB_Loop])
                      • Custom script: call DestroyGroup(udg_TBB_Group[udg_TBB_Loop])
                      • Unit Group - Pick every unit in TBB_GroupSel[TBB_Loop] and do (Actions)
                        • Loop - Actions
                          • Set TBB_TempUnit = (Picked unit)
                          • Unit - Pause TBB_TempUnit
                          • Floating Text - Create floating text that reads Refugee intercepted... above TBB_TempUnit with Z offset 100.00, using font size 10.00, color (100.00%, 0.00%, 0.00%), and 0.00% transparency
                          • Floating Text - Change (Last created floating text): Disable permanence
                          • Floating Text - Change the lifespan of (Last created floating text) to 2.00 seconds
                          • Unit - Hide TBB_TempUnit
                      • Set TBB_Loaded[TBB_Loop] = True
                    • Else - Actions
                      • Set TBB_Loaded[TBB_Loop] = False
                • Else - Actions
              • Custom script: call RemoveLocation(udg_TBB_TempPoint[udg_TBB_Loop])

  • V1: Put Level of TBB into variable. Made dummy unit configurable. Put Picked unit into temp variable.
  • V2: Put offset point into a new variable instead of overwriting. Put random N selection group selection into new variable.
  • V3: Fixed the Loop trigger to check if TBB_Group is empty so that TBB_loaded boolean is not erroneously set as true at initial position of dummy.
  • V4: Removed leak in the event condition is false by shifting the custom script to outside the ITE. Put multiple references into variable. Added SFX to boat dying.

Keywords:
tony abbott, refugees, boat, sail, PM, lol, epic, politician, policy
Contents

Turn Back the Boats (Map)

Reviews
12th Dec 2015 IcemanBo: For long time as NeedsFix. Rejected. 02:03, 10th Jan 2015 IcemanBo: http://www.hiveworkshop.com/forums/spells-569/turn-back-boats-v4-259744/#post2638274
Level 13
Joined
Jul 16, 2012
Messages
679
In your Trigger Loop,

Your Unit Groups TBB_Group[TBB_Loop], you must put the Picked Unit in a variable

  • Time - Every 0.02 seconds of game time
->>
  • Time - Every 0.03 seconds of game time
This is recommended...

  • Set TBB_Group[TBB_Loop] = (Units within TBB_detection[(Level of Turn Back the Boats for TBB_Caster[TBB_Loop])] of TBB_TempPoint[TBB_Loop] matching ((((Matching unit) belongs to an enemy of (Owner of TBB_Caster[TBB_Loop])) Equal to True) and ((((Matching unit) is alive) Equal to True)
Put this in ITE (If then Else), to easy to change the condition if need.
 
This should be stored.
  • (TBB_distance[TBB_Loop] + TBB_speed[(Level of Turn Back the Boats for TBB_Caster[TBB_Loop])])
The level above should always be stored when the spell is first cast. Otherwise when a unit casts a spell then upgrades it the spell will get the outcome of a higher spell level.

Anything you use twice or more should be stored in a variable. This is for speed and efficiency. Example: (Picked unit) / (Last created floating text)
 
Level 20
Joined
Jul 14, 2011
Messages
877
  • Set TBB_TempPoint[TBB_Loop] = (Position of TBB_Dummy[TBB_Loop])
  • Set TBB_TempPoint[TBB_Loop] = (TBB_TempPoint[TBB_Loop] offset by TBB_speed[TBB_Level[TBB_Loop]] towards TBB_Angle[TBB_Loop] degrees)
Remove locations when you are done using them (before you set them to another value, to be more precise). In this case you need a second variable for the offset.

  • Set TBB_Group[TBB_Loop] = (Units within TBB_detection[TBB_Level[TBB_Loop]] of TBB_TempPoint[TBB_Loop] matching ((((Matching unit) belongs to an enemy of (Owner of TBB_Caster[TBB_Loop])) Equal to True) and ((((Matching unit) is alive) Equal to True) and (((Matching unit) is A Hero) Equ
  • Set TBB_Group[TBB_Loop] = (Random TBB_refugees[TBB_Level[TBB_Loop]] units from TBB_Group[TBB_Loop])
Same thing here.
 
Level 5
Joined
May 13, 2012
Messages
68
  • Set TBB_TempPoint[TBB_Loop] = (Position of TBB_Dummy[TBB_Loop])
  • Set TBB_TempPoint[TBB_Loop] = (TBB_TempPoint[TBB_Loop] offset by TBB_speed[TBB_Level[TBB_Loop]] towards TBB_Angle[TBB_Loop] degrees)
Remove locations when you are done using them (before you set them to another value, to be more precise). In this case you need a second variable for the offset.

  • Set TBB_Group[TBB_Loop] = (Units within TBB_detection[TBB_Level[TBB_Loop]] of TBB_TempPoint[TBB_Loop] matching ((((Matching unit) belongs to an enemy of (Owner of TBB_Caster[TBB_Loop])) Equal to True) and ((((Matching unit) is alive) Equal to True) and (((Matching unit) is A Hero) Equ
  • Set TBB_Group[TBB_Loop] = (Random TBB_refugees[TBB_Level[TBB_Loop]] units from TBB_Group[TBB_Loop])
Same thing here.
I'm not sure what harm there is overwriting variables rather than using a new one. Is it more likely to bug?
 
I'm not sure what harm there is overwriting variables rather than using a new one. Is it more likely to bug?

Locations among other things leak. That means once you lose the reference to them they sit in memory for no reason. That is why you need to destroy the location.

Look at the tutorial Things that leaks. It is on the triggers and scripts main page.
 
This should be calculated and stored.
  • (400.00 + (400.00 x (Real(TBB_Level[TBB_Loop]))))
Same with this.
  • (Owner of TBB_Caster[TBB_Loop]))
Both of the above will easily be used twice or more in a spell instance.

This needs to be moved into the Then block of the ITE otherwise it leaks when the condition is false.
  • Set TBB_TempPoint[TBB_Loop] = (Position of TBB_Dummy[TBB_Loop])
As said above anything used twice or more should be stored. This should be stored.
  • (Last created floating text)
Switch these around to make it more efficient.
  • Set TBB_CasterLoc = (Position of (Triggering unit))
    • Set TBB_TargetLoc = (Target point of ability being cast)
    • Set TBB_Index = (TBB_Index + 1)
    • Set TBB_Caster[TBB_Index] = (Triggering unit)
Like this.
  • Set TBB_Caster[TBB_Index] = (Triggering unit)
  • Set TBB_CasterLoc = (Position of TBB_Caster[TBB_Index])
  • Set TBB_TargetLoc = (Target point of ability being cast)
  • Set TBB_Index = (TBB_Index + 1)[//trigger]
 
- Don't use PauseUnit.
- The effect should be configurable.
- Trigger the AOE damage yourself, and make it configurable.
- You have potential group leaks.
- FloatingTexts are not needed. At least make them optional, and part of the config.
- Set periodic time to "0.03".
- Explain in SetUp that the speed is linked with your periodic event.
- Settint integer to "0" is not needed onDeindex.
- Setting booleans to "false" is not needed onDeindex.
- Your import instructions are lacking.
- Add some comments. At least for user.
- Tooltip is one big sentence. It can be improved. And somehow the "Turn Back to Boats" name is a strange spell name in my opinion.

Needs Fix
 
Top