查看: 3095|回复: 1

[已经过期] STG脚本怎么用

[复制链接]
梦石
0
星屑
1918
在线时间
380 小时
注册时间
2012-12-10
回帖
402
发表于 2014-10-29 22:58:36 | 显示全部楼层 |阅读模式

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

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

×
下面是三个脚本和前面的说明:



说明:
STG脚本:
Srpite_aaaagq
Bul_aaaagq
Scene_Show
参数:
    $maxbul   = 100   #全弹量
    $maxenemy = 6     #敌人量
    $伤害显示 = true  #就是伤害显示





Srpite_aaaagq:


  1. class Srpite_aaaagq < RPG::Sprite
  2.     attr_accessor :hp               
  3.     attr_accessor :maxhp
  4.    
  5.     attr_accessor :nextpx               
  6.     attr_accessor :nextpy
  7.    
  8.     attr_accessor :tdam              
  9.     attr_accessor :dam              
  10.     attr_accessor :damagerange
  11.    
  12.     attr_accessor :wt              
  13.     attr_accessor :rwt
  14.    
  15.     attr_accessor :showdt
  16.     attr_accessor :speed
  17.    
  18.    
  19. #------------------------------------------------------------------------   
  20. #------------------------------------------------------------------------   
  21. #------------------------------------------------------------------------   
  22. #------------------------------------------------------------------------   
  23.     def init
  24.       initialize
  25.     end

  26.     def initialize
  27.       super
  28.       @damagerange  =   20
  29.       @tdam         =   0
  30.       @dam          =   0
  31.       @nextpx       =   0
  32.       @nextpy       =   0
  33.       @maxhp        =   1000
  34.       @hp           =   @maxhp
  35.       @wt           =   0
  36.       @rwt          =   34
  37.       @showdt       =   0
  38.       @speed        =   2
  39.       update
  40.     end
  41.   
  42.     def recover
  43.       @wt=[@wt-@rwt,0].max
  44.     end
  45.    
  46.     def moving
  47.       if (self.x>-@damagerange) and (self.x<640+@damagerange) and
  48.          (self.y>-@damagerange) and (self.y<480+@damagerange)
  49.         tx = self.x
  50.         ty = self.y
  51.         self.x = @nextpx
  52.         self.y = @nextpy
  53.         @nextpx = @nextpx + @nextpx - tx
  54.         @nextpy = @nextpy + @nextpy - ty
  55.       else
  56.         self.x=-2000
  57.         self.y=-2000        
  58.       end
  59.     end
  60.    
  61. #------------------------------------------------------------------------   
  62. #------------------------------------------------------------------------   
  63. #------------------------------------------------------------------------   
  64.     def adddamage()
  65.       if @dam > @tdam
  66.         @tdam = @dam
  67.         damage(@dam, false)
  68.       end      
  69.     end
  70.    
  71.     def damage(value, critical)
  72.       if value.is_a?(Numeric)
  73.         damage_string = value.to_s
  74.       end
  75.       dispose_damage
  76.       bitmap = Bitmap.new(160, 48)
  77.       bitmap.font.name = "Arial Black"
  78.       bitmap.font.size = 32
  79.       bitmap.font.color.set(0, 0, 0)
  80.       bitmap.draw_text(-1, 12-1, 160, 36, damage_string, 1)
  81.       bitmap.draw_text(+1, 12-1, 160, 36, damage_string, 1)
  82.       bitmap.draw_text(-1, 12+1, 160, 36, damage_string, 1)
  83.       bitmap.draw_text(+1, 12+1, 160, 36, damage_string, 1)
  84.       if value.is_a?(Numeric) and value < 0
  85.         bitmap.font.color.set(176, 255, 144)
  86.       else
  87.         bitmap.font.color.set(255, 255, 255)
  88.       end
  89.       bitmap.draw_text(0, 12, 160, 36, damage_string, 1)
  90.       if critical
  91.         bitmap.font.size = 20
  92.         bitmap.font.color.set(0, 0, 0)
  93.         bitmap.draw_text(-1, -1, 160, 20, "CRITICAL", 1)
  94.         bitmap.draw_text(+1, -1, 160, 20, "CRITICAL", 1)
  95.         bitmap.draw_text(-1, +1, 160, 20, "CRITICAL", 1)
  96.         bitmap.draw_text(+1, +1, 160, 20, "CRITICAL", 1)
  97.         bitmap.font.color.set(255, 255, 255)
  98.         bitmap.draw_text(0, 0, 160, 20, "CRITICAL", 1)
  99.       end
  100.       @_damage_sprite = ::Sprite.new(self.viewport)
  101.       @_damage_sprite.bitmap = bitmap
  102.       @_damage_sprite.ox = 80#rand(40) - 20, rand(30) + 50
  103.       @_damage_sprite.oy = 20
  104.       @_damage_sprite.x = self.x
  105.       @_damage_sprite.y = self.y - self.oy / 2
  106.       @_damage_sprite.z = 3000
  107.       @_damage_duration = 40
  108.     end
  109.         
  110.     def update
  111.       super
  112.       if @_whiten_duration > 0
  113.         @_whiten_duration -= 1
  114.         self.color.alpha = 128 - (16 - @_whiten_duration) * 10
  115.       end
  116.       if @_appear_duration > 0
  117.         @_appear_duration -= 1
  118.         self.opacity = (16 - @_appear_duration) * 16
  119.       end
  120.       if @_escape_duration > 0
  121.         @_escape_duration -= 1
  122.         self.opacity = 256 - (32 - @_escape_duration) * 10
  123.       end
  124.       if @_collapse_duration > 0
  125.         @_collapse_duration -= 1
  126.         self.opacity = 256 - (48 - @_collapse_duration) * 6
  127.       end
  128.       adddamage
  129.       if @_damage_duration > 0
  130.         @_damage_duration -= 1
  131.         case @_damage_duration
  132.         when 38..39
  133.           @_damage_sprite.y -= 4
  134.         when 36..37
  135.           @_damage_sprite.y -= 2
  136.         when 34..35
  137.           @_damage_sprite.y += 2
  138.         when 28..33
  139.           @_damage_sprite.y += 4
  140.         end
  141.         @_damage_sprite.opacity = 256 - (12 - @_damage_duration) * 32
  142.         if @_damage_duration == 0
  143.           dispose_damage
  144.         end
  145.       else
  146.         @dam = 0
  147.         @tdam = 0
  148.       end
  149.       if @_animation != nil and (Graphics.frame_count % 2 == 0)
  150.         @_animation_duration -= 1
  151.         update_animation
  152.       end
  153.       if @_loop_animation != nil and (Graphics.frame_count % 2 == 0)
  154.         update_loop_animation
  155.         @_loop_animation_index += 1
  156.         @_loop_animation_index %= @_loop_animation.frame_max
  157.       end
  158.       if @_blink
  159.         @_blink_count = (@_blink_count + 1) % 32
  160.         if @_blink_count < 16
  161.           alpha = (16 - @_blink_count) * 6
  162.         else
  163.           alpha = (@_blink_count - 16) * 6
  164.         end
  165.         self.color.set(255, 255, 255, alpha)
  166.       end
  167.       @@_animations.clear
  168.     end

  169. end
复制代码





Bul_aaaagq:
  1. class Bul_aaaagq < Sprite
  2.     attr_accessor :nextpx               
  3.     attr_accessor :nextpy
  4.    
  5.     attr_accessor :dam            
  6.     attr_accessor :damagerange
  7.    
  8.     attr_accessor :bul_st              
  9.   
  10.     def init
  11.       @bul_st       = 0
  12.       @damagerange  = 20
  13.       @nextpx       = 0
  14.       @nextpy       = 0
  15.       self.x        = -2000
  16.       self.y        = -2000
  17.     end
  18.    
  19.     def initialize
  20.       super
  21.       @bul_st       = 0
  22.       @damagerange  = 20
  23.       @dam          = 100
  24.       @nextpx       = 0
  25.       @nextpy       = 0
  26.       self.x        = -2000
  27.       self.y        = -2000
  28.       update
  29.     end
  30.   
  31.     def moving(spr)
  32.       if @bul_st == 0 #直线
  33.         if (self.x>-@damagerange) and (self.x<640+@damagerange) and
  34.            (self.y>-@damagerange) and (self.y<480+@damagerange)
  35.           self.x += @nextpx
  36.           self.y += @nextpy
  37.         else
  38.           self.x=-2000
  39.           self.y=-2000        
  40.         end
  41.       end
  42.       if @bul_st == 1 #等待
  43.         self.x = spr.x + @nextpx
  44.         self.y = spr.y + @nextpy
  45.       end
  46.     end
  47.     def c10(x,y)
  48.       if @bul_st == 1
  49.         @bul_st = 0
  50.         @nextpx = x
  51.         @nextpy = y
  52.       end
  53.     end
  54. end
复制代码






  1. class Scene_Show
  2.   def main
  3.     @maxbul   =   $maxbul
  4.     @maxenemy =   $maxenemy
  5.     @lastB    =   false #集气相关
  6.     @numB     =   0     #集气相关
  7.    
  8.     @mysprite           = Srpite_aaaagq
  9.       @mysprite         = Srpite_aaaagq.new
  10.       @mysprite.bitmap  = Bitmap.new("Graphics/Battlers/001-Fighter01.png")
  11.       @mysprite.ox      = @mysprite.bitmap.width / 2
  12.       @mysprite.oy      = @mysprite.bitmap.height / 2
  13.       @mysprite.x       = 100
  14.       @mysprite.y       = 100
  15.     @enemy              = [Srpite_aaaagq.new,Srpite_aaaagq.new]
  16.     for i in 0 .. @maxenemy
  17.       @enemy[i]         = Srpite_aaaagq.new
  18.       @enemy[i].bitmap  = Bitmap.new("Graphics/Battlers/075-Devil01")
  19.       @enemy[i].ox      = @enemy[i].bitmap.width / 2
  20.       @enemy[i].oy      = @enemy[i].bitmap.height / 2
  21.       @enemy[i].x       = -2000
  22.       @enemy[i].y       = -2000
  23.     end
  24.       @enemy[0].x       = 580
  25.       @enemy[0].y       = 150
  26.       @enemy[1].x       = 590
  27.       @enemy[1].y       = 400
  28.     @bul                = [Bul_aaaagq.new,Bul_aaaagq.new]
  29.     for i in 0 .. @maxbul
  30.       @bul[i]           = Bul_aaaagq.new
  31.       @bul[i].bitmap    = Bitmap.new("Graphics/Icons/001-Weapon01.png")
  32.       @bul[i].ox        = @bul[i].bitmap.width / 2
  33.       @bul[i].oy        = @bul[i].bitmap.height / 2
  34.       @bul[i].x         = -2000
  35.       @bul[i].y         = -2000
  36.     end
  37.     Audio.bgm_play("bgm30.ogg")
  38.     Graphics.transition
  39.    
  40.     loop do
  41.       # 刷新游戏画面
  42.       Graphics.update
  43.       # 刷新输入信息
  44.       Input.update
  45.       # 刷新画面
  46.       update
  47.       if $scene != self
  48.         break
  49.       end
  50.     end
  51.     alldispose
  52.     Graphics.freeze
  53.   rescue Errno::ENOENT
  54.         Graphics.transition
  55.    
  56.     loop do
  57.       # 刷新游戏画面
  58.       Graphics.update
  59.       # 刷新输入信息
  60.       Input.update
  61.       # 刷新画面
  62.       update
  63.       if $scene != self
  64.         break
  65.       end
  66.     end
  67.     alldispose
  68.     Graphics.freeze

  69.   end

  70.   #------------------------------------------------------------------
  71.   def alldispose
  72.     @mysprite.dispose
  73.     for i in 0 .. @maxenemy
  74.       @enemy[i].dispose
  75.     end
  76.     for i in 0 .. @maxbul
  77.       @bul[i].dispose
  78.     end
  79.   end
  80.   def update
  81.       @mysprite.recover
  82.       
  83.       for i in 0 .. @maxenemy
  84.         for j in 0 .. @maxbul
  85.           if distance(@enemy[i],@bul[j])
  86.             if $伤害显示
  87.               @enemy[i].dam += @bul[j].dam*(150-rand(100))/100
  88.             end
  89.             #@bul[j].x = -2000
  90.             #@bul[j].y = -2000
  91.             @bul[j].init
  92.           end
  93.         end
  94.       end
  95.       for i in 0 .. @maxenemy
  96.         @enemy[i].update
  97.       end
  98.       for i in 0 .. @maxbul
  99.         @bul[i].moving(@mysprite)
  100.       end
  101.       if Input.press?(Input::UP)
  102.           @mysprite.y -= @mysprite.speed
  103.       end
  104.       if Input.press?(Input::DOWN)
  105.           @mysprite.y += @mysprite.speed
  106.       end
  107.       if Input.press?(Input::LEFT)
  108.           @mysprite.x -= @mysprite.speed
  109.       end
  110.       if Input.press?(Input::RIGHT)
  111.           @mysprite.x += @mysprite.speed
  112.       end
  113.       if Input.press?(Input::A)#普通攻击
  114.         onfire(@mysprite,0,0,13,0)
  115.         onfire(@mysprite,0,0,10,2)
  116.         onfire(@mysprite,0,0,10,-2)
  117.         if @maxbul>50
  118.           onfire(@mysprite,0,10,12,0)
  119.           onfire(@mysprite,0,-10,12,0)
  120.           onfire(@mysprite,0,20,11,0)
  121.           onfire(@mysprite,0,-20,11,0)
  122.           onfire(@mysprite,0,50,11,0)
  123.           onfire(@mysprite,0,-50,11,0)
  124.         end
  125.         if @mysprite.wt == 0
  126.           Audio.se_play("Audio/SE/043-Knock04.ogg")
  127.           @mysprite.wt = 100
  128.         end
  129.       end
  130.       if Input.press?(Input::B)#集气攻击
  131.         @lastB = true
  132.         for i in 0 .. 5
  133.           if onfire1(@mysprite, -rand(20), 2*(@numB%50)-50) != -1
  134.             @numB += 1
  135.           end
  136.         end
  137.       elsif @lastB
  138.         @lastB = false
  139.         @numB  = 0
  140.         for i in 0 .. @maxbul
  141.           @bul[i].c10(10+rand(10),-5+rand(10))
  142.         end
  143.         Audio.se_play("Audio/SE/142-Burst02.ogg")
  144.         if @mysprite.wt == 0
  145.           @mysprite.wt = 500
  146.         end
  147.       end
  148.       if Input.press?(Input::C)
  149.         $scene = Scene_Map.new
  150.       end
  151.   end
  152. #-------------------------------功能------------------------------------  
  153.   def onfire(spr,px,py,x,y)
  154.         if spr.wt == 0
  155.           for i in 0 .. @maxbul
  156.             if  @bul[i].x <= 0 or @bul[i].x >= 700
  157.               @bul[i].x = spr.x + px
  158.               @bul[i].y = spr.y + py
  159.               @bul[i].nextpx = x
  160.               @bul[i].nextpy = y
  161.               return i
  162.             end
  163.           end
  164.         end
  165.               return -1
  166.   end
  167.   def onfire1(spr,x,y)
  168.         #if spr.wt == 0
  169.           for i in 0 .. @maxbul
  170.             if  @bul[i].x <= 0 or @bul[i].x >= 700
  171.               @bul[i].x = spr.x + x
  172.               @bul[i].y = spr.y + y
  173.               @bul[i].nextpx = x
  174.               @bul[i].nextpy = y
  175.               @bul[i].bul_st = 1
  176.               return i
  177.             end
  178.           end
  179.         #end
  180.               return -1
  181.   end
  182.   
  183.   def distance(spr,bul)
  184.     if spr.x<-1000 or bul.x<-1000
  185.       return false
  186.     end
  187.     if spr.x>bul.x-bul.damagerange-spr.bitmap.width / 3.0 and spr.x<bul.x+bul.damagerange+spr.bitmap.width / 3.0 and
  188.        spr.y>bul.y-bul.damagerange-spr.bitmap.height / 3.0 and spr.y<bul.y+bul.damagerange+spr.bitmap.height / 3.0
  189.       return true
  190.     else
  191.       return false
  192.     end
  193.   end
  194.   
  195. end
复制代码
『我对你矢志不渝。』
梦石
0
星屑
1918
在线时间
380 小时
注册时间
2012-12-10
回帖
402
 楼主| 发表于 2014-11-2 13:27:24 | 显示全部楼层
没有人知道吗?
『我对你矢志不渝。』
回复

使用道具 举报

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

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部