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.

Help on modifying the standard battle system

Lycosa

Member

Hi all,

I have some questions on modifying the standard battle system:

First of all:
How can I let the RPG Maker show a HP and SP bar on each opponent, so that the player always knows how strong the opponents are?

Secondly:
Is there an universal RGSS conditional branch that finds out what weapon the active player is wielding? I need something I can use in the "Scene_Battle 4" script.

Thirdly:
I'd like to have a battle command that sets a switch on and off ... And it should, if the switch is on, show another text as if it`s off (e.g. "defense ON" <-> "defense OFF"). How does that work? A simple conditional branch does not work, because the text is not updated...

Fourthly:
If HP is regenerated, the value is shown above the battler. How can I make the RPG Maker show that also when SP are regenerated?

I would greatly appreciate every answer.
 
1. I found this script by searching the board: http://www.rmxp.org/forums/index.php?topic=5617

2. By looking at Scene_Battle, I reckon in any phase2 method, you can obtain the appropriate actors weapon by using:
Code:
$game_party.actors[@actor_index].weapon_id

Note that it only obtains the ID of the weapon from the database. To get its data, you would have to use:
Code:
$data_weapons[$game_party.actors[@actor_index].weapon_id]

3. What code do you currently use for this? If this is on the command window, use:
Code:
@actor_command_window.refresh
after every switch change.

4. This can be done as simple as this. Inside Game_Battler 3, find the line:
Code:
self.damage = -recover_hp
Should be 259 by default. Now, replace this line with the block below:
Code:
if recover_sp > recover_hp
  self.damage = -recover_sp
else
  self.damage = -recover_hp
end
You could expand the methods to show both values, but in theory, this method should show the SP gain if the SP gain is higher than the HP gain, otherwise show the HP gain. I didn't test this, but it should work fine.

Hope this helps.
 

Lycosa

Member

1.
Thanks! I forgot to search for a script like this. This works fine.

2.
That also works. Thanks a lot.

3.
I realized that what I wanted to do with this would be a lot more complicated then I thought, so I`ll leave that one out. Thank you nevertheless.

4.
I´m not so sure on that, because I`ve modified the battle system that any attack will first damage the SP, then the SP, I changed exactly that line, and it works like I want it to.
So I think this change will not effect the things that are displayed, but the things that are in fact regenerated. I don`t want to change anything there, I just would like to have an SP change also displayed (e.g.: Potions that restore HP show how much HP is regenerated, potions that restore SP do not - But I want them to).
 
Yeah, that's what I did. The self.damage is what that shows on the battler once damage_pop is set to true. This is when the damage() function is being run and showing self.damage as a pop with a different font (default Arial Black). Did you even try the snippet?

Glad the rest worked out for ya, though.

Cheers.
 

Lycosa

Member

Yes, I tried, but it just doesn`t seem to do anything :sad:. But perhaps I´m doing something wrong or it isn`t compatible with other scripts I use...

I have a fifth question:
What command do you use in "Scene_Battle 4" to show a text on the active battler? It should look like the damage that is shown above a battler.
 
You might wanna send me the methods for the SP text? This is for 'item_effect()' right?

5. You should be able to use:
Code:
@active_battler.damage("Text here", false)
But I haven't tested it. In theory this should do the trick, if used in an approriate location. If you're not sure if the location, you might wanna check if it's nil, and print a message if not to see if its misplaced:
Code:
if @active_battler.nil?
  print "battler is nil"
else
  @active_battler.damage("Text here", false)
end

Cheers.
 

Lycosa

Member

This is what I added to "Scene_Battle 4":
Code:
if @active_battler.sp >0
  if @active_battler.sp < @active_battler.maxsp
    aktuelle_sp = @active_battler.sp
    if $game_party.actors[@actor_index].weapon_id == 0
        sp_regeneration = aktuelle_sp/20
     else
        sp_regeneration = aktuelle_sp/10
        end
    @active_battler.sp += sp_regeneration
  end
end
This should add 10 % of the current SP to any battler at the begin of his turn. Now I would like to have a text show "+10 % SP", so that it`s a bit more clear for the player.
BTW, at the moment, the SP are added in the exact moment the player attacks, so if you use a skill that consumes SP, you can`t see how much SP the skill consumes and how much are regenerated... Any suggestions for that?

No, sorry, that doesn`t work. It says there is a wrong number of arguments (2 for 0). Whatever that exactly means (I`m a newcomer to RGSS).
 
I didn't test these snippets, but the RPG::Sprite (which Game_Battler bases upon) should have the damage method which uses 2 arguments, not 0, so that makes little sense. Could you add the code WITH the damage method? You should add it right after:
Code:
@active_battler.sp += sp_regeneration
 

Lycosa

Member

The damage method? Sorry, I`m new to RGSS... What do you mean?

Er... And I have a sixth question :lol::
How can I replace the
Code:
if $game_party.actors[@actor_index].weapon_id == 0
with a conditional branch that finds out what attribute (e.g. fire or ice) the weapon has?
 
My previous posts use @active_battler.damage(text, critical). You have to use this. I mean, if you don't even use the code I provided, how can it be of use? :P

If you wanna find attributes, use the element set of the data.

Code:
weapon = $data_weapons[$game_party.actors[@actor_index].weapon_id]
if weapon.element_set.include?(id)
  # do something
end
The 'id' is the number of the element from the System tab in the database.
 

Lycosa

Member

Sorry, of course I tried the code, but it didn`t work and I don`t know the definition of "methods" or "arguments" in RGSS very well - That`s why I asked.

My code looks like this now:
Code:
if @active_battler.sp >0
if @active_battler.sp < @active_battler.maxsp
  aktuelle_sp = @active_battler.sp
  weapon = $data_weapons[$game_party.actors[@actor_index].weapon_id]
  if weapon.element_set.include?(7)
    sp_regeneration = aktuelle_sp/20
  else
    sp_regeneration = aktuelle_sp/10
  end
  @active_battler.sp += sp_regeneration
  @active_battler.damage("+10% SP", false)
end
It still says it`s the wrong number of arguments.
 
I just mixed up the methods. I apologize. Here's the code that works, though it only shows the +10% SP text when the command menu pops up, so you might wanna take the blocks and stick them elsewhere if you want it to show after they attack or whatnot.

Code:
  #--------------------------------------------------------------------------
  # * Go to Command Input for Next Actor
  #--------------------------------------------------------------------------
  def phase3_next_actor
    # Loop
    begin
      # Actor blink effect OFF
      if @active_battler != nil
        @active_battler.blink = false
      end
      # If last actor
      if @actor_index == $game_party.actors.size-1
        @active_battler = $game_party.actors[@actor_index]
        if @active_battler.sp >0
          if @active_battler.sp < @active_battler.maxsp
            aktuelle_sp = @active_battler.sp
            weapon = $data_weapons[$game_party.actors[@actor_index].weapon_id]
            if weapon.element_set.include?(7)
              sp_regeneration = aktuelle_sp/20
            else
              sp_regeneration = aktuelle_sp/10
            end
            @active_battler.sp += sp_regeneration
            @active_battler.damage = "+10% SP"
            @active_battler.damage_pop = true
            p @active_battler.damage_pop
          end
        end
        # Start main phase
        start_phase4
        return
      end
      # Advance actor index
      @actor_index += 1
      @active_battler = $game_party.actors[@actor_index]
      @active_battler.blink = true
      if @active_battler.sp >0
        if @active_battler.sp < @active_battler.maxsp
          aktuelle_sp = @active_battler.sp
          weapon = $data_weapons[$game_party.actors[@actor_index].weapon_id]
          if weapon.element_set.include?(7)
            sp_regeneration = aktuelle_sp/20
          else
            sp_regeneration = aktuelle_sp/10
          end
          @active_battler.sp += sp_regeneration
          @active_battler.damage = "+10% SP"
          @active_battler.damage_pop = true
          p @active_battler.damage_pop
        end
      end
    # Once more if actor refuses command input
    end until @active_battler.inputable?
    # Set up actor command window
    phase3_setup_command_window
  end

Oh, and don't get as paranoid as me and expect the +10% SP thingy to show with full SP, cause the code requires you to have less than maximum SP :P

Cheers.
 

Lycosa

Member

Thanks FireRaven, but your code didn`t work properly... It always printed "+10% SP" and "true", but I don`t know why.

I have now added
Code:
@active_battler.damage = "+10% Energie"
@active_battler.damage_pop = true
at the end of my script, and now it works.
The only problem is, that it will show a "+10% Energie" on the enemy, but the enemy will receive that 10 % a bit later, when he attacks. But that`s ok.

Thanks a lot!
 

Lycosa

Member

Thanks FireRaven, but the method I`m using at the moment works just fine.

But I have two more questions now:

Firstly:
How can I let an enemy regenerate more than the standard 10 % SP per turn?
Perhaps with a conditional branch that finds out what attribute resistance they have or what ID they have in the database?

Secondly:
How can I also let some other equipment affect the SP regeneration? I probably need to change this:
Code:
weapon = $data_weapons[$game_party.actors[@actor_index].weapon_id]
if weapon.element_set.include?(8)
into something else... But that conditional branch does of course not work as armor does not have an attribute.

Thanks!
 

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