Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Battle Event upon Party KO? (RpgXP)

I tried searching the forums but I wasn't able to find anything about this after the first 7 or 8 pages of browsing.. so I apologize if this has already been answered before.

What I'm trying to do is run a Battle Event in a Random Battle for when the Party dies. Normally, when the party dies, you instantly go to the Gameover screen. Basically, I want there to be some text and pictures before the gameover screen comes up.

I tried setting the conditions to:
CONDITION: Actor's HP 0% or Below
SPAN: Battle (Tried Moment and Turn too)

Unfortunately, once dead, it instantly goes to the gameover screen.

I know that if the battle is not random, but rather an event on the map, this can be done by Ending the battle upon KO and then running the final event before bringing up a gameover, but I'm trying to do it for Random Troop battles too.

Am I messing up somehow? Is this even possible? Or do I have to disable the Gameover script and bring it up manually to overcome this problem?

The purpose behind this (for those who are curious) is so that the player gets a unique death message for what kills him.
 
Your best bet would probably be to modify the gameover script. My guess would be to edit Scene_Battle 1, line 116 and set it to false, then in your commands show a message and then manually initiate gameover. I haven't tested it, though.
 
I tried changing just line 116 to "false," but unfortunately the Game Over screen still came up instantly. I tried fiddling with other lines, always making sure to hit Apply before hitting OK, but nothing even seemed to have an effect on the battle.


Lines 278 - 282
# If game over
if $game_temp.gameover
# Switch to game over screen
$scene = Scene_Gameover.new
return
end
Tried disabling that... no effect.


Lines 194 - 200
# Confirm actor conditions
if c.actor_valid
actor = $game_actors[c.actor_id]
if actor == nil or actor.hp * 100.0 / actor.maxhp > c.actor_hp
next
end
end
Thought maybe if it couldn't confirm that the player had 0 HP then it wouldn't start the gameover... no effect.


Just for kicks, I disabled the ENTIRE "Determine Battle Win/Loss Results"... and oddly enough, it didn't have any effect on the game whatsoever.

I don't really know the RGSS system well... but my only two guesses are that either these are grabbing info/coding from somewhere else that's superceding it, or the game's Battle Test runs on different coding that isn't being affected by any changes.
 
An idea I had.. I was wondering if Immortality could be used to achieve this?

I don't see any checkbox for such a thing, so I assume immortality has to be granted via scripting of some kind.

Basically, would immortality prevent any HP from lowering, or would it stop at 1? Cause if it's the latter, then I could set the Conditions to "1% or below." If it can go all the way to zero, but the player never dies, then my original Condition should work. If it doesn't reduce any HP... then... damn.

The only way other than this would be to somehow disable the Gameover Auto-Run, but no matter what I change or disable it seems to continue running unimpeded.
 
I don't know about immortality, but try this:
1.make a common event
doxbeforescene_gameover.png


2. make Scene_Battle 1 (lines 278 - 282) activate this event, instead of going to Scene_Gameover.
Code:
# If game over

    if $game_temp.gameover

      $game_switches[4] = true

      $game_temp.gameover = false

      $game_variables[1] = @troop_id

      # Return to BGM used before battle started

      $game_system.bgm_play($game_temp.map_bgm)

      battle_end(1)

      # Switch to game over screen

      #$scene = Scene_Gameover.new

      return

    end

Variable 001 should now hold the troop id (troop number in the database), so you can do different things for every enemy.
 
I feel like an idiot because I just can't seem to wrap my head around the logic used in scripting, when it seems to go against all logic in the end.

I don't quite understand where the Troop Variable would come into play.

I tried copying everything you wrote, though I didn't touch the troop.id at all since I just don't know anything, and what I ended up with was:

1. Party is KO'd
2. Screen fades to black (instead of a game-over screen coming up)
3. Kicked out of Battle Test

I never would've thought that I'd have so much trouble figuring this out, considering there's a condition that specifically lets you play an event when a party reaches 0%... and yet that doesn't work cause it goes to a Gameover instead... :\

I don't want to become a beggar who has to have his hand held every step of the way, or make someone else do all the work, but I'll try to understand what you wrote so that I can find the error.


So, game over is called.
It activates Switch 4.
Common Event X is called up since Switch 4 is the condition.
Common Event X plays, and once done it turns off Switch 4 and calls Gameover.

...But wouldn't Switch 4 then re-activate because it's at the top of the tree for the Game Over section, thus restarting the Common Event?
 
Kleptomaniac":1zfgtmhm said:
1. Party is KO'd
2. Screen fades to black (instead of a game-over screen coming up)
3. Kicked out of Battle Test

Oh.. sorry, The script isn't meant to be used from Battle Test. You must play the game and go into battle.
It's possible to make this work in Battle Test, her's how to fix it:
This is a new method, there's no need for a common event here, so delete it.
now, use this code, and edit the troop's pages like this:
doxbeforegame-over2.png


I tested the code, it works- both in Battle Test and when playing the game.
Make sure you do this for every troop (just copy-paste the 2 pages)
About the troop id, I simply saved the the troop number in variable 001. You don't need it if you use the new script, since every troop has a page handling the "game over" scenario.
 
Thank you! I copied everything and it worked flawlessly in the game. It did come up with an error during Battle Test, however. Here's what happened:

1. Monster KO's player
2. Player is set back to 1 HP (No text pops up)
3. Monster KO's player again
4. Error message pops up:

Script 'Scene_Battle 1' line 280: NameError occured.

uninitialized constant Scene_battle::SceneGameover

At first I thought it was another dead end, but I tried running it in the game, and it worked exactly. Player was KO'd, text popped up, then the Gameover.

I really appreciate all the work you did in helping me get this, and I hope other people also benefit from this script.

EDIT: I did make a typo before and had corrected it, but it was still giving me the error. Seems I had to restart RPG Maker entirely for it to notice the change. Script now works flawlessly in game and in battle test.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top