Bạn có muốn phản ứng với tin nhắn này? Vui lòng đăng ký diễn đàn trong một vài cú nhấp chuột hoặc đăng nhập để tiếp tục.



 
Trang ChínhPortalTìm kiếmLatest imagesĐăng kýĐăng Nhập
Bài gửiNgười gửiThời gian
GAME nhập vai - Gta San Andreas phiên bản multiplayer. [ScriptVX]Skill Requirement System 1.0 115/11/2014, 22:08
Tài nguyên game bang bang zing me [ScriptVX]Skill Requirement System 1.0 114/11/2014, 07:32
Hướng dẫn làm nhân vật di chuyển [ScriptVX]Skill Requirement System 1.0 114/11/2014, 06:57
Cách sử dụng code current [ScriptVX]Skill Requirement System 1.0 114/11/2014, 06:52
Em xin làm đoạn video do em tự dẫn giúp cho các anh chị nào không biết các công cụ trong game maker [ScriptVX]Skill Requirement System 1.0 114/11/2014, 06:50
Cần tài nguyên game Võ đài thần tiên [ScriptVX]Skill Requirement System 1.0 114/11/2014, 06:39
Tải RPG XP + Việt Hóa [ScriptVX]Skill Requirement System 1.0 127/9/2014, 18:50
Bản hướng dẫn RPGXP đây..... [ScriptVX]Skill Requirement System 1.0 127/9/2014, 13:43
can giup [ScriptVX]Skill Requirement System 1.0 127/9/2014, 13:40
can giup [ScriptVX]Skill Requirement System 1.0 127/9/2014, 13:36
sự thật về vtc academy hcm [ScriptVX]Skill Requirement System 1.0 122/10/2013, 20:07
[vnplay.org]MU Việt Season 6.3 - Reset Và Non Reset -Không Webshop - Open tháng 5 [ScriptVX]Skill Requirement System 1.0 14/5/2013, 15:35
Phần trang bị giống game diablo [ScriptVX]Skill Requirement System 1.0 113/3/2013, 18:31
Game4V và Event "Viết bài hay, nhận ngay quà tặng" [ScriptVX]Skill Requirement System 1.0 119/2/2012, 21:24
HELP: Failed to create process [ScriptVX]Skill Requirement System 1.0 113/12/2011, 11:27
Danh hiệu member [ScriptVX]Skill Requirement System 1.0 16/12/2011, 13:02
TRY.VN RA MẮT CỤM MÁY CHỦ MỚI : HOÀN MỸ - OPEN 22/11 - ĐỈNH CAO MU ONLINE [ScriptVX]Skill Requirement System 1.0 123/11/2011, 07:44
MU 24 Giờ - Cực khó dành cho game thủ đích thực - Open Beta vào lúc 11h ngày 11/11/2011 [ScriptVX]Skill Requirement System 1.0 119/11/2011, 18:55
wqswqdqw [ScriptVX]Skill Requirement System 1.0 123/10/2011, 21:51
Diễn đàn Make Game VN chính thức [ScriptVX]Skill Requirement System 1.0 131/8/2011, 10:29

Share | 
 

 [ScriptVX]Skill Requirement System 1.0

Xem chủ đề cũ hơn Xem chủ đề mới hơn Go down 
Tác giảThông điệp
duongtiep
Level 15
Level 15
duongtiep

Danh hiệu : The King
Tổng số bài gửi : 1229
MGV Xu : 2677
Danh tiếng : 45
Ngày tham gia : 10/12/2010
Đến từ : Quảng Ninh

[ScriptVX]Skill Requirement System 1.0 Empty
Bài gửiTiêu đề: [ScriptVX]Skill Requirement System 1.0   [ScriptVX]Skill Requirement System 1.0 I_icon_minitime14/12/2010, 06:04

Skill Requirement System 1.0
Version 1.0 #
Author: Queex

Giới thiệu
Script này bổ sung các hiệu chỉnh để bạn có thể thêm các yêu cầu cho Skill. Ví dụ để sử dụng Skill "Đấm" thì cần phải có vũ khí "Bao tay đấm bốc" chẳng hạn.
Yêu cầu script TagNote 2.0 để sử dụng.

TagNote 2.0
Code:
###############
# TagNote    #
######################################################################
# Version 2.0                                                        #
# Author: Queex                                                      #
# Licence: Creative Commons non-commercial attributive              #
######################################################################
# Allows the easy use of tags in the note field for                  #
# objects to store data. Syntax is simple, and the system ignores    #
# any lines in the notes field that don't match the syntax.          #
#                                                                    #
# Version history:                                                  #
# 1.2 Final 1.x version                                              #
# 2.0 Changed to follow Ruby naming conventions                      #
#                                                                    #
# Usage:                                                            #
# get_tag(<notes field>,<tag name>)                                  #
# has_tag?(<notes field>,<tag name>)                                #
# has_tag_value?(<notes field>,<tag name>,<tag value>)              #
# get_additional_tag(<notes field>,<tag name>,<index>                #
# get_additional_tag_by_value(<notes field>,<tag name>,<tag value>  #
#                                                          ,<index> #
#                                                                    #
# Syntax in the note field:                                          #
# <tag_name tag_value>                                              #
# <tag_name>                                                        #
# <tag_name tag_value param1 param2 ...>                            #
######################################################################

module TAGNOTE

###########
# get_tag #
###################################################################
# Gets the stored value of the first occurrence of the named tag  #
# in the notes field.                                            #
# <tag_name tag_value tag_value2>        will return 'tag_value' #
# <tag_name tag_value>                    will return 'tag_value' #
# <tag_name>                              will return true        #
# if no tag with tag_name, returns nil                            #
###################################################################
def get_tag(note_field, tag_name)
  lines=note_field.split("\n")
  for line in lines
    #process line by line
    if line[0,1].eql?("<")
      #this line has a tag
      line2=line.split(/[<> ]/)
      if line2[1].eql?(tag_name)
        if(line2.length==2)
          #there is actually no value
          return true
        else
          return line2[2]
        end
      end
    end
  end
  return nil
end

############
# has_tag? #
##################################################################
# Indicates whether the given note field has a tag of that name. #
# <tag_name tag_value tag_value2> and                            #
# <tag_name tag_value>            and                            #
# <tag_name>                      will both return true          #
# if no tag with tag_name, returns false                        #
##################################################################
def has_tag?(note_field,tag_name)
  lines=note_field.split("\n")
  for line in lines
    if line[0,1].eql?("<")
      line2=line.split(/[<> ]/)
      if line2[1].eql?(tag_name)
        return true
      end
    end
  end
  return false
end

##################
# has_tag_value? #
#################################################################
# Indicates whether the note field has a tag of a given name    #
# with a certain value.                                        #
# <tag_name tag_value>      returns true                      #
# <tag_name wrong_tag_value> returns false                      #
# <tag_name>                returns false                      #
# if no tag with tag_name has the correct value, returns false. #
# tag_value2 is ignored                                        #
#################################################################
def has_tag_value?(note_field,tag_name,tag_value)
  lines=note_field.split("\n")
  for line in lines
    if line[0,1].eql?("<")
      line2=line.split(/[<> ]/)
      if line2[1].eql?(tag_name) and line2[2].eql?(tag_value)
        return true
      end
    end
  end
  return false
end

######################
# get_additional_tag #
######################################################################
# Gets additional parameters for a tag of a given name.              #
# Calling with an index of 1 returns                                #
# the first value after the tag name.                                #
# Returns nil if the index is higher than the last parameter.        #
# Returns false if no match for the tag name is found.              #
######################################################################
def get_additional_tag(note_field,tag_name,index)
  lines=note_field.split("\n")
  for line in lines
    if line[0,1].eql?("<")
      line2=line.split(/[<> ]/)
      if line2[1].eql?(tag_name)
        if(line2.length<index+2)
          #Actually no value to get
          return nil
        else
          return line2[index+1]
        end
      end
    end
  end
  return false
end

###############################
# get_additional_tag_by_value #
######################################################################
# Gets additional parameters for a tag of a given name              #
# with a certain value. Calling with an index of 1 returns          #
# the first value after the tag name.                                #
# Returns nil if the index is higher than the last parameter.        #
# Returns false if no match for the tag name and tag value is found. #
######################################################################
def get_additional_tag_by_value(note_field,tag_name,tag_value,index)
  lines=note_field.split("\n")
  for line in lines
    if line[0,1].eql?("<")
      line2=line.split(/[<> ]/)
      if line2[1].eql?(tag_name) and line2[2].eql?(tag_value)
        if(line2.length<index+2)
          #Actually no value to get
          return nil
        else
          return line2[index+1]
        end
      end
    end
  end
  return false
end

end

Requirements for Skills
Code:
###########################
# Requirements for Skills #
##############################################################################
# Version 1.0                                                                #
# Author: Queex                                                              #
# Licence: Creative Commons Non-Commercial Attributive                      #
# Requires: TagNote 2.0+                                                    #
##############################################################################
# Allows extra requirement before skills can be used. The requirements are  #
# tags added to the notes field ofthe skills. Currently, only the first      #
# requirement of a given type is checked.                                    #
#                                                                            #
# Tags that can be used in weapons:                                          #
# <weapon_type xxx>                                                          #
#                                                                            #
# Tags that can be used in items:                                            #
# <include_battle_test>  - makes this item available when testing battles  #
#                                                                            #
# Tags that can be used in skills:                                          #
# <weapon_type xxx> - only weapons with this same type can use this skill    #
# <item_present id> - the party must possess at least 1 item of that id      #
# <item_consume id n> - the party must possess n items of that id, which    #
#                      will be consumed.                                    #
# <item_consume id> - the party must possess 1 item of that id, which will  #
#                    be consumed.                                          #
# <hp_percent_exceed per> - the actor's HP must equal or exceed this        #
#                          percentage.                                      #
# <hp_percent_below per> - the actor's HP must be below this percentage.    #
# <mp_percent_exceed per> - the actor's MP must equal or exceed this        #
#                          percentage.                                      #
# <mp_percent_exceed per true> - the actor's MP must equal or exceed this    #
#                                percentage, and that percentage will be    #
#                                consumed.                                  #
# <mp_percent_below per> - the actor's MP must be below this percentage.    #
# <free_hand> - the actor must have at least one free hand.                  #
# <dual_weapon> - the actor must be using two weapons.                      #
# <two_handed_weapon> - the actor must be using a two-handed weapon.        #
#                                                                            #
# Note:                                                                      #
# This script also includes the function hands_free which returns the        #
# number of free hands for a Game_Actor.                                    #
#                                                                            #
# Version History:                                                          #
# 0.4 - test release                                                        #
# 0.5 - can specify some item to include in battle test                      #
# 1.0 - Bugfix and update to TagNote 2.0 *RELEASE*                          #
##############################################################################

class Game_Actor < Game_Battler
 
  include TAGNOTE

  def hands_free
    if weapons[0]==nil
      if @armor1_id[0]==0
        return 2
      elsif weapons.length==2
        if weapons[1].two_handed
          return 0
        else
          return 1
        end
      else
        return 1
      end
    elsif weapons[0].two_handed or @armor1_id!=0
      return 0
    else
      return 1
    end
  end

  alias skill_req_skill_can_use? skill_can_use?
  def skill_can_use?(skill)
   
    if skill.id != 0
      skill_note=$data_skills[skill.id].note
      #Check for weapon type
      skill_needs = get_tag(skill_note,"weapon_type") #weapon type string
      if skill_needs != nil
        if two_swords_style
          if @weapon_id!=0 and @armor1_id!=0
            return false unless has_tag_value?($data_weapons[@weapon_id].note,"weapon_type",skill_needs) or has_tag_value?($data_weapons[@armor1_id].note,"weapon_type",skill_needs)
          elsif @weapon_id!=0
            return false unless has_tag_value?($data_weapons[@weapon_id].note,"weapon_type",skill_needs)
          elsif @armor1_id!=0
            return false unless has_tag_value?($data_weapons[@armor1_id].note,"weapon_type",skill_needs)
          else
            return false
          end
        else
          return false unless @weapon_id!=0
          return false unless has_tag_value?($data_weapons[@weapon_id].note,"weapon_type",skill_needs)
        end
      end
     
      #Check for item presence
      skill_needs = get_tag(skill_note,"item_present") #item id
      if skill_needs != nil
        return false unless $game_party.has_item?($data_items[skill_needs.to_i],true)
      end
     
      #Check for item consumption
      skill_needs = get_tag(skill_note,"item_consume") #item id
      if skill_needs !=nil
        skill_needs_num = get_additional_tag(skill_note,"item_consume",2) #number
        if skill_needs_num == nil
          skill_needs_num = 1
        end
        return false unless $game_party.item_number($data_items[skill_needs.to_i])>=skill_needs_num.to_i
      end
     
      #Check for HP exceeds
      skill_needs = get_tag(skill_note,"hp_percent_exceed") #percent
      if skill_needs !=nil
        return false unless (100.0 * @hp/maxhp)>=skill_needs.to_f
      end
     
      #Check for HP below
      skill_needs = get_tag(skill_note,"hp_percent_below") #percent
      if skill_needs != nil
        return false unless (100.0 * @hp/maxhp)<skill_needs.to_f
      end
     
      #Check for MP exceeds
      skill_needs = get_tag(skill_note,"mp_percent_exceed") #percent
      if skill_needs != nil
        return false unless (100.0 * @mp/maxmp)>=skill_needs.to_f
      end
     
      #Check for MP below
      skill_needs = get_tag(skill_note,"mp_percent_below") #percent
      if skill_needs != nil
        return false unless (100.0* @mp/maxmp)<skill_needs.to_f
      end
     
      #Check for free hand
      skill_needs = has_tag?(skill_note,"free_hand") #boolean
      if skill_needs
        return false unless hands_free>=1
      end
     
      #Check for dual weapons
      skill_needs = has_tag?(skill_note,"dual_weapon") #boolean
      if skill_needs
        return false unless two_swords_style
        return false unless weapons[0]!=nil and weapons[1]!=nil
      end
     
      #Check for two-handed weapon
      skill_needs = has_tag?(skill_note,"two_handed_weapon") #boolean
      if skill_needs
        return false unless ( weapons[0]!= nil and weapons[0].two_handed)
        if two_swords_style
          return false unless ( weapons[0]!= nil and weapons[0].two_handed) or (weapons[1] != nil and weapons[1].two_handed)
        end
      end
     
      return skill_req_skill_can_use?(skill)
    end
  end
 
 
  def calc_mp_cost(skill)
    base_cost=skill.mp_cost
   
    mp_prop=get_tag(skill.note,"mp_percent_exceed")
    if mp_prop!=nil
      mp_lose=get_additional_tag_value(skill.note,"mp_percent_exceed",2)
      if mp_lose.eql?("true")
        base_cost=(mp_prop.to_f/100.0 * maxmp).to_i
      end
    end
   
    if half_mp_cost
      return base_cost / 2
    else
      return base_cost
    end
  end
 
end

class Scene_Battle < Scene_Base
 
  include TAGNOTE
#--------------------------------------------------------------------------
# * Execute Battle Action: Skill
#--------------------------------------------------------------------------
  alias skill_req_execute_action_skill execute_action_skill
  def execute_action_skill
    skill_req_execute_action_skill
    skill = @active_battler.action.skill
   
    #consume items required
    skill_needs = get_tag(skill.note,"item_consume")
    if skill_needs != nil
      num_items = get_additional_tag(skill.note,"item_consume",2)
      if num_items==nil
        num_items=1
      end
      $game_party.lose_item($data_items[skill_needs.to_i],num_items.to_i,true)
    end
  end
end

class Game_Party < Game_Unit
 
  include TAGNOTE
 
  alias skill_req_setup_battle_test_members setup_battle_test_members
  def setup_battle_test_members
    skill_req_setup_battle_test_members
    for i in 1...$data_items.size
      if has_tag?($data_items[i].note,"include_battle_test")
        @items[i] = 99
      end
    end
  end
end

Hướng dẫn sử dụng
Thêm các dòng sau vào phần Note khi tạo Skill trong Database.

<weapon_type x>
Yêu cầu vũ khí tương ứng để dùng Skill. Trong đó 'x' là nơi bạn đánh tên của vũ khí đó.

<item_present x>
Yêu cầu vật phẩm tương ứng để dùng Skill. Trong ó 'x' là nơi bạn nhập ID của vật phẩm đó (ID của vật phẩm xem ở Database).

<item_consumed x>
<item_consumed x n>

Khi sử dụng Skill thì sẽ mất đi một vật phẩm tương ứng, và đòi hỏi Party phải sỡ hữu vật phẩm đó. 'x' là nơi nhập ID của vật phẩm, và 'n' là nơi nhập số lượng bị mất đi khi dùng Skill. Nếu không có 'n', thì mặc định sẽ mất đi một vật phẩm khi sử dụng Skill,

<hp_percent_exceed p>
Yêu cầu HP (Sinh lực) của nhân vật phải cao hơn số 'p'. Số nhập vào 'p' là tỉ lệ % HP của nhân vật. Ví dụ bạn đánh vào 50% thì nhân vật đó phải có số máu cao hơn hoặc bằng 50% để sử dụng skill.

<hp_percent_below p>
Yêu cầu HP (Sinh lực) của nhân vật phải thấp hơn số 'p'. Số nhập vào 'p' là tỉ lệ % HP của nhân vật. Ví dụ bạn đánh vào 50 thì nhân vật đó phải có số máu thấp hơn 50% để sử dụng skill.

<mp_percent_exceed p>
<mp_percent_exceed p true>

Yêu cầu MP (Ma lực) của nhân vật phải cao hơn số 'p'. Số nhập vào 'p' là tỉ lệ % MP của nhân vật. Ví dụ bạn đánh vào 50 thì nhân vật đó phải có số ma lực cao hơn hoặc bằng 50% để sử dụng skill. Nếu thêm 'true' vào, thì số MP đó sẽ bị tiêu hao khi sử dụng Skill.

<mp_percent_below p>
Yêu cầu MP (Ma lực) của nhân vật phải thấp hơn số 'p'. Số nhập vào 'p' là tỉ lệ % MP của nhân vật. Ví dụ bạn đánh vào 50 thì nhân vật đó phải có số ma lực thấp hơn 50% để sử dụng skill.

<free_hand>
Yêu cầu Nhân vật phải ở trạng thái Rảnh tay, tức không trang bị vũ khí.

<dual_weapon>
Yêu cầu Nhân vật trang bị vũ khí trên hai tay.

<two_handed_weapon>
Yêu cầu Nhân vật trang bị vũ khí cầm bằng hai tay.
Chữ ký của duongtiep
Về Đầu Trang Go down
https://makegame.forumvi.com
 

[ScriptVX]Skill Requirement System 1.0

Xem chủ đề cũ hơn Xem chủ đề mới hơn Về Đầu Trang 

 Similar topics

+
Trang 1 trong tổng số 1 trang

Permissions in this forum:Bạn không có quyền trả lời bài viết
 :: RPG VX :: Script-
Chuyển đến