08-25-2007, 01:00 PM
(This post was last modified: 05-24-2017, 04:55 AM by DerVVulfman.)
Spell Tablet System
GubiD
Aug 25, 2007
Want to make it so everyone can learn spells/skills, but not require them to be a mage? With the below script you can assign a "TABLET" that will teach the wielding character spells/skills that are assigned to that tablet, but its not that simple. You must earn them using AP(Ability Points) that is generated from the enemies you fight. This system allows you to earn AP from enemies and when you have enough, the associated skill from the tablet.
here is the code
ou will notice that it also uses cogwheels HP/SP/EXP bars in the menu along with Character Graphics instead of walk graphics. (It uses character name to determine file name for the picture.)
If you are not a code buff, then you can also download the demo from mediafire at the following link
LINK
Edit: Updated post, cause I noticed that the spoiler and codebox weren't working correctly. I split it up and now it seems to work correctly. There has been no actual change to the above code at this time.
GubiD
Aug 25, 2007
This is a locked, single-post thread from Creation Asylum. Archived here to prevent its loss.
No support is given. If you are the owner of the thread, please contact administration.
No support is given. If you are the owner of the thread, please contact administration.
Want to make it so everyone can learn spells/skills, but not require them to be a mage? With the below script you can assign a "TABLET" that will teach the wielding character spells/skills that are assigned to that tablet, but its not that simple. You must earn them using AP(Ability Points) that is generated from the enemies you fight. This system allows you to earn AP from enemies and when you have enough, the associated skill from the tablet.
here is the code
Script Part 1
Code:
#------------------------------------------------------------------------------
# Spell Tablet System
# by GubiD
# v1.0
# Last modified 8/14/07
#------------------------------------------------------------------------------
module Tablets
#--------------------------------------------------------------------
#Tablets are refrenced as though they are characters in the database.
#characters whos numbers are listed below will be "tablets." Keep in
#mind that skills assigned to the characters will be ignored as they are
#assigned in the Tablets module below for access reasons.
#--------------------------------------------------------------------
def self.tablets
return [61,62,63,64,65,66,67,68,69,70]
end
#--------------------------------------------------------------------
#Skills are determined for each tablet according to character number.
#When TABLETID; return[[Skill_ID_1, Rate],[Skill_ID_2, Rate],...]
#--------------------------------------------------------------------
def self.skills(tablet)
case tablet
when 61; return [ [1,5], [7,10] ]
when 62; return [ [7, 15], [8, 5] ]
end
end
end
#------------------------------------------------------------------------------
# Spell Tablet System
# by GubiD
# v1.0
# Last modified 8/14/07
#------------------------------------------------------------------------------
class Scene_Menu
def main
# Make command window
s1 = $data_system.words.item
s2 = $data_system.words.skill
s3 = $data_system.words.equip
s4 = "Status"
##CHANGED##
s5 = "Tablets"
s6 = "Save"
s7 = "End Game"
@command_window = Window_Command.new(160, [s1, s2, s3, s4, s5, s6, s7])
##END CHANGED##
@command_window.index = @menu_index
# If number of party members is 0
if $game_party.actors.size == 0
# Disable items, skills, equipment, and status
@command_window.disable_item(0)
@command_window.disable_item(1)
@command_window.disable_item(2)
@command_window.disable_item(3)
end
@tab_disabled = false
##########THIS IS NEW#############
if $game_party.tablets.size == 0
@command_window.disable_item(4)
@tab_disabled = true
end
###########END NEW################
# If save is forbidden
if $game_system.save_disabled
# Disable save
@command_window.disable_item(4)
end
# Make play time window
@playtime_window = Window_PlayTime.new
@playtime_window.x = 0
@playtime_window.y = 239
# Make steps window
@steps_window = Window_Steps.new
@steps_window.x = 0
@steps_window.y = 330
# Make gold window
@gold_window = Window_Gold.new
@gold_window.x = 0
@gold_window.y = 416
# Make status window
@status_window = Window_MenuStatus.new
@status_window.x = 160
@status_window.y = 0
# Execute transition
Graphics.transition
# Main loop
loop do
# Update game screen
Graphics.update
# Update input information
Input.update
# Frame update
update
# Abort loop if screen is changed
if $scene != self
break
end
end
# Prepare for transition
Graphics.freeze
# Dispose of windows
@command_window.dispose
@playtime_window.dispose
@steps_window.dispose
@gold_window.dispose
@status_window.dispose
end
#--------------------------------------------------------------------------
# * Frame Update (when command window is active)
#--------------------------------------------------------------------------
def update_command
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Switch to map screen
$scene = Scene_Map.new
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# If command other than save or end game, and party members = 0
if $game_party.actors.size == 0 and @command_window.index < 4
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
# Branch by command window cursor position
case @command_window.index
when 0 # item
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to item screen
$scene = Scene_Item.new
when 1 # skill
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Make status window active
@command_window.active = false
@status_window.active = true
@status_window.index = 0
when 2 # equipment
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Make status window active
@command_window.active = false
@status_window.active = true
@status_window.index = 0
when 3 # status
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Make status window active
@command_window.active = false
@status_window.active = true
@status_window.index = 0
when 4 # Tablets
if @tab_disabled == false
$game_system.se_play($data_system.decision_se)
# Make status window active
@command_window.active = false
@status_window.active = true
@status_window.index = 0
else
$game_system.se_play($data_system.buzzer_se)
end
when 5 # save
# If saving is forbidden
if $game_system.save_disabled
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to save screen
$scene = Scene_Save.new
when 6 # end game
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to end game screen
$scene = Scene_End.new
end
return
end
end
#--------------------------------------------------------------------------
# * Frame Update (when status window is active)
#--------------------------------------------------------------------------
def update_status
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Make command window active
@command_window.active = true
@status_window.active = false
@status_window.index = -1
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# Branch by command window cursor position
case @command_window.index
when 1 # skill
# If this actor's action limit is 2 or more
if $game_party.actors[@status_window.index].restriction >= 2
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to skill screen
$scene = Scene_Skill.new(@status_window.index)
when 2 # equipment
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to equipment screen
$scene = Scene_Equip.new(@status_window.index)
when 3 # status
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to status screen
$scene = Scene_Status.new(@status_window.index)
when 4 #Tablets
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to status screen
$scene = Scene_Tablet.new(@status_window.index)
end
return
end
end
end
class Window_MenuStatus < Window_Selectable
def refresh
@sprites = []
self.contents.clear
@item_max = $game_party.actors.size
for i in 0...$game_party.actors.size
x = 64
y = i * 116
actor = $game_party.actors[i]
#draw_actor_graphic(actor, x - 40, y + 80)
sprite = Sprite.new
sprite.bitmap = RPG::Cache.picture(actor.name)
sprite.x = x*3 - 20
sprite.y = (i*110)+10
sprite.z = 5000
@sprites.push(sprite)
draw_actor_name(actor, x + 20, y)
draw_actor_class(actor, x + 144, y)
draw_actor_level(actor, x + 10, y + 32)
draw_actor_state(actor, x + 90, y + 32)
draw_actor_exp(actor, x + 10, y + 64)
draw_actor_hp(actor, x + 236, y + 32)
draw_actor_sp(actor, x + 236, y + 64)
end
end
alias menu_status_update update
def update
menu_status_update
for sprite in @sprites
sprite.update
end
end
def dispose
# Dispose if window contents bit map is set
if self.contents != nil
self.contents.dispose
end
if @sprites.size > 0
for sprite in @sprites
sprite.dispose
end
end
super
end
end
#------------------------------------------------------------------------------
# Spell Tablet System
# by GubiD
# v1.0
# Last modified 8/14/07
#------------------------------------------------------------------------------
class Scene_Save < Scene_File
#--------------------------------------------------------------------------
# * Decision Processing
#--------------------------------------------------------------------------
def on_decision(filename)
# Play save SE
$game_system.se_play($data_system.save_se)
# Write save data
file = File.open(filename, "wb")
write_save_data(file)
file.close
# If called from event
if $game_temp.save_calling
# Clear save call flag
$game_temp.save_calling = false
# Switch to map screen
$scene = Scene_Map.new
return
end
# Switch to menu screen
##########CHANGE#########
$scene = Scene_Menu.new(5)
##########END CHANGE#########
end
#--------------------------------------------------------------------------
# * Cancel Processing
#--------------------------------------------------------------------------
def on_cancel
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# If called from event
if $game_temp.save_calling
# Clear save call flag
$game_temp.save_calling = false
# Switch to map screen
$scene = Scene_Map.new
return
end
# Switch to menu screen
##########CHANGE#########
$scene = Scene_Menu.new(5)
##########END CHANGE#########
end
end
#------------------------------------------------------------------------------
# Spell Tablet System
# by GubiD
# v1.0
# Last modified 8/14/07
#------------------------------------------------------------------------------
class Scene_End
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
# Update command window
@command_window.update
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Switch to menu screen
###CHANGE###
$scene = Scene_Menu.new(6)
###END CHANGE###
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# Branch by command window cursor position
case @command_window.index
when 0 # to title
command_to_title
when 1 # shutdown
command_shutdown
when 2 # quit
command_cancel
end
return
end
end
#--------------------------------------------------------------------------
# * Process When Choosing [Cancel] Command
#--------------------------------------------------------------------------
def command_cancel
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to menu screen
##########CHANGE#########
$scene = Scene_Menu.new(6)
##########END CHANGE#########
end
end
#------------------------------------------------------------------------------
# Spell Tablet System
# by GubiD
# v1.0
# Last modified 8/14/07
#------------------------------------------------------------------------------
class Window_Base
#--------------------------------------------------------------------------
# * Draw learned skill name -
# skill : skill_id
# x : draw spot x-coordinate
# y : draw spot y-coordinate
#--------------------------------------------------------------------------
def draw_learned_skill_name(actor_id, skill_id, x, y)
if skill_id == nil
return
end
actor = $data_actors[actor_id]
skill = $data_skills[skill_id]
bitmap = RPG::Cache.icon(skill.icon_name)
self.contents.font.color = normal_color
self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
self.contents.draw_text(x + 28, y, 240, 32, actor.name + " learned " + skill.name, 0)
end
def draw_skill_name(skill_id, x, y)
if skill_id == nil
return
end
skill = $data_skills[skill_id]
bitmap = RPG::Cache.icon(skill.icon_name)
self.contents.font.color = normal_color
self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
self.contents.draw_text(x + 28, y, 240, 32, skill.name, 0)
end
end
#------------------------------------------------------------------------------
# Spell Tablet System
# by GubiD
# v1.0
# Last modified 8/14/07
#------------------------------------------------------------------------------
# Description:
# This system allows you to each AP (Ability Points) from enemies, which in turn
# is used to learn spells from the assigned Spell Tablet.
#
#------------------------------------------------------------------------------
# Updates:
# All updates that were made, were made to the native system. This script
# should work with most other scripts, except for those that modify the
# Scene_Battle, Battle Results window, or another CMS system.
#------------------------------------------------------------------------------
# Changes:
# If you would like to see changes made to any part of this script, please PM
# me at www.creationasylum.net.
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
# Spell Tablet System
# by GubiD
# v1.0
# Last modified 8/14/07
#------------------------------------------------------------------------------
class Scene_Battle
#--------------------------------------------------------------------------
# * Start After Battle Phase
#--------------------------------------------------------------------------
def start_phase5
# Shift to phase 5
@phase = 5
# Play battle end ME
$game_system.me_play($game_system.battle_end_me)
# Return to BGM before battle started
$game_system.bgm_play($game_temp.map_bgm)
# Initialize EXP, amount of gold, and treasure
exp = 0
gold = 0
treasures = []
newskills = []
ap = 0
# Loop
for enemy in $game_troop.enemies
# If enemy is not hidden
unless enemy.hidden
# Add EXP and amount of gold obtained
exp += enemy.exp
gold += enemy.gold
ap += enemy.ap
# Determine if treasure appears
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
# Treasure is limited to a maximum of 6 items
treasures = treasures[0..5]
# check skills learned
for j in 0...$game_party.actors.size
actor2 = $game_party.actors[j]
if actor2.tablet > 0
spiritskills = Tablets::skills(actor2.tablet)
for k in 0...spiritskills.size
ap_earned = ap
skill_id = spiritskills[k][0]
rate = spiritskills[k][1]
ap_earned = ap * rate
if $game_actors[actor2.id].learning[skill_id] < 100
$game_actors[actor2.id].learning[skill_id] += ap_earned
if $game_actors[actor2.id].learning[skill_id] >= 100
$game_actors[actor2.id].learning[skill_id] = 100
$game_actors[actor2.id].learn_skill(skill_id)
newskills.push([actor2.id,skill_id])
end
end
end
end
end
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)
$game_system.se_play($data_system.cancel_se)
end
end
end
# Obtaining gold
$game_party.gain_gold(gold)
# Obtaining treasure
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
# Make battle result window
@result_window = Window_BattleResult.new(exp, gold, treasures, newskills, ap)
# Set wait count
@phase5_wait_count = 100
end
end
#------------------------------------------------------------------------------
# Spell Tablet System
# by GubiD
# v1.0
# Last modified 8/14/07
#------------------------------------------------------------------------------
#==============================================================================
# ** Window_BattleResult
#------------------------------------------------------------------------------
# This window displays amount of gold and EXP acquired at the end of a battle.
#==============================================================================
class Window_BattleResult < Window_Base
#--------------------------------------------------------------------------
# * Object Initialization
# exp : EXP
# gold : amount of gold
# treasures : treasures
#--------------------------------------------------------------------------
def initialize(exp, gold, treasures, newskills, ap)
@exp = exp
@gold = gold
@treasures = treasures
@newskills = newskills
@ap = ap
super(160, 0, 320, (@treasures.size * 32) + (@newskills.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
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
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
cx = contents.text_size("AP").width
self.contents.draw_text(x, 0, 64, 32, "AP")
x += cx + 16
y = 32
for item in @treasures
draw_item_name(item, 4, y)
y += 32
end
for skill in @newskills
draw_learned_skill_name(skill[0], skill[1], 4, y)
y += 32
end
end
end
Script Part 2
Code:
#------------------------------------------------------------------------------
# Spell Tablet System
# by GubiD
# v1.0
# Last modified 8/14/07
#------------------------------------------------------------------------------
class Scene_Tablet
def initialize(actor_index = 0, tablet_index = 0)
@actor = $game_party.actors[actor_index]
end
def main
#create background image
@sprite = Sprite.new
#@sprite.bitmap = RPG::Cache.picture("Tablet_Menu_Back")
@face = Sprite.new
@face.bitmap = RPG::Cache.picture(@actor.name)
@face.x = 10
@face.y = 340
#initialize windows
@tab_index = Window_Tablet_Index.new
@tab_status = Window_Tablet_Status.new
@tab_trade = Window_Tablet_Trade.new
@tab_remove = Window_Tablet_Remove.new
@tab_remove.y = 170
@tab_remove.x = 200
#initialize commands
s0 = "Learning"
s1 = "Assign"
s2 = "Remove"
s3 = "Trade"
s4 = "Exit"
commands = [s0,s1,s2,s3,s4]
@command = Window_Command.new(160, commands)
@command.opacity = 200
#set window visibility
@command.active = true
@tab_index.active = false
@tab_index.visible = false
@tab_status.active = false
@tab_status.visible = false
@tab_trade.active = false
@tab_trade.visible = false
@tab_remove.active = false
@tab_remove.visible = false
#refresh @command according to character assigned
command_refresh
Graphics.transition
loop do
Graphics.update
Input.update
update
if $scene != self
break
end
end
@face.dispose
@command.dispose
@tab_index.dispose
@tab_status.dispose
@tab_trade.dispose
@sprite.dispose
end
def update
@command.update
@tab_index.update
@tab_status.update
@tab_trade.update
@tab_remove.update
if @command.active == true
update_command
return
end
if @tab_index.active == true
update_index
return
end
if @tab_status.active == true
update_status
return
end
if @tab_remove.active == true
update_remove
return
end
if @tab_trade.active == true
update_trade
return
end
end
def update_command
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
$scene = Scene_Menu.new(4)
end
if Input.trigger?(Input::C)
case @command.index
when 0
if @learn_disabled == true
$game_system.se_play($data_system.buzzer_se)
else
$game_system.se_play($data_system.decision_se)
@tab_status.refresh(@actor.tablet, @actor)
@tab_status.active = true
@tab_status.visible = true
@command.active = false
end
when 1
if @assign_disabled == true
$game_system.se_play($data_system.buzzer_se)
else
$game_system.se_play($data_system.decision_se)
@tab_index.refresh
@tab_index.active = true
@tab_index.visible = true
@command.active = false
end
when 2
if @remove_disabled == true
$game_system.se_play($data_system.buzzer_se)
else
$game_system.se_play($data_system.decision_se)
@tab_remove.active = true
@tab_remove.visible = true
@tab_remove.index = 0
@command.active = false
end
when 3
if @trade_disabled == true
$game_system.se_play($data_system.buzzer_se)
else
$game_system.se_play($data_system.decision_se)
@tab_trade.active = true
@tab_trade.visible = true
@tab_trade.index = 0
@tab_trade.refresh
@command.active = false
end
when 4
$game_system.se_play($data_system.decision_se)
$scene = Scene_Menu.new(4)
end
end
end
def update_index
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
@tab_index.active = false
@tab_index.visible = false
@command.active = true
end
if Input.trigger?(Input::C)
r = 0
for actor in $game_party.actors
if actor.tablet == $game_party.tablets[@tab_index.index]
r += 1
end
end
if r == 0
$game_system.se_play($data_system.decision_se)
@actor.tablet = $game_party.tablets[@tab_index.index]
@actor.set_learned
@tab_index.index = -1
@tab_index.active = false
@tab_index.visible = false
@command.active = true
@command.refresh
command_refresh
else
$game_system.se_play($data_system.buzzer_se)
end
end
return
end
def update_status
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
@tab_status.active = false
@tab_status.visible = false
@command.active = true
end
end
def update_remove
if Input.trigger?(Input::RIGHT)
$game_system.se_play($data_system.cursor_se)
@tab_remove.index += 1 unless @tab_remove.index = 1
end
if Input.trigger?(Input::LEFT)
$game_system.se_play($data_system.cursor_se)
@tab_remove.index -= 1 unless @tab_remove.index <= 0
end
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
@tab_remove.active = false
@tab_remove.visible = false
@command.active = true
end
if Input.trigger?(Input::C)
case @tab_remove.index
when 0
@actor.tablet = 0
$game_system.se_play($data_system.decision_se)
@tab_remove.active = false
@tab_remove.visible = false
@command.refresh
command_refresh
@command.active = true
when 1
$game_system.se_play($data_system.decision_se)
@tab_remove.active = false
@tab_remove.visible = false
@command.active = true
end
end
end
def update_trade
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
@tab_trade.active = false
@tab_trade.visible = false
@command.active = true
end
if Input.trigger?(Input::C)
if @actor == $game_party.actors[@tab_trade.index]
$game_system.se_play($data_system.buzzer_se)
else
$game_system.se_play($data_system.decision_se)
tablet = $game_party.actors[@tab_trade.index].tablet
$game_party.actors[@tab_trade.index].tablet = @actor.tablet
$game_party.actors[@tab_trade.index].set_learned
@actor.tablet = tablet
@actor.set_learned
@command.refresh
command_refresh
@command.active = true
@tab_trade.active = false
@tab_trade.visible = false
end
end
end
def command_refresh
@learn_disabled = false
@assign_disabled = false
@remove_disabled = false
@trade_disabled = false
if @actor.tablet > 0
@command.disable_item(1)
@assign_disabled = true
else
@command.disable_item(0)
@command.disable_item(2)
@command.disable_item(3)
@learn_disabled = true
@remove_disabled = true
@trade_disabled = true
end
if $game_party.actors.size < 2
@command.disable_item(3)
@trade_disabled = true
end
end
end
#------------------------------------------------------------------------------
# Spell Tablet System
# by GubiD
# v1.0
# Last modified 8/14/07
#------------------------------------------------------------------------------
class Window_Tablet_Index < Window_Selectable
def initialize
super(160,0,160,360)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.draw_text(0,0,120,32, "Index")
end
def refresh
self.opacity = 200
self.contents.clear
x = 0
for i in 0...$game_party.tablets.size
y = 32 * i
self.contents.draw_text(x, y, 160, 32, $data_actors[$game_party.tablets[i]].name)
end
@item_max = (y/32).to_i + 1
self.index = 0
end
def update_cursor_rect
self.cursor_rect.set(0, @index * 32, 135, 32)
end
end
class Window_Tablet_Status < Window_Selectable
def initialize
super(160,0,480,480)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.draw_text(0,0,120,32, "Status")
self.index = -1
end
def refresh(tablet_id, actor)
self.opacity = 200
self.contents.clear
skills = Tablets::skills(tablet_id)
self.contents.draw_text(0,0,80,32,"Skill")
self.contents.draw_text(230,0,60,32,"Rate")
self.contents.draw_text(350,0,100,32,"Learned")
x = 0
y = 32
for i in 0...skills.size
y = (i*32)+32
draw_skill_name(skills[i][0], x, y)
self.contents.draw_text(x+230, y, 80,32, skills[i][1].to_s + "%")
learned = actor.learning[skills[i][0]]
self.contents.draw_text(x+350, y, 80,32, learned.to_s + "%")
end
@item_max = skills.size
end
def update_cursor_rect
unless @index == -1
self.cursor_rect.set(0, @index * 32+32, 440, 32)
end
end
end
class Window_Tablet_Remove < Window_Selectable
def initialize
super(160,0,240,120)
self.opacity = 200
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.draw_text(40,0,240,32, "Unequip Tablet?")
self.contents.draw_text(50,32,50,32, "Yes")
self.contents.draw_text(100,32,50,32, "No")
self.index = 0
@item_max = 2
end
def update_cursor_rect
self.cursor_rect.set((@index*50)+40, 36, 50, 24)
end
end
class Window_Tablet_Trade < Window_Selectable
def initialize
super(160,0,320,480)
self.contents = Bitmap.new(width - 32, height - 32)
self.opacity = 200
@sprites = []
refresh
end
def refresh
@sprites = []
self.contents.clear
@item_max = $game_party.actors.size
for i in 0...$game_party.actors.size
actor = $game_party.actors[i]
sprite = Sprite.new
sprite.bitmap = RPG::Cache.picture(actor.name)
sprite.x = 170
sprite.y = (i*110) + 15
sprite.visible = false
sprite.z = 5000
self.contents.font.size = 17
self.contents.draw_text(100,(i*110)+15, 150, 32, actor.name)
if actor.tablet > 0
self.contents.draw_text(150,(i*110)+32, 150,32, $data_actors[actor.tablet].name, 4)
end
@sprites.push(sprite)
end
end
def update_cursor_rect
self.cursor_rect.set(90,(@index*110)+15, 190, 100)
end
alias tab_update update
def update
tab_update
for sprite in @sprites
sprite.visible = self.visible
sprite.update
end
end
end
#------------------------------------------------------------------------------
# Spell Tablet System
# by GubiD
# v1.0
# Last modified 8/14/07
#------------------------------------------------------------------------------
class Game_Party
attr_reader :tablets
alias tablet_init_party initialize
def initialize
@tablets = []
tablet_init_party
end
end
class Game_Actor < Game_Battler
attr_accessor :tablet
attr_accessor :learning
alias tablet_init_actor initialize
def initialize(actor_id)
tablet_init_actor(actor_id)
@tablet = 0
@learning = []
end
def set_learned
unless @tablet == 0
skills = Tablets::skills(@tablet)
for i in 0...skills.size
if @learning[skills[i][0]] == nil
@learning[skills[i][0]] = 0
end
end
end
end
end
class Game_Enemy < Game_Battler
attr_accessor :ap
alias initialize_enemy initialize
def initialize(troop_id, member_index)
initialize_enemy(troop_id, member_index)
@ap = 1
@character_hue = 0
@name = $data_enemies[@enemy_id].name
end
#get enemy AP for battle results
def ap
return @ap
end
def name
return @name
end
end
#Note from GubiD-
# I dont claim responsibility for this HP/SP/EXP bar script. This was made
# by someone else, although I cannot recall who.
#------------------------------------------------------------------------------
# Game_Actor, updates
#------------------------------------------------------------------------------
class Game_Actor < Game_Battler
def now_exp
return @exp - @exp_list[@level]
end
def next_exp
return @exp_list[@level+1] > 0 ? @exp_list[@level+1] - @exp_list[@level] : 0
end
end
#------------------------------------------------------------------------------
# Window_Base - updates
#------------------------------------------------------------------------------
class Window_Base < Window
#------------------------------------------------------------------------------
#Draw HP Bars
#------------------------------------------------------------------------------
alias :draw_actor_hp_hpsp :draw_actor_hp
def draw_actor_hp(actor, x, y, width = 144)
if actor.maxhp != 0
rate = actor.hp.to_f / actor.maxhp
else
rate = 0
end
plus_x = 0
rate_x = 0
plus_y = 25
plus_width = 0
rate_width = 100
height = 10
align1 = 1
align2 = 2
align3 = 0
grade1 = 1
grade2 = 0
color1 = Color.new(0, 0, 0, 192)
color2 = Color.new(255, 255, 192, 192)
color3 = Color.new(0, 0, 0, 192)
color4 = Color.new(64, 0, 0, 192)
color5 = Color.new(80 - 24 * rate, 80 * rate, 14 * rate, 192)
color6 = Color.new(240 - 72 * rate, 240 * rate, 62 * rate, 192)
if actor.maxhp != 0
hp = (width + plus_width) * actor.hp * rate_width / 100 / actor.maxhp
else
hp = 0
end
gauge_rect(x + plus_x + width * rate_x / 100, y + plus_y,
width, plus_width + width * rate_width / 100,
height, hp, align1, align2, align3,
color1, color2, color3, color4, color5, color6, grade1, grade2)
draw_actor_hp_hpsp(actor, x, y, width)
end
#------------------------------------------------------------------------------
#Draw SP
#------------------------------------------------------------------------------
alias :draw_actor_sp_hpsp :draw_actor_sp
def draw_actor_sp(actor, x, y, width = 144)
if actor.maxsp != 0
rate = actor.sp.to_f / actor.maxsp
else
rate = 1
end
plus_x = 0
rate_x = 0
plus_y = 25
plus_width = 0
rate_width = 100
height = 10
align1 = 1
align2 = 2
align3 = 0
grade1 = 1
grade2 = 0
color1 = Color.new(0, 0, 0, 192)
color2 = Color.new(255, 255, 192, 192)
color3 = Color.new(0, 0, 0, 192)
color4 = Color.new(0, 64, 0, 192)
color5 = Color.new(14 * rate, 80 - 24 * rate, 80 * rate, 192)
color6 = Color.new(62 * rate, 240 - 72 * rate, 240 * rate, 192)
if actor.maxsp != 0
sp = (width + plus_width) * actor.sp * rate_width / 100 / actor.maxsp
else
sp = (width + plus_width) * rate_width / 100
end
gauge_rect(x + plus_x + width * rate_x / 100, y + plus_y,
width, plus_width + width * rate_width / 100,
height, sp, align1, align2, align3,
color1, color2, color3, color4, color5, color6, grade1, grade2)
draw_actor_sp_hpsp(actor, x, y, width)
end
#------------------------------------------------
#Draw_Actor_Exp
#------------------------------------------------
alias :draw_actor_exp_hpsp :draw_actor_exp
def draw_actor_exp(actor, x, y, width = 204)
if actor.next_exp != 0
rate = actor.now_exp.to_f / actor.next_exp
else
rate = 1
end
plus_x = 0
rate_x = 0
plus_y = 25
plus_width = 0
rate_width = 100
height = 10
align1 = 1
align2 = 2
align3 = 0
grade1 = 1
grade2 = 0
color1 = Color.new(0, 0, 0, 192)
color2 = Color.new(255, 255, 192, 192)
color3 = Color.new(0, 0, 0, 192)
color4 = Color.new(64, 0, 0, 192)
color5 = Color.new(80 * rate, 80 - 80 * rate ** 2, 80 - 80 * rate, 192)
color6 = Color.new(240 * rate, 240 - 240 * rate ** 2, 240 - 240 * rate, 192)
if actor.next_exp != 0
exp = (width + plus_width) * actor.now_exp * rate_width /
100 / actor.next_exp
else
exp = (width + plus_width) * rate_width / 100
end
gauge_rect(x + plus_x + width * rate_x / 100, y + plus_y,
width, plus_width + width * rate_width / 100,
height, exp, align1, align2, align3,
color1, color2, color3, color4, color5, color6, grade1, grade2)
draw_actor_exp_hpsp(actor, x, y)
end
#--------------------------------------------------------------------------
# Gauge_Rect
#--------------------------------------------------------------------------
def gauge_rect(x, y, rect_width, width, height, gauge, align1, align2, align3,
color1, color2, color3, color4, color5, color6, grade1, grade2)
case align1
when 1
x += (rect_width - width) / 2
when 2
x += rect_width - width
end
case align2
when 1
y -= height / 2
when 2
y -= height
end
self.contents.fill_rect(x, y, width, height, color1)
self.contents.fill_rect(x + 1, y + 1, width - 2, height - 2, color2)
if align3 == 0
if grade1 == 2
grade1 = 3
end
if grade2 == 2
grade2 = 3
end
end
if (align3 == 1 and grade1 == 0) or grade1 > 0
color = color3
color3 = color4
color4 = color
end
if (align3 == 1 and grade2 == 0) or grade2 > 0
color = color5
color5 = color6
color6 = color
end
self.contents.gradation_rect(x + 2, y + 2, width - 4, height - 4,
color3, color4, grade1)
if align3 == 1
x += width - gauge
end
self.contents.gradation_rect(x + 2, y + 2, gauge - 4, height - 4,
color5, color6, grade2)
end
end
#------------------------------------------------------------------------------
# Bitmap class, for gradiation
#------------------------------------------------------------------------------
class Bitmap
def gradation_rect(x, y, width, height, color1, color2, align = 0)
if align == 0
for i in x...x + width
red = color1.red + (color2.red - color1.red) * (i - x) / (width - 1)
green = color1.green +
(color2.green - color1.green) * (i - x) / (width - 1)
blue = color1.blue +
(color2.blue - color1.blue) * (i - x) / (width - 1)
alpha = color1.alpha +
(color2.alpha - color1.alpha) * (i - x) / (width - 1)
color = Color.new(red, green, blue, alpha)
fill_rect(i, y, 1, height, color)
end
elsif align == 1
for i in y...y + height
red = color1.red +
(color2.red - color1.red) * (i - y) / (height - 1)
green = color1.green +
(color2.green - color1.green) * (i - y) / (height - 1)
blue = color1.blue +
(color2.blue - color1.blue) * (i - y) / (height - 1)
alpha = color1.alpha +
(color2.alpha - color1.alpha) * (i - y) / (height - 1)
color = Color.new(red, green, blue, alpha)
fill_rect(x, i, width, 1, color)
end
elsif align == 2
for i in x...x + width
for j in y...y + height
red = color1.red + (color2.red - color1.red) *
((i - x) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
green = color1.green + (color2.green - color1.green) *
((i - x) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
blue = color1.blue + (color2.blue - color1.blue) *
((i - x) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
alpha = color1.alpha + (color2.alpha - color1.alpha) *
((i - x) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
color = Color.new(red, green, blue, alpha)
set_pixel(i, j, color)
end
end
elsif align == 3
for i in x...x + width
for j in y...y + height
red = color1.red + (color2.red - color1.red) *
((x + width - i) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
green = color1.green + (color2.green - color1.green) *
((x + width - i) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
blue = color1.blue + (color2.blue - color1.blue) *
((x + width - i) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
alpha = color1.alpha + (color2.alpha - color1.alpha) *
((x + width - i) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
color = Color.new(red, green, blue, alpha)
set_pixel(i, j, color)
end
end
end
end
end
Script Part 3
Code:
#------------------------------------------------------------------------------
#Class Sprite, Additional Functionality
#------------------------------------------------------------------------------
module RPG
class Sprite < ::Sprite
def damage(value, critical)
dispose_damage
if value.is_a?(Numeric)
damage_string = value.abs.to_s
else
damage_string = value.to_s
end
bitmap = Bitmap.new(160, 48)
bitmap.font.name = "Tahoma"
bitmap.font.size = 32
bitmap.font.color.set(0, 0, 0)
bitmap.draw_text(-1, 12-1, 160, 36, damage_string, 1)
bitmap.draw_text(+1, 12-1, 160, 36, damage_string, 1)
bitmap.draw_text(-1, 12+1, 160, 36, damage_string, 1)
bitmap.draw_text(+1, 12+1, 160, 36, damage_string, 1)
if value.is_a?(Numeric) and value < 0
bitmap.font.color.set(176, 255, 144)
else
bitmap.font.color.set(255, 255, 255)
end
bitmap.draw_text(0, 12, 160, 36, damage_string, 1)
if critical
bitmap.font.size = 20
bitmap.font.color.set(0, 0, 0)
bitmap.draw_text(-1, -1, 160, 20, "CRITICAL", 1)
bitmap.draw_text(+1, -1, 160, 20, "CRITICAL", 1)
bitmap.draw_text(-1, +1, 160, 20, "CRITICAL", 1)
bitmap.draw_text(+1, +1, 160, 20, "CRITICAL", 1)
bitmap.font.color.set(255, 255, 255)
bitmap.draw_text(0, 0, 160, 20, "CRITICAL", 1)
end
@_damage_sprite = ::Sprite.new
@_damage_sprite.bitmap = bitmap
@_damage_sprite.ox = 80 + self.viewport.ox
@_damage_sprite.oy = 20 + self.viewport.oy
@_damage_sprite.x = self.x + self.viewport.rect.x
@_damage_sprite.y = self.y - self.oy / 2 + self.viewport.rect.y
@_damage_sprite.z = 3000
@_damage_duration = 40
end
def animation(animation, hit)
dispose_animation
@_animation = animation
return if @_animation == nil
@_animation_hit = hit
@_animation_duration = @_animation.frame_max
animation_name = @_animation.animation_name
animation_hue = @_animation.animation_hue
bitmap = RPG::Cache.animation(animation_name, animation_hue)
if @@_reference_count.include?(bitmap)
@@_reference_count[bitmap] += 1
else
@@_reference_count[bitmap] = 1
end
@_animation_sprites = []
if @_animation.position != 3 or not @@_animations.include?(animation)
for i in 0..15
sprite = ::Sprite.new
sprite.bitmap = bitmap
sprite.visible = false
@_animation_sprites.push(sprite)
end
unless @@_animations.include?(animation)
@@_animations.push(animation)
end
end
update_animation
end
def loop_animation(animation)
return if animation == @_loop_animation
dispose_loop_animation
@_loop_animation = animation
return if @_loop_animation == nil
@_loop_animation_index = 0
animation_name = @_loop_animation.animation_name
animation_hue = @_loop_animation.animation_hue
bitmap = RPG::Cache.animation(animation_name, animation_hue)
if @@_reference_count.include?(bitmap)
@@_reference_count[bitmap] += 1
else
@@_reference_count[bitmap] = 1
end
@_loop_animation_sprites = []
for i in 0..15
sprite = ::Sprite.new
sprite.bitmap = bitmap
sprite.visible = false
@_loop_animation_sprites.push(sprite)
end
update_loop_animation
end
def animation_set_sprites(sprites, cell_data, position)
for i in 0..15
sprite = sprites[i]
pattern = cell_data[i, 0]
if sprite == nil or pattern == nil or pattern == -1
sprite.visible = false if sprite != nil
next
end
sprite.visible = true
sprite.src_rect.set(pattern % 5 * 192, pattern / 5 * 192, 192, 192)
if position == 3
if self.viewport != nil
sprite.x = self.viewport.rect.width / 2
sprite.y = self.viewport.rect.height - 160
else
sprite.x = 320
sprite.y = 240
end
else
sprite.x = self.x + self.viewport.rect.x -
self.ox + self.src_rect.width / 2
sprite.y = self.y + self.viewport.rect.y -
self.oy + self.src_rect.height / 2
sprite.y -= self.src_rect.height / 4 if position == 0
sprite.y += self.src_rect.height / 4 if position == 2
end
sprite.x += cell_data[i, 1]
sprite.y += cell_data[i, 2]
sprite.z = 2000
sprite.ox = 96
sprite.oy = 96
sprite.zoom_x = cell_data[i, 3] / 100.0
sprite.zoom_y = cell_data[i, 3] / 100.0
sprite.angle = cell_data[i, 4]
sprite.mirror = (cell_data[i, 5] == 1)
sprite.opacity = cell_data[i, 6] * self.opacity / 255.0
sprite.blend_type = cell_data[i, 7]
end
end
end
end
ou will notice that it also uses cogwheels HP/SP/EXP bars in the menu along with Character Graphics instead of walk graphics. (It uses character name to determine file name for the picture.)
If you are not a code buff, then you can also download the demo from mediafire at the following link
LINK
Edit: Updated post, cause I noticed that the spoiler and codebox weren't working correctly. I split it up and now it seems to work correctly. There has been no actual change to the above code at this time.