Hello, first time poster here, though I've been around for a few weeks now. I'm working on a map in which I have five variables, that each hold any one out of 13 different values (1-13), and I need a trigger that checks if they are lined up in a sequence (such as 1-2-3-4-5, or 6-4-7-5-8). [Edit: Not a set sequence, but if one card is X the next needs to be X+1 or X-1 and so on. Maybe that's how you'd go about solving it? I'll try...]
Is that possible? I can handle all the other checks I'm using, but this one I just can't figure out. Thanks in advance.
(Bonus points if you can figure out what kind of map I'm making.)
Edit: Solved! I asked my good friend and together we figured out that we can use the sum of the sequence to identify it. Starting at 15, going up in intervals of 5, we can pin point any one sequence. That is, 1+2+3+4+5=15, 5+6+7+8+9=35, 9+10+11+12+13=55 etc. Only these values would give the correct sum, and the order of the values won't matter, since we're just adding them to each other.
Ever played Poker Defense? It was great fun in the BW days. I'm recreating a real version with 52 cards and everything. Not like the version I recently played that was completely broken and only used 2-3 suits and about 9 ranks for cards.
Anyway, I didn't solve it. Forgot something so simple as the fact that other cards can give the same sum as a sequence. -.- So, back to my question. Is it possible to check if my 5 variables are in sequence somehow?
Edit: Solved! This time for real, I hope. Add the values, get the sum, check all variables so that none of them are below the lowest value that would start the sequence. That is, 5+6+7+8+9=35, so if you have 35 none of the values can be below 5. If none of them are, then you really have your sequence. Because you can't get 35 without using 1-4, if you're not using 5-9 - the sequence in question. I hope that made sense.
Haha, you wrote that as I updated my post above. Yeah, I got it working I think (thought I did it as I wrote above). Thanks a lot, I should be ready to release this tomorrow or so.
I don't understand the system a 100%, so I might be wrong, but...
Wouldn't 5-7-7-7-9 count as a straight then? Sum is 35, lowest = 5 and highest is lowest + 4. (It should be four right? Else the straight would be 5 till 10).
Another way to do it would be to (copy a players hand to a temp variable and) sort the cards from lowest to highest, then check so that every card equals the last one minus one.
5,2,8,10,2 would become 2,2,5,8,10 (this would fail the sequence check)
3,5,6,4,2 would become 2,3,4,5,6 (which would pass the sequence check)
I'm making a test map for fun and practice that tries to accomplish this in an efficient manner. I'll post it here when done for anyone that wants to see.
Edit: Finished... This will check for straights. Should be easily adaptable to straight flush and royal straights too.
...and yes, as far as I understood that other solution, 5-7-7-7-9 would give a false positive.
No, I have a variable that checks for pair / two pair etc. So straights won't trigger if any two cards are the same rank. But yes, without such a check you'd be right. I should have included that in my original post. :p
I had no idea you could sort values... That would have helped a lot, but now I worked it out with the help of dgh64. But for future reference, how do you go about doing that? Looked at your map, but I'm in no shape to understand all that stuff right now. I'll be keeping it for future reference though. Thanks.
Since I have your attention, is there any way to stop / kill / shut down a trigger in the middle of it? I have 13 If Then Else checks to identify the player's hand, but if I now get royal straight flush, I also get flush and straight. Stop Trigger and Clear Action Queue doesn't stop the current trigger. :/
Have the royal straight flush check run first, and if it's true, then set a temp variable from 0 to 1 (or false to true, or whatever else you feel like). In the flush and straight checks, also check that variable's state.
There's no Return function? You know, to just stop doing whatever the trigger's doing at that point? Used it all the time when modding for Oblivion and Fallout 3. :x Otherwise I'll have to do that. Thanks.
Edit: Sorry for the long read, but I just jotted down my thoughts real fast. Hopefully you get what I'm trying to say.
It is possible to "break" loops and end triggers. But that's sloppy programming and you shouldn't be doing it that way.
You say that you already check for pairs so that you would not have to do that in straights. Then you say you want to check for the highest value hands first and kill the rest of the trigger when you do find one. This means that you would actually be checking for pairs after straights... maybe this works anyway since a full house contains a pair... but really, I think this gets waay too messy and you have too keep too much in mind. You should do a full check for each hand type. If you're feeling really nifty, you could make functions that look like mine, but do smaller things like, "All cards same suit?" (return true or false), "Hand contains a pair?" (return true or false), "Hand contains 3 of a kind?" (return true or false) etc. Then you can doo cool stuff like:
If(containsapairANDcontainsthreeofakind)then"You got a full house yo!"elseif(containstreeofakind)then"Nice! Three of a kind.etc.
If you place your 13 "if then else" inside each other, it will only check for the next hand combination if the previous one failed.
I'm just throwing out ideas here and I realize that you are reluctant to change too much in your map since you seem to be nearing a finished version... but the ground work is the most important thing to get right, make it effective and all the other triggers that build on this will be childsplay.
Ah yes, I think I get what you mean. But the thing is, I already got a way to detect pair, two pair, three of a kind, full house and four of a kind. Together with my straight check and flush check, I just have a trigger with 13 If Then Else conditions (also check for ace high and rockets) that check if you got a royal straight flush, a straight flush, four of a kind etc. all the way down. I did what dgh64 said, with a Do Once variable that makes sure no other command will run further down if my trigger finds a match higher up. And it works perfectly.
I'm still somewhat of a beginner, so I have no idea how to do custom functions and stuff. Still, using logic and some basic knowledge I managed to finish all the poker triggers in two days - and I'm really proud of that. But thanks for your help, and I'll be back once I learn a bit more. :3
Hello, first time poster here, though I've been around for a few weeks now. I'm working on a map in which I have five variables, that each hold any one out of 13 different values (1-13), and I need a trigger that checks if they are lined up in a sequence (such as 1-2-3-4-5, or 6-4-7-5-8). [Edit: Not a set sequence, but if one card is X the next needs to be X+1 or X-1 and so on. Maybe that's how you'd go about solving it? I'll try...]
Is that possible? I can handle all the other checks I'm using, but this one I just can't figure out. Thanks in advance.
(Bonus points if you can figure out what kind of map I'm making.)
Edit: Solved! I asked my good friend and together we figured out that we can use the sum of the sequence to identify it. Starting at 15, going up in intervals of 5, we can pin point any one sequence. That is, 1+2+3+4+5=15, 5+6+7+8+9=35, 9+10+11+12+13=55 etc. Only these values would give the correct sum, and the order of the values won't matter, since we're just adding them to each other.Uh, you're making a poker game? In starcraft? Ooooookaaaaaay....
@dgh64: Go
Ever played Poker Defense? It was great fun in the BW days. I'm recreating a real version with 52 cards and everything. Not like the version I recently played that was completely broken and only used 2-3 suits and about 9 ranks for cards.
Anyway, I didn't solve it. Forgot something so simple as the fact that other cards can give the same sum as a sequence. -.- So, back to my question. Is it possible to check if my 5 variables are in sequence somehow?
Edit: Solved! This time for real, I hope. Add the values, get the sum, check all variables so that none of them are below the lowest value that would start the sequence. That is, 5+6+7+8+9=35, so if you have 35 none of the values can be below 5. If none of them are, then you really have your sequence. Because you can't get 35 without using 1-4, if you're not using 5-9 - the sequence in question. I hope that made sense.
You're just trying to detect a straight, right? Well, you can do what you said before, and then also add "If the smallest + 5 = the largest".
@dgh64: Go
Haha, you wrote that as I updated my post above. Yeah, I got it working I think (thought I did it as I wrote above). Thanks a lot, I should be ready to release this tomorrow or so.
I don't understand the system a 100%, so I might be wrong, but...
Wouldn't 5-7-7-7-9 count as a straight then? Sum is 35, lowest = 5 and highest is lowest + 4. (It should be four right? Else the straight would be 5 till 10).
Another way to do it would be to (copy a players hand to a temp variable and) sort the cards from lowest to highest, then check so that every card equals the last one minus one.
5,2,8,10,2 would become 2,2,5,8,10 (this would fail the sequence check)
3,5,6,4,2 would become 2,3,4,5,6 (which would pass the sequence check)
I'm making a test map for fun and practice that tries to accomplish this in an efficient manner. I'll post it here when done for anyone that wants to see.
Edit: Finished... This will check for straights. Should be easily adaptable to straight flush and royal straights too.
...and yes, as far as I understood that other solution, 5-7-7-7-9 would give a false positive.
@DisAs7ro: Go
No, I have a variable that checks for pair / two pair etc. So straights won't trigger if any two cards are the same rank. But yes, without such a check you'd be right. I should have included that in my original post. :p
@Berrala: Go
I had no idea you could sort values... That would have helped a lot, but now I worked it out with the help of dgh64.
But for future reference, how do you go about doing that?Looked at your map, but I'm in no shape to understand all that stuff right now. I'll be keeping it for future reference though. Thanks.Since I have your attention, is there any way to stop / kill / shut down a trigger in the middle of it? I have 13 If Then Else checks to identify the player's hand, but if I now get royal straight flush, I also get flush and straight. Stop Trigger and Clear Action Queue doesn't stop the current trigger. :/
Have the royal straight flush check run first, and if it's true, then set a temp variable from 0 to 1 (or false to true, or whatever else you feel like). In the flush and straight checks, also check that variable's state.
@dgh64: Go
There's no Return function? You know, to just stop doing whatever the trigger's doing at that point? Used it all the time when modding for Oblivion and Fallout 3. :x Otherwise I'll have to do that. Thanks.
Edit: Sorry for the long read, but I just jotted down my thoughts real fast. Hopefully you get what I'm trying to say.
It is possible to "break" loops and end triggers. But that's sloppy programming and you shouldn't be doing it that way.
You say that you already check for pairs so that you would not have to do that in straights. Then you say you want to check for the highest value hands first and kill the rest of the trigger when you do find one. This means that you would actually be checking for pairs after straights... maybe this works anyway since a full house contains a pair... but really, I think this gets waay too messy and you have too keep too much in mind. You should do a full check for each hand type. If you're feeling really nifty, you could make functions that look like mine, but do smaller things like, "All cards same suit?" (return true or false), "Hand contains a pair?" (return true or false), "Hand contains 3 of a kind?" (return true or false) etc. Then you can doo cool stuff like:
If you place your 13 "if then else" inside each other, it will only check for the next hand combination if the previous one failed.
I'm just throwing out ideas here and I realize that you are reluctant to change too much in your map since you seem to be nearing a finished version... but the ground work is the most important thing to get right, make it effective and all the other triggers that build on this will be childsplay.
@Berrala: Go
Ah yes, I think I get what you mean. But the thing is, I already got a way to detect pair, two pair, three of a kind, full house and four of a kind. Together with my straight check and flush check, I just have a trigger with 13 If Then Else conditions (also check for ace high and rockets) that check if you got a royal straight flush, a straight flush, four of a kind etc. all the way down. I did what dgh64 said, with a Do Once variable that makes sure no other command will run further down if my trigger finds a match higher up. And it works perfectly.
I'm still somewhat of a beginner, so I have no idea how to do custom functions and stuff. Still, using logic and some basic knowledge I managed to finish all the poker triggers in two days - and I'm really proud of that. But thanks for your help, and I'll be back once I learn a bit more. :3
Well, if it works, thats all you need to know. :-)