• 🏆 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!

Please help making this leakless

Status
Not open for further replies.
Level 8
Joined
Jun 13, 2010
Messages
344
Hi,
so i followes this turtorial and I suddenly realized it seems this procedure is not leakless.
It is a Creep Respawn System. It has 3 triggers, shown below.
Trigger nr 2 seems to be the one leaking, since it does not remove the past point, while trigger nr 3 creates yet another one for the newly spawned one.
How do I custom script this? Like...:

  • Custom script: call RemoveLocation (udg_Creep_Respawn_Point[(Custom Value of (Dying unit))]
But is that legti? xD
Can the computer read (Custom Value of (Dying unit))? ^^

Trigger 1:
  • Creep Respawn Point Saver
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set Creep_Respawn_Timer = 70.00
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units in (Entire map) owned by Player 12 (Brown)) and do (Actions)
        • Loop - Actions
          • Set Creep_Respawn_Integer = (Creep_Respawn_Integer + 1)
          • Unit - Set the custom value of (Picked unit) to Creep_Respawn_Integer
          • Set Creep_Respawn_Point[Creep_Respawn_Integer] = (Position of (Picked unit))
Trigger 2:
  • Creep Respawn Timer
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Owner of (Dying unit)) Equal to Player 12 (Brown)
      • (Custom value of (Dying unit)) Greater than 0
    • Actions
      • Wait Creep_Respawn_Timer seconds
      • Unit - Create 1 (Unit-type of (Dying unit)) for Player 12 (Brown) at Creep_Respawn_Point[(Custom value of (Dying unit))] facing (Random real number between 0.00 and 360.00) degrees
      • Unit - Set the custom value of (Last created unit) to (Custom value of (Dying unit))
Trigger 3:
  • Creep Respawn
    • Events
      • Unit - A unit enters (Playable map area)
    • Conditions
      • (Owner of (Entering unit)) Equal to Neutral Hostile
    • Actions
      • Set Creep_Respawn_Integer = (Creep_Respawn_Integer + 1)
      • Unit - Set the custom value of (Entering unit) to Creep_Respawn_Integer
      • Set Creep_Respawn_Point[Creep_Respawn_Integer] = (Position of (Entering unit))
 
Level 8
Joined
Jun 13, 2010
Messages
344
I just noticd Trigger 3 has condition as Hostile, while the others have Player 12.. But it seems to be working.
Does it even require trigger 3?
I mean trigger 2 copies the custom value of dying unit and becomes a copy of it. So why increase its integer level and create yet another location for it?


Addtionally, if you would mind answering another question..

A Hero in my RPG map has a Charm ability. Now I want the charmed unit to start the respawn timer as well.
Do you guys approve this trigger set for that ability?

  • Creep Hexing Doll
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Voodoo Master (Hexing Doll)
      • (Owner of (Target unit of ability being cast)) Equal to Player 12 (Brown)
    • Actions
      • Wait Creep_Respawn_Timer seconds
      • Unit - Create 1 (Unit-type of (Target unit of ability being cast)) for Player 12 (Brown) at Creep_Respawn_Point[(Custom value of (Target unit of ability being cast))] facing (Random real number between 0.00 and 360.00) degrees
      • Unit - Set the custom value of (Last created unit) to (Custom value of (Dying unit))
and I know this trigger is quite nooby, but do you have a simpler suggestion?
The first makes sure you cannot charm a higher level than your heroes' and gives your charmed unit a variable... I know..
The second just makes sure you cannot have more than 1 charmed unit at a time and kills the first.

  • Doll Hexing
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Voodoo Master (Hexing Doll)
    • Actions
      • Set VoodooMaster_HD_Caster = (Casting unit)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Level of (Casting unit)) Less than (Level of (Target unit of ability being cast))
        • Then - Actions
          • Game - Display to (All players controlled by a ((Owner of (Casting unit)) controller) player) for 3.00 seconds the text: |cffff0000Target is...
          • Unit - Order (Casting unit) to Stop
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Owner of (Casting unit)) Equal to Player 1 (Red)
            • Then - Actions
              • Unit - Kill VoodooMaster_HD_Target_P1
              • Set VoodooMaster_HD_Target_P1 = (Target unit of ability being cast)
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Owner of (Casting unit)) Equal to Player 2 (Blue)
                • Then - Actions
                  • Unit - Kill VoodooMaster_HD_Target_P2
                  • Set VoodooMaster_HD_Target_P2 = (Target unit of ability being cast)
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Owner of (Casting unit)) Equal to Player 3 (Teal)
                    • Then - Actions
                      • Unit - Kill VoodooMaster_HD_Target_P3
                      • Set VoodooMaster_HD_Target_P3 = (Target unit of ability being cast)
                    • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Owner of (Casting unit)) Equal to Player 4 (Purple)
                        • Then - Actions
                          • Unit - Kill VoodooMaster_HD_Target_P4
                          • Set VoodooMaster_HD_Target_P4 = (Target unit of ability being cast)
                        • Else - Actions
                          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            • If - Conditions
                              • (Owner of (Casting unit)) Equal to Player 5 (Yellow)
                            • Then - Actions
                              • Unit - Kill VoodooMaster_HD_Target_P5
                              • Set VoodooMaster_HD_Target_P5 = (Target unit of ability being cast)
                            • Else - Actions
                              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                • If - Conditions
                                  • (Owner of (Casting unit)) Equal to Player 6 (Orange)
                                • Then - Actions
                                  • Unit - Kill VoodooMaster_HD_Target_P6
                                  • Set VoodooMaster_HD_Target_P6 = (Target unit of ability being cast)
                                • Else - Actions
                                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                    • If - Conditions
                                      • (Owner of (Casting unit)) Equal to Player 7 (Green)
                                    • Then - Actions
                                      • Unit - Kill VoodooMaster_HD_Target_P7
                                      • Set VoodooMaster_HD_Target_P7 = (Target unit of ability being cast)
                                    • Else - Actions
                                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                        • If - Conditions
                                          • (Owner of (Casting unit)) Equal to Player 8 (Pink)
                                        • Then - Actions
                                          • Unit - Kill VoodooMaster_HD_Target_P8
                                          • Set VoodooMaster_HD_Target_P8 = (Target unit of ability being cast)
                                        • Else - Actions
                                          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                            • If - Conditions
                                              • (Owner of (Casting unit)) Equal to Player 9 (Gray)
                                            • Then - Actions
                                              • Unit - Kill VoodooMaster_HD_Target_P9
                                              • Set VoodooMaster_HD_Target_P9 = (Target unit of ability being cast)
                                            • Else - Actions
                                              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                                • If - Conditions
                                                  • (Owner of (Casting unit)) Equal to Player 10 (Light Blue)
                                                • Then - Actions
                                                  • Unit - Kill VoodooMaster_HD_Target_P10
                                                  • Set VoodooMaster_HD_Target_P10 = (Target unit of ability being cast)
                                                • Else - Actions
                                                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                                    • If - Conditions
                                                      • (Owner of (Casting unit)) Equal to Player 11 (Dark Green)
                                                    • Then - Actions
                                                      • Unit - Kill VoodooMaster_HD_Target_P11
                                                      • Set VoodooMaster_HD_Target_P11 = (Target unit of ability being cast)
                                                    • Else - Actions

  • Doll Hexing Master Dying
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Unit-type of (Dying unit)) Equal to Voodoo Master
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of (Dying unit)) Equal to Player 1 (Red)
        • Then - Actions
          • Unit - Kill VoodooMaster_HD_Target_P1
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of (Dying unit)) Equal to Player 2 (Blue)
        • Then - Actions
          • Unit - Kill VoodooMaster_HD_Target_P2
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of (Dying unit)) Equal to Player 3 (Teal)
        • Then - Actions
          • Unit - Kill VoodooMaster_HD_Target_P3
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of (Dying unit)) Equal to Player 4 (Purple)
        • Then - Actions
          • Unit - Kill VoodooMaster_HD_Target_P4
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of (Dying unit)) Equal to Player 5 (Yellow)
        • Then - Actions
          • Unit - Kill VoodooMaster_HD_Target_P5
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of (Dying unit)) Equal to Player 6 (Orange)
        • Then - Actions
          • Unit - Kill VoodooMaster_HD_Target_P6
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of (Dying unit)) Equal to Player 7 (Green)
        • Then - Actions
          • Unit - Kill VoodooMaster_HD_Target_P7
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of (Dying unit)) Equal to Player 8 (Pink)
        • Then - Actions
          • Unit - Kill VoodooMaster_HD_Target_P8
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of (Dying unit)) Equal to Player 9 (Gray)
        • Then - Actions
          • Unit - Kill VoodooMaster_HD_Target_P9
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of (Dying unit)) Equal to Player 10 (Light Blue)
        • Then - Actions
          • Unit - Kill VoodooMaster_HD_Target_P10
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of (Dying unit)) Equal to Player 11 (Dark Green)
        • Then - Actions
          • Unit - Kill VoodooMaster_HD_Target_P11
        • Else - Actions
 
If you want to do it directly, you can use this:
  • Custom script: call RemoveLocation(udg_Creep_Respawn_Point[GetUnitUserData(GetDyingUnit())])
You can figure out the appropriate functions to use by creating a new trigger in GUI, writing down your code in GUI, and then going to Edit -> Convert Custom Text to see the equivalent JASS functions.

However, that can be a tedious process. In general, if you're ever stuck on what to put for array indices, then just use a variable! :)
  • Set TempInt = (Custom value of (Dying unit))
  • Custom script: call RemoveLocation(udg_Creep_Respawn_Point[udg_TempInt])
EDIT:
I just noticd Trigger 3 has condition as Hostile, while the others have Player 12.. But it seems to be working.
Does it even require trigger 3?

It depends on whether you use "Neutral Hostile" for your creeps or whether you use "Player 12". If you use Player 12, then you should change it to use Player 12. Otherwise the creep locations won't be stored for units that are spawned as the map goes on (i.e. when a unit "enters the playable map area").

Do you guys approve this trigger set for that ability?

The main issue I see with your trigger is the "Custom value of (Dying unit)". "Dying unit" only returns a valid unit in response to a unit-death event. Your event is for a spell cast. Which unit are you trying to refer to with "Dying unit"?

As for your second set of triggers, consider using an array instead of individual variables. That way you can just reduce all that code to a loop across the players, e.g.
  • For each (VoodooMaster_Loop) from 1 to 11 do (Actions)
    • Loop - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of (Dying unit)) Equal to (Player (VoodooMaster_Loop))
        • Then - Actions
          • Unit - Kill VoodooMaster_HD_Target[(VoodooMaster_Loop)]
        • Else - Actions
Something along those lines.
 
Status
Not open for further replies.
Top