• 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.

Confused on why its not working...

Status
Not open for further replies.
Level 8
Joined
Jun 2, 2015
Messages
86
I have set up a code that you can type "-revive" which will cost 35xHero Level (It's working as intended). But every time someone types -revive, It will take the money and not resurrect the hero. It's set to pick all units owned by the player who triggered the event. And it also checks for if the target is a Hero and if the target is dead. What should I do?
 

Attachments

  • ImConfused.JPG
    ImConfused.JPG
    114.6 KB · Views: 65

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,867
You don't need those "Ands" in your conditions. By default your conditions are all treated as "Ands".

Anyway, the only other issue I can imagine is that those units aren't in the Unit Group. You should test it by displaying a test message of "the name of picked unit" to see if it finds your dead heroes.
 
Level 12
Joined
Jan 30, 2020
Messages
875
Actually no.

Your group contains all the units for the player who typed the command. Pick all units also adds dead units to the group.
So the hero MUST be in the group.

I would rather suspect an interference from another trigger.
Would you by any chance have added an anti-leak script somewhere removing dead units ? Because that is one of the first things people add to GUI triggers when it comes to fight leaks. The thing is Removed units are not added to a group by Pick...
 
Level 12
Joined
Jan 30, 2020
Messages
875
I am getting ready for an important appointment right now, but if you send me the updated map, I'll have a look when I return
 
Level 13
Joined
Feb 5, 2018
Messages
567
  • All players
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Triggering unit) is an illusion) Equal to False
      • ((Triggering unit) is hidden) Equal to False
      • ((Triggering unit) is A Hero) Equal to True
    • Actions
      • -------- >>>Locals<<< --------
      • Custom script: local unit OURHERO = GetTriggerUnit()
      • Custom script: local real HEROWAIT = 25
      • Custom script: local timerdialog WINDOW
      • Custom script: local timer OURTIMER
      • -------- ---The Trigger--- --------
      • Custom script: set OURTIMER = CreateTimer()
      • Custom script: call TimerStart(OURTIMER,HEROWAIT,false,null)
      • Custom script: set WINDOW = CreateTimerDialog(OURTIMER)
      • Custom script: if GetLocalPlayer() == GetTriggerPlayer() then
      • Custom script: call TimerDialogDisplay(WINDOW,true)
      • Custom script: endif
      • Custom script: call PolledWait(HEROWAIT)
      • Custom script: call ReviveHero(OURHERO,GetRectCenterX(gg_rct_HeroStartPoint),GetRectCenterY(gg_rct_HeroStartPoint),true)
      • Custom script: if GetLocalPlayer() == GetTriggerPlayer() then
      • Custom script: call PanCameraToTimed(GetUnitX(OURHERO),GetUnitY(OURHERO),0.6)
      • Custom script: endif
      • Custom script: call PauseTimer(OURTIMER)
      • Custom script: call DestroyTimer(OURTIMER)
      • Custom script: call DestroyTimerDialog(WINDOW)
      • Custom script: set OURHERO = null
Change the event to our your event and remove the timers.

Add your checks to this trigger. Hope this gives at least an idea how to run it.
Never give up :)
Sometimes the triggering is hard and you might feel a bit overwhelmed, but in the end it will work.

It should work then.

NOTE: This trigger is originated from hiveworkshop.com Just found it faster on my map.
 
Level 12
Joined
Jan 30, 2020
Messages
875
This is mostly Jass written with GUI line by line.

I am not sure this will help the readability of the map. It is usually better not to mix them too much except when there is no other way.

I still believe doing what she attempts to get done is not hard but I keep suspecting anti-leak triggers.

@TheSilverhand : where can I find an updated version of your map with the problematic resurrect trigger ?

I can have a look at it now I have returned !
 
Level 8
Joined
Jun 2, 2015
Messages
86
This is mostly Jass written with GUI line by line.

I am not sure this will help the readability of the map. It is usually better not to mix them too much except when there is no other way.

I still believe doing what she attempts to get done is not hard but I keep suspecting anti-leak triggers.

@TheSilverhand : where can I find an updated version of your map with the problematic resurrect trigger ?

I can have a look at it now I have returned !

I'm currently working on combinations atm. My recent map was uploaded to Epicwar.com and should have also been updated via my link at the bottom where my Custom Hero Defense map is listed.
 
I think the problem lies in the fact that dead heroes do not exist in the map, so when a unit group sweep is executed, it fails to capture the hero. I recall similar things also exist on Locust units.

The solution would be to register the hero on their death event to a variable and when player execute the revival command, retrieve the variable and use it for revival.
 
Level 12
Joined
Jan 30, 2020
Messages
875
I think the problem lies in the fact that dead heroes do not exist in the map, so when a unit group sweep is executed, it fails to capture the hero. I recall similar things also exist on Locust units.

The solution would be to register the hero on their death event to a variable and when player execute the revival command, retrieve the variable and use it for revival.


Had just started working on it and then I read this :)
Yes that is a really good idea and would also at the same time make every trigger related to the heroes more simple. Ideally for every player the hero and his/her alive status should be stored.


EDIT Ok working on the map.
The Heroes are actually already stored upon death. So that will make the trigger to revive them much easier
 
Last edited:
Level 12
Joined
Jan 30, 2020
Messages
875
OK.

@TheSilverhand : please stop adding new functionalities to your map right now.

It is urgent that you clean up your triggers first. Leaving the triggers like that and keeping adding more functionalities is just pure self torture.


Please stop making 10 copies (without renaming them) of a trigger or an action when you want to use them for every player. It his horrible. Just create an array, then you only have to change the array index with the player number.

I have spent a lot of time tracking everything related to your reviving system, it was all over the place.

You used 2 timer variables and you copied them 9 times to have 1 for each player. NO! Never do that, you're making your code a nightmare to read and you're making your life very difficult.

You need a timer for each player ? Easy : create a Timer array, then use the player number as the index and you only have to use your actions once.

I remade your hero revive system. I haven't tested it yet because I want you to look at what I did so far.
I also could not stop myself from changing your trigger that displays deaths and kills on the multiboard, it was another trigger replication horror.

I put these 2 things at the beginning of your triggers and gave them proper names :

"Multiboards and death counts"
and
"Hero Revive For Gold"
I also created the appropriate variables INSIDE the categories, and removed all the copies of copies of copies... of the old ones, as well as the related copies of copies of copies... of your actions.

Please spend some time looking at the new triggers
, and how amazingly smaller and easier to understand they are. This should help you using a similar process to remake other triggers you made the "copy of copy of copy..." way.

I am sure you could reduce the size of your whole map triggers by 3 or 4 if not more this way.

Honestly, I would even do it right now IF I had the time.

IMPORTANT NOTE : it is important for you to know that you cannot use WAITS inside a trigger if you are using event responses (triggering player, dying unit, etc...) after these waits, chances are high the trigger will not know what they are after the wait.

ALSO : Use variables. Store the event response Player or Unit or anything else in variables. You can't use local variables like in Jass, but if you use global variables, at least other triggers using the same event responses won't conflict with your trigger.

Anyways, I don't say all this to be nasty, on the contrary. I like your map, and I believe you could make it really stable with some trigger cleaning.

If you do the cleaning, I can promise to sort out all your leaks, but I don't have the time to do the whole cleaning before.

This said, I am also willing to give you any help you would require if you had any trouble cleaning your triggers.

But please don't leave them like that !


EDIT : I am going back to your map to test what I changed. I'll keep you updated.

EDIT 2 : After testing, the Revive for Gold seems to work quite nicely :)
 

Attachments

  • Custom_Hero_DefenseTSH.20.8BIS.w3x
    7.1 MB · Views: 24
Last edited:
Level 8
Joined
Jun 2, 2015
Messages
86
OK.

@TheSilverhand : please stop adding new functionalities to your map right now.

It is urgent that you clean up your triggers first. Leaving the triggers like that and keeping adding more functionalities is just pure self torture.


Please stop making 10 copies (without renaming them) of a trigger or an action when you want to use them for every player. It his horrible. Just create an array, then you only have to change the array index with the player number.

I have spent a lot of time tracking everything related to your reviving system, it was all over the place.

You used 2 timer variables and you copied them 9 times to have 1 for each player. NO! Never do that, you're making your code a nightmare to read and you're making your life very difficult.

You need a timer for each player ? Easy : create a Timer array, then use the player number as the index and you only have to use your actions once.

I remade your hero revive system. I haven't tested it yet because I want you to look at what I did so far.
I also could not stop myself from changing your trigger that displays deaths and kills on the multiboard, it was another trigger replication horror.

I put these 2 things at the beginning of your triggers and gave them proper names :

"Multiboards and death counts"
and
"Hero Revive For Gold"
I also created the appropriate variables INSIDE the categories, and removed all the copies of copies of copies... of the old ones, as well as the related copies of copies of copies... of your actions.

Please spend some time looking at the new triggers
, and how amazingly smaller and easier to understand they are. This should help you using a similar process to remake other triggers you made the "copy of copy of copy..." way.

I am sure you could reduce the size of your whole map triggers by 3 or 4 if not more this way.

Honestly, I would even do it right now IF I had the time.

IMPORTANT NOTE : it is important for you to know that you cannot use WAITS inside a trigger if you are using event responses (triggering player, dying unit, etc...) after these waits, chances are high the trigger will not know what they are after the wait.

ALSO : Use variables. Store the event response Player or Unit or anything else in variables. You can't use local variables like in Jass, but if you use global variables, at least other triggers using the same event responses won't conflict with your trigger.

Anyways, I don't say all this to be nasty, on the contrary. I like your map, and I believe you could make it really stable with some trigger cleaning.

If you do the cleaning, I can promise to sort out all your leaks, but I don't have the time to do the whole cleaning before.

This said, I am also willing to give you any help you would require if you had any trouble cleaning your triggers.

But please don't leave them like that !


EDIT : I am going back to your map to test what I changed. I'll keep you updated.

EDIT 2 : After testing, the Revive for Gold seems to work quite nicely :)

Also, you did something wrong. The trigger was meant to have a timer window. When the hero dies and have a timer to respawn. then you can type -revive to instantly revive instead of waiting.
 
Level 12
Joined
Jan 30, 2020
Messages
875
OK sorry I actually spent all the time since my message playing your map !

You're not a master at triggers, but you have ideas and quite refreshing one !!!
Yes I knew I should have checked about this TimerWin(dow). But it took me so long to fish for everything related to the Revive and other bits that It seems I removed window. Will find it back.

In the meantime please read the 2 triggers I rewrote, you will see how simple it can become when you make them right.

I understand the situation from your perspective though. You have incredible imagination, amazing ideas as if the years would not bore you, and that is rare !!!!

When I ask you to study these changes I made, and understand them, It is because I'd love you to improve your approach. Right now, when you don't know how to do something, you would take any path around to make sure you reach your goal, even if the path stops by Paris on the way.

Take your time, think twice about how you could solve your problems. When you are stuck (I don't mean when you have stitched together a trigger by means I could hardly fathom) ask for advice. Not necessary on a complete trigger that became Huge and difficult to decipher, but on the parts that give you a hard time.

Overall you don't HAVE to be good at triggers to make good maps. I have seen maps with triggers so polished and well conceived that it is nearly frightening. Unfortunately performance or coding elegance never makes a game attractive. So don't give up, but make your life easier : learn the simple tools for it. Using loops, arrays and some variables will make your coding hard times become a breeze.

For the more complex stuff, remember you can always ask for help.




Back again.

I know why there is no timer window : you were not starting the timer on hero death.

Anyways, I don't mind recreating the timer windows properly, but for that please describe exactly what should happen :

1) Duration of the Revive timer
2) What happens if the player does not revive for gold (I suppose the hero auto revives at the end of the timer ?)

Just want to make sure that I make things right.
 
Last edited:
Level 8
Joined
Jun 2, 2015
Messages
86
You have 2 options: Type "-Revive" to instantly revive your hero. Or you can let the timer run out and instantly revive you. The cost is just for insta revive.

The few triggers you wrote made no sense to me. I tried to make it work they didn't work for me. (I tried to make a trigger work that way. But the count down never showed up. Such as my map if you look back in the older days. the trigger was built the same way you have set up. However, it did not understand the code and did not work. It would only show up for player 1.)
I may not know my way around some coding. but I know what I want. I want people to feel like they have the advantages of -revive or just keeping their gold and letting it count down.
I try to redo my strats and take my time. but It doesn't always work. Which is why I get stressed out and say I'm done trying.

Also, I am trying to make it where you can have 15 players in my map again. so I'm currently working on that. it should work fine.
 
Last edited:
Level 45
Joined
Feb 27, 2007
Messages
5,578
if you use global variables, at least other triggers using the same event responses won't conflict with your trigger.
Wc3 is single-threaded and with the exception of employing waits or something the first trigger doing causing trigger 2 to fire, a second trigger will never 'interrupt' and 'conflict with' another trigger. Even then the event responses aren't overwritten.
 
Level 12
Joined
Jan 30, 2020
Messages
875
If you tried to use arrays and it only worked for Player 1, it just means you used the wrong index for the array.

Anyways I know what you want, that is what I guessed anyways, I will get that Timer back don't worry.

Need a bit of time before as I have to sort out important paperwork, but don't worry it will be fixed in a few hours.

Now for the thing that worries me :
"The few triggers you wrote made no sense to me".

I don't understand how you can make sense of something like :

Code:
If (triggering player is equal to Player 1)
  Do Something for Player1
Else
If (triggering player is equal to Player 2)
  Do Something for Player2
Else
If (triggering player is equal to Player 3)
  Do Something for Player3
Else
If (triggering player is equal to Player 4)
  Do Something for Player4
Else
If (triggering player is equal to Player 5)
  Do Something for Player5
Else
If (triggering player is equal to Player 6)
  Do Something for Player6
Else
If (triggering player is equal to Player 7)
  Do Something for Player7
Else
...
If (triggering player is equal to Player 15)
  Do Something for Player15
Else
...

and not make sense of something that does exactly the same thing in 45 times less lines

Code:
Do something for triggering player

Because that is exactly what it is about

As for saving the triggering player or his number in a variable before the other actions, it has 2 purposes :
1) not having to write something like "Player Number Of Owner Of Dying Unit" many times isn't "PlayerNb" easier or am I crazy ?????
2) when you use your waits, event in 0.5 second, the triggering player can change, the dying unit can change and then your trigger has a chance to not work at all

Don't be frightened by lines of code you are not accustomed to, read it first and try to see what it does.


Anyways you really need to change habits. I just saw another trigger that nearly gave me a heart attack.

What would you do if you had to make a map with 2000 players (I know it's not possible, just trying to make you realize your way is like jumping off a bridge) ?
 
Level 12
Joined
Jan 30, 2020
Messages
875
Wc3 is single-threaded and with the exception of employing waits or something the first trigger doing causing trigger 2 to fire, a second trigger will never 'interrupt' and 'conflict with' another trigger. Even then the event responses aren't overwritten.

The wait is exactly what it was on about :)

She had a trigger that roughly does this

Event - A Unit Dies

Actions
Do something with Owner of Dying Unit and Owner of killing Unit
WAIT 0.5s
Display Something on the multiboard for Owner of Dying Unit and for Owner Of Killing Unit
 
Level 12
Joined
Jan 30, 2020
Messages
875
Those two specifically should also still work.
Event Response Myths

Thanks for the link but this is really confusing

How does the game manage to differentiate 2 dying units if another unit dies before the 0.5s have elapsed ?

Do you mean that the game instantiates event responses to avoid losing references ?

Seems like I thought I knew Jass, and that I was utterly wrong. - or maybe I knew it 16 years ago and I haven't really caught up yet :)
 
Last edited:
Level 12
Joined
Jan 30, 2020
Messages
875
The Timed event has been working for a long time. Which is why it was there. lol

You had an event "a unit dies" with condition "dying unit is a hero" and it had no timer start, that is why I didn't notice.
But don't worry, I will put it back as promised... :)

EDIT : I wish my laptop was faster to load big maps like this one in less than 5 minutes :D
 
Level 12
Joined
Jan 30, 2020
Messages
875
Some of them, yes. The thread shows which ones work this way.

Honestly, I prefer considering they could be lost rather than maintaining a list of resilient / non-resilient event responses. If I use the same good practices for all event responses, at least I am sure I won't make a mistake.

But once again, thank you as it was very instructive... this is one of the things I don't think we were aware of back in 2004 !
 
Level 12
Joined
Jan 30, 2020
Messages
875
The Timed event has been working for a long time. Which is why it was there. lol

OK took me a while because I needed to have the 2 versions of your map opened at the same time, but I think I have it right now.
Will test it immediately after this message before posting the new version of the map.

It was not "easy" actually. I found your Variable "DeathTimer", it is the duration of the timer for dead heroes. I have found some triggers where you alter this duration, but the trigger is not enabled for some reason. I suppose you enable it somewhere else on this labyrinth of GUI triggers :D

Also your revive for gold would have been very problematic as you automatically revive every hero.... after the duration of the timer, not using the timer expires as an event.

So : A Hero dies then Start the "Revive" Timer, then Wait for DeathTimer seconds, then Revive hero.
Problem is you can not interrupt that if a player types the -Revive (for gold) command.

Thus what I did is When Hero dies, I start the timer (and its window ;-) ) after saving the hero in the DeadHero array, and setting the corresponding boollean array value to true

Then I created a new trigger for when the timer expires :
of course, if a player typed "-Revive" in the meantime, I have stopped the Timer and destroyed its window in the Revive for Gold Trigger so the timer will not expire.
I added the timer expire event for each player (HeroMsgTimer[1 to 10])
Then I added a bit of custom script with a simple loop to find the timer that expired because in GUI you don't have "Event Response - Expired Timer" as far as I know, even if this one exists in Jass. The loop finds the number of the timer that is also the number of the player. It is saved in the variable PlayerNb.
Then I revive the hero with the camera as usual and with a message "(Player Name) 's hero has resurrected..." you can easily change that text.

Ok time for me to test this before posting the map - it started saving the map before I wrote this message, so it should be ready by now :)

EDIT : Both forms of revives now work (timer window too, change the text if needed)
Attached the new version of the map.
 

Attachments

  • Custom_Hero_DefenseTSH.20.8TER.w3x
    7.1 MB · Views: 60
Last edited:
Level 8
Joined
Jun 2, 2015
Messages
86
First of all, I already told ya about this before. Your trigger doesn't work. When people die, their timer starts. However, it doesn't have a count down for anyone else but player 1 (red) I already tested this. I put in 4 Mountain Kings to test to see if it works. Player 1 died. Revived. Player 2, 16, and 20 died but did not pop up. if player 2 did not revive that means that player 16 - 20 would not do so either.
 
Level 12
Joined
Jan 30, 2020
Messages
875
The BEST way to make this work is by having multiple triggers. And that's the best way to do it.

No, seriously it is a really bad programming practice, you should not rely on that. I might work on limited circumstances, but chaining bad habits always ends up with more problems than solutions.

I admit I couldn't test it for all players, but there is no reason it would not find the right Expired Timer unless I made a stupid typo somewhere.

And I know my method works because I use something similar in Jass in one of my maps. Just need to make the custom script part work properly and in synergy with the GUI triggers.

EDIT :
Will have a look at this tonight.
And I make a promise : if I fail to do it my way, I will revert back to these horrible multiple triggers, I swear.
 
Level 12
Joined
Jan 30, 2020
Messages
875
OK.

I had to give up. After 10 failed attempts, you map simply is too heavy for my poor laptop to handle.
I guess your PC must be quite powerful.

What happens is I can't even open the player properties from the Scenario menu to change player settings. World Edit freezes and never recovers.
As a consequence I could not change the player slot used by worldedit test.

I had added a debug message that shows the number of the timer once the trigger is started.

But obviously I have no way to test it. Also, I'm on my own and as I just came back to wc3, I have no friend to test the map with in multiplayer.


Anyways. As I could not do the tests, I can not trace where my script failed to identify the expired timer, and I then was forced to use the dirty method of making 1 trigger for each player.

Oh well at least I tried :)

Please let me know if this works.

EDIT :
It is important that you realize that the map i downloaded from you post only had support for 10 players in these revive triggers. If you want more players to work, you'll have to edit the corresponding triggers, and if you can't I can do it for you.

But don't test players beyond player 10 as their heroes won"t revive
 

Attachments

  • Custom_Hero_DefenseTSH.20.8TET.w3x
    7.1 MB · Views: 63
Last edited:
Status
Not open for further replies.
Top