Battle Rules

battlerules3.gif



This script allows you to set up "battle rules" for victory or defeat. The default battle rules are


Default victory rules: all enemies are dead


Default defeat rules: all actors are dead


There are four scopes for battle rules

  • Global battle rules
    These apply to all battles. These are the "default" rules.
  • Map battle rules
    These apply to all battles that occur on the current map
  • Troop battle rules
    These apply to any encounter with this troop.
  • Event battle rules
    These apply to encounters on a per-event basis
There are two ways to specify rules for a battle
  • Set rules. These overwrite any previous rules. So for example, if you defined map rules and troop rules, but then have "set" event rules, thenall of the map rules and troop rules will not apply for this battle.
  • Add rules. These are added on top of any previous rules, so you can add event battle rules to any troop rules or map rules.
battlerules1.gif

Download


Get it at Hime Works!


Further instructions can be found there.
Wow, this is a really cool idea! I'll probably be using this!
Awesome idea! Good job Princess!
There is an important issue that must be tested: battles that can never end.

If you carelessly override the default rules (eg: all enemies are dead), then it is possible that your current battle rules do not actually consider the fact that all enemies are dead, and so the battle continues even if there is nothing left.

Furthermore, since "all rules must be met" in order for victory or defeat to be achieved, you'll have to override the default rule for the current battle and move the "all enemies are dead" condition into one of your more localized rules, like

<victory rule: set>cond: $game_troop.all_dead? || some_other_condition</victory rule>This will then allow you to say "either enemies are all dead, or some other condition is met"On the other hand, you might want to say "the only way to win is to capture at least one monster. If all monsters are dead then you lose". Again, you'll have to override the default defeat rule

Code:
<defeat rule: setcond: $game_troop.all_dead? || $game_party.all_dead?</defeat rule>
Maybe in the future I will figure out a way to say "this rule, or that rule" but for now such an option is not available.
I have implemented a new feature called "Rule Groups"

Basically, rule groups are just groups of rules.

You define a rule, then assign it to a group.

The special thing about groups is that you might have multiple rule groups for your victory condition, but you only need to satisfy one of them in order to achieve victory.

Here is a quick summary

  • All rules WITHIN a group must be satisfied in order to satisfy the group
  • Only ONE group needs to be satisfied in order to achieve victory (or defeat)
You do NOT need to change any of your existing rules.Here is an example of what I mean: Suppose you are in a battle with some slime. The victory conditions are as follows:

1: kill all enemies, OR

2: wait 5 turns

Previously, you can accomplish it by combining all of those into a single rule

<victory rule: set>Cond: (the appropriate condition, as a ruby statement. Could be very long)Desc: kill all slime OR wait five turns</victory rule>Which is ok...until you realize that the script does not support very, very long ruby statements, and the rule display does not support very long descriptions either.With the new concept of rule groups, you can create two groups and place a rule in each:

<victory rule: set>Desc: Kill all slimeGroup: 1</victory rule><victory rule: set>Desc: Wait 5 turnsGroup: 2</victory rule>Now you can allow the player to choose which group of rules they want to complete in order to win the battle.By default, all rules are assigned to group 1 if you don't specify one.

Note that this update breaks compatibility with Mr Bubbles' Battle Rule Display.

I will provide proper documentation once I get around to it, but if anyone wants to test it out it is ready for use.
another awesome script and really useful specially for boss battles and such...
This is a nice script, Tsukihime, but it's kind of unyielding and unfriendly to those unfamiliar with Rubyscript. Like me.

Suppose I wanted the defeat conditions to be all the party members being dead AND there not being at least one of a certain item?

How would I do that?
$game_party.all_dead? && $game_party.item_number($data_items[23]) == 0This checks whether all battle members are dead and the party has zero of item 23.
I will modify the script to provide an easier way to specify battle rules.


Namely, using conditional branch commands and comments.
I plugged it in like you said, but I got an error.

Script 'Battle Rules' line 423:SyntaxError occured.

 

unexpected ';'

def self.defeat_conditions_met?; $game_party.all_dead? &&;end
Oh wait, this script was designed so that each rule supports only one condition.

So you'll have to write them as separate rules in the same group

Code:
<defeat rule: set>cond: first_conditiongroup: 1</defeat rule><defeat rule: set>cond: second_conditiongroup: 1</defeat rule>
Okay, that seems to have done it. But now i'm having a problem with Game End Events e_e

The game crashes with this error upon game over:

script 'Game End Event' line 219: NoMethodError occured.

 

undefined method 'gameover_event_id' for nil:NilClass

 

I know this is the wrong thread, but I really don't wanna spread all my posts all over the place.

 

uWmegEo.jpg
Event page with the defeat rules.

 

MJeH5W5.jpg
Script Editor Materials list.
You need to raise issues in separate threads with a clear topic otherwise no one will see it.


The issue occurs when you battle test. I have fixed the problem.
Ah, that did it. Thanks.

Sorreh.

Original thread: https://forums.rpgmakerweb.com/threads/battle-rules.12526/