• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Solved] Limited Summon trigger

Status
Not open for further replies.
Hello so i want to make a skill for a basic unit (Ex:Footman) that will summon 1 unit. This skill will let you summon max 3 units after that you will get an error message. The problem with my trigger is that will not keep the track when that summoning will die. If i have 2 footman and i summoned with them 6 units the moment one of those 6 units will die i will be able to summon again but the problem is that the footman that used the last time this skill will summon that unit even if we have 3 units already.
  • Test1
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to ....Summon Water Elemental
    • Actions
      • Set AlbatrossCastingUnitLimit = (Casting unit)
      • Set AlbatrossLimitPoint = (Position of (Casting unit))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Level of ....Summon Water Elemental for (Casting unit)) Equal to 1
        • Then - Actions
          • Unit - Create 1 Albatross for (Owner of AlbatrossCastingUnitLimit) at AlbatrossLimitPoint facing 0.00 degrees
          • Set AlbatrossLimitUnits = (Last created unit)
          • Unit - Set level of ....Summon Water Elemental for (Casting unit) to 2
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of ....Summon Water Elemental for (Casting unit)) Equal to 2
            • Then - Actions
              • Unit - Create 1 Albatross for (Owner of AlbatrossCastingUnitLimit) at AlbatrossLimitPoint facing 0.00 degrees
              • Set AlbatrossLimitUnits = (Last created unit)
              • Unit - Set level of ....Summon Water Elemental for (Casting unit) to 3
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Level of ....Summon Water Elemental for (Casting unit)) Equal to 3
                • Then - Actions
                  • Unit - Create 1 Albatross for (Owner of AlbatrossCastingUnitLimit) at AlbatrossLimitPoint facing 0.00 degrees
                  • Set AlbatrossLimitUnits = (Last created unit)
                  • Unit - Set level of ....Summon Water Elemental for (Casting unit) to 4
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Level of ....Summon Water Elemental for (Casting unit)) Equal to 4
                    • Then - Actions
                      • Unit - Order (Triggering unit) to Stop
                      • Custom script: if udg_ErrorSound == null then
                      • Custom script: set udg_ErrorSound = CreateSoundFromLabel( "InterfaceError",false,false,false,10,10)
                      • Custom script: endif
                      • Set ErrorMessage = Can't train more
                      • Set ErrorPlayer = (Owner of (Triggering unit))
                      • Custom script: if GetLocalPlayer() == udg_ErrorPlayer then
                      • Custom script: call ClearTextMessages()
                      • Custom script: call DisplayTimedTextToPlayer( udg_ErrorPlayer, 0.52, 0.96, 2.00, "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n|cffffcc00"+udg_ErrorMessage+"|r" )
                      • Custom script: call StartSound(udg_ErrorSound)
                      • Wait 0.50 seconds
                      • Custom script: call DisplayTimedTextToPlayer( udg_ErrorPlayer, 0.00, 0.00, 2.00, "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n|cffffcc00"+udg_ErrorMessage+"|r" )
                      • Custom script: endif
                    • Else - Actions
  • Test2
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Unit-type of (Dying unit)) Equal to (Unit-type of AlbatrossLimitUnits)
    • Actions
      • Unit - Set level of ....Summon Water Elemental for AlbatrossCastingUnitLimit to ((Level of ....Summon Water Elemental for AlbatrossCastingUnitLimit) - 1)
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,539
Here's the Unit Group Array method Pyro mentioned:
  • Summon Begin Cast
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Summon
    • Actions
      • Set VariableSet SummonUnit = (Triggering unit)
      • Set VariableSet SummonCV = (Custom value of SummonUnit)
      • -------- --------
      • -------- Check if the Summoner's Unit Group exists: --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • SummonHasGroup[SummonCV] Equal to True
        • Then - Actions
          • -------- Cancel the cast if the Summoner's Unit Group is full: --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Number of units in SummonGroup[SummonCV]) Greater than or equal to 3
            • Then - Actions
              • -------- For some reason the Start Cast trigger would still run even after cancelling the ability early. --------
              • -------- Maybe it's just a 1.33 bug - You probably don't need the Pause/Unpause actions on older versions. --------
              • Unit - Pause SummonUnit
              • Unit - Order SummonUnit to Stop.
              • Unit - Unpause SummonUnit
            • Else - Actions
        • Else - Actions
          • -------- If the Unit Group didn't exist, create it: --------
          • Set VariableSet SummonHasGroup[SummonCV] = True
          • Custom script: set udg_SummonGroup[udg_SummonCV] = CreateGroup()
  • Summon Start Cast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Summon
    • Actions
      • Set VariableSet SummonUnit = (Triggering unit)
      • Set VariableSet SummonCV = (Custom value of SummonUnit)
      • Set VariableSet SummonPoint = (Position of SummonUnit)
      • -------- --------
      • -------- Create the Summoned Unit and Add it to the Unit Group: --------
      • Unit - Create 1 Albatross for (Owner of SummonUnit) at SummonPoint facing Default building facing degrees
      • Unit Group - Add (Last created unit) to SummonGroup[SummonCV]
      • -------- --------
      • -------- Link the Summoned Unit to it's Summoner: --------
      • Set VariableSet SummonHost[(Custom value of (Last created unit))] = SummonUnit
      • -------- --------
      • Custom script: call RemoveLocation(udg_SummonPoint)
  • Summon Dies
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Albatross
    • Actions
      • Set VariableSet SummonUnit = (Triggering unit)
      • Set VariableSet SummonCV = (Custom value of SummonUnit)
      • -------- --------
      • -------- Removed the Summoned Unit from it's Summoner's Unit Group: --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (SummonHost[SummonCV] is alive) Equal to True
        • Then - Actions
          • Unit Group - Remove SummonUnit from SummonGroup[(Custom value of SummonHost[SummonCV])].
        • Else - Actions
  • Summoner Dies
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Level of Summon for (Triggering unit)) Greater than 0
    • Actions
      • Set VariableSet SummonUnit = (Triggering unit)
      • Set VariableSet SummonCV = (Custom value of SummonUnit)
      • -------- --------
      • -------- Destroy the Summoner's Unit Group if one even exists: --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • SummonHasGroup[SummonCV] Equal to True
        • Then - Actions
          • Set VariableSet SummonHasGroup[SummonCV] = False
          • Custom script: call DestroyGroup(udg_SummonGroup[udg_SummonCV])
        • Else - Actions
This method requires a Unit Indexer.
The attached map requires the latest version of Warcraft 3.
 

Attachments

  • Summon Limit Example.w3m
    23.7 KB · Views: 6
Thx Uncle for you help but i have a problem i can summon more that 3 units
  • Summon Begin Cast
    • Events
      • Unit - A unit Begins channeling an ability
    • Conditions
      • (Ability being cast) Equal to ....Summon Water Elemental
    • Actions
      • Set AlbatrossSummonTriggerUnit = (Triggering unit)
      • Set AlbatrossSummonValue = (Custom value of AlbatrossSummonTriggerUnit)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • AlbatrossSummonHasGroup[AlbatrossSummonValue] Equal to True
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Number of units in AlbatrossSummonGroup[AlbatrossSummonValue]) Greater than or equal to 3
            • Then - Actions
              • Unit - Pause AlbatrossSummonTriggerUnit
              • Unit - Order AlbatrossSummonTriggerUnit to Stop
              • Unit - Unpause AlbatrossSummonTriggerUnit
              • Custom script: if udg_ErrorSound == null then
              • Custom script: set udg_ErrorSound = CreateSoundFromLabel( "InterfaceError",false,false,false,10,10)
              • Custom script: endif
              • Set ErrorMessage = Can't train more
              • Set ErrorPlayer = (Owner of (Triggering unit))
              • Custom script: if GetLocalPlayer() == udg_ErrorPlayer then
              • Custom script: call ClearTextMessages()
              • Custom script: call DisplayTimedTextToPlayer( udg_ErrorPlayer, 0.52, 0.96, 2.00, "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n|cffffcc00"+udg_ErrorMessage+"|r" )
              • Custom script: call StartSound(udg_ErrorSound)
              • Wait 0.50 seconds
              • Custom script: call DisplayTimedTextToPlayer( udg_ErrorPlayer, 0.00, 0.00, 2.00, "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n|cffffcc00"+udg_ErrorMessage+"|r" )
              • Custom script: endif
            • Else - Actions
        • Else - Actions
          • Set AlbatrossSummonHasGroup[AlbatrossSummonValue] = True
          • Custom script: set udg_AlbatrossSummonGroup[udg_AlbatrossSummonValue] = CreateGroup()
  • Summon Start Cast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to ....Summon Water Elemental
    • Actions
      • Set AlbatrossSummonTriggerUnit = (Triggering unit)
      • Set AlbatrossSummonValue = (Custom value of AlbatrossSummonTriggerUnit)
      • Set AlbatrossSummonPoint = (Position of AlbatrossSummonTriggerUnit)
      • Unit - Create 1 Albatross for (Owner of AlbatrossSummonTriggerUnit) at AlbatrossSummonPoint facing 0.00 degrees
      • Unit Group - Add (Last created unit) to AlbatrossSummonGroup[AlbatrossSummonValue]
      • Set AlbatrossSummonCaster[(Custom value of (Last created unit))] = AlbatrossSummonTriggerUnit
      • Custom script: call RemoveLocation(udg_AlbatrossSummonPoint)
  • Summon Dies
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Albatross
    • Actions
      • Set AlbatrossSummonTriggerUnit = (Triggering unit)
      • Set AlbatrossSummonValue = (Custom value of AlbatrossSummonTriggerUnit)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (AlbatrossSummonCaster[AlbatrossSummonValue] is alive) Equal to True
        • Then - Actions
          • Unit Group - Remove AlbatrossSummonTriggerUnit from AlbatrossSummonGroup[AlbatrossSummonValue]
        • Else - Actions
  • Summoner Dies
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Level of ....Summon Water Elemental for (Triggering unit)) Greater than 0
    • Actions
      • Set AlbatrossSummonTriggerUnit = (Triggering unit)
      • Set AlbatrossSummonValue = (Custom value of AlbatrossSummonTriggerUnit)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • AlbatrossSummonHasGroup[AlbatrossSummonValue] Equal to False
        • Then - Actions
          • Set AlbatrossSummonHasGroup[AlbatrossSummonValue] = False
          • Custom script: call DestroyGroup(udg_AlbatrossSummonGroup[udg_AlbatrossSummonValue])
        • Else - Actions
Update my bad i put the wrong condition..... sry thx Uncle again for your help
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,539
That looks good although you're using the Begins Channeling Event instead of Begins Casting (not sure if it makes a difference but it's the wrong Event).

Also, the Wait in that GetLocalPlayer() block looks sketchy:
  • Wait 0.50 seconds
  • Custom script: call DisplayTimedTextToPlayer( udg_ErrorPlayer, 0.00, 0.00, 2.00, "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n|cffffcc00"+udg_ErrorMessage+"|r" )
What's stopping ErrorPlayer from changing during those 0.50 seconds? Also, why do you need to display two error messages?

I have no idea what happens if you use a Wait locally like that but it may desync.
 
Last edited:
That looks good although you're using the Begins Channeling Event instead of Begins Casting (not sure if it makes a difference).

Also, the Wait in that GetLocalPlayer() block looks sketchy:
  • Wait 0.50 seconds
  • Custom script: call DisplayTimedTextToPlayer( udg_ErrorPlayer, 0.00, 0.00, 2.00, "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n|cffffcc00"+udg_ErrorMessage+"|r" )
What's stopping ErrorPlayer from changing during those 0.50 seconds? Also, why do you need to display two error messages?

I have no idea what happens if you use a Wait locally like that but it may desync.
for some reason if i don't have that wait that error message will not appear
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,539
Try Displaying the text message outside of the GetLocalPlayer() block. It doesn't look like it needs to be in there anyway.

If that doesn't help, it's probably because Custom script: call ClearTextMessages() is deleting the first message for some reason.

  • Set ErrorMessage = Can't train more
  • Set ErrorPlayer = (Owner of AlbatrossSummonTriggerUnit)
  • Custom script: if GetLocalPlayer() == udg_ErrorPlayer then
  • Custom script: call ClearTextMessages()
  • Custom script: call StartSound(udg_ErrorSound)
  • Custom script: endif
  • Custom script: call DisplayTimedTextToPlayer( udg_ErrorPlayer, 0.00, 0.00, 2.00, "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n|cffffcc00"+udg_ErrorMessage+"|r" )
Edit: I just noticed the DisplayTimedText values don't match up. The one that works uses 0.00, 0.00, 2.00 and the other uses 0.52, 0.96, 2.00.
 
Last edited:
Try Displaying the text message outside of the GetLocalPlayer() block. It doesn't look like it needs to be in there anyway.

If that doesn't help, it's probably because Custom script: call ClearTextMessages() is deleting the first message for some reason.

  • Set ErrorMessage = Can't train more
  • Set ErrorPlayer = (Owner of AlbatrossSummonTriggerUnit)
  • Custom script: if GetLocalPlayer() == udg_ErrorPlayer then
  • Custom script: call ClearTextMessages()
  • Custom script: call StartSound(udg_ErrorSound)
  • Custom script: endif
  • Custom script: call DisplayTimedTextToPlayer( udg_ErrorPlayer, 0.00, 0.00, 2.00, "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n|cffffcc00"+udg_ErrorMessage+"|r" )
Edit: I just noticed the DisplayTimedText values don't match up. The one that works uses 0.00, 0.00, 2.00 and the other uses 0.52, 0.96, 2.00.
i still don't get that message, i will let this like this for now thx Uncle for helping me with this system
 
Status
Not open for further replies.
Top