Chaos Project

RPG Maker => RPG Maker Scripts => RMXP Script Database => Topic started by: G_G on January 28, 2010, 08:34:35 pm

Title: [XP] Character Races
Post by: G_G on January 28, 2010, 08:34:35 pm
Character Races
Authors: game_guy
Version: 1.0
Type: Character Customization
Key Term: Actor Add-on



Introduction

Adds character races to your game. If you've played oblivion its a lot like that. Pretty much each race has its own stat bonuses, skill bonuses, and name.


Features




Screenshots

N/A


Demo

MediaFire (http://www.mediafire.com/download.php?n34yzhm4k0j)


Script

Spoiler: ShowHide

#===============================================================================
# Character Races
# Author game_guy
# Version 1.0
#-------------------------------------------------------------------------------
# Intro:
# Adds character races to your game. If you've played oblivion its a lot like
# that. Pretty much each race has its own stat bonuses, skill bonuses, and
# name.
#
# Features:
# Have unlimited races
# Have stat bonuses
# Have skill bonuses
#
# Instructions:
# Go down to Config. Follow the instructions there.
#
# To change a class of any actor use this.
# $game_actors[actor id].race = race id
#
# Credits:
# game_guy ~ for making it
# Bethesda ~ for making oblvion which this script is based from
#===============================================================================
module GameGuy
  #=========================================================
  # Config
  #=========================================================
  #==========================================
  # DefaultRace ~ The id of the race that
  # every actor starts with.
  #==========================================
  DefaultRace   = 1 # Default Race for every actor
  def self.racen(id) # Race Names
    case id
    #==========================================
    # Race Name
    # when race_id then return "Name of Race"
    # Example:
    # when 1 then return "Human"
    # Race 1 is called human now
    #==========================================
    when 1 then return "Human"
    when 2 then return "Orc"
    when 3 then return "Elf"
    end
    return "Human"
  end
  def self.raceb(id) # Race Bonus Attributes
    case id
    #==========================================
    # Race Stat Bonuses
    # when race_id then return [hp+, sp+, str+, dex+, agi+, int+]
    # Example:
    # when 1 then return [10, 0, 5, 0, 0, 0]
    # So 'Human' would have a 10 bonus hp and 5 bonus of strength.
    #==========================================
    when 1 then return [10, 0, 5, 0, 0, 0]
    when 2 then return [0, 0, 10, 5, 0, 0]
    when 3 then return [0, 20, 0, 0, 10, 5]
    end
    return [0, 0, 0, 0, 0, 0]
  end
  def self.races(id) # Race Bonus Skills
    case id
    #==========================================
    # Race Bonus Skills
    # when 1 then return [skill 1, skill 2, ect]
    # Example:
    # when 1 then return [1, 2]
    # So 'Human' would know the skills Heal and Greater Heal
    #==========================================
    when 1 then return [1, 2]
    when 2 then return [57, 58]
    when 3 then return [4, 5, 6, 7, 8, 9]
    end
    return []
  end
end
class Game_Actor
  attr_accessor :race_id
  attr_accessor :race_name
  alias gg_add_races_act_later setup
  def setup(actor_id)
    @race_id = 0
    gg_add_races_act_later(actor_id)
    setup_race(GameGuy::DefaultRace)
  end
  def setup_race(id = 0)
    old_id = @race_id
    stats = GameGuy.raceb(old_id)
    @maxhp_plus -= stats[0]
    @maxsp_plus -= stats[1]
    @str_plus -= stats[2]
    @dex_plus -= stats[3]
    @agi_plus -= stats[4]
    @int_plus -= stats[5]
    @race_id = id
    skills = GameGuy.races(old_id)
    skills2 = []
    for i in $data_classes[@class_id].learnings
      skills2.push(i.skill_id)
    end
    for i in skills
      unless skills2.include?(i)
        forget_skill(i)
      end
    end
    stats = GameGuy.raceb(@race_id)
    @maxhp_plus += stats[0]
    @maxsp_plus += stats[1]
    @str_plus += stats[2]
    @dex_plus += stats[3]
    @agi_plus += stats[4]
    @int_plus += stats[5]
    @race_name = GameGuy.racen(@race_id)
    skills = GameGuy.races(@race_id)
    @hp = maxhp
    @sp = maxsp
    for i in skills
      learn_skill(i)
    end
  end
  def race=(id)
    setup_race(id)
  end
end



Instructions

In the script.


Compatibility

Not tested with SDK.
Tested with Blizz-Abs and works. (It was actually made for Blizz-Abs but it works for most battle systems as well.)


Credits and Thanks




Author's Notes

Please do give proper credit for the maker. This script was made for a game I'm working on with a friend. I thought it'd be cool to release it though.
Enjoy!
Title: Re: [XP] Character Races
Post by: ShinyToyGuns on January 28, 2010, 08:50:45 pm
I'm definitely gonna have to try this out :D

I personally LOVE the Elder Scrolls series, and this seems like it would be a great addition to my game :D

I'll let you know what I think ;)

One question...does this script go below all others?

Another question just came to mind...is there a way to show the race name in-game, and how do I assign each actor a different race? (i.e. Orc Fighter)
Title: Re: [XP] Character Races
Post by: G_G on January 28, 2010, 09:07:29 pm
if you read the instructions you'd know to use this.
$game_actors[actor id] = race id


Place it above blizz's scripts and below all others.

and glad you like it :)
Title: Re: [XP] Character Races
Post by: ShinyToyGuns on January 28, 2010, 09:10:50 pm
Apparently, there's some sort of syntax error on line 75...I didn't make any changes to the script either...Would the actors have to have skills assigned to them for this to work?
Title: Re: [XP] Character Races
Post by: G_G on January 28, 2010, 09:21:16 pm
My bad. I fixed it.
Title: Re: [XP] Character Races
Post by: Blizzard on January 29, 2010, 05:45:54 am
There's much sex in this young one. :V: *levels up*
Title: Re: [XP] Character Races
Post by: WhiteRose on January 31, 2010, 10:58:01 am
Just a suggestion for the next version, maybe you should make it so certain races have weaknesses to certain elements (Orcs and goblins are weak against fire, etc.) This would also allow the creation of weapons more effective against certain races, such as silver weapons being strong against demonic races. That's just an idea that you might want to implement if you update in the future, though; the script is already great.
Title: Re: [XP] Character Races
Post by: Eternal on February 01, 2010, 12:38:00 pm
wait a second, couldn't you just give the actor the bonuses from the start...? and with the skill bonuses, wouldn't it just be a simple matter of assigning a unique class for every actor so that their skills could be unique or "with a bonus"?

lol, I'm most likely gonna use it, but to me it kinda seems as pointless as the existance of for example hannah montanna, or the thinking of the us government...
Title: Re: [XP] Character Races
Post by: [Faint] on February 01, 2010, 01:17:59 pm
@Eternal : this script is great for orginization. Also it can be a pain  if you have a larger amount of classes in your game to sit there and and create another class for each race. Say for example you have 15 classes and 5 races, with this script you can easily setup the bonus for being a certain race, but using the method you suggest, you would have to make and configure 75 different classes. So which seems easier? :P
Title: Re: [XP] Character Races
Post by: G_G on February 01, 2010, 04:46:17 pm
@faint: Thanks for backing me up!

Also for the custom version I have the stat multiplier done like STR * 1.5 but learning a skill at a different level isn't quite done. It will be though so just gotta wait.
Title: Re: [XP] Character Races
Post by: [Faint] on February 01, 2010, 04:50:44 pm
ok no problem man but just wondering how did you go about doing the multipliers? Only wondering because I am trying to get better at scripting myself and was trying to figure it out myself. I managed to get it it partially working =p
Title: Re: [XP] Character Races
Post by: G_G on February 01, 2010, 05:03:13 pm
Well in the setup_race method I changed all the minuses to /= and all the pluses to *=. It was very simple. :D So you could go ahead and add that yourself. I'm trying to find a fairly easy way to setup the skill level.
Title: Re: [XP] Character Races
Post by: [Faint] on February 01, 2010, 05:05:14 pm
omg I actually got it right bwahahaha. I just hadn't tested it yet. I don't feel like such a noob anymore lol. For the skills I wonder if "skill_can_use?" would work? I am gonig to try and figure out my idea about elemental efficiencies for the races.
Title: Re: [XP] Character Races
Post by: G_G on February 01, 2010, 05:10:25 pm
I already added that as well(element efficiancies) :S

I'm almost done with the levels hopefully I'll have it done tonight.
Title: Re: [XP] Character Races
Post by: [Faint] on February 01, 2010, 05:15:46 pm
well then I do believe I love you :P
Title: Re: [XP] Character Races
Post by: Eternal on February 02, 2010, 04:17:31 am
@faint aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaahhh. +@game_guy not too stupid actually...
Title: Re: [XP] Character Races
Post by: [Faint] on February 02, 2010, 09:51:40 am
Everything is easier when you break it down  8)
Title: Re: [XP] Character Races
Post by: Godsigma on February 02, 2010, 09:50:44 pm
game_guy, you are my hero. you have made my job so much easier right now i could cry.... my game will pass though the troubled times of my lacking RGSS skills and shall become a blossoming sakura (Cherry) tree and shall bear fruit of wisdom and love for pain and suffering of gamers. truly this night has been blessed for me to return from my stupor and lack of internets... hail odin....
Title: Re: [XP] Character Races
Post by: Eternal on February 03, 2010, 04:02:07 am
 8-O
Title: Re: [XP] Character Races
Post by: phillip1756 on February 03, 2010, 01:54:25 pm
cool
Title: Re: [XP] Character Races
Post by: ShinyToyGuns on February 28, 2010, 09:49:56 am
Is there a way to make this so it doesn't just trigger one actor, but a set of actors with the same race? i.e. Player chooses Elf race, then before they get to the class selection, it automatically makes them an Elf? To make this more clear, my situation is this: Player chooses race, and then they can choose the class, and then they are assigned an actor based on the class and race they choose.

Let me know if you need more detail.
Title: Re: [XP] Character Races
Post by: G_G on February 28, 2010, 10:07:16 am
You could do this.
$game_actors.each{|i| i.race = race_id}
That turns all actors into the same race. I think that'd do what you need.
Title: Re: [XP] Character Races
Post by: ShinyToyGuns on February 28, 2010, 02:58:03 pm
So would I use that in an event script call when they choose their race?
Title: Re: [XP] Character Races
Post by: G_G on February 28, 2010, 05:16:58 pm
Yes. After they choose the race. Just call that script and change race_id.
Title: Re: [XP] Character Races
Post by: ShinyToyGuns on February 28, 2010, 06:26:50 pm
What if there are no actors in the Initial Party until they choose a class? I'd prolly have to put it in for each class, aye?
Title: Re: [XP] Character Races
Post by: The Niche on May 22, 2010, 04:00:54 pm
Game_Guy, I'd first like to declare that I adore you.

Second, I looked at the script and I'm guessing that it;d be possible to limit weapons to races by messing with a copy of the skills yoke.
Title: Re: [XP] Character Races
Post by: G_G on May 22, 2010, 06:29:34 pm
You can just limit weapons through classes.
Title: Re: [XP] Character Races
Post by: The Niche on May 23, 2010, 05:14:48 am
I could, but I could also do the same with skills.
Title: Re: [XP] Character Races
Post by: Griver03 on May 18, 2012, 03:04:10 pm
can you maybe help me with a equipment by race plugin?
like

if shield => [[1, 0], [2,1], [3,2]]
if helmet... and so on...
id1 can be equped by all races, id2 can be equiped by raceid1 only, id3 can be equiped by raceid2 only...

thx in advance
Title: Re: [XP] Character Races
Post by: Griver03 on June 04, 2012, 06:01:40 am
bump
Title: Re: [XP] Character Races
Post by: PhoenixFire on June 30, 2014, 06:48:32 pm
To start with, I do apologize for a... well, like 2 year necro-post. I do have legitimate questions though, and I know the creator is still active lolz..

1) Am I correct in thinking that by just changing the way it calculates bonuses, I could make it use a "percentage" instead of numbers?such as:

   @temp_stat=@new_stat
   @new_stat=(@temp_stat*1.5)


2) Is this called every time that Game_Actor is called? As in, if the character levels up, is there a way to make it recalculate the bonuses?
Title: Re: [XP] Character Races
Post by: G_G on June 30, 2014, 09:08:04 pm
You'd have to modify the script a bit. The script subtracts and adds bonuses. The bonuses are calculated only once when you setup the player's race. Bonuses aren't added at every level up.
Title: Re: [XP] Character Races
Post by: Marauder93 on August 29, 2014, 01:31:18 pm
Is there an easy way to have the race be displayed in the menu right after the class? There's definitely space for it, as much space as there is for the actor name and class. I'm just getting into scripting so I personally haven't a clue how to do this yet.
Title: Re: [XP] Character Races
Post by: KK20 on August 29, 2014, 01:43:43 pm
Stick this to the end of the script:

class Window_Base < Window
  def draw_actor_race(actor, x, y)
    self.contents.font.color = normal_color
    self.contents.draw_text(x, y, 236, 32, actor.race_name)
  end
end

class Window_Status < Window_Base
  alias draw_actor_race_after_refresh refresh
  def refresh
    draw_actor_race_after_refresh
    draw_actor_race(@actor, 4 + 144 * 2, 0)
  end
end
Title: Re: [XP] Character Races
Post by: Marauder93 on August 29, 2014, 02:55:58 pm
Right at the end of the races script? Didn't work for me, but like I said, still getting the hang of this so might be a tad confused...
Title: Re: [XP] Character Races
Post by: KK20 on August 29, 2014, 03:09:11 pm
Yes, just append the snippet to the end of G_G's script. Tested and works.

Did you put the script below Scene_Debug and above Main?
Title: Re: [XP] Character Races
Post by: Marauder93 on August 29, 2014, 03:18:08 pm
Yep. There's a few other scripts installed however, guess it might be a conflict...

pics

(https://imagizer.imageshack.us/v2/683x328q90/537/nEAzrc.jpg)

where I want the race name (right after class above hp)

(https://imagizer.imageshack.us/v2/524x155q90/537/9m0i2z.jpg)
Title: Re: [XP] Character Races
Post by: KK20 on August 29, 2014, 03:22:32 pm
Ohhhhhhh, that status window. Let me whip that up quick-like.

Append this to the bottom of what I put before.

class Window_MenuStatus < Window_Selectable
  alias draw_races_after_refresh refresh
  def refresh
    draw_races_after_refresh
    for i in 0...$game_party.actors.size
      x = 64
      y = i * 116
      actor = $game_party.actors[i]
      draw_actor_race(actor, x + 144 * 2, y)
    end
  end
end
Title: Re: [XP] Character Races
Post by: Marauder93 on August 29, 2014, 05:05:42 pm
Worked! Much thanks ^_^ and made it look so easy. I really need to wrap my head around this stuff. Just got back into using rpg maker after quite a few years (making a 5th ed D&D inspired thing), so I'll be definitely be frequenting these parts.