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

Project1

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

[已经解决] 请问如何使用公共事件确定技能的使用者?

[复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
18 小时
注册时间
2015-5-13
帖子
32
跳转到指定楼层
1
发表于 2017-6-16 22:51:35 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
本帖最后由 guoxiaomi 于 2017-6-16 23:52 编辑

想要达到的效果:角色使用“嘲讽”技能,对象敌人下回合只会攻击该角色(游戏中不只一个角色可以使用“嘲讽”技能)

搜到了叶子的嘲讽脚本,是通过创建状态、技能使用者和对象敌人都获得同一状态实现的,使用者需要用公共事件来加上同一个状态。举个栗子:技能设置为:敌人附加20号状态,公共事件是角色附加20号状态。

可是不明白该怎么判断使用技能的角色。请问这个公共事件该怎么设置呢?

或者有其他方法可以达到嘲讽吗?(应该没有比这个脚本更简单的方法了吧)

(花了一个小时实在是搜索无果才发帖提问的……头疼)

脚本如下:
RUBY 代码复制
  1. # ============================================================================
  2. # 嘲讽脚本 v1.1 by 叶子
  3. # 特别鸣谢:
  4. # 柳柳 (是柳柳解决了最关键的技术问题,叶子我充其量只是个策划者和打字员)
  5. # SailCat (从SailCat的脚本中学到不少RGSS知识,只是叶子天生愚钝,还是菜鸟一个)
  6. # ......
  7. # ============================================================================
  8. #脚本用途:
  9. #实现嘲讽效果(废话)
  10. #通过一个极其简单的判断,让怪物固定攻击某一角色
  11. #区别于事件的强制行动,怪物该用技能时还是会用技能
  12. #由于判断极其简单,所以可以自己将这个判断替换Scene_Battle 4中相应内容
  13. #原理:
  14. #怪物中了特定的状态后(默认20到23号状态),
  15. #自动寻找与它有相同状态(20到23号)的角色,
  16. #找到后就以该角色为目标,找不到就照原样行动
  17. #脚本使用说明:
  18. #方法一.直接复制后插入到Main前面(方便快速,懒人最爱)
  19. #方法二.将脚本中标明的更改内容复制,替换Scene_Battle 4中相应内容(可能可以减少冲突,推荐)
  20. #1.创建4个状态,默认分别为20至23号(要改的话改相应内容...只有两处)
  21. #2.4个状态设置成两两互斥(例如20号状态在右边状态栏里的21,22,23号状态全部设置成“-”)
  22. #3.设置n个回合xx%解除(注意:只有被嘲讽者和嘲讽者同时存在这个状态时,嘲讽才生效)
  23. #4.带有嘲讽效果的特技,数据库里设定附加状态21到24号状态其中一个,带公共事件:给使用者加上同一个状态
  24. #(公共事件不太好判断谁是使用者,而Sailcat的“23种战斗特效的公共事件版”的脚本就可以判断,建议使用)
  25. # ============================================================================
  26. class Scene_Battle
  27. #--------------------------------------------------------------------------
  28. # ● 生成基本行动结果
  29. #--------------------------------------------------------------------------
  30. def make_basic_action_result
  31.    # 攻击的情况下
  32.    if @active_battler.current_action.basic == 0
  33.      # 设置攻击 ID
  34.      @animation1_id = @active_battler.animation1_id
  35.      @animation2_id = @active_battler.animation2_id
  36.      # 行动方的战斗者是敌人的情况下
  37.      if @active_battler.is_a?(Game_Enemy)
  38.        if @active_battler.restriction == 3
  39.          target = $game_troop.random_target_enemy
  40.        elsif @active_battler.restriction == 2
  41.           target = $game_party.random_target_actor
  42.        else
  43.          #=====以下更改内容=========
  44.          target_got = false
  45.          for a in $game_party.actors
  46.            if (@active_battler.state?(20) and a.state?(20)) \
  47.              or (@active_battler.state?(21) and a.state?(21)) \
  48.              or (@active_battler.state?(22) and a.state?(22)) \
  49.              or (@active_battler.state?(23) and a.state?(23))
  50.                target = a
  51.                target_got = true
  52.            end
  53.          end
  54.          unless target_got
  55.              index = @active_battler.current_action.target_index
  56.              target = $game_party.smooth_target_actor(index) #原有内容
  57.          end
  58.         #=====以上更改内容=========
  59.       end
  60.      end
  61.      # 行动方的战斗者是角色的情况下
  62.      if @active_battler.is_a?(Game_Actor)
  63.        if @active_battler.restriction == 3
  64.          target = $game_party.random_target_actor
  65.        elsif @active_battler.restriction == 2
  66.          target = $game_troop.random_target_enemy
  67.        else
  68.          index = @active_battler.current_action.target_index
  69.          target = $game_troop.smooth_target_enemy(index)
  70.        end
  71.      end
  72.      # 设置对像方的战斗者序列
  73.      @target_battlers = [target]
  74.      # 应用通常攻击效果
  75.      for target in @target_battlers
  76.        target.attack_effect(@active_battler)
  77.      end
  78.      return
  79.    end
  80.    # 防御的情况下
  81.    if @active_battler.current_action.basic == 1
  82.      # 帮助窗口显示"防御"
  83.      @help_window.set_text($data_system.words.guard, 1)
  84.      return
  85.    end
  86.    # 逃跑的情况下
  87.    if @active_battler.is_a?(Game_Enemy) and
  88.       @active_battler.current_action.basic == 2
  89.      #  帮助窗口显示"逃跑"
  90.      @help_window.set_text("逃跑", 1)
  91.      # 逃跑
  92.      @active_battler.escape
  93.      return
  94.    end
  95.    # 什么也不做的情况下
  96.    if @active_battler.current_action.basic == 3
  97.      # 清除强制行动对像的战斗者
  98.      $game_temp.forcing_battler = nil
  99.      # 移至步骤 1
  100.      @phase4_step = 1
  101.      return
  102.    end
  103. end
  104. #--------------------------------------------------------------------------
  105. # ● 设置物品或特技对像方的战斗者
  106. #     scope : 特技或者是物品的范围
  107. #--------------------------------------------------------------------------
  108. def set_target_battlers(scope)
  109.    # 行动方的战斗者是敌人的情况下
  110.    if @active_battler.is_a?(Game_Enemy)
  111.      # 效果范围分支
  112.      case scope
  113.      when 1  # 敌单体
  114.        index = @active_battler.current_action.target_index
  115.        #==以下更改内容===============
  116.          target_got = false
  117.          for a in $game_party.actors
  118.            if (@active_battler.state?(20) and a.state?(20)) \
  119.              or (@active_battler.state?(21) and a.state?(21)) \
  120.              or (@active_battler.state?(22) and a.state?(22)) \
  121.              or (@active_battler.state?(23) and a.state?(23))
  122.                @target_battlers.push(a)
  123.                target_got = true
  124.            end
  125.          end
  126.          unless target_got
  127.          @target_battlers.push($game_party.smooth_target_actor(index)) #原有内容
  128.          end
  129.       #==以上更改内容===============
  130.      when 2  # 敌全体
  131.        for actor in $game_party.actors
  132.          if actor.exist?
  133.            @target_battlers.push(actor)
  134.          end
  135.        end
  136.      when 3  # 我方单体
  137.        index = @active_battler.current_action.target_index
  138.        @target_battlers.push($game_troop.smooth_target_enemy(index))
  139.      when 4  # 我方全体
  140.        for enemy in $game_troop.enemies
  141.          if enemy.exist?
  142.            @target_battlers.push(enemy)
  143.          end
  144.        end
  145.      when 5  # 我方单体 (HP 0)  
  146.        index = @active_battler.current_action.target_index
  147.        enemy = $game_troop.enemies[index]
  148.        if enemy != nil and enemy.hp0?
  149.          @target_battlers.push(enemy)
  150.        end
  151.      when 6  # 我方全体 (HP 0)  
  152.        for enemy in $game_troop.enemies
  153.          if enemy != nil and enemy.hp0?
  154.            @target_battlers.push(enemy)
  155.          end
  156.        end
  157.      when 7  # 使用者
  158.        @target_battlers.push(@active_battler)
  159.      end
  160.    end
  161.    # 行动方的战斗者是角色的情况下
  162.    if @active_battler.is_a?(Game_Actor)
  163.      # 效果范围分支
  164.      case scope
  165.      when 1  # 敌单体
  166.        index = @active_battler.current_action.target_index
  167.        @target_battlers.push($game_troop.smooth_target_enemy(index))
  168.      when 2  # 敌全体
  169.        for enemy in $game_troop.enemies
  170.          if enemy.exist?
  171.            @target_battlers.push(enemy)
  172.          end
  173.        end
  174.      when 3  # 我方单体
  175.        index = @active_battler.current_action.target_index
  176.        @target_battlers.push($game_party.smooth_target_actor(index))
  177.      when 4  # 我方全体
  178.        for actor in $game_party.actors
  179.          if actor.exist?
  180.            @target_battlers.push(actor)
  181.          end
  182.        end
  183.      when 5  # 我方单体 (HP 0)  
  184.        index = @active_battler.current_action.target_index
  185.        actor = $game_party.actors[index]
  186.        if actor != nil and actor.hp0?
  187.          @target_battlers.push(actor)
  188.        end
  189.      when 6  # 我方全体 (HP 0)  
  190.        for actor in $game_party.actors
  191.          if actor != nil and actor.hp0?
  192.            @target_battlers.push(actor)
  193.          end
  194.        end
  195.      when 7  # 使用者
  196.        @target_battlers.push(@active_battler)
  197.      end
  198.    end
  199. end
  200. end

Lv5.捕梦者 (版主)

梦石
1
星屑
23984
在线时间
3339 小时
注册时间
2011-7-8
帖子
3926

开拓者

2
发表于 2017-6-16 23:55:12 | 只看该作者
获取当前行动中的角色,和目标数组:
脚本添加:
  1. class Scene_Battle  
  2.   attr_reader :active_battler
  3.   attr_reader :target_battlers
  4. end
复制代码

然后使用 $scene.active_batter 和 $scene.target_battlers 获得对应的 Game_Battler 对象

评分

参与人数 1星屑 +200 收起 理由
RyanBern + 200 6

查看全部评分

熟悉rgss和ruby,xp区版主~
正在填坑:《膜拜组传奇》讲述膜拜组和学霸们的故事。
已上steam:与TXBD合作的Reformers《变革者》
* 战斗调用公共事件 *
* RGSOS 网络脚本 *
回复 支持 1 反对 0

使用道具 举报

Lv4.逐梦者

梦石
0
星屑
12157
在线时间
4435 小时
注册时间
2014-4-11
帖子
5955

开拓者

3
发表于 2017-6-17 08:54:37 | 只看该作者
用脚本的话比较好实现。在角色建立一个变量。然后使用嘲讽后,被嘲讽者的这个变量赋值嘲讽者。被其他人嘲讽,这个变量就重新复制其他人。嘲讽消失,这个变量就赋值0
通过判断这个变量来判断是否被嘲讽,以及被谁嘲讽
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
18 小时
注册时间
2015-5-13
帖子
32
4
 楼主| 发表于 2017-6-17 09:42:49 | 只看该作者
guoxiaomi 发表于 2017-6-16 23:55
获取当前行动中的角色,和目标数组:
脚本添加:

请问具体应该怎么用呢……脚本盲……
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
18 小时
注册时间
2015-5-13
帖子
32
5
 楼主| 发表于 2017-6-17 09:47:00 | 只看该作者
yang1zhi 发表于 2017-6-17 08:54
用脚本的话比较好实现。在角色建立一个变量。然后使用嘲讽后,被嘲讽者的这个变量赋值嘲讽者。被其他人嘲讽 ...

{:2_263:}不明白该怎么做……我脚本盲……哭唧唧
回复 支持 反对

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
1438
在线时间
328 小时
注册时间
2016-4-4
帖子
168

开拓者

6
发表于 2017-6-19 00:04:35 | 只看该作者
775933591 发表于 2017-6-17 09:47
不明白该怎么做……我脚本盲……哭唧唧
获取当前行动中的角色,和目标数组:
脚本添加:
class Scene_Battle  
  attr_reader :active_battler
  attr_reader :target_battlers
end
复制代码

然后使用 $scene.active_batter 和 $scene.target_battlers 获得对应的 Game_Battler 对象

将此脚本放至main前  
然后 在公共事件中写判定时
条件分歧-页面4-脚本:$game_party.actors[0] == $scene.active_buttler 来获取使用者

点评

你不要瞎解释……  发表于 2017-6-19 08:20
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
28 小时
注册时间
2015-5-22
帖子
17
7
发表于 2017-6-19 06:33:51 | 只看该作者
回复 支持 反对

使用道具 举报

Lv5.捕梦者 (版主)

梦石
1
星屑
23984
在线时间
3339 小时
注册时间
2011-7-8
帖子
3926

开拓者

8
发表于 2017-6-19 08:22:51 | 只看该作者
本帖最后由 guoxiaomi 于 2017-6-21 00:40 编辑

在main前插入脚本,公共事件里,用$scene.active_battler.add_state(20)

忘了添加状态是不是 add_state了
熟悉rgss和ruby,xp区版主~
正在填坑:《膜拜组传奇》讲述膜拜组和学霸们的故事。
已上steam:与TXBD合作的Reformers《变革者》
* 战斗调用公共事件 *
* RGSOS 网络脚本 *
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
18 小时
注册时间
2015-5-13
帖子
32
9
 楼主| 发表于 2017-6-20 20:38:38 | 只看该作者
guoxiaomi 发表于 2017-6-19 08:22
在main前插入脚本,公共事件里,用$scene.active_batter.add_state(20)

忘了添加状态是不是 add_state了 ...

昨天有事没用电脑;试了一下,把脚本插入main前之后,技能设置成给敌人附加20号状态、同时使用公共事件,公共事件是脚本$scene.active_batter.add_state(20)
测试时,使用嘲讽技能后报错
“执行脚本时发生 NoMethodError
undefined method 'active_batter'for #<Scene_Battle:0x2987ca0>”

请问该怎么办呢……
我嘲讽脚本是直接插入main前的,是不是应该用第一种用法,就是“将脚本中标明的更改内容复制,替换Scene_Battle 4中相应内容”,这样的(但是不知道对应的地方是指哪里……)

点评

我的锅,是battler  发表于 2017-6-20 22:09
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
18 小时
注册时间
2015-5-13
帖子
32
10
 楼主| 发表于 2017-6-20 22:36:50 | 只看该作者
guoxiaomi 发表于 2017-6-19 08:22
在main前插入脚本,公共事件里,用$scene.active_batter.add_state(20)

忘了添加状态是不是 add_state了 ...

哈哈哈哈哈哈在脚本搜索batter半天,原来是在公共事件里打错了
问题已解决
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-9-22 04:20

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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