Project1

标题: 【vx脚本】主角选择画面+获取技能物品作用对象 [打印本页]

作者: 企鹅达达    时间: 2010-11-9 21:17
标题: 【vx脚本】主角选择画面+获取技能物品作用对象
本帖最后由 企鹅达达 于 2010-11-14 20:43 编辑

两个扩展性很好的脚本。非常简单好用。
1. 队伍中的主角选择画面,选择结果(主角id及队伍序号)带入变量(默认19、20号变量,66、68行更改)。使用方法 $scene = Scene_ActorChoice.new
  1. #==============================================================================
  2. # ■ Scene_ActorChoice
  3. #------------------------------------------------------------------------------
  4. # アクターの選択後、選択したアクターのID、選択時のインデックスを變數に代入します。
  5. #
  6. #「使用方法」
  7. # イベントコマンドのスクリプトで、$scene = Scene_ActorChoice.new記入
  8. # 使用時のウィンドウは Window_MenuStatus を使用しました。
  9. # 變數にアクターIDや選択時のインデックスを代入した後には条件分岐で使用してください。
  10. # 注意:選択時のインデックスは実際選択したのが何番目とかには関係なく-1をしてください。
  11. # 例)選択時三番目のキャラを選択した時のインデックスは2になります。
  12. #
  13. #「カスタマイズ」
  14. # 66, 68行
  15. # $game_variables[n]の nに 代入する變數IDを記入してください。
  16. #
  17. # ※このスクリプトのベースは Scene_Menu です。
  18. #
  19. #==============================================================================

  20. class Scene_ActorChoice < Scene_Base
  21.   #--------------------------------------------------------------------------
  22.   # ● OBJECTの初期化
  23.   #     menu_index : カーソルの初期位置
  24.   #--------------------------------------------------------------------------
  25.   def initialize(menu_index = 0)
  26.     @status_window_index = menu_index
  27.   end
  28.   #--------------------------------------------------------------------------
  29.   # ● 開示處理
  30.   #--------------------------------------------------------------------------
  31.   def start
  32.     super
  33.     create_menu_background
  34.     @status_windows = Window_MenuStatus.new(0, 0)
  35.     @status_windows.active = true
  36.     @status_windows.index = @status_window_index
  37.   end
  38.   #--------------------------------------------------------------------------
  39.   # ● 終了處理
  40.   #--------------------------------------------------------------------------
  41.   def terminate
  42.     super
  43.     dispose_menu_background
  44.     @status_windows.dispose
  45.   end
  46.   #--------------------------------------------------------------------------
  47.   # ● Update
  48.   #--------------------------------------------------------------------------  
  49.   def update
  50.     super
  51.     update_menu_background
  52.     @status_windows.update
  53.     update_actor_selection_achoice
  54.   end
  55.   #--------------------------------------------------------------------------
  56.   # ● アクター選択の更新
  57.   #--------------------------------------------------------------------------
  58.   def update_actor_selection_achoice
  59.     if Input.trigger?(Input::B)
  60.       Sound.play_cancel
  61.       $scene = Scene_Map.new
  62.     elsif Input.trigger?(Input::C)
  63.       $game_party.last_actor_index = @status_windows.index
  64.       # 19番の變數に選択したキャラの選択時のインテックス(-1)を代入する。
  65.       $game_variables[19] = @status_windows.index
  66.       # 20番の變數に選択したキャラのアクターIDを代入する。
  67.       $game_variables[20] = $game_party.members[@status_windows.index].id
  68.       Sound.play_decision
  69.       $scene = Scene_Map.new
  70.     end
  71.   end
  72. end



  73. ########################################################
  74. # 制作 : dest21c (韓国)    [email protected]          #
  75. ########################################################
复制代码
2. 技能和物品对象获取,可以将作用的主角对象、作用的敌人队伍序号带入变量,用开关判定作用对象为主角还是敌人、技能对象是否成功击中(使用)。脚本中设定两个变量和开关。默认变量11、12,开关13、14
  1. #==============================================================================
  2. #    Record Target Variable
  3. #    Version: 1.0
  4. #    Author: modern algebra (rmrk.net)
  5. #    Date: August 24, 2009
  6. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  7. #  Description:
  8. #
  9. #    This script allows you to save the ID of an actor or enemy targetted by a
  10. #   skill or item to a designated variable. It is perfect for use in
  11. #   Common Events that are called by using items or weapons, as you can add
  12. #   additional effects that effect the target through the common event.
  13. #
  14. #    Note that it only works for targetted items and skills - if the scope has
  15. #   multiple targets, than it will not update the values.
  16. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  17. #  Instructions:
  18. #
  19. #    Place this script above Main and below Materials.
  20. #
  21. #    To choose which variables to use for this script, go down to lines 41 & 43
  22. #   and alter the values of SELECTED_ACTOR_VARIABLE & SELECTED_ENEMY_VARIABLE.
  23. #   Note that when selecting an actor, it saves the ID of the actor, but when
  24. #   selecting an enemy, it returns the INDEX of the enemy in the troop. This
  25. #   follows the lead of event commands in how actors are selected. There are
  26. #   also two switches you can set at lines 46 & 49; TARGET_CLASS_SWITCH_ID
  27. #   records whether the user of the skill is an actor or an enemy, while
  28. #   NOHIT_SWITCH_ID records whether the target was hit by the item or skill.
  29. #
  30. #    Using the script is fairly easy. Simply have the item or skill call a
  31. #   common event, and in that comment you can use the values of the variables
  32. #   and switches to determine the effect.
  33. #==============================================================================

  34. #==============================================================================
  35. # ** Global Constants
  36. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  37. #  new constants - RTV_SELECTED_ACTOR_VARIABLE, RTV_SELECTED_ENEMY_VARIABLE
  38. #==============================================================================
  39. # The ID of the variable to which the selected actor ID will be saved.
  40. RTV_SELECTED_ACTOR_VARIABLE = 11
  41. # The ID of the variable to which the selected enemy INDEX will be saved.
  42. RTV_SELECTED_ENEMY_VARIABLE = 12
  43. # The ID of a switch which tells if the target of a skill is an actor or an enemy
  44. #  ON => Enemy is target; OFF => Actor is target(此处有误,MS是倒过来)
  45. RTV_TARGET_CLASS_SWITCH_ID = 13
  46. # The ID of a switch which records whether or not the skill or item hit its
  47. #  target. ON => Target missed; OFF => Target hit
  48. RTV_NOHIT_SWITCH_ID = 14

  49. #==============================================================================
  50. # ** Game_Battler
  51. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  52. #  Summary of Changes:
  53. #    aliased method - item_effect, skill_effect
  54. #==============================================================================

  55. class Game_Battler
  56.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  57.   # * Item Effect
  58.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  59.   alias modnalgb_st_efctitm_actrvar_0bg3 item_effect
  60.   def item_effect (user, item, *args)
  61.     # Run Original Method
  62.     modnalgb_st_efctitm_actrvar_0bg3 (user, item, *args)
  63.     rtv_set_target_to_variable (item)
  64.   end
  65.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  66.   # * Skill Effect
  67.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  68.   alias algabramod_skleffect_rtv_3jc2 skill_effect
  69.   def skill_effect (user, skill, *args)
  70.     # Run Original Method
  71.     algabramod_skleffect_rtv_3jc2 (user, skill, *args)
  72.     rtv_set_target_to_variable (skill)
  73.   end
  74.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  75.   # Set Target to Variable
  76.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  77.   def rtv_set_target_to_variable (item)
  78.     if item.for_one?
  79.       if self.actor?
  80.         $game_variables[RTV_SELECTED_ACTOR_VARIABLE] = self.id
  81.         $game_switches[RTV_TARGET_CLASS_SWITCH_ID] = true
  82.       else
  83.         $game_variables[RTV_SELECTED_ENEMY_VARIABLE] = self.index
  84.         $game_switches[RTV_TARGET_CLASS_SWITCH_ID] = false
  85.       end
  86.       $game_switches[RTV_NOHIT_SWITCH_ID] = @missed || @evaded
  87.     end
  88.   end
  89. end
复制代码
Project1.rar (240.75 KB, 下载次数: 401)
作者: 仲秋启明    时间: 2010-11-14 18:37
建议咱发个工程
作者: 企鹅达达    时间: 2010-11-14 19:42
回复 仲秋启明 的帖子

既然你用的是“咱”,那就麻烦你了;P
作者: 风雪优游    时间: 2010-11-16 12:02
有奇妙作用的脚本……
作者: 退屈£无聊    时间: 2010-11-16 20:12
是的呀是的呀..
原来以为地球村是个没内涵的地方- - 看来我错了= =
作者: 冰舞蝶恋    时间: 2010-12-5 22:04
看帖不回是罪人。。阿门!
作者: 一瞬间的幻觉    时间: 2010-12-12 07:29
看不太懂,怎么用?用在哪?




欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1