Vlue Proximity Script Zero Division Error

Hello folks.

At the moment, I'm trying to implement a system in my game where enemies roam the field, and if you get close enough the enemies will start pursuing you. Of course, once the enemies touch you, you will engage in battle. If you get far away enough from the pursuing enemy, then that enemy will stop chasing and return to its previous movement patterns. Since I can't seem to figure out how to do this without scripts, I resorted to using Vlue's Proximity Script:

http://pastebin.com/kCL50nSC

For the most part, the script was working as intended. However, whenever the player gets touched by more than one enemy at a time, the game always crashes with this error after the player wins the battle:

Script 'Window Selectable' Line 61: Zero Division Error occurred. Divided by 0.

Since I know nearly nothing about scripting, I'm at a loss as to what's causing this problem. If anyone can help me, I'd really appreciate it.

If it helps, here are all the other custom scripts I'm using besides Vlue's Proximity Script:

- Yanfly ACE Battle Engine

- Yanfly Enemy HP Bars

- DT's One Person Menu

- Fomar0153's Faces to Busts

- ACE Battle Engine Revival Glitch Fix
Can you show us one of your events that initiates a battle?


And when does it crash - at the end of a battle, while you're still on the battle screen? Or is it when you come back to the map? Does it seem like it's attempting to start a second battle?


Given that Window Selectable is not used at all by the proximity script, I'm more inclined to think the issue is with the Yanfly battle engine. To be sure, if you follow Galv's instructions in this post and add Mithran's crash debugger to your project, turn on the console, and play through to get a crash, it should give you the exact hierarchy of what is calling what, so we can see what is initiating the error.


You should also try and create a brand new project and use JUST the proximity script to see if you can duplicate it. The solution MAY be as simple as changing your events to do a quick check, and only enter battle processing if there isn't currently a battle going on.
I see. Well, I'll try to get the crash debugger and come back later with the results.

But yeah, I always get the error after the victory message is displayed. Like, the process goes like this:

1.) Player gets touched by two or more enemies simultaneously.

2.) Commence first battle.

3.) First battle is won. EXP, Gold, and Item rewards are displayed.

4.) Screen fades to black, attempting to either exit the battle or start the second one.

5.) Zero Division Error occurs during black screen and game shuts down. The game never gets to go back to the field map.
Sorry for the bump, but I have finally installed the debugger and replicated the problem. The crash log then recorded this after the zero division error crash:

Time: 2013-08-05 17:54:41 -0700
Critical Object #<Sprite_Popup:0x910eab0>
In Scene NilClass
Caller::
{0121}:881:in `create_new_popup'
{0121}:865:in `setup_popups'
{0121}:854:in `setup_new_effect'
{0045}:42:in `update'
{0124}:225:in `update'
{0050}:333:in `block in update_enemies'
{0050}:333:in `each'
{0050}:333:in `update_enemies'
{0050}:311:in `update'
{0117}:59:in `update_basic'
{0121}:2576:in `update_basic'
{0117}:67:in `update_for_wait'
{0117}:98:in `wait_for_message'
{0007}:162:in `call'
{0007}:162:in `wait_for_message'
{0007}:322:in `gain_gold'
{0007}:207:in `process_victory'
{0007}:194:in `judge_win_loss'
{0121}:2634:in `debug_kill_all'
{0121}:2588:in `update_debug'
{0121}:2577:in `update_basic'
{0100}:41:in `update'
{0117}:45:in `update'
{0100}:14:in `main'
{0126}:201:in `main'
{0006}:23:in `run'
{0131}:7:in `block in <main>'
:1:in `block in rgss_main'
:1:in `loop'
:1:in `rgss_main'
{0131}:7:in `<main>'
ruby:in `eval'
mahoshojo03, please avoid double posting, as it is against the forum rules. You can review our forum rules here. Thank you.


Please use the Edit button to add extra information unless your last post is 72 hours old.


Is that message from the console, or from the log file? I'm after the message from the console.
I'm sorry, but I obtained this from the log file (I think it's the notepad file named "gobj"). How exactly do I obtain the console message?
You play the game with the console turned on. Menu > Game > Show Console.


The log file will only tell you what sprites are in use when the crash happened. It's not really relevant to what caused the crash. The console message at the time of the crash will give you the error message (division by 0) and tell you where it happened (Window_Selectable, line 61). The other important thing it will tell you is what method from what other class made it try to run Window_Selectable, line 61, and what called that, and what called that, and so on. Usually, while one line generates the error, it's another line somewhere else back up the hierarchy that caused it to run with something not set up quite right.

Original thread: https://forums.rpgmakerweb.com/threads/vlue-proximity-script-zero-division-error.16485/