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

Project1

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

[RMVA发布] 自用的召唤兽系统 2013-03-23更新设定召唤兽数量上限

[复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
77 小时
注册时间
2006-6-12
帖子
95
跳转到指定楼层
1
发表于 2013-3-18 15:57:23 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

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

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

x
本帖最后由 wangxinly 于 2013-3-23 23:03 编辑

自己编写的一个召唤兽系统,可以在战斗时召唤出敌人来帮我方战斗。可以自己设定是否有回合数限制和是否挡住敌人的攻击

因为是新手,摸索着编写的,依然很多问题
比如召唤兽的辅助技能是给我方角色加,而我方角色是给自己加,所以召唤兽不能补血、辅助、复活等
另外敌人的全体攻击会被召唤兽全部挡住,而不会伤害到我方角色

使用这个召唤兽系统,要设定一个技能,技能使用效果里设置出发公共事件,公共事件里执行脚本$game_sunmmon.add(summon_id,liveturn=9999)
summon_id是数据库里的敌人的编号,liveturn是存在的回合,不填就默认9999


这个召唤兽系统要修改BattleManager
RUBY 代码复制
  1. #修改---------------------------------------------------------------------------
  2.   #召唤兽产生行动
  3.   def self.input_start
  4.     if @phase != :input
  5.       @phase = :input
  6.       $game_party.make_actions
  7.       $game_troop.make_actions
  8.       #修改
  9.       $game_sunmmon.make_actions
  10.       #修改结束
  11.       clear_actor
  12.     end
  13.     return !@surprise && $game_party.inputable?
  14.   end
  15.   #召唤兽参与回合行动
  16.   def self.make_action_orders
  17.     @action_battlers = []
  18.     @action_battlers += $game_party.members unless @surprise
  19.     @action_battlers += $game_troop.members unless @preemptive
  20.     @action_battlers.each {|battler| battler.make_speed }
  21.     @action_battlers.sort! {|a,b| b.speed - a.speed }
  22.     #修改
  23.     @action_battlers += $game_sunmmon.alive_members
  24.     #修改结束
  25.   end
,可以对比着修改,或者直接在最后一个end前加入





这些在MAIN前新开一页复制进去就好
RUBY 代码复制
  1. #需要修改BattleManager
  2. #战斗时才能使用的召唤兽系统,可以帮助战斗,不包括召唤兽,我方角色全灭即算战斗失败
  3. #
  4. #
  5. #
  6. #使用这个召唤兽系统,要设定一个技能,技能使用效果里设置出发公共事件
  7. #公共事件里执行脚本$game_sunmmon.add(summon_id,liveturn=9999)
  8. #summon_id是数据库里的敌人的编号,liveturn是存在的回合,不填就默认9999
  9. #例如$game_sunmmon.add(30) 既是召唤第30个敌人"魔神"来帮忙战斗9999回合
  10. #例如$game_sunmmon.add(29,3) 是召唤第29个敌人"魔王"来战斗3回合
  11. #
  12. #
  13. #module是开关控制true和false
  14. #召唤兽是否挡住敌人的全部攻击,true时所有攻击都由召唤兽来承受,包括全体伤害
  15. #回合限制是召唤兽行动几回合后消失,不包括召唤出来的那个回合
  16. #显示有边框的窗口,或者一个淡淡的底色
  17. #前缀名和后缀名是区分怪物和召唤兽名字用的
  18. #2013-03-23新增召唤兽最大数量限制和保留的方式
  19. module SUMMON
  20.   #召唤兽控制开关
  21.   EnableAttack          = true         #召唤兽是否挡住敌人的攻击
  22.   EnableTrun            = true         #召唤兽是否有存在回合限制
  23.   EnableBack            = true         #召唤兽窗口显示边框或者底色
  24.   ItemWidthMin          = 24*3         #召唤兽窗口的最小文字宽度
  25.   ItemWidthMax          = 24*9         #召唤兽窗口的最大文字宽度
  26.   FirstName             = "召唤兽"     #召唤兽的前缀名
  27.   BackName              = "的幻影"     #召唤兽的后缀名
  28.   MaxSummon             = 2            #最大的召唤兽数量
  29.   NewSummon             = true         #保留最新的召唤兽还是最老的,TRUE是保留最新
  30. end
  31.  
  32. class Scene_Battle
  33.   alias start_sunmmon start
  34.   def start #战斗开始,创建召唤兽队伍的类的实例
  35.     $game_sunmmon=Game_Summoned.new #创建召唤兽队伍的类的实例
  36.     start_sunmmon
  37.   end
  38.   alias turn_end_sunmmon turn_end
  39.   def turn_end #回合结束
  40.     turn_end_sunmmon
  41.     $game_sunmmon.turnend #召唤兽存在回合-1
  42.     refresh_sunmmon_windows
  43.   end
  44.   def create_sunmmon_windows #创建召唤兽窗口
  45.     @sunmmon_window = Window_Summon.new(0,0)
  46.     refresh_sunmmon_windows
  47.   end
  48.   def refresh_sunmmon_windows #刷新召唤兽窗口
  49.     @sunmmon_window.show
  50.     @sunmmon_window.hide if @sunmmon_window.item_max==0
  51.     @sunmmon_window.width=@sunmmon_window.window_width
  52.     @sunmmon_window.height=@sunmmon_window.window_height
  53.     #@sunmmon_window.x=Graphics.width - @sunmmon_window.width
  54.     @sunmmon_window.y=Graphics.height - @sunmmon_window.height - @party_command_window.height
  55.     @sunmmon_window.refresh
  56.   end
  57.   alias create_all_windows_sunmmon create_all_windows
  58.   def create_all_windows
  59.     create_all_windows_sunmmon
  60.     create_sunmmon_windows
  61.   end
  62.   def refresh_status
  63.     @status_window.refresh
  64.     refresh_sunmmon_windows
  65.   end
  66. end
  67. #召唤兽的状态显示窗口
  68. class Window_Summon < Window_Base
  69.   def initialize(x, y)
  70.     super(x, y, window_width, window_height)
  71.     self.opacity = 0 if SUMMON::EnableBack
  72.     refresh
  73.   end
  74.   def window_width
  75.     [[SUMMON::ItemWidthMin,item_width].max,SUMMON::ItemWidthMax].min+24+standard_padding * 2
  76.   end
  77.   def window_height
  78.     fitting_height(item_max)
  79.   end
  80.   def contents_height
  81.     window_height - standard_padding * 2
  82.   end
  83.   def item
  84.     $game_sunmmon.members
  85.   end
  86.   def item_max
  87.     item.size
  88.   end
  89.   def item_width
  90.     max=1
  91.     item.each {|item| max=item.name.size if item.name.size>max }
  92.     return max*24
  93.   end
  94.   def draw_sunmmon
  95.     item_max.times {|i| draw_item(i) }
  96.   end
  97.   def draw_item(index)
  98.     rect = Rect.new
  99.     rect.width = contents_width
  100.     rect.height = line_height
  101.     rect.x = 0
  102.     rect.y = (item_max-index-1) * line_height
  103.     contents.fill_rect(rect,Color.new(0, 0, 0, 64)) if SUMMON::EnableBack
  104.     #显示召唤兽血条
  105.     draw_new_hpgauge(rect.x,rect.y+12,rect.width,item[index].hp_rate)
  106.     #显示回合数
  107.     draw_text(rect.x,rect.y,24+2,rect.height,item[index].liveturn-1 ) if SUMMON::EnableTrun&&item[index].liveturn<101
  108.     #显示召唤兽名字
  109.     draw_text(rect.x+24-2,rect.y,rect.width-24+2,rect.height,item[index].name)
  110.   end
  111.   def draw_new_hpgauge(x,y,width, rate,gaugeheight=6)
  112.     contents.fill_rect(x, y+6, width, gaugeheight, gauge_back_color)
  113.     fill_w = (width * rate).to_i
  114.     contents.gradient_fill_rect(x+width/2,y+6,fill_w-width/2,gaugeheight,text_color(17),text_color(3)) if fill_w>width/2
  115.     contents.gradient_fill_rect(x,y+6,width/2,gaugeheight,text_color(18),text_color(17)) if fill_w>width/2
  116.     contents.gradient_fill_rect(x,y+6,fill_w,gaugeheight,text_color(18),text_color(17))  if fill_w<=width/2   
  117.   end
  118.   def refresh
  119.     contents.clear
  120.     create_contents
  121.     draw_sunmmon
  122.   end
  123. end
  124. #实例   $game_sunmmon = Game_Summoned.new
  125. #召唤兽队伍的类
  126. class Game_Summoned < Game_Unit
  127.   def initialize
  128.     super
  129.     members
  130.     @index=0
  131.   end
  132.   def members
  133.     @summon=[] unless @summon
  134.     @summon
  135.   end
  136.   def alive_members
  137.     members.select {|member| member.alive? }
  138.   end
  139.   def add(summon_id,liveturn=9999)    #增加召唤兽
  140.     summon = Game_Summon.new(@index,summon_id)
  141.     summon.liveturn=liveturn+1
  142.     @summon.push(summon)
  143.     @index+=1
  144.     summonlimit
  145.   end
  146.   def turnend #召唤兽回合处理
  147.     members.each do |summon|
  148.       summon.turnend
  149.     end
  150.     @summon.delete_if{|summon| summon.liveturn<=0} #清除不存在的召唤兽
  151.     summonlimit
  152.   end
  153.  
  154.   def summonlimit
  155.     summonmax(SUMMON::MaxSummon,SUMMON::NewSummon)
  156.   end
  157.  
  158.   def summonmax(num,new=true)
  159.     if @summon.size>num
  160.       if new
  161.         (1..(@summon.size-num)).each{|i|@summon.shift}
  162.       else
  163.         (1..(@summon.size-num)).each{|i|@summon.pop}
  164.       end
  165.     end
  166.   end
  167.  
  168. end
  169.  
  170. #召唤兽的类
  171. class Game_Summon < Game_Enemy
  172.   attr_accessor :liveturn #存在的回合数
  173.   def friends_unit #对自己的角色辅助
  174.     $game_party
  175.   end
  176.   def opponents_unit #对敌人攻击
  177.     $game_troop
  178.   end
  179.   def name #名字前增加“召唤兽”
  180.     SUMMON::FirstName + @original_name + SUMMON::BackName
  181.   end
  182.   def turnend ##召唤兽是否有存在回合限制
  183.     @liveturn=[@liveturn-1,0].max if SUMMON::EnableTrun
  184.   end
  185. end
  186.  
  187. class Game_Enemy
  188.   def opponents_unit #召唤兽存在时是否先攻击召唤兽
  189.     if SUMMON::EnableAttack&&$game_sunmmon.alive_members!=[]
  190.       $game_sunmmon
  191.     else
  192.       $game_party
  193.     end
  194.   end
  195.  
  196. end

评分

参与人数 1星屑 +200 收起 理由
feizhaodan + 200 奖赏条例。话说头像最好换个。.

查看全部评分

Lv1.梦旅人

梦石
0
星屑
189
在线时间
366 小时
注册时间
2009-9-6
帖子
62
2
发表于 2013-3-20 03:23:01 | 只看该作者
本帖最后由 arnie510 于 2013-3-20 04:36 编辑

感谢大大! 这非常实用喔!!真棒!! {:2_275:}

问一下大大如果我想将召幻兽显示的位置改在右上方,并往下递增请问该怎么做?? 如下图
还有此脚本有"限制召换数量"这个功能吗?

回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
60
在线时间
12 小时
注册时间
2008-5-12
帖子
6
3
发表于 2013-3-20 20:38:03 | 只看该作者
话说,按照大大方法做出来的召唤兽似乎不能攻击,也不能行动啊,是不是要设定什么才行?
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
189
在线时间
366 小时
注册时间
2009-9-6
帖子
62
4
发表于 2013-3-21 14:32:01 | 只看该作者
jrgerm 发表于 2013-3-20 20:38
话说,按照大大方法做出来的召唤兽似乎不能攻击,也不能行动啊,是不是要设定什么才行? ...

要修改BattleManager腳本的兩個地方,召喚獸就會動了!
   
#修改BattleManager---------------------------------------------------------------------------
      #召唤兽产生行动
      def self.input_start
        if @phase != :input
          @phase = :input
          $game_party.make_actions
          $game_troop.make_actions
          #修改
          $game_sunmmon.make_actions
          #修改结束
          clear_actor
        end
        return !@surprise && $game_party.inputable?
      end
      #召唤兽参与回合行动
      def self.make_action_orders
        @action_battlers = []
        @action_battlers += $game_party.members unless @surprise
        @action_battlers += $game_troop.members unless @preemptive
        @action_battlers.each {|battler| battler.make_speed }
        @action_battlers.sort! {|a,b| b.speed - a.speed }
        #修改
        @action_battlers += $game_sunmmon.alive_members
        #修改结束
      end
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
77 小时
注册时间
2006-6-12
帖子
95
5
 楼主| 发表于 2013-3-21 22:30:50 | 只看该作者
arnie510 发表于 2013-3-20 03:23
感谢大大! 这非常实用喔!!真棒!!  

问一下大大如果我想将召幻兽显示的位置改在右上方,并往 ...

可以在之前的代码页下边再开一页,放入
RUBY 代码复制
  1. #右上角,顺次往下
  2. class Scene_Battle
  3.   def refresh_sunmmon_windows #刷新召唤兽窗口
  4.     @sunmmon_window.show
  5.     @sunmmon_window.hide if @sunmmon_window.item_max==0
  6.     @sunmmon_window.width=@sunmmon_window.window_width
  7.     @sunmmon_window.height=@sunmmon_window.window_height
  8.     @sunmmon_window.x=Graphics.width - @sunmmon_window.width
  9.     #@sunmmon_window.y=Graphics.height - @sunmmon_window.height - @party_command_window.height
  10.     @sunmmon_window.refresh
  11.   end
  12.  
  13. end



或者直接修改对应的这个refresh_sunmmon_windows
只改了一句
回复 支持 反对

使用道具 举报

Lv2.观梦者

梦石
0
星屑
589
在线时间
332 小时
注册时间
2011-11-19
帖子
194
6
发表于 2013-3-22 19:50:27 | 只看该作者
请问怎样设置才能使召唤兽不超过两个?

点评

已更新主楼的代码,可以在开始设定最大数量和保留的方式了  发表于 2013-3-23 23:02
支持《彼岸之光》系列!加油!
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
189
在线时间
366 小时
注册时间
2009-9-6
帖子
62
7
发表于 2013-3-23 01:26:18 | 只看该作者
wangxinly 发表于 2013-3-21 22:30
可以在之前的代码页下边再开一页,放入
#右上角,顺次往下
class Scene_Battle

非常感謝你!! {:2_280:}
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
77 小时
注册时间
2006-6-12
帖子
95
8
 楼主| 发表于 2013-3-23 22:57:46 | 只看该作者
q854240045 发表于 2013-3-22 19:50
请问怎样设置才能使召唤兽不超过两个?

在下边新开一页放入或者自己修改对应的

RUBY 代码复制
  1. class Game_Summoned
  2.   def add(summon_id,liveturn=9999)    #增加召唤兽
  3.     summon = Game_Summon.new(@index,summon_id)
  4.     summon.liveturn=liveturn+1
  5.     @summon.push(summon)
  6.     @index+=1
  7.     summonlimit
  8.   end
  9.   def turnend #召唤兽回合处理
  10.     members.each do |summon|
  11.       summon.turnend
  12.     end
  13.     @summon.delete_if{|summon| summon.liveturn<=0} #清除不存在的召唤兽
  14.     summonlimit
  15.   end
  16.   def summonlimit
  17.     summonmax(2)
  18.   end
  19.  
  20.   def summonmax(num,new=true)
  21.     if @summon.size>num
  22.       if new
  23.         (1..(@summon.size-num)).each{|i|@summon.shift}
  24.       else
  25.         (1..(@summon.size-num)).each{|i|@summon.pop}
  26.       end
  27.     end
  28.   end
  29.  
  30. end
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
353
在线时间
5 小时
注册时间
2012-9-19
帖子
1
9
发表于 2013-4-21 23:46:34 | 只看该作者
脚本“Game_Interpreter"第1411行发生ArgumentError.wrong number of arguments(0 for 1)
这是什么意思呢
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
77 小时
注册时间
2006-6-12
帖子
95
10
 楼主| 发表于 2013-4-23 12:39:42 | 只看该作者
wyws1983 发表于 2013-4-21 23:46
脚本“Game_Interpreter"第1411行发生ArgumentError.wrong number of arguments(0 for 1)
这是什么意思呢 ...

这表示你在事件里用的脚本没有参数,而它需要1个参数
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-5-2 16:32

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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