Magica Scroll System PDF Print E-mail
User Rating: / 1
PoorBest 
Written by Dark Dragon   

Author: Dark Dragon
Verion: 1.0

Download

Introduction

This script allows you to equip your party with scrolls before entering a battle, which allows them to use certain skills. This will make a player think of a strategy before entring a battle and then applying it in the battle ground..

Features

  • A nicely designed Scene to handle the scrolls..
  • You can edit the scroll easily through the "items" slot and a ready made template for you to use on RGSS..
  • Additional "Switch trigger" function that will help you include the presence of scrolls in certain events..

Edits:
#=========================================================================
=====
# Blizzards "slice_text" add-on to the Window_Base class..
#==============================================================================
class Window_Base
def slice_text(text, width)
result, last_word, current_text = [], 0, ''
(0..text.size).each {|i|
if text[i, 1] == ' ' || i == text.size
word = text[last_word, i-last_word]
if self.contents.text_size("#{current_text} #{word}").width > width
result.push(current_text)
current_text = word
else
current_text += (current_text == '' ? word : " #{word}")
end
last_word = i+1
end}
result.push("#{current_text} #{text[last_word, text.size-last_word]}")
return result
end
end
#==============================================================================
# Set extra attributes that the system will need later..
#==============================================================================
# Set the extra attribute to relate items to scrolls..
module RPG
class Item < UsableItem
attr_accessor :scroll
end
end
# Set the extra attributes to manage the party's equipped scrolls..
class Game_Actor < Game_Battler
attr_accessor :scroll
attr_accessor :scroll2
attr_accessor :scroll3
end
#==============================================================================

 

Main_Scroll_Script

#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# Magica Scroll System
# Version: 1.0
# Type: Custom System
# Made by : Dark Dragon
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=

#==============================================================================
#==============================================================================
#==============================================================================
class Scroll_Scene < Scene_Base
#-----------------------------------------------------------------------------
# Set classes which will be used later..
#-----------------------------------------------------------------------------
def start
@window_scroll = Window_Scroll.new
@window_charcter = WindowS_Charcter.new
@scroll_details = Scroll_Details.new
@current_scroll = Window_CurrentScroll.new
@current_scroll.active = false
@charcter_status = Window_CharcterScrollStatus.new
@scroll_array = Scrolls::Scroll_Array.new
end
#-----------------------------------------------------------------------------
#Dispose of the classes whe $scene != self
#-----------------------------------------------------------------------------
def terminate
@window_scroll.dispose
@window_charcter.dispose
@scroll_details.dispose
@current_scroll.dispose
@charcter_status.dispose
end
#-----------------------------------------------------------------------------
# Update each class in loops and set the @actor value..
#-----------------------------------------------------------------------------
def update
@actor = $game_party.members[@window_charcter.index]
@window_scroll.update
@window_charcter.update
@current_scroll.update
#-----------------------------------------------------------------------------
# Set the details in the Scroll_Details window according to the position of the index
#-----------------------------------------------------------------------------
if @window_scroll.active
@scroll_details.update_details(@window_scroll.item)
elsif @current_scroll.active
case @current_scroll.index
when 0
if @actor.scroll != nil
@scroll_details.update_details2(@actor.scroll.item_related)
else
@scroll_details.update_details2(nil)
end
when 1
if @actor.scroll2 != nil
@scroll_details.update_details2(@actor.scroll2.item_related)
else
@scroll_details.update_details2(nil)
end
when 2
if @actor.scroll3 != nil
@scroll_details.update_details2(@actor.scroll3.item_related)
else
@scroll_details.update_details2(nil)
end

end
end

@current_scroll.refresh(@actor)
@charcter_status.refresh(@actor)
#-----------------------------------------------------------------------------
# Apply commands when C is pushed according to the active window..
#-----------------------------------------------------------------------------
if Input.trigger?(Input::C)
if @window_scroll.active
@window_scroll.active = false
@current_scroll.active = true

elsif @current_scroll.active
case @current_scroll.index
when 0
unless @window_scroll.item == nil
@scroll = @scroll_array.data(@window_scroll.item.scroll.id)
unless @actor.scroll == nil
$game_party.gain_item(@actor.scroll.item_related, 1)
end
@actor.scroll = @scroll
$game_party.consume_item(@window_scroll.item)
@window_scroll.refresh
@current_scroll.refresh2(@actor)
else
unless @actor.scroll == nil
$game_party.gain_item(@actor.scroll.item_related, 1)
@window_scroll.refresh
@actor.scroll = nil
@current_scroll.refresh2(@actor)
end
end
@current_scroll.active = false
@window_scroll.active = true
when 1
unless @window_scroll.item == nil
@scroll = @scroll_array.data(@window_scroll.item.scroll.id)
unless @actor.scroll2 == nil
$game_party.gain_item(@actor.scroll2.item_related, 1)
end
@actor.scroll2 = @scroll
$game_party.consume_item(@window_scroll.item)
@window_scroll.refresh
@current_scroll.refresh2(@actor)
else
unless @actor.scroll2 == nil
$game_party.gain_item(@actor.scroll2.item_related, 1)
@window_scroll.refresh
@actor.scroll2 = nil
@current_scroll.refresh2(@actor)
end
end
@current_scroll.active = false
@window_scroll.active = true
when 2
unless @window_scroll.item == nil
@scroll = @scroll_array.data(@window_scroll.item.scroll.id)
unless @actor.scroll3 == nil
$game_party.gain_item(@actor.scroll3.item_related, 1)
end
@actor.scroll3 = @scroll
$game_party.consume_item(@window_scroll.item)
@window_scroll.refresh
@current_scroll.refresh2(@actor)
else
unless @actor.scroll3 == nil
$game_party.gain_item(@actor.scroll3.item_related, 1)
@window_scroll.refresh
@actor.scroll3 = nil
@current_scroll.refresh2(@actor)
end
end
@current_scroll.active = false
@window_scroll.active = true
end


end
end
#-----------------------------------------------------------------------------
# Set the magical skills when aborting..and return to the scroll window if you are not..
#-----------------------------------------------------------------------------
if Input.trigger?(Input::B)
if @window_scroll.active
Magica.new
$scene = Scene_Map.new
elsif @current_scroll.active
@current_scroll.active = false
@window_scroll.active = true
end
end
end
end

#==============================================================================
#==============================================================================
#==============================================================================
#-----------------------------------------------------------------------------
# Set the Scroll Selection Class..
#-----------------------------------------------------------------------------
class Window_Scroll < Window_Selectable
def initialize
super(0,0,250,105)
self.contents = Bitmap.new(200,300)
self.index = 0
refresh
end
def refresh
self.contents.clear
#-----------------------------------------------------------------------------
# Push items with the first "Scroll" attribute on into the data array..
#-----------------------------------------------------------------------------
y = -1
@data = []
for i in 0 ... $game_party.items.size
if $game_party.items[i].is_a?(RPG::Item) and $game_party.items[i].element_set.include?(1)
@data.push($game_party.items[i])
y +=1
self.contents.draw_text(35,y*23-2,200,32,$game_party.items[i].name)
self.contents.draw_text(190,y*23-2,200,32,$game_party.item_number($game_party.items[i]))
draw_icon($game_party.items[i].icon_index, 0, y*23-2)
end
end
@data.push(nil)
self.contents.font.color = text_color(6)
self.contents.draw_text(5,@data.size*23-24,200,32,"Remove")
self.contents.font.color = normal_color
@item_max = @data.size
end
#-----------------------------------------------------------------------------
# Return the data array into self.data
#-----------------------------------------------------------------------------
def item
return @data[self.index]
end

end

#==============================================================================
#==============================================================================
#==============================================================================
#-----------------------------------------------------------------------------
# Set the Details Window..
#-----------------------------------------------------------------------------
class Scroll_Details < Window_Base
def initialize
super(0,250,350,167)
end
#-----------------------------------------------------------------------------
# Fill up the details when @scroll_window.active
#-----------------------------------------------------------------------------
def update_details(item)
unless item == nil
self.contents.font.size = 18
if item != @text
self.contents.clear
self.contents.font.color = text_color(6)
self.contents.draw_text(0,0,200,32,item.name)
self.contents.font.color = normal_color
text = slice_text(item.description, 400)
text.each_index {|i| self.contents.draw_text(4, i*32+32, self.width - 35, 32, text[i])}
@text = item
end

else
if item != @text
self.contents.clear
self.contents.draw_text(4, 0, self.width - 40, 32, "Remove scroll equipped.")
@text = item
end
end
end
#-----------------------------------------------------------------------------
# Fill up the window when @current_scroll.active
#-----------------------------------------------------------------------------
def update_details2(item)
unless item == nil
self.contents.font.size = 18
if item != @text
self.contents.clear
self.contents.font.color = text_color(6)
self.contents.draw_text(0,0,200,32,item.name)
self.contents.font.color = normal_color
text = slice_text(item.description, 400)
text.each_index {|i| self.contents.draw_text(4, i*32+32, self.width - 35, 32, text[i])}
@text = item
end

else
if item != @text
self.contents.clear
self.contents.draw_text(4, 0, self.width - 40, 32, "There is no scroll equipped.")
@text = item
end
end
end

end

#==============================================================================
#==============================================================================
#==============================================================================
#-----------------------------------------------------------------------------
# Set up the character selection window..
#-----------------------------------------------------------------------------
class WindowS_Charcter < Window_Selectable
def initialize
super(0,105,545,145)
for actor in $game_party.members
draw_actor_face(actor, actor.index*130+10, 10,96 )
self.contents.font.color = text_color(5)
draw_actor_name(actor,actor.index*130 +10, 10)
draw_actor_class(actor, actor.index*130+10, 35)
draw_actor_level(actor,actor.index*130 +10,60)
self.contents.font.color = normal_color
draw_actor_state(actor,actor.index*130 +90, 85 )
@column_max = 4
@item_max = $game_party.members.size
self.index = 0
end
end

def update_cursor
self.cursor_rect.set(self.index * 130, 0, 120, 120)
end
end


#==============================================================================
#==============================================================================
#==============================================================================
#-----------------------------------------------------------------------------
# Set the Current Actor Scroll window..
#-----------------------------------------------------------------------------
class Window_CurrentScroll < Window_Selectable
def initialize
super(250,0,295,105)
@item_max = 3
self.index = 0
end
#-----------------------------------------------------------------------------
# Fill up the window when contents is diffrent..
#-----------------------------------------------------------------------------
def refresh(actor)
unless actor == nil
self.contents.font.size = 18

if actor != @text
self.contents.clear
self.contents.font.color = text_color(6)
self.contents.draw_text(3,0,200,32,"")
self.contents.font.color = normal_color
if actor.scroll==nil
self.contents.draw_text(45,-2,200,32,"No equipped scroll.")
end
unless actor.scroll==nil
draw_icon(actor.scroll.item_related.icon_index, 0, -2)
self.contents.draw_text(45,-2,200,32,actor.scroll.name)
end

if actor.scroll2==nil
self.contents.draw_text(45,21,200,32,"No equipped scroll.")
end
unless actor.scroll2==nil
draw_icon(actor.scroll2.item_related.icon_index, 0, 21)
self.contents.draw_text(45,21,200,32,actor.scroll2.name)
end
if actor.scroll3==nil
self.contents.draw_text(45,44,200,32,"No equipped scroll.")
end
unless actor.scroll3==nil
draw_icon(actor.scroll3.item_related.icon_index, 0, 44)
self.contents.draw_text(45,44,200,32,actor.scroll3.name)
end

@text = actor
end
end
end
#-----------------------------------------------------------------------------
# Fill up the window when C is pushed..
#-----------------------------------------------------------------------------
def refresh2(actor)
unless actor == nil
self.contents.font.size = 18
self.contents.clear
self.contents.font.color = text_color(6)
self.contents.draw_text(3,0,200,32,"")
self.contents.font.color = normal_color
if actor.scroll==nil
self.contents.draw_text(45,-2,200,32,"No equipped scroll.")
end
unless actor.scroll==nil
draw_icon(actor.scroll.item_related.icon_index, 0, -2)
self.contents.draw_text(45,-2,200,32,actor.scroll.name)
end
if actor.scroll2==nil
self.contents.draw_text(45,21,200,32,"No equipped scroll.")
end
unless actor.scroll2==nil
draw_icon(actor.scroll2.item_related.icon_index, 0, 21)
self.contents.draw_text(45,21,200,32,actor.scroll2.name)
end
if actor.scroll3==nil
self.contents.draw_text(45,44,200,32,"No equipped scroll.")
end
unless actor.scroll3==nil
draw_icon(actor.scroll3.item_related.icon_index, 0, 44)
self.contents.draw_text(45,44,200,32,actor.scroll3.name)
end

@text = actor
end
end
end
#==============================================================================
#==============================================================================
#==============================================================================

class Window_CharcterScrollStatus < Window_Base
#-----------------------------------------------------------------------------
# Set up the characters window..
#-----------------------------------------------------------------------------
def initialize
super(350,250,195,167)
end
#-----------------------------------------------------------------------------
# Fill the window with the characters basic statues..
#-----------------------------------------------------------------------------
def refresh(actor )
unless actor == nil
self.contents.font.size = 18
if actor != @text
self.contents.clear
x = 0
draw_actor_hp(actor, x, 0)
draw_actor_mp(actor, x, 32 )
self.contents.font.size = 15
draw_actor_parameter(actor, x, 60, 0)
draw_actor_parameter(actor, x, 60 + 18, 1)
draw_actor_parameter(actor, x, 60 + 18*2, 2)
draw_actor_parameter(actor, x, 60+18*3, 3)
@text = actor
end
end
end
end
#==============================================================================
#==============================================================================
#==============================================================================
#-----------------------------------------------------------------------------
# Set the Scene_Title to set up the scrolls when starting a new game..
#-----------------------------------------------------------------------------
class Scene_Title
def load_database
$data_actors = load_data("Data/Actors.rvdata")
$data_classes = load_data("Data/Classes.rvdata")
$data_skills = load_data("Data/Skills.rvdata")
$data_items = load_data("Data/Items.rvdata")
$data_weapons = load_data("Data/Weapons.rvdata")
$data_armors = load_data("Data/Armors.rvdata")
$data_enemies = load_data("Data/Enemies.rvdata")
$data_troops = load_data("Data/Troops.rvdata")
$data_states = load_data("Data/States.rvdata")
$data_animations = load_data("Data/Animations.rvdata")
$data_common_events = load_data("Data/CommonEvents.rvdata")
$data_system = load_data("Data/System.rvdata")
$data_areas = load_data("Data/Areas.rvdata")
Set_Item_Scrolls.new
end
end

 

Magica_Handling

#==============================================================================
# ■ Magica
#------------------------------------------------------------------------------
# Right, now here is where you can set each scroll's effects. Wether it was it was adding magical
# skills, corresponding with other events, it doesn't matter !
# I made the basic commands which are setting a new skill,
#
# How to use :
#
# - Add the effects you want using the already setted methods under "def initialize" :
# (set_magica or switch_trigger)
# the arguments are as follows :
# set_magica(scroll_id,skill_id)
# set_switch(scroll_id, switch, character)
#
#==============================================================================

class Magica

def initialize #Add the scroll related skills below this line
end


#This is the method you'll be using for setting magic.
def set_magica(scroll_id,skill_id)
for i in 0...$game_party.members.size
@actor = $game_party.members[i]

if @actor.scroll.id == $data_items[scroll_id].scroll.id or
@actor.scroll2.id == $data_items[scroll_id].scroll.id or
@actor.scroll3.id == $data_items[scroll_id].scroll.id
@actor.learn_skill(skill_id)
else
@actor.forget_skill(skill_id)
end
end
end
#This is the method you'll be using for triggering a switch
def switch_trigger(scroll_id, switch, character)
if
$game_party.members[character-1].scroll.id ==
$data_items[scroll_id].scroll.id or
$game_party.members[character-1].scroll2.id ==
$data_items[scroll_id].scroll.id or
$game_party.members[character-1].scroll3.id ==
$data_items[scroll_id].scroll.id
$game_switches[switch] = true
else
$game_switches[switch] = false
end
end

end

 

Scroll_setting_Up

module Scrolls

class Scroll_Array

def initialize
# Don't forget to add the scroll's class name in this array, and don't forget the ".new"
@scroll_array = [Fire_Scroll.new, Water_Scroll.new,Blaze_Scroll.new,Ice_Scroll.new]
end
def data(id)
for i in 0...@scroll_array.size
if @scroll_array[i].id == id
return @scroll_array[i]
end
end
end

end
#=====================================================================
#=====================================================================
#=====================================================================
#How to set Scrolls :
# 1 - Use the template below and follow the instructions
# 2 - Add the <class name> with a ".new" sticked to the end of it in the Array above..
# 3 - Add a line in the "Set_Item_Scrolls" class below using this syntax :
# $data_items[item_id].scroll = Scrolls::<class name>.new
# item_id : The id of the item related to the scroll
# <class name> : The name of the class of the scroll, again, don't forget the ".new"
#4 - All the items related to scrolls must have the first attribute -name it "Scroll"- setted on..
# If you still have problems with functioning the script please revise the templates in the
# demonstration game, if you still experince problems, you can PM in the RRR forums
# or through msn live messanger through my e-mail : This e-mail address is being protected from spambots. You need JavaScript enabled to view it
#=====================================================================
#=====================================================================

=begin

class <class name> #This can be anything but it should start with a capital letter
def initialize
end
def id
return <id> #This is the ID of the item you want the scroll to be related to..
end
def item_related
return $data_items[id]
end
def name
return <name> #The name of the scroll, you should name it like
#the item the scroll is related to although you can change it
# don't forget to put BETWEEN 2 QOUTE MARKZ
end
end

=end
#=====================================================================
#=====================================================================

end

class Set_Item_Scrolls
def initialize
#Set the items related to the scrolls here
$data_items[1].scroll = Scrolls::Water_Scroll.new
$data_items[2].scroll = Scrolls::Fire_Scroll.new
$data_items[5].scroll = Scrolls::Blaze_Scroll.new
$data_items[6].scroll = Scrolls::Ice_Scroll.new
end
end

Instructions

Add the first scroll above main and add th other two below it.
Follow the instructions in the script.
And dont forget to set the Scroll Related items to the first attribute, and you preferably should name it "Scroll"..

Credits and Thanks

  • Blizzard - For his slice_text add-on to the Window_Base Class
  • Zeriab for his.... tipz >_>

Author's Notes

If you experience any problems regarding the script please try the
demonstration first, if you STILL have problems feel free to PM or
contact me through MSN live messenger ... my e-mail
This e-mail address is being protected from spambots. You need JavaScript enabled to view it

Comments (0)add
Write comment

busy
Last Updated on Tuesday, 13 May 2008 22:29