Jump to content

Recommended Posts

So, in VX Ace, we all know there's no real thing as races or elemental strength, just weakness. This script, now that I think about it, is a very simplified version of Elemental scripts the professionals made, but this time, each enemy can now have their own "Race", defined under the Class tab.

Directions: Whatever race you decide to make, make a class of it with the features you want, then in Enemy Notetags, put this:
<Race: ???>

where ??? is your preferred race.

 

Spoiler

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#   Brandon Kaminari: Enemy Races v1.0
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#   Use in Non-Commercial or Commercial, just credit me :)
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#   Place below Materials and over Main Process
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#   Instructions:
#   For your enemies, go to their note box and type in the following:
#   <Race: ???>
#   (Where ??? is your desired race)
#   Then create your desired race in the Class Tab with the desired features.
#   WARNING: IT'S JUST THE FEATURES, NOT SKILLS
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

class Game_Enemy < Game_Battler
  def race
    return @race unless @race.nil?
    load_notetag_enemy_race
    return @race
  end
  
  def load_notetag_enemy_race
    regex = /<Race:\s*(.*)\s*>/i
    @race = enemy.note =~ regex ? $1.downcase : ""
  end
  
  def race_stats
    return if race.nil?
    return if race==""
    $data_classes.size.times do |whee|
      next unless $data_classes[whee+1]
      return $data_classes[whee+1] if $data_classes[whee+1].name == race
    end
  end
  #--------------------------------------------------------------------------
  # * Get Array of All Objects Retaining Features
  alias bkami_add_race_stats_45ws   feature_objects
  #--------------------------------------------------------------------------
  def feature_objects
    super + [enemy] + [race_stats]
    bkami_add_race_stats_45ws
  end
end
 

 

races-subraces.JPG

Share this post


Link to post
Share on other sites

Huh... You know I made a script to give enemies classes once too, though I never thought of inheriting features and was using it instead along with a script that gave enemies levels to calculate stats. I ended up not using it because a monster having stats the same as an actor is often way too tough. But then I didn't think of using it in this way with monster only races/classes and features. It's a really neat idea!

Share this post


Link to post
Share on other sites
15 minutes ago, Kayzee said:

Huh... You know I made a script to give enemies classes once too, though I never thought of inheriting features and was using it instead along with a script that gave enemies levels to calculate stats. I ended up not using it because a monster having stats the same as an actor is often way too tough. But then I didn't think of using it in this way with monster only races/classes and features. It's a really neat idea!

What I was thinking was: There's going to be a LOT of monsters in my game. I don't want to program each and every monster's elemental weakness manually. AND All I need are the features, not the level or gear.....yet.
And thanks! Not just for the praise, but the fact that I'm purposely planning my game and its enemies to be hard, but damn rewarding!

Share this post


Link to post
Share on other sites

Yeah, it seems super useful for sure! I see a few issues with how you coded it though... You are looking up the class every time by name. It would be better if you just looked up the class once and remembered the id. Also, if the race is not set, won't race_stats return nil making the feature objects look at the nil object? That might not matter though if it dosn't actually add nil to the array.

Edited by Kayzee

Share this post


Link to post
Share on other sites

Okay, after several hours and blunts later, I considered your idea.

The reason I'm still going to search by name is I think it would be easier on the programmer to utilize both the database and scripting evenly instead of relying on either.

With that being said, I added in a Sub Race section, and it can only be read if there's a main race. Also, when I tested it out, it wasn't working! Now, I'm still kinda confused, especially on RPG::xxxx-related classes, BUT...

Spoiler

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#   Brandon Kaminari: Enemy Races v1.0
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#   Use in Non-Commercial or Commercial, just credit me :)
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#   Place below Materials and over Main Process
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#   Instructions:
#   For your enemies, go to their note box and type in the following:
#   <Race: ???>
#   <Sub Race: ???>
#   (Where ??? is your desired race. Sub Race won't register until you have a main Race.
#   Then create your desired race in the Class Tab with the desired features.
#   WARNING: IT'S JUST THE FEATURES, NOT SKILLS
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class RPG::Enemy < RPG::BaseItem
  def load_notetag_enemy_race
    regex = /<Race:\s*(\w*)\s*>/i
    @race_name = note =~ regex ? $1 : ""
    @races.push(@race_name)
  end
  
  def load_notetag_enemy_subrace
    sub_regex = /<Sub Race:\s*(\w*)\s*>/i
    results = note.scan(sub_regex) {|res|
      @race_name = note =~ sub_regex ? res : ""
      @races.push(@race_name[0])
    }
  end
end

class Game_Enemy < Game_Battler
  def load_notetag_enemy_race
    regex = /<Race:\s*(\w*)\s*>/i
    @race_name = enemy.note =~ regex ? $1 : ""
    @races.push(@race_name)
  end
  
  def load_notetag_enemy_subrace
    sub_regex = /<Sub Race:\s*(\w*)\s*>/i
    results = enemy.note.scan(sub_regex)
    results.each do |res|
      @race_name = enemy.note =~ sub_regex ? res : ""
      @races.push(@race_name[0])
    end
  end

  #--------------------------------------------------------------------------
  # * Get Array of All Objects Retaining Features
  alias bkami_add_race_stats_45ws   feature_objects
  #--------------------------------------------------------------------------
  def feature_objects
    return bkami_add_race_stats_45ws + race
  end
  
  def race
    return @race_array unless @race_array.nil?
    @race_array = []
    @races = []
    load_notetag_enemy_race
    load_notetag_enemy_subrace if @races.size != 0
    therace
    return @race_array
  end
  
  def therace
    @races.each do |whee|
      next unless whee != ""
      $data_classes.each do |whoo|
        next unless whoo
        @race_array.push(whoo) if whoo.name == whee
      end
    end
  end
  
end
 

 

Share this post


Link to post
Share on other sites

Hehe, that looks like it should work a lot better, though it looks a bit messy with the regex things, but that's hard to avoid (personally I hate coding note tag stuff in every script so I tend to use this instead, but the downside is it becomes an extra required script to install). Funny, I was just thinking about having multiple race/classes before I read this, and you already did it.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×