Project1

标题: 问个问题,顺便庆6R重新建站 [打印本页]

作者: 刹那铃音    时间: 2017-9-27 18:19
标题: 问个问题,顺便庆6R重新建站
请问如何直接用脚本指令将一个角色的jp直接减少或增加常量,或放入一个变量呢
  1. #==============================================================================
  2. #
  3. # ▼ Yanfly Engine Ace - JP Manager v1.00
  4. # -- Last Updated: 2012.01.07
  5. # -- Level: Normal, Hard
  6. # -- Requires: n/a
  7. #
  8. #==============================================================================

  9. $imported = {} if $imported.nil?
  10. $imported["YEA-JPManager"] = true

  11. #==============================================================================
  12. # ▼ Updates
  13. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  14. # 2012.01.07 - Started Script and Finished.
  15. #
  16. #==============================================================================
  17. # ▼ Introduction
  18. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  19. # This script provides a base for JP implementation. JP is a currency similar
  20. # to EXP that's gained through performing actions and leveling up in addition
  21. # to killing enemies. This script provides modifiers that adjust the gains for
  22. # JP through rates, individual gains per skill or item, and per enemy. Though
  23. # this script provides no usage of JP by itself, future Yanfly Engine Ace
  24. # scripts may make use of it.
  25. #
  26. #==============================================================================
  27. # ▼ Instructions
  28. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  29. # To install this script, open up your script editor and copy/paste this script
  30. # to an open slot below ▼ Materials/素材 but above ▼ Main. Remember to save.
  31. #
  32. # -----------------------------------------------------------------------------
  33. # Actor Notetags - These notetags go in the actors notebox in the database.
  34. # -----------------------------------------------------------------------------
  35. # <jp rate: x%>
  36. # Changes the JP earned rate to x%. This affects JP earned and not JP directly
  37. # gained. If this notetag isn't used, the object will default to 100%.
  38. #
  39. # -----------------------------------------------------------------------------
  40. # Class Notetags - These notetags go in the class notebox in the database.
  41. # -----------------------------------------------------------------------------
  42. # <jp rate: x%>
  43. # Changes the JP earned rate to x%. This affects JP earned and not JP directly
  44. # gained. If this notetag isn't used, the object will default to 100%.
  45. #
  46. # -----------------------------------------------------------------------------
  47. # Skill Notetags - These notetags go in the skills notebox in the database.
  48. # -----------------------------------------------------------------------------
  49. # <jp gain: x>
  50. # When the actor successfully hits an target with this action, the actor will
  51. # earn x JP. If this notetag isn't used, the amount of JP earned will equal to
  52. # the ACTION_JP constant in the module.
  53. #
  54. # -----------------------------------------------------------------------------
  55. # Item Notetags - These notetags go in the items notebox in the database.
  56. # -----------------------------------------------------------------------------
  57. # <jp gain: x>
  58. # When the actor successfully hits an target with this action, the actor will
  59. # earn x JP. If this notetag isn't used, the amount of JP earned will equal to
  60. # the ACTION_JP constant in the module.
  61. #
  62. # -----------------------------------------------------------------------------
  63. # Weapon Notetags - These notetags go in the weapon notebox in the database.
  64. # -----------------------------------------------------------------------------
  65. # <jp rate: x%>
  66. # Changes the JP earned rate to x%. This affects JP earned and not JP directly
  67. # gained. If this notetag isn't used, the object will default to 100%.
  68. #
  69. # -----------------------------------------------------------------------------
  70. # Armour Notetags - These notetags go in the armour notebox in the database.
  71. # -----------------------------------------------------------------------------
  72. # <jp rate: x%>
  73. # Changes the JP earned rate to x%. This affects JP earned and not JP directly
  74. # gained. If this notetag isn't used, the object will default to 100%.
  75. #
  76. # -----------------------------------------------------------------------------
  77. # Enemy Notetags - These notetags go in the enemy notebox in the database.
  78. # -----------------------------------------------------------------------------
  79. # <jp gain: x>
  80. # Changes the amount of JP gained for killing the enemy to x. If this notetag
  81. # isn't used, then the default JP gain will be equal to the amount set in the
  82. # module through the constant ENEMY_KILL.
  83. #
  84. # -----------------------------------------------------------------------------
  85. # State Notetags - These notetags go in the states notebox in the database.
  86. # -----------------------------------------------------------------------------
  87. # <jp rate: x%>
  88. # Changes the JP earned rate to x%. This affects JP earned and not JP directly
  89. # gained. If this notetag isn't used, the object will default to 100%.
  90. #
  91. # -----------------------------------------------------------------------------
  92. # Script Calls - These commands are used with script calls.
  93. # -----------------------------------------------------------------------------
  94. # $game_actors[x].earn_jp(y)
  95. # $game_actors[x].earn_jp(y, z)
  96. # This will cause actor x to earn y amount of JP. JP earned will be modified by
  97. # any JP Rate traits provided through notetags. If z is used, z will be the
  98. # class the JP is earned for.
  99. #
  100. # $game_actors[x].gain_jp(y)
  101. # $game_actors[x].gain_jp(y, z)
  102. # This will cause actor x to gain y amount of JP. JP gained this way will not
  103. # be modified by any JP Rate traits provided through notetags. If z is used,
  104. # z will be the class the JP is gained for.
  105. #
  106. # $game_actors[x].lose_jp(y)
  107. # $game_actors[x].lose_jp(y, z)
  108. # This will cause actor x to lose y amount of JP. JP lost this way will not be
  109. # modified by any JP Rate traits provided through notetags. If z is used, z
  110. # will be the class the JP is lost from.
  111. #
  112. #==============================================================================
  113. # ▼ Compatibility
  114. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  115. # This script is made strictly for RPG Maker VX Ace. It is highly unlikely that
  116. # it will run with RPG Maker VX without adjusting.
  117. #
  118. # This script is compatible with Yanfly Engine Ace - Victory Aftermath v1.03+.
  119. # If you wish to have Victory Aftermath display JP gains, make sure the version
  120. # is 1.03+. Script placement of these two scripts don't matter.
  121. #
  122. #==============================================================================

  123. module YEA
  124.   module JP
  125.    
  126.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  127.     # - General JP Settings -
  128.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  129.     # This adjusts the way JP appears visually in your game. Change the icon
  130.     # used and the vocabulary used here. Furthermore, adjust the maximum amount
  131.     # of JP that an actor can have at a time.
  132.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  133.     ICON   = 0           # Icon index used to represent JP.
  134.     VOCAB  = "SP"        # What JP will be called in your game.
  135.     MAX_JP = 99999999    # Maximum JP an actor can have.
  136.    
  137.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  138.     # - Default JP Gain Settings -
  139.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  140.     # The following constants adjust how much JP is earned by default through
  141.     # enemy kills, leveling up, and performing actions.
  142.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  143.     ENEMY_KILL = 30     # JP earned for the whole party.
  144.     LEVEL_UP   = 100    # JP earned when leveling up!
  145.     ACTION_JP  = 0      # JP earned per successful hit.
  146.    
  147.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  148.     # - Victory Message -
  149.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  150.     # This adjusts the victory message shown for the default battle system and
  151.     # the Yanfly Engine Ace - Victory Aftermath script (if used together).
  152.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  153.     VICTORY_MESSAGE   = "%s 获得了 %s %s!"
  154.     VICTORY_AFTERMATH = "+%s%s"
  155.    
  156.   end # JP
  157. end # YEA

  158. #==============================================================================
  159. # ▼ Editting anything past this point may potentially result in causing
  160. # computer damage, incontinence, explosion of user's head, coma, death, and/or
  161. # halitosis so edit at your own risk.
  162. #==============================================================================

  163. module YEA
  164.   module REGEXP
  165.   module BASEITEM
  166.    
  167.     JP_RATE = /<(?:JP_RATE|jp rate):[ ](\d+)([%%])>/i
  168.    
  169.   end # BASEITEM
  170.   module USABLEITEM
  171.    
  172.     JP_GAIN = /<(?:JP_GAIN|jp gain):[ ](\d+)>/i
  173.    
  174.   end # USABLEITEM
  175.   module ENEMY
  176.    
  177.     JP_GAIN = /<(?:JP_GAIN|jp gain):[ ](\d+)>/i
  178.    
  179.   end # ENEMY
  180.   end # REGEXP
  181. end # YEA

  182. #==============================================================================
  183. # ■ Vocab
  184. #==============================================================================

  185. module Vocab
  186.   
  187.   #--------------------------------------------------------------------------
  188.   # new method: self.jp
  189.   #--------------------------------------------------------------------------
  190.   def self.jp
  191.     return YEA::JP::VOCAB
  192.   end
  193.   
  194. end # Vocab

  195. #==============================================================================
  196. # ■ Icon
  197. #==============================================================================

  198. module Icon
  199.   
  200.   #--------------------------------------------------------------------------
  201.   # self.jp
  202.   #--------------------------------------------------------------------------
  203.   def self.jp; return YEA::JP::ICON; end
  204.    
  205. end # Icon

  206. #==============================================================================
  207. # ■ Numeric
  208. #==============================================================================

  209. class Numeric
  210.   
  211.   #--------------------------------------------------------------------------
  212.   # new method: group_digits
  213.   #--------------------------------------------------------------------------
  214.   unless $imported["YEA-CoreEngine"]
  215.   def group; return self.to_s; end
  216.   end # $imported["YEA-CoreEngine"]
  217.    
  218. end # Numeric

  219. #==============================================================================
  220. # ■ DataManager
  221. #==============================================================================

  222. module DataManager
  223.   
  224.   #--------------------------------------------------------------------------
  225.   # alias method: load_database
  226.   #--------------------------------------------------------------------------
  227.   class <<self; alias load_database_jp load_database; end
  228.   def self.load_database
  229.     load_database_jp
  230.     load_notetags_jp
  231.   end
  232.   
  233.   #--------------------------------------------------------------------------
  234.   # new method: load_notetags_jp
  235.   #--------------------------------------------------------------------------
  236.   def self.load_notetags_jp
  237.     groups = [$data_actors, $data_classes, $data_weapons, $data_armors,
  238.       $data_states, $data_enemies, $data_items, $data_skills]
  239.     for group in groups
  240.       for obj in group
  241.         next if obj.nil?
  242.         obj.load_notetags_jp
  243.       end
  244.     end
  245.   end
  246.   
  247. end # DataManager

  248. #==============================================================================
  249. # ■ RPG::BaseItem
  250. #==============================================================================

  251. class RPG::BaseItem
  252.   
  253.   #--------------------------------------------------------------------------
  254.   # public instance variables
  255.   #--------------------------------------------------------------------------
  256.   attr_accessor :jp_rate
  257.   
  258.   #--------------------------------------------------------------------------
  259.   # common cache: load_notetags_jp
  260.   #--------------------------------------------------------------------------
  261.   def load_notetags_jp
  262.     @jp_rate = 1.0
  263.     #---
  264.     self.note.split(/[\r\n]+/).each { |line|
  265.       case line
  266.       #---
  267.       when YEA::REGEXP::BASEITEM::JP_RATE
  268.         @jp_rate = $1.to_i * 0.01
  269.       #---
  270.       end
  271.     } # self.note.split
  272.     #---
  273.   end
  274.   
  275. end # RPG::BaseItem

  276. #==============================================================================
  277. # ■ RPG::UsableItem
  278. #==============================================================================

  279. class RPG::UsableItem < RPG::BaseItem
  280.   
  281.   #--------------------------------------------------------------------------
  282.   # public instance variables
  283.   #--------------------------------------------------------------------------
  284.   attr_accessor :jp_gain
  285.   
  286.   #--------------------------------------------------------------------------
  287.   # common cache: load_notetags_jp
  288.   #--------------------------------------------------------------------------
  289.   def load_notetags_jp
  290.     @jp_gain = YEA::JP::ACTION_JP
  291.     #---
  292.     self.note.split(/[\r\n]+/).each { |line|
  293.       case line
  294.       #---
  295.       when YEA::REGEXP::USABLEITEM::JP_GAIN
  296.         @jp_gain = $1.to_i
  297.       #---
  298.       end
  299.     } # self.note.split
  300.     #---
  301.   end
  302.   
  303. end # RPG::UsableItem

  304. #==============================================================================
  305. # ■ RPG::Enemy
  306. #==============================================================================

  307. class RPG::Enemy < RPG::BaseItem
  308.   
  309.   #--------------------------------------------------------------------------
  310.   # public instance variables
  311.   #--------------------------------------------------------------------------
  312.   attr_accessor :jp_gain
  313.   
  314.   #--------------------------------------------------------------------------
  315.   # common cache: load_notetags_jp
  316.   #--------------------------------------------------------------------------
  317.   def load_notetags_jp
  318.     @jp_gain = YEA::JP::ENEMY_KILL
  319.     #---
  320.     self.note.split(/[\r\n]+/).each { |line|
  321.       case line
  322.       #---
  323.       when YEA::REGEXP::ENEMY::JP_GAIN
  324.         @jp_gain = $1.to_i
  325.       #---
  326.       end
  327.     } # self.note.split
  328.     #---
  329.   end
  330.   
  331. end # RPG::Enemy

  332. #==============================================================================
  333. # ■ BattleManager
  334. #==============================================================================

  335. module BattleManager
  336.   
  337.   #--------------------------------------------------------------------------
  338.   # alias method: display_exp
  339.   #--------------------------------------------------------------------------
  340.   unless $imported["YEA-VictoryAftermath"]
  341.   class <<self; alias battlemanager_display_exp_jp display_exp; end
  342.   def self.display_exp
  343.     battlemanager_display_exp_jp
  344.     gain_jp
  345.   end
  346.   end # $imported["YEA-VictoryAftermath"]
  347.   
  348.   #--------------------------------------------------------------------------
  349.   # new method: gain_jp
  350.   #--------------------------------------------------------------------------
  351.   def self.gain_jp
  352.     amount = $game_troop.jp_total
  353.     fmt = YEA::JP::VICTORY_MESSAGE
  354.     for member in $game_party.members
  355.       member.earn_jp(amount)
  356.       next if $imported["YEA-VictoryAftermath"]
  357.       value = member.battle_jp_earned.group
  358.       $game_message.add('\.' + sprintf(fmt, member.name, value, Vocab::jp))
  359.     end
  360.     wait_for_message unless $imported["YEA-VictoryAftermath"]
  361.   end
  362.   
  363. end # BattleManager

  364. #==============================================================================
  365. # ■ Game_BattlerBase
  366. #==============================================================================

  367. class Game_BattlerBase
  368.   
  369.   #--------------------------------------------------------------------------
  370.   # new method: jpr
  371.   #--------------------------------------------------------------------------
  372.   def jpr
  373.     n = 1.0
  374.     if actor?
  375.       n *= self.actor.jp_rate
  376.       n *= self.class.jp_rate
  377.       for equip in equips
  378.         next if equip.nil?
  379.         n *= equip.jp_rate
  380.       end
  381.     end
  382.     for state in states
  383.       next if state.nil?
  384.       n *= state.jp_rate
  385.     end
  386.     return n
  387.   end
  388.   
  389. end # Game_BattlerBase

  390. #==============================================================================
  391. # ■ Game_Battler
  392. #==============================================================================

  393. class Game_Battler < Game_BattlerBase
  394.   
  395.   #--------------------------------------------------------------------------
  396.   # public instance variables
  397.   #--------------------------------------------------------------------------
  398.   attr_accessor :battle_jp_earned
  399.   
  400.   #--------------------------------------------------------------------------
  401.   # alias method: on_battle_start
  402.   #--------------------------------------------------------------------------
  403.   alias game_battler_on_battle_start_jp on_battle_start
  404.   def on_battle_start
  405.     game_battler_on_battle_start_jp
  406.     @battle_jp_earned = 0
  407.   end
  408.   
  409.   #--------------------------------------------------------------------------
  410.   # alias method: on_battle_end
  411.   #--------------------------------------------------------------------------
  412.   alias game_battler_on_battle_end_jp on_battle_end
  413.   def on_battle_end
  414.     game_battler_on_battle_end_jp
  415.     @battle_jp_earned = 0
  416.   end
  417.   
  418.   #--------------------------------------------------------------------------
  419.   # alias method: item_user_effect
  420.   #--------------------------------------------------------------------------
  421.   alias game_battler_item_user_effect_jp item_user_effect
  422.   def item_user_effect(user, item)
  423.     game_battler_item_user_effect_jp(user, item)
  424.     user.earn_jp(item.jp_gain) if user.actor?
  425.   end
  426.   
  427. end # Game_Battler

  428. #==============================================================================
  429. # ■ Game_Actor
  430. #==============================================================================

  431. class Game_Actor < Game_Battler
  432.   
  433.   #--------------------------------------------------------------------------
  434.   # alias method: setup
  435.   #--------------------------------------------------------------------------
  436.   alias game_actor_setup_jp setup
  437.   def setup(actor_id)
  438.     game_actor_setup_jp(actor_id)
  439.     init_jp
  440.   end
  441.   
  442.   #--------------------------------------------------------------------------
  443.   # new method: init_jp
  444.   #--------------------------------------------------------------------------
  445.   def init_jp
  446.     @jp = {}
  447.     @jp[@class_id] = 0
  448.   end
  449.   
  450.   #--------------------------------------------------------------------------
  451.   # new method: earn_jp
  452.   #--------------------------------------------------------------------------
  453.   def earn_jp(jp, class_id = nil)
  454.     gain_jp(jp * jpr, class_id)
  455.   end
  456.   
  457.   #--------------------------------------------------------------------------
  458.   # new method: gain_jp
  459.   #--------------------------------------------------------------------------
  460.   def gain_jp(jp, class_id = nil)
  461.     init_jp if @jp.nil?
  462.     class_id = @class_id if class_id.nil?
  463.     @jp[class_id] = 0 if @jp[class_id].nil?
  464.     @jp[class_id] += jp.to_i
  465.     @jp[class_id] = [[@jp[class_id], YEA::JP::MAX_JP].min, 0].max
  466.     @battle_jp_earned = 0 if @battle_jp_earned.nil? && $game_party.in_battle
  467.     @battle_jp_earned += jp.to_i if $game_party.in_battle
  468.   end
  469.   
  470.   #--------------------------------------------------------------------------
  471.   # new method: lose_jp
  472.   #--------------------------------------------------------------------------
  473.   def lose_jp(jp, class_id = nil)
  474.     gain_jp(-jp, class_id)
  475.   end
  476.   
  477.   #--------------------------------------------------------------------------
  478.   # new method: jp
  479.   #--------------------------------------------------------------------------
  480.   def jp(class_id = nil)
  481.     class_id = @class_id if class_id.nil?
  482.     @jp[class_id] = 0 if @jp[class_id].nil?
  483.     return @jp[class_id]
  484.   end
  485.   
  486.   #--------------------------------------------------------------------------
  487.   # alias method: level_up
  488.   #--------------------------------------------------------------------------
  489.   alias game_actor_level_up_jp level_up
  490.   def level_up
  491.     game_actor_level_up_jp
  492.     earn_jp(YEA::JP::LEVEL_UP)
  493.   end
  494.   
  495. end # Game_Actor

  496. #==============================================================================
  497. # ■ Game_Enemy
  498. #==============================================================================

  499. class Game_Enemy < Game_Battler
  500.   
  501.   #--------------------------------------------------------------------------
  502.   # new method: jp
  503.   #--------------------------------------------------------------------------
  504.   def jp
  505.     return enemy.jp_gain
  506.   end
  507.   
  508. end # Game_Enemy

  509. #==============================================================================
  510. # ■ Game_Troop
  511. #==============================================================================

  512. class Game_Troop < Game_Unit
  513.   
  514.   #--------------------------------------------------------------------------
  515.   # new method: jp_total
  516.   #--------------------------------------------------------------------------
  517.   def jp_total
  518.     dead_members.inject(0) {|r, enemy| r += enemy.jp }
  519.   end
  520.   
  521. end # Game_Troop

  522. #==============================================================================
  523. # ■ Window_Base
  524. #==============================================================================

  525. class Window_Base < Window
  526.   
  527.   #--------------------------------------------------------------------------
  528.   # new method: draw_actor_jp
  529.   #--------------------------------------------------------------------------
  530.   def draw_actor_jp(actor, dx, dy, dw = 112)
  531.     draw_icon(Icon.jp, dx + dw - 24, dy) if Icon.jp > 0
  532.     dw -= 24 if Icon.jp > 0
  533.     change_color(system_color)
  534.     draw_text(dx, dy, dw, line_height, Vocab::jp, 2)
  535.     dw -= text_size(Vocab::jp).width
  536.     change_color(normal_color)
  537.     draw_text(dx, dy, dw, line_height, actor.jp.group, 2)
  538.   end
  539.   
  540.   #--------------------------------------------------------------------------
  541.   # new method: draw_actor_jp_class
  542.   #--------------------------------------------------------------------------
  543.   def draw_actor_jp_class(actor, class_id, dx, dy, dw = 112)
  544.     draw_icon(Icon.jp, dx + dw - 24, dy) if Icon.jp > 0
  545.     dw -= 24 if Icon.jp > 0
  546.     change_color(system_color)
  547.     draw_text(dx, dy, dw, line_height, Vocab::jp, 2)
  548.     dw -= text_size(Vocab::jp).width
  549.     change_color(normal_color)
  550.     draw_text(dx, dy, dw, line_height, actor.jp(class_id).group, 2)
  551.   end
  552.   
  553. end # Window_Base

  554. #==============================================================================
  555. #
  556. # ▼ End of File
  557. #
  558. #==============================================================================
复制代码

又一次新建站···不过貌似没预注册,所以经验什么的都没了,但是project1真的熟悉死了
作者: fux2    时间: 2017-9-27 20:12
  1. $game_actors[角色ID].gain_jp(100)
复制代码

作者: 百里_飞柳    时间: 2017-9-27 23:18
备注里写的很清楚了

actor的实例的jp方法可以直接获得该角色的jp值




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