So... you think you know it all, right?

UndeadDragon

Super Moderator
Reaction score
447
Hopefully, this will stop a few of the common problems that often occur.

I think that #1 and #3 are the most common "type" of problem. People often have trouble with their conditions. Especially using (Picked Unit) or (Picked Player) when they haven't picked any.
 

Dameon

"All the power in the world resides in the eyes"
Reaction score
127
Problem 1:

This trigger works, it will display the item name.

Code:
Code:
Losing an item
    Events
        Unit - A unit Loses an item
    Conditions
        ((Item being manipulated) is owned) Equal to True
    Actions
        Game - Display to (All players) the text: (Name of (Item being manipulated))

When the unit loses the item it is still owned, when the item is droped it is owned by player 16


Problem 2:

This trigger works as well

Code:
Code:
Unit dies 1
    Events
        Unit - A unit Dies
    Conditions
    Actions
        Trigger - Run Unit dies 2 <gen> (ignoring conditions)Code:

Code:
Unit dies 2
    Events
    Conditions
    Actions
        Game - Display to (All players) the text: (Name of (Dying unit))

In a case like this the other trigger is the event, so the triggering unit for the first trigger will follow thru

Problem 3:

This one works

Code:
Code:
Triggering Caster
    Events
        Unit - A unit Spawns a summoned unit
    Conditions
        (Triggering unit) Not equal to (Summoning unit)
    Actions
        Game - Display to (All players) the text: This can't happen, ...
        Game - Display to (All players) the text: (T:  + (Name of (Triggering unit)))
        Game - Display to (All players) the text: (C:  + (Name of (Summoning unit)))

In A case like this the summoned unit is what is triggering the trigger.

Problem 4:

This Trigger Works

Code:
Code:
Count 1
    Events
        Map initialization
    Conditions
    Actions
        Set UnitCount = 0
        Unit - Create 1 Furbolg for Neutral Hostile at (Center of (Playable map area)) facing Default building facing degrees
        Unit - Create 2 Furbolg for Neutral Hostile at (Center of (Playable map area)) facing Default building facing degrees
        Unit - Create 3 Furbolg for Neutral Hostile at (Center of (Playable map area)) facing Default building facing degreesCode:

Code:
Count 2
    Events
        Unit - A unit enters (Playable map area)
    Conditions
    Actions
        Set UnitCount = (UnitCount + 1)

Code:
Code:
Count 3
    Events
        Time - Elapsed game time is 1.00 seconds
    Conditions
    Actions
        Game - Display to (All players) the text: (Units created:  + (String(UnitCount)))
MI starts right as the map starts, but a trigger can be ran .001 secs after that.

Side Note

I would have done the last 2 as well, but I got bored :)

Side Note 2

Ps Guys AceHeart already knew how each trigger would run, he posted this to test your skill level and instead of actualy looking at the triggers you just read what he said and agree with it. Just cause it seems obvious dosen't mean it is. Try to look deeper next time.
 

Prometheus

Everything is mutable; nothing is sacred
Reaction score
590
Problem 3:

Code:
Triggering Caster
    Events
        Unit - A unit Spawns a summoned unit
    Conditions
        (Triggering unit) Not equal to (Summoning unit)
    Actions
        Game - Display to (All players) the text: This can't happen, ...
        Game - Display to (All players) the text: (T:  + (Name of (Triggering unit)))
        Game - Display to (All players) the text: (C:  + (Name of (Summoning unit)))

Triggering Unit = The Unit that spawned the summoned unit.


Problem 4:

Code:
Count 1
    Events
        Map initialization
    Conditions
    Actions
        Set UnitCount = 0
        Unit - Create 1 Furbolg for Neutral Hostile at (Center of (Playable map area)) facing Default building facing degrees
        Unit - Create 2 Furbolg for Neutral Hostile at (Center of (Playable map area)) facing Default building facing degrees
        Unit - Create 3 Furbolg for Neutral Hostile at (Center of (Playable map area)) facing Default building facing degrees

Code:
Count 2
    Events
        Unit - A unit enters (Playable map area)
    Conditions
    Actions
        Set UnitCount = (UnitCount + 1)

Code:
Count 3
    Events
        Time - Elapsed game time is 1.00 seconds
    Conditions
    Actions
        Game - Display to (All players) the text: (Units created:  + (String(UnitCount)))

I tested, it works just fine. The event registers any unit creation at any time, I believe it loads before map init.

Problem 5:

Code:
Integer A
    Events
        Time - Elapsed game time is 2.00 seconds
    Conditions
    Actions
        For each (Integer A) from 10 to 1, do (Actions)
            Loop - Actions
                Game - Display to (All players) the text: (Current value of "Integer A":  + (String((Integer A))))
                Custom script:   set bj_forLoopAIndex = bj_forLoopAIndex - 2

Not sure what you're trying to do here.
A loop using locals would be easier, would it not?

I'm not sure how number 6 is a problem.
 

Dameon

"All the power in the world resides in the eyes"
Reaction score
127
Problem 3:

Code:
Triggering Caster
    Events
        Unit - A unit Spawns a summoned unit
    Conditions
        (Triggering unit) Not equal to (Summoning unit)
    Actions
        Game - Display to (All players) the text: This can't happen, ...
        Game - Display to (All players) the text: (T:  + (Name of (Triggering unit)))
        Game - Display to (All players) the text: (C:  + (Name of (Summoning unit)))

Triggering Unit = The Unit that spawned the summoned unit.

Wrong, the summoned unit is the triggering unit, not the summoning unit, this is obvious sence when you do display the name of the triggering unit is shows the summoned units name.
 

Jeeyo

New Member
Reaction score
3
"Originally Posted by Genyuumaru":

he's also a human.he's not perfect and you also won't learn how to edit maps if you're not going to ask questions.now tell me,did you ask anything on your mom when you were just a boy?of course yes.did she asked anything from you as a reward.no. that's why we are asking to get informations not to be insulted.and we are answering questions to help others not because we want something for exchange.
 

saw792

Is known to say things. That is all.
Reaction score
280
Get over Genyu's post guys.

Anyway, this is a great thread that really made me think. I initially skimmed over it agreeing with the explanations Ace gave for every trigger. Until I looked again. Thanks for letting me learn something today :)
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,495
> Triggering Unit = The Unit that spawned the summoned unit.

Which agrees with the given description.
Given most descriptions are slightly off... are you sure?


> In a case like this the "summoned unit" is what is triggering the trigger.

So, you didn't try this either...
However, at least it does not agree with the given description.


Well :p
 

Dameon

"All the power in the world resides in the eyes"
Reaction score
127
> Triggering Unit = The Unit that spawned the summoned unit.

Which agrees with the given description.
Given most descriptions are slightly off... are you sure?


> In a case like this the "summoned unit" is what is triggering the trigger.

So, you didn't try this either...
However, at least it does not agree with the given description.


Well :p

I did try it, and it is the summoned unit that triggers it, if you dont belive me then change the trigger condition to triggering unit not equal to summoned unit. If you do this the trigger will stop working.

Edit you curently have it set to the summoning unit.
 

rover2341

Is riding a roller coaster...Wee!
Reaction score
113
Well, I am pretty sure your right. but on the 2ed one. i have a game that the triggers never run unless another trigger calls it. It seems like it should go...
Lol i am most likey not seeing something simple or just dont get it.

Edit: I looked at it again.
Trigger - Run Unit dies 2 <gen> (ignoring conditions)

Werid. I guess it wont run if no conditions. If thats ture. Then i could see that happing. It shouldnt but i could see it not triggering.
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,495
Problem 1:

Code:
Losing an item
    Events
        Unit - A unit Loses an item
    Conditions
        ((Item being manipulated) is owned) Equal to True
    Actions
        Game - Display to (All players) the text: (Name of (Item being manipulated))

This trigger actually will show that text...

Why is it doing that? The item is lost after all.
Well, it so happens that that event fires while the item is still in your inventory!
You are about to lose it, but it just has not happened yet...


Why I posted this?

People do all kinds of "strange" things to and with items.
For example, they want to see if the Hero still has an item of the very same type as he just now lost.
So they come with "loses an item" and "Hero - Hero has item of type",
only to find out the actions still run even though they are very sure the Hero only ever had one item to begin with when they tested it.

Event:
- A unit loses an item
Conditions:
- Item type of (Item being manipulated) equal to <whatever>
Actions:
- Wait 0.0 seconds
- If (((Triggering unit) has an item of type <whatever>) equal to true) then ...

Works correctly.
Yes, 0 seconds is long enough.
No, "Triggering" unit has no problems here...


Problem 2:

Code:
Unit dies 1
    Events
        Unit - A unit Dies
    Conditions
    Actions
        Trigger - Run Unit dies 2 <gen> (ignoring conditions)

Code:
Unit dies 2
    Events
    Conditions
    Actions
        Game - Display to (All players) the text: (Name of (Dying unit))

"Trigger - Run" calls the given trigger's "action" function.
Which is just the same as calling any other function.
Set myUnitVariable = (Triggering unit)
That's already a function call, it calls the function that gives you the unit.
This trigger works just fine.


Why I posted this?

This is actually a classic.
It's asked rather often, and the replies don't always agree...
Well, those triggers work. Correctly. As expected.


Problem 3:

Code:
Triggering Caster
    Events
        Unit - A unit Spawns a summoned unit
    Conditions
        (Triggering unit) Not equal to (Summoning unit)
    Actions
        Game - Display to (All players) the text: This can't happen, ...
        Game - Display to (All players) the text: (T:  + (Name of (Triggering unit)))
        Game - Display to (All players) the text: (C:  + (Name of (Summoning unit)))

So, you summon a unit with some ability.
We get, therefore, a "summoning unit".
It's also a unit event, which gives us a "triggering unit".

And yet, it is possible for the condition to be true.
There are spells where the casting unit just isn't the triggering unit...

Though the abilities that happens with are rare and difficult to find.

Give yourself a Hero, the item "Wand of Illusions", and some other unit, like a Footman for example.
Have the Hero cast "item illusion" on the Footman.
Result:
- Triggering unit: the Hero
- Summoning unit: the Footman!

You also get a "summoned unit", which is the created illusion.


Why I posted this?

For the heck of it :p
Just to see that, sometimes, things are just "different".

More seriously though, there's a lot of recommendations that come with:
"Use (Triggering unit) instead of (<more specific> unit) and all of your problems are solved".
Turns out the problem may actually only start... rarely, but it's not impossible.

On a related note, once you start on JASS, you'll pretty much forget anything other than "GetTriggerUnit()".
Just something to keep in mind...


Problem 4:

Code:
Count 1
    Events
        Map initialization
    Conditions
    Actions
        Set UnitCount = 0
        Unit - Create 1 Furbolg for Neutral Hostile at (Center of (Playable map area)) facing Default building facing degrees
        Unit - Create 2 Furbolg for Neutral Hostile at (Center of (Playable map area)) facing Default building facing degrees
        Unit - Create 3 Furbolg for Neutral Hostile at (Center of (Playable map area)) facing Default building facing degrees

Code:
Count 2
    Events
        Unit - A unit enters (Playable map area)
    Conditions
    Actions
        Set UnitCount = (UnitCount + 1)

Code:
Count 3
    Events
        Time - Elapsed game time is 1.00 seconds
    Conditions
    Actions
        Game - Display to (All players) the text: (Units created:  + (String(UnitCount)))

Yes, map init is the first event of interest to happen in a map.
However, that event happens *after* the triggers have registered their events.
I.e. this will work just fine and say "Units created: 3".


Why I posted this?

Because every now and then, people for example create some units at map init, while having some trigger that counts units as they enter some region.
And... they end up with "really weird" numbers... "I'm sure no unit was created... Impossible 2 seconds into the game...".
Note: triggers can be turned off.


Problem 5:

Code:
Integer A
    Events
        Time - Elapsed game time is 2.00 seconds
    Conditions
    Actions
        For each (Integer A) from 10 to 1, do (Actions)
            Loop - Actions
                Game - Display to (All players) the text: (Current value of "Integer A":  + (String((Integer A))))
                Custom script:   set bj_forLoopAIndex = bj_forLoopAIndex - 2

Looping "for" loops backwards is an all-time classic.
Every now and then, people try to get creative.

But, as usual, while JASS is mysterious and ancient and strong, it isn't magical.

This will, indeed, produce two lines of JASS code (menu: Edit / Convert to custom script):
set bj_forLoopAIndex = bj_forLoopAIndex - 2
set bj_forLoopAIndex = bj_forLoopAIndex + 1
I.e. "Integer A" will be one less than before.

Unfortunately, the ending condition is tested at the very beginning of the loop,
and, additionally, is limited to "less than or equal".

Nice as this may seem, it's not working. Sorry.


Why I posted this?

- To confuse the Russians
- For fun
- To show that even JASS isn't magical

Yes, every now and then, we get some post along "I'm sure JASS can do it"...
Yes, JASS can do a lot of things. But not all of them.


Problem 6:

Code:
Alliance 1
    Events
        Time - Elapsed game time is 2.00 seconds
    Conditions
    Actions
        Player Group - Make (All players) treat (All players) as an Enemy with shared vision

Code:
Alliance 2
    Events
        Time - Elapsed game time is 1.00 seconds
    Conditions
    Actions
        Game - Display to (All players) the text: All players:
        Player Group - Pick every player in (All players) and do (Actions)
            Loop - Actions
                Game - Display to (All players) the text: (Name of (Picked player))

Two things here:
- yes, you will be enemy to Neutral Passive after trigger 1
- trigger 2 will only show players 1 to 12 that are playing

So, yes, "all players" does not include any Neutrals.
And yet, we end up enemies...

What happened here?
Well, that's a bug in "SetForceAllianceStateBJ", the function that is called when you use that player group action.

As seen in Blizzard.j:
JASS:
function SetForceAllianceStateBJ takes force sourceForce, force targetForce, integer allianceState returns nothing
    local integer sourceIndex
    local integer targetIndex

    set sourceIndex = 0
    loop

        if (sourceForce==bj_FORCE_ALL_PLAYERS or IsPlayerInForce(Player(sourceIndex), sourceForce)) then
            set targetIndex = 0
            loop
                if (targetForce==bj_FORCE_ALL_PLAYERS or IsPlayerInForce(Player(targetIndex), targetForce)) then
                    call SetPlayerAllianceStateBJ(Player(sourceIndex), Player(targetIndex), allianceState)
                endif

                set targetIndex = targetIndex + 1
                exitwhen targetIndex == bj_MAX_PLAYER_SLOTS
            endloop
        endif

        set sourceIndex = sourceIndex + 1
        exitwhen sourceIndex == bj_MAX_PLAYER_SLOTS
    endloop
endfunction


There's two loops here, that check all players, 0 to 15 (i.e. the usual 1 to 12 and all 4 Neutrals),
and, if they are in the given player group, will set the alliance as wanted.
However, for some strange reason, when you pass it "all players", it's not checking the groups anymore.
Instead it just assumes that any player is in "all players" anyway...
Which is, obviously, just plain wrong.

Why is it doing that?
I can only guess there...

- "all players" only has players 1 to 12 that are playing
- don't use that player group action to set your alliances
- someone at Blizzard wasn't reading the documentation...


Why I posted this?

Because it actually happens, and no one knows why.
Now you know.


Works as designed.


If nothing else, this may also pass as a general foruming lesson:
Sometimes, the problem description ("It doesn't work"), the perceived solution ("It's obvious") and the trigger posted have little in common.


Happy mapping.


Yours,
AceHart
 

Prometheus

Everything is mutable; nothing is sacred
Reaction score
590
>"I.e. this will work just fine and say "Units created: 3"."

6. :D
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Monovertex Monovertex:
    How are you all? :D
    +1
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top