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

Stop attacking

Status
Not open for further replies.
Level 7
Joined
Sep 19, 2012
Messages
204
Aaaand its me again ;)

Now im stuck trying to make my units stop attacking when they have no mana...

I already tried to turn their aquisition range down to 0, but that didnt work...
Also i downloaded, a http://www.hiveworkshop.com/forums/spells-569/autoattack-off-system-gui-v0-13-a-223836/?prev=search%3Dattack%26d%3Dlist%26r%3D20 from hive workshop, but for some reason my map crashes when i put it in... while it works outside my map just fine <.<

Any simple ideas...im not that good in things like that :)
 
Level 7
Joined
Sep 19, 2012
Messages
204
  • Set u = YourUnit
  • Custom script: call UnitAddAbility(udg_u, 'Abun')
--> disable attack for unit u

  • Set u = YourUnit
  • Custom script: call UnitRemoveAbility(udg_u, 'Abun')
--> enable attack for unit u

...i think i do sth wrong because it continues attacking...

I made a variable (the unit one) and set it as the unit my trigger picked before.
then i copied in the script command you posted...

Code:
Deactivate Attack
    Events
        Time - Every 0.01 seconds of game time
    Conditions
    Actions
        Unit Group - Pick every unit in (Units in (Entire map) matching (((Picked unit) is A structure) Equal to True)) and do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        (Mana of (Picked unit)) Less than 10.00
                    Then - Actions
                        Set u = (Picked unit)
                        Custom script:   call UnitAddAbility(udg_u, 'Abun')
                    Else - Actions
 
"Picked unit is a Strucutre == True" is wrong -->

Picked unit --> Matching unit
True --> False (or if you only want to make it for structures this was actually right)

Also oh my goodness, don't make it like this. You create each 0.01 seconds a new unit group.

Making it each 0.1, 0.2 seconds (or more) would also do the job. And you could even have only global unit group variable, and always add/remove the relevant units.
 
Level 7
Joined
Sep 19, 2012
Messages
204
"Picked unit is a Strucutre == True" is wrong -->

Picked unit --> Matching unit
True --> False (or if you only want to make it for structures this was actually right)

Also oh my goodness, don't make it like this. You create each 0.01 seconds a new unit group.

Making it each 0.1, 0.2 seconds (or more) would also do the job. And you could even have only global unit group variable, and always add/remove the relevant units.

Im not that good in triggering ^^
can you explain the global unit group thingy plz?

EDIT: yes it was meant to make my towers stop shooting when out of mana...
 
Level 7
Joined
Sep 19, 2012
Messages
204
Thanks LordDz, for making an example.

@CodeBlack
I didn't look at LordDz code, but I guess he implemented it correctly if it works for him.

Edit:

Maybe you made a little mistake. You can post your code if you want.

thx, but i already deleted my code and copied his XD

as i said this version is a bit buggy because the unit always tries to attack, but gets stopped by the triggers...when somebody can make me a system that is more advanced, so i can copy it i would be very happy :thumbs_up:

@LorDZ: Thx now i can work on my map and replace it later on :)
 
Level 21
Joined
May 29, 2013
Messages
1,567
as i said this version is a bit buggy because the unit always tries to attack, but gets stopped by the triggers...
If you want to completely remove attack for a period of time, you could use a dummy unit to cast an edited version of the Silence ability (it has an option for disabling attacks). When unit has enough mana you could just remove the buff from it.
 
Level 23
Joined
Oct 20, 2012
Messages
3,075
IcemanBo's method works best. It doesn't really need anything other than a single trigger and you'll be able to completely disable a unit's attack without any ugly stuff going on. You were just doing some things wrong in you trigger. ^^

Try this one:
  • Periodic
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Set tempgroup = (Units in (Playable map area) matching (((Matching unit) is A structure) Equal to True))
      • Unit Group - Pick every unit in tempgroup and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Mana of (Picked unit)) Less than 10.00
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Level of Cargo Hold (Orc Burrow) for (Picked unit)) Greater than 0
                • Then - Actions
                • Else - Actions
                  • -------- GetEnumUnit() is (Picked Unit) in GUI --------
                  • Custom script: call UnitAddAbility(GetEnumUnit(), 'Abun')
                  • Game - Display to (All players) the text: Cargo Hold added.
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Level of Cargo Hold (Orc Burrow) for (Picked unit)) Greater than 0
                • Then - Actions
                  • Custom script: call UnitRemoveAbility(GetEnumUnit(), 'Abun')
                  • Game - Display to (All players) the text: Cargo Hold removed.
                • Else - Actions
      • Custom script: call DestroyGroup(udg_tempgroup)
I think the trigger is self explanatory. But If you still get errors or bugs, try the test map attached to this post.

BTw, use a periodic event of 0.03 instead of 0.01 since it doesn't really have any difference but 0.03 is much easier on the game. It just means that the trigger will be ran 33 times per second instead of 100 times with the 0.01.
 

Attachments

  • testmap.w3x
    18.7 KB · Views: 34
Level 7
Joined
Sep 19, 2012
Messages
204
IcemanBo's method works best. It doesn't really need anything other than a single trigger and you'll be able to completely disable a unit's attack without any ugly stuff going on. You were just doing some things wrong in you trigger. ^^

Try this one:
  • Periodic
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Set tempgroup = (Units in (Playable map area) matching (((Matching unit) is A structure) Equal to True))
      • Unit Group - Pick every unit in tempgroup and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Mana of (Picked unit)) Less than 10.00
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Level of Cargo Hold (Orc Burrow) for (Picked unit)) Greater than 0
                • Then - Actions
                • Else - Actions
                  • -------- GetEnumUnit() is (Picked Unit) in GUI --------
                  • Custom script: call UnitAddAbility(GetEnumUnit(), 'Abun')
                  • Game - Display to (All players) the text: Cargo Hold added.
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Level of Cargo Hold (Orc Burrow) for (Picked unit)) Greater than 0
                • Then - Actions
                  • Custom script: call UnitRemoveAbility(GetEnumUnit(), 'Abun')
                  • Game - Display to (All players) the text: Cargo Hold removed.
                • Else - Actions
      • Custom script: call DestroyGroup(udg_tempgroup)
I think the trigger is self explanatory. But If you still get errors or bugs, try the test map attached to this post.

BTw, use a periodic event of 0.03 instead of 0.01 since it doesn't really have any difference but 0.03 is much easier on the game. It just means that the trigger will be ran 33 times per second instead of 100 times with the 0.01.

It´s ALIVE :ogre_hurrhurr:

THANK YOU VERY MUCH ^^
 
Status
Not open for further replies.
Top