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.

[Resolved]I think this request sounds simple...

Status
Not open for further replies.
I'm still trying to learn Scripting myself...but until then, I was hoping someone could give me a hand here...

I would like a script (if one doesn't already exist, and I've checked and couldn't find one) that constantly checks all active player's hp. If at anytime ONE of those players reaches zero (dead), either IN OR OUT OF BATTLE, it's Game-over, REGARDLESS OF THE STATUS OF THE OTHER CHARACTERS!!

So this script should do two things:

#1: All you would need is one dead character to end the game, rather than the whole party!
(Don't ask why, It works for the game I am designing:yes:)

...and before you ask, NO my game does not have life-restoring items AKA Phoenix Down!!

#2: Currently, I've found that setting event-based traps that sets the Dead Status to a character/s, they are listed dead but the game doesn't end EVEN IF THEY ARE ALL DEAD, giving you time to recover (it won't Game-over unless triggering a battle). This proposed script would correct that problem (cause a whole team of dead guys walking around saving the world JUST doesn't sound right, you know?)

http://img233.imageshack.us/img233/5310/examplekx1.th.png[/IMG]
(See Image? They're all dead, yet still going..and going..and going..

This would be useful for all the lethal traps in my game (which could be set off if the player is stupid and didn't pay attention)
(Again, don't ask why)

EDIT: NOW THAT I THINK ABOUT IT, SETTING EVENT-BASED TRAPS TO TRIGGER THE GAME-OVER SCREEN DIRECTLY MAY SUCCEED THE SECOND PART!

Think of this script as the Banon of FFVI. If you ever played it, you know that while he was on the team, if he ever died...GAMEOVER...no matter the other characters.

Any further questions, ask.

..and no, I don't necessarily NEED this script, but having it would be nice.

That is all!
 
This can be done pretty simply with a comment event (well, if you don't have a huge amount of characters).

Just setup a parallel common event like this:

Var: xxx*:hero_hp = Hero 1's HP
Conditional Branch: If Var xxx = 0
Game Over
<>
Else
<>
Var: xxx:hero_hp = Hero 2's HP
Conditional Branch: If Var xxx = 0
Game Over
<>
Else
<>
etc.

*any unused variable number

But if you don't want to do that, I might be able to come up with something later. Maybe.
 

Abbey

Member

If you want to do that in a script, you can find this in Game_party:
Code:
def increase_steps
@steps = [@steps + 1, 9999999].min
  end

and add this after it:

Code:
def one_is_dead
    for actor in @actors
      if actor.hp == 0
        $scene = Scene_Gameover.new
      end
    end
  end

Then, in Game_Map, add this in def update
Code:
$game_party.one_is_dead

I'm working on the battle one right now, but I'm on a very slow computer...
 
If you want to do that in a script, you can find this in Game_party:
Code:

def increase_steps
@steps = [@steps + 1, 9999999].min
end

and add this after it:

Code:

def one_is_dead
for actor in @actors
if actor.hp == 0
$scene = Scene_Gameover.new
end
end
end

Then, in Game_Map, add this in def update
Code:

$game_party.one_is_dead

Looks good. I'd test it now, but I'm at work. Looking at the script's setup, I'm sure it will work just fine :thumb:

I'm working on the battle one right now, but I'm on a very slow computer...

No rush...take as long as you need ;)
 

Abbey

Member

I've gotten close to it, but I'm having a slight problem with it: It doesn't show the animation for whatever killed them. On the enemy's turn in my test game, they'd die before it even showed the enemy flash white...I can't figure out why, it looked perfect...in script...
 
Finally tested the first script...works like a beauty...no problems!

I've gotten close to it, but I'm having a slight problem with it:

Hmmm...well lets see what you've got so far, and maybe we can figure this out together, eh?

Or some random person reading this will look at the script and have the answer.
 

Abbey

Member

From what I can see, it only involves changing one line...it DOES TECHNICALLY work, but it doesn't show animation or damage...I tried making it wait a few frames after the hit, but it still doesn't show anything...

It's in game_battler1...
Code:
def hp=(hp)
    @hp = [[hp, maxhp].min, 0].max
    # add or exclude incapacitation
    for i in 1...$data_states.size
      if $data_states[i].zero_hp
        if self.dead?
          add_state(i)
        else
          remove_state(i)
        end
      end
    end
  end

all I did was $scene = Scene_Gameover.new (in a new line) after add_state(i), but that didn't work...so I tried

Code:
def hp=(hp)
    @hp = [[hp, maxhp].min, 0].max
    # add or exclude incapacitation
    for i in 1...$data_states.size
      if $data_states[i].zero_hp
        if self.dead?
          add_state(i)
          @wait_count = 40
          $scene = Scene_Gameover.new
        else
          remove_state(i)
        end
      end
    end
  end

But that only made it wait before the gameover; Still no animation or damage (so you have no idea why it's game over unless you know this is in the script)
 
Try this:
Code:
class Game_Party
  alias change_die_one_char_all_dead? all_dead?
  def all_dead?
    # If an actor is in the party with 0 HP
    for actor in @actors
      if actor.hp <= 0
        return true
      end
    end
    change_die_one_char_all_dead?
  end
end

Put it above main.
It works in battle and in the map.

Tested: SDK compatible.

And about the death status:
Do not make the traps with change status (I never saw that error, cool!).
You should set the traps as "Change HP value" with the value of sustract 9999 and check the option of permit K.O.
 
entrando2
That works perfectly in battle, but I couldn't get it to work on the map. Not a problem since I mixed it with Abbey's working map check. Both work just as I wanted them to.

Thank you Abbey and entrando2 for the help (and thank BusterSword777 also).

Topic Resolved!
 
This topic has been resolved. If FaaidDeOiad or any other users have any questions or further problems regarding this topic, please create a new thread about them.

Thank you!
 
Status
Not open for further replies.

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