I have a trigger that should increase a targeted players income timer when I pick them with a trigger. The issue is that I have a warning message depending on their current timer length but when i try to increase it once all of the message triggers fire which make me think that the trigger is not working properly. I'll post the trigger here.
General - If (Conditions) then do (Actions) else do (Actions)
If
Player 5 timer integer == 30
Then
Timer - Start (New timer) as a Repeating timer that will expire in 37.5 Game Time seconds
Variable - Set Player 5 timer = (Last started timer)
Variable - Set Player 5 timer integer = 38
Transmission - Send transmission to (All players) from ((Last created unit) with No Flash (Do Not override portrait) playing Talk) playing No Sound Link with name "Warning!" and message (Combine ((Name of player 5), " has had their income time increase...")) using (Cinematic portrait at Center Left) playing Talk (Add 0.0 seconds, Don't Wait until it finishes)
Then I just copy pasted and changed the if to the new player 5 timer integer and increased the timer by the amount and changed the text to reflect the new timer. So where did I screw this up? Do I need to create a new trigger for each new time?
It would help if we had a bigger picture to look at. Copy your entire trigger as text and paste it here in code tags. It's better to see exactly what you did. Right now I'm sitting here guessing what your trigger looks like from your description.
When you form a reply you see this button. Click on it and you'll be asked for the specific language. Just click OK (doesn't matter which language) and write within the code tags.
PickPlayer5(Debuff)EventsDialog-AnyDialogItemisusedbyPlayer1witheventtypeCheckedLocalVariablesConditions(DialogCheckPlayer5ischeckedfor(Triggeringplayer))==truePlayer5timerinteger>=30ActionsGeneral-If(Conditions)thendo(Actions)elsedo(Actions)IfPlayer5timerinteger==30(DialogCheckPlayer5ischeckedfor(Triggeringplayer))==trueThenGeneral-Waitfor(Conditions),checkingevery1.0GameTimesecondsConditionsPlayer5timerinteger==30Timer-Start(Newtimer)asaRepeatingtimerthatwillexpirein37.5GameTimesecondsVariable-SetPlayer5timer=(Laststartedtimer)Variable-ModifyPlayer5timerinteger:+8Transmission-Sendtransmissionto(Allplayers)from((Lastcreatedunit)withNoFlash(DoNotoverrideportrait)playingTalk)playingNoSoundLinkwithname"Warning!"andmessage(Combine((Nameofplayer5)," has had their income time increase..."))using(CinematicportraitatCenterLeft)playingTalk(Add0.0seconds,Don't Wait until it finishes)ElseGeneral-If(Conditions)thendo(Actions)elsedo(Actions)IfPlayer5timerinteger==38(DialogCheckPlayer5ischeckedfor(Triggeringplayer))==trueThenGeneral-Waitfor(Conditions),checkingevery1.0GameTimesecondsConditionsPlayer5timerinteger==38Timer-Start(Newtimer)asaRepeatingtimerthatwillexpirein46.8GameTimesecondsVariable-SetPlayer5timer=(Laststartedtimer)Variable-ModifyPlayer5timerinteger:+8Transmission-Sendtransmissionto(Allplayers)from((Lastcreatedunit)withNoFlash(DoNotoverrideportrait)playingTalk)playingNoSoundLinkwithname"Warning!"andmessage(Combine((Nameofplayer5)," has had their income time increase..."))using(CinematicportraitatCenterLeft)playingTalk(Add0.0seconds,Don't Wait until it finishes)ElseGeneral-If(Conditions)thendo(Actions)elsedo(Actions)IfPlayer5timerinteger==46(DialogCheckPlayer5ischeckedfor(Triggeringplayer))==trueThenTimer-Start(Newtimer)asaRepeatingtimerthatwillexpirein58.5GameTimesecondsVariable-SetPlayer5timer=(Laststartedtimer)Variable-ModifyPlayer5timerinteger:+13Transmission-Sendtransmissionto(Allplayers)from((Lastcreatedunit)withNoFlash(DoNotoverrideportrait)playingTalk)playingNoSoundLinkwithname"Warning!"andmessage(Combine((Nameofplayer5)," has had their income time increase..."))using(CinematicportraitatCenterLeft)playingTalk(Add0.0seconds,Don't Wait until it finishes)ElseGeneral-If(Conditions)thendo(Actions)elsedo(Actions)IfPlayer5timerinteger==59(DialogCheckPlayer5ischeckedfor(Triggeringplayer))==trueThenTimer-Start(Newtimer)asaRepeatingtimerthatwillexpirein73.1GameTimesecondsVariable-SetPlayer5timer=(Laststartedtimer)Variable-SetPlayer5timerinteger=73Variable-ModifyPlayer5timerinteger:+14Transmission-Sendtransmissionto(Allplayers)from((Lastcreatedunit)withNoFlash(DoNotoverrideportrait)playingTalk)playingNoSoundLinkwithname"Warning!"andmessage(Combine((Nameofplayer5)," has had their income time increase..."))using(CinematicportraitatCenterLeft)playingTalk(Add0.0seconds,Don't Wait until it finishes)ElseDialog-DestroyallitemsforDialogIncomeChoiceBoxDialog-Destroyalldialogs
A lot of some of the things like every if statement checking it the check was used and the first condition statement with the >= is me trying to fix it on my own lol >.<
Well, put all those if thens into a switch statement first. And you don't need the (Dialog Check Player 5 is checked for (Triggering player)) == true part at every if then. Don't see why you need the wait for conditions part when it's exactly the same as the if then condition.
Your problem is the order in which you do the if checks.
You start off with the timer at 30, and add 8. So now it's 38.
Your next if checks if it's 38, and it is.. so adding 8 more. Now it's 46.
the next if fires if it's 46. Bad luck, it is 46.
...and so on.
There are a few options to fix this, but the easiest as far as I can see would be to reverse the order of the checks. Start with your highest and check lower and lower. Now, if your timer is increased, the check for that higher timer has already been done, so it won't fire immediately.
...or use a local boolean variable that makes sure that the timer is only increased once each time the trigger runs.
I get the feeling that the entire procedure can be done with only one if check but using a few more variables that keeps track of which timer step you are currently on, but since you already have the trigger set up, might as well keep it I guess. Don't really matter as long as you get it to work as intended.
Edit:
Yeah, the trigger could be cleaned up quite a bit by removing redundant steps. But I think it's more important that you do it your way, so that you understand your own triggers.
I'm unsure exactly how switches work in the galaxy editor, but using that instead of if then might also solve the problem (assuming it only allows one case to be chosen, even if the variables change halfway through).
Your problem is the order in which you do the if checks.
You start off with the timer at 30, and add 8. So now it's 38.
Your next if checks if it's 38, and it is.. so adding 8 more. Now it's 46.
the next if fires if it's 46. Bad luck, it is 46.
...and so on.
There are a few options to fix this, but the easiest as far as I can see would be to reverse the order of the checks. Start with your highest and check lower and lower. Now, if your timer is increased, the check for that higher timer has already been done, so it won't fire immediately.
...or use a local boolean variable that makes sure that the timer is only increased once each time the trigger runs.
I get the feeling that the entire procedure can be done with only one if check but using a few more variables that keeps track of which timer step you are currently on, but since you already have the trigger set up, might as well keep it I guess. Don't really matter as long as you get it to work as intended.
Edit:
Yeah, the trigger could be cleaned up quite a bit by removing redundant steps. But I think it's more important that you do it your way, so that you understand your own triggers.
I'm unsure exactly how switches work in the galaxy editor, but using that instead of if then might also solve the problem (assuming it only allows one case to be chosen, even if the variables change halfway through).
A switch condition should fix that, with 30, 38, and 46 being cases, then the action beneath each one.
A switch works by looking at each condition. If you have a switch dependant on i, and cases 'when 30', 'when 38', 'when 46' it will look at it. i = 30, so stop looking at it and do the next action. If it is say 54, and it looks at it and nothing is found then it will do the default case.
Example: You have 3 dialogs. You want one to open if a score is 5, a differant one if it's 10, and all other times a third one. Instead of doing 'If i == 5, open dialog 1 else if i == 10 open dialog 2 else open dialog 3' a switch would do it more efficiently and takes up less space in the trigger.
Switching the order worked thanks very much. Once I get the map working for the most part and done some testing and publishing I plan on coming back and fixing/cleaning up most of the trigger and issues that i know exist now.
I have a trigger that should increase a targeted players income timer when I pick them with a trigger. The issue is that I have a warning message depending on their current timer length but when i try to increase it once all of the message triggers fire which make me think that the trigger is not working properly. I'll post the trigger here.
General - If (Conditions) then do (Actions) else do (Actions)
If
Player 5 timer integer == 30
Then
Timer - Start (New timer) as a Repeating timer that will expire in 37.5 Game Time seconds
Variable - Set Player 5 timer = (Last started timer)
Variable - Set Player 5 timer integer = 38
Transmission - Send transmission to (All players) from ((Last created unit) with No Flash (Do Not override portrait) playing Talk) playing No Sound Link with name "Warning!" and message (Combine ((Name of player 5), " has had their income time increase...")) using (Cinematic portrait at Center Left) playing Talk (Add 0.0 seconds, Don't Wait until it finishes)
Then I just copy pasted and changed the if to the new player 5 timer integer and increased the timer by the amount and changed the text to reflect the new timer. So where did I screw this up? Do I need to create a new trigger for each new time?
you are creating a new timer and not editing the old one, this might cause it
@b0ne123: Go
hhmmm ok i'll look into it. thanks I'll post again if it works.
Still doesn't work I changed it to modify the time integer and added a condition that says if the integer is >= 30. Still spams the messages.
It would help if we had a bigger picture to look at. Copy your entire trigger as text and paste it here in code tags. It's better to see exactly what you did. Right now I'm sitting here guessing what your trigger looks like from your description.
@Berrala: Go
Oh ok. I guess I can do that. How do I put it in as code tags? (I never used forums before really >.< )
@Reaperguyver: Go
When you form a reply you see this button. Click on it and you'll be asked for the specific language. Just click OK (doesn't matter which language) and write within the code tags.
A lot of some of the things like every if statement checking it the check was used and the first condition statement with the >= is me trying to fix it on my own lol >.<
bump. hoping for some help. I don't really want to make like 500,000 triggers. :(
Well, put all those if thens into a switch statement first. And you don't need the (Dialog Check Player 5 is checked for (Triggering player)) == true part at every if then. Don't see why you need the wait for conditions part when it's exactly the same as the if then condition.
Your problem is the order in which you do the if checks.
You start off with the timer at 30, and add 8. So now it's 38.
Your next if checks if it's 38, and it is.. so adding 8 more. Now it's 46.
the next if fires if it's 46. Bad luck, it is 46.
...and so on.
There are a few options to fix this, but the easiest as far as I can see would be to reverse the order of the checks. Start with your highest and check lower and lower. Now, if your timer is increased, the check for that higher timer has already been done, so it won't fire immediately.
...or use a local boolean variable that makes sure that the timer is only increased once each time the trigger runs.
I get the feeling that the entire procedure can be done with only one if check but using a few more variables that keeps track of which timer step you are currently on, but since you already have the trigger set up, might as well keep it I guess. Don't really matter as long as you get it to work as intended.
Edit:
Yeah, the trigger could be cleaned up quite a bit by removing redundant steps. But I think it's more important that you do it your way, so that you understand your own triggers.
I'm unsure exactly how switches work in the galaxy editor, but using that instead of if then might also solve the problem (assuming it only allows one case to be chosen, even if the variables change halfway through).
A switch condition should fix that, with 30, 38, and 46 being cases, then the action beneath each one.
A switch works by looking at each condition. If you have a switch dependant on i, and cases 'when 30', 'when 38', 'when 46' it will look at it. i = 30, so stop looking at it and do the next action. If it is say 54, and it looks at it and nothing is found then it will do the default case.
Example: You have 3 dialogs. You want one to open if a score is 5, a differant one if it's 10, and all other times a third one. Instead of doing 'If i == 5, open dialog 1 else if i == 10 open dialog 2 else open dialog 3' a switch would do it more efficiently and takes up less space in the trigger.
Yeah, that's the way it should work, but as I haven't used it here yet, I didn't want to say anything for certain.
Switching the order worked thanks very much. Once I get the map working for the most part and done some testing and publishing I plan on coming back and fixing/cleaning up most of the trigger and issues that i know exist now.
I'm working the same as yours.
Simple as this I say,
Periodic Event 0.87 = Time Interval
Var = Timer Count
Repeat (Forever) Wait 0.87 seconds
Modify Var Timer Count +1 If-Then Else Timer Count = 21 Then Turn (Current Trigger) Off
Else
Display combine text </fb26488> combine text[ text to integer - Timer Count Var] </c> for Var Active Players to Directive Area.
I'm currently working with a RPGic genre like Map. If you'd wish, You could join mine.
Just a sample tho, Its not literally a working one but its as simple as that.
I Initialized it = Off because I wanna run the trigger itself through OneTwoSC's Revive trigger-based/+data