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

Help with destroying all farms please?

Status
Not open for further replies.
Level 2
Joined
May 31, 2012
Messages
16
Hey guys, Ive literally been trying for HOURS just to try and figure this out, Ive tried asking on other sites but no one would help.

Anyway, I have been making a practice map for myself and I got stuck on this one trigger I cant seem to figure out... And im sure its pretty easy to make.

I want a trigger that would destroy every building thats been built in the game if someone types a chat message... Heres what I have and it doesnt work (Ive tried more methods but I lost them due to so many attempts)

I KNOW this can be done since so many maps have it.

  • Destroy
    • Events
      • Player - Player 1 (Red) types a chat message containing d as An exact match
    • Conditions
    • Actions
      • Set Farm = Grid Farm light
      • Set Farm = Grid Farm heavy
      • Set Farm = Hard Farm
      • Set Farm = Invisible Farm
      • Set Farm = Pick Farm
      • Set Farm = Tiny Farm
      • Set Farm = Upgraded Farm
      • Set Farm = Wide Farm
      • Unit - Remove (Random unit from (Units of type Farm)) from the game
 
Level 19
Joined
Feb 25, 2009
Messages
2,004
What you do is replacing the variable each time and only the last one will be destroyed.

You need to save each type of farm to a array variable and then loop through all numbers and destroy those.

Other way to do is, detect when a player builds any of the farms and put it into a global group, then when a player types the message, pick all buildings that belong to him and destroy them.
 
Level 2
Joined
May 31, 2012
Messages
16
Can you provide an example? Sorry this is one of my first maps I am making, and I dont understand what you mean nor do I know what an array is used for or how to loop them at this moment.

From what I do understand however, I have tried the action on only one type of farm on one of my methods, so I believe what you are suggesting fixes this problem. I think the problem has to do something with my last trigger, I do not think it is made correctly in a way the game can understand it. Can you or anyone confirm?
 
Level 2
Joined
May 21, 2012
Messages
31
When you are making the variable check the box that says "array". This means you can use the same variable to store more things. In your case, set it to 8.
 
Level 2
Joined
May 31, 2012
Messages
16
Ive been tweaking around World Editor and is this what you mean? Please reply to me


  • Destroy
    • Events
      • Player - Player 1 (Red) types a chat message containing d as An exact match
    • Conditions
    • Actions
      • Set Farm[0] = Grid Farm light
      • Set Farm[1] = Grid Farm heavy
      • Set Farm[2] = Hard Farm
      • Set Farm[3] = Invisible Farm
      • Set Farm[4] = Pick Farm
      • Set Farm[5] = Tiny Farm
      • Set Farm[6] = Upgraded Farm
      • Set Farm[7] = Wide Farm
      • For each (Integer A) from 1 to 7, do (Actions)
        • Loop - Actions
          • Unit - Remove (Random unit from (Units of type Farm[(Integer A)])) from the game
Ill be testing to see if this works. Ill repost in a few minutes
 
Level 2
Joined
May 21, 2012
Messages
31
EDIT: defskull beat me to it. his is probably better anyway


Heres a simpler way to do it.

  • DestroyFarm
    • Events
      • Player - Player 1 (Red) types a chat message containing destroyfarm as An exact match
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Entered chat string) Equal to destroyfarm
        • Then - Actions
          • Unit Group - Pick every unit in (Units owned by Player 2 (Blue) of type Farm) and do (Unit - Kill (Picked unit))
        • Else - Actions
and attached is an example of this.
 

Attachments

  • destroyfarm.w3x
    16.7 KB · Views: 53
Level 2
Joined
May 31, 2012
Messages
16
Does not work... even any random farm from the last trigger.

My goal here is to Destroy every building whenever someone types "D"

Hope this clears it up

Thank you for your test map guys, I appreciate it, Ill be back in a few minutes to look it up.
 
Level 2
Joined
May 21, 2012
Messages
31
  • destroy
    • Events
      • Player - Player 1 (Red) types a chat message containing d as An exact match
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Entered chat string) Equal to d
            • Then - Actions
              • If (((Picked unit) is A structure) Equal to True) then do (Unit - Kill (Picked unit)) else do (Do nothing)
            • Else - Actions
destroy all _BUILDINGS_ in map when user types "d"

is this what you are looking for?
 
Level 2
Joined
May 31, 2012
Messages
16
This one worked! thanks mihaiul!
Thanks Mortar and Defskull :) I still learned very useful stuff from your attempts to help me :)

By the way, I was pretty sure the first two test maps would work, it didnt.

If you guys can explain why the past GUI triggers didnt work (Including mine) and why the last suggestion did? Id appreciate it for my learning in future editing/mapmaking. If not, thats okay at least its fixed.

Ill be trying to create a "Cancel Farm" ability on my unit on if used the last created farm if used tomorrow, ill see if Ill need help since I have tried it before this issue but gave up too early.

By the way, should I be learning JASS or would learning GUI first help me on my way to JASS, and will JASS help me on my way to earning computer programming?

  • destroy
    • Events
      • Player - Player 1 (Red) types a chat message containing d as An exact match
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Entered chat string) Equal to d
            • Then - Actions
              • If (((Picked unit) is A structure) Equal to True) then do (Unit - Kill (Picked unit)) else do (Do nothing)
            • Else - Actions
destroy all _BUILDINGS_ in map when user types "d"

is this what you are looking for?
 
Level 2
Joined
May 21, 2012
Messages
31
Definetly learn GUI!! Its very simple, it took me 1 day to get the basics of it, and you seem to get the basic of it too. Start with simple stuff. For example, try make a trigger that displays a message to all players when a footman is dead, then create a new footman. Its very important to get the basics.

Your first trigger didnt work because of a few things.

1) Unit - Remove (Random unit from (Units of type Farm)) from the game
- Removing a random unit from units of type farm wouldn't have done anything.

2) Variables. You defined the variable, but didn't actually use them. For example: Footman = Soldier. Kill all soldiers. In yours, you defined the soldier, but didn't specify to destroy it.

3) You were on the right track with the 2nd one, but it still didn't work because of the way you specified to destroy them.

Mine works because I create a unit group, then check if they all are BUILDINGS, then check the chat message, then if both are correct, destroy them!
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
The test map of mine, didn't work ?

Tell me, what part of didn't work you are getting ?

You are pre-setting Unit-Type variable for each Farm your map has and destroy every possible Unit-Type that you have set in the Setup Trigger

It works as it should have, lol ?

You did not say to destroy all your units, you said to destroy every Farm, provided that you set the Unit-Type in the Setup Trigger

Next time, please be more specified and detailed and be more clear on what you are trying to achieve.
 
Level 2
Joined
May 31, 2012
Messages
16
The test map of mine, didn't work ?

Tell me, what part of didn't work you are getting ?

You are pre-setting Unit-Type variable for each Farm your map has and destroy every possible Unit-Type that you have set in the Setup Trigger

It works as it should have, lol ?

You did not say to destroy all your units, you said to destroy every Farm, provided that you set the Unit-Type in the Setup Trigger

Next time, please be more specified and detailed and be more clear on what you are trying to achieve.

Yes it wasnt working for some reason when I typed d to destroy the farms.
By what you said, it sounds like you misunderstood me and what was this trigger intended for?

I think this trigger shouldve worked for the same purpose as it shouldve on destroy all farms, to remove/kill all the structures in the game (all the variables I had were structures that could be built)

I made an attachment for you to see if the fault was from I copied your trigger or how the trigger was made.

I'd like to know too why it wasnt working

Heres how I put it in my map:
  • Farm Destroy
    • Events
      • Player - Player 1 (Red) types a chat message containing d as An exact match
    • Conditions
    • Actions
      • For each (Integer A) from 0 to 7, do (Actions)
        • Loop - Actions
          • Custom script: set bj_wantDestroyGroup = true
          • Unit Group - Pick every unit in (Units in (Entire map)) and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Unit-type of (Picked unit)) Equal to Farm[(Integer A)]
                • Then - Actions
                  • Unit - Kill (Picked unit)
                • Else - Actions
I put my Initializations/Variables on one trigger:

  • Initialization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set Farm[0] = Grid Farm light
      • Set Farm[1] = Grid Farm heavy
      • Set Farm[2] = Hard Farm
      • Set Farm[3] = Invisible Farm
      • Set Farm[4] = Pick Farm
      • Set Farm[5] = Tiny Farm
      • Set Farm[6] = Upgraded Farm
      • Set Farm[7] = Wide Farm
      • Visibility - Disable black mask
      • Visibility - Disable fog of war
      • Selection - Select Sheep 0012 <gen> for Player 1 (Red)
      • Camera - Set Player 1 (Red)'s camera Distance to target to 2400.00 over 0.00 seconds
 

Attachments

  • Map.w3x
    66.3 KB · Views: 45
Last edited:
Level 33
Joined
Mar 27, 2008
Messages
8,035
You're setting up the wrong units in the Setup Trigger.

The sheep builds only 5 of the setup buildings while the reset is not setup at all.

You setup Grid Farm Heavy/Light whereas the Sheep does not build that kind of buildings at all.

Also, you disabled the trigger + Initially off it, well, I have edited it, take a look at yourself

And, please enable back your Sheep Chase trigger as I have disabled it for easier constructing all the structures without being attacked, that's annoying
 

Attachments

  • Map.w3x
    66.2 KB · Views: 45
Last edited:
Level 2
Joined
May 31, 2012
Messages
16
I guess that was failure on my part, although I did try build every structure before trying the destroy command and it didnt destroy any of the farms I built, which was weird. But its fixed and thanks for helping me. This is the first map I made from scratch trigger-wise
 
Status
Not open for further replies.
Top