Need very small help to change hero revive location in custom script trigger

Status
Not open for further replies.
Level 5
Joined
Aug 9, 2019
Messages
58
Hey everyone!
I used this trigger (Reviving Fallen Heroes) for my hero revive system, but I need to change the location from "Center of playable Map" to a region I created at my base. In that link it explains how to change it, but I don't understand, I am still very new to GUI, can someone help me please?
 
Level 5
Joined
Aug 9, 2019
Messages
58
hi can you make a demo map with that trigger and post that map here? If you can't post a demo then what you need to do is to make a new variable with that region and next change that trigger old variable center map with this new variable.
Hey, sure, I just attached it to the post.
 

Attachments

  • demo map.w3m
    17.3 KB · Views: 8

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,272
You cannot get a location inside a region. Only test if a location is inside a region or add more cells to a region. You might be referring to a rect which GUI incorrectly calls "region". In which case change the rect argument from playable map area to your own rect argument to get the centre of.
 
Level 5
Joined
Aug 9, 2019
Messages
58
change the rect argument from playable map area to your own rect argument to get the centre of
I am not sure I am understanding correctly, but basically I need to change this line: " GetRectCenter(GetPlayableMapRect()), true)" to something like "GetRectCenter(GetRegion_1Rect()),true) correct?
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,272
I am not sure I am understanding correctly, but basically I need to change this line: " GetRectCenter(GetPlayableMapRect()), true)" to something like "GetRectCenter(GetRegion_1Rect()),true) correct?
Yes but since you are using the GUI "region" editor it is a variable and not function. So something like...

Code:
GetRectCenter(gg_rct_1Rect)
Assuming you called the GUI region "1Rect" and made it in the region editor.

If it is a GUI region variable called "1Rect" set in some trigger then the following would be used.
Code:
GetRectCenter(udg_1Rect)
 
Level 5
Joined
Aug 9, 2019
Messages
58
Yes but since you are using the GUI "region" editor it is a variable and not function. So something like...

Code:
GetRectCenter(gg_rct_1Rect)
Assuming you called the GUI region "1Rect" and made it in the region editor.

If it is a GUI region variable called "1Rect" set in some trigger then the following would be used.
Code:
GetRectCenter(udg_1Rect)

[/QUOTE]
I see, I think my head is just too tired, still trying to figure out , I think i am doing something wrong
Ok try this
Because your map is made with reforged i can't test the map
I tried, but unofrtunately it gave me syntax error. Not sure why. Thank you though for trying.
 

Attachments

  • 1657409256102.png
    1657409256102.png
    109.2 KB · Views: 13

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,272
I tried, but unofrtunately it gave me syntax error. Not sure why. Thank you though for trying.
udg_Hero is a variable not a function? The syntax error is pretty descriptive as to the problem.

Code:
set x = udg_Hero() // This calls the function named udg_Hero passing it no arguments.
set x = udg_Hero // This looks up the value stored in a variable named udg_Hero ("Hero" in GUI).
 
Last edited:

Uncle

Warcraft Moderator
Level 71
Joined
Aug 10, 2018
Messages
7,640
Create a new Region variable and set it to the region where you want your Hero to revive:
  • Events
  • Map initialization
  • Actions
  • Set Variable R = YourReviveRegion <gen>
Now inside of the Revive trigger you can replace the ReviveHeroLoc() line with this:
  • Custom script: call ReviveHero(OURHERO, GetRectCenterX(udg_R), GetRectCenterY(udg_R), true )

Also, if you want to avoid creating memory leaks then do this at the end of the Revive trigger:
  • Custom script: call DestroyTimer(OURTIMER)
  • Custom script: set OURTIMER = null
  • Custom script: set OURHERO = null
  • Custom script: set WINDOW = null
And replace the PanCameraToTimedLocForPlayer() line with this:
  • Custom script: call PanCameraToTimedForPlayer( GetOwningPlayer(OURHERO), GetRectCenterX(udg_R), GetRectCenterY(udg_R), 0.60 )
This will clean up the memory leaks which helps with game performance. It's sort of like emptying your recycling bin of unnecessary garbage.

Some other optimizations can be made as well but they're not really necessary for a trigger that runs so infrequently.
 
Last edited:
Level 5
Joined
Aug 9, 2019
Messages
58
Create a new Region variable and set it to the region where you want your Hero to revive:
  • Events
  • Map initialization
  • Actions
  • Set Variable R = YourReviveRegion <gen>
Now inside of the Revive trigger you can replace the ReviveHeroLoc() line with this:
  • Custom script: call ReviveHero(OURHERO, GetRectCenterX(udg_R), GetRectCenterY(udg_R), true )

Also, if you want to avoid creating memory leaks then do this at the end of the Revive trigger:
  • Custom script: call DestroyTimer(OURTIMER)
  • Custom script: set OURTIMER = null
  • Custom script: set OURHERO = null
  • Custom script: set WINDOW = null
And replace the PanCameraToTimedLocForPlayer() line with this:
  • Custom script: call PanCameraToTimedForPlayer( GetOwningPlayer(OURHERO), GetRectCenterX(udg_R), GetRectCenterY(udg_R), 0.60 )
This will clean up the memory leaks which helps with game performance. It's sort of like emptying your recycling bin of unnecessary garbage.

Some other optimizations can be made as well but they're not really necessary for a trigger that runs so infrequently.
Thank you so much! That helped me a lot to understand it more clearly. Btw, do you know how to reply to messages without quoting the message itself? I clicked on something and every time I reply, it automatically quotes the message I reply t. Tried clicking on"Quotes" button, didn't do anything.
 

Uncle

Warcraft Moderator
Level 71
Joined
Aug 10, 2018
Messages
7,640
Click "Post reply" at the bottom of the screen. You can also delete the quoted message when replying to someone directly. There's also @Marcus777 to get someone's attention.

Edit: I reread what you said and I've never had that happen before. I don't think there's a button that does that...
 
Last edited:
Status
Not open for further replies.
Top