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

Project1

 找回密码
 注册会员
搜索
查看: 3547|回复: 9

[已经解决] 如何在角色攻击时调用公共事件

[复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
26 小时
注册时间
2016-10-15
帖子
51
发表于 2017-2-22 22:32:47 | 显示全部楼层 |阅读模式

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

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

x
本帖最后由 RyanBern 于 2017-3-1 21:44 编辑

怎么设置      当第n号角色攻击时调用第n号事件(简单点)

Lv5.捕梦者 (版主)

梦石
1
星屑
23963
在线时间
3338 小时
注册时间
2011-7-8
帖子
3925

开拓者

发表于 2017-2-23 09:07:43 | 显示全部楼层
本帖最后由 guoxiaomi 于 2017-2-26 18:14 编辑

众所周知RMXP的数据库里物品和特技是有关联公共事件的。这个公共事件将在技能结算完毕之后触发,公共事件执行完了就进入下一个角色的回合。但是攻击和防御是没有关联公共事件的,其实这个很容易做到。
请看Scene_Battle 4的178-240行的 make_basic_action_result 方法,在每个return(这里是第35行和第43行)前添加
@common_event_id = XXX

当然也可以根据情况进行判断具体执行哪个公共事件,这里只是给出添加关联的位置。下面是修改过的 make_basic_action_result 方法,攻击和防御在执行结束后会触发1号和2号公共事件。
  1.   def make_basic_action_result
  2.     # 攻击的情况下
  3.     if @active_battler.current_action.basic == 0
  4.       # 设置攻击 ID
  5.       @animation1_id = @active_battler.animation1_id
  6.       @animation2_id = @active_battler.animation2_id
  7.       # 行动方的战斗者是敌人的情况下
  8.       if @active_battler.is_a?(Game_Enemy)
  9.         if @active_battler.restriction == 3
  10.           target = $game_troop.random_target_enemy
  11.         elsif @active_battler.restriction == 2
  12.           target = $game_party.random_target_actor
  13.         else
  14.           index = @active_battler.current_action.target_index
  15.           target = $game_party.smooth_target_actor(index)
  16.         end
  17.       end
  18.       # 行动方的战斗者是角色的情况下
  19.       if @active_battler.is_a?(Game_Actor)
  20.         if @active_battler.restriction == 3
  21.           target = $game_party.random_target_actor
  22.         elsif @active_battler.restriction == 2
  23.           target = $game_troop.random_target_enemy
  24.         else
  25.           index = @active_battler.current_action.target_index
  26.           target = $game_troop.smooth_target_enemy(index)
  27.         end
  28.       end
  29.       # 设置对像方的战斗者序列
  30.       @target_battlers = [target]
  31.       # 应用通常攻击效果
  32.       for target in @target_battlers
  33.         target.attack_effect(@active_battler)
  34.       end
  35.       # 设置攻击公共事件 id
  36.       @common_event_id = 1
  37.       return
  38.     end
  39.     # 防御的情况下
  40.     if @active_battler.current_action.basic == 1
  41.       # 帮助窗口显示"防御"
  42.       @help_window.set_text($data_system.words.guard, 1)
  43.       # 设置防御公共事件 id
  44.       @common_event_id = 2
  45.       return
  46.     end
  47.     # 逃跑的情况下
  48.     if @active_battler.is_a?(Game_Enemy) and
  49.        @active_battler.current_action.basic == 2
  50.       #  帮助窗口显示"逃跑"
  51.       @help_window.set_text("逃跑", 1)
  52.       # 逃跑
  53.       @active_battler.escape
  54.       return
  55.     end
  56.     # 什么也不做的情况下
  57.     if @active_battler.current_action.basic == 3
  58.       # 清除强制行动对像的战斗者
  59.       $game_temp.forcing_battler = nil
  60.       # 移至步骤 1
  61.       @phase4_step = 1
  62.       return
  63.     end
  64.   end
  65. end
复制代码


n号角色攻击时执行n号公共事件,就注释掉44行,然后修改36行为:
  1. if @active_battler.is_a?(Game_Actor)
  2.   @common_event_id = @active_battler.id
  3. end
复制代码

点评

我华兹沃斯了,是 common_event_id ……我又写错了……  发表于 2017-2-26 18:14
额,还是不行呀  发表于 2017-2-26 15:19
我已经在帖子里改了,你再复制一次……  发表于 2017-2-25 22:20
额,要怎么改,我不会  发表于 2017-2-25 21:31
哦我知道了,我把 comment_event_id 写错了一个字母  发表于 2017-2-25 16:29

评分

参与人数 1星屑 +30 收起 理由
钓鱼的岛 + 30 认可答案

查看全部评分

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

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-3-29 01:30

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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