help with controlling Variables with common events

Hello,

I am trying to use variables to track damage exchanged between 2 groups,4 subgroups in each group. It works fine, except the variables go to negative numbers. I set up a common event to ensure the variables do not go below 0, and inserted the common event call below the label in the event page. Here is the common event I am using:

The numbers are still getting negative values. I have intermediate experiance with RPG maker. Any help would be appreciated.

New Bitmap Image.bmp
Seems like your common event isn't being called.


How are your variables used? Where (apart from this common event) are they being updated? Go to those places, and add a Call Common Event after they are updated, to make sure your common event runs.


If you want it to ALWAYS be running (and I don't recommend it), you would need to set it up as a parallel process (in the common event trigger), add a switch as a condition, then turn on the switch at the beginning of the game. I can't see if you've actually done that, because you've only provided the list of event commands. Whenever you ask for help with anything to do with events, ALWAYS show the whole window - it includes the trigger type and any conditions, which is what I'm referring to here, and can't see because you've cropped your image to remove some of the important stuff.
parallel processes don't work on battlescreen.


When do you want those variables to be checked? What type of battles do you use?


And please, always provide the entire windows in the screenshot - events are more than just the content, and the setting options are neccessary to see how the event behaves.
oh - I assumed it was meant to be run outside of battle. You're right - didn't even think about that.
First, thank you for the quick reply.

Shaz, you are right it is used outside of battle....

I am trying to simulate an army battle ala suikoden 1, with 2 armies and 4 groups. Archers, light infantry, heavy infantry, and cavalry. I have set it up as an event page to assign 8 variables certain values before the "battle". Think of it as a mini game used to represent an army battle in my game. I will endeavor to give as much info as possible. I have the common event in one bmp with the full screen, and the event page in another, and finally the error message when I try to use this common event. The error says it is an error in the syntax of the script I wrote.

The idea is a group is either strong or weak against another group. Against the same they lose about the same. For the same I took the value of the player army, divided by 2, subtracted the result from the opposite side, and multiplied the player army by two to get original result, and subtract the new enemy number from the player army group. For a group strong, divide and multiply the same for the strong group, and divide and multiply by 4 for the weaker.

The problem is when the variable is reduced below 0. I am trying to make it not drop below zero. I know this may make the computer use 0 number groups, but the main issue is I have a variable for representing the total army strength, that add the values of the four variables as seen in the event page.These are the variables I am attempting to use to base a conditional branch on to decide if the player wins or loses the battle. before I tried to use this common event the second issue I have other than the negative numbers is using this conditional branch. When either group runs out of troops (the total variable 82 or 83) drops below zero, the event says both you won and are out of troops, and goes to the self switch A, which states that they were beaten. (This is an issue as in my vision the results will be either the battle is won or it is game over, this is set up this way as a test before implementation.)

In the event image it reads 1-2-3

                                            4-5

from 4, I go to the end, as the event page is extremely long. I select a random number 1-4 to represent the choice the computer makes, and so the script repeats with minor variation, adjusting the formulas and variables used due to which two groups battle at that point, then going back to the fight! label.

Sorry for the long post, any help is appreciated.

Note...I will attach files on three posts, as I am limited on how much I can post.

error.bmp
Event pages

rsz_event_page.jpg

New Bitmap Image.bmp
Realized the size change on the last event page image is unreadable, here is a better one...

rsz_1event_page.jpg
gnosis234, please avoid double posting, as it is against the forum rules. You can review our forum rules here. Thank you.


Please just use the Edit button and change your post instead of double (or triple) posting. Also, even the second version is unreadable. If you have to provide screenshots, just do individual screenshots and provide several links or images (if images, put them in spoiler tags so the reader can open/close them as needed).


There are several distinct points in those events where the variables are changed. After each "group" of variable changes, add a Call Script event command, and call your common event. So the variables will be changed by the events, then your common event will be immediately called and will fix any negative values.
Thank you for the help, I'll try that.

Sorry about the triple posting....had a brain dump and didn't realize I could edit the post. That was why I re-submitted the event page, it was unreadable. I could have edited it and removed the unreadable one...oh well, I learned for future reference. I'll let you know later if it worked.

Original thread: https://forums.rpgmakerweb.com/threads/help-with-controlling-variables-with-common-events.23370/