Win Battle if All Enemies Have State?

Psykai

Veteran
Veteran
Joined
Dec 8, 2017
Messages
104
Reaction score
4
First Language
English
Primarily Uses
RMVXA
I say it everytime "Hopefully this will be simple enough" and it never is, lol. Let's see if today's any different!

My game has a character with the ability to calm and tame animals and what I want is a way for the player to win a battle if the animal tamer calms the enemies down rather than killing them. They do this by afflicting them with a 'Soothed' status, which makes the enemy unable to act for a while (but is removed by damage, so you have to commit to the non-violent approach). Some enemies naturally will be easier to calm than others.

In-game design terms: I want the game to treat Soothed in a similar manner to how Final Fantasy treats Petrify, in that it counts as death if the entire troop is affected.

I thought all I would have to do is edit this in BattleManager:
Code:
  #--------------------------------------------------------------------------
  # * Determine Win/Loss Results
  #--------------------------------------------------------------------------
  def self.judge_win_loss
    if @phase
      return process_abort   if $game_party.members.empty?
      return process_defeat  if $game_party.all_dead?
      return process_victory if $game_troop.all_dead?
      return process_abort   if aborting?
    end
    return false
  end
And change it to this:
Code:
  #--------------------------------------------------------------------------
  # * Determine Win/Loss Results
  #--------------------------------------------------------------------------
  def self.judge_win_loss
    if @phase
      return process_abort   if $game_party.members.empty?
      return process_defeat  if $game_party.all_dead?
      return process_victory if $game_troop.all_dead?
      return process_victory if $game_troop.all_stateaffected(42)?
      return process_abort   if aborting?
    end
    return false
  end
However this resulted in an error stating that the 'aborting' line was missing a colon, which makes no sense because it's not like there was one there already :S I tried moving my new line BELOW aborting but that resutled in a 'expected 'end'' error. Am I simply placing this in the wrong order? Did I write the line wrong (should I remove the word 'all_' or something)?

I would really rather not make this a battle event that I have to copy to every troop, plus there would be no way to earn gold and experience if I did it that way.

Hopefully this is simple T_T I'm so exhausted from trying to fix stuff that should take 5 minutes but takes a whole day instead.
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
5,599
Reaction score
6,552
First Language
Indonesian
Primarily Uses
RMVXA
Code:
return process_victory if $game_troop.all_stateaffected(42)?
You put the question mark after ()
Assume you really have that method in Game_Troop
 

Psykai

Veteran
Veteran
Joined
Dec 8, 2017
Messages
104
Reaction score
4
First Language
English
Primarily Uses
RMVXA
Oh I assumed the ? had to be the last thing in the line. So it's "stateaffected?(42)" at the end instead?

And I need to edit something in Game_Troop too? I'm completely alien to script editing so I've no idea where to look or what I need to change, and what to change it to.
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
5,599
Reaction score
6,552
First Language
Indonesian
Primarily Uses
RMVXA
You can't just assume a method exists and write it right away. Like, why do you assume the method all_stateaffected() exist?
Code:
  #--------------------------------------------------------------------------
  # * Determine Win/Loss Results
  #--------------------------------------------------------------------------
  def self.judge_win_loss
   if @phase
     return process_abort   if $game_party.members.empty?
     return process_defeat  if $game_party.all_dead?
     return process_victory if $game_troop.all_dead?
     return process_victory if $game_troop.members.all? (|m| m.state?(42))
     return process_abort   if aborting?
   end
   return false
  end
Try this instead.
 

Psykai

Veteran
Veteran
Joined
Dec 8, 2017
Messages
104
Reaction score
4
First Language
English
Primarily Uses
RMVXA
I haven't heard the term method before and I thought maybe RPG Maker had in-built recognition for certain kinds of statements and I thought I'd seen terminology like 'if stateaffected' before within parts of the default scripts and my faulty logic assumed I could just write the same line elsewhere and it'd work :blush: This is why I don't play with scripts normally and prefer to use ones that others have already written. I originally wanted to use Hime's Alternate Death Conditions script which lets you tag states as death-like but sadly it's for MV only :(

I pasted your code in and received this upon trying to open the game:
"Script 'BattleManager line 195: SyntaxError occurred.
unexpected '|'
... if $game_troop.members.all? (|m| m.state?(42))"

Was I supposed to replace any of that with something else?
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
5,599
Reaction score
6,552
First Language
Indonesian
Primarily Uses
RMVXA
Ah, it's supposed to be {}
Code:
... if $game_troop.members.all? {|m| m.state?(42)}
This is why u shouldn't code after u wake up.
 

Psykai

Veteran
Veteran
Joined
Dec 8, 2017
Messages
104
Reaction score
4
First Language
English
Primarily Uses
RMVXA
Haha I'm just glad it wasn't me dude. I was like "Ok, all I did was copy and paste... HOW did I even mess THAT up?" :guffaw: Knowing me it wouldn't have surprised me if I had.

I just tested it out in battle and it worked flawlessly! :) Thank you so much! And I'm sorry I'm such a dunce. I hate wasting people's time because I'm too stupid to 'get it'.

A thought occured to me that if the player wasn't keeping track of their state-afflictions, they might not realize WHY they won the battle. How difficult would it be for a message to pop on screen before the victory screen rolls, saying something like "the enemy troop was subdued" or something? If it'd be too complicated then I wouldn't bother with it and just let the player work it out, lol. I tend to overthink things like this and worry "oh what if they're mad at me for not making it clearer" lol
 

DerVVulfman

Resident Werewolf
Veteran
Joined
Jun 26, 2012
Messages
315
Reaction score
155
First Language
English
Primarily Uses
RMXP
..... Er, I think you better consider mix and match. Your code assumes two things:
1) It runs Victory if 'ALL the enemies are dead' or
2) It runs Victory if 'ALL the enemies are under state 42'

You're not considering that some are dead and some are under state 42.

Oh, hey Theo! Long time no text. :cutesmile:
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
5,599
Reaction score
6,552
First Language
Indonesian
Primarily Uses
RMVXA
@DerVVulfman lol you're right. And hello there!

@Psykai maybe you better to consider those point above.
 

Psykai

Veteran
Veteran
Joined
Dec 8, 2017
Messages
104
Reaction score
4
First Language
English
Primarily Uses
RMVXA
Oh, err, I didn't think about that. Sounds ..................... tricky. How would I make that work? Without tearing even more of my hair out, I mean ... :guffaw:
 

DerVVulfman

Resident Werewolf
Veteran
Joined
Jun 26, 2012
Messages
315
Reaction score
155
First Language
English
Primarily Uses
RMXP
Er...

Code:
  #--------------------------------------------------------------------------
  # * Determine Win/Loss Results
  #--------------------------------------------------------------------------
  def self.judge_win_loss
   if @phase
    heroes_won = true
    for member in  $game_troop.members
      heroes_won = false unless member.dead? or member.state?(42)
    end
    return process_abort   if $game_party.members.empty?
    return process_defeat  if $game_party.all_dead?
    return process_victory if heroes_won
    return process_abort   if aborting?
   end
   return false
  end
Mebby this?
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
5,599
Reaction score
6,552
First Language
Indonesian
Primarily Uses
RMVXA
Code:
  #--------------------------------------------------------------------------
  # * Determine Win/Loss Results
  #--------------------------------------------------------------------------
  def self.judge_win_loss
   if @phase
    return process_abort   if $game_party.members.empty?
    return process_defeat  if $game_party.all_dead?
    return process_victory if $game_troop.members.all? (|m| m.dead? || m.state?(42))
    return process_abort   if aborting?
   end
   return false
  end
 

Psykai

Veteran
Veteran
Joined
Dec 8, 2017
Messages
104
Reaction score
4
First Language
English
Primarily Uses
RMVXA
Thanks guys :)

Copied Theo's script in and after changing the () to {} again it worked :) Did a test battle, killed two of the enemies, soothed the last one and the battle ended fine :)
 

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

Latest Threads

Latest Profile Posts

Day 9 of giveaways! 8 prizes today :D
He mad, but he cute :kaopride:

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.

Forum statistics

Threads
106,036
Messages
1,018,461
Members
137,821
Latest member
Capterson
Top