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

Trigger Questions

Status
Not open for further replies.
Level 3
Joined
Mar 25, 2011
Messages
50
Hello,

Due to my lack of trigger expertise, I've come up with a few problems. If anyone can help guide me in the right direction, it would be appreciated :)

  • Dialog
    • Events
      • Player - Player 1 (Red) Selects a unit
    • Conditions
      • ((Attacked unit) is A town-hall-type unit) Equal to True
    • Actions
      • Dialog - Change the title of Dialog_Window to Choose your Action
      • Dialog - Show Dialog_Window for Player 1 (Red)
Essentially, I want the dialog box to appear when a "Base" is killed. (The event is only selection to make sure it works which it does.) ALSO, it should display the dialog box to whoever kills the base, and not just player 1 red.

If you know a way to make it more universal so that it works for all players, and triggers upon death of a building. Keep the conditions.

  • Function
    • Events
      • Dialog - A dialog button is clicked for Dialog_Window
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Clicked dialog button) Equal to Dialbuttone
        • Then - Actions
          • Unit - Change ownership of TOWNHALL to (Owner of (Triggering unit)) and Change color
        • Else - Actions
          • Unit - Kill TOWNHALL
          • Player - Add (Random integer number between 275 and 425) to (Triggering player) Current gold
The gold system works when I pillage the base, but the capturing doesnt. Any ideas?

  • Melee Initialization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • Trigger - Add to camera distance <gen> the event (Player - (Player((Integer A))) types a chat message containing -view as A substring)
Also look at:

  • camera distance
    • Events
      • Map initialization
    • Conditions
      • (Substring((Entered chat string), 1, 6)) Equal to -view 3000
    • Actions
      • Set Distance = (Real((Substring((Entered chat string), 7, (Length of (Entered chat string))))))
      • Camera - Set (Triggering player)'s camera Distance to target to Distance over 0.00 seconds
Its suppose to let a player who types -view (then the number they want to view at, but it doesnt work.) example of what i'd like it to be. -view 3000 (camera goes back that far.)

  • Spawn Inititation
    • Events
      • Unit - A unit Finishes training a unit
    • Conditions
      • ((Triggering unit) is A ground unit) Equal to True
    • Actions
      • Unit Group - Add (Trained unit) to SpawnGroup
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
        • Then - Actions
        • Else - Actions
I wanted to make a spawn system, where the player trains a unit. Then every 1 minute (there is a timer), the unit will respawn at that base.

Im sorry to appear needy, and I know this is a lot of stuff lol. However, I feel that it's better to do a bulk rather than a small bit by bit. IF you can help me with any of these triggers I'd greatly appreciate it. Thanks!
 

Bannar

Code Reviewer
Level 26
Joined
Mar 19, 2008
Messages
3,140
There are two mistakes: first mentioned above, should be:
  • Conditions
    • ((Triggering unit) is A town-hall-type unit) Equal to True
Second:
  • Then - Actions
    • Unit - Change ownership of TOWNHALL to (Triggering player) and Change color
Triggering player instead of Owner of (triggering unit)
 
Level 3
Joined
Mar 25, 2011
Messages
50
Well I added those changes, and it does work! However, the line:

  • Unit - Change ownership of TOWNHALL to (Owner of (Triggering unit)) and Change color
Doesnt work. Probably because the bulding has to die for the trigger to start. But I cant find a thing that allows me to create a new building at the same place where the other building was destroyed at.

That was probably the biggest trigger in this lol. The view/camera trigger still
baffles me...

Also, thanks gangspear/spinnaker for the help so far!
 
Level 3
Joined
Mar 25, 2011
Messages
50
  • Function
    • Events
      • Dialog - A dialog button is clicked for Dialog_Window
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Clicked dialog button) Equal to Dialbuttone
        • Then - Actions
          • Unit - Change ownership of TOWNHALL to (Triggering player) and Change color
        • Else - Actions
          • Unit - Kill TOWNHALL
          • Player - Add (Random integer number between 275 and 425) to (Triggering player) Current gold
Sorry, I used the old text for some reason >.<
Thats what I have now.
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
"Triggering Player" does work with the event "Dialog - A dialog button is clicked".

I recommend you try debugging the trigger.
Debugging is an art, it is a very important tool of every mapper/coder.
It's so important there's even a tutorial on how to debug triggers.

Where did you set the variable "TOWNHALL"?
Where did you set the variable "Dialogbuttone"?

I cannot find these in your posts, both are required for the trigger to work.

Edit:
  • (Substring((Entered chat string), 1, 6)) Equal to -view 3000
How can this ever work? Substring(1, 6) is "-view " (because the trigger only runs when you type "-view"). It can never be "-view 3000".
Remove the condition.
Also, set limits: min. 700 and max. 3000 should work.


And this works for me:
  • Init Dialog
    • Events
    • Conditions
    • Actions
      • Dialog - Change the title of testDialog to Base Sieged
      • Dialog - Create a dialog button for testDialog labelled Destroy
      • Set testButton1 = (Last created dialog Button)
      • Dialog - Create a dialog button for testDialog labelled Take Control
      • Set testButton2 = (Last created dialog Button)
      • Dialog - Show testDialog for Player 1 (Red)
(called by another trigger).

  • Press Button
    • Events
      • Dialog - A dialog button is clicked for testDialog
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Clicked dialog button) Equal to testButton1
        • Then - Actions
          • Unit - Kill Town Hall 0001 <gen>
          • Player - Add (Random integer number between 100 and 200) to (Triggering player) Current gold
        • Else - Actions
          • Unit - Change ownership of Town Hall 0001 <gen> to (Triggering player) and Change color
 
Level 3
Joined
Mar 25, 2011
Messages
50
Alright, the camera distance trigger now works properly thanks :)

This is what I have in terms of the base pillage/capture trigger.

  • Dialog
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Triggering unit) is A town-hall-type unit) Equal to True
    • Actions
      • Dialog - Change the title of Dialog_Window to Choose your Action
      • Dialog - Show Dialog_Window for Player 1 (Red)
Note that it triggers upon death, and I cant use say it has 1k hitpoints because it isnt uninversal.

  • Function
    • Events
      • Dialog - A dialog button is clicked for Dialog_Window
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Clicked dialog button) Equal to Dialbuttone
        • Then - Actions
          • Unit - Change ownership of TOWNHALL to (Matching player) and Change color
        • Else - Actions
          • Player - Add (Random integer number between 275 and 425) to (Triggering player) Current gold
The problem is that I cant revive the building, change control/color, and have it placed exactly where the previous building stood...

TOWNHALL = a unit variable

I could make a trigger for each invdividual building, but I would need upwards of 40 of them, and i dont know if that would lag my map. Or worth the tedious effort :p

EDIT:

  • Unit - Change ownership of TOWNHALL to (Matching player) and Change color
Ignore that, I know it doesnt work. I need a system that would revive the destroyed building, change color/control, and place it where the previous bulding was destroyed. I just cant get it to do that...

Also I looked at your debug thing, I'm too big of a novice to understand that, but I did read all of it... but undertsood little :C

REEDIT: Spinnaker I didnt really understand your post that much...
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
I know TOWNHALL is a unit variable, I got that. I don't see you set that variable anywhere though (not can I see where you set the dialog button variable).

Why don't you use the event:
  • Unit - Townhall's life becomes Less than {value}
Make the town hall invulnerable after that (to make sure it does not get destroyed) and do your actions.
Then make the town hall vulnerable again.

I said {value} because I don't know the damage values in your map.
 
Last edited:
Level 3
Joined
Mar 25, 2011
Messages
50
Because it wont be universal that way. It would come out as like:

Blacksmith0013<gen> life is 800 etc...

I would like something like

TOWNHALL(Or any general unit because I have a condition to limit it to a townahll) life comes down to 800. Then make it invulnerable.

Change owner/color.

Make it 100% life again.

Make vulnerable.

It wont let me use any variables in there though, so if you know of one I could use then that would fix the problem as well.
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
You could use:
  • Trigger - Add to {Trigger} the event (Unit - {town hall's} life becomes Less than {value})
To add a new event every time a town hall is created (or however they enter the map).

There are also the variable type "event" in JASS to remove those events when the town hall is destroyed, but ehh... I think that the amount of town halls in your map is low enough for this to work properly.
Otherwise you'd have to code a few things in JASS and you'd have to use JNGP to set up new global variables with the type "event").
 
Level 3
Joined
Mar 25, 2011
Messages
50
Well, it didnt work :C

  • Initialization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Trigger - Add to Dialog <gen> the event (Unit - TOWNHALL's life becomes Less than or equal to 800.00)
      • Dialog - Create a dialog button for Dialog_Window labelled Capture the Town
      • Set Dialbuttone = (Last created dialog Button)
      • Dialog - Create a dialog button for Dialog_Window labelled Pillage the Town
      • Set Diabuttontwo = (Last created dialog Button)
Is where I added it, otherwise it would active after the death of the building and be useless.

I did however manage to get it to work if I make it absolutely specific to the building like:

  • Function
    • Events
      • Dialog - A dialog button is clicked for Dialog_Window
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Clicked dialog button) Equal to Dialbuttone
        • Then - Actions
          • Unit - Change ownership of Bandatia 0007 <gen> to Player 1 (Red) and Change color
          • Unit - Make Bandatia 0007 <gen> Vulnerable
          • Unit - Set life of Bandatia 0007 <gen> to 100.00%
        • Else - Actions
          • Player - Add (Random integer number between 275 and 425) to (Triggering player) Current gold
Heck, if I have to I' will just do it this way as long as it wont lag/leak.
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
That's because you misunderstood me.
At map initialization, the variable "TOWNHALL" doesn't have any value (the value is "no unit", aka a null value).

So the event now says "if a null value's HP becomes less than or equal to 800.00".
The event doesn't change along with the variable. If you set TOWNHALL to something, the event will not change.
This is also why I said: "add a new event every time a town hall is created (or however they enter the map)".

You see, I don't know if town halls are preset in your map, or whether the player has to construct them.
But my point is: you have to add 1 event for every town hall.
 
Level 3
Joined
Mar 25, 2011
Messages
50
O lol. Now I understand, and it does work. Just a few questions though.

1. If I have around 40 bases, will this cause any problems? fyi. the bases are preset.

2. When somebody does capture the town, how can I make it their color. So far I can only make it specific for one person. So if blue captures it, it actually goes to red. But I want it to be like when blue captures it, it goes to blue. I hope that made sense... I would just use triggering player, but it apparently doesnt work if you have a dialog butten clicked as a event.

Either way, I gave +rep because you did a lot :p

EDIT: When it allows me again to.
 
Status
Not open for further replies.
Top