The RPG Maker Resource Kit

RMRK RPG Maker Creation => XP => XP Scripts Database => Topic started by: tSwitch on May 14, 2007, 11:21:38 PM

Title: NBDA v1.3b
Post by: tSwitch on May 14, 2007, 11:21:38 PM
NBDA v1.3b
(NAMKCOR's Battle Difficulty Announcer)

Info
This script can be used to have actors talk before and after battle, to describe both the battle and their own conditions
Kinda Valkyrie Profile-ish

Features
-- uses easily customizable arrays to determine sounds
-- uses an array to create enemy group levels
-- have different sounds for Boss Battles!
-- actors' statements at end battle are determined by their hp levels
-- user friendly instructions
-- exotic CBS compatable!

Screenies
N/A - Audio Script

Version History
(note: versions 1.0-1.1 were NOT released)
- 1.0 - completed basic system for pre-battle talk
- 1.0b - fixed bug where dead people spoke ;D
- 1.1 - added end of battle speech
- 1.1b - fixed bug where any hp loss resulted in low hp sounds
- 1.2 - Fixed mute characters bug; removed useless variable; sounds now must
        go in their own folder under SE for easier organization
        The folder is - "Audio\SE\NBDA\"
        Discovered complete incompatability with Cogwheel's RTAB
        as well as a compatabilizing technique
- 1.3 - Made the script compatible (mostly) with exotic-CBS'es
              removed useless lines of code
- 1.3b - Fixed echo problem by changing location of the end-battlecry =D

Script
Spoiler for:
Code: [Select]
#=================================================================
#   NAMKCOR's Battle Difficulty Announcer v1.3b                                                             
#---------------------------------------------------------------------------------------------------------------------             
#   Created By: NAMKCOR                                                                                                     
#   Created for the Websites: Chaos Project & RPG Maker Resource Kit                     
#                                                  (www.chaosproject.co.nr & www.rmrk.net)                       
#   If this script is hosted on any other website, then it is stolen, please contact           
#   me at the address given below                                                                                         
#--------------------------------------------------------------------------------------------------------------------
#   If you find any Bugs/Incompatability issues with this script, please contact me at   
#   the following e-mail address: Rockman922@aol.com, and please be descriptive   
#   with your e-mail subject, as I delete spam on sight.  I might be able to fix it, but       
#   as of right now I'm kinda a mediocre scripter so some Incompatability issues may
#   be unsolvable.                                                                                                                     
#--------------------------------------------------------------------------------------------------------------------
#   Function:                                                                                                                             
#    This script will play a "battle cry" that is randomized and chosen due to a set       
#    number of parameters.  This system was designed to be customizable without   
#
#     much special scripting know-how                                                                                 
#    Compatability:                                                                                                                   
#     100% compatability with SDK (some things may conflict I dunno SDK well)
#     90% compatability with exotic-CBS
#                                                                                                                                                 
#     Instructions:                                                                                                                     
#      Comments and instructions for the individual customizations will be given           
#       right where they are located.  Only real skills needed are reading, typing,             
#       and copy&paste
#       All sounds used must go under "Audio\SE\NBDA\" or the script will bug
#--------------------------------------------------------------------------------------------------------------------
#     Version History:
#     1.0 - completed system, different phrases at start of battle only
#     1.0b - Fixed a bug where dead people could still talk at beginning of battle
#     1.1 - Added talking at end of battle
#     1.1b - Fixed a bug where any hitpoint loss at all would result
#                Low HP sounds being played
#     1.2 - Fixed mute characters bug; removed useless variable; sounds now must
#                go in their own folder under SE for easier organization
#                The folder is - "Audio\SE\NBDA\"
#                Discovered incompatability with Cogwheel's RTAB
#                 as well as a compatabilizing technique (temporary)
#     1.3 - Made the script compatible (mostly) with exotic-CBS'es
#              removed useless lines of code
#     1.3b - Fixed echo problem by changing location of the end-battlecry =D
#=================================================================

#don't touch
class Game_Party
  def partyActors
    return @actors
  end
end
#end don't touch

#=================================================================
#  This array will be used to detect if an enemy troop is a boss battle
#  Simply add the index of the boss troops to the array
#=================================================================
$bosses = [3]

#=================================================================
#  This array is used to detect the level of the enemy in the database
#  All enemy MUST have a level value put in this array, and  the levels MUST be
#  In order of the enemy in the database or the system will bug and/or crash
#  ENEMY LEVELS CANNOT BE NIL
#  To include a boss,  make the level value equal to zero
#
#  example - say you have 5 enemies, and the first two are level 1 battles, 2
#                    level 5, $enemy_level would look like this:
#                    $enemy_level[1,1,5,5]
#=================================================================
$enemy_level = [1,5,10,10]

#=================================================================
#  These arrays are used to store the sounds played by the actors
#   All you need to do is write the name of the sound you want played by the actor
#   Based on the conditions
#   Like the enemy levels, this one is organized by the actor's number in
#   the database, and all must have a value for the correct sound to be played
#   (or nil if no sound)

#    $in_boss_battle: If the character is in a boss battle
#    $in_desperate_battle: if the character's level is DESPERATE or more levels below the
#                                            enemy party's level
#                                            (change DESPERATE to whatever value you feel would be
#                                              appropriate to determine whether or not the character
#                                              will have a tough time with the battle)
#    $in_normal_battle: if the battle isn't desperate or easy, basically in the right range
#                                      for the character's level
#    $in_desperate_battle: if the character's level is EASY or more levels above the
#                                            enemy party's level
#                                            (change EASY to whatever value you feel would be
#                                             appropriate to determine whether or not the character
#                                             will have an easy time with the battle)
#   $low_hp: if the character has low hp at the start of battle, they will say this
#   LOWPERCENT: what percent of hp would be considered low
#   MIDPERCENT: what percent of hp would be considered middleish
#    $end_low_hp: what sound is played at the end of battle if actor's hitpoints are
#                              below LOWPERCENT
#    $end_mid_hp: what sound is played at the end of battle if actor's hitpoints are
#                               above LOWPERCENT, but lower than MIDPERCENT
#    $end_high_hp: what sound is played at the end of battle if the actor's hitpoints are
#                                above MIDPERCENT
#
#   The character's sounds must be in order of the actors in the database
#    for mute characters, leave their values nil
#
#    example: if actor 1 plays sound "omg" at the beginning of boss battles, and
#                     actor 3 plays "ahhh" but actor 2 is mute, $in_boss_battle would look
#                      like this:
#                      $in_boss_battle = ["omg", nil, "ahhh"]
#                      where "omg" and "ahhh" are the names of the SE file in the folder
#
#   The syntax is the same for all the other arrays
#=================================================================
$in_boss_battle = ["Actor001-bossBattle", "Actor002-bossBattle",nil,nil]
$in_desperate_battle = ["Actor001-desperateBattle","Actor002-desperateBattle",nil,nil]
DESPERATE = 4
$in_normal_battle = ["Actor001-normalBattle","Actor002-normalBattle",nil,nil]
$in_easy_battle = ["Actor001-easyBattle","Actor002-easyBattle",nil,nil]
EASY = 4
$low_hp = ["Actor001-lowHP","Actor002-lowHP",nil,nil]
LOWPERCENT = 25
MIDPERCENT = 75
$end_low_hp = ["Actor001-lowWin","Actor002-lowWin",nil,nil]
$end_mid_hp = ["Actor001-normWin","Actor002-normWin",nil,nil]
$end_high_hp = ["Actor001-bestWin","Actor002-bestWin",nil,nil]

 #==================================================================
 #DO NOT EDIT BELOW THIS LINE UNLESS YOU KNOW WHAT YOU ARE DOING
 #==================================================================
@char_selection = 0
class Scene_Battle
#alias phase1 to make it compatible
alias new_phase1 start_phase1
#overloaded phase1 for battlecry before phase1 execution
def start_phase1
      #Battlecry Excecution
    @played = false
    @troop_id2 = ($game_temp.battle_troop_id)-1
    @actors = $game_party.partyActors
    @char_selection = rand(@actors.size)
   
    while @actors[@char_selection].level == nil or @actors[@char_selection].hp <= 0
      @char_selection = rand(@actors.size)
    end
    @level = @actors[@char_selection].level
    @hpRemain = (@actors[@char_selection].hp*100/@actors[@char_selection].maxhp)
    @enemylevel = $enemy_level[@troop_id2]
    if $bosses.include?(@troop_id2) and @played == false
      if $in_boss_battle[@char_selection] != nil
        Audio.se_play("Audio/SE/NBDA/" + $in_boss_battle[@char_selection], 100, 100)
        @played = true
      end
    end
    if @hpRemain < LOWPERCENT and @played == false
      if $low_hp[@char_selection] != nil
        Audio.se_play("Audio/SE/NBDA/" + $low_hp[@char_selection], 100, 100)
        @played = true
      end
    end
      if @level + DESPERATE  <= @enemylevel and $in_desperate_battle[@char_selection] != nil and @played == false
          Audio.se_play("Audio/SE/NBDA/" + $in_desperate_battle[@char_selection], 100, 100)
         @played = true
      elsif @level - EASY >= @enemylevel and $in_easy_battle[@char_selection] != nil and @played == false
          Audio.se_play("Audio/SE/NBDA/" + $in_easy_battle[@char_selection],100,100)
          @played = true
      elsif $in_normal_battle[@char_selection] != nil and @played == false
          Audio.se_play("Audio/SE/NBDA/" + $in_normal_battle[@char_selection],100,100)
        end
        @played = false
    #end battlecry execution
    new_phase1
  end
end
class Window_BattleResult < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     exp       : EXP
  #     gold      : amount of gold
  #     treasures : treasures
  #--------------------------------------------------------------------------
  alias new_initialize initialize
  def initialize(exp, gold, treasures)
    #play end of battle SE
    @played = false
    @actors = $game_party.partyActors
    @char_selection = rand(@actors.size)   
    while @actors[@char_selection].level == nil or @actors[@char_selection].hp <= 0
      @char_selection = rand(@actors.size)
    end   
    @hpRemain = (@actors[@char_selection].hp*100/@actors[@char_selection].maxhp)
    if @hpRemain <= LOWPERCENT and @played == false
      if $end_low_hp[@char_selection] != nil
        Audio.se_play("Audio/SE/NBDA/" + $end_low_hp[@char_selection], 100, 100)
        @played == true
      end
    end   
    if @hpRemain <= MIDPERCENT and @hpRemain > LOWPERCENT and @played == false
      if $end_mid_hp[@char_selection] != nil
        Audio.se_play("Audio/SE/NBDA/" + $end_mid_hp[@char_selection], 100, 100)
        @played == true
      end
    end   
    if @hpRemain > MIDPERCENT and @played == false
      if $end_high_hp[@char_selection] != nil
        Audio.se_play("Audio/SE/NBDA/" + $end_high_hp[@char_selection], 100, 100)
        @played == true
      end
    end
    new_initialize(exp,gold,treasures)
  end
end
Just paste that in it's own script above main.
Instructions are given in the script's comments above the arrays and values
that they concern

Demo
Attached to this Post
*requires .rar extractor, can be found HERE (http://www.rarlab.com/download.htm)

Compatability
Most likely compatable with SDK
Most likely compatable with exotic CBSes
no known incompatability issues

Other Info
WOHOO! This is my first "real" script
If you find any bugs, please feel free to e-mail me at Rockman922@aol.com
Also contact me and let me know about any incompatability issues!
If this script is used in a game, please credit me, and let me know about the game so that I can see what you did with my script ok?

--enjoy!
Title: Re: NBDA v1.1b
Post by: WcW on May 14, 2007, 11:59:45 PM
Cool.  This is also similar to FF10, except not as context-sensitive.  Maybe you could add somesort of database or something for that, like where it changes depending on the battle and story, and were you are, that sort of thing.  But still, awesome.  I haven't tried it yet though...
Title: Re: NBDA v1.1b
Post by: tSwitch on May 15, 2007, 01:37:31 AM
well, you can easily change the sounds with a call script event

for example
at one point in the game you could have

Code: [Select]
$end_low_hp = ["Actor001-LowHPChap1"]

and later on, call this event script

Code: [Select]
$end_low_hp = ["Actor001-lowHPChap2"]
return true

and by using simple call script events, you could use my script as a base system to make it more context sensitive.
Title: Re: NBDA v1.1b
Post by: modern algebra on May 16, 2007, 04:01:01 AM
Pretty neat script. I think I would have made the variables class variables rather than global, but I am not a very good scripter so I might be missing something obvious. Anyway, good job.
Title: Re: NBDA v1.1b
Post by: Zeriab on May 16, 2007, 12:38:12 PM
It's a pretty sweet little script ^_^

It is easier to change global variables than class variables with the Call Script event command.
The problem is that you pollute the name space. You also increase the likelihood of compatibility problems with other scripts using global variables.

I suggest creating a separate class to contain the information.
Just make it a Singleton  (http://www.google.com/search?q=Singleton+Ruby)and you can just as easily call it with the Call Script event command.
Creating class method will simplify the calls even further.
You can also catch potential errors this way as the Call Script does not directly effect the data.

Loads of advantages ^_^
The only disadvantage I can think of is that it is more difficult to script.
Title: Re: NBDA v1.1b
Post by: modern algebra on May 16, 2007, 01:17:30 PM
 :-[

I meant for the arrays as the user is not likely to have to change enemy level or boss troops.

But Zeriab is definitely better than me, so ignore me and do as he says.
Title: Re: NBDA v1.1b
Post by: tSwitch on May 16, 2007, 06:46:13 PM
It's a pretty sweet little script ^_^

It is easier to change global variables than class variables with the Call Script event command.
The problem is that you pollute the name space. You also increase the likelihood of compatibility problems with other scripts using global variables.

I suggest creating a separate class to contain the information.
Just make it a Singleton  (http://www.google.com/search?q=Singleton+Ruby)and you can just as easily call it with the Call Script event command.
Creating class method will simplify the calls even further.
You can also catch potential errors this way as the Call Script does not directly effect the data.

Loads of advantages ^_^
The only disadvantage I can think of is that it is more difficult to script.

I just did it the way I did because I saw it done that way in the past ;D
I'll optimize it later, after I learn some more scripting
Title: Re: NBDA v1.3b
Post by: tSwitch on May 27, 2007, 10:49:22 PM
updated to 1.3b

it's now compatable with exotic CBS-es!
(think Side View or RTAB here)
Title: Re: NBDA v1.3b
Post by: :) on August 21, 2007, 10:22:43 PM
Nice work!! :D
+ rep
Title: The children; resources, prednisone without dr prescription contraindicated, base therapist anaphyla
Post by: izaisuzal on August 22, 2019, 06:39:28 PM
Any bdq.ipbs.rmrk.net.yrg.bx interrupted assisting recurrent buy kamagra online (http://wellnowuc.com/buy-kamagra-online/) prednisone 20 mg (http://myquickrecipes.com/prednisone-without-dr-prescription/) levitra cost (http://myquickrecipes.com/levitra-online/) online methotrexate (http://passagesinthevoid.com/methotrexate/) buy kamagra online (http://robots2doss.org/kamagra-oral-jelly/) opinions, pyelography <a href="http://wellnowuc.com/buy-kamagra-online/">kamagra buy online</a> <a href="http://myquickrecipes.com/prednisone-without-dr-prescription/">prednisone</a> <a href="http://myquickrecipes.com/levitra-online/">levitra</a> <a href="http://passagesinthevoid.com/methotrexate/">methotrexate without a prescription</a> <a href="http://robots2doss.org/kamagra-oral-jelly/">kamagra oral</a> internal, scapulae, ligated, http://wellnowuc.com/buy-kamagra-online/ kamagra oral jelly canada http://myquickrecipes.com/prednisone-without-dr-prescription/ prednisone 20 mg http://myquickrecipes.com/levitra-online/ levitra http://passagesinthevoid.com/methotrexate/ methotrexate for sale http://robots2doss.org/kamagra-oral-jelly/ kamagra pain virilization.