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

Project1

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

[已经解决] 关于战斗指针脚本

[复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
107 小时
注册时间
2014-1-19
帖子
13
跳转到指定楼层
1
发表于 2014-4-26 18:26:08 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
本帖最后由 Deeeeemo 于 2014-4-26 20:34 编辑
  1. #战斗时用箭头指定敌人
  2. #==============================================================================
  3. # +++ MOG - Battle Cursor (1.0) +++
  4. #==============================================================================
  5. # By Moghunter
  6. # [url]http://www.atelier-rgss.com/[/url]
  7. #==============================================================================
  8. # Sistema de cursor animado de batalha nos sprites dos battlers.
  9. #==============================================================================
  10. # Arquivo necessário. (Graphics/System)
  11. #
  12. # Battle_Cursor.png
  13. #
  14. #==============================================================================

  15. #==============================================================================
  16. # ■ CURSOR SETTING
  17. #==============================================================================
  18. module MOG_BATTLE_CURSOR
  19.   #Definição da posição do cursor em relação ao alvo.
  20.   CURSOR_POSITION = [-38, -22]
  21.   #Definição da posição do nome do alvo.
  22.   CURSOR_NAME_POSITION = [-7,34]
  23.   #Ativar efeito deslizar.
  24.   CURSOR_SLIDE_EFFECT = true
  25.   #Ativar animação de levitação.
  26.   CURSOR_FLOAT_EFFECT = true
  27.   #Definição da prioridade do cursor.
  28.   CURSOR_Z = 0
  29. end

  30. #==============================================================================
  31. # ■ Game Temp
  32. #==============================================================================
  33. class Game_Temp

  34.   attr_accessor :battle_cursor

  35.   #--------------------------------------------------------------------------
  36.   # ● Initialize
  37.   #--------------------------------------------------------------------------  
  38.   alias mog_battle_cursor_initialize initialize
  39.   def initialize
  40.       @battle_cursor = [0,0,false,""]
  41.       mog_battle_cursor_initialize
  42.   end  

  43. end

  44. #==============================================================================
  45. # ■ Spriteset Battle Cursor
  46. #==============================================================================
  47. class Sprite_Battle_Cursor < Sprite
  48.   include MOG_BATTLE_CURSOR

  49.   #--------------------------------------------------------------------------
  50.   # ● Initialize
  51.   #--------------------------------------------------------------------------        
  52.   def initialize(viewport = nil)
  53.       super(viewport)
  54.       $game_temp.battle_cursor = [0,0,false,""]
  55.       self.bitmap = Cache.system("Battle_Cursor")
  56.       self.visible = $game_temp.battle_cursor[2]
  57.       self.z = CURSOR_Z
  58.       self.z = 10 if $mog_rgss3_battle_hud != nil
  59.       @cursor_name = Sprite.new
  60.       @cursor_name.bitmap = Bitmap.new(120,32)
  61.       @cursor_name.z = self.z + 1
  62.       @cursor_name.bitmap.font.size = 18
  63.       @cursor_name_enemy = $game_temp.battle_cursor[3]
  64.       @cursor_name_position = [CURSOR_NAME_POSITION[0] ,CURSOR_NAME_POSITION[1]]
  65.       @cursor_float = [0,0]
  66.       refresh_cursor_name
  67.   end

  68.   #--------------------------------------------------------------------------
  69.   # ● Dispose Sprite
  70.   #--------------------------------------------------------------------------         
  71.   def dispose
  72.       super
  73.       dispose_sprite_cursor
  74.   end

  75.   #--------------------------------------------------------------------------
  76.   # ● Dispose Sprite Cursor
  77.   #--------------------------------------------------------------------------            
  78.   def dispose_sprite_cursor
  79.       if @cursor_name != nil
  80.          @cursor_name.bitmap.dispose
  81.          @cursor_name.dispose
  82.       end
  83.       self.bitmap.dispose
  84.   end

  85.   #--------------------------------------------------------------------------
  86.   # ● Refresh Cursor Name
  87.   #--------------------------------------------------------------------------              
  88.   def refresh_cursor_name
  89.       @cursor_name_enemy = $game_temp.battle_cursor[3]
  90.       @cursor_name.bitmap.clear
  91.       @cursor_name.bitmap.draw_text(0,0,120,32,@cursor_name_enemy.to_s,1)
  92.   end

  93.   #--------------------------------------------------------------------------
  94.   # ● Update
  95.   #--------------------------------------------------------------------------            
  96.   def update
  97.       super
  98.       update_sprite_cursor
  99.   end

  100.   #--------------------------------------------------------------------------
  101.   # ● Update Sprite Cursor
  102.   #--------------------------------------------------------------------------              
  103.   def update_sprite_cursor
  104.       update_visible
  105.       update_cursor_float_effect
  106.       execute_move(0,self.x,$game_temp.battle_cursor[0])
  107.       execute_move(1,self.y,$game_temp.battle_cursor[1] + @cursor_float[1])
  108.       update_sprite_name
  109.   end

  110.   #--------------------------------------------------------------------------
  111.   # ● Update Visible
  112.   #--------------------------------------------------------------------------               
  113.   def update_visible
  114.       self.visible = $game_temp.battle_cursor[2]
  115.       if !self.visible
  116.          self.x = -64
  117.          self.y = -64
  118.       end  
  119.   end  

  120.   #--------------------------------------------------------------------------
  121.   # ● Update Sprite Name
  122.   #--------------------------------------------------------------------------               
  123.   def update_sprite_name
  124.       return if @cursor_name == nil
  125.       refresh_cursor_name  if @cursor_name_enemy != $game_temp.battle_cursor[3]
  126.       @cursor_name.x = self.x + @cursor_name_position[0]
  127.       @cursor_name.y = self.y + @cursor_name_position[1]
  128.       @cursor_name.opacity = self.opacity
  129.       @cursor_name.visible = self.visible
  130.   end  

  131.   #--------------------------------------------------------------------------
  132.   # ● Update Cursor Float Effect
  133.   #--------------------------------------------------------------------------              
  134.   def update_cursor_float_effect
  135.       return if !CURSOR_FLOAT_EFFECT
  136.       @cursor_float[0] += 1
  137.       case @cursor_float[0]
  138.         when 0..30
  139.           @cursor_float[1] += 0.25
  140.         when 31..60
  141.           @cursor_float[1]  -= 0.25
  142.         else
  143.           @cursor_float[0] = 0
  144.           @cursor_float[1] = 0
  145.       end        
  146.   end  

  147.   #--------------------------------------------------------------------------
  148.   # ● Execute Move
  149.   #--------------------------------------------------------------------------      
  150.   def execute_move(type,cp,np)
  151.       sp = 5 + ((cp - np).abs / 5)
  152.       if cp > np
  153.          cp -= sp
  154.          cp = np if cp < np
  155.       elsif cp < np
  156.          cp += sp
  157.          cp = np if cp > np
  158.       end     
  159.       self.x = cp if type == 0
  160.       self.y = cp if type == 1
  161.   end      

  162. end

  163. #==============================================================================
  164. # ■ Spriteset Battle
  165. #==============================================================================
  166. class Spriteset_Battle

  167.   #--------------------------------------------------------------------------
  168.   # ● Initialize
  169.   #--------------------------------------------------------------------------      
  170.   alias mog_battle_cursor_initialize initialize
  171.   def initialize
  172.       mog_battle_cursor_initialize
  173.       create_cursor
  174.   end

  175.   #--------------------------------------------------------------------------
  176.   # ● Dispose
  177.   #--------------------------------------------------------------------------      
  178.   alias mog_battle_cursor_dispose dispose
  179.   def dispose
  180.       mog_battle_cursor_dispose
  181.       dispose_cursor
  182.   end

  183.   #--------------------------------------------------------------------------
  184.   # ● Update
  185.   #--------------------------------------------------------------------------         
  186.   alias mog_battle_cursor_update update
  187.   def update
  188.       mog_battle_cursor_update
  189.       update_battle_cursor
  190.   end  

  191.   #--------------------------------------------------------------------------
  192.   # ● Create_Cursor
  193.   #--------------------------------------------------------------------------        
  194.   def create_cursor
  195.       return if @battle_cursor != nil
  196.       @battle_cursor = Sprite_Battle_Cursor.new      
  197.   end

  198.   #--------------------------------------------------------------------------
  199.   # ● Dispose Cursor
  200.   #--------------------------------------------------------------------------        
  201.   def dispose_cursor
  202.       return if @battle_cursor == nil
  203.       @battle_cursor.dispose
  204.   end  

  205.   #--------------------------------------------------------------------------
  206.   # ● Update Battle Cursor
  207.   #--------------------------------------------------------------------------         
  208.   def update_battle_cursor
  209.       return if @battle_cursor == nil
  210.       @battle_cursor.update      
  211.   end

  212. end

  213. #==============================================================================
  214. # ■ Battle Cursor Index
  215. #==============================================================================
  216. module Battle_Cursor_index
  217.   include MOG_BATTLE_CURSOR
  218.   #--------------------------------------------------------------------------
  219.   # ● Check Index Limit
  220.   #--------------------------------------------------------------------------      
  221.   def check_index_limit
  222.       self.index = 0 if self.index >= item_max
  223.       self.index = (item_max - 1) if self.index < 0
  224.   end      

  225.   #--------------------------------------------------------------------------
  226.   # ● Set Cursor Position Enemy
  227.   #--------------------------------------------------------------------------   
  228.   def set_cursor_position_enemy
  229.       return if !self.active
  230.       $game_temp.battle_cursor[0] = $game_troop.alive_members[self.index].screen_x + CURSOR_POSITION[0] rescue nil
  231.       $game_temp.battle_cursor[1] = $game_troop.alive_members[self.index].screen_y + CURSOR_POSITION[1] rescue nil
  232.       $game_temp.battle_cursor[3] = $game_troop.alive_members[self.index].name rescue nil
  233.       $game_temp.battle_cursor = [0,0,false,0] if $game_temp.battle_cursor[0] == nil
  234.   end

  235.   #--------------------------------------------------------------------------
  236.   # ● Set Cursor Position Actor
  237.   #--------------------------------------------------------------------------   
  238.   def set_cursor_position_actor
  239.       return if !self.active
  240.       $game_temp.battle_cursor[0] = $game_party.members[self.index].screen_x + CURSOR_POSITION[0] rescue nil
  241.       $game_temp.battle_cursor[1] = $game_party.members[self.index].screen_y + CURSOR_POSITION[1] rescue nil
  242.       $game_temp.battle_cursor[3] = $game_party.members[self.index].name rescue nil
  243.       $game_temp.battle_cursor = [0,0,false,0] if $game_temp.battle_cursor[0] == nil
  244.   end  

  245.   #--------------------------------------------------------------------------
  246.   # ● Process Cursor Move
  247.   #--------------------------------------------------------------------------
  248.   def process_cursor_move
  249.       return unless cursor_movable?
  250.       last_index = @index
  251.       cursor_move_index(+1) if Input.repeat?(:DOWN)
  252.       cursor_move_index(-1) if Input.repeat?(:UP)
  253.       cursor_move_index(+1) if Input.repeat?(:RIGHT)
  254.       cursor_move_index(-1) if Input.repeat?(:LEFT)
  255.       if @Index= last_index
  256.          Sound.play_cursor
  257.       end
  258.   end

  259.   #--------------------------------------------------------------------------
  260.   # ● Process Cursor Move Index
  261.   #--------------------------------------------------------------------------  
  262.   def cursor_move_index(value = 0)
  263.       self.index += value
  264.       check_index_limit
  265.   end

  266. end

  267. #==============================================================================
  268. # ■ Window_BattleActor
  269. #==============================================================================
  270. class Window_BattleActor < Window_BattleStatus
  271.   include Battle_Cursor_index

  272.   #--------------------------------------------------------------------------
  273.   # ● Update
  274.   #--------------------------------------------------------------------------  
  275.   def update
  276.       super
  277.       set_cursor_position_actor
  278.   end  

  279.   #--------------------------------------------------------------------------
  280.   # ● Show
  281.   #--------------------------------------------------------------------------
  282.   alias mog_battle_cursor_show show
  283.   def show
  284.       if @info_viewport
  285.          set_cursor_position_actor
  286.          $game_temp.battle_cursor[2] = true
  287.       end
  288.       mog_battle_cursor_show
  289.   end

  290.   #--------------------------------------------------------------------------
  291.   # ● Hide
  292.   #--------------------------------------------------------------------------
  293.   alias mog_battle_cursor_hide hide
  294.   def hide
  295.       if @info_viewport
  296.           $game_temp.battle_cursor[2] = false
  297.       end
  298.       mog_battle_cursor_hide
  299.   end  

  300. end

  301. #==============================================================================
  302. # ■ Window_BattleEnemy
  303. #==============================================================================
  304. class Window_BattleEnemy < Window_Selectable
  305.   include Battle_Cursor_index

  306.   #--------------------------------------------------------------------------
  307.   # ● Update
  308.   #--------------------------------------------------------------------------  
  309.   def update
  310.       super
  311.       set_cursor_position_enemy
  312.   end

  313.   #--------------------------------------------------------------------------
  314.   # ● Show
  315.   #--------------------------------------------------------------------------
  316.   alias mog_battle_cursor_show show
  317.   def show
  318.       if @info_viewport
  319.          set_cursor_position_enemy
  320.          $game_temp.battle_cursor[2] = true
  321.       end
  322.       mog_battle_cursor_show
  323.   end

  324.   #--------------------------------------------------------------------------
  325.   # ● Hide
  326.   #--------------------------------------------------------------------------
  327.   alias mog_battle_cursor_hide hide
  328.   def hide
  329.       if @info_viewport
  330.           $game_temp.battle_cursor[2] = false
  331.       end
  332.       mog_battle_cursor_hide
  333.   end  

  334. end

  335. $mog_rgss3_battle_cursor = true
复制代码
长话短说
这个战斗指针脚本在运用时会出现奇怪的声音,怎么把这个声音去掉或者改动呢?PS:关于这个声音描述真的很困难,请大大新建个工程试一下。
感激不尽  

Lv3.寻梦者 (版主)

…あたしは天使なんかじゃないわ

梦石
0
星屑
2208
在线时间
4033 小时
注册时间
2010-10-4
帖子
10779

开拓者贵宾

2
发表于 2014-4-26 20:01:28 | 只看该作者
删掉第285行试试看?

评分

参与人数 1星屑 +105 收起 理由
Sion + 105 认可答案

查看全部评分

回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
107 小时
注册时间
2014-1-19
帖子
13
3
 楼主| 发表于 2014-4-26 20:34:03 | 只看该作者
taroxd 发表于 2014-4-26 20:01
删掉第285行试试看?

额,居然成功了,大神我爱死你了
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-9-25 07:20

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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