赞 | 0 |
VIP | 208 |
好人卡 | 0 |
积分 | 31 |
经验 | 35012 |
最后登录 | 2016-3-14 |
在线时间 | 177 小时 |
Lv3.寻梦者
- 梦石
- 3
- 星屑
- 50
- 在线时间
- 177 小时
- 注册时间
- 2008-3-21
- 帖子
- 939
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
这个我就不多说了,在武器数据库中使用方法与那个RMXP的基本相同。主要还是看范例。
核心脚本:与RMXP感觉上区别不小,但基本概念是一致的。
任何角色刚登场时SP都是0,因此开场时不要设定初始武器
武器仍可决定技能
不同SP显示颜色也不一样
- #不同SP分开用 VX 版 BY SLICK
- module RPG
- class Weapon # 武器名称所能决定SP种类及属性的定义方法(格式像这样:钢匕首,2000,0)
- attr_writer :w_maxsp
- attr_writer :w_akind
- def name
- name = @name.split(/,/)[0]
- return name != nil ? name : ''
- end
- def w_maxsp
- w_maxsp = @name.split(/,/)[1]
- return w_maxsp != nil ? w_maxsp.to_i : 0
- end
- def w_akind
- w_akind = @name.split(/,/)[2]
- return w_akind != nil ? w_akind.to_i : 1
- end
- end
- class Item < UsableItem
- attr_writer :i_rkind
- def name
- name = @name.split(/,/)[0]
- return name != nil ? name : ''
- end
- def i_rkind
- i_rkind = @name.split(/,/)[1]
- return i_rkind != nil ? i_rkind.to_i : nil
- end
- end
- end
- class Game_Actor < Game_Battler
- #--------------------------------------------------------------------------
- # ● 公開インスタンス変数
- #--------------------------------------------------------------------------
- #这里做修改==================================
- attr_accessor :ammo # SP残留量
- attr_accessor :akind # 使用何种SP
- attr_accessor :cta # SP最大容量
- #=======================================
-
- #感谢禾大人帮助精简==============================
- #--------------------------------------------------------------------------
- # ● セットアップ
- # actor_id : アクター ID
- #--------------------------------------------------------------------------
- alias ooo_setup setup
- def setup(actor_id)
- #=======================================
-
- #这里做修改==================================
- @ammo = [0,0,0,0,0,0,0,0,0,0,0,0,0]# 目前只使用9-12四种能量
- @akind = 10 # 缺省情况下使用格斗技能量
- @cta = [0,0,0,0,0,0,0,0,0,0,0,0,0]# 每一种能量的最大值都要设定
- #=======================================
- ooo_setup(actor_id)
- end
- end
- #==============================================================================
- # ■ Scene_Equip
- #------------------------------------------------------------------------------
- # 处理装备画面
- #==============================================================================
- class Scene_Equip < Scene_Base
- #--------------------------------------------------------------------------
- # ● 更新选择装备部位
- #--------------------------------------------------------------------------
- def update_equip_selection
- if Input.trigger?(Input::B)
- Sound.play_cancel
- #装备结束时再次判断一下属性SP值========================
- if $lammo=[]
- $lkind = @actor.akind #弹药种类是否与以前相同?
- for ii in [email protected]
- $lammo[ii][email protected][ii]
- end
- end
- neomaxsp=0
- if @actor.weapon_id !=0
- @actor.akind=$data_weapons[@actor.weapon_id].w_akind
- neomaxsp+=$data_weapons[@actor.weapon_id].w_maxsp
- @actor.cta[@actor.akind]=neomaxsp
- @actor.ammo[@actor.akind] = [$lammo[@actor.akind],@actor.cta[@actor.akind]].min#弹药种类相同取弹匣小值
- else #如果扔掉武器,SP就是0
- @actor.akind=1
- @actor.cta[@actor.akind]=0
- @actor.ammo[@actor.akind]=0
- end
- #=======================================
- return_scene
- elsif Input.trigger?(Input::R)
- Sound.play_cursor
- next_actor
- elsif Input.trigger?(Input::L)
- Sound.play_cursor
- prev_actor
- elsif Input.trigger?(Input::C)
- if @actor.fix_equipment
- Sound.play_buzzer
- else
- Sound.play_decision
- @equip_window.active = false
- @item_window.active = true
- @item_window.index = 0
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● 更新选择物品
- #--------------------------------------------------------------------------
- def update_item_selection
- if Input.trigger?(Input::B)
- Sound.play_cancel
- @equip_window.active = true
- @item_window.active = false
- @item_window.index = -1
- elsif Input.trigger?(Input::C)
- Sound.play_equip
- #开始装备武器时判断一下属性SP值========================
- $lkind = @actor.akind #弹药种类是否与以前相同?
- $lammo = []
- for ii in [email protected]
- $lammo[ii][email protected][ii]
- end
- #=======================================
- @actor.change_equip(@equip_window.index, @item_window.item)
- @equip_window.active = true
- @item_window.active = false
- @item_window.index = -1
- @equip_window.refresh
- for item_window in @item_windows
- item_window.refresh
- end
- end
- end
- end
- class Game_Battler
- #--------------------------------------------------------------------------
- SW_SET = [9,10,11,12] # 此处设定武器和技能关联的属性id
- #--------------------------------------------------------------------------
- def skill_can_use?(skill)
- if self.is_a?(Game_Actor) and self.weapon_id > 0
- sw_boolean = false # 判断武器和技能关联
- s = SW_SET & $data_skills[skill.id].element_set
- if s.empty?
- sw_boolean = true
- else
- for i in s
- if $data_weapons[self.weapon_id].element_set .include?(i)
- sw_boolean = true
- break
- end
- end
- end
- if sw_boolean == false
- return false
- end
-
-
- #这里修改为对各种SP的判断===========================
- current_mp=self.ammo[self.akind]
- current_maxmp=self.cta[self.akind]
- #=======================================
-
-
- if $data_skills[skill.id].mp_cost > current_mp
- return false
- end
- end
- return false unless skill.is_a?(RPG::Skill)
- return false unless movable?
- return false if silent? and skill.spi_f > 0
- return false if calc_mp_cost(skill) > mp
- if $game_temp.in_battle
- return skill.battle_ok?
- else
- return skill.menu_ok?
- end
- end
- #--------------------------------------------------------------------------
- # ● 物品应用测试
- # user : 物品使用者
- # item : 物品
- # 判断在使用对象 HP/MP 满值时禁止回复。
- #--------------------------------------------------------------------------
- def item_test(user, item)
- tester = self.clone
- tester.make_obj_damage_value(user, item)
- tester.apply_state_changes(item)
- if tester.hp_damage < 0 or tester.calc_hp_recovery(user, item) > 0
- return true if tester.hp < tester.maxhp
- end
- if tester.mp_damage < 0 or tester.calc_mp_recovery(user, item) > 0
- return true if tester.ammo[tester.akind] < tester.cta[tester.akind]
- return true if item.i_rkind != tester.akind
- end
- return true unless tester.added_states.empty?
- return true unless tester.removed_states.empty?
- return true if item.parameter_type > 0
- return false
- end
- def item_effect(user, item)
- clear_action_results
- unless item_effective?(user, item)
- @skipped = true
- return
- end
- if rand(100) >= calc_hit(user, item) # 判断命中
- @missed = true
- return
- end
- if rand(100) < calc_eva(user, item) # 判断回避
- @evaded = true
- return
- end
- hp_recovery = calc_hp_recovery(user, item) # 计算 HP 回复量
- mp_recovery = calc_mp_recovery(user, item) # 计算 MP 回复量
- make_obj_damage_value(user, item) # 计算伤害
- @hp_damage -= hp_recovery # 减去 HP 回复量
- @mp_damage -= mp_recovery # 减去 MP 回复量
- case item.i_rkind
- when nil
- user.ammo[user.akind]+=mp_recovery
- if user.ammo[user.akind]>user.cta[user.akind]
- user.ammo[user.akind]=user.cta[user.akind]
- end
- when 255
- for ii in 0...user.cta.size
- user.ammo[ii]+=mp_recovery
- if user.ammo[ii]>user.cta[ii] and ii==user.akind
- user.ammo[ii]=user.cta[ii]
- end
- end
- else
- user.ammo[item.i_rkind]+=mp_recovery
- if user.ammo[item.i_rkind]>user.cta[item.i_rkind] and item.i_rkind==user.akind
- user.ammo[item.i_rkind]=user.cta[item.i_rkind]
- end
- end
- make_obj_absorb_effect(user, item) # 计算吸收效果
- execute_damage(user) # 反映伤害
- item_growth_effect(user, item) # 应用成长效果
- if item.physical_attack and @hp_damage == 0 # 判断物理攻击无效
- return
- end
- apply_state_changes(item) # 状态变化
- end
- end
- class Scene_Battle
- #--------------------------------------------------------------------------
- # ● 执行战斗行动 : 特技
- #--------------------------------------------------------------------------
- def execute_action_skill
- skill = @active_battler.action.skill
- text = @active_battler.name + skill.message1
- @message_window.add_instant_text(text)
- unless skill.message2.empty?
- wait(10)
- @message_window.add_instant_text(skill.message2)
- end
- targets = @active_battler.action.make_targets
- display_animation(targets, skill.animation_id)
- # 消耗 SP(区分不同种类)===========================
- if @active_battler.is_a?(Game_Actor)
- @active_battler.ammo[@active_battler.akind] -= @active_battler.calc_mp_cost(skill)
- else
- @active_battler.mp -= @active_battler.calc_mp_cost(skill)
- end if
- #=======================================
- $game_temp.common_event_id = skill.common_event_id
- for target in targets
- target.skill_effect(@active_battler, skill)
- display_action_effects(target, skill)
- end
- end
- end
- class Window_Base
- #--------------------------------------------------------------------------
- # ● 描绘 MP
- # actor : 角色
- # x : 描绘目标 X 坐标
- # y : 描绘目标 Y 坐标
- # width : 宽
- #--------------------------------------------------------------------------
- def draw_actor_mp(actor, x, y, width = 120)
- draw_actor_mp_gauge(actor, x, y, width)
- self.contents.font.color = system_color
- self.contents.draw_text(x, y, 30, WLH, Vocab::mp_a)
- self.contents.font.color = mp_color(actor)
- xr = x + width
- if width < 120
- self.contents.draw_text(xr - 40, y, 40, WLH, actor.ammo[actor.akind], 2)
- else
- self.contents.draw_text(xr - 90, y, 40, WLH, actor.ammo[actor.akind], 2)
- self.contents.font.color = normal_color
- self.contents.draw_text(xr - 50, y, 10, WLH, "/", 2)
- self.contents.draw_text(xr - 40, y, 40, WLH, actor.cta[actor.akind], 2)
- end
- end
- #--------------------------------------------------------------------------
- # ● 描绘 MP 槽
- # actor : 角色
- # x : 描绘目标 X 坐标
- # y : 描绘目标 Y 坐标
- # width : 宽
- #--------------------------------------------------------------------------
- def draw_actor_mp_gauge(actor, x, y, width = 120)
- gw = width * actor.ammo[actor.akind] / [actor.cta[actor.akind], 1].max
- case actor.akind
- when 9
- gc1=Color.new(255,128,128,255)
- gc2=Color.new(192, 0, 0,255)
- when 10
- gc1=Color.new(192,192,192,255)
- gc2=Color.new( 96, 96, 96,255)
- when 11
- gc1=Color.new(128,255,128,255)
- gc2=Color.new( 0,192, 0,255)
- when 12
- gc1=Color.new(128,128,255,255)
- gc2=Color.new( 0, 0,192,255)
- else
- gc1 = mp_gauge_color1
- gc2 = mp_gauge_color2
- end
- self.contents.fill_rect(x, y + WLH - 8, width, 6, gauge_back_color)
- self.contents.gradient_fill_rect(x, y + WLH - 8, gw, 6, gc1, gc2)
- end
- end
复制代码
http://rpg.blue/upload_program/f ... ��(VX)_93468951.rar
詳細說明請看XP版的:
http://rpg.blue/viewthread.php?tid=88299
[right]----snstar2006[/right] |
|