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

Project1

 找回密码
 注册会员
搜索
查看: 1176|回复: 2

[已经过期] 如何用脚本写地图上的CP变量开关1-7

[复制链接]

Lv4.逐梦者

梦石
0
星屑
6116
在线时间
1089 小时
注册时间
2015-8-15
帖子
652
发表于 2022-11-30 10:23:17 | 显示全部楼层 |阅读模式

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

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

x
本帖最后由 金芒芒 于 2022-11-30 14:35 编辑

ARPG 进入战斗地图cp值=0      快捷键1-7已经设好,快捷键是安放技能的,变量1-7号=快捷键1-7。
‘’如果‘’1号变量值等于角色2号.       角色2号=9号变量.9号变量的常量等于6000MS.
地图上价格CP条,那么1号快捷键满CP就=6000MS,等快捷键1号满CP的时候强行2号角色使用技能。



RUBY 代码复制
  1. class Game_Character
  2.   #--------------------------------------------------------------------------
  3.   # ● 指定イベントに近づく ●接近指定活动
  4.   #--------------------------------------------------------------------------
  5.   def move_toward_event(id)
  6.     # 指定イベントの座標との差を求める #求出与指定事件坐标的差
  7.     sx = @x - $game_map.events[id].x
  8.     sy = @y - $game_map.events[id].y
  9.     # 坐标相等时
  10.     if sx == 0 and sy == 0
  11.       return
  12.     end
  13.     # 差の絶対値を求める #求差的绝对值
  14.     abs_sx = sx.abs
  15.     abs_sy = sy.abs
  16.     # 横の距離と縦の距離が等しい場合#横向距离和纵向距离相等时
  17.     if abs_sx == abs_sy
  18.       # ランダムでどちらかを 1 増やす #随机增加1
  19.       rand(2) == 0 ? abs_sx += 1 : abs_sy += 1
  20.     end
  21.     # 横の距離のほうが長い場合 横向距离较长时
  22.     if abs_sx > abs_sy
  23.       # 左右方向を優先し、指定イベントのいるほうへ移動
  24.       #优先左右方向,向有指定事件的方向移动
  25.       sx > 0 ? move_left : move_right
  26.       if not moving? and sy != 0
  27.         sy > 0 ? move_up : move_down
  28.       end
  29.     # 縦の距離のほうが長い場合 纵向距离较长时
  30.     else
  31.       # 优先上下方向,向有指定事件的方向移动
  32.       sy > 0 ? move_up : move_down
  33.       if not moving? and sx != 0
  34.         sx > 0 ? move_left : move_right
  35.       end
  36.     end
  37.   end
  38.   #--------------------------------------------------------------------------
  39.   # ● 指定イベントから遠ざかる #距离指定事件
  40.   #--------------------------------------------------------------------------
  41.   def move_away_from_event(id)
  42.     # 指定イベントの座標との差を求める
  43.     #求出与指定事件坐标的差
  44.     sx = @x - $game_map.events[id].x
  45.     sy = @y - $game_map.events[id].y
  46.     # 座標が等しい場合#坐标相等时
  47.     if sx == 0 and sy == 0
  48.       return
  49.     end
  50.     # 差の絶対値を求める求差的绝对值
  51.     abs_sx = sx.abs
  52.     abs_sy = sy.abs
  53.     # 横の距離と縦の距離が等しい場合
  54.     #横向距离和纵向距离相等时
  55.     if abs_sx == abs_sy
  56.       # ランダムでどちらかを 1 増やす
  57.       #随机增加1
  58.       rand(2) == 0 ? abs_sx += 1 : abs_sy += 1
  59.     end
  60.     # 横の距離のほうが長い場合#横向距离较长时
  61.     if abs_sx > abs_sy
  62.       # 左右方向を優先し、指定イベントのいないほうへ移動
  63.       #优先左右方向,向没有指定事件的方向移动
  64.       sx > 0 ? move_right : move_left
  65.       if not moving? and sy != 0
  66.         sy > 0 ? move_down : move_up
  67.       end
  68.     # 縦の距離のほうが長い場合
  69.     #  纵向距离较长时
  70.     else
  71.       # 上下方向を優先し、指定イベントのいないほうへ移動
  72.       #优先上下方向,向没有指定事件的方向移动
  73.       sy > 0 ? move_down : move_up
  74.       if not moving? and sx != 0
  75.         sx > 0 ? move_right : move_left
  76.       end
  77.     end
  78.   end
  79.   #--------------------------------------------------------------------------
  80.   # ● 指定座標に近づく#接近指定坐标
  81.   #--------------------------------------------------------------------------
  82.   def move_toward_position(x, y)
  83.     # 座標の差を求める #求坐标差
  84.     sx = @x - x
  85.     sy = @y - y
  86.     # 座標が等しい場合 坐标相等时
  87.     if sx == 0 and sy == 0
  88.       return
  89.     end
  90.     # 求差的绝对值
  91.     abs_sx = sx.abs
  92.     abs_sy = sy.abs
  93.     # 横の距離と縦の距離が等しい場合
  94.     # 横向距离和纵向距离相等时
  95.     if abs_sx == abs_sy
  96.       # ランダムでどちらかを 1 増やす
  97.       #随机增加一个
  98.       rand(2) == 0 ? abs_sx += 1 : abs_sy += 1
  99.     end
  100.     # 横の距離のほうが長い場合
  101.     # 横向距离较长时
  102.     if abs_sx > abs_sy
  103.       sx > 0 ? move_left : move_right
  104.       if not moving? and sy != 0
  105.         sy > 0 ? move_up : move_down
  106.       end
  107.     # 縦の距離のほうが長い場合
  108.     # 纵向距离较长时
  109.     else
  110.       sy > 0 ? move_up : move_down
  111.       if not moving? and sx != 0
  112.         sx > 0 ? move_left : move_right
  113.       end
  114.     end
  115.   end
  116.   #--------------------------------------------------------------------------
  117.   # ● 指定座標から遠ざかる ●远离指定坐标
  118.   #--------------------------------------------------------------------------
  119.   def move_away_from_position(x, y)
  120.     # 座標の差を求める 求坐标差
  121.     sx = @x - x
  122.     sy = @y - y
  123.     # 座標が等しい場合 坐标相等时
  124.     if sx == 0 and sy == 0
  125.       return
  126.     end
  127.     # 差の絶対値を求める 求差的绝对值
  128.     abs_sx = sx.abs
  129.     abs_sy = sy.abs
  130.     # 横の距離と縦の距離が等しい場合
  131.     # 横向距离和纵向距离相等时
  132.     if abs_sx == abs_sy
  133.       # ランダムでどちらかを 1 増やす
  134.       # 随机增加一个
  135.       rand(2) == 0 ? abs_sx += 1 : abs_sy += 1
  136.     end
  137.     # 横の距離のほうが長い場合
  138.     # 横向距离较长时
  139.     if abs_sx > abs_sy
  140.       sx > 0 ? move_right : move_left
  141.       if not moving? and sy != 0
  142.         sy > 0 ? move_down : move_up
  143.       end
  144.     # 縦の距離のほうが長い場合
  145.     #纵向距离较长时
  146.     else
  147.       sy > 0 ? move_down : move_up
  148.       if not moving? and sx != 0
  149.         sx > 0 ? move_right : move_left
  150.       end
  151.     end
  152.   end
  153.   #--------------------------------------------------------------------------
  154.   # ● 指定イベントの方を向く ●面向指定活动
  155.   #--------------------------------------------------------------------------
  156.   def turn_toward_event(id)
  157.     # 指定イベントの座標との差を求める
  158.     #求出与指定事件坐标的差
  159.     sx = @x - $game_map.events[id].x
  160.     sy = @y - $game_map.events[id].y
  161.     # 座標が等しい場合 坐标相等时
  162.     if sx == 0 and sy == 0
  163.       return
  164.     end
  165.     # 横の距離のほうが長い場合
  166.     #横向距离较长时
  167.     if sx.abs > sy.abs
  168.       # 左右方向で指定イベントのいるほうを向く
  169.       # 在左右方向朝向有指定活动的方向
  170.       sx > 0 ? turn_left : turn_right
  171.     # 縦の距離のほうが長い場合 #纵向距离较长时
  172.     else
  173.       # 上下方向で指定イベントのいるほうを向く
  174.       # 在上下方向朝向有指定活动的方向
  175.       sy > 0 ? turn_up : turn_down
  176.     end
  177.   end
  178.   #--------------------------------------------------------------------------
  179.   # ● 指定イベントの逆を向く
  180.   #--------------------------------------------------------------------------
  181.   def turn_away_from_event(id)
  182.     # 指定イベントの座標との差を求める
  183.     sx = @x - $game_map.events[id].x
  184.     sy = @y - $game_map.events[id].y
  185.     # 座標が等しい場合
  186.     if sx == 0 and sy == 0
  187.       return
  188.     end
  189.     # 横の距離のほうが長い場合
  190.     if sx.abs > sy.abs
  191.       # 左右方向で指定イベントのいないほうを向く
  192.       sx > 0 ? turn_right : turn_left
  193.     # 縦の距離のほうが長い場合
  194.     else
  195.       # 上下方向で指定イベントのいないほうを向く
  196.       sy > 0 ? turn_down : turn_up
  197.     end
  198.   end
  199.   #--------------------------------------------------------------------------
  200.   # ● 指定座標の方を向く
  201.   #--------------------------------------------------------------------------
  202.   def turn_toward_position(x, y)
  203.     # 座標の差を求める
  204.     sx = @x - x
  205.     sy = @y - y
  206.     # 座標が等しい場合
  207.     if sx == 0 and sy == 0
  208.       return
  209.     end
  210.     # 横の距離のほうが長い場合
  211.     if sx.abs > sy.abs
  212.       sx > 0 ? turn_left : turn_right
  213.     # 縦の距離のほうが長い場合
  214.     else
  215.       sy > 0 ? turn_up : turn_down
  216.     end
  217.   end
  218.   #--------------------------------------------------------------------------
  219.   # ● 指定座標の逆を向く
  220.   #--------------------------------------------------------------------------
  221.   def turn_away_from_position(x, y)
  222.     # 座標の差を求める
  223.     sx = @x - x
  224.     sy = @y - y
  225.     # 座標が等しい場合
  226.     if sx == 0 and sy == 0
  227.       return
  228.     end
  229.     # 横の距離のほうが長い場合
  230.     if sx.abs > sy.abs
  231.       sx > 0 ? turn_right : turn_left
  232.     # 縦の距離のほうが長い場合
  233.     else
  234.       sy > 0 ? turn_down : turn_up
  235.     end
  236.   end
  237.   #--------------------------------------------------------------------------
  238.   # ● 指定範囲内をランダムに移動
  239.   #--------------------------------------------------------------------------
  240.   def move_random_area(x, y, distance)
  241.     # 自分とエリア中心の座標の差を求める
  242.     sx = @x - x
  243.     sy = @y - y
  244.     # 既に範囲外にいる場合
  245.     if sx.abs + sy.abs > distance
  246.       # エリア中心に近づく
  247.       move_toward_position(x, y)
  248.       return
  249.     end
  250.     # とりあえずどの方向に進むか決定した後に距離判定
  251.     case rand(4)
  252.     when 0  # 下に移動
  253.       if sx.abs + sy < distance
  254.         move_down(false)
  255.       end
  256.     when 1  # 左に移動
  257.       if -sx + sy.abs < distance
  258.         move_left(false)
  259.       end
  260.     when 2  # 右に移動
  261.       if sx + sy.abs < distance
  262.         move_right(false)
  263.       end
  264.     when 3  # 上に移動
  265.       if sx.abs - sy < distance
  266.         move_up(false)
  267.       end
  268.     end
  269.   end
  270. end




RUBY 代码复制
  1. module SXL_ICON
  2.  
  3.   ICONS = {
  4.     1=>"$R_Key_1",
  5.     2=>"$R_Key_2",
  6.     3=>"$R_Key_3",
  7.     4=>"$R_Key_4",
  8.     5=>"$R_Key_5",
  9.     6=>"$R_Key_6",
  10.     7=>"$R_Key_7",
  11.   }
  12.  
  13.   SKIN = "123"
  14.   X    =  32         
  15.   Y    =  16      
  16. end
  17.  
  18. class KZGJ
  19.  
  20.   def initialize
  21.  
  22.     @base = Sprite.new
  23.     @base.bitmap = RPG::Cache.picture(SXL_ICON::SKIN)
  24.     @base.x = SXL_ICON::X
  25.     @base.y = SXL_ICON::Y
  26.     @base.z = SXL_ICON::Y+100
  27.     @width  = @base.bitmap.width
  28.     @height = @base.bitmap.height
  29.  
  30.     refresh
  31.  
  32.   end
  33.  
  34.  
  35.    def refresh
  36.      sort
  37.      n = 0
  38.      @icon_set = []
  39.      for battler in @battlers_array
  40.        p battler.id
  41.        iconname = SXL_ICON::ICONS[battler.id]
  42.        sprite = Sprite.new
  43.        sprite.bitmap = RPG::Cache.icon(iconname)
  44.        sprite.x = SXL_ICON::X + n * 25 + 25
  45.        sprite.y = SXL_ICON::Y
  46.        sprite.z = @base.z + 100
  47.        @icon_set.push([sprite,battler.id])
  48.        n += 1
  49.      end
  50.    end
  51.  
  52.    def reset
  53.      @icon_set.each { |set| set[0].dispose}
  54.      refresh
  55.    end
  56.  
  57.  
  58.    def cr(actor_id, position)
  59.      for set in @icon_set
  60.        if set[1] == actor_id then
  61.          set[0].x = SXL_ICON::X + position * 25 + 25
  62.          set[0].y = SXL_ICON::Y - 25
  63.          7.times { Graphics.update }
  64.          7.times { set[0].y += 7; Graphics.update}
  65.          break
  66.        end
  67.      end
  68.    end  
  69.  
  70.    def move_up(array)
  71.      for element in array
  72.       for i in 1..7
  73.        for set in @icon_set
  74.           if $game_map.events[element].at < $game_map.events[set[1]].at and set[0].visible == true then
  75.             set[0].x -= 7
  76.           end
  77.        end
  78.         Graphics.update
  79.       end
  80.     end
  81.    end
  82.  
  83.    def move_down(index)
  84.      for i in 1..7
  85.        for set in @icon_set
  86.           if $game_map.events[index].at < $game_map.events[set[1]].at and set[0].visible == true then
  87.             set[0].x += 7
  88.           end
  89.        end
  90.         Graphics.update
  91.       end
  92.    end
  93.  
  94.    def forward
  95.      for i in 1..7
  96.        for set in @icon_set
  97.          if set[0].visible == true then
  98.            set[0].x -= 7
  99.          end
  100.        end
  101.      Graphics.update  
  102.      end
  103.    end
  104.  
  105.    def conceal(array)
  106.       for id in array
  107.         for set in @icon_set
  108.           if id == set[1] then
  109.             set[0].visible = false
  110.           end
  111.         end
  112.       end
  113.    end
  114.  
  115.    def sort
  116.     @battlers_array = []
  117.     for i in $game_system.tactics_actors.keys
  118.       actor = $game_map.events[i]
  119.       if !$game_system.tactics_actors[i].dead? then
  120.        @battlers_array.push(actor)
  121.       end
  122.     end
  123.     for i in $game_system.tactics_enemies.keys
  124.       enemy = $game_map.events[i]
  125.       if !$game_system.tactics_enemies[i].dead? then
  126.        @battlers_array.push(enemy)
  127.      end
  128.     end
  129.  
  130.     @battlers_array.sort! {|a,b| a.at - b.at }
  131.   end
  132.  
  133.  
  134.   def dispose
  135.     @base.dispose
  136.     @icon_set.each { |set| set[0].dispose}
  137.   end
  138.  
  139.  
  140. end
  

Lv5.捕梦者

梦石
10
星屑
39440
在线时间
1914 小时
注册时间
2010-11-14
帖子
3315

R考场第七期纪念奖

发表于 2022-11-30 12:27:23 | 显示全部楼层
理性讨论,如果楼主不把用到的ARPG脚本贴上来,问题可能无法得到解决。
用头画头像,用脚写脚本
回复 支持 反对

使用道具 举报

Lv4.逐梦者

梦石
0
星屑
6116
在线时间
1089 小时
注册时间
2015-8-15
帖子
652
 楼主| 发表于 2022-11-30 14:02:50 | 显示全部楼层
本帖最后由 金芒芒 于 2022-11-30 14:12 编辑
KB.Driver 发表于 2022-11-30 12:27
理性讨论,如果楼主不把用到的ARPG脚本贴上来,问题可能无法得到解决。


帮忙改进一下 每一个快捷键只能使用一次
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-3-28 21:01

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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