[XP] Chrono Trigger Skill Learning

Started by G_G, January 10, 2010, 11:08:05 am

Previous topic - Next topic

G_G

January 10, 2010, 11:08:05 am Last Edit: April 24, 2010, 05:29:26 pm by game_guy
Chrono Trigger Skill Learning
Authors: game_guy
Version: 1.0
Type: Custom Skill Learning
Key Term: Actor Add-on



Introduction

Remember the good old game Chrono Trigger? You already knew skills but you couldn't just use them yet. Each skill needed a certain amount of "AP" to use. You got AP from enemies. Well this script is pretty much the same. If that doesn't make sense then pretty much all it does is make it so you learn skills the same way you did in Chrono Trigger.

If thats not explanatory enough let me make it simpler. You learn skills. You can't use them until you get enough AP for them. Once you have enough AP for them, you can then use them. You get AP from enemies. Simple?


Features


  • Easily setup AP for Enemies
  • Easily setup AP for Skills
  • Display amount AP the skill needs



Screenshots

Spoiler: ShowHide



Demo

MediaFire


Script

This version does not work with Blizz-ABS.
Spoiler: ShowHide

#===============================================================================
# Chrono Trigger SkilL Learning
# Author game_guy
# Version 1.0
#-------------------------------------------------------------------------------
# Intro:
# Remember the good old game Chrono Trigger? You already knew skills but you
# couldn't just use them yet. Each skill needed a certain amount of "AP" to
# use. You got AP from enemies. Well this script is pretty much the same.
#
# Features:
# Easily setup AP for Enemies
# Easily setup AP for Skills
# Display amount AP the skill needs
#
# Instructions:
# Go down and look at the config. Follow the instructions. They're pretty
# simple. If you can't understand it please do ask questions.
#
# Some noteworthy things. Any skill that's not configured will automatically
# be usable. Any enemy that's not configured, its ap will be set to 0.
#
# Credits:
# game_guy ~ for making it
# Chrono Trigger ~ for inspiring me to make this
#===============================================================================
module GameGuy
 #====================================
 # ApWord2 ~ Word used for displaying
 # AP at the end of a battle.
 #====================================
 ApWord2    = "AP"
 #====================================
 # ShowAp ~ If true, it displays the
 # skills current ap in the skill
 # menu.
 #====================================
 ShowAp     = true
 def self.skillptz(id)
   #==============================================================
   # Config Skill Points
   # This is how many points a skill needs to be usable.
   # when skill_id then return points
   # Example: when 1 then return 5
   # So you need 5 "AP" points until Heal is officially learned.
   #==============================================================
   case id
   when 57 then return 10
   when 58 then return 2
   when 59 then return 6
   when 60 then return 8
   end
   return 0
 end
 def self.enemyptz(id)
   #=============================================================
   # Config Enemy Points
   # This is how many points enemies are worth.
   # when enemy_id then return points
   # Example: when 1 then return 1
   # So when ghost is killed you would get 1 ap point.
   #=============================================================
   case id
   when 1 then return 1
   end
   return 0
 end
end
class Game_System
 attr_accessor :pointsa
 alias gg_ct_skills_lat initialize
 def initialize
   @pointsa = []
   return gg_ct_skills_lat
 end
end
class Game_Actor
 alias gg_init_parray_lat setup
 def setup(actor_id)
   $game_system.pointsa[actor_id] = []
   return gg_init_parray_lat(actor_id)
 end
 def learn_skill(skill_id)
   if skill_id > 0 and not skill_learn?(skill_id)
     @skills.push(skill_id)
     @skills.sort!
     $game_system.pointsa[id][skill_id] = 0
   end
 end
 def forget_skill(skill_id)
   @skills.delete(skill_id)
   $game_system.pointsa[id][skill_id] = nil
 end
 def add_points(skill, n)
   unless @skills.include?(skill)
     return
   end
   if $game_system.pointsa[id][skill] == nil
     $game_system.pointsa[id][skill] = 0
   end
   $game_system.pointsa[id][skill] += n
   if $game_system.pointsa[id][skill] > GameGuy.skillptz(skill)
     $game_system.pointsa[id][skill] = GameGuy.skillptz(skill)
   end
 end
 alias gg_skill_can_use_ct_lat skill_can_use?
 def skill_can_use?(skill_id)
   skill = $game_system.pointsa[id][skill_id]
   if skill >= GameGuy.skillptz(skill_id)
     return super
   else
     return false
   end
   return gg_skill_can_use_ct_lat(skill_id)
 end
end
class Scene_Battle
 def start_phase5
   ap = 0
   for enemy in $game_troop.enemies
     eid = enemy.id
     ap += GameGuy.enemyptz(eid)
     for i in $game_party.actors
       arrayt = $game_system.pointsa[i.id]
       for j in i.skills
         $game_actors[i.id].add_points(j, GameGuy.enemyptz(eid))
       end
     end
   end
   @phase = 5
   $game_system.me_play($game_system.battle_end_me)
   $game_system.bgm_play($game_temp.map_bgm)
   exp = 0
   gold = 0
   treasures = []
   for enemy in $game_troop.enemies
     unless enemy.hidden
       exp += enemy.exp
       gold += enemy.gold
       if rand(100) < enemy.treasure_prob
         if enemy.item_id > 0
           treasures.push($data_items[enemy.item_id])
         end
         if enemy.weapon_id > 0
           treasures.push($data_weapons[enemy.weapon_id])
         end
         if enemy.armor_id > 0
           treasures.push($data_armors[enemy.armor_id])
         end
       end
     end
   end
   treasures = treasures[0..5]
   for i in 0...$game_party.actors.size
     actor = $game_party.actors[i]
     if actor.cant_get_exp? == false
       last_level = actor.level
       actor.exp += exp
       if actor.level > last_level
         @status_window.level_up(i)
       end
     end
   end
   $game_party.gain_gold(gold)
   for item in treasures
     case item
     when RPG::Item
       $game_party.gain_item(item.id, 1)
     when RPG::Weapon
       $game_party.gain_weapon(item.id, 1)
     when RPG::Armor
       $game_party.gain_armor(item.id, 1)
     end
   end
   @result_window = Window_BattleResult.new(exp, gold, treasures, ap)
   @phase5_wait_count = 100
 end
end
class Window_BattleResult < Window_Base
 def initialize(exp, gold, treasures, ap)
   @exp = exp
   @gold = gold
   @treasures = treasures
   @ap = ap
   super(160, 0, 320, @treasures.size * 32 + 64)
   self.contents = Bitmap.new(width - 32, height - 32)
   self.y = 160 - height / 2
   self.back_opacity = 160
   self.visible = false
   refresh
 end
 def refresh
   self.contents.clear
   x = 4
   self.contents.font.color = normal_color
   cx = contents.text_size(@exp.to_s).width
   self.contents.draw_text(x, 0, cx, 32, @exp.to_s)
   x += cx + 4
   self.contents.font.color = system_color
   cx = contents.text_size("EXP").width
   self.contents.draw_text(x, 0, 64, 32, "EXP")
   x += cx + 16
   self.contents.font.color = normal_color
   cx = contents.text_size(@gold.to_s).width
   self.contents.draw_text(x, 0, cx, 32, @gold.to_s)
   x += cx + 4
   self.contents.font.color = system_color
   self.contents.draw_text(x, 0, 128, 32, $data_system.words.gold)
   x += cx + 16
   self.contents.font.color = normal_color
   cx = contents.text_size(@ap.to_s).width
   self.contents.draw_text(x, 0, cx, 32, @ap.to_s)
   x += cx + 4
   self.contents.font.color = system_color
   self.contents.draw_text(x, 0, 128, 32, GameGuy::ApWord2)
   y = 32
   for item in @treasures
     draw_item_name(item, 4, y)
     y += 32
   end
 end
end
class Window_Skill < Window_Selectable
 def initialize(actor)
   super(0, 128, 640, 352)
   @actor = actor
   @column_max = 1
   refresh
   self.index = 0
   if $game_temp.in_battle
     self.y = 64
     self.height = 256
     self.back_opacity = 160
   end
 end
 def draw_item(index)
   skill = @data[index]
   if @actor.skill_can_use?(skill.id)
     self.contents.font.color = normal_color
   else
     self.contents.font.color = disabled_color
   end
   x = 4 + index % 1 * (288 + 32)
   y = index / 1 * 32
   rect = Rect.new(x, y, self.width / @column_max - 32, 32)
   self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
   bitmap = RPG::Cache.icon(skill.icon_name)
   opacity = self.contents.font.color == normal_color ? 255 : 128
   self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
   self.contents.draw_text(x + 28, y, 204, 32, skill.name, 0)
   self.contents.draw_text(x + 232, y, 48, 32, skill.sp_cost.to_s, 2)
   if GameGuy::ShowAp
     skillp = $game_system.pointsa[@actor.id][skill.id]
     skillp2 = GameGuy.skillptz(skill.id)
     skillt = skillp.to_s + " / " + skillp2.to_s
     self.contents.draw_text(x, y, 600, 32, skillt, 2)
   end
 end
end


Instead use this one. Place it below Blizz-ABS.
Its now working! :)
Spoiler: ShowHide

#===============================================================================
# Chrono Trigger SkilL Learning
# Author game_guy
# Version 1.0
#-------------------------------------------------------------------------------
# Intro:
# Remember the good old game Chrono Trigger? You already knew skills but you
# couldn't just use them yet. Each skill needed a certain amount of "AP" to
# use. You got AP from enemies. Well this script is pretty much the same.
#
# Features:
# Easily setup AP for Enemies
# Easily setup AP for Skills
# Display amount AP the skill needs
#
# Instructions:
# Go down and look at the config. Follow the instructions. They're pretty
# simple. If you can't understand it please do ask questions.
#
# Some noteworthy things. Any skill that's not configured will automatically
# be usable. Any enemy that's not configured, its ap will be set to 0.
#
# Credits:
# game_guy ~ for making it
# Chrono Trigger ~ for inspiring me to make this
#===============================================================================
module GameGuy
 #====================================
 # ApWord2 ~ Word used for displaying
 # AP at the end of a battle.
 #====================================
 ApWord2    = "AP"
 #====================================
 # ShowAp ~ If true, it displays the
 # skills current ap in the skill
 # menu.
 #====================================
 ShowAp     = true
 def self.skillptz(id)
   #==============================================================
   # Config Skill Points
   # This is how many points a skill needs to be usable.
   # when skill_id then return points
   # Example: when 1 then return 5
   # So you need 5 "AP" points until Heal is officially learned.
   #==============================================================
   case id
   when 57 then return 10
   end
   return 0
 end
 def self.enemyptz(id)
   #=============================================================
   # Config Enemy Points
   # This is how many points enemies are worth.
   # when enemy_id then return points
   # Example: when 1 then return 1
   # So when ghost is killed you would get 1 ap point.
   #=============================================================
   case id
   when 1 then return 1
   end
   return 1
 end
end
if !$BlizzABS || BlizzABS::VERSION < 2.7
 raise 'CT Skill Learning needs Blizz-ABS of version 2.7. RMXP will now close.'
end
class Game_System
 attr_accessor :pointsa
 alias gg_ct_skills_lat initialize
 def initialize
   @pointsa = []
   return gg_ct_skills_lat
 end
end
class Game_Actor
 alias gg_init_parray_lat setup
 def setup(actor_id)
   $game_system.pointsa[actor_id] = []
   return gg_init_parray_lat(actor_id)
 end
 def learn_skill(skill_id)
   if skill_id > 0 and not skill_learn?(skill_id)
     @skills.push(skill_id)
     @skills.sort!
     $game_system.pointsa[id][skill_id] = 0
   end
 end
 def forget_skill(skill_id)
   @skills.delete(skill_id)
   $game_system.pointsa[id][skill_id] = nil
 end
 def add_points(skill, n)
   unless @skills.include?(skill)
     return
   end
   if $game_system.pointsa[id][skill] == nil
     $game_system.pointsa[id][skill] = 0
   end
   $game_system.pointsa[id][skill] += n
   if $game_system.pointsa[id][skill] > GameGuy.skillptz(skill)
     $game_system.pointsa[id][skill] = GameGuy.skillptz(skill)
   end
 end
 alias gg_skill_can_use_ct_lat skill_can_use?
 def skill_can_use?(skill_id)
   skill = $game_system.pointsa[id][skill_id]
   if skill >= GameGuy.skillptz(skill_id)
     return super
   else
     return false
   end
   return gg_skill_can_use_ct_lat(skill_id)
 end
end
class Window_Skill < Window_Selectable
 def initialize(actor)
   super(0, 128, 640, 352)
   @actor = actor
   @column_max = 1
   refresh
   self.index = 0
   if $game_temp.in_battle
     self.y = 64
     self.height = 256
     self.back_opacity = 160
   end
 end
 def draw_item(index)
   skill = @data[index]
   if @actor.skill_can_use?(skill.id)
     self.contents.font.color = normal_color
   else
     self.contents.font.color = disabled_color
   end
   x = 4 + index % 1 * (288 + 32)
   y = index / 1 * 32
   rect = Rect.new(x, y, self.width / @column_max - 32, 32)
   self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
   bitmap = RPG::Cache.icon(skill.icon_name)
   opacity = self.contents.font.color == normal_color ? 255 : 128
   self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
   self.contents.draw_text(x + 28, y, 204, 32, skill.name, 0)
   self.contents.draw_text(x + 232, y, 48, 32, skill.sp_cost.to_s, 2)
   if GameGuy::ShowAp
     skillp = $game_system.pointsa[@actor.id][skill.id]
     skillp2 = GameGuy.skillptz(skill.id)
     skillt = skillp.to_s + " / " + skillp2.to_s
     self.contents.draw_text(x, y, 600, 32, skillt, 2)
   end
 end
end
module BlizzABS
  class Processor
    alias gg_add_ap_ct_abs_lat remove_enemy
    def remove_enemy(enemy)
      gg_add_ap_ct_abs_lat(enemy)
      ap = GameGuy.enemyptz(enemy.enemy.id)
      for i in $game_party.actors
        arrayt = $game_system.pointsa[i.id]
        for j in i.skills
          $game_actors[i.id].add_points(j, ap)
        end
      end
    end
  end
end
$BlizzABS = BlizzABS::Processor.new



Instructions

Instructions are in the script.
If you're using the Blizz-ABS version place it below Blizz-ABS.


Compatibility

Not tested with SDK.
Seperate version made for Blizz-ABS.


Credits and Thanks


  • game_guy ~ for making it
  • Chrono Trigger ~ for inspiring me to make this



Author's Notes

Please post any bugs or questions! Enjoy!

Spaceman McConaughey

Ah, nice simple and easy. Like it. +rep ;D

G_G

Thanks! :)

Also updated Blizz-ABS Version. It works now.

Aqua


G_G

Nice catch Aqua! I actually thought I did but I guess I didn't. =\
Anyways update again.

EDIT:
Thoughts on the script?

Eternal

I have some questions: how do you get AP from enemies? What does AP stand for (Allstart Power? Aristocratic Peoplez?)? What is it? And how come you can have 10/10 if you only have 4/6 with another spell? I mean last time I checked 10 was higher than 4...



-Eternally Unknowing

G_G

If you tried out the demo, and fought the enemy you would have gotten 2 AP. "Ability Points".
Also in the demo if you talk to one of the people they give Cross Cut all 10 AP.

If you have anymore questions feel free to ask!

Eternal

January 11, 2010, 10:02:39 am #7 Last Edit: January 11, 2010, 10:08:52 am by Eternal
I haven't played the demo yet (I dont have infinite space on my drives..), but I'm gonna, this sounds cool.

But I do have another question: when you get AP, which spell(s) do(es) it/they go to? Do you fx. get 2 AP for every spell, or is it given randomly, or do you choose?

I know I could just play the demo but 1) ur online and 2)
Quote from: ME!!I dont have infinite space on my drives..

G_G

For every skill each player in the party knows gains ap.

Eternal


(Hexamin)

March 08, 2010, 03:03:21 pm #10 Last Edit: March 08, 2010, 03:05:00 pm by (Hexamin)


So how's this work with BABS?  Does it show the AP requirements on the map?  Etc... etc...
Max 1111101000; characters remaining: 1110111000

G_G

Nope, it shows the AP requirement in the skill menu I believe.

G_G

PHSYCHO!

Updated the Blizz-Abs plugin. Fixed AP Adding bug.

Moshan

I'm having a problem with this script.....When I'm trying to attack an enemy(configured for Chrono Trigger) it shows me this error: Script: 'chrono' line 159: NoMethodError occurred. undefined method 'enemy' for #<Map_enemy:0x3bae258>....I'm using Blizz-ABS

G_G

See this line?
ap = GameGuy.enemyptz(enemy.enemy.id)

Try changing it to
ap = GameGuy.enemyptz(enemy.id)

If that doesn't work I'll take a look at it after school.

Shalaren

sorry for necro posting
but is there a way I can have an event give AP points? instead of just killing enemies.
like if a player completes a mission he gets X amount of points (no killing enemies involved)

KK20

$game_actors[actor_id].add_points(skill_id, amount) #actor_id = 1..however big your actor database size is
# OR you can do
$game_party.actors[party_position].add_points(skill_id, amount) #party_position = 0..however many party members you have - 1





   


   
   


   
   

Other Projects
RPG Maker XP AceUpgrade RMXP to RMVXA performance!
XPA TilemapTilemap rewrite with many features, including custom resolution!



Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

Shalaren

Thank you :) one more thing tho
anyway to make it so it adds AP to all skills? instead of picking just one skill_id
so basically it adding X amount of AP to all skills together

KK20

Easy Way: ShowHide

Add this to the script:

class Game_Actor
  def add_points_all(amount)
    for i in @skills
      add_points(i, amount)
    end
  end
end

And call it with:

$game_actors[actor_id].add_points_all(amount)
# OR
$game_party.actors[party_position].add_points_all(amount)

Or to do it for all party members

for actor in $game_party.actors
actor.add_points_all(AMOUNT)
end


Scripter's Way: ShowHide

In the script call:

actor = $game_actors[ACTOR_ID]
for skill in actor.skills
actor.add_points(skill, AMOUNT)
end

and replace the capitalized parameters with your actual values.
To do it for the entire party:

for actor in $game_party.actors
for skill in actor.skills
actor.add_points(skill, AMOUNT)
end
end






   


   
   


   
   

Other Projects
RPG Maker XP AceUpgrade RMXP to RMVXA performance!
XPA TilemapTilemap rewrite with many features, including custom resolution!



Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!