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.

Script needs help to modify

Im trying to get the second character in my party to change after a certian level and its not working with this script... also i would like to add and take away skills at the levels two, and i would like to change class of this character. can you help???

heres the script:
#----------------
# Level: Character Graphic Change
#----------------
class Scene_Map
# This is for aliasing the code to Scene_Map
alias levelgraphicchange_update update
def update

# $game_actors[ACTOR ID].level.between?(MIN LEVEL, MAX LEVEL)
if $game_actors[1].level.between?(6, 15)
# $game_party.actors[ACTOR ID].set_graphic("CHARSET FILE NAME", HUE, BATTLER, HUE)
$game_party.actors[0].set_graphic("002-Fighter02", 0, "002-Fighter02", 0)
# Update the graphic
$game_player.refresh
end

# $game_actors[ACTOR ID].level.between?(MIN LEVEL, MAX LEVEL)
if $game_actors[1].level.between?(16, 30)
# $game_party.actors[ACTOR ID].set_graphic("CHARSET FILE NAME", HUE, BATTLER, HUE)
$game_party.actors[0].set_graphic("003-Fighter03", 0, "002-Fighter02", 0)
# Update the graphic
$game_player.refresh
end

# $game_actors[ACTOR ID].level.between?(MIN LEVEL, MAX LEVEL)
if $game_actors[1].level.between?(31, 50)
# $game_party.actors[ACTOR ID].set_graphic("CHARSET FILE NAME", HUE, BATTLER, HUE)
$game_party.actors[0].set_graphic("004-Fighter04", 0, "002-Fighter02", 0)
# Update the graphic
$game_player.refresh
end

# $game_actors[ACTOR ID].level.between?(MIN LEVEL, MAX LEVEL)
if $game_actors[1].level.between?(51, 77)
# $game_party.actors[ACTOR ID].set_graphic("CHARSET FILE NAME", HUE, BATTLER, HUE)
$game_party.actors[0].set_graphic("005-Fighter05", 0, "002-Fighter02", 0)
# Update the graphic
$game_player.refresh
end
levelgraphicchange_update
end
end
 
Even if it works, I think it does unnecessary checking (and actor changes), since that method is called as long as player is on the map (might slow down their computer). I made a better script that executes just as an actor levels up (either by winning battle or via Change Level event). It might not best match your needs (since I think it's doable to other actors too), so if anything doesn't match, tell me and I'll fix it.

Just copy and paste this script above Main:
Code:
# SETTINGS BEGIN

# specify in which position your actor will change
# may be filled more than 1 position
# zero-based (so 1st actor is in pos 0, 2nd in pos 1, and so on)
POS_TO_CHANGE = [1]

# changes details...
ACTOR_TO_CHANGE =
{
1 => # position in party
  {
    2 => # minimum level to reach
    {
    # ----------- GRAPHIC CHANGE -------------------
    :change_chara_graph => false, # set false to keep chara graphic
    # OMIT these settings if you don't change graphic
    :new_character_name => "003-Fighter03",
    :new_character_hue  => 0,
    :new_battler_name   => "003-Fighter03",
    :new_battler_hue    => 0,
    # ------------- CLASS CHANGE -------------------
    :change_class       => true, # set false to keep current class
    # OMIT this setting if you don't change class
    :new_class_id       => 3,
    # ------------- SKILL CHANGE -------------------
    :change_skill       => false, # set false to keep current skill
    # OMIT these settings if you don't change skill
    :new_skills         => [1, 2, 3],
    :omit_old_skills    => false # set false to keep old skills
    },
    3 =>
    {
    :change_chara_graph => false,
    :new_character_name => "003-Fighter03",
    :new_character_hue  => 0,
    :new_battler_name   => "003-Fighter03",
    :new_battler_hue    => 0,
    :change_class       => false,
    :new_class_id       => 3,
    :change_skill       => true,
    :new_skills         => [1, 2, 3],
    :omit_old_skills    => false
    },
    6 => # minimum level to reach
    {
    :change_chara_graph => true,
    :new_character_name => "003-Fighter03",
    :new_character_hue  => 0,
    :new_battler_name   => "003-Fighter03",
    :new_battler_hue    => 0,
    :change_class       => false,
    :new_class_id       => 3,
    :change_skill       => false,
    :new_skills         => [1, 2, 3],
    :omit_old_skills    => false
    },
    15 =>
    {
    :change_chara_graph => true,
    :new_character_name => "004-Fighter04",
    :new_character_hue  => 0,
    :new_battler_name   => "004-Fighter04",
    :new_battler_hue    => 0,
    :change_class       => false,
    :new_class_id       => 3,
    :change_skill       => false,
    :new_skills         => [1, 2, 3],
    :omit_old_skills    => false
    }
    # and so on...
  }
# you can also add more position here, following the same pattern as above...
}

# SETTINGS END
# Enjoy! ;)

class Game_Actor
  #--------------------------------------------------------------------------
  # * Change EXP
  #     exp : new EXP
  #--------------------------------------------------------------------------
  def exp=(exp)
    @exp = [[exp, 9999999].min, 0].max
    # Level up
    while @exp >= @exp_list[@level+1] and @exp_list[@level+1] > 0
      @level += 1
      check_actor_for_changes
      # Learn skill
      for j in $data_classes[@class_id].learnings
        if j.level == @level
          learn_skill(j.skill_id)
        end
      end
    end
    # Level down
    while @exp < @exp_list[@level]
      @level -= 1
      check_actor_for_changes
    end
    # Correction if exceeding current max HP and max SP
    @hp = [@hp, self.maxhp].min
    @sp = [@sp, self.maxsp].min
  end
  
  def check_actor_for_changes
    # position need to change?
    unless POS_TO_CHANGE.empty?
      for pos in POS_TO_CHANGE
        # just checking, in case you don't specify the changes for this position...
        if ACTOR_TO_CHANGE.has_key?(pos)
          actor = $game_party.actors[pos]
          return if actor == nil
          # need changes?
          if ACTOR_TO_CHANGE[pos].has_key?(actor.level)
            # save typing :P
            temp = ACTOR_TO_CHANGE[pos][actor.level]
            # need graphic change?
            if temp[:change_chara_graph]
              # need change, change it now
              actor.set_graphic(temp[:new_character_name], temp[:new_character_hue], temp[:new_battler_name], temp[:new_battler_hue])
#              p "Graphic changed!"
            end
            # need class change?
            if temp[:change_class]
#                p "Class changed!"
                actor.class_id = temp[:new_class_id]
            end
            # need skill change?
            if temp[:change_skill]
              # keep old skills?
              if temp[:omit_old_skills]
                # remove old skills
                actor.skills = []
              end
              # now learn new skills
              for skill_id in temp[:new_skills]
                actor.learn_skill(skill_id)
              end
#              p "Skills changed"
            end
          end
        end
      end
    end
  end
end

Compatibility: Should work with other scripts that do not modify Game_Actor class, exp=(exp) method. Not tested with SDK...
 
I wrote a false comment for :change_skill, it should be # set true to change skills.

Did you set :change_skill to true? If set false, skills won't be changed when leveling up, even though you put skill IDs to :new_skills.
 
I have done that.. it is the second script that failed me... says something to do with the new skills or something the part with the new_skills [] and there is the blank box...i tried to fill it but no go!
 
I see, you didn't mention there was an error... I thought it was only a misconfiguration. Silly me ^_^;

Find this line:
Code:
                # remove old skills
                actor.skills = []
and replace it with this one:
Code:
                # remove old skills
                actor.skills.clear

Should there be other errors, let me know.
 
The Script works perfect now :thumb: , but one thing is wrong ':| ... the graphic in the map stays the same for the character in the party position 2... can that get changed or what?
Thats the onlything wrong now!!! makes me sad...
 
Second character in the map? Did you use caterpillar script (or something like that)? By default, only the first character will show on the map.

By the way, if it's the first actor whose graphic is changed, his/her graphic on the map will be still the old one. I really forgot that, sorry :)

Actually it can be fixed by adding one line of script. Find this line:
Code:
              # need change, change it now
              actor.set_graphic(temp[:new_character_name], temp[:new_character_hue], temp[:new_battler_name], temp[:new_battler_hue])
and immediately add this new line below that line:
Code:
              $game_player.refresh

If you need the full version of this script, let me know and I'll repost it.

That should work fine now (I don't know with caterpillar script, but hope it works too).
 
Here you go. I'll provide my full script so you can just delete my old one. Make a new page below Caterpillar script and before Main:

Code:
# SETTINGS BEGIN

# specify in which position your actor will change
# may be filled more than 1 position
# zero-based (so 1st actor is in pos 0, 2nd in pos 1, and so on)
POS_TO_CHANGE = [1]

# changes details...
ACTOR_TO_CHANGE =
{
1 => # position in party
  {
    2 => # minimum level to reach
    {
    # ----------- GRAPHIC CHANGE -------------------
    :change_chara_graph => false, # set false to keep chara graphic
    # OMIT these settings if you don't change graphic
    :new_character_name => "003-Fighter03",
    :new_character_hue  => 0,
    :new_battler_name   => "003-Fighter03",
    :new_battler_hue    => 0,
    # ------------- CLASS CHANGE -------------------
    :change_class       => true, # set false to keep current class
    # OMIT this setting if you don't change class
    :new_class_id       => 3,
    # ------------- SKILL CHANGE -------------------
    :change_skill       => false, # set true to change skills
    # OMIT these settings if you don't change skill
    :new_skills         => [1, 2, 3],
    :omit_old_skills    => false # set false to keep old skills
    },
    3 =>
    {
    :change_chara_graph => false,
    :new_character_name => "003-Fighter03",
    :new_character_hue  => 0,
    :new_battler_name   => "003-Fighter03",
    :new_battler_hue    => 0,
    :change_class       => false,
    :new_class_id       => 3,
    :change_skill       => true,
    :new_skills         => [1, 2, 3],
    :omit_old_skills    => false
    },
    6 => # minimum level to reach
    {
    :change_chara_graph => true,
    :new_character_name => "003-Fighter03",
    :new_character_hue  => 0,
    :new_battler_name   => "003-Fighter03",
    :new_battler_hue    => 0,
    :change_class       => false,
    :new_class_id       => 3,
    :change_skill       => false,
    :new_skills         => [1, 2, 3],
    :omit_old_skills    => false
    },
    15 =>
    {
    :change_chara_graph => true,
    :new_character_name => "004-Fighter04",
    :new_character_hue  => 0,
    :new_battler_name   => "004-Fighter04",
    :new_battler_hue    => 0,
    :change_class       => false,
    :new_class_id       => 3,
    :change_skill       => false,
    :new_skills         => [1, 2, 3],
    :omit_old_skills    => false
    }
    # and so on...
  }
# you can also add more position here, following the same pattern as above...
}

# SETTINGS END
# Enjoy! ;)

class Game_Actor
  #--------------------------------------------------------------------------
  # * Change EXP
  #     exp : new EXP
  #--------------------------------------------------------------------------
  def exp=(exp)
    @exp = [[exp, 9999999].min, 0].max
    # Level up
    while @exp >= @exp_list[@level+1] and @exp_list[@level+1] > 0
      @level += 1
      check_actor_for_changes
      # Learn skill
      for j in $data_classes[@class_id].learnings
        if j.level == @level
          learn_skill(j.skill_id)
        end
      end
    end
    # Level down
    while @exp < @exp_list[@level]
      @level -= 1
      check_actor_for_changes
    end
    # Correction if exceeding current max HP and max SP
    @hp = [@hp, self.maxhp].min
    @sp = [@sp, self.maxsp].min
  end
  
  def check_actor_for_changes
    # position need to change?
    unless POS_TO_CHANGE.empty?
      for pos in POS_TO_CHANGE
        # just checking, in case you don't specify the changes for this position...
        if ACTOR_TO_CHANGE.has_key?(pos)
          actor = $game_party.actors[pos]
          return if actor == nil
          # need changes?
          if ACTOR_TO_CHANGE[pos].has_key?(actor.level)
            # save typing :P
            temp = ACTOR_TO_CHANGE[pos][actor.level]
            # need graphic change?
            if temp[:change_chara_graph]
              # need change, change it now
              actor.set_graphic(temp[:new_character_name], temp[:new_character_hue], temp[:new_battler_name], temp[:new_battler_hue])
              $game_party.refresh_sprites
#              p "Graphic changed!"
            end
            # need class change?
            if temp[:change_class]
#                p "Class changed!"
                actor.class_id = temp[:new_class_id]
            end
            # need skill change?
            if temp[:change_skill]
              # keep old skills?
              if temp[:omit_old_skills]
                # remove old skills
                actor.skills.clear
              end
              # now learn new skills
              for skill_id in temp[:new_skills]
                actor.learn_skill(skill_id)
              end
#              p "Skills changed"
            end
          end
        end
      end
    end
  end
end

class Game_Party
  def refresh_sprites
      for i in 1 .. 4
        @characters[i - 1].setup(actors[i])
      end
  end
end

It should work now; if not, let me know.
 
Wow I think you just made a ninja fall out of stealth@_@ , wet himself':| , and everyone pointed and laughed at himO_o ...

Amazing dude it works perfectly now...

um... oh yeah... i also forgot... change hero name?
can you do that... you don't have to repost the entire script again.. just post the missing piece...

I'm gonna go see if i can find how to add an animation in there like so

animation 102
wait 10
animation 103

if you can post back before it would be nice...
oh and if you want cridet, I'd be glad to give it just tell me any information to post for your credit and you got it!


EDIT!!! Below
This is what i have found but no luck with getting it to work

:$animations.push(Animation.new('player',0,0,102[loop.false,sound.true,viewport.'screen'])),

tricksters script... here is the link

http://www.rmxp.org/forums/showthread.php?t=3292&highlight=show+animation+script
 
Okay, what problem do you have with change hero name? It's doable via events... Or do you want me to update my script so it can change hero name when s/he levels up?

And do you want animations when changing the character graphic?

By the way, your call is wrong, it should be

Code:
$animations.push(Animation.new('player', 0, 0, 102))

If ever you need to specify loop, sound, and viewport, you'd do something like this:

Code:
$animations.push(Animation.new('player', 0, 0, 102[b], 2, true, [i]<something here, I don't know the possible values>[/i][/b]))

I didn't find Trickster's script by the way...

Feel free to credit me or not :)
 
YES YES!!!

it is what i want indeed... hehe...
to have the name change in the script event... as the level changes...
that would be nice...
and the animation as well... i have two seperate animations that i was going to use like my example i want one to go and then wait and then the other...
 
For the name change, will it be fixed (you enter a new name to the script so player will have to use that name) or player can enter a desirable new name?

I guess you want to do animations in map, don't you? Have you tried using normal events? I didn't get it though...
 
hey its no problem... don't worry about it... i would love to use the animations in the map when the character reaches a certain level, but no sweat... and the name change... i guess i can't change it then... but those i will work on that myself then...
 
please give me a hint... i tried... lol... can't do it... to much to try from... i thought you said it wasn't doable... lol... well anyway... it would be helpfull... and im still lost with the animations... well yay! I am kinda hungry...
 

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