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

Project1

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

[已经解决] 如何实现“和敌人交换HP”或者交换力量,速度的效果?

[复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
14 小时
注册时间
2012-1-21
帖子
67
跳转到指定楼层
1
发表于 2012-2-9 18:17:49 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式
如何实现“和敌人交换HP”或者交换力量,交换速度的效果?

最好是脚本啦,公共事件好像也做不出来了。。

求解。。

Lv3.寻梦者

梦石
0
星屑
3657
在线时间
4466 小时
注册时间
2008-6-12
帖子
802
2
发表于 2012-2-9 19:25:15 | 只看该作者
本帖最后由 过眼云烟 于 2012-2-9 19:39 编辑

技能的公共事件中添加脚本
a=$scene.active_battler
for t in $scene.target_battlers
m = t.hp
t.hp =[a.hp,t.maxhp].min
a.hp =[m,a.maxhp].min
end
Scene_Battle 1的def main前添加
  attr_reader   :active_battler
  attr_reader   :skill
  attr_accessor :target_battlers
剩下的自由发挥了

点评

这个。。鄙人脚本一知半解。。实在不懂如何应用?  发表于 2012-2-9 22:09
好吧,我错了··········  发表于 2012-2-9 19:39
2个东西交换数值的话你不得用第三者吗????  发表于 2012-2-9 19:38
那个m = t.hp是干什么用的= =  发表于 2012-2-9 19:29
本人三无老人,请大神轻拍
回复

使用道具 举报

Lv1.梦旅人

虱子

梦石
0
星屑
121
在线时间
1782 小时
注册时间
2010-6-19
帖子
3597
3
发表于 2012-2-9 20:49:21 | 只看该作者
战斗结束后不恢复么-.-

点评

当然要回复啊。。。并且交换效果维持到战斗结束。。  发表于 2012-2-9 22:00

http://rpg.blue/thread-175056-1-2.html
PVZ型塔防物一个
http://rpg.blue/thread-155199-1-2.html
RMXP技术讨论区手动认可帖,得到答案请认可
回复

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
3657
在线时间
4466 小时
注册时间
2008-6-12
帖子
802
4
发表于 2012-2-9 22:39:30 | 只看该作者
就是个添加脚本这个你还不会吗????
如果寻找一个地方添加脚本都懒得弄的话,真是有点无语了
  1. #==============================================================================
  2. # ■ Scene_Battle (分割定义 1)
  3. #------------------------------------------------------------------------------
  4. #  处理战斗画面的类。
  5. #==============================================================================

  6. class Scene_Battle
  7.   #--------------------------------------------------------------------------
  8.   # ● 主处理
  9.   #--------------------------------------------------------------------------
  10.   attr_reader   :active_battler   #云烟添加
  11.   attr_reader   :skill            #云烟添加
  12.   attr_accessor :target_battlers  #云烟添加
  13.   def main
  14.     # 初始化战斗用的各种暂时数据
  15.     $game_temp.in_battle = true
  16.     $game_temp.battle_turn = 0
  17.     $game_temp.battle_event_flags.clear
  18.     $game_temp.battle_abort = false
  19.     $game_temp.battle_main_phase = false
  20.     $game_temp.battleback_name = $game_map.battleback_name
  21.     $game_temp.forcing_battler = nil
  22.     # 初始化战斗用事件解释器
  23.     $game_system.battle_interpreter.setup(nil, 0)
  24.     # 准备队伍
  25.     @troop_id = $game_temp.battle_troop_id
  26.     $game_troop.setup(@troop_id)
  27.     # 生成角色命令窗口
  28.     s1 = $data_system.words.attack
  29.     s2 = $data_system.words.skill
  30.     s3 = $data_system.words.guard
  31.     s4 = $data_system.words.item
  32.     @actor_command_window = Window_Command.new(160, [s1, s2, s3, s4])
  33.     @actor_command_window.y = 160
  34.     @actor_command_window.back_opacity = 160
  35.     @actor_command_window.active = false
  36.     @actor_command_window.visible = false
  37.     # 生成其它窗口
  38.     @party_command_window = Window_PartyCommand.new
  39.     @help_window = Window_Help.new
  40.     @help_window.back_opacity = 160
  41.     @help_window.visible = false
  42.     @status_window = Window_BattleStatus.new
  43.     @message_window = Window_Message.new
  44.     # 生成活动块
  45.     @spriteset = Spriteset_Battle.new
  46.     # 初始化等待计数
  47.     @wait_count = 0
  48.     # 执行过渡
  49.     if $data_system.battle_transition == ""
  50.       Graphics.transition(20)
  51.     else
  52.       Graphics.transition(40, "Graphics/Transitions/" +
  53.         $data_system.battle_transition)
  54.     end
  55.     # 开始自由战斗回合
  56.     start_phase1
  57.     # 主循环
  58.     loop do
  59.       # 刷新游戏画面
  60.       Graphics.update
  61.       # 刷新输入信息
  62.       Input.update
  63.       # 刷新画面
  64.       update
  65.       # 如果画面切换的话就中断循环
  66.       if $scene != self
  67.         break
  68.       end
  69.     end
  70.     # 刷新地图
  71.     $game_map.refresh
  72.     # 准备过渡
  73.     Graphics.freeze
  74.     # 释放窗口
  75.     @actor_command_window.dispose
  76.     @party_command_window.dispose
  77.     @help_window.dispose
  78.     @status_window.dispose
  79.     @message_window.dispose
  80.     if @skill_window != nil
  81.       @skill_window.dispose
  82.     end
  83.     if @item_window != nil
  84.       @item_window.dispose
  85.     end
  86.     if @result_window != nil
  87.       @result_window.dispose
  88.     end
  89.     # 释放活动块
  90.     @spriteset.dispose
  91.     # 标题画面切换中的情况
  92.     if $scene.is_a?(Scene_Title)
  93.       # 淡入淡出画面
  94.       Graphics.transition
  95.       Graphics.freeze
  96.     end
  97.     # 战斗测试或者游戏结束以外的画面切换中的情况
  98.     if $BTEST and not $scene.is_a?(Scene_Gameover)
  99.       $scene = nil
  100.     end
  101.   end
  102.   #--------------------------------------------------------------------------
  103.   # ● 胜负判定
  104.   #--------------------------------------------------------------------------
  105.   def judge
  106.     # 全灭判定是真、并且同伴人数为 0 的情况下
  107.     if $game_party.all_dead? or $game_party.actors.size == 0
  108.       # 允许失败的情况下
  109.       if $game_temp.battle_can_lose
  110.         # 还原为战斗开始前的 BGM
  111.         $game_system.bgm_play($game_temp.map_bgm)
  112.         # 战斗结束
  113.         battle_end(2)
  114.         # 返回 true
  115.         return true
  116.       end
  117.       # 设置游戏结束标志
  118.       $game_temp.gameover = true
  119.       # 返回 true
  120.       return true
  121.     end
  122.     # 如果存在任意 1 个敌人就返回 false
  123.     for enemy in $game_troop.enemies
  124.       if enemy.exist?
  125.         return false
  126.       end
  127.     end
  128.     # 开始结束战斗回合 (胜利)
  129.     start_phase5
  130.     # 返回 true
  131.     return true
  132.   end
  133.   #--------------------------------------------------------------------------
  134.   # ● 战斗结束
  135.   #     result : 結果 (0:胜利 1:失败 2:逃跑)
  136.   #--------------------------------------------------------------------------
  137.   def battle_end(result)
  138.     # 清除战斗中标志
  139.     $game_temp.in_battle = false
  140.     # 清除全体同伴的行动
  141.     $game_party.clear_actions
  142.     # 解除战斗用状态
  143.     for actor in $game_party.actors
  144.       actor.remove_states_battle
  145.     end
  146.     # 清除敌人
  147.     $game_troop.enemies.clear
  148.     # 调用战斗返回
  149.     if $game_temp.battle_proc != nil
  150.       $game_temp.battle_proc.call(result)
  151.       $game_temp.battle_proc = nil
  152.     end
  153.     # 切换到地图画面
  154.     $scene = Scene_Map.new
  155.   end
  156.   #--------------------------------------------------------------------------
  157.   # ● 设置战斗事件
  158.   #--------------------------------------------------------------------------
  159.   def setup_battle_event
  160.     # 正在执行战斗事件的情况下
  161.     if $game_system.battle_interpreter.running?
  162.       return
  163.     end
  164.     # 搜索全部页的战斗事件
  165.     for index in 0...$data_troops[@troop_id].pages.size
  166.       # 获取事件页
  167.       page = $data_troops[@troop_id].pages[index]
  168.       # 事件条件可以参考 c
  169.       c = page.condition
  170.       # 没有指定任何条件的情况下转到下一页
  171.       unless c.turn_valid or c.enemy_valid or
  172.              c.actor_valid or c.switch_valid
  173.         next
  174.       end
  175.       # 执行完毕的情况下转到下一页
  176.       if $game_temp.battle_event_flags[index]
  177.         next
  178.       end
  179.       # 确认回合条件
  180.       if c.turn_valid
  181.         n = $game_temp.battle_turn
  182.         a = c.turn_a
  183.         b = c.turn_b
  184.         if (b == 0 and n != a) or
  185.            (b > 0 and (n < 1 or n < a or n % b != a % b))
  186.           next
  187.         end
  188.       end
  189.       # 确认敌人条件
  190.       if c.enemy_valid
  191.         enemy = $game_troop.enemies[c.enemy_index]
  192.         if enemy == nil or enemy.hp * 100.0 / enemy.maxhp > c.enemy_hp
  193.           next
  194.         end
  195.       end
  196.       # 确认角色条件
  197.       if c.actor_valid
  198.         actor = $game_actors[c.actor_id]
  199.         if actor == nil or actor.hp * 100.0 / actor.maxhp > c.actor_hp
  200.           next
  201.         end
  202.       end
  203.       # 确认开关条件
  204.       if c.switch_valid
  205.         if $game_switches[c.switch_id] == false
  206.           next
  207.         end
  208.       end
  209.       # 设置事件
  210.       $game_system.battle_interpreter.setup(page.list, 0)
  211.       # 本页的范围是 [战斗] 或 [回合] 的情况下
  212.       if page.span <= 1
  213.         # 设置执行结束标志
  214.         $game_temp.battle_event_flags[index] = true
  215.       end
  216.       return
  217.     end
  218.   end
  219.   #--------------------------------------------------------------------------
  220.   # ● 刷新画面
  221.   #--------------------------------------------------------------------------
  222.   def update
  223.    
  224.     # 执行战斗事件中的情况下
  225.     if $game_system.battle_interpreter.running?
  226.       # 刷新解释器
  227.       $game_system.battle_interpreter.update
  228.       # 强制行动的战斗者不存在的情况下
  229.       if $game_temp.forcing_battler == nil
  230.         # 执行战斗事件结束的情况下
  231.         unless $game_system.battle_interpreter.running?
  232.           # 继续战斗的情况下、再执行战斗事件的设置
  233.           unless judge
  234.             setup_battle_event
  235.           end
  236.         end
  237.         # 如果不是结束战斗回合的情况下
  238.         if @phase != 5
  239.           # 刷新状态窗口
  240.           @status_window.refresh
  241.         end
  242.       end
  243.     end
  244.     # 系统 (计时器)、刷新画面
  245.     $game_system.update
  246.     $game_screen.update
  247.     # 计时器为 0 的情况下
  248.     if $game_system.timer_working and $game_system.timer == 0
  249.       # 中断战斗
  250.       $game_temp.battle_abort = true
  251.     end
  252.     # 刷新窗口
  253.     @help_window.update
  254.     @party_command_window.update
  255.     @actor_command_window.update
  256.     @status_window.update
  257.     @message_window.update
  258.     # 刷新活动块
  259.     @spriteset.update
  260.     # 处理过渡中的情况下
  261.     if $game_temp.transition_processing
  262.       # 清除处理过渡中标志
  263.       $game_temp.transition_processing = false
  264.       # 执行过渡
  265.       if $game_temp.transition_name == ""
  266.         Graphics.transition(20)
  267.       else
  268.         Graphics.transition(40, "Graphics/Transitions/" +
  269.           $game_temp.transition_name)
  270.       end
  271.     end
  272.     # 显示信息窗口中的情况下
  273.     if $game_temp.message_window_showing
  274.       return
  275.     end
  276.     # 显示效果中的情况下
  277.     if @spriteset.effect?
  278.       return
  279.     end
  280.     # 游戏结束的情况下
  281.     if $game_temp.gameover
  282.       # 切换到游戏结束画面
  283.       $scene = Scene_Gameover.new
  284.       return
  285.     end
  286.     # 返回标题画面的情况下
  287.     if $game_temp.to_title
  288.       # 切换到标题画面
  289.       $scene = Scene_Title.new
  290.       return
  291.     end
  292.     # 中断战斗的情况下
  293.     if $game_temp.battle_abort
  294.       # 还原为战斗前的 BGM
  295.       $game_system.bgm_play($game_temp.map_bgm)
  296.       # 战斗结束
  297.       battle_end(1)
  298.       return
  299.     end
  300.     # 等待中的情况下
  301.     if @wait_count > 0
  302.       # 减少等待计数
  303.       @wait_count -= 1
  304.       return
  305.     end
  306.     # 强制行动的角色存在、
  307.     # 并且战斗事件正在执行的情况下
  308.     if $game_temp.forcing_battler == nil and
  309.        $game_system.battle_interpreter.running?
  310.       return
  311.     end
  312.     # 回合分支
  313.     case @phase
  314.     when 1  # 自由战斗回合
  315.       update_phase1
  316.     when 2  # 同伴命令回合
  317.       update_phase2
  318.     when 3  # 角色命令回合
  319.       update_phase3
  320.     when 4  # 主回合
  321.       update_phase4
  322.     when 5  # 战斗结束回合
  323.       update_phase5
  324.     end
  325.   end
  326. end
复制代码

1.jpg (26.38 KB, 下载次数: 1)

1.jpg
本人三无老人,请大神轻拍
回复

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
14 小时
注册时间
2012-1-21
帖子
67
5
 楼主| 发表于 2012-2-10 09:28:02 | 只看该作者
过眼云烟 发表于 2012-2-9 22:39
就是个添加脚本这个你还不会吗????
如果寻找一个地方添加脚本都懒得弄的话,真是有点无语了 ...

如果我要制作对BOSS无效。。我该怎么做?
回复

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
3657
在线时间
4466 小时
注册时间
2008-6-12
帖子
802
6
发表于 2012-2-10 09:36:30 | 只看该作者
你这属于第二个问题了,强烈要求双份报酬
在for循环内加个判定
if t.state_ranks[X] == 3#这里的X是指你指定的属性编号,比如死亡属性,如果对它无抵抗力的话(用后边的数值判定)
(要执行的东西,之前给你写的)
end

我觉得你一点不懂脚本的话最好先别接触这稍微复杂的东西,
我只是建议,没有别的意思

本人三无老人,请大神轻拍
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-4-27 19:09

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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