设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 3170|回复: 4
打印 上一主题 下一主题

[原创发布] 給装备附加多个自动状态

 关闭 [复制链接]

Lv3.寻梦者

酱油的

梦石
0
星屑
975
在线时间
2161 小时
注册时间
2007-12-22
帖子
3271

贵宾

跳转到指定楼层
1
发表于 2008-3-9 16:10:55 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有帐号?注册会员

x
本帖最后由 后知后觉 于 2009-12-29 16:37 编辑

那個啥?一個自動狀態根本就不夠用嘛!
  1. #==============================================================================
  2. # 附加多於一個自動狀態
  3. # 禾西
  4. #==============================================================================
  5. module RPG
  6.   class Weapon
  7.     def auto_state_set
  8.       auto_state_set = []
  9.       return [] if @description.split(/@s/)[1].nil?
  10.       a = @description.split(/@s/)[1].split(/,/)
  11.       a.each {|i| auto_state_set.push(i.to_i)}
  12.       return auto_state_set.nil? ? [] : auto_state_set
  13.     end
  14.     def description
  15.       description = @description.split(/@s/)[0]
  16.       return description.nil? ? '' : description
  17.     end
  18.   end
  19.   class Armor
  20.     def auto_state_set
  21.       auto_state_set = []
  22.       return [] if @description.split(/@s/)[1].nil?
  23.       a = @description.split(/@s/)[1].split(/,/)
  24.       a.each {|i| auto_state_set.push(i.to_i)}
  25.       return auto_state_set.nil? ? [] : auto_state_set
  26.     end
  27.     def description
  28.       description = @description.split(/@s/)[0]
  29.       return description.nil? ? '' : description
  30.     end
  31.   end
  32. end
  33. #==============================================================================
  34. # ■ Game_Actor
  35. #------------------------------------------------------------------------------
  36. #  处理角色的类。本类在 Game_Actors 类 ($game_actors)
  37. # 的内部使用、Game_Party 类请参考 ($game_party) 。
  38. #==============================================================================

  39. class Game_Actor < Game_Battler
  40.   #--------------------------------------------------------------------------#
  41.   # ● 更新自动状态組(新方法)                                                #
  42.   #     old_armor : 卸下防具                                                 #
  43.   #     new_armor : 装备防具                                                 #
  44.   #--------------------------------------------------------------------------#
  45.   def update_auto_state_set(old_armor, new_armor)
  46.     # 强制解除卸下防具的自动状态
  47.     if old_armor != nil and old_armor.auto_state_set.empty? != true
  48.       for i in 0...old_armor.auto_state_set.size
  49.         if @states.include? old_armor.auto_state_set[i]
  50.           remove_state(old_armor.auto_state_set[i], true)
  51.         end
  52.       end
  53.     end
  54.     # 强制附加装备防具的自动状态
  55.     if new_armor != nil and new_armor.auto_state_set.empty? != true
  56.       for i in 0...new_armor.auto_state_set.size
  57.         add_state(new_armor.auto_state_set[i], true)
  58.       end
  59.     end
  60.   end
  61. #----------------------------------------------------------------------------
  62. # ● 召喚舊方法
  63. #----------------------------------------------------------------------------
  64.   #--------------------------------------------------------------------------
  65.   # ● 设置
  66.   #     actor_id : 角色 ID
  67.   #--------------------------------------------------------------------------
  68.   alias sidaf_setup setup
  69.   def setup(actor_id)
  70.     sidaf_setup(actor_id)
  71. #---------------------刷新自动状态組---------------------#
  72.     update_auto_state_set(nil, $data_weapons[@weapon_id])
  73.     update_auto_state_set(nil, $data_armors[@armor1_id])
  74.     update_auto_state_set(nil, $data_armors[@armor2_id])
  75.     update_auto_state_set(nil, $data_armors[@armor3_id])
  76.     update_auto_state_set(nil, $data_armors[@armor4_id])
  77. #--------------------------------------------------------#
  78.   end
  79.   #--------------------------------------------------------------------------
  80.   # ● 变更装备
  81.   #     equip_type : 装备类型
  82.   #     id    : 武器 or 防具 ID  (0 为解除装备)
  83.   #--------------------------------------------------------------------------
  84.   def equip(equip_type, id)
  85.     case equip_type
  86.     when 0  # 武器
  87.       if id == 0 or $game_party.weapon_number(id) > 0
  88.         
  89. # 刷新自動狀態組---------------------------------------------------------
  90.         update_auto_state_set($data_weapons[@weapon_id], $data_weapons[id])
  91. # 完了-------------------------------------------------------------------------
  92.         
  93.         $game_party.gain_weapon(@weapon_id, 1)
  94.         @weapon_id = id
  95.         $game_party.lose_weapon(id, 1)
  96.       end
  97.     when 1  # 盾
  98.       if id == 0 or $game_party.armor_number(id) > 0
  99.         
  100.         
  101. # 刷新自動狀態組---------------------------------------------------------
  102.         update_auto_state_set($data_armors[@armor1_id], $data_armors[id])
  103. # 完了-------------------------------------------------------------------------
  104.         
  105.         update_auto_state($data_armors[@armor1_id], $data_armors[id])
  106.         $game_party.gain_armor(@armor1_id, 1)
  107.         @armor1_id = id
  108.         $game_party.lose_armor(id, 1)
  109.       end
  110.     when 2  # 头
  111.       if id == 0 or $game_party.armor_number(id) > 0
  112.         
  113.         
  114. # 刷新自動狀態組---------------------------------------------------------
  115.         update_auto_state_set($data_armors[@armor2_id], $data_armors[id])
  116. # 完了-------------------------------------------------------------------------
  117.         
  118.         update_auto_state($data_armors[@armor2_id], $data_armors[id])
  119.         $game_party.gain_armor(@armor2_id, 1)
  120.         @armor2_id = id
  121.         $game_party.lose_armor(id, 1)
  122.       end
  123.     when 3  # 身体
  124.       if id == 0 or $game_party.armor_number(id) > 0
  125.         
  126.         
  127. # 刷新自動狀態組---------------------------------------------------------
  128.         update_auto_state_set($data_armors[@armor3_id], $data_armors[id])
  129. # 完了-------------------------------------------------------------------------
  130.         
  131.         update_auto_state($data_armors[@armor3_id], $data_armors[id])
  132.         $game_party.gain_armor(@armor3_id, 1)
  133.         @armor3_id = id
  134.         $game_party.lose_armor(id, 1)
  135.       end
  136.     when 4  # 装饰品
  137.       if id == 0 or $game_party.armor_number(id) > 0
  138.         
  139. # 刷新自動狀態組---------------------------------------------------------
  140.         update_auto_state_set($data_armors[@armor4_id], $data_armors[id])
  141. # 完了-------------------------------------------------------------------------

  142.         
  143.         update_auto_state($data_armors[@armor4_id], $data_armors[id])
  144.         $game_party.gain_armor(@armor4_id, 1)
  145.         @armor4_id = id
  146.         $game_party.lose_armor(id, 1)
  147.       end
  148.     end
  149.   end
  150. end
复制代码
使用方法如下圖:


說明 + @s + 狀態ID1, 狀態ID2, 狀態ID3
設定方法武器防具通用
放假很無聊……外加近來沒有找到想寫的東西T T

              [本贴由 风雪优游 于 2008-3-19 22:20:22 进行了编辑]
不做頭像做簽名,看我囧冏有神(多謝山人有情提供 )
头像被屏蔽

Lv1.梦旅人 (禁止发言)

冰の红苹果的小狗狗

梦石
0
星屑
50
在线时间
0 小时
注册时间
2007-12-15
帖子
2539
2
发表于 2008-3-9 18:22:23 | 只看该作者
提示: 作者被禁止或删除 内容自动屏蔽
签名被屏蔽
回复 支持 反对

使用道具 举报

头像被屏蔽

Lv1.梦旅人 (禁止发言)

梦石
0
星屑
50
在线时间
0 小时
注册时间
2008-3-10
帖子
24
3
发表于 2008-3-10 08:52:22 | 只看该作者
提示: 作者被禁止或删除 内容自动屏蔽
签名被屏蔽
回复 支持 反对

使用道具 举报

Lv1.梦旅人

很傻很天真

梦石
0
星屑
55
在线时间
3 小时
注册时间
2007-3-13
帖子
3667
4
发表于 2008-3-14 04:26:17 | 只看该作者
   不错.....不过有BUG吗?
回复 支持 反对

使用道具 举报

Lv1.梦旅人

风雪夜不归人

梦石
0
星屑
50
在线时间
276 小时
注册时间
2006-3-7
帖子
6721

贵宾

5
发表于 2008-3-20 06:18:27 | 只看该作者
发布完毕,VIP+2
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-5-15 04:34

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表