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

Project1

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

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

[复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
77 小时
注册时间
2006-6-12
帖子
95
跳转到指定楼层
发表于 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
星屑
50
在线时间
203 小时
注册时间
2014-8-18
帖子
8
30
发表于 2014-9-6 19:11:01 | 只看该作者
要是能和Sideview整合起来就好了!
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
75 小时
注册时间
2006-11-22
帖子
58
29
发表于 2014-8-5 20:23:45 | 只看该作者


83 def item
84   $game_sunmmon.members
這二句有什魔用?因為我用的時候佢出錯了...
回复 支持 反对

使用道具 举报

头像被屏蔽

Lv1.梦旅人 (禁止发言)

梦石
0
星屑
50
在线时间
48 小时
注册时间
2014-5-7
帖子
49
28
发表于 2014-5-30 17:59:44 | 只看该作者
提示: 作者被禁止或删除 内容自动屏蔽
回复 支持 反对

使用道具 举报

头像被屏蔽

Lv1.梦旅人 (禁止发言)

梦石
0
星屑
50
在线时间
48 小时
注册时间
2014-5-7
帖子
49
27
发表于 2014-5-23 17:33:46 | 只看该作者
提示: 作者被禁止或删除 内容自动屏蔽
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
13 小时
注册时间
2014-3-7
帖子
15
26
发表于 2014-3-13 21:22:38 | 只看该作者
楼主召唤兽的脚本“Game_Interpreter”第1141行发生NameError。undefined local variable or method summon_id' for #<Game_Interpreter:0×2d17是咋回事?
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
27 小时
注册时间
2014-3-5
帖子
26
25
发表于 2014-3-9 23:21:43 | 只看该作者
请问有没有完整版的工程文件,我是新手....脚本好多我不知道要放哪个位置
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
140
在线时间
0 小时
注册时间
2013-12-10
帖子
2
24
发表于 2013-12-10 12:47:10 | 只看该作者


   关注下~~~
回复 支持 反对

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
4801
在线时间
53 小时
注册时间
2011-11-18
帖子
1
23
发表于 2013-11-30 17:06:38 | 只看该作者
大大,请问有办法在召唤兽名字旁边显示头像吗?
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
185
在线时间
1 小时
注册时间
2013-10-16
帖子
1
22
发表于 2013-10-16 21:41:01 | 只看该作者
大大有没有可以在EAS战斗系统上用的召唤兽系统
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
189
在线时间
366 小时
注册时间
2009-9-6
帖子
62
21
发表于 2013-9-15 19:08:44 | 只看该作者
623279257 发表于 2013-9-15 12:20
没看明白,是增加那红色的代码还是怎么样?

是的!{:2_275:}
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-9-28 09:41

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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