LuZi   07-04-2012, 04:22 AM
#1
Dash-Enabling Equipment

สคริปต์เขียนโดย : PK8
ลิงค์ต้นฉบับ : http://forums.rpgmakerweb.com/index.php?...equipment/


รายละเอียด :
สคริปต์นี่ทำให้สามารถกำหนดได้ว่าเครื่องป้องกันชนิดใหนที่สวมใส่แล้วทำให้สามารถกดวิ่ง หรือปิดการวิ่งในเกมได้
  • กำหนดว่าอุปกรณ์ไหนทำให้แดชได้เมื่อสวมใส่
  • กำหนดว่าอุปกรณ์ทำให้แดชเมื่อสวมใส่(เหมือนบังคับ)
  • ให้ตัดสินใจว่าเกิดกับเฉพาะหัวตี้หรือทั้งตี้

วิธีการใช้งาน :
ให้ใส่สคริปต์ลงไปในตัวเกม และตั้งค่าในส่วนของ General Settings ในสคริปต์
Code:
# Turns script on (TRUE) or off (FALSE).
Switch      = true < หากต้องการเปิดระบบนี่ให้ใส่ True ถ้าไม่ให้ใส่ False

# If TRUE, checks party leader for equipment. If FALSE, checks whole party.
Leader      = true < เช็คว่าหัวปาร์ตี้ใส่เครื่องป้องกันหรือไม่ ถ้าใช่ให้ใส่True ถ้าเช็คจากคนในปาร์ตี้ให้ใส่ False

# Set which armor equipment will give players dashing ability when equipped
# Integers and Ranges can be set.
Armors      = [980..999] < กรอกไอดีของเครื่องป้องกัน ที่เมื่อสวมใส่แล้วทำให้วิ่งได้

# If TRUE, Armors specified above would allow the player to dash. If FALSE,
# armors not specified would allow the player to dash.
Armors_Flag = true < หากเซ็ตเป็นtrue  เกราะข้างล่างนี้จะทำให้คนเล่นแดชได้ แต่ถ้าfalse เกราะที่นอกเหนือจากลิสท์ด้านล่างจะทำให้คนเล่นแดชได้

# Set which armors will have the side effect of making the player dash
# without pressing a button. Integers and Ranges can be set.
Armors_Auto = [] < กรอกตัวเลขID ของเครื่องป้องกันที่เมื่อสวมใส่แล้วสามารถวิ่งได้โดยไม่ต้องกดปุ่ม



โค๊ดสคริปต์
Code:
=begin

Dash-Enabling Equipment
by PK8
Created: 6/1/2012
Modified: -
??????????????????????????????????????????????????????????????????????????????
? Author's Notes
   This was an idea that came about when me and IceDragon were chatting about
   dashing.
??????????????????????????????????????????????????????????????????????????????
? Introduction
   This script allows developers to set which equipment disables/enables
   dashing.
??????????????????????????????????????????????????????????????????????????????
? Features
   o Set which equipment enables dashing when equipped.
   o Set which equipment makes you dash when equipped.
   o Decide if it only occurs with either the leader of the party or with the
      entire party.
??????????????????????????????????????????????????????????????????????????????
? Changelog
   o v1     (06/01/2012): Initial Release
??????????????????????????????????????????????????????????????????????????????
? Methods Aliased
   Game_Player.dash?

=end

#==============================================================================
# ** Configuration
#==============================================================================

module PK8
  class Dash_Equip
    #--------------------------------------------------------------------------
    # * General Settings
    #--------------------------------------------------------------------------
    # Turns script on (TRUE) or off (FALSE).
    Switch      = true
    # If TRUE, checks party leader for equipment. If FALSE, checks whole party.
    Leader      = true
    # Set which armor equipment will give players dashing ability when equipped
    # Integers and Ranges can be set.
    Armors      = [980..999]
    # If TRUE, Armors specified above would allow the player to dash. If FALSE,
    # armors not specified would allow the player to dash.
    Armors_Flag = true
    # Set which armors will have the side effect of making the player dash
    # without pressing a button. Integers and Ranges can be set.
    Armors_Auto = []
    
    #--------------------------------------------------------------------------
    # * Do Not Modify
    #--------------------------------------------------------------------------
    if Armors.include?(nil)
      load_data("Data/Armors.rvdata").keys.each { |item| Armors.push(item) }
      Armors.delete(nil)
    end
    Armors.each { |item|
      if item.is_a?(Range)
        for i in item; Armors.push(i); end
        Armors.delete(item)
      elsif item.is_a?(Array)
        item.each { | i |
          if i.is_a?(Integer); Armors.push[i]
          elsif i.is_a?(Range); for i2 in i; Armors.push[i2]; end
          end
        }
        Armors.delete(item)
      end
    }
    Armors.compact
    if Armors_Auto.include?(nil)
      load_data("Data/Armors.rvdata").keys.each {|item| Armors_Auto.push(item)}
      Armors_Auto.delete(nil)
    end
    Armors_Auto.each { |item|
      if item.is_a?(Range)
        for i in item; Armors_Auto.push(i); end
        Armors_Auto.delete(item)
      elsif item.is_a?(Array)
        item.each { | i |
          if i.is_a?(Integer); Armors_Auto.push[i]
          elsif i.is_a?(Range); for i2 in i; Armors_Auto.push[i2]; end
          end
        }
        Armors_Auto.delete(item)
      end
    }
    Armors_Auto.compact
  end
end

#==============================================================================
# ** Game_Player
#------------------------------------------------------------------------------
#  This class handles maps. It includes event starting determinants and map
# scrolling functions. The instance of this class is referenced by $game_map.
#==============================================================================

class Game_Player < Game_Character
  #--------------------------------------------------------------------------
  # * Alias Listings
  #--------------------------------------------------------------------------
  unless method_defined?(:pk8_dashequip_dash?)
    alias_method(:pk8_dashequip_dash?, :dash?)
  end
  #--------------------------------------------------------------------------
  # * Determine if Dashing
  #--------------------------------------------------------------------------
  def dash?
    if PK8::Dash_Equip::Switch == true
      if @move_route_forcing or $game_map.disable_dash? or in_vehicle?
        return false
      else
        # Checks for Auto-Dashing Armors
        PK8::Dash_Equip::Armors_Auto.each { | item |
          if PK8::Dash_Equip::Leader == true    # Applies to Party Leader only
            if $game_party.members[0].armors.include?($data_armors[item]) and
              $data_armors[item] != nil; return true;
            end
          else                                  # Applies to All Members
            $game_party.members.each { | member |
              if member.armors.include?($data_armors[item]) and
                $data_armors[item] != nil; return true;
              end
            }
          end
        }
        # Checks for Non Auto-Dashing Armors
        included = false
        PK8::Dash_Equip::Armors.each { | item |
          if PK8::Dash_Equip::Leader == true    # Applies to Party Leader only
            member = $game_party.members[0]
            if ((PK8::Dash_Equip::Armors_Flag==true and member.armors.include?(
              $data_armors[item])) or (PK8::Dash_Equip::Armors_Flag == false and
              !member.armors.include?($data_armors[item]))) and
              $data_armors[item] != nil; included = true; break;
            end
          else                                  # Applies to All Members
            $game_party.members.each { | member |
              if ((PK8::Dash_Equip::Armors_Flag==true and member.armors.
                include?($data_armors[item])) or (
                PK8::Dash_Equip::Armors_Flag==false and !member.armors.include?(
                $data_armors[item]))) and $data_armors[item] != nil
                  included = true
                  break
              end
            }
            break if included == true
          end
        }
        return true if included == true and Input.press?(Input::A)
        return false if included != true
      end
    end
    pk8_dashequip_dash?
  end
end
This post was last modified: 07-04-2012, 05:03 AM by LuZi.



  
Users browsing this thread: 1 Guest(s)
Powered By MyBB, © 2002-2024 MyBB Group.
Made with by Curves UI.