• 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] Text Based Commands & Monster Spawns

Status
Not open for further replies.

GrapesOfWath

Sound Reviewer
Level 16
Joined
Mar 31, 2012
Messages
256
Ok, so, I decided that I'd make a map with just heroes fighting each other and random monster spawns. Well, I've had a few problems with the triggers. One, I made it so that when a unit enters a region (a large circle of power), 5 murloc tiderunners spawn in the middle of another region (an area enclosed by boundaries, rock chunks, and an iron gate). Well, it works just fine. But, there's one problem with it. See, the spawn area and the circle aren't too far from each other, so the tiderunners can step on the circle too. But, I don't want it to work with monsters stepping on it too, because then pretty much all of the map is full of murloc tiderunners stepping on the switch and then spawning all over everywhere.

Another problem is this. I want to make a few text based commands, such as red being able to disable the fog of war by saying -no fog. Well, I made the trigger, and tested it. I typed it in while testing, and nothing happened. I also was thinking about making 16 custom heroes for the deathmatch, and making them selectable by saying -a through -t, and then making a trigger to disable all of the selection triggers after the heroes have been selected for each player. But, I don't know how to do either of these. So, here's the map and some screenshots of the triggers, since I don't know how to put the trigger code thingy in the post.
 

Attachments

  • No Fog.jpg
    No Fog.jpg
    65.8 KB · Views: 184
  • Tiderunner Spawn.jpg
    Tiderunner Spawn.jpg
    68.3 KB · Views: 152
  • Custom Hero Deathmatch.w3x
    50.1 KB · Views: 44
Last edited:
Level 5
Joined
Jun 16, 2004
Messages
108
Probably want something like this to stop murlocs from causing the spawn:
  • Murloc Tiderunner
    • Events
      • Unit - A unit enters Region 003 <gen>
    • Conditions
      • (Unit-type of (Triggering unit)) Not equal to Murloc Tiderunner
    • Actions
      • Unit - Create 5 Murloc Tiderunner for Neutral Hostile at (Center of Region 004 <gen>) facing Default building facing degrees
You can also instead check that the owner of the unit is a player
  • ((Owner of (Triggering unit)) controller) Equal to User
(under player controller comparison)
or that it is a hero type
  • ((Triggering unit) is A Hero) Equal to True
(under boolean comparison)
or that it is not owned by a computer
  • ((Owner of (Triggering unit)) controller) Not equal to Computer
(also under player controller comparison)
And so on

You probably wanted this for the visibility trigger:
  • Commands
    • Events
      • Player - Player 1 (Red) types a chat message containing -no fog as An exact match
    • Conditions
    • Actions
      • Visibility - Disable fog of war
      • Visibility - Disable black mask
Keep in mind that there are two forms of visibility blocking. One is for areas you have not explored yet (black mask - it is darker in those areas and you cannot see the terrain), and the other is fog of war which comes up if you do not have sight active in already explored areas. Removing fog of war means that once you explore an area, it will be visible forever. However, it will have no noticeable effect immediately. So disable black mask too.

As for a selection trigger, you can make one that stops a player from picking twice pretty easily:
  • Untitled Trigger 004
    • Events
      • Player - Player 1 (Red) types a chat message containing -a as An exact match
    • Conditions
      • heropicked[(Player number of (Triggering player))] Equal to False
    • Actions
      • Unit - Create 1 Footman for (Triggering player) at (Center of (Playable map area)) facing Default building facing degrees
      • Set heropicked[(Player number of (Triggering player))] = True
heropicked being a boolean array of size 12, initial value set to false.
 
Level 5
Joined
Jun 16, 2004
Messages
108
Sure thing, though I do not know how much experience you have with programming and so on.

First of all it uses a boolean array variable. Booleans hold one of two potential values, true and false, and are typically used in situations where the case demands a "yes" or "no" response, like whether a player can select a hero or not, whether the game has started or not, and whether a unit has a buff/ability or not.

  • ((Triggering unit) is A Hero) Equal to True
The above is an example of doing a boolean comparison, either the triggering unit is a hero or is not a hero in this case, and we are checking that it is a hero since we are using true.

A simple way of viewing a variable is that it allows us to store a value for later. In this case, wanting to store whether a player can select a hero or not so that we can stop him from selecting more than one hero.

And finally, an array typically refers to one or more values of some type found in uninterrupted sequence. Since arrays usually have more than one value, a method of accessing each value is necessary, and this often manifests itself in the form of square brackets "[" and "]". The number inside square brackets can be referred to as the array index, meaning which value of the array you are accessing. Arrays are more easily used when the index is directly related to what you are trying to store in some way.

So, a variable array means a variable with one or more values associated with it. A boolean variable array means a boolean variable with one or more true/false values associated with it.

In the case of selecting one hero per player, the case can be thought of asking "Has this player not selected a hero yet?", which would be a boolean value (true for yes, false for no). We want to store this value, so a variable is useful. And we want to store more than one of this value for the 12 possible players, so an array is useful. Also remember that arrays I said arrays are easier to use when the index is relatable to the stored data in some way. Since I wanted to store data for a player, and the player number is easily accessed, the player number can be used to create the array index I want easily.

So now the trigger again:
  • Untitled Trigger 004
    • Events
      • Player - Player 1 (Red) types a chat message containing -a as An exact match
    • Conditions
      • heropicked[(Player number of (Triggering player))] Equal to False
    • Actions
      • Unit - Create 1 Footman for (Triggering player) at (Center of (Playable map area)) facing Default building facing degrees
      • Set heropicked[(Player number of (Triggering player))] = True
  • Conditions
    • heropicked[(Player number of (Triggering player))] Equal to False
In this case, "heropicked" is the name of the boolean array I used. As you can see, it uses "(Player number of (Triggering player))" as the array index. It is checking that the array value stored for this player is equal to false ("Has this player not selected a hero yet?"). If this check passes, the trigger continues down to the actions. If it fails, the trigger stops execution and does not create the unit.

To create the boolean array you first go into the trigger editor, then click the orange X button,
Ey4R

then click the green "+X" button that is in the new window,
Ey4Y

then fill in your desired variable traits.
Ey53


To use the condition, you will want to add a new condition and look under "boolean comparison" since we are doing a boolean check. The final condition of course looks like this:
Ey9L


And after creating the hero you want to set the variable so that the player cannot choose again, which is done here:
  • Set heropicked[(Player number of (Triggering player))] = True
EybH

Found under "Set Variable".

So the logic becomes pretty easy. "Has this player not selected a hero yet?" If not, create the hero, then set the boolean array value for this player to true. The next time that question is asked, the answer will be "yes" of course, and the trigger will not create another unit for that player.
 
Status
Not open for further replies.
Top