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

Project1

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

[原创发布] ARPG用范围性影响能力值的技能

[复制链接]

Lv4.逐梦者

梦石
0
星屑
6645
在线时间
1666 小时
注册时间
2008-10-29
帖子
6710

贵宾

跳转到指定楼层
1
发表于 2010-9-30 19:22:06 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
先说明一下.此纯属搞着玩= =

效果嘛.看下面的 flash.

使用说明请看脚本开头处和范例里的公共事件 1 号.



多余的话:
Tilemap 的闪烁感觉边缘太硬了.
换成 loop_animation 可能会好些.
但是那样貌似会又把一些遮挡物、不可通行的图块给覆盖住= =
要改 Tilemap 的闪烁颜色的话可以在脚本开头的 Colors 常量数组里改.
其索引对应相应状态的 定量值
还有就是想把范围矩形改成别的什么形状的话请自行处理= =
这玩意还可以扩展一下做做技能冷却/限制什么的.
当矩形消失的时候才能再次使用或使用别的这类技能.
有兴趣的话就自己动手做吧.嗯.
大概就是这样了.

注意事项:
同一个状态最好不要被多个技能使用.因为是以状态的ID为主键建立的范围矩形数据对象.

范例:
ArpgAuxiliarySkill.rar (189.48 KB, 下载次数: 132)

脚本:

  1. #==============================================================================
  2. # ■ 本脚本来自 www.66rpg.com 转载和使用时请保留此信息
  3. #==============================================================================
  4. =begin
  5.   脚本作者:后知后觉
  6.   脚本功能:应用于地图上的直接战斗
  7.             可以在地图上设置某个矩形范围内
  8.             在这个范围内影响战斗者的能力值
  9.             并能让这个范围闪烁以醒目
  10.   使用方法:数据库状态的设置
  11.             定量:定量用来设置闪烁的颜色.0~10.一共11种.其中0为不无闪烁效果
  12.             经过 A 回合后 B%几率解除
  13.             因为是直接在地图上作战.所以这个貌似没什么用了.我就拿来用用了.
  14.             A : 持续的时间.结果为 A * 20.
  15.                 当 $game_system.update 被执行了 A * 20 次后该区域就消失
  16.             B : 范围的长度.
  17.                 在生成范围的时候要求设置一个中心点的x、y坐标
  18.                 以该点为中心.B*2+1 为边长的矩形
  19.             这个矩形内对能力值的影响效果就是该状态的效果.
  20.             使用脚本 ArpgAuxiliarySkill.new(x,y,state_id,target)
  21.             来声场这个矩形对象.
  22.             其中x、y为中心店坐标,state_id 为状态id
  23.             target 为作用对象类型.整数型.为 0 的时候对所有人有效.
  24.                    默认 1 为对角色有效.2为对敌人有效.这个可以自定义决定.
  25.                    只是用来做判断用.当要获取信息的时候传递进来的值与.new
  26.                    的时候所保存的值相吻合的时候才会对能力值有影响。
  27.           这些能力值的影响本应该写进 Game_Battler 里去的.
  28.           不过冲突啊什么的最讨厌了.所以还是你自己写进去吧.
  29.           具体的应用到实际的计算当中请参考范例的公共事件1号.
  30. =end

  31. $hzhj_ArpgAuxiliarySkill.call if $hzhj_ArpgAuxiliarySkill
  32. class ArpgAuxiliarySkill
  33.   Colors = [0,
  34.             0xf00,
  35.             0x0f0,
  36.             0x00f,
  37.             0xff0,
  38.             0xf0f,
  39.             0x0ff,
  40.             0xfff,
  41.             0xf84,
  42.             0x8f4,
  43.             0x84f]
  44.   attr_reader :time
  45.   attr_reader :x
  46.   attr_reader :y
  47.   attr_reader :key
  48.   attr_reader :state
  49.   attr_reader :rating
  50.   attr_reader :range
  51.   attr_reader :target
  52.   attr_reader :start_x
  53.   attr_reader :start_y
  54.   attr_reader :end_x
  55.   attr_reader :end_y
  56.   def initialize(x, y, state_id, target = 0)
  57.     @x = x
  58.     @y = y
  59.     @key = state_id
  60.     @state = $data_states[state_id]
  61.     @time = @state.hold_turn * 20
  62.     @range = @state.auto_release_prob
  63.     @target = target
  64.     @rating = @state.rating
  65.     $game_system.hzhj_hash[@key] = self
  66.     set_flash_data
  67.   end
  68.   def update
  69.     if @time > 0
  70.       @time -= 1
  71.       return
  72.     end
  73.     $game_system.hzhj_hash[@key] = nil
  74.     reset_flash_data
  75.   end
  76.   def set_xyt(x, y, time)
  77.     @x = x
  78.     @y = y
  79.     @time = time
  80.     reset_flash_data
  81.   end
  82.   def set_flash_data
  83.     @start_x = [@x - @range, 0].max
  84.     @start_y = [@y - @range, 0].max
  85.     @end_x = [@x + @range, $game_map.width - 1].min
  86.     @end_y = [@y + @range, $game_map.height - 1].min
  87.     for i in @start_x..@end_x
  88.       for j in @start_y..@end_y
  89.         if $game_map.passable?(i, j, 0)
  90.           $game_map.flash_data[i, j] = Colors[@rating]
  91.         end
  92.       end
  93.     end
  94.   end
  95.   def reset_flash_data
  96.     $game_map.flash_data = Table.new($game_map.width, $game_map.height)
  97.     values = $game_system.hzhj_hash.values
  98.     values.delete(nil)
  99.     for hzhj in values.sort!{|a,b|a.rating - b.rating}
  100.       hzhj.set_flash_data
  101.     end
  102.   end
  103. end

  104. class Hzhj_Hash < Hash
  105.   def initialize
  106.     super
  107.   end
  108.   def []=(key, value)
  109.     if self[key].nil?
  110.       super(key, value)
  111.     else
  112.       if value.nil?
  113.         super(key, value)
  114.       else
  115.         self[key].set_xyt(value.x, value.y, value.time)
  116.       end
  117.     end
  118.   end
  119.   def hit_rate(x, y, target)
  120.     n = 100
  121.     for hzhj in self.values
  122.       next if hzhj.nil?
  123.       if x.between?(hzhj.start_x, hzhj.end_x)
  124.         if y.between?(hzhj.start_y, hzhj.end_y)
  125.           if target == hzhj.target or hzhj.target == 0
  126.             n *= hzhj.state.hit_rate / 100.0
  127.           end
  128.         end
  129.       end
  130.     end
  131.     return Integer(n.round)
  132.   end
  133.   def maxhp_rate(x, y, target)
  134.     n = 100
  135.     for hzhj in self.values
  136.       next if hzhj.nil?
  137.       if x.between?(hzhj.start_x, hzhj.end_x)
  138.         if y.between?(hzhj.start_y, hzhj.end_y)
  139.           if target == hzhj.target or hzhj.target == 0
  140.             n *= hzhj.state.maxhp_rate / 100.0
  141.           end
  142.         end
  143.       end
  144.     end
  145.     return Integer(n.round)
  146.   end
  147.   def maxsp_rate(x, y, target)
  148.     n = 100
  149.     for hzhj in self.values
  150.       next if hzhj.nil?
  151.       if x.between?(hzhj.start_x, hzhj.end_x)
  152.         if y.between?(hzhj.start_y, hzhj.end_y)
  153.           if target == hzhj.target or hzhj.target == 0
  154.             n *= hzhj.state.maxsp_rate / 100.0
  155.           end
  156.         end
  157.       end
  158.     end
  159.     return Integer(n.round)
  160.   end
  161.   def str_rate(x, y, target)
  162.     n = 100
  163.     for hzhj in self.values
  164.       next if hzhj.nil?
  165.       if x.between?(hzhj.start_x, hzhj.end_x)
  166.         if y.between?(hzhj.start_y, hzhj.end_y)
  167.           if target == hzhj.target or hzhj.target == 0
  168.             n *= hzhj.state.str_rate / 100.0
  169.           end
  170.         end
  171.       end
  172.     end
  173.     return Integer(n.round)
  174.   end
  175.   def dex_rate(x, y, target)
  176.     n = 100
  177.     for hzhj in self.values
  178.       next if hzhj.nil?
  179.       if x.between?(hzhj.start_x, hzhj.end_x)
  180.         if y.between?(hzhj.start_y, hzhj.end_y)
  181.           if target == hzhj.target or hzhj.target == 0
  182.             n *= hzhj.state.dex_rate / 100.0
  183.           end
  184.         end
  185.       end
  186.     end
  187.     return Integer(n.round)
  188.   end
  189.   def agi_rate(x, y, target)
  190.     n = 100
  191.     for hzhj in self.values
  192.       next if hzhj.nil?
  193.       if x.between?(hzhj.start_x, hzhj.end_x)
  194.         if y.between?(hzhj.start_y, hzhj.end_y)
  195.           if target == hzhj.target or hzhj.target == 0
  196.             n *= hzhj.state.agi_rate / 100.0
  197.           end
  198.         end
  199.       end
  200.     end
  201.     return Integer(n.round)
  202.   end
  203.   def int_rate(x, y, target)
  204.     n = 100
  205.     for hzhj in self.values
  206.       next if hzhj.nil?
  207.       if x.between?(hzhj.start_x, hzhj.end_x)
  208.         if y.between?(hzhj.start_y, hzhj.end_y)
  209.           if target == hzhj.target or hzhj.target == 0
  210.             n *= hzhj.state.int_rate / 100.0
  211.           end
  212.         end
  213.       end
  214.     end
  215.     return Integer(n.round)
  216.   end
  217.   def atk_rate(x, y, target)
  218.     n = 100
  219.     for hzhj in self.values
  220.       next if hzhj.nil?
  221.       if x.between?(hzhj.start_x, hzhj.end_x)
  222.         if y.between?(hzhj.start_y, hzhj.end_y)
  223.           if target == hzhj.target or hzhj.target == 0
  224.             n *= hzhj.state.atk_rate / 100.0
  225.           end
  226.         end
  227.       end
  228.     end
  229.     return Integer(n.round)
  230.   end
  231.   def pdef_rate(x, y, target)
  232.     n = 100
  233.     for hzhj in self.values
  234.       next if hzhj.nil?
  235.       if x.between?(hzhj.start_x, hzhj.end_x)
  236.         if y.between?(hzhj.start_y, hzhj.end_y)
  237.           if target == hzhj.target or hzhj.target == 0
  238.             n *= hzhj.state.pdef_rate / 100.0
  239.           end
  240.         end
  241.       end
  242.     end
  243.     return Integer(n.round)
  244.   end
  245.   def mdef_rate(x, y, target)
  246.     n = 100
  247.     for hzhj in self.values
  248.       next if hzhj.nil?
  249.       if x.between?(hzhj.start_x, hzhj.end_x)
  250.         if y.between?(hzhj.start_y, hzhj.end_y)
  251.           if target == hzhj.target or hzhj.target == 0
  252.             n *= hzhj.state.mdef_rate / 100.0
  253.           end
  254.         end
  255.       end
  256.     end
  257.     return Integer(n.round)
  258.   end
  259.   def eva(x, y, target)
  260.     n = 0
  261.     for hzhj in self.values
  262.       next if hzhj.nil?
  263.       if x.between?(hzhj.start_x, hzhj.end_x)
  264.         if y.between?(hzhj.start_y, hzhj.end_y)
  265.           if target == hzhj.target or hzhj.target == 0
  266.             n += hzhj.state.eva
  267.           end
  268.         end
  269.       end
  270.     end
  271.     return Integer(n)
  272.   end
  273. end

  274. class Game_System
  275.   attr_reader :hzhj_hash
  276.   alias hzhj_hash_game_system_initialize initialize
  277.   def initialize
  278.     hzhj_hash_game_system_initialize
  279.     @hzhj_hash = Hzhj_Hash.new
  280.   end
  281.   alias hzhj_hash_game_system_update update
  282.   def update
  283.     hzhj_hash_game_system_update
  284.     @hzhj_hash.values.each{|hzhj|hzhj.update if not hzhj.nil?}
  285.   end
  286. end

  287. class Game_Map
  288.   attr_accessor :flash_data
  289.   alias hzhj_hash_game_map_setup setup
  290.   def setup(*args)
  291.     hzhj_hash_game_map_setup(*args)
  292.     $game_system.hzhj_hash.clear
  293.     @flash_data = Table.new(width, height)
  294.   end
  295. end

  296. class Spriteset_Map
  297.   alias hzhj_hash_spriteset_map_initialize initialize
  298.   def initialize
  299.     hzhj_hash_spriteset_map_initialize
  300.     @tilemap.flash_data = $game_map.flash_data
  301.     @tilemap.update
  302.   end
  303.   alias hzhj_hash_spriteset_map_update update
  304.   def update
  305.     if @tilemap.flash_data != $game_map.flash_data
  306.       @tilemap.flash_data = $game_map.flash_data
  307.     end
  308.     hzhj_hash_spriteset_map_update
  309.   end
  310. end

  311. callcc{|$hzhj_ArpgAuxiliarySkill|}
  312. #==============================================================================
  313. # ■ 本脚本来自 www.66rpg.com 转载和使用时请保留此信息
  314. #==============================================================================

复制代码











你知道得太多了

Lv1.梦旅人

梦石
0
星屑
133
在线时间
195 小时
注册时间
2009-10-10
帖子
435
2
发表于 2010-9-30 20:52:10 | 只看该作者
{:2_42:} 好东西,移植到我的ARPG里  {:2_36:}
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-5-14 13:24

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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