查看: 3655|回复: 11

[原创发布] 用伤害/恢复的血量,计算得到的经验值

[复制链接]
梦石
0
星屑
34511
在线时间
5096 小时
注册时间
2012-11-19
回帖
4715

开拓者

发表于 2020-8-14 11:09:08 | 显示全部楼层 |阅读模式

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

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

×
@alexncf125   从以前的废弃仓库里刨了出来。

  1. #==============================================================================
  2. # 〓 以伤害敌方的血量来计算获得的经验值 〓
  3. #==============================================================================
  4. # 该脚本的 EXP 计算方式:
  5. # 1,战斗中 伤害/恢复 被攻击方的血量,通过下面设置的算式计算成 EXP 给予 攻击方 。
  6. # 2,若被攻击方在当次行动中死亡,攻击方将会获得其在 数据库设置的默认经验 。
  7. #==============================================================================
  8. module XR_DamageExp
  9.   # 恢复 HP 是否计入EXP计算(是:true; 否:false)
  10.   Renew_vaild = true
  11.   
  12.   # 计算 EXP 的算式
  13.   # 简写:
  14.   # a => 攻击方
  15.   # b => 被攻击方
  16.   # d => 当次行动 减少/增加 的被攻击方的血量
  17.   # v => 游戏变量
  18.   # s => 游戏开关
  19.   # p => 游戏队伍对象
  20.   #
  21.   Formula = "d / 10"
  22. #==============================================================================
  23.   #--------------------------------------------------------------------------
  24.   def self.count_current_exp(subject, target, damage)
  25.     return 0 if damage == 0 || !Renew_vaild && damage < 0
  26.     a = subject
  27.     b = target
  28.     d = damage.abs
  29.     v = $game_variables
  30.     s = $game_switches
  31.     p = $game_party
  32.     exp = eval(Formula) || 0
  33.     exp += target.exp if target.dead? && !target.is_a?(Game_Actor)
  34.     return exp
  35.   end
  36. end
  37. #==============================================================================
  38. module BattleManager
  39.   #--------------------------------------------------------------------------
  40.   def self.gain_exp
  41.     $game_party.all_members.each{|actor| actor.apply_xr_exp }
  42.     wait_for_message
  43.   end
  44.   #--------------------------------------------------------------------------
  45.   def self.display_exp
  46.     $game_party.all_members.each do |actor|
  47.       next if actor.xr_exp == 0
  48.       text = actor.name + "获得" + sprintf(Vocab::ObtainExp, actor.xr_exp)
  49.       $game_message.add('\.' + text)
  50.     end
  51.   end
  52. end
  53. #==============================================================================
  54. class Game_Battler
  55.   #--------------------------------------------------------------------------
  56.   alias xr_de_item_apply item_apply
  57.   def item_apply(user, item)
  58.     last_hp = self.hp
  59.     xr_de_item_apply(user, item)
  60.     record_user_xr_exp(user, last_hp - self.hp)
  61.   end
  62.   #--------------------------------------------------------------------------
  63.   def record_user_xr_exp(user, damage)
  64.     return if !user.is_a?(Game_Actor)
  65.     exp = XR_DamageExp.count_current_exp(user, self, damage)
  66.     user.record_xr_exp(exp)
  67.   end
  68. end
  69. #==============================================================================
  70. class Game_Actor
  71.   #--------------------------------------------------------------------------
  72.   def xr_exp
  73.     return @xr_exp || 0
  74.   end
  75.   #--------------------------------------------------------------------------
  76.   def record_xr_exp(exp)
  77.     @xr_exp = xr_exp + exp
  78.   end
  79.   #--------------------------------------------------------------------------
  80.   def apply_xr_exp
  81.     gain_exp(xr_exp)
  82.   end
  83.   #--------------------------------------------------------------------------
  84.   alias xr_de_on_battle_end on_battle_end
  85.   def on_battle_end
  86.     @xr_exp = 0
  87.     xr_de_on_battle_end
  88.   end
  89. end
  90. #==============================================================================
  91. # end
  92. #==============================================================================
复制代码

评分

参与人数 1赞 +1 收起 理由
alexncf125 + 1 精品文章+认可答案+塞糖

查看全部评分

xp vx va mv  va mz 各类型脚本/插件定制
梦石
0
星屑
30103
在线时间
5741 小时
注册时间
2016-3-8
回帖
1662
发表于 2020-8-14 13:18:46 | 显示全部楼层
本帖最后由 alexncf125 于 2020-8-16 10:09 编辑

ヾ(。◕◡◕。)ノ谢谢大神~!

测试了一会,发觉好像不是"以角色打掉敌人血量的百分比来获得对应经验"

大神的效果是这样子的(Formula = "d")
敌人有一个(称之E),血量是20,经验值是64
角色有三个,分别称为A,B,C
A打掉E十点血,C打掉E三点血,B打掉E七点血
A,B,C分别会获得10,71,3点经验值

于是我改成如下的样子
  1. Formula = "d"
  2.     #================================================= =============================
  3.       #------------------------------------------------- -------------------------
  4.       def self.count_current_exp(subject, target, damage)
  5.         return 0 if damage == 0 || !Renew_vaild && damage < 0
  6.         a = subject
  7.         b = target
  8.         d = damage.abs
  9.         v = $game_variables
  10.         s = $game_switches
  11.         p = $game_party
  12.         exp = eval(Formula) || 0
  13.         exp = exp * target.exp / target.mhp if !target.is_a?(Game_Actor)
  14. #~        exp += target.exp if target.dead? && !target.is_a?(Game_Actor)
  15.         return exp.round        #return exp.to_i
  16.       end
  17.     end
复制代码


出来的效果却是这样子(return exp.to_i)

敌人有一个(称之E),血量是19,经验值是64
角色有三个,分别称为A,B,C
A打掉E六点血,B打掉E九点血,C打掉E四点血
A,B,C分别会获得20,30,13点经验值

32+22+9 = 63

(return exp.round)
敌人有一个(称之E),血量是20,经验值是64
角色有三个,分别称为A,B,C
A打掉E六点血,B打掉E九点血,C打掉E五点血
A,B,C分别会获得18,27,15点经验值

18+27+15 = 60

为什么都不会是64呢??

点评

喔喔喔,原来是先得转浮点数算,最后gain_exp(xr_exp.round)才对,明白了明白了,谢谢大佬  发表于 2020-8-14 16:08
算式 d / b.mhp * b.exp 不就行了?要小数就转浮点数精确算。难道非要给写死成百分比么?  发表于 2020-8-14 15:06
算式给你写出来就是你自己写的。  发表于 2020-8-14 15:03
回复

使用道具 举报

梦石
0
星屑
30103
在线时间
5741 小时
注册时间
2016-3-8
回帖
1662
发表于 2020-8-15 06:39:13 | 显示全部楼层
本帖最后由 alexncf125 于 2020-8-16 10:10 编辑

能请教一个问题么...我在用战斗胜利评级脚本...
之后只是把552行的actor.gain_exp_cpv($game_troop.exp_total, rate)
更改成actor.gain_exp_cpv(actor.xr_exp, rate)
怎么影响了821-823行的计算??现在角色没要升级,也会显示"等级提升!!"...(824行那里变得都是else那部分)
  1. ###--------------------------------------------------------------------------###
  2. #  战斗胜利评级脚本                                                      #
  3. #  Version 2.1e                                                                #
  4. #                                                                              #
  5. #      Credits:                                                                #
  6. #  Original code by: Neon Black                                                #
  7. #  Modified by:                                                                #
  8. #                                                                              #
  9. #  This work is licensed under the Creative Commons Attribution-NonCommercial  #
  10. #  3.0 Unported License. To view a copy of this license, visit                 #
  11. #  [url]http://creativecommons.org/licenses/by-nc/3.0/.[/url]                             #
  12. #  Permissions beyond the scope of this license are available at               #
  13. #  [url]http://cphouseset.wordpress.com/liscense-and-terms-of-use/.[/url]                 #
  14. #                                                                              #
  15. #      Contact:                                                                #
  16. #  NeonBlack - neonblack23@live.com (e-mail) or "neonblack23" on skype         #
  17. ###--------------------------------------------------------------------------###

  18. ###--------------------------------------------------------------------------###
  19. #      Revision information:                                                   #
  20. #  V2.1 - 11.16.2012                                                           #
  21. #   Added grade requirement for drops                                          #
  22. #   Fixed an issue where drop rate was not figured properly                    #
  23. #  V2.0 - Finished 8.11.2012                                                   #
  24. #   Added level up windows                                                     #
  25. #   Created score items and Grade module                                       #
  26. #   Numerous other bugfixes and changes                                        #
  27. #  V1.1b - 6.26.2012                                                           #
  28. #   Fixed an error related to exp gain display                                 #
  29. #  V1.1 - 6.21.2012                                                            #
  30. #   Added rank sprite effect                                                   #
  31. #  V1.0 - 6.19.2012                                                            #
  32. #   Wrote and debugged main script                                             #
  33. ###--------------------------------------------------------------------------###

  34. ###--------------------------------------------------------------------------###
  35. #      Compatibility:                                                          #
  36. #  This script has been tested to work with Yanfly's battle engine (just the   #
  37. #  base engine) and Yami's PCTB.  If you have any issue, let me know and I     #
  38. #  will address them asap.                                                     #
  39. #  Due to the number of new windows, I will only list methods in already       #
  40. #  existing objects here and not any of the newly created objects.             #
  41. #                                                                              #
  42. #  Alias       - BattleManager: setup, play_battle_bgm                         #
  43. #                Game_Battler: execute_damage                                  #
  44. #                Game_Enemy: initialize                                        #
  45. #                Game_Actor: level_up                                          #
  46. #                Scene_Battle: update_pctb_speed, dispose_all_windows,         #
  47. #                              use_item                                        #
  48. #                DataManager: load_database                                    #
  49. #  Overwrites  - BattleManager: process_victory, play_battle_end_me,           #
  50. #                               gain_gold, gain_drop_items, gain_exp           #
  51. #                Game_Troop: make_drop_items                                   #
  52. #                Game_Enemy: make_drop_items                                   #
  53. #                Scene_Battle: update                                          #
  54. #  New Objects - BattleManager: old_levels, old_skills, victory_phase?,        #
  55. #                               skip?, victory_end                             #
  56. #                Game_Troop: check_boss                                        #
  57. #                Game_Actor: gain_exp_cpv, last_level_exp                      #
  58. #                Scene_Battle: close_status_window, exp_window_update,         #
  59. #                              update_window_rates, update_scores,             #
  60. #                              show_victory_windows, create_leveled_windows,   #
  61. #                              pack_and_send, remove_sprite, drop_items        #
  62. #                RPG::UsableItem: karma_modif                                  #
  63. #                RPG::Enemy: add_drops                                         #
  64. #                DataManager: make_extra_drops                                 #
  65. ###--------------------------------------------------------------------------###

  66. ###--------------------------------------------------------------------------###
  67. #      Instructions:                                                           #
  68. #  Place this script in the "Materials" section of the scripts above main.     #
  69. #  This script requires you to set several settings for the script to work     #
  70. #  properly.  The screen modifies the end of battle to allow a victory screen  #
  71. #  to appear.  This script also has several notebox tags that can be added to  #
  72. #  define changes to the grade and one note tag that will allow you to define  #
  73. #  additional monster drops.                                                   #
  74. ###-----                                                                -----###
  75. #                                                                              #
  76. #      敌人备注:                                                   #
  77. #                                                                              #
  78. #   drop[i:1:1:100] 或 drop[i:1:1]                                           #
  79. #               可以为敌人添加额外的掉落物品. 以上两种格式都行  #
  80. #               第一个参数是物品类型,可以是 "i", "a", 或  "w" ,分别代表 "物品",
  81. #               "护甲", 和 "武器".  第二个是物品id.  第三个是掉落几率.       #
  82. #               x分之1的概率,x=1时代表必定掉落,数字越大,掉落率越低.        #
  83. #               最后一个参数是可选的,代表战斗分数要求,胜利后评价的分数必须大于
  84. #               某个数,才会掉落该物品 .   
  85. #
  86. #   score[1]  - 该怪物每死一只,评价分数就加1.         #
  87. #               你可以把1替换为其他数字
  88. #
  89. #   onehit[1]  - 该怪物每被我方技能命中一次,评价分数就加1.  
  90. #                请注意,多段伤害的技能只会触发一次,附加死亡状态的技能不会触发   #
  91. #                在下面你可以设定默认每一次命中会获得的分数,优先级低于本敌人备注.                                                       #
  92. ###-----                                                                -----###
  93. #                                                                              #
  94. #      物品/技能备注:                                            #
  95. #                                                                              #
  96. #   score[+1]  - 使用该物品/技能后评级分数+1,如果是 score[-20] 则分数-20                 #
  97. ###--------------------------------------------------------------------------###

  98. ###--------------------------------------------------------------------------###
  99. #      Config:                                                                 #
  100. #  These are the default values used by several of the functions in the        #
  101. #  script.  You may change these values as you find your game requires in      #
  102. #  order to give the player a better playing experience based on your game.    #
  103. #                                                                              #
  104. module CP       # Do not edit                                                  #
  105. module VICTORY  #  these two lines.                                            #
  106. #                                                                              #
  107. ###-----                                                                -----###
  108. # 跳过评级BGM的开关,开关开启时不会播放评级BGM                                #
  109. SKIP_SWITCH = 5 # 默认 = 5                                                  #
  110. #                                                                              #
  111.           #
  112. USE_MUSIC = false # 是否播放评级BGM 默认 = true                                               #
  113. VICTORY_MUSIC = "" # 评级BGM文件名  默认 = "Scene4"   如果要静音请设定为nil                               #
  114. MSX_VOL = 100 # 音量  默认 = 100                                                  #
  115. MSX_PIT = 100 # 音调  默认 = 100                                                  #
  116. #                                                                              #
  117. # 是否播放数据库里设定战斗胜利ME,true时会在评级BGM之前播放                  #
  118. USE_ME = false # 默认 = false                                               #
  119. #                                                                              #
  120. # exp值槽颜色                                              #
  121. EXP_GAUGE_1 = 30 # 颜色1 默认 = 30                                                #
  122. EXP_GAUGE_2 = 31 # 颜色2 默认 = 31                                                #
  123. EXP_ADDED = 17 # 增长部分的颜色 默认 = 17                                                  #
  124. #                                                                              #
  125. # 是否对调下方左右两个窗口的位置                   #
  126. FLIP_LOWER = false # 默认 = false                                           #
  127. #                                                                              #
  128. # 设定升级后回复hp/mp的模式                                                                   #
  129. #  0 = 升级后不会回复.                       #
  130. #  1 = 升级后根据角色hpmp的增加量,回复部分hpmp.                #
  131. #  2 = 升级后全回复.                 #
  132. HP_HEAL_TYPE = 0 # 升级后hp回复模式  默认 = 0                                                 #
  133. MP_HEAL_TYPE = 0 # 升级后hp回复模式  默认 = 0                                                 #
  134. #                                                                              #
  135. # 设定显示的文字.                                               #
  136. LEVEL_UP = "等级提升!!" # 默认 = "Level Up!!"                               #
  137. SPOILS = "战利品" # 默认 = "Spoils"                                         #
  138. EXP_NAME = "EXP" # 默认 = "EXP"                                             #
  139. DEALT_NAME = "造成伤害" # 默认 = "Dealt"                                       #
  140. RECIEVED_NAME = "受到伤害" # 默认 = "Recieved"                              #
  141. TURNS_NAME = "回合数" # 默认 = "Turns"                                       #
  142. RANK_NAME = "评级" # 默认 = "Rank"                                         #
  143. NO_DROPS = "无战利品" # 默认 = "No drops recieved"                 #
  144. #                                                                              #
  145. ###-----                                                                -----###
  146. # 是否显示升级窗口                                   #
  147. LVL_UP_ENABLE = true # 默认 = true                                          #
  148. #                                                                              #
  149.          #
  150. LVL_SFX = "Item3" # 升级音效 默认 = "Item3" 想静音请设定为nil                                         #
  151. LVL_VOL = 80 # 音量 默认 = 80                                                    #
  152. LVL_PIT = 100 # 音调 默认 = 100                                                  #
  153. #                                                                              #
  154. # 学会技能时显示的文字                    #
  155. NEW_SKILLS = "学会技能:" # 默认 = "Learned:"                                 #
  156. MORE_SKILLS = "和其他 %s 个技能" # 默认 = "And %s more skills"            #
  157. #                                                                              #
  158. ###-----                                                                -----###
  159.                                                              #
  160. USE_IMAGES = false # 是否使用图片替代评级文字 默认 = false                                           #
  161. IMAGE_NAME = "Rank" # 评级图片文件名的前缀 默认 = "Rank" 如果获得评级C
  162. #                   #则会显示 RankC.png
  163. #                                                                              #
  164. #            #
  165. IMAGE_SFX = "Shot2" # 评级音效 默认 = "Shot2"  想静音请设定为nil                                         #
  166. SFX_VOL = 100 # 音量 默认 = 100                                                  #
  167. SFX_PIT = 100 # 音调 默认 = 100                                                  #
  168. #                                                                              #
  169. # 设定评级,必须按从上到下,从小到大的顺序:                                                     #
  170. #    ["评级",  要求分数,  获得exp比率,  获得金钱比率, 获得战利品率,  文字颜色],            #
  171. # 评级 - 请写在双引号里      #
  172. # 要求分数 - 达到该评级需要的最低分数,请确定第一个评级的要求分数为 "0".                                           #
  173. # 获得exp比率 - 默认值为 100 ,如果设定为200,代表获得双倍exp,下面两个比率同理.                                              #
  174. # 获得金钱比率 - 默认值为 100.                                             #
  175. # 获得战利品率 - 默认值为 100,不影响同一物品的掉落次数,仅影响单个物品的掉落概率.                                                  #
  176. # 文字颜色 - 文字颜色,和文本颜色一样.         #
  177. RANKS =[ # Do not edit this line.                                              #

  178.   ["E",   0, 100, 100, 100, 18],
  179.   ["D", 100, 100, 105, 100, 20],
  180.   ["C", 150, 100, 110, 105,  4],
  181.   ["B", 250, 105, 110, 110, 21],
  182.   ["A", 400, 115, 115, 115,  3],
  183.   ["S", 700, 125, 125, 125, 17],
  184.   
  185. ] # Do not edit this line.                                                     #
  186. #                                                                              #
  187. # 设定伤害率对应的获得分数       #
  188. # 给你一个公式:伤害率 = 造成伤害 / 受到伤害 *100%
  189. # 举个栗子,假如玩家受到 140 点伤害,并且造成200点伤害,
  190. # 伤害率 = 200/140*100% = 142 ,对应下表142在100~150之间,此时获得的分数
  191. # 算到较小的区间,所以最终获得的分数为50
  192. #    格式为:                                                         #
  193. #    [伤害率,  获得分数],                                                         #
  194. DAMAGE_POINTS =[ # Do not edit this line.                                      #

  195.   [ 50,  20],
  196.   [ 80,  30],
  197.   [100,  50],
  198.   [150,  75],
  199.   [200, 100],
  200.   [300, 200],

  201. ] # Do not edit this line.                                                     #
  202. #                                                                              #
  203. # 以下是特殊情况会获得的的分数,那一项你不需要就把那一项设定为"0".                   #
  204. #                                                                              #
  205. # 在同一回合中消灭所有敌人.                                #
  206. SINGLE_TURN = 150 # 默认 = 150                                              #
  207. # 消灭boss (请在敌人特性中设定死亡方式为boss. 此分数一场战斗中只会增加一次
  208. # 就算同一敌群有多个boss也一样.      #
  209. BOSS_POINTS = 200 # 默认 = 200                                              #
  210. # 全程无伤                                 #
  211. NO_DAMAGE = 100 # 默认 = 100                                                #
  212. # 战斗结束时全员满HP.                              #
  213. FULL_HP = 50 # 默认 = 50                                                    #
  214. # 一击必杀(只用一个技能就消灭一个敌人),对添加死亡状态的技能无效                #
  215. ONE_HIT = 40 # 默认 = 40                                                    #
  216. ###--------------------------------------------------------------------------###

  217. ###--------------------------------------------------------------------------###
  218. #      A note to scripters:                                                    #
  219. #  As of version 2.0 I have made it possible to add custom score items to be   #
  220. #  used in battle.  These scores are handled by the "Grade" module.  If you    #
  221. #  have created a new score item you want to use, you can add it to the Grade  #
  222. #  module by using the script call "Grade.new_score(:foo, Bar)" where ":foo"   #
  223. #  is the key you will use to access the object and "Bar" is the name of the   #
  224. #  new objects class (in this case, the defining line for the object would be  #
  225. #  "class Bar < Score_Base").  You can then reach this score object at any     #
  226. #  time by using the script call "Grade.score[:foo]".  To see the base score   #
  227. #  object or any of the pre-made score object, scroll down.  The score         #
  228. #  objects have been placed at the top of the script.                          #
  229. ###--------------------------------------------------------------------------###


  230. ###--------------------------------------------------------------------------###
  231. #  The following lines are the actual core code of the script.  While you are  #
  232. #  certainly invited to look, modifying it may result in undesirable results.  #
  233. #  Modify at your own risk!                                                    #
  234. ###--------------------------------------------------------------------------###


  235. end  ## Close the VICTORY module.
  236. end  ## Close the CP module.


  237. ##-----
  238. ## This is a basic score item.  There are 3 main parts to this.  The initialize
  239. ## part which defines each of the score variables to be used at the start, the
  240. ## update score part, which can be used at any time to get the current score
  241. ## the item will add, and the total part, which is used by the Grade module to
  242. ## get the final value.  You can use "attr_accessor" to create values that can
  243. ## be adjusted at any time or you can create methods to adjust different aspects
  244. ## of the score object.
  245. ##-----
  246. class Score_Base  ## A score item.  Holds and adjusts an aspect of score.
  247.   def initialize
  248.     @score = 0  ## Sets the score to 0 at the start.
  249.   end
  250.   
  251.   def update_score  ## Objects used to modify the score.
  252.     return 0
  253.   end
  254.   
  255.   def total  ## Create and return the score.
  256.     update_score
  257.     return @score
  258.   end
  259. end

  260. class Score_Damage < Score_Base
  261.   attr_accessor :dealt
  262.   attr_accessor :recieved
  263.   attr_accessor :onehit
  264.   
  265.   def initialize  ## Holds dealt and recieved damage as well as one hit scores.
  266.     super         ## Creates a score based on dealt and recieved ratio.
  267.     @dealt = 0
  268.     @recieved = 0
  269.     @onehit = 0
  270.   end
  271.   
  272.   def update_score
  273.     res = super
  274.     if @recieved == 0
  275.       CP::VICTORY::DAMAGE_POINTS.each {|point| res += point[1]}
  276.     else
  277.       dr = (@dealt * 100 / @recieved)
  278.       CP::VICTORY::DAMAGE_POINTS.each do |point|
  279.         next if dr < point[0]
  280.         res += point[1]
  281.       end
  282.     end
  283.     res += CP::VICTORY::NO_DAMAGE if @recieved == 0
  284.     res += @onehit
  285.     @score = res
  286.   end
  287. end

  288. class Score_HP < Score_Base
  289.   def initialize  ## Holds the hp at the start of battle.
  290.     super         ## Not technically used, but checks max hp at end of battle.
  291.     @start_hp = get_party_hp
  292.   end
  293.   
  294.   def get_party_hp
  295.     return 0 if $game_party.battle_members.empty?
  296.     result = 0
  297.     $game_party.battle_members.each do |member|
  298.       result += member.hp
  299.     end
  300.     return result
  301.   end
  302.   
  303.   def get_max_hp
  304.     return 0 if $game_party.battle_members.empty?
  305.     result = 0
  306.     $game_party.battle_members.each do |member|
  307.       result += member.mhp
  308.     end
  309.     return result
  310.   end
  311.   
  312.   def update_score
  313.     res = super
  314.     res += CP::VICTORY::FULL_HP if get_party_hp == get_max_hp
  315.     @score = res
  316.   end
  317. end

  318. class Score_Troop < Score_Base
  319.   def update_score  ## Gets score values from the existance of boss monsters
  320.     res = super     ## as well as adding custom scores per monster.
  321.     res += CP::VICTORY::BOSS_POINTS if $game_troop.check_boss
  322.     res += CP::VICTORY::SINGLE_TURN if $game_troop.turn_count == 1
  323.     $game_troop.members.each {|foe| res += foe.add_score}
  324.     @score = res
  325.   end
  326. end

  327. class Score_Skill < Score_Base
  328.   attr_accessor :karma
  329.   
  330.   def initialize
  331.     super
  332.     @karma = 0
  333.   end
  334.   
  335.   def update_score
  336.     res = super
  337.     res += @karma
  338.     @score = res
  339.   end
  340. end

  341. module Grade
  342.   def self.reset  ## Holds score objects, score, and grades.
  343.     @rate = CP::VICTORY::RANKS[0]
  344.     @score = 0
  345.     create_score_items
  346.   end
  347.   
  348.   def self.create_score_items  ## Creates the default score items.
  349.     @score_items = {}
  350.     new_score(:damage, Score_Damage)
  351.     new_score(:hp,     Score_HP)
  352.     new_score(:troop,  Score_Troop)
  353.     new_score(:skill,  Score_Skill)
  354.   end
  355.   
  356.   def self.new_score(key, scr)  ## Adds a custom score item.
  357.     @score_items[key] = scr.new
  358.   end
  359.   
  360.   def self.update_score  ## Creates a score.
  361.     return 0 if @score_items.empty?
  362.     val = 0
  363.     @score_items.each do |key, score|
  364.       val += score.total
  365.     end
  366.     @score = val
  367.   end
  368.   
  369.   def self.update_rate  ## Updates the rank and grade.
  370.     update_score
  371.     rank_top = 0
  372.     CP::VICTORY::RANKS.each do |rank|
  373.       next if rank[1] > @score
  374.       if rank[1] > rank_top
  375.         @rate = rank
  376.         rank_top = rank[1]
  377.       end
  378.     end
  379.   end
  380.   
  381.   def self.score  ## Returns the score.
  382.     return @score
  383.   end
  384.   
  385.   def self.rate(key = nil)  ## Gets bits of all of the rate.
  386.     update_rate
  387.     case key
  388.     when :exp
  389.       return @rate[2]
  390.     when :gold
  391.       return @rate[3]
  392.     when :drop
  393.       return @rate[4]
  394.     else
  395.       return @rate
  396.     end
  397.   end
  398.   
  399.   def self.score_items  ## Gets all score items for usage.
  400.     return @score_items
  401.   end
  402. end

  403. ##-----
  404. ## End of score object.  The rest of the script is below.
  405. ##-----

  406. module CP
  407. module VICTORY
  408. SCORE  = /SCORE\[(\d+)\]/i
  409. KARMA  = /SCORE\[(\+|\-)?(\d+)\]/i
  410. DROPS  = /DROP\[(\w+):(\d+):(\d+):?(\d*)\]/i
  411. ONEHIT = /ONEHIT\[(\d+)\]/i
  412. end  ## Used for added drops.
  413. end

  414. $imported = {} if $imported == nil
  415. $imported["CP_VICTORY"] = 2.1

  416. module BattleManager
  417.   class << self
  418.   
  419.   ## Aliased to add certain new settings to the module.
  420.   alias setup_cp_vict setup unless $@
  421.   def setup(troop_id, can_escape = true, can_lose = false)
  422.     Grade.reset
  423.     setup_cp_vict(troop_id, can_escape, can_lose)
  424.     @victory = false
  425.     @played_bgm = 0
  426.     @old_levels = {}; @old_skills = {}
  427.     $game_party.all_members.each do |actr|
  428.       id = actr.actor_id; lvl = actr.level; skl = actr.skills
  429.       @old_levels[id] = lvl; @old_skills[id] = skl
  430.     end
  431.   end
  432.   
  433.   ## Gets the level or skills of the actors from before battle.
  434.   def old_levels(id); return @old_levels[id]; end
  435.   def old_skills(id); return @old_skills[id]; end
  436.   
  437.   ## Helps determine if the victory screen is active.
  438.   def victory_phase?
  439.     @phase == :victory
  440.   end
  441.   
  442.   ## Determine if all musics should be skipped.
  443.   def skip?
  444.     $game_switches[CP::VICTORY::SKIP_SWITCH]
  445.   end
  446.   
  447.   ## Aliased to skip bgm change if the switch is flipped.
  448.   alias play_battle_bgm_cpv play_battle_bgm unless $@
  449.   def play_battle_bgm
  450.     play_battle_bgm_cpv unless skip?
  451.   end
  452.   
  453.   ## Overwritten for the new victory screen.
  454.   def process_victory
  455.     return if @victory; @victory = true
  456.     $game_system.battle_end_me.play if CP::VICTORY::USE_ME && !skip?
  457.     RPG::BGM.fade(500) unless skip? || CP::VICTORY::USE_ME
  458.     20.times do; Graphics.update; end
  459.     SceneManager.scene.close_status_window
  460.     Audio.return_audio if $imported["CP_CROSSFADE"]
  461.     play_battle_end_me unless skip?  ## Skip the bgm change again.
  462.     @phase = :victory
  463.     SceneManager.scene.show_victory_windows
  464.     exp = gain_exp
  465.     gold = gain_gold
  466.     gain_drop_items
  467.     turns = $game_troop.turn_count
  468.     dlt = Grade.score_items[:damage].dealt
  469.     rcv = Grade.score_items[:damage].recieved
  470.     SceneManager.scene.update_scores(dlt, rcv, turns)
  471.     SceneManager.scene.update_window_rates(exp, gold, Grade.rate[4])
  472.     SceneManager.scene.exp_window_update(exp)
  473.     return true
  474.   end
  475.   
  476.   ## Added to actually leave battle.
  477.   def victory_end
  478.     RPG::BGM.fade(500) unless skip?
  479.     20.times do; Graphics.update; end
  480.     SceneManager.return
  481.     battle_end(0)
  482.     replay_bgm_and_bgs unless skip? || $BTEST
  483.   end
  484.   
  485.   ## Skipped if music is not made to change.
  486.   def play_battle_end_me
  487.     return if @played_bgm > 1
  488.     @played_bgm += CP::VICTORY::USE_ME ? 1 : 2
  489.     Audio.bgm_stop
  490.     if CP::VICTORY::USE_MUSIC
  491.       mus = CP::VICTORY::VICTORY_MUSIC
  492.       vol = (CP::VICTORY::USE_ME && @played_bgm == 1) ? 0 : CP::VICTORY::MSX_VOL
  493.       pit = CP::VICTORY::MSX_PIT
  494.       RPG::BGM.new(mus, vol, pit).play unless mus.nil?
  495.     else
  496.       $game_system.battle_end_me.play
  497.       replay_bgm_and_bgs unless $BTEST
  498.     end
  499.   end
  500.   
  501.   ## Adjusts the gold rate.
  502.   def gain_gold
  503.     if $game_troop.gold_total > 0
  504.       rate = Grade.rate(:gold)
  505.       gold = $game_troop.gold_total
  506.       gold = gold * rate / 100
  507.       $game_party.gain_gold(gold)
  508.     else
  509.       gold = 0
  510.     end
  511.     return gold
  512.   end
  513.   
  514.   ## Adjusts the drop rate.
  515.   def gain_drop_items
  516.     drops = []
  517.     rate = Grade.rate(:drop)
  518.     $game_troop.make_drop_items(rate).each do |item|
  519.       $game_party.gain_item(item, 1)
  520.       drops.push(item)
  521.     end
  522.     SceneManager.scene.drop_items(drops)
  523.   end
  524.   
  525.   ## Adjusts the exp rate.
  526.   def gain_exp
  527.     rate = Grade.rate(:exp)
  528.     $game_party.all_members.each do |actor|
  529.       actor.gain_exp_cpv(actor.xr_exp, rate)
  530. #~       actor.gain_exp_cpv($game_troop.exp_total, rate)
  531.     end
  532.     return $game_troop.exp_total * rate / 100
  533.   end

  534.   end
  535. end

  536. class Game_Troop < Game_Unit
  537.   ## Checks if a monster has the boss kill flag set.
  538.   def check_boss
  539.     members.each do |enemy|
  540.       next unless enemy.collapse_type == 1
  541.       return true
  542.     end
  543.     return false
  544.   end
  545.   
  546.   ## Adjusted drop rate.
  547.   def make_drop_items(rate = 100)
  548.     dead_members.inject([]) {|r, enemy| r += enemy.make_drop_items(rate) }
  549.   end
  550. end

  551. class Game_Battler < Game_BattlerBase
  552.   ## Aliased to add damage dealt and recieved to a value for later.
  553.   alias exec_damage_cpv execute_damage unless $@
  554.   def execute_damage(user)
  555.     if @result.hp_damage > 0
  556.       i = [@result.hp_damage, hp].min
  557.       Grade.score_items[:damage].dealt += i if enemy?
  558.       Grade.score_items[:damage].recieved += i if !enemy?
  559.       if hp == mhp && i >= mhp && enemy?
  560.         Grade.score_items[:damage].onehit += @one_hit
  561.       end
  562.     end
  563.     exec_damage_cpv(user)
  564.   end
  565. end

  566. class Game_Enemy < Game_Battler
  567.   attr_accessor :add_score
  568.   attr_accessor :one_hit
  569.   
  570.   ## Gets the default added points for an enemy.
  571.   alias cp_gbv_initialize initialize unless $@
  572.   def initialize(index, enemy_id)
  573.     cp_gbv_initialize(index, enemy_id)
  574.     enemy = $data_enemies[@enemy_id]
  575.     @add_score = enemy.add_score
  576.     @one_hit = enemy.one_hit
  577.   end
  578.   
  579.   ## The actual adjusted drop rate.
  580.   def make_drop_items(rate = 100)
  581.     cpi = rate.to_f / 100
  582.     enemy.drop_items.inject([]) do |r, di|
  583.       if di.kind > 0 && rand * di.denominator < drop_item_rate * cpi
  584.         if Grade.score >= di.req_grade
  585.           r.push(item_object(di.kind, di.data_id))
  586.         else
  587.           r
  588.         end
  589.       else
  590.         r
  591.       end
  592.     end
  593.   end
  594. end

  595. class Game_Actor < Game_Battler
  596.   attr_reader :actor_id
  597.   
  598.   alias cp_gv_level_up level_up unless $@
  599.   def level_up
  600.     tmp1 = mhp
  601.     tmp2 = mmp
  602.     cp_gv_level_up
  603.     heal1 = mhp - tmp1
  604.     heal2 = mmp - tmp2
  605.     case CP::VICTORY::HP_HEAL_TYPE
  606.     when 1; self.hp += heal1
  607.     when 2; self.hp = mhp
  608.     end
  609.     case CP::VICTORY::MP_HEAL_TYPE
  610.     when 1; self.mp += heal2
  611.     when 2; self.mp = mmp
  612.     end
  613.   end
  614.   
  615.   ## Just made a whole new exp event here.  Adjusts the rate.
  616.   def gain_exp_cpv(exp, vic_rate = 100)
  617.     change_exp(self.exp + (exp * vic_rate * final_exp_rate / 100).to_i, false)
  618.   end
  619.   
  620.   ## Determines the exp for the last level.
  621.   def last_level_exp
  622.     return 0 if @level <= 0
  623.     return exp_for_level(@level - 1)
  624.   end
  625. end

  626. class Scene_Battle < Scene_Base
  627.   if $imported["YSA-PCTB"]
  628.   alias cp_bv_fix_yami_pctb update_pctb_speed unless $@
  629.   def update_pctb_speed
  630.     return if BattleManager.victory_phase?
  631.     cp_bv_fix_yami_pctb
  632.   end
  633.   end
  634.   
  635.   ## Overwritten to stop stuff from happening during the victory phase.
  636.   def update
  637.     super
  638.     if BattleManager.in_turn?
  639.       process_event
  640.       process_action
  641.     end
  642.     BattleManager.judge_win_loss unless BattleManager.victory_phase?
  643.     if BattleManager.victory_phase?
  644.       if @victory_score.done and @victory_score.active
  645.         sfx = CP::VICTORY::IMAGE_SFX
  646.         vol = CP::VICTORY::SFX_VOL
  647.         pit = CP::VICTORY::SFX_PIT
  648.         RPG::SE.new(sfx, vol, pit).play unless sfx.nil?
  649.         @victory_score.active = false
  650.         @victory_item.active = true
  651.       end
  652.     end
  653.   end
  654.   
  655.   ## Terminates the sprites and extra windows at the end of battle.
  656.   alias cp_gv_dispose_all_windows dispose_all_windows unless $@
  657.   def dispose_all_windows
  658.     remove_sprite
  659.     cp_gv_dispose_all_windows
  660.   end
  661.   
  662.   ## Applies score loss/gain when using an item/skill.
  663.   alias cp_gv_use_item use_item unless $@
  664.   def use_item
  665.     item = @subject.current_action.item
  666.     Grade.score_items[:skill].karma += item.add_score
  667.     cp_gv_use_item
  668.   end
  669.   
  670.   ## Closes the status window sorta.
  671.   def close_status_window
  672.     instance_variables.each do |varname|
  673.       ivar = instance_variable_get(varname)
  674.       ivar.openness = 0 if ivar.is_a?(Window)
  675.     end
  676.   end
  677.   
  678.   ## The next few call stuff.
  679.   def exp_window_update(exp)
  680.     @victory_main.redraw_exp(exp)
  681.     create_leveled_windows
  682.     pack_and_send
  683.   end
  684.   
  685.   def update_window_rates(exp, gold, item)
  686.     @victory_rank.get_rates(exp, gold)
  687.     @victory_item_top.get_rates(item)
  688.   end
  689.   
  690.   def update_scores(dealt, recieved, turns)
  691.     @victory_score.draw_score(CP::VICTORY::DEALT_NAME, dealt, 0)
  692.     @victory_score.draw_score(CP::VICTORY::RECIEVED_NAME, recieved, 24)
  693.     @victory_score.draw_score(CP::VICTORY::TURNS_NAME, turns, 48)
  694.     @victory_score.rank_stuff
  695.   end
  696.   
  697.   def show_victory_windows
  698.     @victory_main = Window_VictoryMain.new
  699.     @victory_top = Window_VictoryTop.new
  700.     @victory_score = Window_VictoryScore.new
  701.     @victory_rank = Window_VictoryRank.new
  702.     @victory_item_top = Window_VictoryItemTop.new
  703.     @victory_item = Window_VictoryItem.new
  704.     @victory_main.openness = 0
  705.     @victory_top.openness = 0
  706.     @victory_score.openness = 0
  707.     @victory_rank.openness = 0
  708.     @victory_item_top.openness = 0
  709.     @victory_item.openness = 0
  710.     @victory_main.open
  711.     @victory_top.open
  712.     @victory_score.open
  713.     @victory_rank.open
  714.     @victory_item_top.open
  715.     @victory_item.open
  716.     if CP::VICTORY::USE_IMAGES
  717.       @victory_score.active = true
  718.     else
  719.       @victory_item.active = true
  720.     end
  721.   end
  722.   
  723.   def create_leveled_windows
  724.     @leveled = []
  725.     return if @victory_main.leveled.empty?
  726.     @victory_main.leveled.each {|actor| @leveled.push(Window_LvlUp.new(actor))}
  727.     @leveled.each {|wind| wind.visible = false}
  728.   end
  729.   
  730.   def pack_and_send
  731.     ar1 = [@victory_main, @victory_top, @victory_score, @victory_rank,
  732.            @victory_item_top, @victory_item]
  733.     @victory_item.get_windows(ar1, @leveled)
  734.   end
  735.   
  736.   def remove_sprite
  737.     @victory_score.remove_sprite unless @victory_score.nil? || @victory_score.disposed?
  738.     return if @leveled.nil? || @leveled.empty?
  739.     @leveled.each {|wind| wind.dispose}
  740.   end
  741.   
  742.   ## This pushes the drop items to the drop window.
  743.   def drop_items(drops)
  744.     @victory_item.get_drops(drops)
  745.   end
  746. end

  747. ## The main window with the character faces.
  748. class Window_VictoryMain < Window_Selectable
  749.   attr_reader :leveled
  750.   
  751.   def initialize
  752.     super(0, 48, Graphics.width, 152)
  753.     @index = -1
  754.     @leveled = []
  755.     draw_all_items
  756.   end
  757.   
  758.   def draw_all_items
  759.     item_max.times {|i| draw_item(i) }
  760.   end
  761.   
  762.   def redraw_exp(exp)
  763.     item_max.times {|i| draw_exp(i, exp) }
  764.   end
  765.   
  766.   def draw_item(index)
  767.     actor = $game_party.members[index]
  768.     rect = item_rect(index)
  769.     draw_victory_face(actor, rect)
  770.     draw_actor_exp_info(actor, rect.x, rect.y + 104, rect.width)
  771.   end
  772.   
  773.   def draw_victory_face(actor, orect)
  774.     bitmap = Cache.face(actor.face_name)
  775.     rect = Rect.new(actor.face_index % 4 * 96, actor.face_index / 4 * 96, 96, 96)
  776.     fx = (orect.width - 96) / 2
  777.     temp_bit = Bitmap.new(orect.width, orect.height)
  778.     temp_bit.blt(fx, 0, bitmap, rect)
  779.     contents.blt(orect.x, orect.y, temp_bit, temp_bit.rect)
  780.   end
  781.   
  782.   def draw_exp(index, exp)
  783.     actor = $game_party.members[index]
  784.     rect = item_rect(index)
  785.     draw_actor_exp_info(actor, rect.x, rect.y + 104, rect.width, exp)
  786.   end
  787.   
  788.   def draw_actor_exp_info(actor, x, y, width, aexp = 0)
  789.     x += (width - 96) / 2
  790.     width = [width, 96].min
  791.     aexr = aexp * actor.exr
  792.     cexp = actor.exp - actor.current_level_exp
  793.     nexp = actor.next_level_exp - actor.current_level_exp
  794.     if cexp - aexr >= 0
  795.       rate = cexp.to_f / nexp
  796.       rate = 1.0 if rate > 1.0
  797.       gc1 = text_color(CP::VICTORY::EXP_ADDED)
  798.       gc2 = text_color(CP::VICTORY::EXP_ADDED)
  799.       draw_gauge(x, y, width, rate, gc1, gc2)
  800.       cexp -= aexr
  801.       rate = cexp.to_f / nexp
  802.       rate = 1.0 if rate > 1.0
  803.       rate = 1.0 if actor.level == actor.max_level
  804.       gc1 = text_color(CP::VICTORY::EXP_GAUGE_1)
  805.       gc2 = text_color(CP::VICTORY::EXP_GAUGE_2)
  806.       draw_gauge_clear(x, y, width, rate, gc1, gc2)
  807.     else
  808.       rate = 1.0
  809.       gc1 = text_color(CP::VICTORY::EXP_ADDED)
  810.       gc2 = text_color(CP::VICTORY::EXP_ADDED)
  811.       draw_gauge(x, y, width, rate, gc1, gc2)
  812.       cexp = actor.exp - actor.last_level_exp - aexr
  813.       nexp = actor.current_level_exp - actor.last_level_exp
  814.       rate = cexp.to_f / nexp
  815.       gc1 = text_color(CP::VICTORY::EXP_GAUGE_1)
  816.       gc2 = text_color(CP::VICTORY::EXP_GAUGE_2)
  817.       draw_gauge_clear(x, y, width, rate, gc1, gc2)
  818.       change_color(normal_color)
  819.       draw_text(x, y, width, line_height, CP::VICTORY::LEVEL_UP, 1)
  820.       @leveled.push(actor)
  821.     end
  822.   end
  823.    
  824.   def draw_gauge_clear(x, y, width, rate, color1, color2)
  825.     fill_w = (width * rate).to_i
  826.     gauge_y = y + line_height - 8
  827.     contents.gradient_fill_rect(x, gauge_y, fill_w, 6, color1, color2)
  828.   end
  829.   
  830.   def item_max
  831.     $game_party.battle_members.size
  832.   end
  833.   
  834.   def item_height
  835.     return 128
  836.   end
  837.   
  838.   def col_max
  839.     $game_party.max_battle_members
  840.   end
  841.   
  842.   def spacing
  843.     return 0
  844.   end
  845. end

  846. ## The window at the top that says victory stuff.
  847. class Window_VictoryTop < Window_Base
  848.   def initialize
  849.     super(0, 0, Graphics.width, 48)
  850.     draw_title
  851.   end
  852.   
  853.   def draw_title
  854.     title = sprintf(Vocab::Victory, $game_party.name)
  855.     change_color(normal_color)
  856.     draw_text(0, 0, contents.width, line_height, title, 1)
  857.   end
  858. end

  859. ## The window that shows rank and score stuff.
  860. class Window_VictoryScore < Window_Base
  861.   attr_accessor :done
  862.   
  863.   def initialize
  864.     side = CP::VICTORY::FLIP_LOWER ? Graphics.width / 2 : 0
  865.     super(side, 200, Graphics.width / 2, Graphics.height - 272)
  866.     @done = false
  867.     setup_image if CP::VICTORY::USE_IMAGES
  868.   end
  869.   
  870.   def update
  871.     super
  872.     unless @rank.nil? or @done or !open?
  873.       @rank.opacity += 25
  874.       @rank.zoom_x -= 0.2
  875.       @rank.zoom_y -= 0.2
  876.       if @rank.zoom_y < 1.0
  877.         @done = true
  878.         @rank.zoom_x = 1.0
  879.         @rank.zoom_y = 1.0
  880.       end
  881.     end
  882.   end
  883.   
  884.   def setup_image
  885.     @rank = Sprite.new
  886.   end
  887.   
  888.   def hide_image
  889.     @rank.visible = false if @rank
  890.   end
  891.   
  892.   def remove_sprite
  893.     @rank.dispose unless @rank.nil?
  894.   end
  895.   
  896.   def draw_score(name, value, y)
  897.     change_color(system_color)
  898.     draw_text(16, y, contents.width-32, 24, name, 0)
  899.     change_color(normal_color)
  900.     draw_text(16, y, contents.width-32, 24, value, 2)
  901.   end
  902.   
  903.   def rank_stuff
  904.     draw_rank
  905.     draw_image if CP::VICTORY::USE_IMAGES
  906.   end
  907.   
  908.   def draw_image
  909.     ranking = CP::VICTORY::IMAGE_NAME + Grade.rate[0]
  910.     @rank.bitmap = Cache.system(ranking)
  911.     @rank.ox = @rank.bitmap.width / 2
  912.     @rank.oy = @rank.bitmap.height / 2
  913.     @rank.opacity = 0
  914.     @rank.zoom_x = 5.0
  915.     @rank.zoom_y = 5.0
  916.     @rank.x = x + width - padding - 16 - @rank.bitmap.width / 2
  917.     @rank.y = y + height - padding - 16
  918.     @rank.z = z + 800
  919.   end
  920.   
  921.   def draw_rank
  922.     color = Grade.rate[5]
  923.     rank = Grade.rate[0]
  924.     change_color(system_color)
  925.     contents.font.size = 32
  926.     fs = contents.font.size
  927.     draw_text(16, contents.height-fs, contents.width-32, fs, CP::VICTORY::RANK_NAME, 0)
  928.     change_color(normal_color) if color.nil?
  929.     change_color(text_color(color)) unless color.nil?
  930.     draw_text(16, contents.height-fs, contents.width-32, fs, rank, 2) unless CP::VICTORY::USE_IMAGES
  931.   end
  932. end

  933. ## The window that shows exp and gold.
  934. class Window_VictoryRank < Window_Base
  935.   def initialize
  936.     side = CP::VICTORY::FLIP_LOWER ? Graphics.width / 2 : 0
  937.     super(side, Graphics.height - 72, Graphics.width / 2, 72)
  938.   end
  939.   
  940.   def get_rates(exp, gold)
  941.     draw_object(Grade.rate[2], CP::VICTORY::EXP_NAME, exp, 0)
  942.     draw_object(Grade.rate[3], Vocab.currency_unit, gold, 24)
  943.   end
  944.   
  945.   def draw_object(rate, name, value, y)
  946.     change_color(normal_color)
  947.     draw_text(16, y, contents.width - 32, 24, value, 0)
  948.     n = contents.text_size(value).width
  949.     change_color(system_color)
  950.     draw_text(n + 20, y, contents.width - n - 36, 24, name, 0)
  951.     change_color(normal_color)
  952.     text = rate.to_s + "%"
  953.     draw_text(16, y, contents.width - 32, 24, text, 2)
  954.   end
  955. end

  956. ## The window that shows drop rate.
  957. class Window_VictoryItemTop < Window_Base
  958.   def initialize
  959.     side = CP::VICTORY::FLIP_LOWER ? 0 : Graphics.width / 2
  960.     super(side, 200, Graphics.width / 2, 48)
  961.   end
  962.   
  963.   def get_rates(rate)
  964.     change_color(system_color)
  965.     draw_text(16, 0, contents.width-32, 24, CP::VICTORY::SPOILS, 0)
  966.     change_color(normal_color)
  967.     text = rate.to_s + "%"
  968.     draw_text(16, 0, contents.width-32, 24, text, 2)
  969.   end
  970. end

  971. ## The window that shows items.  You can scroll through the items in it.
  972. class Window_VictoryItem < Window_Selectable
  973.   def initialize
  974.     side = CP::VICTORY::FLIP_LOWER ? 0 : Graphics.width / 2
  975.     super(side, 248, Graphics.width / 2, Graphics.height - 248)
  976.     @index = 0
  977.   end
  978.   
  979.   def item_max
  980.     @data ? @data.size : 0
  981.   end
  982.   
  983.   def draw_all_items
  984.     return super if item_max > 0
  985.     draw_null
  986.   end
  987.   
  988.   def draw_item(index)
  989.     item = @data[index]
  990.     if item
  991.       rect = item_rect(index)
  992.       rect.width -= 4
  993.       draw_item_name(item, rect.x, rect.y)
  994.       draw_item_number(rect, index)
  995.     end
  996.   end
  997.   
  998.   def draw_null
  999.     rect = item_rect(0)
  1000.     rect.width -= 4
  1001.     draw_text(rect, CP::VICTORY::NO_DROPS, 1)
  1002.   end
  1003.   
  1004.   def draw_item_number(rect, index)
  1005.     draw_text(rect, sprintf(":%2d", @number[index]), 2)
  1006.   end
  1007.   
  1008.   def get_drops(drops)
  1009.     @data = []
  1010.     @number = []
  1011.     for i in 0...drops.size
  1012.       ind = @data.index(drops[i])
  1013.       if ind.nil?
  1014.         @data.push(drops[i])
  1015.         @number.push(1)
  1016.       else
  1017.         @number[ind] += 1
  1018.       end
  1019.     end
  1020.     self.refresh
  1021.   end
  1022.   
  1023.   def get_windows(ar1, ar2)
  1024.     @done = 0
  1025.     @ar1 = ar1
  1026.     @ar2 = ar2
  1027.   end
  1028.   
  1029.   def process_handling
  1030.     return unless open? && active
  1031.     BattleManager.victory_end if Input.trigger?(:B)
  1032.     check_leveled_up if Input.trigger?(:C)
  1033.   end
  1034.   
  1035.   def check_leveled_up
  1036.     @done = 0 if @done.nil?; @done += 1
  1037.     return BattleManager.victory_end unless CP::VICTORY::LVL_UP_ENABLE
  1038.     return BattleManager.victory_end if @ar2.nil?
  1039.     return BattleManager.victory_end if @done > @ar2.size
  1040.     sfx = CP::VICTORY::LVL_SFX
  1041.     vol = CP::VICTORY::LVL_VOL
  1042.     pit = CP::VICTORY::LVL_PIT
  1043.     RPG::SE.new(sfx, vol, pit).play unless sfx.nil?
  1044.     @ar1.each {|wind| wind.visible = false}
  1045.     @ar2.each {|wind| wind.visible = false}
  1046.     @ar1[2].hide_image
  1047.     @ar2[@done - 1].visible = true
  1048.   end
  1049.   
  1050.   def update
  1051.     super
  1052.     if Audio.bgm_pos != 0
  1053.       BattleManager.play_battle_end_me
  1054.     end
  1055.   end
  1056.   
  1057.   def refresh
  1058.     contents.clear
  1059.     create_contents
  1060.     draw_all_items
  1061.   end
  1062. end

  1063. ## Modifies a skill's score modification when used.
  1064. class RPG::UsableItem < RPG::BaseItem
  1065.   def add_score
  1066.     karma_modif if @add_score.nil?
  1067.     return @add_score
  1068.   end
  1069.   
  1070.   def karma_modif
  1071.     @add_score = 0
  1072.     self.note.split(/[\r\n]+/).each do |line|
  1073.       case line
  1074.       when CP::VICTORY::KARMA
  1075.         @add_score = ($1.to_s + $2.to_s).to_i
  1076.       end
  1077.     end
  1078.   end
  1079. end

  1080. class RPG::Enemy::DropItem
  1081.   def req_grade
  1082.     return @req_grade ? @req_grade : 0
  1083.   end
  1084.   
  1085.   def req_grade=(val)
  1086.     @req_grade = val
  1087.   end
  1088. end

  1089. ## Modifies the enemy's drops from the database.
  1090. class RPG::Enemy < RPG::BaseItem
  1091.   def add_score
  1092.     add_drops if @add_score.nil?
  1093.     return @add_score
  1094.   end
  1095.   
  1096.   def one_hit
  1097.     add_drops if @one_hit.nil?
  1098.     return @one_hit
  1099.   end
  1100.   
  1101.   def drop_items
  1102.     add_drops if @added_drops.nil?
  1103.     return @drop_items
  1104.   end
  1105.   
  1106.   def add_drops
  1107.     @added_drops = true
  1108.     @add_score = 0
  1109.     @one_hit = CP::VICTORY::ONE_HIT
  1110.     self.note.split(/[\r\n]+/).each do |line|
  1111.       case line
  1112.       when CP::VICTORY::DROPS
  1113.         temp = RPG::Enemy::DropItem.new
  1114.         case $1.to_s
  1115.         when "I", "i"
  1116.           temp.kind = 1
  1117.         when "W", "w"
  1118.           temp.kind = 2
  1119.         when "A", "a"
  1120.           temp.kind = 3
  1121.         end
  1122.         temp.data_id = $2.to_i
  1123.         temp.denominator = $3.to_i
  1124.         temp.req_grade = $4.to_i
  1125.         @drop_items.push(temp)
  1126.       when CP::VICTORY::SCORE
  1127.         @add_score = $1.to_i
  1128.       when CP::VICTORY::ONEHIT
  1129.         @one_hit = $1.to_i
  1130.       end
  1131.     end
  1132.   end
  1133. end

  1134. ## Creates windows at the end of the victory screen that display level up stats.
  1135. class Window_LvlUp < Window_Base
  1136.   def initialize(actor)
  1137.     @actor = actor  ## Gets the actor, old level, and new skills.
  1138.     @old_level = BattleManager.old_levels(actor.actor_id)
  1139.     @skills = actor.skills - BattleManager.old_skills(actor.actor_id)
  1140.     create_params  ## Creates all params.  Here for custom params.
  1141.     super(0, 0, box_width, box_height)  ## Creates and moves the box.
  1142.     self.x = (Graphics.width - width) / 2
  1143.     self.y = (Graphics.height - height) / 2
  1144.     refresh
  1145.   end
  1146.   
  1147.   ## Creates the entire list of params.
  1148.   def create_params
  1149.     @params = []
  1150.     8.times do |i|
  1151.       p1 = @actor.class.params[i, @old_level]
  1152.       p2 = @actor.class.params[i, @actor.level]
  1153.       vocab = Vocab.param(i)
  1154.       add_param(vocab, p1, p2)
  1155.     end
  1156.   end
  1157.   
  1158.   ## Adds a param to the list.
  1159.   def add_param(vocab, p1, p2)
  1160.     @params.push([vocab, p1, p2])
  1161.   end
  1162.   
  1163.   ## Width of the box based on whether any new skills were learned.
  1164.   def box_width
  1165.     wd = @skills.empty? ? 240 : 480
  1166.     return wd + standard_padding * 2
  1167.   end
  1168.   
  1169.   ## Height of the box based on total params.
  1170.   def box_height
  1171.     return line_height + 104 + line_height * (@params.size + 1)
  1172.   end
  1173.   
  1174.   ## Refreshed the box contents.
  1175.   def refresh
  1176.     contents.clear
  1177.     draw_header
  1178.     draw_face_area(line_height * 1.5)
  1179.     draw_attr_area(0, line_height * 2 + 104)
  1180.     draw_skill_area(240, line_height * 2 + 104)
  1181.   end
  1182.   
  1183.   ## Draws the level up header.
  1184.   def draw_header
  1185.     x = (contents.width - 240) / 2
  1186.     ml = 0
  1187.     p1 = @old_level
  1188.     p2 = @actor.level
  1189.     ml = contents.text_size(p1).width if contents.text_size(p1).width > ml
  1190.     ml = contents.text_size(p2).width if contents.text_size(p2).width > ml
  1191.     ml += 4
  1192.     mo = 236 - ml
  1193.     change_color(system_color)
  1194.     draw_text(x + 2, 0, mo - ml - 22, line_height, CP::VICTORY::LEVEL_UP, 0)
  1195.     draw_text(x + mo - 22, 0, 22, line_height, "→", 1)
  1196.     change_color(normal_color)
  1197.     draw_text(x + mo - ml - 22, 0, ml, line_height, p1, 2)
  1198.     change_color(power_up_color)
  1199.     draw_text(x + mo, 0, ml, line_height, p2, 2)
  1200.   end
  1201.   
  1202.   ## Draws the params section.
  1203.   def draw_attr_area(x, y)
  1204.     ml = 0
  1205.     @params.each do |p|  ## Find the wides param.
  1206.       ml = contents.text_size(p[1]).width if contents.text_size(p[1]).width > ml
  1207.       ml = contents.text_size(p[2]).width if contents.text_size(p[2]).width > ml
  1208.     end
  1209.     ml += 4  ## Set params box size.
  1210.     mo = 236 - ml  ## Last object's location.
  1211.     @params.each_with_index do |para, i|
  1212.       ylh = y + i * line_height  ## Gets the y location.
  1213.       change_color(system_color)  ## Draws the name and arrow.
  1214.       draw_text(x + 2, ylh, mo - ml - 22, line_height, para[0], 0)
  1215.       draw_text(x + mo - 22, ylh, 22, line_height, "→", 1)
  1216.       change_color(normal_color)  ## Draws the old and new stats.
  1217.       draw_text(x + mo - ml - 22, ylh, ml, line_height, para[1], 2)
  1218.       change_color(para[2] > para[1] ? power_up_color : power_down_color)
  1219.       change_color(normal_color) if para[1] == para[2]
  1220.       draw_text(x + mo, ylh, ml, line_height, para[2], 2)
  1221.     end
  1222.   end
  1223.   
  1224.   def draw_face_area(y)  ## Draws the area with the face, name, and class.
  1225.     xi = (contents.width - 216) / 2
  1226.     draw_actor_name(@actor, xi + 104, y + 0 * line_height)
  1227.     draw_actor_class(@actor, xi + 104, y + 1 * line_height)
  1228.     draw_actor_face(@actor, xi + 4, y + 4)
  1229.   end
  1230.   
  1231.   def draw_skill_area(x, y)  ## Draw skill names.
  1232.     change_color(system_color)  ## First, draw the skill message.
  1233.     draw_text(x + 18, y, 220, line_height, CP::VICTORY::NEW_SKILLS, 1)
  1234.     change_color(normal_color)  ## Next, check if there are too many skills.
  1235.     if @skills.size > @params.size - 1
  1236.       total = @params.size-3
  1237.       total.times do |i|
  1238.         item = @skills[i]  ## Draws only so many skills.
  1239.         draw_item_name(item, x + 18, y + (i + 1) * line_height, true, 220)
  1240.       end  ## Draws the final message.
  1241.       draw_text(x + 18, y + (@params.size - 2) * line_height, 220, line_height,
  1242.                 more_skills, 1)
  1243.     else
  1244.       @skills.each_with_index do |item, i|  ## Draws all skills.
  1245.         draw_item_name(item, x + 18, y + (i + 1) * line_height, true, 220)
  1246.       end
  1247.     end
  1248.   end
  1249.   
  1250.   def more_skills  ## Gets the more skills text.
  1251.     more = @skills.size - @params.size
  1252.     return sprintf(CP::VICTORY::MORE_SKILLS, more)
  1253.   end
  1254. end


  1255. ###--------------------------------------------------------------------------###
  1256. #  End of script.                                                              #
  1257. ###--------------------------------------------------------------------------###
复制代码
回复

使用道具 举报

梦石
0
星屑
34511
在线时间
5096 小时
注册时间
2012-11-19
回帖
4715

开拓者

 楼主| 发表于 2020-8-15 14:09:14 | 显示全部楼层
本帖最后由 芯☆淡茹水 于 2020-8-15 14:15 编辑

咦,我把你改的加入工程,加上1楼的脚本,没有报错哇?!就是得到的经验与显示的经验不一致。
1楼脚本是每个人得到的经验都有不同。
捕获.PNG


因为每个人得到的经验都有不同,所以与原本的整体得到相同经验的理念冲突较大,只有把 DataManager 的 gain_exp 给黑掉了。
可以把1楼脚本放前面,你的脚本放后面试试。

评分

参与人数 1赞 +1 收起 理由
alexncf125 + 1 塞糖

查看全部评分

xp vx va mv  va mz 各类型脚本/插件定制
回复

使用道具 举报

梦石
0
星屑
30103
在线时间
5741 小时
注册时间
2016-3-8
回帖
1662
发表于 2020-8-15 17:17:47 | 显示全部楼层
本帖最后由 alexncf125 于 2020-8-16 09:38 编辑
芯☆淡茹水 发表于 2020-8-15 14:09
咦,我把你改的加入工程,加上1楼的脚本,没有报错哇?!就是得到的经验与显示的经验不一致。
1楼脚本是每 ...


Project2.rar (1.91 MB, 下载次数: 46)
Data.rar (550.18 KB, 下载次数: 50)

(☍﹏⁰) 奇了怪了,新建的工程,不知什么原因会报错(╥﹏╥)
我正在做的工程却不会报错(((φ(◎ロ◎;)φ)))
未命名.png

大大可不可以把我正在做的工程发给您?
能请您帮忙看看么?゜+.(人-ω◕)゜+.゜
就是战斗胜利评级脚本第552-553行
注釋了原先的,改成actor.xr_exp才会出现下方图片的情況

未命名.png 未命名.png
回复

使用道具 举报

梦石
0
星屑
34511
在线时间
5096 小时
注册时间
2012-11-19
回帖
4715

开拓者

 楼主| 发表于 2020-8-16 09:26:26 | 显示全部楼层
alexncf125 发表于 2020-8-15 17:17
(☍﹏⁰) 奇了怪了,新建的工程,不知什么原因会报错(╥﹏╥)
我正在做的工程却不会报错(((φ(◎ロ◎;)φ ...

捕获.PNG

点评

啊这怎么损坏了...姑且更新了附件...大大看看能打开不  发表于 2020-8-16 09:39

评分

参与人数 1赞 +1 收起 理由
alexncf125 + 1 塞糖

查看全部评分

xp vx va mv  va mz 各类型脚本/插件定制
回复

使用道具 举报

梦石
0
星屑
34511
在线时间
5096 小时
注册时间
2012-11-19
回帖
4715

开拓者

 楼主| 发表于 2020-8-16 11:02:11 | 显示全部楼层
alexncf125 发表于 2020-8-15 17:17
(☍﹏⁰) 奇了怪了,新建的工程,不知什么原因会报错(╥﹏╥)
我正在做的工程却不会报错(((φ(◎ロ◎;) ...

角色得到的是各自的经验,你写的返回确实原本默认的敌人队伍经验。
在计算升了多少级什么的,实际得到的经验与代入的经验不符,所以出错。
脚本改了一下,搜索 <XR> 就能找到改的地方


Scripts.rar (159.11 KB, 下载次数: 55)

评分

参与人数 1赞 +1 收起 理由
alexncf125 + 1 认可答案

查看全部评分

xp vx va mv  va mz 各类型脚本/插件定制
回复

使用道具 举报

梦石
0
星屑
30103
在线时间
5741 小时
注册时间
2016-3-8
回帖
1662
发表于 2020-8-16 12:30:42 | 显示全部楼层
芯☆淡茹水 发表于 2020-8-16 11:02
角色得到的是各自的经验,你写的返回确实原本默认的敌人队伍经验。
在计算升了多少级什么的,实际得到的 ...


咦咦咦..Σ ( ´゚Д゚`)
我都没留意下两行还有句return
太专注于上方那句而忽略它了.._(┐∠ ﹃゚。)_

现在全部的问题都解决了ヽ(●´∀`●)ノ
\(^ω^\)谢谢大大不遗余力地帮忙( /^ω^)/
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部