Jump to content
Chaos Krux

Conditional Branch Check for Encounters

Recommended Posts

Greetings~ It is I, here to annoy you all once again with another question~ Sorry~
I while ago I made an item in my game that allows the player to disable random encounters for a limited number of steps, much like a repel item in a Pokémon game. The item, along with the common event it calls, work perfectly fine as they are. The problem I'm having is that the item also works in areas that would ordinarily have encounters disabled by default. As an example, there are some locations in my project in which encounters are disabled at first, but troops are still set to appear. This is because these areas will be revisited later with encounters turned on. However, if a player was to use the repel item in one of these locations before reaching a trigger that activates the encounters, then the encounters would be turned on automatically once the repel's effect wore off, meaning that enemies would be able to appear when they shouldn't. To remedy this, I would like to add a conditional branch to my repel common event that uses the script tab to check whether or not encounters are currently turned on. This way, I will be able to prevent the item from working at all if encounters are already turned off. The problem is that I have absolutely no idea what I need to type into the script tab in order to accomplish this. I have briefly checked through all of the sections in VX Ace's script editor that I thought might be connected to encounters, but I have been unable to find any sort of command I could use for a conditional branch. And so I have decided to ask if any of you lovely people might have a solution~ It's not necessarily a huge issue, but I'd imagine it would be rather confusing for the player if enemies suddenly started popping up in previously safe areas with no clear explanation given as to why. Any and all help any of you can give would be most appreciated~ Thank you~

Share this post


Link to post
Share on other sites

I don't know your project, but one idea is to have an indicator. For me, I would just use the "show picture" command to have an indicator pop up in the corner or something and then have a parallel process running that will check time its been on and then when time is up, itll delete picture. So assuming this is an item:

 

Common event 1: 60s Repellant (<= this is what the repellent would call)

variable 1 = 60

Show Picture: Repellent_Icon

Call common event: Common Even 2: Repel


Common Event 2: Repel

Parallel Process

wait: 1 frame

conditional branch: if variable 1 == 0

  remove picture: 1

else

  variable 1: time -= 1

end

Does that make sense?

  • Confused 1

Share this post


Link to post
Share on other sites
41 minutes ago, Lord Vectra said:

I don't know your project, but one idea is to have an indicator. For me, I would just use the "show picture" command to have an indicator pop up in the corner or something and then have a parallel process running that will check time its been on and then when time is up, itll delete picture. So assuming this is an item:

 

Common event 1: 60s Repellant (<= this is what the repellent would call)

variable 1 = 60

Show Picture: Repellent_Icon

Call common event: Common Even 2: Repel


Common Event 2: Repel

Parallel Process

wait: 1 frame

conditional branch: if variable 1 == 0

  remove picture: 1

else

  variable 1: time -= 1

end

Does that make sense?

My apologies, perhaps I wasn't clear. The Repel Item itself works perfectly fine, and the common events do not need any changes to make them function properly. The question I am asking is if there is any sort of script command I could use in a Conditional Branch in order to check whether or not encounters are currently on or off?

Share this post


Link to post
Share on other sites

You know, it would probobly be a better idea to have the item/event give a state with the party ability feature 'Encounter None' instead of turning encounters on and off via event. That's why it's there ya know. Just saying.

 

Other then that... I am not sure just knowing if encounters are on or off would be enough. I mean, could you use the item before transferring to a map with no encounters? What would happen if you used the item while under effects of the item? In general I think it's just a bad idea two have two different things that don't keep track of each other try and modify the same thing. If you really want to do it by tuning on and off encounters for the whole game for some reason, you should pobobly have the event that the item runs set a switch, have the maps you want encounters to be off in set a different switch, and have a third common event that disables encounters if either of the switches is set.

 

Still think you should set a state with 'Encounter None' on the party leader or something. You can even set and unset it via event instead of having the item directly set the event and it expiring in x steps or something if you want more control.

  • Like 1

Share this post


Link to post
Share on other sites

 

2 hours ago, Kayzee said:

You know, it would probobly be a better idea to have the item/event give a state with the party ability feature 'Encounter None' instead of turning encounters on and off via event. That's why it's there ya know. Just saying.

 

Other then that... I am not sure just knowing if encounters are on or off would be enough. I mean, could you use the item before transferring to a map with no encounters? What would happen if you used the item while under effects of the item? In general I think it's just a bad idea two have two different things that don't keep track of each other try and modify the same thing. If you really want to do it by tuning on and off encounters for the whole game for some reason, you should pobobly have the event that the item runs set a switch, have the maps you want encounters to be off in set a different switch, and have a third common event that disables encounters if either of the switches is set.

 

Still think you should set a state with 'Encounter None' on the party leader or something. You can even set and unset it via event instead of having the item directly set the event and it expiring in x steps or something if you want more control.

Well, I have already made it so that the item simply doesn't work if it's effect is already active, but I will admit I hadn't thought of the other things you mentioned. I suppose knowing whether or not encounters are on ultimately wouldn't make a difference in certain scenarios. Thanks for your input, I'll have to rethink this whole thing.

Share this post


Link to post
Share on other sites

@Chaos Krux
I think I have something.

In Game_System, there's a line which does...
@encounter_disabled = false

I'd place the following in the script check:
if @encounter_disabled = true
$game_system.encounter_disabled
OR
!$game_system.encounter_disabled

I can one hundred percent guarantee this works. Or, well, it doesn't throw any errors. The struck text is my first attempt; it throws an eval error likely because it's an if conditional in a conditional check. Oops, I blame it on the stress and this #SCAMDEMIC, among other things.
But yeah; look at me, the coding novice, actually giving you the answer you sought, or so she's hoping...

Edited by PhoenixSoul
Did my own checks and figured out what doesn't throw an error
  • Thanks 1

Share this post


Link to post
Share on other sites
8 hours ago, PhoenixSoul said:

@Chaos Krux
I think I have something.

In Game_System, there's a line which does...
@encounter_disabled = false

I'd place the following in the script check:
if @encounter_disabled = true
$game_system.encounter_disabled
OR
!$game_system.encounter_disabled

I can one hundred percent guarantee this works. Or, well, it doesn't throw any errors. The struck text is my first attempt; it throws an eval error likely because it's an if conditional in a conditional check. Oops, I blame it on the stress and this #SCAMDEMIC, among other things.
But yeah; look at me, the coding novice, actually giving you the answer you sought, or so she's hoping...

That's perfect, actually~ Exactly what I was looking for~ Thank you, Phoenix~
I also figured out a way to solve the issues Kayzee brought up, so it actually works flawlessly now~ Thank you all~

  • Like 1

Share this post


Link to post
Share on other sites

Yay! I am glad you got it to work! :3 Be careful if you are still using events and need to add a lot of special exceptions to get it to work the way you want. There might very well be edge cases neither of us thought of, and the more special exceptions something has the harder it becomes to figure out what's happening when something goes wrong.

Edited by Kayzee
  • Like 2

Share this post


Link to post
Share on other sites

 

11 hours ago, Chaos Krux said:

That's perfect, actually~ Exactly what I was looking for~ Thank you, Phoenix~

Dé rìen, mon ami.
 

1 hour ago, Kayzee said:

There might very well be edge cases neither of us thought of, and the more special exceptions something has the harder it becomes to figure out what's happening when something goes wrong.

Mmm. The Wheel of Coding Torture is very real, lolz

  • Like 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×
Top ArrowTop Arrow Highlighted