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

Dungeon Help (Triggers)

Status
Not open for further replies.
Level 11
Joined
Aug 11, 2009
Messages
594
So I am stuck on how to make it work to enter a Dungeon in my map. There will be several dungeons in the map and to enter them a player will write "-enter" while standing on the Circle of Power outside the specific dungeon.

So how it should work is like this:
- Player writes "-enter" and then he and 3 other nearby allies are moved instantly into the dungeon. There can be a maxiumum of 8 players in the map but I want to limit the dungeons to only 4 players. So it should randomly pick three nearby allies to the one who writes "-enter".
- Players who enters a dungeon should be in a Unit Group so when all player Heroes has died or leaved the dungeon it should instantly resets.
- Triggers should work with 10+ dungeons, so it checks which Circle of Power the player stands on.

Would be very grateful if anyone could help me with this and ofcourse +rep aswell.

Thanks in advance
 
Level 11
Joined
Nov 15, 2007
Messages
781
  • Dungeon
    • Events
      • Player - Player 1 (Red) types a chat message containing -enter as An exact match
      • Player - Player 2 (Blue) types a chat message containing -enter as An exact match
      • Player - Player 3 (Teal) types a chat message containing -enter as An exact match
      • Player - Player 4 (Purple) types a chat message containing -enter as An exact match
      • Player - Player 5 (Yellow) types a chat message containing -enter as An exact match
      • Player - Player 6 (Orange) types a chat message containing -enter as An exact match
      • Player - Player 7 (Green) types a chat message containing -enter as An exact match
      • Player - Player 8 (Pink) types a chat message containing -enter as An exact match
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 10, do (Actions)
        • Loop - Actions
          • Set point = (Position of hero[(Player number of (Triggering player))])
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (entrance[(Integer A)] contains point) Equal to True
            • Then - Actions
              • Custom script: call DestroyGroup(udg_group[GetForLoopIndexA()])
              • Set group[(Integer A)] = (Random 3 units from (Units in entrance[(Integer A)] matching ((((Matching unit) is A Hero) Equal to True) and ((((Matching unit) is an illusion) Equal to False) and ((Matching unit) Not equal to hero[(Player number of (Triggering player))])))))
              • Unit Group - Add hero[(Player number of (Triggering player))] to group[(Integer A)]
              • Custom script: call RemoveLocation(udg_point)
              • Set point = (Center of dungeon[(Integer A)])
              • Unit Group - Pick every unit in group[(Integer A)] and do (Unit - Move (Picked unit) instantly to point)
              • Custom script: call RemoveLocation(udg_point)
            • Else - Actions
              • Game - Display to (Player group((Triggering player))) the text: |cffffcc00No entrance in range!|r
I believe this will get the result you're looking for.

Variables:

"hero" is a unit variable for the player character of each individual player. This should be defined when the player's character is selected, either purchased from a tavern or whatever other system you're using for your map.

"group" is the unit group variable for the characters in the dungeon. The group is cleared before the characters are moved so that it won't overwrite itself and leak if they do the dungeon more than once.

"entrance" is a region variable you'll need to place in the editor and then assign to a variable. I believe you can assign pre-placed regions at map initialization (Using the General - Set Variable action)

"dungeon" is another region variable. It's the point you want your characters to start in the dungeon. Again, place a region at the appropriate point in the editor, and then assign this as a variable at initialization.

"point" is just a location variable used so that it can be removed immediately. If you don't remove things like locations, unit groups, etc. you'll get memory leaks.

"Hero" is an array so it can correspond to a player number, "dungeon," "entrance" and "group" are arrays so that they can correspond to eachother.

Edit: Oops, the
  • Else - Actions
    • Game - Display to (Player group((Triggering player))) the text: |cffffcc00No entrance in range!|r
will actually display the message 9-10 times every time you type -enter the way I have it set up :p

Edit2: You also need a
  • Custom script: call RemoveLocation(udg_point)
under Else - Actions.
 
Last edited:
Level 11
Joined
Aug 11, 2009
Messages
594
Thanks alot for the help, gonna try it out :) but does this check so only 4 heroes enter the dungeon even if 8 are in range?

Edit: Sorry didnt see the 3 random player check at first :p I tried it and it worked very well in single player and it looks in the code as it works in multiplayer aswell :) thanks alot for your help :D
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
GetForLoopIndexA() -> bj_forLoopAIndex
Leaks a player group -> http://www.hiveworkshop.com/forums/triggers-scripts-269/things-leak-35124/
Don't use call RemoveLocation in both THEN and ELSE, put it after the I/T/E
Filter out dead units in the unit group pick.
The trigger shouldn't loop ten times setting the position of the hero of triggering unit. Only do it once. Pick heroes around the point and if x units are already in the group, skip remaining actions.

@meticulous, use [hidden=Trigger][/trigger] tags.
 
Level 11
Joined
Nov 15, 2007
Messages
781
GetForLoopIndexA() -> bj_forLoopAIndex
Leaks a player group -> http://www.hiveworkshop.com/forums/triggers-scripts-269/things-leak-35124/
Don't use call RemoveLocation in both THEN and ELSE, put it after the I/T/E
Filter out dead units in the unit group pick.
The trigger shouldn't loop ten times setting the position of the hero of triggering unit. Only do it once. Pick heroes around the point and if x units are already in the group, skip remaining actions.

@meticulous, use [hidden=Trigger][/trigger] tags.

It uses the location twice and removes it twice (as it first sets the point to check if it's in the entrance region, and then sets a point to move to the dungeon). I suppose it could use two temporary points instead, is there much of a difference?

Filtering out dead units seemed unnecessary, as I assume heroes would be moved and respawned on death.

Thanks, I overlooked that bit about the loop. Thanks for the tag reminder as well.
 
Status
Not open for further replies.
Top