• 🏆 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] Trigger Review (Long Post)

Status
Not open for further replies.
Level 4
Joined
Dec 31, 2014
Messages
68
Hi all, long post Warning so sorry about that. Basically I have reached another impasse with my level in terms of memory leakage and I'd like to post a few of my triggers here for you all to take a look at. I'll try to be as descriptive as I can, I'll also include how many of each trigger type I have and If some of you can suggest fixes, or know how to merge a few of them down please let me know.

I have read up on Memory leaking thoroughly on various posts so please don't just direct me to one of them

My Level is a Single/Multiplayer RPG map and a typical playthrough is around 8-10 hours, at around the 7:30h mark (without assigning more Virtual Memory) the game usually crashes.
In the task manager, when first booting up the level the memory reads 430,000k and at the 7:30h mark it reaches approx 930,000k (Gradually rising 500,000k for that period). Ideally I want to keep the memory nearer the starting mark, but if not and I get another 5 hours or so safe playtime before it crashes that would be acceptable.

When suggesting things, even though I have experience in triggers can you please include examples. At a rough count I have 724 Triggers and 73 Variables.
I think for this thread I'll limit the triggers to 15, may make a new thread for other triggers also.

------------------------
Ok here goes..

1.Enemies which come alive if you go too close to them (5 Triggers)
  • Events
    • Unit - A unit enters AliveEnemy1<gen>
  • Conditions
    • ((Triggering unit) is A Hero) Equal to True
  • Actions
    • Sound - Play It'sAlive<gen>
    • Unit - Replace Sleeper 557 <gen> with a Awakened using The new unit's default life and mana
    • Unit - Cause (Last replaced unit) to damage (Triggering unit), dealing 200.00 damage of attack type Normal and damage type Magic
    • Custom script: call DestroyTrigger( GetTriggeringTrigger() )
2.Shake Camera for all players if stood in a specific Region - (17 Triggers)
  • Events
    • Unit - A unit enters ShakeCamera1 <gen>
  • Conditions
    • ((Triggering unit) is A Hero) Equal to True
  • Actions
    • Sound - Play Rumble<gen>
    • Trigger - Turn off (This trigger)
    • Game - Display to Team1 for 10.00 seconds the text: Shake!
    • Camera - Shake the camera for Player 1 (Red) with magnitude 8.00
    • Camera - Shake the camera for Player 2 (Blue) with magnitude 8.00
    • Camera - Shake the camera for Player 3 (Teal) with magnitude 8.00
    • Wait 1.00 seconds
    • Camera - Stop swaying/shaking the camera for Player 1 (Red)
    • Camera - Stop swaying/shaking the camera for Player 2 (Blue)
    • Camera - Stop swaying/shaking the camera for Player 3 (Teal)
    • Custom script: call DestroyTrigger(GetTriggeringTrigger())
3.Merchant Dialog which displays to the triggering player, then turns off its own trigger, waits 10 seconds then turns itself back on (30 Triggers)
  • Events
    • Unit - A unit enters NPCDialog1 <gen>
  • Conditions
    • ((Entering unit) is A Hero) Equal to True
  • Actions
    • Trigger - Turn off (This trigger)
    • Cinematic - Turn subtitle display override On
    • Player Group - Remove all players from TempplayerGroup
    • Player Group - Add (Owner of (Triggering unit)) to TempplayerGroup
    • Cinematic - Send transmission to TempplayerGroup from Merchant (NPC) 0450 <gen> named Merchant: Play No sound and display Hello! Modify duration: Add 5.00 seconds and Wait
    • Player Group - Remove all players from TempplayerGroup
    • Wait 10.00 seconds
    • Trigger - Turn on (This trigger)
4.Teleportation between areas/Rooms - (..There are 100's of these triggers)
  • Events
    • Unit - A unit enters Tele1<gen>
  • Conditions
  • Actions
    • Set Point = (Center of X <gen>)
    • Unit - Move (Triggering unit) instantly to Point
    • Custom script: call RemoveLocation(udg_Point)
5.A message is broadcast to the owner of the triggering unit when stepping on a specific region (21 Triggers)
  • Events
    • Unit - A unit enters FirstMessage <gen>
  • Conditions
    • ((Entering unit) is A Hero) Equal to True
  • Actions
    • Player Group - Remove all players from TempplayerGroup
    • Player Group - Add (Owner of (Triggering unit)) to TempplayerGroup
    • Game - Display to TempplayerGroup for 5.00 seconds the text: Welcome...
    • Player Group - Remove all players from TempplayerGroup
6.All Players receive some Lumber when any unit except those owned by Player 12 goes into a specific region (16 Triggers)
  • Events
    • Unit - A unit enters Lumber1 Trigger <gen>
  • Conditions
    • (((Triggering unit) is A Hero) Equal to True) and ((Owner of (Triggering unit)) Not equal to Player 12 (Brown))
  • Actions
    • Sound - Play Lumber<gen>
    • Player - Add 300 to Player 1 (Red) Current lumber
    • Player - Add 300 to Player 2 (Blue) Current lumber
    • Player - Add 300 to Player 3 (Teal) Current lumber
    • Game - Display to Team1 for 10.00 seconds the text: Lumber!
    • Trigger - Turn off (This trigger)
    • Custom script: call DestroyTrigger(GetTriggeringTrigger())
7.When A Hero auto-revives the game locks the camera for the player who owns the unit to that Unit (3 Triggers)
  • Events
    • Unit - A unit owned by Player 1 (Red) Finishes reviving
  • Conditions
    • (Owner of (Triggering unit)) Equal to Player 1 (Red)
  • Actions
    • Camera - Lock camera target for Player 1 (Red) to (Reviving Hero), offset by (0.00, 0.00) using Default rotation
    • Game - Display to (All players matching ((Owner of (Triggering unit)) Not equal to Player 1 (Red))) the text: Player 1 has been r...
    • Sound - Play Revived<gen>
    • Camera - Set (Triggering player)'s camera Distance to target to 1500.00 over 0.00 seconds
8.Checkpoint Based Revival, When a player controlled unit enters a region it Turns on 1 respawn trigger to but turns off all the other respawn triggers for that player (51 Triggers/17 per player)
  • Events
    • Unit - A unit enters Respawnatstartifdie <gen>
  • Conditions
    • (((Triggering unit) is A Hero) Equal to True) and ((Owner of (Triggering unit)) Equal to Player 1 (Red))
  • Actions
    • Trigger - Turn on p1 Respawn at Area1 <gen>
    • -------- Turnoff --------
    • Trigger - Turn off p1 Respawn at Area2 <gen>
    • Trigger - Turn off p1 Respawn at Area3 <gen>
    • Trigger - Turn off p1 Respawn at Area4 <gen>
    • Trigger - Turn off p1 Respawn at Area5 <gen>
    • Trigger - Turn off p1 Respawn at Area6 <gen>
    • Trigger - Turn off p1 Respawn at Area7 <gen>
    • Trigger - Turn off p1 Respawn at Area8 <gen>
    • Trigger - Turn off p1 Respawn at Area9 <gen>
    • Trigger - Turn off p1 Respawn at Area10 <gen>
    • Trigger - Turn off p1 Respawn at Area11 <gen>
    • Trigger - Turn off p1 Respawn at Area12 <gen>
    • Trigger - Turn off p1 Respawn at Area13 <gen>
    • Trigger - Turn off p1 Respawn at Area14 <gen>
    • Trigger - Turn off p1 Respawn at Area15 <gen>
    • Trigger - Turn off p1 Respawn at Area16 <gen>
9.Linked to the Above; the 'Respawn at Area1' (51 Triggers/17 per player)
  • Events
    • Unit - A unit owned by Player 1 (Red) Dies
  • Conditions
    • ((Triggering unit) is A Hero) Equal to True
  • Actions
    • Wait 10.00 seconds
    • Set RevivalPoint = (Center of Area1 <gen>)
    • Hero - Instantly revive (Dying unit) at RevivalPoint, Hide revival graphics
    • Custom script: call RemoveLocation(udg_RevivalPoint)
-----------------------------------------------------------------------

10. A Unit enters a region (which isn't owned by player 12) takes damage - I have already condensed this down to 1 Trigger for the Entire level, Here is a short sample..
  • Events
    • Time - Every 0.30 seconds of game time
  • Conditions
  • Actions
    • -------- ------------------PoisonArea1------------------- --------
    • -------- Poison1 --------
    • Set PoisonGround = (Units in Poison1 <gen>)
    • Unit Group - Pick every unit in PoisonGround and do (Actions)
      • Loop - Actions
        • Set Temp_Pickedunit = (Picked unit)
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (Owner of Temp_Pickedunit) Not equal to Player 12 (Brown)
          • Then - Actions
            • Unit - Cause (Picked unit) to damage Temp_Pickedunit, dealing 50.00 damage of attack type Pierce and damage type Normal
          • Else - Actions
            • -------- Do Nothing --------
    • Custom script: call DestroyGroup (udg_PoisonGround)
    • -------- Poison2 --------
    • Set PoisonGround = (Units in Poison2 <gen>)
    • Unit Group - Pick every unit in PoisonGround and do (Actions)
      • Loop - Actions
        • Set Temp_Pickedunit = (Picked unit)
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (Owner of Temp_Pickedunit) Not equal to Player 12 (Brown)
          • Then - Actions
            • Unit - Cause (Picked unit) to damage Temp_Pickedunit, dealing 50.00 damage of attack type Pierce and damage type Normal
          • Else - Actions
            • -------- Do Nothing --------
    • Custom script: call DestroyGroup (udg_PoisonGround)
& 100's more in this trigger

11.Fake AI triggers (8 Triggers)
A trigger turns these on when a unit enters certain regions, they are Off at Map initialisation.
  • Events
    • Time - Every 40.00 seconds of game time
  • Conditions
  • Actions
    • Unit - Boss1 <gen> to Night Elf Priestess Of The Moon - Starfall
12.A Player Enters the Game (3 Triggers)
  • Events
    • Unit - A unit enters (Playable map area)
  • Conditions
    • (Owner of (Entering unit)) Equal to Player 1 (Red)
  • Actions
    • Game - Display to Player Group - Player 1 (Red) the text: View the Quest's Me...
    • Quest - Flash the quest dialog button
    • Game - Display to Player Group - Player 1 (Red) the text: Add your first hero...
    • Custom script: call DestroyTrigger(GetTriggeringTrigger())
13. A Player leaves the game (1 Trigger)
  • Events
    • Player - Player 1 (Red) leaves the game
    • Player - Player 2 (Blue) leaves the game
    • Player - Player 3 (Teal) leaves the game
  • Conditions
  • Actions
    • Game - Display to Team1 the text: A player has left t...
14. In-Game Manual (1 Trigger)
  • Manual
    • Events
      • Time - Elapsed game time is 0.20 seconds
    • Conditions
    • Actions
      • Player - Change color of Player 1 (Red) to Gray, Changing color of existing units
      • Player - Change color of Player 2 (Blue) to Orange, Changing color of existing units
      • Player - Change color of Player 3 (Teal) to Green, Changing color of existing units
      • Quest - Create a Optional quest titled Movement & Abilitie... with the description Movement Standard ..., using icon path war3mapImported\HeroAttritubes.tga
      • Quest - Create a Optional quest titled NPC's & Enemies with the description Non Player Characte..., using icon path ReplaceableTextures\CommandButtons\BTNHeroMountainKing.blp
      • Quest - Create a Optional quest titled Attributes/Stats with the description Intelligence - Addi..., using icon path ReplaceableTextures\CommandButtons\BTN_Levelup.tga
      • Quest - Create a Optional quest titled Weapons with the description Weapons can be foun..., using icon path ReplaceableTextures\CommandButtons\BTN_Axe.tga
      • Quest - Create a Optional quest titled Armor and Shields with the description Both raise your def..., using icon path ReplaceableTextures\CommandButtons\BTN_knightshield.tga
      • Quest - Create a Optional quest titled Magic with the description There are 3 types o..., using icon path ReplaceableTextures\CommandButtons\BTN_SoulArrow.tga
      • Trigger - Turn off (This trigger)
      • Custom script: call DestroyTrigger( gg_trg_Manual )
15. Make a sound when a specific enemy dies (1 Large Trigger)
  • Events
    • Unit - A unit Dies
  • Conditions
  • Actions
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • (Unit-type of (Dying unit)) Equal to Enemy1
      • Then - Actions
        • Player - Add 100 to Player 1 (Red) Current gold
        • Player - Add 100 to Player 2 (Blue) Current gold
        • Player - Add 100 to Player 3 (Teal) Current gold
        • Game - Display to Team1 the text: You Win 100 Gold
        • Wait 0.50 seconds
        • Sound - Play Gold <gen>
      • Else - Actions
        • -------- Do Nothing --------
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • (Unit-type of (Dying unit)) Equal to Enemy2
      • Then - Actions
        • Player - Add 200 to Player 1 (Red) Current gold
        • Player - Add 200 to Player 2 (Blue) Current gold
        • Player - Add 200 to Player 3 (Teal) Current gold
        • Game - Display to Team1 the text: You Win 200 Gold
        • Wait 0.50 seconds
        • Sound - Play Gold <gen>
      • Else - Actions
        • -------- Do Nothing --------
Thanks for taking the time to read, if you have any suggesting please let me know, with the appropriate Trigger Number so I know what you're on about.
 
Level 28
Joined
Feb 18, 2014
Messages
3,580
Well that's a huge triggers you have here, I'm not I can suggest all, but I give some try
Trigger 1 and 2 : When you make a unit enter ''region X'', you can't make in condition ''Triggering unit'' but ''Entering unit equal...''
More post will come later

Edit : Trigger 9 ---> Event '' a unit owned by player red dies
Condition : Dying unit equal to hero

Trigger 15 , you can merge EnemyI & EnemyII inside one trigger condition like ''Any condition equal to true''
 
Level 19
Joined
Jul 14, 2011
Messages
875
Using Triggering unit over Dying, Entering and etc is generally recommended as not all of them are local and may become invalid after a wait (mainly Casting unit).
As far as I know Triggering unit is also faster. Both of these wont make a big difference, I think.
Also, use Triggering player instead of Owner of Triggering unit. Its the same thing.
Maybe setting bj_wantDestroyGroup to true befoer the group loop might be a tiny bit faster than destroying it manually but, again, probably wont make a difference.

I'd say that the rise in memory usage is completely normal (in terms of Wc3, atleast). I mean, even a completely empty map's memory usage slowly rises.
There are also some (mostly small) leaks that are unavoidable and nothing can really be done about them.

I think your biggest problem is trigger 10, where you have hundrets of group loops on a relatively fast timer.
 
Level 4
Joined
Dec 31, 2014
Messages
68
Thanks for all your responses, I appreciate how long it must have taken to read through all them triggers.
Hmm conflicting answers between Warseeker and Gismo.. I hadn't actually heard that Triggering unit was any faster but I do recall seeing some posts where people have said to just use Triggering Unit over anything else.

I think I'll take this opportunity to say that my Level doesn't actually Lag or slow down, it just all of a sudden crashes when it reaches a certain number in the Task Manager.

So err.. I think I may stick with Triggering Unit instead of dying etc, it sounds like it might be.. better? (I'm not really too sure) but on the other hand if it doesn't make much of a difference.. then.. doesn't matter..?

Warseeker you mentioned in Trigger 15 about merging the enemies etc, how would you go about doing that? Do you mean a system with IF/THEN/ELSE where the next enemy will be inside another if/then/else in the Else slot?
I.E
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
    • Then - Actions
    • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
        • Then - Actions
        • Else - Actions
Like this? (I've done this before on other triggers in my map [not listed here])

Gismo, bj_wantDestroyGroup.. hm well if you say it probably wont make a difference I maybe won't do it. Yeah I appreciate the memory building up over time - it's a bit of a pain, its just that my level is so big and knowing that eventually it will crash isn't a pleasant thought.
With Trigger 10, yeah what you said I think would help a lot (why didn't I think of it before heh) I'll change it to every 1 second I think just to be sure, thanks!

Hey Empirean (again :D) Use Hidden Tags? also sorry I'm not sure I understood what you meant in trigger 12, to use that IF/THEN/ELSE trick?
 
trigger 8 and 9 change proposal:

  • init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set Reg[1] = Region 000 <gen>
      • Set Reg[2] = Region 001 <gen>
      • Set Reg[3] = Region 002 <gen>
      • Set Reg[4] = Region 003 <gen>
      • Set RevieveLoc[1] = (Center of Reg[1])
      • Set RevieveLoc[2] = (Center of Reg[1])
      • Set RevieveLoc[3] = (Center of Reg[1])
  • enters01
    • Events
      • Unit - A unit enters Region 000 <gen>
    • Conditions
      • ((Entering unit) is A Hero) Equal to True
    • Actions
      • Set TempInt = 1
      • Set PlayerNr = (Player number of (Owner of (Entering unit)))
      • Game - Display to (All players) for 1.00 seconds the text: (entering player + (String(PlayerNr)))
      • Custom script: call RemoveLocation(udg_RevieveLoc[udg_PlayerNr])
      • Set RevieveLoc[PlayerNr] = (Center of Reg[TempInt])
      • Game - Display to (All players) the text: (setting loc for player + ((String(PlayerNr)) + ( to: + (String(TempInt)))))
  • enters02
    • Events
      • Unit - A unit enters Region 001 <gen>
    • Conditions
      • ((Entering unit) is A Hero) Equal to True
    • Actions
      • Set TempInt = 2
      • Set PlayerNr = (Player number of (Owner of (Entering unit)))
      • Game - Display to (All players) for 1.00 seconds the text: (entering player + (String(PlayerNr)))
      • Custom script: call RemoveLocation(udg_RevieveLoc[udg_PlayerNr])
      • Set RevieveLoc[PlayerNr] = (Center of Reg[TempInt])
      • Game - Display to (All players) the text: (setting loc for player + ((String(PlayerNr)) + ( to: + (String(TempInt)))))
similar for all your regions..

  • heroDies
    • Events
      • Unit - A unit owned by Player 1 (Red) Dies
      • Unit - A unit owned by Player 2 (Blue) Dies
      • Unit - A unit owned by Player 3 (Teal) Dies
    • Conditions
      • ((Dying unit) is A Hero) Equal to True
    • Actions
      • Wait 10.00 seconds
      • Set PlayerNr = (Player number of (Triggering player))
      • Hero - Instantly revive (Dying unit) at RevieveLoc[PlayerNr], Hide revival graphics
zibi
 
Level 28
Joined
Feb 18, 2014
Messages
3,580
Warseeker you mentioned in Trigger 15 about merging the enemies etc, how would you go about doing that? Do you mean a system with IF/THEN/ELSE where the next enemy will be inside another if/then/else in the Else slot?

Not just If/Then/Else condition, I meant the condition boutton (Above action boutton), the condition should be like this '' Any condition equal to true, then use ''Owner of dying unit equal to Enemy 1 / Owner of dying equal to Enemy 2 , now you can use action to add ressources to one player instead of using two]
 
Level 4
Joined
Dec 31, 2014
Messages
68
Sorry for the late reply,
Zibi, I gave your proposal a try and It works (haven't fully tested but so far Player 1 works great, need to try it in Multiplayer though which is a bit difficult as I don't have 2 PC's and unfortunately i'm running Windows 7 64 bit so I can't multiload Warcraft :/) it's certainly a lot less trigger intensive, should help a lot thanks.
I maybe won't do it for the teleporting triggers (Trigger 4) as there are too many of them and to define all the regions will take ages.

Warseeker, oh right I see what you mean - I haven't gave this a go yet but I will do soon. Thanks
 
Level 19
Joined
Jul 14, 2011
Messages
875
I suggest you take a look at this example instead of creating a trigger for each region you use.

Edit: Realised that the link in his post is outdated. Here is an example + map
The example simply prints the index of the entered region in the array

E:Look [self=http://www.hiveworkshop.com/forums/triggers-scripts-269/trigger-review-long-post-274235/#post2774908]here[/self] instead.


  • OnInit
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- No need for a global variable here; must be on top --------
      • Custom script: local region r
      • -------- Create hashtable --------
      • Hashtable - Create a hashtable
      • Set RectHash = (Last created hashtable)
      • -------- Need to use te trigger in GUI because Blizzard --------
      • Set Trig = OnEnter <gen>
      • -------- Enter your regions --------
      • -------- I assume the first 12 will be for the hero revive points -------- E: Or, how many players you use
      • Set Regions[1] = Region 000 <gen>
      • Set Regions[2] = Region 001 <gen>
      • Set Regions[3] = Region 002 <gen>
      • Set Regions[4] = Region 003 <gen>
      • Set Regions[5] = Region 004 <gen>
      • Set Regions[6] = Region 005 <gen>
      • Set Regions[7] = Region 006 <gen>
      • Set MaxRegions = 7
      • For each (Integer i) from 1 to MaxRegions, do (Actions)
        • Loop - Actions
          • -------- Set the revive point --------
          • Set RevivePoint[i] = (Center of Regions[i])
          • -------- These are because GUI is kind of limited in regards of regions --------
          • -------- (Regions in GUI are not actually regions in JASS) --------
          • -------- Basically creates a region, adds the GUI rect to it and creates an event for the other trigger --------
          • Custom script: set r = CreateRegion()
          • Custom script: call RegionAddRect(r, udg_Regions[udg_i])
          • Custom script: call TriggerRegisterEnterRegion(udg_Trig, r, null)
          • Custom script: call SaveInteger(udg_RectHash , GetHandleId(r), 0, udg_i )
      • Custom script: set r = null
  • OnEnter
    • Events
    • Conditions
      • ((Triggering unit) is A Hero) Equal to True
    • Actions
      • Set i = (Player number of (Triggering player))
      • Custom script: set udg_j = LoadInteger(udg_RectHash , GetHandleId(GetTriggeringRegion()) , 0)
      • -------- 'i' is the number of the triggering player --------
      • -------- and 'j' is the index of the entered region in the Regions array --------
      • Game - Display to (All players) the text: (String(j))
  • OnDeath
    • Events
      • Unit - A unit owned by Player 1 (Red) Dies
      • Unit - A unit owned by Player 2 (Blue) Dies
      • Unit - A unit owned by Player 3 (Teal) Dies
    • Conditions
      • ((Triggering unit) is A Hero) Equal to True
    • Actions
      • Hero - Instantly revive (Triggering unit) at RevivePoint[(Player number of (Triggering player))], Show revival graphics
      • -------- No use in removing the revive location since you will be reusing it --------
 
Last edited:
Level 4
Joined
Dec 31, 2014
Messages
68
Wow, thank you for going to the trouble of creating an example map for me Zibi.
That's great, ah I see you've included you proposed revival system also for reference.

Since I had so many of these regions, rather than going in 1 by 1 editing the custom script 100's of times; I converted the trigger to custom text, then using an online tool to add incremental numbers as suffixes etc to make up my poisonous region names, I pasted it into the trigger. I left the other triggers as standard GUI and it works great.

This should help the memory for sure!

(If anyone reads this and wants to know the website I used for the incremental numbers it's http://textmechanic.com/Generate-List-of-Numbers.html Also to see how the custom text triggers are made up, make a standard GUI trigger then Edit, convert to custom text and adjust the names accordingly)


Also thank you for the link Gismo, I'll keep that in mind.
 
Level 4
Joined
Dec 31, 2014
Messages
68
(god sake... 3rd time retyping this message as post Quick Reply didn't work)

Hi Gismo, sorry I didn't see that you had edited your post when I replied.
I gave what you suggested a go - also thank you for the example map, and I managed to get it to work but currently it only re spawns me at the first region that was set which I don't understand. Also that (String(j)) doesn't seem to work, it just displays (String(j)) in-game. Ill give it another go tomorrow but while we are on the subject of String, is there a way that I can make the game displays the Name of the Region when you enter it?
Originally I had/wanted it as separate triggers so that I could type 'X checkpoint' so that when the players respawn they can see the name of the place they have respawned, can I do this with your trigger proposal somehow? String(j) when it works I think only shows the number of the region and not the name of it?

Thanks, if I managed to get this fixed it'll rid me of a few more triggers which is good!
 
Level 19
Joined
Jul 14, 2011
Messages
875
It displays just 'String(j)'?
It worked when I made it. I'll check when I get home but I cant see any problems in the triggers.
I think the map got corrupted during upload or something because it seems too small in filesize.
Try saving it, maybe I didnt save it properly.

As for the names, you can save them in an array the same way you saved the regions and use the index to get the name.
 
Level 4
Joined
Dec 31, 2014
Messages
68
Hey err, well It all seemed to work on your example map but when I made it for mine it keeps displaying String(j)). Yeah I don't know why there's been issues, iv likely misstyped a section of custom code or something - I'll give it another go later on.

Edit: Also on a side note, is there a way I can see which variables are not being used in my map? I have quite a few and may have some from old triggers that have been replaced. Or can you only try pressing Delete on variables to see if it references a trigger?
 
Level 19
Joined
Jul 14, 2011
Messages
875
I think you typed 'String(j)' as a string. Its actually 'Conversion - Integer to String' (or something like that). You should probably copy the whole triggers though, and then change what you need.

As for the variables, not to my knowledge. The closest thing I can think of pressing delete to see if they are being used, like you said. Note that that works only for variables used in triggers, custom scipt doesnt count.
Also, I think that JassHelper's optimizations remove unused variables in the end code (if you use JNGP).
 
Level 4
Joined
Dec 31, 2014
Messages
68
ah.. that would make sense with String haha, I thought it might reference it with the double Brackets. Hmm how would you copy triggers from 1 map to the other? the only way iv seen is to export and import but it tells you that it will replace all the triggers in your map if you do so (This is all from memory, might be wrong), is there some other way?
 
Level 19
Joined
Jul 14, 2011
Messages
875
You can open multiple maps and switch between them from the 'Window' menu. Just copy the trigger you want and switch to the other map. You can do that for Object Editor data, whole trigger categories, terrain, units, cameras (pasting them is awkward - you can edit a camera to go out of bounds but you cant paste it on it), regions etc. Pretty much everything except imports and AI, I think.
 
Level 4
Joined
Dec 31, 2014
Messages
68
Ok I sorted out the String thing, it was what you said was wrong.
Would you be able to show me how to do that 'region name' setup? Iv had a go but I don't quite understand what sorts of variables I need to make.

Also I re-downloaded your example map, and saved it in case it was corruption. I walk into say region 7 and spawned some enemies to kill my unit, when he dies he re spawns at Region 1 so unfortunately it isn't working my end :/

Edit: Damn I'm having forum issues these days, I just seen your reply about pasting - thanks.
 
Level 19
Joined
Jul 14, 2011
Messages
875
Just make a String array and put each region's name in it so that they have the same index in the arrays. For example here, the for the region with index 5 in the Region array, you can find its name in the same index(5) of the string array. Same goes for the others

  • Set RegionNames[1] = First region's name
  • Set RegionNames[2] = Second region's name
  • Set RegionNames[3] = Third region's name
  • Set RegionNames[4] = Fourth region's name
  • Set RegionNames[5] = Fifth region's name
  • ...
  • Set Regions[1] = First region
  • Set Regions[2] = Second region
  • Set Regions[3] = Third region
  • Set Regions[4] = Fourth region
  • Set Regions[5] = Fifth region
  • ...
Ah, I guess I have misunderstood how you wanted the revival to work. Gonna fix it in a bit.

E: Okay, fixed. The hero revives at the last region he has entered. When he enters the name of the region is displayed.

There were a couple of bugs in the last post. Mainly that the enter event doesnt have a triggering player but only a triggering.


  • OnInit
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- No need for a global variable here; must be on top --------
      • Custom script: local region r
      • -------- Create hashtable --------
      • Hashtable - Create a hashtable
      • Set RectHash = (Last created hashtable)
      • -------- Need to use te trigger in GUI because Blizzard --------
      • Set Trig = OnEnter <gen>
      • -------- Region names --------
      • Set RegionNames[1] = First
      • Set RegionNames[2] = Second
      • Set RegionNames[3] = Third
      • Set RegionNames[4] = Fourth
      • Set RegionNames[5] = Fifth
      • Set RegionNames[6] = Sixth
      • Set RegionNames[7] = Seventh
      • Set RegionNames[8] = Eighth
      • -------- Enter your regions --------
      • -------- I assume the first 12 will be for the hero revive points --------
      • Set Regions[1] = Region 000 <gen>
      • Set Regions[2] = Region 001 <gen>
      • Set Regions[3] = Region 002 <gen>
      • Set Regions[4] = Region 003 <gen>
      • Set Regions[5] = Region 004 <gen>
      • Set Regions[6] = Region 005 <gen>
      • Set Regions[7] = Region 006 <gen>
      • Set Regions[8] = Region 007 <gen>
      • Set MaxRegions = 8
      • For each (Integer i) from 1 to MaxRegions, do (Actions)
        • Loop - Actions
          • -------- Save the centers of the regions --------
          • Set RegionCenter[i] = (Center of Regions[i])
          • -------- These are because GUI is kind of limited in regards of regions --------
          • -------- (Regions in GUI are not actually regions in JASS) --------
          • -------- Basically creates a region, adds the GUI rect to it and creates an event for the other trigger --------
          • Custom script: set r = CreateRegion()
          • Custom script: call RegionAddRect(r, udg_Regions[udg_i])
          • Custom script: call TriggerRegisterEnterRegion(udg_Trig, r, null)
          • Custom script: call SaveInteger(udg_RectHash , GetHandleId(r), 0, udg_i )
      • -------- They revive at the first one by default --------
      • Set RevivePoint[1] = RevivePoint[1]
      • Set RevivePoint[2] = RevivePoint[1]
      • Set RevivePoint[3] = RevivePoint[1]
      • Custom script: set r = null
  • OnEnter
    • Events
    • Conditions
      • ((Triggering unit) is A Hero) Equal to True
      • Or - Any (Conditions) are true
        • Conditions
          • (Owner of (Triggering unit)) Equal to Player 1 (Red)
          • (Owner of (Triggering unit)) Equal to Player 2 (Blue)
          • (Owner of (Triggering unit)) Equal to Player 3 (Teal)
    • Actions
      • Set i = (Player number of (Owner of (Triggering unit)))
      • Custom script: set udg_j = LoadInteger(udg_RectHash , GetHandleId(GetTriggeringRegion()) , 0)
      • -------- 'i' is the number of the triggering player --------
      • -------- and 'j' is the index of the entered region in the Regions array --------
      • Game - Display to (All players) the text: (You have entered the + (RegionNames[j] + region.))
      • Set RevivePoint[i] = RegionCenter[j]
  • OnDeath
    • Events
      • Unit - A unit owned by Player 1 (Red) Dies
      • Unit - A unit owned by Player 2 (Blue) Dies
      • Unit - A unit owned by Player 3 (Teal) Dies
    • Conditions
      • ((Triggering unit) is A Hero) Equal to True
    • Actions
      • Hero - Instantly revive (Triggering unit) at RevivePoint[(Player number of (Triggering player))], Show revival graphics
      • -------- No use in removing the revive location since you will be reusing it --------
 

Attachments

  • Example.w3x
    20.2 KB · Views: 30
Last edited:
Level 4
Joined
Dec 31, 2014
Messages
68
Hi Gismo, I tried your new example map and it all worked as I wanted - thanks. I managed to transfer it over to my map and Iv tested it all as much as I could and it works great so thank you.
Also thank you for including the region names in the map, I don't quite understand how the game knows the name of the specific region you go into, but it works - some magic no doubt!

Thanks again for taking the time for making and sending me example maps and responding, I would give REP if I could but that 'spread some rep around first' pops up, otherwise I would have gave you rep for every post you made!
Iv managed to get rid of quite a few triggers doing this which will really help I think. You've been very helpful, cheers.
 
Level 19
Joined
Jul 14, 2011
Messages
875
Its simple: just imagine you have 2 shelves. In one of them you put the regions, and in the other one you put the names in the same order.
When you grab one region from the first shelf then you grab the name from the same spot on the other shelf.
So then if you have, say, the first region in the shelf you know that it's name is the first in the second shelf.
(shelves may not have been the perfect example)
 
Status
Not open for further replies.
Top