查看: 2186|回复: 2

[已经解决] 求ひきも記的アイコンポップ脚本添加开关控制

[复制链接]

漾夕☽星化残月☾

梦石
0
星屑
8611
在线时间
3858 小时
注册时间
2015-5-12
回帖
2022

剧作品鉴家

发表于 2016-1-4 16:50:58 | 显示全部楼层 |阅读模式

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

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

×
{:2_276:} 如题的说。。。

求ひきも記的アイコンポップ脚本添加开关控制
我试了好多方法全都失败了...

就是比如说当6号开关关闭时、角色获得物品不会有提示。
6号开关开启时、角色获得物品会有提示(脚本功能)。
麻烦各位了...OTZ

[pre lang="ruby"]


#==============================================================================
# ★ RGSS3_アイコンポップ Ver1.2
#==============================================================================
=begin

作者:tomoaky
webサイト:ひきも記 (http://hikimoki.sakura.ne.jp/)

イベントの頭上に任意のアイコンを表示することができます。

イベントコマンド『スクリプト』で以下を実行してください
  pop_icon(event_id, icon_id, duration)
  
  event_id 番のイベントの頭上に icon_id 番のアイコンが表示されます。
  event_id に 0 を指定すると実行中のイベント自身が対象となり、
  -1 を指定すればプレイヤーが対象となります。
  duration は省略することが可能です、その場合は 120 となります。
  
  例)pop_icon(-1, 17, 300)
  プレイヤーに戦闘不能アイコンを5秒間(300フレーム)表示します
  
  アイコン表示中に pop_icon コマンドを実行しても効果はありません。
  すぐに次のアイコンを表示したい場合は、delete_icon コマンドで
  アイコンを削除してから pop_icon コマンドを実行してください。
  
  例)delete_icon(-1)
  プレイヤーに表示中のアイコンを削除する
  
おまけとしてイベントコマンド『アイテムの増減』『武器の増減』『防具の増減』が
実行されたとき、自動でアイコンを表示する機能が付いています。
  アイコンを表示する対象はゲーム変数(初期設定では6番)で変更が可能です、
  値は pop_icon コマンドにおける event_id と同様ですが、-2 以下を指定することで
  機能をオフにすることができます。
  

使用するゲーム変数(初期設定)
  0006
  
2012.01.19  Ver1.2
 ・表示中のアイコンポップを削除する delete_icon コマンドを追加
 ・自律移動【カスタム】のスクリプトコマンドで
  アイコンポップ機能が動作しない不具合を修正
  
2011.12.21  Ver1.11
 ・並列処理で event_id に 0 を指定するとアイコンが表示されない不具合を修正
  
2011.12.17  Ver1.1
 ・コマンドに表示時間を指定する機能を追加しました

2011.12.15  Ver1.0
  公開

=end

#==============================================================================
# □ 設定項目
#==============================================================================
module TMICPOP
  GRAVITY = 24              # アイコンにかかる重力
  SPEED   = -320            # アイコンの初速(Y方向)
  
  VN_TARGET = 6             # 自動ポップ対象設定として扱うゲーム変数番号
end

#==============================================================================
# □ コマンド
#==============================================================================
module TMICPOP
module Commands
  #--------------------------------------------------------------------------
  # ○ アイコンポップの開始
  #--------------------------------------------------------------------------
  def pop_icon(event_id, icon_id, duration = 120)
    target = get_character(event_id)
    return unless target
    target.icpop_id = icon_id
    target.icpop_duration = duration
  end
  #--------------------------------------------------------------------------
  # ○ アイコンポップの削除
  #--------------------------------------------------------------------------
  def delete_icon(event_id)
    target = get_character(event_id)
    return unless target
    target.icpop_delete_flag = true
  end
end
end # module TMICPOP

#==============================================================================
# ■ Game_CharacterBase
#==============================================================================
class Game_CharacterBase
  #--------------------------------------------------------------------------
  # ● 公開インスタンス変数
  #--------------------------------------------------------------------------
  attr_accessor :icpop_id                 # アイコンポップ ID
  attr_accessor :icpop_duration           # アイコンポップ 表示時間
  attr_accessor :icpop_delete_flag        # アイコンポップ 削除フラグ
  #--------------------------------------------------------------------------
  # ● 公開メンバ変数の初期化
  #--------------------------------------------------------------------------
  alias tmicpop_game_characterbase_init_public_members init_public_members
  def init_public_members
    tmicpop_game_characterbase_init_public_members
    @icpop_id = 0
    @icpop_duration = 0
    @icpop_delete_flag = false
  end
end

#==============================================================================
# ■ Sprite_Character
#==============================================================================
class Sprite_Character
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #     character : Game_Character
  #--------------------------------------------------------------------------
  alias tmicpop_sprite_character_initialize initialize
  def initialize(viewport, character = nil)
    @icpop_duration = 0
    tmicpop_sprite_character_initialize(viewport, character)
  end
  #--------------------------------------------------------------------------
  # ● 解放
  #--------------------------------------------------------------------------
  alias tmicpop_sprite_character_dispose dispose
  def dispose
    dispose_icpop
    tmicpop_sprite_character_dispose
  end
  #--------------------------------------------------------------------------
  # ● フレーム更新
  #--------------------------------------------------------------------------
  alias tmicpop_sprite_character_update update
  def update
    update_icpop
    tmicpop_sprite_character_update
  end
  #--------------------------------------------------------------------------
  # ● 新しいエフェクトの設定
  #--------------------------------------------------------------------------
  alias tmicpop_sprite_character_setup_new_effect setup_new_effect
  def setup_new_effect
    tmicpop_sprite_character_setup_new_effect
    if !@icpop_sprite && @character.icpop_id > 0
      @icpop_id = @character.icpop_id
      @character.icpop_id = 0
      start_icpop
    end
  end
  #--------------------------------------------------------------------------
  # ○ アイコンポップ表示の開始
  #--------------------------------------------------------------------------
  def start_icpop
    dispose_icpop
    @icpop_duration = @icpop_duration_max = @character.icpop_duration
    @icpop_sprite = ::Sprite.new(viewport)
    @icpop_sprite.bitmap = Cache.system("IconSet")
    @icpop_sprite.src_rect.set(@icpop_id % 16 * 24, @icpop_id / 16 * 24, 24, 24)
    @icpop_sprite.ox = 12
    @icpop_sprite.oy = 24
    @icpop_y_plus = 0
    @icpop_y_speed = TMICPOP::SPEED
    update_icpop
  end
  #--------------------------------------------------------------------------
  # ○ アイコンポップの解放
  #--------------------------------------------------------------------------
  def dispose_icpop
    @character.icpop_delete_flag = false
    if @icpop_sprite
      @icpop_sprite.dispose
      @icpop_sprite = nil
    end
  end
  #--------------------------------------------------------------------------
  # ○ アイコンポップの更新
  #--------------------------------------------------------------------------
  def update_icpop
    if @icpop_duration > 0
      @icpop_duration -= 1
      if @character.icpop_delete_flag
        @icpop_duration = 0
        dispose_icpop
      elsif @icpop_duration > 0
        @icpop_sprite.x = x
        @icpop_y_plus += @icpop_y_speed
        @icpop_y_speed += TMICPOP::GRAVITY
        if @icpop_y_plus > 0
          @icpop_y_plus = 0 - @icpop_y_plus
          @icpop_y_speed = 0 - @icpop_y_speed / 2
        end
        @icpop_sprite.y = y - height + (@icpop_y_plus / 256)
        @icpop_sprite.z = z + 200
        @icpop_sprite.opacity = (@icpop_duration < 16 ? @icpop_duration * 16 :
          (@icpop_duration_max - @icpop_duration) * 32)
      else
        dispose_icpop
        @character.icpop_id = 0
      end
    end
  end
end

#==============================================================================
# ■ Game_Event
#==============================================================================
class Game_Event
  include TMICPOP::Commands
  #--------------------------------------------------------------------------
  # ○ キャラクターの取得
  #     param : -1 ならプレイヤー、0 ならこのイベント、それ以外はイベント ID
  #--------------------------------------------------------------------------
  def get_character(param)
    if param < 0
      $game_player
    else
      $game_map.events[param > 0 ? param : @id]
    end
  end
end

#==============================================================================
# ■ Game_Interpreter
#==============================================================================
class Game_Interpreter
  include TMICPOP::Commands
  #--------------------------------------------------------------------------
  # ● アイテムの増減
  #--------------------------------------------------------------------------
  alias tmicpop_game_interpreter_command_126 command_126
  def command_126
    tmicpop_game_interpreter_command_126
    value = operate_value(@params[1], @params[2], @params[3])
    if value > 0
      if $game_variables[TMICPOP::VN_TARGET] >= -1 && !$game_party.in_battle
        item = $data_items[@params[0]]
        pop_icon($game_variables[TMICPOP::VN_TARGET], item.icon_index)
      end
    end
  end
  #--------------------------------------------------------------------------
  # ● 武器の増減
  #--------------------------------------------------------------------------
  alias tmicpop_game_interpreter_command_127 command_127
  def command_127
    tmicpop_game_interpreter_command_127
    value = operate_value(@params[1], @params[2], @params[3])
    if value > 0
      if $game_variables[TMICPOP::VN_TARGET] >= -1 && !$game_party.in_battle
        item = $data_weapons[@params[0]]
        pop_icon($game_variables[TMICPOP::VN_TARGET], item.icon_index)
      end
    end
  end
  #--------------------------------------------------------------------------
  # ● 防具の増減
  #--------------------------------------------------------------------------
  alias tmicpop_game_interpreter_command_128 command_128
  def command_128
    tmicpop_game_interpreter_command_128
    value = operate_value(@params[1], @params[2], @params[3])
    if value > 0
      if $game_variables[TMICPOP::VN_TARGET] >= -1 && !$game_party.in_battle
        item = $data_armors[@params[0]]
        pop_icon($game_variables[TMICPOP::VN_TARGET], item.icon_index)
      end
    end
  end
end
[/pre]

无限の剣制

梦石
0
星屑
10450
在线时间
5019 小时
注册时间
2013-2-28
回帖
4942

开拓者贵宾

发表于 2016-1-4 17:31:12 | 显示全部楼层
  1. module TMICPOP::Commands
  2.   ID = 1 # 这里改ID编号
  3.   def pop_icon(event_id, icon_id, duration = 120)
  4.     return if $game_switches[ID]
  5.     target = get_character(event_id)
  6.     return unless target
  7.     target.icpop_id = icon_id
  8.     target.icpop_duration = duration
  9.   end
  10. end
复制代码
未测试

点评

试了一下、原来是开/关作用反了、实际上还是有效的...  发表于 2016-1-4 20:47
这个脚本的最后面追加上这一段  发表于 2016-1-4 19:48
呃、这个是插在什么地方?脚本页的最后还是mian里面都不行的样子...  发表于 2016-1-4 19:26

评分

参与人数 2星屑 +10 梦石 +1 收起 理由
taroxd + 1 认可答案
御曹司 + 10 认可答案

查看全部评分

回复

使用道具 举报

梦石
0
星屑
50
在线时间
21 小时
注册时间
2015-12-31
回帖
9
发表于 2016-1-4 20:05:44 | 显示全部楼层
看了下代码,这是个有个初始速度的图片(精灵)掉落的动画效果。
如果不想看到动画,可以改变以下两个参数(选择一种即可):
1,调用pop_icon方法时(73行)第三个参数duration为0,也可以target.icpop_duration = 0。
2,或者在pop_icon方法获取target后,加上target.icpop_delete_flag=true。

楼主说的6号开关存储值是第一个pop_icon方法参数event_id,这个事件的位置是图片(精灵)开始掉落的初始位置,所以只需要找一些特殊值(必须大于0)判断event_id,加上以上的条件即可。

评分

参与人数 2星屑 +10 梦石 +1 收起 理由
taroxd + 1 我很赞同
御曹司 + 10 很有帮助!

查看全部评分

回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部