Issues with conditional branching

Hello, I used RMK back when it was pirated software so I'm a bit behind on the logic of the branches. It's even more embarrasing since I got the thing I'm working on to work a month back before erasing it thinking there was a better way. What I'm doing is making an item similar to the Holy Water in Dragon Quest. You know, wards enemies off based on party level versus area level. I have assigned the "encounter half" and "no encounter" to states, I even made a common event that counted down to auto removal.


Now when I'm trying to receate it I can't . I suppose I could simply use one of the encounter modifying scripts out there. But these conditional nesting things still bug me and I could use a refresher on the subject since no tutorial seems to explain how the various "Equal or Less Than" comparisons actually work.


branching_issues.jpg
Work through that logic.


If variable 9 is less than variable 8, then variable 9 cannot also be equal to or greater than variable 8.  So your "no encounters"  condition pairing will never be met.  The "encounters halved" will only ever happen if variable 9 is less than variable 8.  "no effect" will happen if variable 9 is equal to or greater than variable 8 (since that conditional branch will be false, so it will go to the else clause).


Maybe you should explain the logic of what you want to happen, as we can see where the event is failing, but as we don't know exactly what you want to happen, and under what conditions, we can't tell you how to correct it.
Alright. Basically, if the area level is greater than the average party level it means there is no effect. If the area level and party level are close to similar the encounter rate is halved. If the average party level is higher than the area level it means there are no encounters.
What does "close to similar" mean?  Exactly the same?  1 or 2 different?


If you wanted it to be greater, equal to, or less than, it would look something like this:

Code:
Conditional Branch: Variable [0009: Party LV] < Variable [0008: Area Lv]
  Text: No Effect
Else
  Conditional Branch: Variable [0009: Party LV] = Variable [0008: Area LV]
    Text: Encounters Halved
  Else
    Text: No Encounters
  Branch End
Branch End



If you want "close to similar" to mean 1 or 2 different (so area level 5 and party level 3 or 4, or 6 or 7), it would be a bit different - if that's the case, confirm it and I'll give you a different approach.
Now it works. But it's very unreliable and only goes towards the very extremes and I imagine that would be either hell or super easy to exploit. Like hitting a mosquito with a hammer. I realize going into this without clear definitions is a bit irresponsible. Having it be a little more loose like you mention would probably make it more effective.
Okay, so what we need to do is set a variable to be the difference between the party level and the area level.  If we say it's party level - area level, then if the variable is positive, the party level is higher, but if it's negative, the party level is lower.  If it's 0, they're the same.


The following example shows how you would have normal encounters if the party level is more than 2 below the area level, no encounters if the party level is more than 2 higher, and halved encounters if the party level and area level are 2 or less apart.

Code:
Control Variables: 0010: Level Difference = Variable 0009: Party LV - Variable 0008: Area LV
Conditional Branch: Variable 0010: Level Difference > 2
  Text: No Encounters
Else
  Conditional Branch: Variable 0010: Level Difference < -2
    Text: No Effect
  Else
    Text: Encounters Halved
  Branch End
Branch End
I think I set it up right, But I don't know, the minus and equal signs are not the same as the example and the party lv seems to default to zero no matter what I set the levels at.

branching_issues02.jpg
You've used the wrong variable in the second Control Variable statement.  It should be Control Variables: 0014: Level Difference -= Variable 0008: Area LV.
Ah stupid me. It's getting quite late/early in the morning here and medication has been making me loopy the last few hours.. If I go to bed will the thread stay up or does the topic expire after a certain ammount of time?


EDIT: No, wait. I tried it and it works now!


I thank you for all your patience with this medicine drunk loon. I quite like this little thing I'm making and now all my exploration skills are comple. Thank you!
topics don't expire.  It'll be here waiting for you 🙂

Original thread: https://forums.rpgmakerweb.com/threads/issues-with-conditional-branching.55423/