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-Slight Default Battle System/Encounter Tweaks

Hello!

I'm making what I hope is a fairly simple request. Everything I'm asking for should be edits/just little snippets, so it shouldn't be anything too intensive. (But what would I know? I'm the requester!)

Note that the only script I'm using is Dubleaux's Advanced Message System. These are all changes to default systems.

Battle changes
  • [*]I would like agility to be absolute. What I mean by this is I'd like to have the character with the highest Agility ALWAYS hit first. By default the system is very random, so just because you have a higher speed value, doesn't mean you go first. I want a character with 21 Agility to always hit before one with 20 rather than most of the time. Also, I don't know if there are any factors in battle other than Agility that affect who goes first, but if there are, I'd like it to be just Agility-based instead. Extra- If two characters have the same Agility, I'd like it to randomly choose one of the characters to move first. However, I would also like it if after that, the random order stayed the same every turn until the end of that battle so long as no-one's Agility changes. This isn't necessary though.

    [*]I would like the player to have a 100% chance of escaping battle if they try to run away. If the player has been blocked from running away in a battle, however, give them a 0% chance.


Random encounter changes
  • This is an odd one. This is probably the hardest request here, but it might be fairly simple. What I want is a code snippet I can use to add or remove Troops in the Random encounters list during play(preferably through an event). So, for instance, if there is a troop of “Ghost *2” in the list, I want to be able to make that troop stop appearing when I tell it to. I also want to be able to, say, add “Ghost *3” to the troop list during the course of the game. Being able to remove them is more important than being able to add them.

    [*]I’d like to be able to mess around with the number of steps before an encounter(also preferably through an event). So, for instance, if it’s 30 steps before an encounter, during play I want to be able to change it to 40. I would also like to be able to add and subtract(and multiply and divide, if it wouldn’t be any extra trouble) the number of steps per encounters. What I mean is, I won’t always know what number of steps the encounter rate is at, so the ability to “subtract 6 from it” or “multiply it by 2” would be useful, rather than just having to set it.


That’s it!

What I have to offer
My endless gratitude and a credit in my game.
 
Here you go. The rondom encounter changes. Simple to alter and simple to add to your game.

What you have to do to make it work is put the parralel procces event on every map that you will fight a monster and change the monsters accordingly. To change the steps change the 300 number. The monster removel was tricker but done as well. You can have the switch a self switch if you want. If you need help understanding it just ask away.
 
Or, use a script :P
[rgss]class Game_Map
 
  def stop_encounter(id)
    if id.nil? or id > $data_troops.size
      $game_temp.message_text = "Error: No such troop"
      return
    end
    @map.encounter_list.delete(id)
  end
 
  def add_encounter(id)
    if id.nil? or id > $data_troops.size
      $game_temp.message_text = "Error: No such troop"
      return
    end
    @map.encounter_list.push(id)
  end
 
  def set_steps(x)
    @map.encounter_step = x
    $game_player.make_encounter_count
  end
 
end
 
class Interpreter
 
  def add_troop(troop)
    id = (troop.is_a?(String) ? get_troop_id(troop) : troop)
    $game_map.add_encounter(id)
  end
 
  def remove_troop(troop)
    id = (troop.is_a?(String) ? get_troop_id(troop) : troop)
    $game_map.stop_encounter(id)
  end
 
  def get_troop_id(name)
    for id in 1...$data_troops.size
      troop = $data_troops[id]
      return id if troop.name == name
    end
    return nil
  end
 
  def set_steps(x)
    $game_map.set_steps(x)
  end
 
end
 
[/rgss]
in a script command, use:
- set_steps(x) << replace x with any number.
- remove_troop(x)
- add_troop(x)
where x is the troop's name or number, ie: 1, 3, 'Ghost*2'
 
Okay, silver wind, I tried it out, and it works perfectly! Easy to use and no errors thus far. Thanks so much!

How would I go about adding or subtracting from the step count rather than setting it?

~
Waiting on the second request...
 
Add this in line 23 of my script:
[rgss] def add_steps(x)
    @map.encounter_step  += x
    $game_player.make_encounter_count
  end
[/rgss]

To add/remove x steps do:
[rgss]$game_map.add_steps(x)
[/rgss]
(use -x to reduce steps)
Remember if the steps are reduced to 0, RMXP will think the map has no enemy encounters.
 

SPN

Member

Hey there! Just throwing this out there before I get started: I have little to no scripting knowledge whatsoever. After reading your request, I went through the scripts looking for where it sets the players "speed" (being the final number that determines turn order). I eventually came to this:

Game_Battler 1 (lines 259 through 264)
Code:
#--------------------------------------------------------------------------

 # * Determine Action Speed

 #--------------------------------------------------------------------------

 def make_action_speed

   @current_action.speed = agi + rand(10 + agi / 4)

 end

Common sense is telling me that if you remove the whole rand(10 + agi / 4) part, it should just set the action speed to your agility stat, without any further modifications. I would guess that it would select randomly if two ended up with the same action speed, but I couldn't tell you how to keep the "random" order for the whole battle like you asked.

Hope this helps, regardless :)

EDIT: Did some more digging around, and found this for the 100% escape chance you were talking about:

Check out line 84 onward in Scene_Battle 2. That's where the escape chance is determined. The formula they use is essentially:

50 * [party average agility / enemies average agility]

So, if you're average agility is double that of the monsters, you have a (50 * (2x / x)) chance, or 50 * 2, or 100%. If your agility is equal, you have a 50% chance, etc. A quick, slightly improper way to fix this would be to modify line 98:

enemies_agi /= enemies_number

This is the line that divides the total agility by the number of enemies (basic averages calculation). Changing the "enemies_number" to a random high number like 1000 should always net you a 100% chance of escape, if you follow my logic.

And don't worry about not escaping fights you're not supposed to. The event command to disallow escapes doesn't modify the formula, it just doesn't let you select Escape in the first place. No worries.
 
Thank you for this! I am very grateful. From one non-scripter to another, I know how painful trying to edit something with only logic on your side can be.

Just one thing - I don't understand at all what to do with the second snippet.
 

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