[VX] RGSS2 Magica Scroll System

Started by Dark Dragon, January 22, 2008, 03:18:44 pm

Previous topic - Next topic

Dark Dragon

January 22, 2008, 03:18:44 pm Last Edit: February 21, 2009, 05:45:06 am by shdwlink1993
Magica Scroll System
Authors: Dark Dragon
Version: 1.0
Type: Custom System
Key Term: Battle Add-on



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..



Screenshots




Demo
http://www.fileshost.com/en/file/29880/Magica-Scroll-System-exe.html


Script
Spoiler: ShowHide

#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# 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


Spoiler: ShowHide

#==============================================================================
# ? 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

Spoiler: ShowHide

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 : denarto0o0@hotmail.com
#=====================================================================
#=====================================================================

=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 denarto0o0@hotmail.com

Blizzard

Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Dark Dragon

There goes another 10 minutes from my life !_!

Blizzard

10 minutes which will save each person that looks at this topic 2 minutes. After 5 people, you have it in again.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Nortos

lol anyway looks good :) I'm gonna have a look at it I need to learn a lot to do with scripts in battle...it's mainly what I want to edit downloading now :)

Calintz


Nortos

I just realised was vx :P anyway I'll still have a look at it :)

Calintz

Haha, I didn't notice that either!!
But yeh, even so...It still looks intriguing ;D

Dark Dragon

Oh yeah you'll have to install the RMVX RTP before you can play it :P
And guys please post some suggestions that's why I showed it to in it's... bad state..
I could have just finished it the way I wanted it and post it, but I want to make it the way you guys think ^_^

Nortos

I can't play it yet haven't downloaded the rtp yet sorry

Calintz

I'll download everything, and look into it tomorrow... :)

Dark Dragon

!_!
People you don't need to play the demo to say some suggestions !
It's all in the screenie, what do you think I should add ?
I really want to improve this thing it's not so cool as it is :S

Fantasist

Dunno about coolness but I think there's a functional flaw in the layout. The list of scrolls (at the top-left corner) is too small, it only shows 2 scrolls at a time, If I were you; I'd rework the layout, but that's just me.
Do you like ambient/electronic music? Then you should promote a talented artist! Help out here. (I'm serious. Just listen to his work at least!)


The best of freeware reviews: Gizmo's Freeware Reviews




Calintz

I agree with Fantasist...and if you're concerned with space, maybe have it so only one scroll option shows in the middle, and the user cycles through them ( << - >> )left and right...

Dark Dragon

Heh, Actually I was planning to make it only show ONE scroll in the menu xD
Claintz if I make the user choose between them using that "<< - >>" that would screw
the character selection menu :S

Nortos

he has it set the charecter select to left and right and you change the scroll with up and down which is quite nice

Dark Dragon

There you go that's a whole new scripted version, I changed almost everything..
Now there are 3 scroll slots available, should make it more fun :P

Ghareeb