• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Trigger] HELP Ítems to open door

Status
Not open for further replies.
Level 4
Joined
Apr 9, 2020
Messages
15
Hello! I am new here. I need help making a Warcraft III The Frozen Throne map.

Idea is the following: 12 players in a labyrinth. They must get 6 keys to open the gate to escape to freedom. The keys generate randomly every time you play so you dont know where are they. That I solved. Works fine.

Now to the point: I want the gate to be opened when there are six keys close to the gate (inside a region of course) regardless if the 6 keys are carried by just one of the players or by, say, six players each with one key.
The point is there must be six items inside the region to open the gate.
Problem is I have no idea how to do that with the triggers. I know I must use variables and integers but I don't know what to do.
IMG_20200408_231303.jpg
There you see three survivors inside the red area. Lets assume between the three players they have the required number of keys. The gate must open. How do I do that?

This is what I tried but it did not work even with one player having the six keys.

IMG_20200409_001414.jpg
Idea is after you enter the zone you use the key and it has to be removed (obviously so you cant use the same key six times)
IMG_20200409_001432.jpg
This is the victory condition. Again, does not work.

IMG_20200409_001459.jpg
These are my variables. What am I doing wrong?

Any Idea how to do it? I will give credits if you help after the map is finished.

Thanks a lot for your time!!!

--MG-Goblin.
 
Level 3
Joined
Apr 7, 2020
Messages
32
You should probably read this:FAQ & Guidelines

There's a section that goes into detail about how to post Triggers in the forum.

The problem is your Trigger titled "Victory Humans" has no Event. So unless you are using another trigger to call and run it, it will do nothing. There's a few ways to go about this. I'll tell you the easiest. (To my best knowledge!)

  • Untitled Trigger 001
    • Events
      • Time - Every 2.00 seconds of game time
    • Conditions
      • KeyAmount Greater than or equal to 6
    • Actions
      • -------- Do thing --------
      • Trigger - Turn off (This trigger)
Obviously the actions would be modified for your event. Every 2 seconds will suffice for this. Turning off the trigger is important since it'll repeat itself otherwise in this case.

Using the Value of Real Variable (and a Real Variable without an array) event would be better. But that'd require a few more steps.
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,875
How To Post Your Trigger

The boolean checking to see if a "Unit has item" just checks if it has ANY amount of that item, 1 or 6 it doesn't matter, it'll return True as long as it's not 0.

Instead, you should loop through the entering unit's Inventory and check to see if each Inventory Slot from 1 to 6 has a Key. Then increase the Key variable by 1 if it does.

I attached a map with an example (I'm using the latest version so you'll have to be up to date to open it). And here are the triggers:
This first trigger is important. Blizzard managed to screw up the size of regions so that they're slightly off, and this fixes that.

And by screwed up I mean that when the Event "A unit enters region" goes off, the entering unit might not be considered "Inside the region". This trigger fixes that issue by correctly adjusting the size of the Regions. In this case I only had 1 Region in the map (Key Region) so that's the only one I fixed. If you wanted to fix all of your map's Regions then you would need to add those Regions to this trigger. Each Region needs to be assigned using the FixRegions[] variable, and FixRegionCount should be equal to the total amount of Regions assigned this way.
  • Fix Regions CONFIGURE
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Custom script: local rect r
      • -------- --------
      • -------- Set this to the number of Regions you want to fix --------
      • Set Variable FixRegionCount = 1
      • -------- --------
      • -------- Assign each Region you want to fix --------
      • Set Variable FixRegions[1] = Key Region <gen>
      • -------- --------
      • -------- Once our variables are setup, loop through all of the FixRegions and adjust them so that they have the correct size --------
      • For each (Integer A) from 1 to FixRegionCount, do (Actions)
        • Loop - Actions
          • Custom script: set r = udg_FixRegions[bj_forLoopAIndex]
          • Custom script: call SetRect(r, GetRectMinX(r) - 32., GetRectMinY(r) - 32., GetRectMaxX(r) + 32., GetRectMaxY(r) + 32.)
          • Custom script: set r = null
  • Enter Key Region
    • Events
      • Unit - A unit enters Key Region <gen>
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 6, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Item-type of (Item carried by (Triggering unit) in slot (Integer A))) Equal to Gate Key
            • Then - Actions
              • Set Variable KeyCount = (KeyCount + 1)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • KeyCount Equal to 6
                • Then - Actions
                  • Trigger - Turn off Enter Key Region <gen>
                  • Trigger - Turn off Leave Key Region <gen>
                  • Destructible - Open Gate (Vertical) 0000 <gen>
                • Else - Actions
            • Else - Actions
  • Leave Key Region
    • Events
      • Unit - A unit leaves Key Region <gen>
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 6, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Item-type of (Item carried by (Triggering unit) in slot (Integer A))) Equal to Gate Key
            • Then - Actions
              • Set Variable KeyCount = (KeyCount - 1)
            • Else - Actions
Here's an example of adding more Regions to the Fix Region trigger. In this example I removed the Events/other Actions that you shouldn't change:
  • Actions
    • -------- Set this to the number of Regions you want to fix --------
    • Set Variable FixRegionCount = 5
    • -------- --------
    • -------- Assign each Region you want to fix --------
    • Set Variable FixRegions[1] = Key Region <gen>
    • Set Variable FixRegions[2] = Some Other Region <gen>
    • Set Variable FixRegions[3] = Some Other Region <gen>
    • Set Variable FixRegions[4] = Some Other Region <gen>
    • Set Variable FixRegions[5] = Some Other Region <gen>

Note that if the Key can be dropped there's potential for problems.

This is because a unit can drop a key inside the Key Region or a unit could trade the key to another unit that's inside of the Key Region, and the Key Count won't increase/decrease since no unit is "Entering" or "Leaving" the Region.

Either make it so the Key cannot be dropped or add triggers to detect when a unit "Acquires/Loses an item" and check if the item is equal to your Key in addition to checking if "Key Region contains triggering unit", this way you can adjust the Key Count accordingly. I could show you how to do the latter if you'd like.
 

Attachments

  • Key Region Example.w3m
    18.1 KB · Views: 17
Last edited:
Status
Not open for further replies.
Top