[XP]Multiple Hit Script Causing Crash

MollyAvast

Villager
Member
Joined
Jun 12, 2018
Messages
18
Reaction score
6
First Language
English
Primarily Uses
RMXP
Hello! I've encountered an issue using a script I found lately.

I was looking for a way to enable certain weapons and skills to strike enemies multiple times, and I found this script, which works perfectly for the most part. (For full disclosure, I also made the adjustment to the script that was mentioned a bit later in that thread.)

But I've run into an issue - if an enemy is hit by a multi-hit skill or weapon, and is slain before all of the hits have occurred, then the game will crash because it seems to look for a target that isn't there (assuming it's the last enemy in the battle.)

I've been searching for a solution to this, but couldn't seem to find one. Here's the setup I have for the script, in the form of a pastebin. I've also attached an image of the error message this crash gives me.

If anyone could help, it would be appreciated. Thank you in advance! <3

 

slimmmeiske2

Little Red Riding Hood
Global Mod
Joined
Sep 6, 2012
Messages
7,867
Reaction score
5,240
First Language
Dutch
Primarily Uses
RMXP

I've moved this thread to RGSS Script Support. Please be sure to post your threads in the correct forum next time. Thank you.

 

DerVVulfman

Resident Werewolf
Veteran
Joined
Jun 26, 2012
Messages
315
Reaction score
155
First Language
English
Primarily Uses
RMXP
Rather curious. The error is in the default scripts 'make_basic_action_result' , the message indicating that there's no valid target to apply an attack effect. But this method also CREATES the target too. And Blizzard's script doesn't rewrite this method. Nor does it alter any 'random_target_actor' or 'random_target_enemy' methods that the 'make_basic_action_result' requires.

Do you have any other scripts that may affect battlers or battlesystems? And if so, the script order?
 

MollyAvast

Villager
Member
Joined
Jun 12, 2018
Messages
18
Reaction score
6
First Language
English
Primarily Uses
RMXP
Hm, I tried playing around with other scripts to see if that was the issue, to no avail. Though it's completely possible that I was just not thorough enough. I do have a few others, though.

I have this multiple-hit script above every other battle system script. Below it is a script to disable enemy critical hits by MobiusXVI, then PK8's damage numbers script, then another one by MobiusXVI that allows animations to be played upon landing a critical hit. I skipped over a few that don't touch the battle system or enemies at all.

I've included pastebins of all of my settings for those scripts, if that helps. On my end, I'll play around with the order of these scripts to see if I can find a simple load order solution.
 

MobiusXVI

Game Maker
Veteran
Joined
Mar 20, 2013
Messages
383
Reaction score
91
First Language
English
Primarily Uses
tl;dr I think there's a bug in the multiple hit script. Try replacing line 219:
Code:
@phase4_step = 2 if @repeat[0] > 1 && @repeat[2] > 0
with this:
Code:
@phase4_step = 2 if @repeat[0] > 1 && @repeat[2] > 0 && not judge
Full explanation of what I *think* is going on. During the default scripts "update_phase4_step2" (aka step 2) method it calls a sub method based on the attack type (either "make_basic_action_result", "make_skill_action_result", or "make_item_action_result"). All of these methods eventually call "smooth_target_enemy" if the actor is attacking an enemy and their target isn't forced. The problem is that this method assumes (incorrectly is this case but correctly in the default system) that an enemy exists. When none exist because the party just killed that last one, it return null which causes the error.

Ok, so why does smooth_target_enemy assume this and cause a problem? Well in the default system, the battle always (well almost always) progresses in order from step 1 to 2 to 3 etc. The new system does something different. To enable multiple hits the script loops like this: 1-repeat (2-5) as often as hits-6. So it loops around between steps 2 through 5 and skips step 1. However, step 1 is necessary before step 2 as it checks to see if the party has won (i.e. all enemies are dead). If the enemies aren't all dead, then it's safe to continue onto step 2, which is where the problem is.

So what I've done is added that same check from step 1 to the end of step 5 in the new system. If all the enemies are dead, it should prevent the loop back to 2 when it's not appropriate.
 

MollyAvast

Villager
Member
Joined
Jun 12, 2018
Messages
18
Reaction score
6
First Language
English
Primarily Uses
RMXP
Hello again MobiusXVI, I appreciate you looking into this, but sadly that didn't seem to work, either. Now, it just gives me a syntax error on line 219 of that script whenever I try to boot the game. Any idea what might be causing this? I've triple-checked that I pasted it exactly as it is on the page.

Thank you in advance!
 

MobiusXVI

Game Maker
Veteran
Joined
Mar 20, 2013
Messages
383
Reaction score
91
First Language
English
Primarily Uses
Looks like I just missed a set of parenthesis. Try this:
Code:
@phase4_step = 2 if @repeat[0] > 1 && @repeat[2] > 0 && (not judge)
 

MollyAvast

Villager
Member
Joined
Jun 12, 2018
Messages
18
Reaction score
6
First Language
English
Primarily Uses
RMXP
There we go! It works perfectly, now!

Thank you very much- you've saved me again :)

And thank you, too, DerVVulfman!
 

bblizzard

Veteran
Veteran
Joined
Nov 6, 2017
Messages
386
Reaction score
385
First Language
Croatian
Primarily Uses
RMMV
@MollyAvast Can you please try these two variants, too?

Code:
@phase4_step = 2 if @repeat[0] > 1 && @repeat[2] > 0 && !judge
Code:
@phase4_step = 2 if @repeat[0] > 1 && @repeat[2] > 0 && (!judge)
The script should actually use "!" instead of "not". I'll make sure to properly fix it on my end.
 

bblizzard

Veteran
Veteran
Joined
Nov 6, 2017
Messages
386
Reaction score
385
First Language
Croatian
Primarily Uses
RMMV
@MobiusXVI Yup. See here: https://www.techotopia.com/index.php/Ruby_Operator_Precedence
"&&" has precedence over "||" which is as it should be. But "and" and "or" have the same precedence. A line like
Code:
a || b && c
will be evaluated properly (first "a", and only if it's false, then "b && c") while a line like
Code:
a or b and c
will be evaluated wrong (first "a or b" and if it's false, then "c"). Or it was vice versa like "a and b or c" or something like that. I don't remember the exact use case anymore. In any case, "and" and "or" are messed up.

This is also why "!" needs to be used instead of "not". "not" has a lower precedence than the "&&" and "||" operators.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

Our latest feature is an interview with... me?!

People4_2 (Capelet off and on) added!

Just beat the last of us 2 last night and starting jedi: fallen order right now, both use unreal engine & when I say i knew 80% of jedi's buttons right away because they were the same buttons as TLOU2 its ridiculous, even the same narrow hallway crawl and barely-made-it jump they do. Unreal Engine is just big budget RPG Maker the way they make games nearly identical at its core lol.
Can someone recommend some fun story-heavy RPGs to me? Coming up with good gameplay is a nightmare! I was thinking of making some gameplay platforming-based, but that doesn't work well in RPG form*. I also was thinking of removing battles, but that would be too much like OneShot. I don't even know how to make good puzzles!
one bad plugin combo later and one of my followers is moonwalking off the screen on his own... I didn't even more yet on the new map lol.

Forum statistics

Threads
106,035
Messages
1,018,454
Members
137,821
Latest member
Capterson
Top