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.

Party Changing Script

Hey, I just noticed something. It seems that everyone in the party gets equal experience, even if they aren't in the battle.

Is there any way to make it so only the battle party gets experience? And is it possible to make it so the non-combatants get experience, but much less than those in battle?

See, for me...giving experience points to characters that aren't in the battle is convenient, but I don't like the idea of characters gaining levels and getting stronger without doing anything...and I like this script. So I was wondering how to go about doing this...
 
Armor King 108;119648 said:
Hey, I just noticed something. It seems that everyone in the party gets equal experience, even if they aren't in the battle.

Is there any way to make it so only the battle party gets experience? And is it possible to make it so the non-combatants get experience, but much less than those in battle?

See, for me...giving experience points to characters that aren't in the battle is convenient, but I don't like the idea of characters gaining levels and getting stronger without doing anything...and I like this script. So I was wondering how to go about doing this...

Code:
class Scene_Battle
  
  def start_phase5
    @phase = 5
    $game_system.me_play($game_system.battle_end_me)
    $game_system.bgm_play($game_temp.map_bgm)
    exp = 0
    gold = 0
    treasures = []
    for enemy in $game_troop.enemies
      unless enemy.hidden
        exp += enemy.exp
        gold += enemy.gold
        if rand(100) < enemy.treasure_prob
          if enemy.item_id > 0
            treasures.push($data_items[enemy.item_id])
          end
          if enemy.weapon_id > 0
            treasures.push($data_weapons[enemy.weapon_id])
          end
          if enemy.armor_id > 0
            treasures.push($data_armors[enemy.armor_id])
          end
        end
      end
    end
    treasures = treasures[0..5]
    for i in 0...$game_party.actors.size
      actor = $game_party.actors[i]
      if actor.cant_get_exp? == false
        if i < 4
          last_level = actor.level
          actor.exp += exp
          if actor.level > last_level
            @status_window.level_up(i)
          end
        else
          actor.exp += (exp / 2) # EDIT THIS LINE
          # At the moment actors not in battle gain 50% of the exp
        end
      end
    end
    $game_party.gain_gold(gold)
    for item in treasures
      case item
      when RPG::Item
        $game_party.gain_item(item.id, 1)
      when RPG::Weapon
        $game_party.gain_weapon(item.id, 1)
      when RPG::Armor
        $game_party.gain_armor(item.id, 1)
      end
    end
    @result_window = Window_BattleResult.new(exp, gold, treasures)
    @phase5_wait_count = 100
  end
end

japanrock;119582 said:
dear fomar
can you tell me how to put your script to that Icon?
So when i Click that icon i can Call Your Script in My windows menu
cause i dont know much about script
Thank you for read my Post

I'm guessing you don't know that it is over 2000 lines long?
I had already started merging them but I'm probably not going to finish by tonight (and then I go on holiday for christmas) so you'll just have to wait.
 
I'm guessing you don't know that it is over 2000 lines long?
yes thats right in fact i dont know anything hahahaha.. sorry i dont mean to rush..

i'm very happy if you can make that happend to my project
its not a problem for me to wait cause i'm the one who need your help
but dont forget about me hehehehe
I hope you enjoy your Holiday .. Thanks for read my Post
 

Tierra

Member

Really sorry for asking such a stupid question, but I was trying to implement an 8 person party in my game using this script. I've tried to read a few FAQs on scripting and whatnot, but I still haven't been able to figure out where exactly to put all of the necessary information. I see that Fomar's on vacation, but would anyone be able to point out where to place this at? Sorry again for asking this, I know it's the type of question that annoys most people.
 

Eriel

Member

Nice script you got there, Fomar. But I encountered some error while testing it.

If my party has more than 4 characters (6 in my case), I can't get a game over scene. I tried fighting a powerful opponent, but once all my party members all wiped out the game still has the 'Fight' and 'Escape' option and won't let the 'Game Over' screen appear.

Can you please help me with my problem?
 
Tierra;120787 said:
Really sorry for asking such a stupid question, but I was trying to implement an 8 person party in my game using this script. I've tried to read a few FAQs on scripting and whatnot, but I still haven't been able to figure out where exactly to put all of the necessary information. I see that Fomar's on vacation, but would anyone be able to point out where to place this at? Sorry again for asking this, I know it's the type of question that annoys most people.

I still have some internet access (ie this is the only time I've been on today) do you mean where to place the script? If so anywhere above main and below the defualt scripts will work (insert adds another place to put scripts in the editor).

Eriel;121065 said:
Nice script you got there, Fomar. But I encountered some error while testing it.

If my party has more than 4 characters (6 in my case), I can't get a game over scene. I tried fighting a powerful opponent, but once all my party members all wiped out the game still has the 'Fight' and 'Escape' option and won't let the 'Game Over' screen appear.

Can you please help me with my problem?

Do you use a CBS that doesn't call $game_party.all_dead? if you do that's why, or it may be another script.
 

A J

Member

Mr. Fomar0153 how do we make the first 4 fight only
coz I think that I can see all the members attacking.

one more thing is there is a script that alow you to change members in the battle?

thank you :)
 

Tierra

Member

Hrmmm, after messing with it a bit I managed to get it to work but with one snag, for some reason none of character's statuses show up when you go into the menu. I'm not using any other scripts other than this one, would you happen to know what I messed up on?
 
Tierra;125254 said:
Hrmmm, after messing with it a bit I managed to get it to work but with one snag, for some reason none of character's statuses show up when you go into the menu. I'm not using any other scripts other than this one, would you happen to know what I messed up on?

What do you mean messing? If this is the only script you have, you paste it above main and edit 1 constant to use it.
 

Tierra

Member

Oh, by that I just meant trying to place everything in right. Took me awhile to figure out (at least I think I figured out) where everything went in the script. You just insert a new part for each of the "class ___"'s right above the original and paste that part right? I think I copied and pasted it all the right way, but I'm not sure why it's still doing a window error. I'm positive its just something I'm not doing right, I'm just having a hard time figuring out what. I seem to be having a problem with the reserve party members being able to attack when not in the main party, and also none of the stats can be seen in the main menu, like in your pictures.

Sorry for bugging you again, I know you've addressed the reserve party members attacking already, I just can't figure out what to put it above. Anyways, hope your trip was good and you get back safe!
 
Tierra;125817 said:
Oh, by that I just meant trying to place everything in right. Took me awhile to figure out (at least I think I figured out) where everything went in the script. You just insert a new part for each of the "class ___"'s right above the original and paste that part right? I think I copied and pasted it all the right way, but I'm not sure why it's still doing a window error. I'm positive its just something I'm not doing right, I'm just having a hard time figuring out what. I seem to be having a problem with the reserve party members being able to attack when not in the main party, and also none of the stats can be seen in the main menu, like in your pictures.

Sorry for bugging you again, I know you've addressed the reserve party members attacking already, I just can't figure out what to put it above. Anyways, hope your trip was good and you get back safe!

Allmost all of my scripts don't require you to edit an existing class yourself this one included. You just need to paste it (all in one go) above main. You can create a section for it by clicking insert when you have main selected.
As for the lack of text that is caused normally by having an illegal version of rpg maker xp.
 

Tierra

Member

Oh wow, I didn't realize how easy that was. I was over complicating things trying to paste everything individually. As for the legality thing, I was still using a demo my friend sent me before buying the real thing. Guess I should hurry up and do that before working on anything extra, didn't realize there'd be compatibility issues. Anyways, thanks again, it works great now!
 
A J;122625 said:
really thanks man

Sorry I took soo long.
Make sure the party changing script is above the battle system and then use this for the battle system:

Code:
module Fomar
  
  Attack_Cost = 500
  Skill_Cost = 750
  Defend_Cost = 250
  Item_Cost = 500
  Flee_Attempt = 100
  Refresh_Rate = 5
  
  def self.attack
    return Attack_Cost
  end
  
  def self.skill
    return Skill_Cost
  end
  
  def self.defend
    return Defend_Cost
  end
  
  def self.item
    return Item_Cost
  end
  
  def self.critical_value(n)
    return (n == Attack_Cost or n == Skill_Cost or n == Defend_Cost or n == Item_Cost)
  end
  
end

class Game_BattleAction
  
  alias cbs_clear clear
  def clear
    unless (@kind == 0 and @basic == 1)
      cbs_clear
      return
    end
    @speed = 0
    @skill_id = 0
    @item_id = 0
    @target_index = -1
    @forcing = false
  end
  
end

class Game_Battler
  
  attr_accessor :stamina
  attr_accessor :vitality
  attr_accessor :max_stamina
  
  alias cbs_initialize initialize
  def initialize
    cbs_initialize
    @stamina = 0
    @vitality = 1
    @max_stamina = 1000
  end
  
  def stamina_action_cost
    if (@current_action.kind == 0 and @current_action.basic == 1) or 
      ((@current_action.kind == 0 and @current_action.basic == 0) and 
      @current_action.target_index == -1)
      return
    end
    if @current_action.kind == 0 and @current_action.basic == 0
      @stamina -= Fomar.attack
    end
    if @current_action.kind == 1
      @stamina -= Fomar.skill
    end
    if @current_action.kind == 2
      @stamina -= Fomar.item
    end
    
  end
  
end

class Game_Enemy < Game_Battler
  
  alias cbs_make_action make_action
  def make_action
    return
  end
  
  def can_do_action?
    if @current_action.kind == 0 and @current_action.basic == 0
      return self.stamina >= Fomar.attack
    end
    if @current_action.kind == 1
      return self.stamina >= Fomar.skill
    end
    if @current_action.kind == 0 and @current_action.basic == 1
      return self.stamina >= Fomar.defend
    end
    if @current_action.kind == 0 and @current_action.basic == 3
      return false
    end
  end
  
end

class Window_BattleStatus < Window_Base
  def refresh
    self.contents.clear
    self.contents.font.size = 20
    @item_max = [$game_party.actors.size, 4].min
    for i in 0...[$game_party.actors.size, 4].min
      actor = $game_party.actors[i]
      actor_x = i * 160 + 4
      draw_actor_name(actor, actor_x, 0)
      draw_actor_hp(actor, actor_x, 25, 120)
      draw_actor_sp(actor, actor_x, 50, 120)
      draw_fomar_bar(actor_x, 80, ((actor.stamina * 100)/actor.max_stamina), 120)
      if @level_up_flags[i]
        self.contents.font.color = normal_color
        self.contents.draw_text(actor_x, 100, 120, 32, "LEVEL UP!")
      else
        draw_actor_state(actor, actor_x, 100)
      end
    end
  end
  
  def redraw_bars
    for i in 0...[$game_party.actors.size, 4].min
      actor = $game_party.actors[i]
      actor_x = i * 160 + 4
      draw_fomar_bar(actor_x, 80, ((actor.stamina * 100)/actor.max_stamina), 120)
    end
  end
  
  def draw_fomar_bar(x, y, full = 100, width = 128)
    self.contents.fill_rect(x, y, width, 20, Color.new(0, 0, 0, 255))
    self.contents.fill_rect(x + 2, y + 2, width - 4, 16, Color.new(255, 255, 255, 255))
    width *= full
    width /= 100
    # full is a percentage
    self.contents.fill_rect(x +2, y + 2, width - 4, 16, Color.new(255, 0, 0, 255))
  end
end

class Scene_Battle
  
  alias cbs_main main
  def main
    @fleeing = false
    @flee_attempt = 0
    @refresh_rate = 0
    @enemy_decision = 0
    for actor in $game_party.actors
      actor.current_action.cbs_clear
    end
    cbs_main
  end
  
  alias cbs_update update
  def update
    if @refresh_rate == Fomar::Refresh_Rate
      @status_window.redraw_bars
      @refresh_rate = 0
    else
      @refresh_rate += 1
    end
    cbs_update
  end
  
  alias cbs_start_phase2 start_phase2
  def start_phase2
    @fleeing = false
    cbs_start_phase2
  end
  
  def update_phase2_escape
    @fleeing = true
    @flee_attempt = 0
    start_phase3
  end
  
  def end_phase2
    @party_command_window.active = false
    @party_command_window.visible = false
  end
  
  def start_phase3
    end_phase2
    @phase = 3
    @actor_index = 0
    @active_battler = $game_party.actors[0]
    $game_party.clear_actions
    unless @fleeing == true
      phase3_setup_command_window
    end
  end
  
  def phase3_setup_command_window
    phase3_make_command_window
    @party_command_window.active = false
    @party_command_window.visible = false
    @actor_command_window.active = true
    @actor_command_window.visible = true
    @actor_command_window.x = @actor_index * 160
  end
  
  def phase3_make_command_window
    unless @actor_command_window == nil
      @actor_command_window.dispose
    end
    s1 = $data_system.words.attack
    s2 = $data_system.words.skill
    s3 = $data_system.words.guard
    s4 = $data_system.words.item
    @actor_command_window = Window_Command.new(160, [s1, s2, s3, s4])
    @actor_command_window.y = 160
    @actor_command_window.back_opacity = 160
    unless @active_battler.inputable?
      @actor_command_window.disable_item(0)
      @actor_command_window.disable_item(1)
      @actor_command_window.disable_item(2)
      @actor_command_window.disable_item(3)
      return
    end
    unless @active_battler.stamina >= Fomar.attack
      @actor_command_window.disable_item(0)
    end
    unless @active_battler.stamina >= Fomar.skill
      @actor_command_window.disable_item(1)
    end
    unless @active_battler.stamina >= Fomar.defend
      @actor_command_window.disable_item(2)
    end
    unless @active_battler.stamina >= Fomar.item
      @actor_command_window.disable_item(3)
    end
  end
  
  alias cbs_update_phase3 update_phase3
  def update_phase3
    if judge
      return
    end
    cbs_update_phase3
    if @actor_command_window.active == true or @fleeing == true
      @enemy_decision += 1
      if @enemy_decision == 50
        @enemy_decision -= 50
        resolve = false
        for enemy in $game_troop.enemies
          enemy.cbs_make_action
          if enemy.can_do_action?
            resolve = true
          else
            enemy.current_action.clear
          end
        end
        if resolve == true
          @check_index = @actor_index
          start_phase4
          return
        end
      end
    end
    if @fleeing == true
      if Input.trigger?(Input::B)
        start_phase2
      end
      @flee_attempt += 1
      if @flee_attempt == Fomar::Flee_Attempt
        enemies_agi = 0
        enemies_number = 0
        for enemy in $game_troop.enemies
          if enemy.exist?
            enemies_agi += enemy.agi
            enemies_number += 1
          end
        end
        if enemies_number > 0
          enemies_agi /= enemies_number
        end
        actors_agi = 0
        actors_number = 0
        for actor in $game_party.actors
          if actor.exist?
            actors_agi += actor.agi
            actors_number += 1
          end
        end
        if actors_number > 0
          actors_agi /= actors_number
        end
        success = rand(100) < 50 * actors_agi / enemies_agi
        if success
          $game_system.se_play($data_system.escape_se)
          $game_system.bgm_play($game_temp.map_bgm)
          battle_end(1)
        else
          @flee_attempt -= Fomar::Flee_Attempt
        end
      end
    end
    if @active_battler != nil
      if Fomar.critical_value(@active_battler.stamina)
        i = @actor_command_window.index
        k = @actor_command_window.visible
        l = @actor_command_window.active
        phase3_make_command_window
        @actor_command_window.x = @actor_index * 160
        @actor_command_window.index = i
        @actor_command_window.visible = k
        @actor_command_window.active = l
      end
    end
    if @actor_command_window.active
      if Input.trigger?(Input::LEFT)
        @actor_index -= 1
        if @actor_index == -1
          @actor_index = [$game_party.actors.size, 4].min - 1
        end
        @active_battler = $game_party.actors[@actor_index]
        phase3_make_command_window
        @actor_command_window.x = @actor_index * 160
      end
      if Input.trigger?(Input::RIGHT)
        @actor_index += 1
        if @actor_index == [$game_party.actors.size, 4].min
          @actor_index = 0
        end
        @active_battler = $game_party.actors[@actor_index]
        phase3_make_command_window
        @actor_command_window.x = @actor_index * 160
      end
    end
    if @actor_command_window.active == true or @fleeing == true
      phase3_pass_time
    end
  end
  
  def phase3_pass_time
    for battler in $game_party.actors + $game_troop.enemies
      battler.stamina += battler.vitality
      if battler.stamina > battler.max_stamina
        battler.stamina = battler.max_stamina
      end
    end
  end
  
  alias cbs_update_phase4_step1 update_phase4_step1
  def update_phase4_step1
    if @action_battlers.size == 0
      @phase = 3
      for battler in $game_party.actors + $game_troop.enemies
        battler.stamina_action_cost
      end
      i = @actor_command_window.index
      phase3_make_command_window
      @actor_command_window.index = 1
      @actor_command_window.visible = true
      @actor_command_window.active = true
      @actor_index = @check_index
      @actor_command_window.x = 160 * @actor_index
      @active_battler = $game_party.actors[@actor_index]
      $game_party.clear_actions
      for enemy in $game_troop.enemies
        enemy.current_action.clear
      end
      return
    end
    cbs_update_phase4_step1
  end
  
  def phase3_next_actor
    @check_index = @actor_index
    start_phase4
    return
  end
  
  def phase3_prior_actor
    start_phase2
    return
  end
  
  def update_phase3_basic_command
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      phase3_prior_actor
      return
    end
    if Input.trigger?(Input::C)
      case @actor_command_window.index
      when 0
        if @active_battler.stamina < Fomar.attack
          $game_system.se_play($data_system.buzzer_se)
          return
        end
        $game_system.se_play($data_system.decision_se)
        @active_battler.current_action.kind = 0
        @active_battler.current_action.basic = 0
        start_enemy_select
      when 1
        if @active_battler.stamina < Fomar.skill
          $game_system.se_play($data_system.buzzer_se)
          return
        end
        $game_system.se_play($data_system.decision_se)
        @active_battler.current_action.kind = 1
        start_skill_select
      when 2
        if @active_battler.stamina < Fomar.defend
          $game_system.se_play($data_system.buzzer_se)
          return
        end
        $game_system.se_play($data_system.decision_se)
        @active_battler.current_action.kind = 0
        @active_battler.current_action.basic = 1
        @active_battler.stamina -= Fomar.defend
        phase3_next_actor
      when 3
        if @active_battler.stamina < Fomar.item
          $game_system.se_play($data_system.buzzer_se)
          return
        end
        $game_system.se_play($data_system.decision_se)
        @active_battler.current_action.kind = 2
        start_item_select
      end
      return
    end
  end
  
end
 

WiZ`

Member

Hi Fomar :D i've a little problem :\
In battle i must use only 3 character and not 4... i've try to change the script and i've fix the number of character in the menù and the layout but i don't know how to change the number of fighter in battle can you help me please? :* (i'm using the minkoff ATB aniway)
another question :D How can i make enter or exit the character in the party? Oo, becose i need 8 and with the database i can only have 4 party member, there is some command that allow me to force in or out the party the member? Oo
maybe something i can call whit a map script? like @partymember.force_in = [chara's_id]

Thanks :D

EDIT: I've found another problem XD, i've change the layout of the "Window_Target" class and when i use an item the cursor go over the first 3 character and disappear over the 4th how can i fix it? Oo (sorry for my english again XD - like i draw in all my post :P)
 

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