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

Project1

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

传说中的ARPG彩虹神剑(DEBUG版本)

 关闭 [复制链接]

Lv1.梦旅人

梦石
0
星屑
49
在线时间
83 小时
注册时间
2008-4-19
帖子
420
跳转到指定楼层
1
发表于 2009-1-11 21:13:39 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
这是第二次DEBUG了...
修正了一些问题
适用人群:ARPG制作者

  1. #--------------------------------------------------
  2. # 此脚本来自www.66RPG.com,使用请保留此信息
  3. #--------------------------------------------------
  4. module RPG
  5.   class Sprite < ::Sprite
  6.     @@_animations = []
  7.     @@_reference_count = {}
  8.     def initialize(viewport = nil)
  9.       super(viewport)
  10.       @_whiten_duration = 0
  11.       @_appear_duration = 0
  12.       @_escape_duration = 0
  13.       @_collapse_duration = 0
  14.       @_damage_duration = 0
  15.       @_damage = []
  16.       @_animation_duration = 0
  17.       @_blink = false
  18.       @_animation = []
  19.       #========================
  20.       @battler_damage = nil
  21.       @battler_critical = nil
  22.       @all_quanzhong = 1
  23.       @p_dam = 0
  24.       @hits = 0
  25.       #========================
  26.     end
  27.    
  28.     def damage(value, critical)
  29.       #dispose_hit
  30.       if value.is_a?(Numeric)
  31.         damage_string = value.abs.to_s
  32.       else
  33.         damage_string = value.to_s
  34.       end
  35.       bitmap = Bitmap.new(162, 64)
  36.       bitmap.font.name = "宋体"
  37.       bitmap.font.size = 32
  38.       bitmap.font.color.set(0, 0, 0)
  39.       #bitmap.draw_text(-1, 12-1, 160, 36, damage_string, 1)
  40.       #bitmap.draw_text(+1, 12-1, 160, 36, damage_string, 1)
  41.       #bitmap.draw_text(-1, 12+1, 160, 36, damage_string, 1)
  42.       #bitmap.draw_text(+1, 12+1, 160, 36, damage_string, 1)
  43.       if value.is_a?(Numeric) #and value < 0
  44.         damage_array = damage_string.scan(/./)
  45.         damage_x = 81 - damage_string.size * 9
  46.         # 伤害值为负的情况下
  47.         if value < 0
  48.           # 调用回复数字表
  49.           rect_y = 32
  50.         else
  51.           # 调用伤害数字表
  52.           rect_y = 0
  53.         end
  54.         # 循环伤害值字符串
  55.         for char in damage_array
  56.           number = char.to_i
  57.           # 显示伤害数字
  58.           bitmap.blt(damage_x, 32, RPG::Cache.system("Damage"),
  59.           Rect.new(number * 18, rect_y, 18, 32))
  60.           # 后移一位
  61.           damage_x += 18
  62.         end
  63.       else
  64.         if value != "miss"
  65.           # 系统默认描画字符串
  66.           bitmap.font.color.set(0, 0, 0)
  67.           bitmap.draw_text(-1-30, 27, 162, 36, damage_string, 1)
  68.         # Miss 的情况下
  69.         else
  70.           # 显示未击中图画
  71.           bitmap.blt(36, 28, RPG::Cache.system("Damage"), Rect.new(90, 64, 90, 32))
  72.         end
  73.       end
  74.       if critical
  75.         bitmap.blt(36, 0, RPG::Cache.system("Damage"), Rect.new(0, 64, 90, 32))
  76.       end
  77.       @_damage_duration = 40
  78.       num = @_damage.size
  79.       @_damage.push([::Sprite.new,40,0, rand(50) - 15, rand(30)])
  80.       @_damage[num][0].bitmap = bitmap
  81.       @_damage[num][0].ox = 80 + self.viewport.ox
  82.       @_damage[num][0].oy = 20 + self.viewport.oy
  83.       if self.character.is_a?(Game_Actor)
  84.         @_damage[num][0].x = self.x
  85.         @_damage[num][0].y = self.y - self.oy / 2
  86.       else
  87.         @_damage[num][0].x = self.x + self.viewport.rect.x -
  88.                             self.ox + self.src_rect.width / 2
  89.         @_damage[num][0].y = self.y - self.oy * self.zoom_y / 2 +
  90.                             self.viewport.rect.y
  91.         @_damage[num][0].zoom_x = self.zoom_x
  92.         @_damage[num][0].zoom_y = self.zoom_y
  93.         @_damage[num][0].z = 3000
  94.       end
  95.       if value.is_a?(Numeric) and value > 0 and self.character.is_a?(Game_Event)
  96.         dispose_hit
  97.         @hits += 1
  98.         hit
  99.         $game_system.hits += 1
  100.       end
  101.     end
  102.     #=======================================
  103.     # 修改:HIT数字计算
  104.     #=======================================
  105.     def hit
  106.       #dispose_hit
  107.       # 如果伤害值是数值,转为字符串
  108.       value = @hits
  109.       hits_string = value.to_s
  110.       # 初始化位图
  111.       bitmap = Bitmap.new(320, 64)
  112.       bitmap.font.name = "Arial Black"
  113.       bitmap.font.size = 32
  114.       # 分割伤害值字符串
  115.       hits_array = hits_string.scan(/./)
  116.       hits_x = 81 - hits_string.size * 18.1
  117.       rect_y = 0
  118.       # 循环伤害值字符串
  119.       for char in hits_array
  120.         number = char.to_i
  121.         # 显示伤害数字
  122.         bitmap.blt(hits_x, 0, RPG::Cache.system("Number"),
  123.         Rect.new(number * 36.2, rect_y, 36.2, 50))
  124.         # 后移一位
  125.         hits_x += 36.2
  126.       end
  127.       bitmap.blt(hits_x, 0, RPG::Cache.system("HITS"), Rect.new(0, -21, 90, 50))
  128.       # 伤害值定位
  129.       @_hits_sprite = ::Sprite.new(self.viewport)
  130.       @_hits_sprite.bitmap = bitmap
  131.       @_hits_sprite.ox = 81
  132.       @_hits_sprite.oy = 20
  133.       @_hits_sprite.x = 450
  134.       @_hits_sprite.y = 200
  135.       @_hits_sprite.z = 3000
  136.       @_hits_duration = 40
  137.     end
  138.    
  139.     def animation(animation, hit, battler_damage="", battler_critical=false)
  140.       return if animation == nil
  141.       #=======================================
  142.       # 修改:记录伤害和critical,以及防止拖死..
  143.       #=======================================
  144.       dispose_animation(false)
  145.       num = @_animation.size
  146.       @_animation.push([animation, hit, animation.frame_max, []])
  147.       @battler_damage = battler_damage
  148.       @battler_critical = battler_critical
  149.       #return if @_animation == []
  150.       bitmap = RPG::Cache.animation(animation.animation_name,                                     animation.animation_hue)
  151.       anime = @_animation.index([animation, hit, animation.frame_max, []])
  152.       #=======================================
  153.       # 修改:计算总闪光权限值
  154.       #=======================================
  155.       for timing in @_animation[anime][0].timings
  156.         quanzhong = animation_process_timing(timing, @_animation[num][1], true)
  157.         @all_quanzhong += quanzhong
  158.         # 记录最后一次闪光
  159.         @_last_frame = timing.frame if quanzhong != 0
  160.       end      
  161.       #=======================================
  162.       if @@_reference_count.include?(bitmap)
  163.         @@_reference_count[bitmap] += 1
  164.       else
  165.         @@_reference_count[bitmap] = 1
  166.       end
  167.       if @_animation[num][0] != 3 or not @@_animations.include?(animation)
  168.         for i in 0..15
  169.           sprite = ::Sprite.new
  170.           sprite.bitmap = bitmap
  171.           sprite.visible = false
  172.           @_animation[num][3].push(sprite)
  173.         end
  174.         unless @@_animations.include?(animation)
  175.           @@_animations.push(animation)
  176.         end
  177.       end
  178.       update_animation(@_animation[num])
  179.     end
  180.    
  181.     def loop_animation(animation)
  182.       return if animation == @_loop_animation
  183.       dispose_loop_animation
  184.       @_loop_animation = animation
  185.       return if @_loop_animation == nil
  186.       @_loop_animation_index = 0
  187.       animation_name = @_loop_animation.animation_name
  188.       animation_hue = @_loop_animation.animation_hue
  189.       bitmap = RPG::Cache.animation(animation_name, animation_hue)
  190.       if @@_reference_count.include?(bitmap)
  191.         @@_reference_count[bitmap] += 1
  192.       else
  193.         @@_reference_count[bitmap] = 1
  194.       end
  195.       @_loop_animation_sprites = []
  196.       for i in 0..15
  197.         sprite = ::Sprite.new
  198.         sprite.bitmap = bitmap
  199.         sprite.visible = false
  200.         @_loop_animation_sprites.push(sprite)
  201.       end
  202.       # update_loop_animation
  203.     end
  204.    
  205.     def dispose_animation(clearing = true)
  206.       #=======================================
  207.       # 修改:清除记录的伤害,清除权重记录
  208.       #=======================================
  209.       @battler_damage = ""
  210.       @battler_critical = nil
  211.       @all_quanzhong = 1
  212.       @_last_frame = -1
  213.       #=======================================
  214.       if clearing
  215.         for anime in @_animation.reverse
  216.           sprite = anime[3][0]
  217.           if sprite != nil
  218.             @@_reference_count[sprite.bitmap] -= 1
  219.             if @@_reference_count[sprite.bitmap] == 0
  220.               sprite.bitmap.dispose
  221.             end
  222.           end
  223.           for sprite in anime[3]
  224.             sprite.dispose
  225.           end
  226.           @_animation.delete(anime)
  227.         end
  228.       end
  229.     end
  230.    
  231.     #=======================================
  232.     # 清除hit数
  233.     #=======================================
  234.     def dispose_hit(tz = false)
  235.       @hits = 0 if tz
  236.       if @_hits_sprite != nil
  237.         @_hits_sprite.bitmap.dispose
  238.         @_hits_sprite.dispose
  239.         @_hits_sprite = nil
  240.       end
  241.     end
  242.    
  243.     def update
  244.       super
  245.       if @_whiten_duration > 0
  246.         @_whiten_duration -= 1
  247.         self.color.alpha = 128 - (16 - @_whiten_duration) * 10
  248.       end
  249.       if @_appear_duration > 0
  250.         @_appear_duration -= 1
  251.         self.opacity = (16 - @_appear_duration) * 16
  252.       end
  253.       if @_escape_duration > 0
  254.         @_escape_duration -= 1
  255.         self.opacity = 256 - (32 - @_escape_duration) * 10
  256.       end
  257.       if @_collapse_duration > 0
  258.         @_collapse_duration -= 1
  259.         self.opacity = 256 - (48 - @_collapse_duration) * 6
  260.       end
  261.       for damage in @_damage
  262.         if damage[1] > 0
  263.           damage[1] -= 1
  264.           damage[4] -= 3
  265.           damage[2] -= damage[4]
  266.           if self.character.is_a?(Game_Actor)
  267.             damage[0].x = self.x + self.viewport.rect.x
  268.             damage[0].y -= 3
  269.           else
  270.             damage[0].x = self.x + self.viewport.rect.x
  271.             damage[0].y -= 3
  272.             damage[0].zoom_x = self.zoom_x
  273.             damage[0].zoom_y = self.zoom_y
  274.           end
  275.           damage[0].z = 2960 + damage[1]
  276.           damage[0].opacity = 256 - (12 - damage[1]) * 32
  277.         end
  278.         if damage[1] == 0
  279.           damage[0].bitmap.dispose
  280.           damage[0].dispose
  281.           @_damage.delete(damage)
  282.         end
  283.       end
  284.       if @_damage == [] and Graphics.frame_count % 40 == 0
  285.         dispose_hit(true)
  286.       end
  287.       for anime in @_animation
  288.         if (Graphics.frame_count % 2 == 0)
  289.           anime[2] -= 1
  290.           update_animation(anime)
  291.         end
  292.       end
  293.       if @_loop_animation != nil and (Graphics.frame_count % 2 == 0)
  294.         update_loop_animation
  295.         @_loop_animation_index += 1
  296.         @_loop_animation_index %= @_loop_animation.frame_max
  297.       end
  298.       if @_blink
  299.         @_blink_count = (@_blink_count + 1) % 32
  300.         if @_blink_count < 16
  301.           alpha = (16 - @_blink_count) * 6
  302.         else
  303.           alpha = (@_blink_count - 16) * 6
  304.         end
  305.         self.color.set(255, 255, 255, alpha)
  306.       end
  307.       @@_animations.clear
  308.     end

  309.     def update_animation(anime)
  310.       if anime[2] > 0
  311.         frame_index = anime[0].frame_max - anime[2]
  312.         cell_data = anime[0].frames[frame_index].cell_data
  313.         position = anime[0].position
  314.         animation_set_sprites(anime[3], cell_data, position)
  315.         for timing in anime[0].timings
  316.           if timing.frame == frame_index  
  317.             #=======================================
  318.             # 修改:弹出伤害,权重计算
  319.             #=======================================
  320.             t = 1.0 * animation_process_timing(timing, anime[1],true)      
  321.             #p t,"当前权重", @all_quanzhong,"总权重"
  322.             if @battler_damage.is_a?(Numeric) and t != 0
  323.               t *= @battler_damage
  324.               t /= @all_quanzhong
  325.               t = t.to_i
  326.               # 在闪光不是最后一次的情况下,把这次伤害加入到已经发生的伤害中
  327.               if frame_index != @_last_frame
  328.                 @p_dam += t
  329.               end
  330.               # 闪光为最后一次的情况下,改变这次伤害的计算方法
  331.               if frame_index == @_last_frame
  332.                 t = @battler_damage - @p_dam
  333.               end
  334.               # 最后一次闪光的话,伤害修正, 已经发生的伤害归0, 连击次数归0★
  335.               if frame_index == @_last_frame
  336.                 @p_dam = 0
  337.                 #@hits = 0
  338.               end
  339.               damage(t,@battler_critical)
  340.             elsif !@battler_damage.is_a?(Numeric) and timing.flash_scope != 0
  341.               damage(@battler_damage,@battler_critical)
  342.             end
  343.           end
  344.           #=======================================
  345.         end
  346.       else
  347.         @@_reference_count[anime[3][0].bitmap] -= 1
  348.         if @@_reference_count[anime[3][0].bitmap] == 0
  349.             anime[3][0].bitmap.dispose
  350.         end
  351.         for sprite in anime[3]
  352.           sprite.dispose
  353.         end
  354.         @_animation.delete(anime)
  355.       end
  356.     end
  357.     #=======================================
  358.     # 修改:敌人跳跃的功能 + 添加返回数值
  359.     #=======================================
  360.     def animation_process_timing(timing, hit, rt = false)
  361.       if (timing.condition == 0) or
  362.         (timing.condition == 1 and hit == true) or
  363.         (timing.condition == 2 and hit == false)
  364.         if timing.se.name != ""
  365.           se = timing.se
  366.           Audio.se_play("Audio/SE/" + se.name, se.volume, se.pitch)
  367.         end
  368.         case timing.flash_scope
  369.         when 1
  370.           self.flash(timing.flash_color, timing.flash_duration * 2)
  371.           @flash_shake_switch = true
  372.           @flash_shake = 10
  373.           return timing.flash_color.alpha * timing.flash_duration if rt
  374.         when 2
  375.           if self.viewport != nil
  376.             self.viewport.flash(timing.flash_color, timing.flash_duration * 2)
  377.             return timing.flash_color.alpha * timing.flash_duration if rt
  378.           end
  379.         when 3
  380.           self.flash(nil, timing.flash_duration * 2)
  381.           return timing.flash_color.alpha * timing.flash_duration if rt
  382.         end
  383.       end
  384.       return 0
  385.     end
  386.    
  387.     def animation_set_sprites(sprites, cell_data, position)
  388.       for i in 0..15
  389.         sprite = sprites[i]
  390.         pattern = cell_data[i, 0]
  391.         if sprite == nil or pattern == nil or pattern == -1
  392.           sprite.visible = false if sprite != nil
  393.           next
  394.         end
  395.         sprite.visible = true
  396.         sprite.src_rect.set(pattern % 5 * 192, pattern / 5 * 192, 192, 192)
  397.         if position == 3
  398.           if self.viewport != nil
  399.             sprite.x = self.viewport.rect.width / 2
  400.             if $game_system.arpg_ing and self.character.is_a?(Game_Event)
  401.               sprite.y = self.viewport.rect.height - 320
  402.             else
  403.               sprite.y = self.viewport.rect.height - 160
  404.             end
  405.           else
  406.             sprite.x = 320
  407.             sprite.y = 240
  408.           end
  409.         else
  410.           sprite.x = self.x + self.viewport.rect.x -
  411.                       self.ox + self.src_rect.width / 2
  412.           if $game_temp.in_battle and self.character.is_a?(Game_Event)
  413.             sprite.y = self.y - self.oy * self.zoom_y / 2 +
  414.                         self.viewport.rect.y
  415.             if position == 0
  416.               sprite.y -= self.src_rect.height * self.zoom_y / 4
  417.             elsif position == 2
  418.               sprite.y += self.src_rect.height * self.zoom_y / 4
  419.             end
  420.           else
  421.             sprite.y = self.y + self.viewport.rect.y -
  422.                         self.oy + self.src_rect.height / 2
  423.             sprite.y -= self.src_rect.height / 4 if position == 0
  424.             sprite.y += self.src_rect.height / 4 if position == 2
  425.           end
  426.         end
  427.         sprite.x += cell_data[i, 1]
  428.         sprite.y += cell_data[i, 2]
  429.         sprite.z = 2000
  430.         sprite.ox = 96
  431.         sprite.oy = 96
  432.         sprite.zoom_x = cell_data[i, 3] / 100.0
  433.         sprite.zoom_y = cell_data[i, 3] / 100.0
  434.         if position != 3
  435.           sprite.zoom_x *= self.zoom_x
  436.           sprite.zoom_y *= self.zoom_y
  437.         end
  438.         sprite.angle = cell_data[i, 4]
  439.         sprite.mirror = (cell_data[i, 5] == 1)
  440.         sprite.opacity = cell_data[i, 6] * self.opacity / 255.0
  441.         sprite.blend_type = cell_data[i, 7]
  442.       end
  443.     end
  444.   end
  445. end
复制代码
好吧这是II让我贴的- -

Lv1.梦旅人

梦石
0
星屑
50
在线时间
60 小时
注册时间
2008-8-27
帖子
531
2
发表于 2009-1-11 21:24:22 | 只看该作者
sf
顶一个
回复 支持 反对

使用道具 举报

头像被屏蔽

Lv1.梦旅人 (禁止发言)

梦石
0
星屑
50
在线时间
0 小时
注册时间
2009-1-6
帖子
46
3
发表于 2009-1-12 09:56:08 | 只看该作者
提示: 作者被禁止或删除 内容自动屏蔽
签名被屏蔽
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
98
在线时间
12 小时
注册时间
2008-4-29
帖子
461
4
发表于 2009-1-13 00:14:54 | 只看该作者
不明白,这是干嘛的?
无视VIP
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
394 小时
注册时间
2007-4-2
帖子
954
5
发表于 2009-1-13 03:02:27 | 只看该作者
彩虹神剑是什么

回复 支持 反对

使用道具 举报

Lv4.逐梦者

梦石
0
星屑
5634
在线时间
1052 小时
注册时间
2008-6-9
帖子
524

开拓者

6
发表于 2009-1-13 05:21:47 | 只看该作者
恩?彩虹神剑不能用在ARPG中吗?貌似我以前改夜想曲的时候加了彩虹,效果很不错啊。
总是没耐心做一个游戏。。
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
49
在线时间
83 小时
注册时间
2008-4-19
帖子
420
7
 楼主| 发表于 2009-1-14 04:53:17 | 只看该作者
似乎要改了一个东西.这就是多动画+彩虹神剑整合版本,2年前的脚本水平...
好吧这是II让我贴的- -
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2025-7-22 00:20

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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