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

Project1

 找回密码
 注册会员
搜索
查看: 2616|回复: 11

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

[复制链接]

Lv5.捕梦者

梦石
0
星屑
31681
在线时间
5077 小时
注册时间
2012-11-19
帖子
4877

开拓者

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

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

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

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

RUBY 代码复制
  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 各类型脚本/插件定制

Lv5.捕梦者

梦石
0
星屑
24057
在线时间
4983 小时
注册时间
2016-3-8
帖子
1613
发表于 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
回复 支持 反对

使用道具 举报

Lv5.捕梦者

梦石
0
星屑
24057
在线时间
4983 小时
注册时间
2016-3-8
帖子
1613
发表于 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那部分)
RUBY 代码复制
  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 - [email protected] (e-mail) or "neonblack23" on skype         #
  17. ###--------------------------------------------------------------------------###
  18.  
  19. ###--------------------------------------------------------------------------###
  20. #      Revision information:                                                   #
  21. #  V2.1 - 11.16.2012                                                           #
  22. #   Added grade requirement for drops                                          #
  23. #   Fixed an issue where drop rate was not figured properly                    #
  24. #  V2.0 - Finished 8.11.2012                                                   #
  25. #   Added level up windows                                                     #
  26. #   Created score items and Grade module                                       #
  27. #   Numerous other bugfixes and changes                                        #
  28. #  V1.1b - 6.26.2012                                                           #
  29. #   Fixed an error related to exp gain display                                 #
  30. #  V1.1 - 6.21.2012                                                            #
  31. #   Added rank sprite effect                                                   #
  32. #  V1.0 - 6.19.2012                                                            #
  33. #   Wrote and debugged main script                                             #
  34. ###--------------------------------------------------------------------------###
  35.  
  36. ###--------------------------------------------------------------------------###
  37. #      Compatibility:                                                          #
  38. #  This script has been tested to work with Yanfly's battle engine (just the   #
  39. #  base engine) and Yami's PCTB.  If you have any issue, let me know and I     #
  40. #  will address them asap.                                                     #
  41. #  Due to the number of new windows, I will only list methods in already       #
  42. #  existing objects here and not any of the newly created objects.             #
  43. #                                                                              #
  44. #  Alias       - BattleManager: setup, play_battle_bgm                         #
  45. #                Game_Battler: execute_damage                                  #
  46. #                Game_Enemy: initialize                                        #
  47. #                Game_Actor: level_up                                          #
  48. #                Scene_Battle: update_pctb_speed, dispose_all_windows,         #
  49. #                              use_item                                        #
  50. #                DataManager: load_database                                    #
  51. #  Overwrites  - BattleManager: process_victory, play_battle_end_me,           #
  52. #                               gain_gold, gain_drop_items, gain_exp           #
  53. #                Game_Troop: make_drop_items                                   #
  54. #                Game_Enemy: make_drop_items                                   #
  55. #                Scene_Battle: update                                          #
  56. #  New Objects - BattleManager: old_levels, old_skills, victory_phase?,        #
  57. #                               skip?, victory_end                             #
  58. #                Game_Troop: check_boss                                        #
  59. #                Game_Actor: gain_exp_cpv, last_level_exp                      #
  60. #                Scene_Battle: close_status_window, exp_window_update,         #
  61. #                              update_window_rates, update_scores,             #
  62. #                              show_victory_windows, create_leveled_windows,   #
  63. #                              pack_and_send, remove_sprite, drop_items        #
  64. #                RPG::UsableItem: karma_modif                                  #
  65. #                RPG::Enemy: add_drops                                         #
  66. #                DataManager: make_extra_drops                                 #
  67. ###--------------------------------------------------------------------------###
  68.  
  69. ###--------------------------------------------------------------------------###
  70. #      Instructions:                                                           #
  71. #  Place this script in the "Materials" section of the scripts above main.     #
  72. #  This script requires you to set several settings for the script to work     #
  73. #  properly.  The screen modifies the end of battle to allow a victory screen  #
  74. #  to appear.  This script also has several notebox tags that can be added to  #
  75. #  define changes to the grade and one note tag that will allow you to define  #
  76. #  additional monster drops.                                                   #
  77. ###-----                                                                -----###
  78. #                                                                              #
  79. #      敌人备注:                                                   #
  80. #                                                                              #
  81. #   drop[i:1:1:100] 或 drop[i:1:1]                                           #
  82. #               可以为敌人添加额外的掉落物品. 以上两种格式都行  #
  83. #               第一个参数是物品类型,可以是 "i", "a", 或  "w" ,分别代表 "物品",
  84. #               "护甲", 和 "武器".  第二个是物品id.  第三个是掉落几率.       #
  85. #               x分之1的概率,x=1时代表必定掉落,数字越大,掉落率越低.        #
  86. #               最后一个参数是可选的,代表战斗分数要求,胜利后评价的分数必须大于
  87. #               某个数,才会掉落该物品 .   
  88. #
  89. #   score[1]  - 该怪物每死一只,评价分数就加1.         #
  90. #               你可以把1替换为其他数字
  91. #
  92. #   onehit[1]  - 该怪物每被我方技能命中一次,评价分数就加1.  
  93. #                请注意,多段伤害的技能只会触发一次,附加死亡状态的技能不会触发   #
  94. #                在下面你可以设定默认每一次命中会获得的分数,优先级低于本敌人备注.                                                       #
  95. ###-----                                                                -----###
  96. #                                                                              #
  97. #      物品/技能备注:                                            #
  98. #                                                                              #
  99. #   score[+1]  - 使用该物品/技能后评级分数+1,如果是 score[-20] 则分数-20                 #
  100. ###--------------------------------------------------------------------------###
  101.  
  102. ###--------------------------------------------------------------------------###
  103. #      Config:                                                                 #
  104. #  These are the default values used by several of the functions in the        #
  105. #  script.  You may change these values as you find your game requires in      #
  106. #  order to give the player a better playing experience based on your game.    #
  107. #                                                                              #
  108. module CP       # Do not edit                                                  #
  109. module VICTORY  #  these two lines.                                            #
  110. #                                                                              #
  111. ###-----                                                                -----###
  112. # 跳过评级BGM的开关,开关开启时不会播放评级BGM                                #
  113. SKIP_SWITCH = 5 # 默认 = 5                                                  #
  114. #                                                                              #
  115.           #
  116. USE_MUSIC = false # 是否播放评级BGM 默认 = true                                               #
  117. VICTORY_MUSIC = "" # 评级BGM文件名  默认 = "Scene4"   如果要静音请设定为nil                               #
  118. MSX_VOL = 100 # 音量  默认 = 100                                                  #
  119. MSX_PIT = 100 # 音调  默认 = 100                                                  #
  120. #                                                                              #
  121. # 是否播放数据库里设定战斗胜利ME,true时会在评级BGM之前播放                  #
  122. USE_ME = false # 默认 = false                                               #
  123. #                                                                              #
  124. # exp值槽颜色                                              #
  125. EXP_GAUGE_1 = 30 # 颜色1 默认 = 30                                                #
  126. EXP_GAUGE_2 = 31 # 颜色2 默认 = 31                                                #
  127. EXP_ADDED = 17 # 增长部分的颜色 默认 = 17                                                  #
  128. #                                                                              #
  129. # 是否对调下方左右两个窗口的位置                   #
  130. FLIP_LOWER = false # 默认 = false                                           #
  131. #                                                                              #
  132. # 设定升级后回复hp/mp的模式                                                                   #
  133. #  0 = 升级后不会回复.                       #
  134. #  1 = 升级后根据角色hpmp的增加量,回复部分hpmp.                #
  135. #  2 = 升级后全回复.                 #
  136. HP_HEAL_TYPE = 0 # 升级后hp回复模式  默认 = 0                                                 #
  137. MP_HEAL_TYPE = 0 # 升级后hp回复模式  默认 = 0                                                 #
  138. #                                                                              #
  139. # 设定显示的文字.                                               #
  140. LEVEL_UP = "等级提升!!" # 默认 = "Level Up!!"                               #
  141. SPOILS = "战利品" # 默认 = "Spoils"                                         #
  142. EXP_NAME = "EXP" # 默认 = "EXP"                                             #
  143. DEALT_NAME = "造成伤害" # 默认 = "Dealt"                                       #
  144. RECIEVED_NAME = "受到伤害" # 默认 = "Recieved"                              #
  145. TURNS_NAME = "回合数" # 默认 = "Turns"                                       #
  146. RANK_NAME = "评级" # 默认 = "Rank"                                         #
  147. NO_DROPS = "无战利品" # 默认 = "No drops recieved"                 #
  148. #                                                                              #
  149. ###-----                                                                -----###
  150. # 是否显示升级窗口                                   #
  151. LVL_UP_ENABLE = true # 默认 = true                                          #
  152. #                                                                              #
  153.          #
  154. LVL_SFX = "Item3" # 升级音效 默认 = "Item3" 想静音请设定为nil                                         #
  155. LVL_VOL = 80 # 音量 默认 = 80                                                    #
  156. LVL_PIT = 100 # 音调 默认 = 100                                                  #
  157. #                                                                              #
  158. # 学会技能时显示的文字                    #
  159. NEW_SKILLS = "学会技能:" # 默认 = "Learned:"                                 #
  160. MORE_SKILLS = "和其他 %s 个技能" # 默认 = "And %s more skills"            #
  161. #                                                                              #
  162. ###-----                                                                -----###
  163.                                                              #
  164. USE_IMAGES = false # 是否使用图片替代评级文字 默认 = false                                           #
  165. IMAGE_NAME = "Rank" # 评级图片文件名的前缀 默认 = "Rank" 如果获得评级C
  166. #                   #则会显示 RankC.png
  167. #                                                                              #
  168. #            #
  169. IMAGE_SFX = "Shot2" # 评级音效 默认 = "Shot2"  想静音请设定为nil                                         #
  170. SFX_VOL = 100 # 音量 默认 = 100                                                  #
  171. SFX_PIT = 100 # 音调 默认 = 100                                                  #
  172. #                                                                              #
  173. # 设定评级,必须按从上到下,从小到大的顺序:                                                     #
  174. #    ["评级",  要求分数,  获得exp比率,  获得金钱比率, 获得战利品率,  文字颜色],            #
  175. # 评级 - 请写在双引号里      #
  176. # 要求分数 - 达到该评级需要的最低分数,请确定第一个评级的要求分数为 "0".                                           #
  177. # 获得exp比率 - 默认值为 100 ,如果设定为200,代表获得双倍exp,下面两个比率同理.                                              #
  178. # 获得金钱比率 - 默认值为 100.                                             #
  179. # 获得战利品率 - 默认值为 100,不影响同一物品的掉落次数,仅影响单个物品的掉落概率.                                                  #
  180. # 文字颜色 - 文字颜色,和文本颜色一样.         #
  181. RANKS =[ # Do not edit this line.                                              #
  182.  
  183.   ["E",   0, 100, 100, 100, 18],
  184.   ["D", 100, 100, 105, 100, 20],
  185.   ["C", 150, 100, 110, 105,  4],
  186.   ["B", 250, 105, 110, 110, 21],
  187.   ["A", 400, 115, 115, 115,  3],
  188.   ["S", 700, 125, 125, 125, 17],
  189.  
  190. ] # Do not edit this line.                                                     #
  191. #                                                                              #
  192. # 设定伤害率对应的获得分数       #
  193. # 给你一个公式:伤害率 = 造成伤害 / 受到伤害 *100%
  194. # 举个栗子,假如玩家受到 140 点伤害,并且造成200点伤害,
  195. # 伤害率 = 200/140*100% = 142 ,对应下表142在100~150之间,此时获得的分数
  196. # 算到较小的区间,所以最终获得的分数为50
  197. #    格式为:                                                         #
  198. #    [伤害率,  获得分数],                                                         #
  199. DAMAGE_POINTS =[ # Do not edit this line.                                      #
  200.  
  201.   [ 50,  20],
  202.   [ 80,  30],
  203.   [100,  50],
  204.   [150,  75],
  205.   [200, 100],
  206.   [300, 200],
  207.  
  208. ] # Do not edit this line.                                                     #
  209. #                                                                              #
  210. # 以下是特殊情况会获得的的分数,那一项你不需要就把那一项设定为"0".                   #
  211. #                                                                              #
  212. # 在同一回合中消灭所有敌人.                                #
  213. SINGLE_TURN = 150 # 默认 = 150                                              #
  214. # 消灭boss (请在敌人特性中设定死亡方式为boss. 此分数一场战斗中只会增加一次
  215. # 就算同一敌群有多个boss也一样.      #
  216. BOSS_POINTS = 200 # 默认 = 200                                              #
  217. # 全程无伤                                 #
  218. NO_DAMAGE = 100 # 默认 = 100                                                #
  219. # 战斗结束时全员满HP.                              #
  220. FULL_HP = 50 # 默认 = 50                                                    #
  221. # 一击必杀(只用一个技能就消灭一个敌人),对添加死亡状态的技能无效                #
  222. ONE_HIT = 40 # 默认 = 40                                                    #
  223. ###--------------------------------------------------------------------------###
  224.  
  225. ###--------------------------------------------------------------------------###
  226. #      A note to scripters:                                                    #
  227. #  As of version 2.0 I have made it possible to add custom score items to be   #
  228. #  used in battle.  These scores are handled by the "Grade" module.  If you    #
  229. #  have created a new score item you want to use, you can add it to the Grade  #
  230. #  module by using the script call "Grade.new_score(:foo, Bar)" where ":foo"   #
  231. #  is the key you will use to access the object and "Bar" is the name of the   #
  232. #  new objects class (in this case, the defining line for the object would be  #
  233. #  "class Bar < Score_Base").  You can then reach this score object at any     #
  234. #  time by using the script call "Grade.score[:foo]".  To see the base score   #
  235. #  object or any of the pre-made score object, scroll down.  The score         #
  236. #  objects have been placed at the top of the script.                          #
  237. ###--------------------------------------------------------------------------###
  238.  
  239.  
  240. ###--------------------------------------------------------------------------###
  241. #  The following lines are the actual core code of the script.  While you are  #
  242. #  certainly invited to look, modifying it may result in undesirable results.  #
  243. #  Modify at your own risk!                                                    #
  244. ###--------------------------------------------------------------------------###
  245.  
  246.  
  247. end  ## Close the VICTORY module.
  248. end  ## Close the CP module.
  249.  
  250.  
  251. ##-----
  252. ## This is a basic score item.  There are 3 main parts to this.  The initialize
  253. ## part which defines each of the score variables to be used at the start, the
  254. ## update score part, which can be used at any time to get the current score
  255. ## the item will add, and the total part, which is used by the Grade module to
  256. ## get the final value.  You can use "attr_accessor" to create values that can
  257. ## be adjusted at any time or you can create methods to adjust different aspects
  258. ## of the score object.
  259. ##-----
  260. class Score_Base  ## A score item.  Holds and adjusts an aspect of score.
  261.   def initialize
  262.     @score = 0  ## Sets the score to 0 at the start.
  263.   end
  264.  
  265.   def update_score  ## Objects used to modify the score.
  266.     return 0
  267.   end
  268.  
  269.   def total  ## Create and return the score.
  270.     update_score
  271.     return @score
  272.   end
  273. end
  274.  
  275. class Score_Damage < Score_Base
  276.   attr_accessor :dealt
  277.   attr_accessor :recieved
  278.   attr_accessor :onehit
  279.  
  280.   def initialize  ## Holds dealt and recieved damage as well as one hit scores.
  281.     super         ## Creates a score based on dealt and recieved ratio.
  282.     @dealt = 0
  283.     @recieved = 0
  284.     @onehit = 0
  285.   end
  286.  
  287.   def update_score
  288.     res = super
  289.     if @recieved == 0
  290.       CP::VICTORY::DAMAGE_POINTS.each {|point| res += point[1]}
  291.     else
  292.       dr = (@dealt * 100 / @recieved)
  293.       CP::VICTORY::DAMAGE_POINTS.each do |point|
  294.         next if dr < point[0]
  295.         res += point[1]
  296.       end
  297.     end
  298.     res += CP::VICTORY::NO_DAMAGE if @recieved == 0
  299.     res += @onehit
  300.     @score = res
  301.   end
  302. end
  303.  
  304. class Score_HP < Score_Base
  305.   def initialize  ## Holds the hp at the start of battle.
  306.     super         ## Not technically used, but checks max hp at end of battle.
  307.     @start_hp = get_party_hp
  308.   end
  309.  
  310.   def get_party_hp
  311.     return 0 if $game_party.battle_members.empty?
  312.     result = 0
  313.     $game_party.battle_members.each do |member|
  314.       result += member.hp
  315.     end
  316.     return result
  317.   end
  318.  
  319.   def get_max_hp
  320.     return 0 if $game_party.battle_members.empty?
  321.     result = 0
  322.     $game_party.battle_members.each do |member|
  323.       result += member.mhp
  324.     end
  325.     return result
  326.   end
  327.  
  328.   def update_score
  329.     res = super
  330.     res += CP::VICTORY::FULL_HP if get_party_hp == get_max_hp
  331.     @score = res
  332.   end
  333. end
  334.  
  335. class Score_Troop < Score_Base
  336.   def update_score  ## Gets score values from the existance of boss monsters
  337.     res = super     ## as well as adding custom scores per monster.
  338.     res += CP::VICTORY::BOSS_POINTS if $game_troop.check_boss
  339.     res += CP::VICTORY::SINGLE_TURN if $game_troop.turn_count == 1
  340.     $game_troop.members.each {|foe| res += foe.add_score}
  341.     @score = res
  342.   end
  343. end
  344.  
  345. class Score_Skill < Score_Base
  346.   attr_accessor :karma
  347.  
  348.   def initialize
  349.     super
  350.     @karma = 0
  351.   end
  352.  
  353.   def update_score
  354.     res = super
  355.     res += @karma
  356.     @score = res
  357.   end
  358. end
  359.  
  360. module Grade
  361.   def self.reset  ## Holds score objects, score, and grades.
  362.     @rate = CP::VICTORY::RANKS[0]
  363.     @score = 0
  364.     create_score_items
  365.   end
  366.  
  367.   def self.create_score_items  ## Creates the default score items.
  368.     @score_items = {}
  369.     new_score(:damage, Score_Damage)
  370.     new_score(:hp,     Score_HP)
  371.     new_score(:troop,  Score_Troop)
  372.     new_score(:skill,  Score_Skill)
  373.   end
  374.  
  375.   def self.new_score(key, scr)  ## Adds a custom score item.
  376.     @score_items[key] = scr.new
  377.   end
  378.  
  379.   def self.update_score  ## Creates a score.
  380.     return 0 if @score_items.empty?
  381.     val = 0
  382.     @score_items.each do |key, score|
  383.       val += score.total
  384.     end
  385.     @score = val
  386.   end
  387.  
  388.   def self.update_rate  ## Updates the rank and grade.
  389.     update_score
  390.     rank_top = 0
  391.     CP::VICTORY::RANKS.each do |rank|
  392.       next if rank[1] > @score
  393.       if rank[1] > rank_top
  394.         @rate = rank
  395.         rank_top = rank[1]
  396.       end
  397.     end
  398.   end
  399.  
  400.   def self.score  ## Returns the score.
  401.     return @score
  402.   end
  403.  
  404.   def self.rate(key = nil)  ## Gets bits of all of the rate.
  405.     update_rate
  406.     case key
  407.     when :exp
  408.       return @rate[2]
  409.     when :gold
  410.       return @rate[3]
  411.     when :drop
  412.       return @rate[4]
  413.     else
  414.       return @rate
  415.     end
  416.   end
  417.  
  418.   def self.score_items  ## Gets all score items for usage.
  419.     return @score_items
  420.   end
  421. end
  422.  
  423. ##-----
  424. ## End of score object.  The rest of the script is below.
  425. ##-----
  426.  
  427. module CP
  428. module VICTORY
  429. SCORE  = /SCORE\[(\d+)\]/i
  430. KARMA  = /SCORE\[(\+|\-)?(\d+)\]/i
  431. DROPS  = /DROP\[(\w+):(\d+):(\d+):?(\d*)\]/i
  432. ONEHIT = /ONEHIT\[(\d+)\]/i
  433. end  ## Used for added drops.
  434. end
  435.  
  436. $imported = {} if $imported == nil
  437. $imported["CP_VICTORY"] = 2.1
  438.  
  439. module BattleManager
  440.   class << self
  441.  
  442.   ## Aliased to add certain new settings to the module.
  443.   alias setup_cp_vict setup unless $@
  444.   def setup(troop_id, can_escape = true, can_lose = false)
  445.     Grade.reset
  446.     setup_cp_vict(troop_id, can_escape, can_lose)
  447.     @victory = false
  448.     @played_bgm = 0
  449.     @old_levels = {}; @old_skills = {}
  450.     $game_party.all_members.each do |actr|
  451.       id = actr.actor_id; lvl = actr.level; skl = actr.skills
  452.       @old_levels[id] = lvl; @old_skills[id] = skl
  453.     end
  454.   end
  455.  
  456.   ## Gets the level or skills of the actors from before battle.
  457.   def old_levels(id); return @old_levels[id]; end
  458.   def old_skills(id); return @old_skills[id]; end
  459.  
  460.   ## Helps determine if the victory screen is active.
  461.   def victory_phase?
  462.     @phase == :victory
  463.   end
  464.  
  465.   ## Determine if all musics should be skipped.
  466.   def skip?
  467.     $game_switches[CP::VICTORY::SKIP_SWITCH]
  468.   end
  469.  
  470.   ## Aliased to skip bgm change if the switch is flipped.
  471.   alias play_battle_bgm_cpv play_battle_bgm unless $@
  472.   def play_battle_bgm
  473.     play_battle_bgm_cpv unless skip?
  474.   end
  475.  
  476.   ## Overwritten for the new victory screen.
  477.   def process_victory
  478.     return if @victory; @victory = true
  479.     $game_system.battle_end_me.play if CP::VICTORY::USE_ME && !skip?
  480.     RPG::BGM.fade(500) unless skip? || CP::VICTORY::USE_ME
  481.     20.times do; Graphics.update; end
  482.     SceneManager.scene.close_status_window
  483.     Audio.return_audio if $imported["CP_CROSSFADE"]
  484.     play_battle_end_me unless skip?  ## Skip the bgm change again.
  485.     @phase = :victory
  486.     SceneManager.scene.show_victory_windows
  487.     exp = gain_exp
  488.     gold = gain_gold
  489.     gain_drop_items
  490.     turns = $game_troop.turn_count
  491.     dlt = Grade.score_items[:damage].dealt
  492.     rcv = Grade.score_items[:damage].recieved
  493.     SceneManager.scene.update_scores(dlt, rcv, turns)
  494.     SceneManager.scene.update_window_rates(exp, gold, Grade.rate[4])
  495.     SceneManager.scene.exp_window_update(exp)
  496.     return true
  497.   end
  498.  
  499.   ## Added to actually leave battle.
  500.   def victory_end
  501.     RPG::BGM.fade(500) unless skip?
  502.     20.times do; Graphics.update; end
  503.     SceneManager.return
  504.     battle_end(0)
  505.     replay_bgm_and_bgs unless skip? || $BTEST
  506.   end
  507.  
  508.   ## Skipped if music is not made to change.
  509.   def play_battle_end_me
  510.     return if @played_bgm > 1
  511.     @played_bgm += CP::VICTORY::USE_ME ? 1 : 2
  512.     Audio.bgm_stop
  513.     if CP::VICTORY::USE_MUSIC
  514.       mus = CP::VICTORY::VICTORY_MUSIC
  515.       vol = (CP::VICTORY::USE_ME && @played_bgm == 1) ? 0 : CP::VICTORY::MSX_VOL
  516.       pit = CP::VICTORY::MSX_PIT
  517.       RPG::BGM.new(mus, vol, pit).play unless mus.nil?
  518.     else
  519.       $game_system.battle_end_me.play
  520.       replay_bgm_and_bgs unless $BTEST
  521.     end
  522.   end
  523.  
  524.   ## Adjusts the gold rate.
  525.   def gain_gold
  526.     if $game_troop.gold_total > 0
  527.       rate = Grade.rate(:gold)
  528.       gold = $game_troop.gold_total
  529.       gold = gold * rate / 100
  530.       $game_party.gain_gold(gold)
  531.     else
  532.       gold = 0
  533.     end
  534.     return gold
  535.   end
  536.  
  537.   ## Adjusts the drop rate.
  538.   def gain_drop_items
  539.     drops = []
  540.     rate = Grade.rate(:drop)
  541.     $game_troop.make_drop_items(rate).each do |item|
  542.       $game_party.gain_item(item, 1)
  543.       drops.push(item)
  544.     end
  545.     SceneManager.scene.drop_items(drops)
  546.   end
  547.  
  548.   ## Adjusts the exp rate.
  549.   def gain_exp
  550.     rate = Grade.rate(:exp)
  551.     $game_party.all_members.each do |actor|
  552.       actor.gain_exp_cpv(actor.xr_exp, rate)
  553. #~       actor.gain_exp_cpv($game_troop.exp_total, rate)
  554.     end
  555.     return $game_troop.exp_total * rate / 100
  556.   end
  557.  
  558.   end
  559. end
  560.  
  561. class Game_Troop < Game_Unit
  562.   ## Checks if a monster has the boss kill flag set.
  563.   def check_boss
  564.     members.each do |enemy|
  565.       next unless enemy.collapse_type == 1
  566.       return true
  567.     end
  568.     return false
  569.   end
  570.  
  571.   ## Adjusted drop rate.
  572.   def make_drop_items(rate = 100)
  573.     dead_members.inject([]) {|r, enemy| r += enemy.make_drop_items(rate) }
  574.   end
  575. end
  576.  
  577. class Game_Battler < Game_BattlerBase
  578.   ## Aliased to add damage dealt and recieved to a value for later.
  579.   alias exec_damage_cpv execute_damage unless $@
  580.   def execute_damage(user)
  581.     if @result.hp_damage > 0
  582.       i = [@result.hp_damage, hp].min
  583.       Grade.score_items[:damage].dealt += i if enemy?
  584.       Grade.score_items[:damage].recieved += i if !enemy?
  585.       if hp == mhp && i >= mhp && enemy?
  586.         Grade.score_items[:damage].onehit += @one_hit
  587.       end
  588.     end
  589.     exec_damage_cpv(user)
  590.   end
  591. end
  592.  
  593. class Game_Enemy < Game_Battler
  594.   attr_accessor :add_score
  595.   attr_accessor :one_hit
  596.  
  597.   ## Gets the default added points for an enemy.
  598.   alias cp_gbv_initialize initialize unless $@
  599.   def initialize(index, enemy_id)
  600.     cp_gbv_initialize(index, enemy_id)
  601.     enemy = $data_enemies[@enemy_id]
  602.     @add_score = enemy.add_score
  603.     @one_hit = enemy.one_hit
  604.   end
  605.  
  606.   ## The actual adjusted drop rate.
  607.   def make_drop_items(rate = 100)
  608.     cpi = rate.to_f / 100
  609.     enemy.drop_items.inject([]) do |r, di|
  610.       if di.kind > 0 && rand * di.denominator < drop_item_rate * cpi
  611.         if Grade.score >= di.req_grade
  612.           r.push(item_object(di.kind, di.data_id))
  613.         else
  614.           r
  615.         end
  616.       else
  617.         r
  618.       end
  619.     end
  620.   end
  621. end
  622.  
  623. class Game_Actor < Game_Battler
  624.   attr_reader :actor_id
  625.  
  626.   alias cp_gv_level_up level_up unless $@
  627.   def level_up
  628.     tmp1 = mhp
  629.     tmp2 = mmp
  630.     cp_gv_level_up
  631.     heal1 = mhp - tmp1
  632.     heal2 = mmp - tmp2
  633.     case CP::VICTORY::HP_HEAL_TYPE
  634.     when 1; self.hp += heal1
  635.     when 2; self.hp = mhp
  636.     end
  637.     case CP::VICTORY::MP_HEAL_TYPE
  638.     when 1; self.mp += heal2
  639.     when 2; self.mp = mmp
  640.     end
  641.   end
  642.  
  643.   ## Just made a whole new exp event here.  Adjusts the rate.
  644.   def gain_exp_cpv(exp, vic_rate = 100)
  645.     change_exp(self.exp + (exp * vic_rate * final_exp_rate / 100).to_i, false)
  646.   end
  647.  
  648.   ## Determines the exp for the last level.
  649.   def last_level_exp
  650.     return 0 if @level <= 0
  651.     return exp_for_level(@level - 1)
  652.   end
  653. end
  654.  
  655. class Scene_Battle < Scene_Base
  656.   if $imported["YSA-PCTB"]
  657.   alias cp_bv_fix_yami_pctb update_pctb_speed unless $@
  658.   def update_pctb_speed
  659.     return if BattleManager.victory_phase?
  660.     cp_bv_fix_yami_pctb
  661.   end
  662.   end
  663.  
  664.   ## Overwritten to stop stuff from happening during the victory phase.
  665.   def update
  666.     super
  667.     if BattleManager.in_turn?
  668.       process_event
  669.       process_action
  670.     end
  671.     BattleManager.judge_win_loss unless BattleManager.victory_phase?
  672.     if BattleManager.victory_phase?
  673.       if @victory_score.done and @victory_score.active
  674.         sfx = CP::VICTORY::IMAGE_SFX
  675.         vol = CP::VICTORY::SFX_VOL
  676.         pit = CP::VICTORY::SFX_PIT
  677.         RPG::SE.new(sfx, vol, pit).play unless sfx.nil?
  678.         @victory_score.active = false
  679.         @victory_item.active = true
  680.       end
  681.     end
  682.   end
  683.  
  684.   ## Terminates the sprites and extra windows at the end of battle.
  685.   alias cp_gv_dispose_all_windows dispose_all_windows unless $@
  686.   def dispose_all_windows
  687.     remove_sprite
  688.     cp_gv_dispose_all_windows
  689.   end
  690.  
  691.   ## Applies score loss/gain when using an item/skill.
  692.   alias cp_gv_use_item use_item unless $@
  693.   def use_item
  694.     item = @subject.current_action.item
  695.     Grade.score_items[:skill].karma += item.add_score
  696.     cp_gv_use_item
  697.   end
  698.  
  699.   ## Closes the status window sorta.
  700.   def close_status_window
  701.     instance_variables.each do |varname|
  702.       ivar = instance_variable_get(varname)
  703.       ivar.openness = 0 if ivar.is_a?(Window)
  704.     end
  705.   end
  706.  
  707.   ## The next few call stuff.
  708.   def exp_window_update(exp)
  709.     @victory_main.redraw_exp(exp)
  710.     create_leveled_windows
  711.     pack_and_send
  712.   end
  713.  
  714.   def update_window_rates(exp, gold, item)
  715.     @victory_rank.get_rates(exp, gold)
  716.     @victory_item_top.get_rates(item)
  717.   end
  718.  
  719.   def update_scores(dealt, recieved, turns)
  720.     @victory_score.draw_score(CP::VICTORY::DEALT_NAME, dealt, 0)
  721.     @victory_score.draw_score(CP::VICTORY::RECIEVED_NAME, recieved, 24)
  722.     @victory_score.draw_score(CP::VICTORY::TURNS_NAME, turns, 48)
  723.     @victory_score.rank_stuff
  724.   end
  725.  
  726.   def show_victory_windows
  727.     @victory_main = Window_VictoryMain.new
  728.     @victory_top = Window_VictoryTop.new
  729.     @victory_score = Window_VictoryScore.new
  730.     @victory_rank = Window_VictoryRank.new
  731.     @victory_item_top = Window_VictoryItemTop.new
  732.     @victory_item = Window_VictoryItem.new
  733.     @victory_main.openness = 0
  734.     @victory_top.openness = 0
  735.     @victory_score.openness = 0
  736.     @victory_rank.openness = 0
  737.     @victory_item_top.openness = 0
  738.     @victory_item.openness = 0
  739.     @victory_main.open
  740.     @victory_top.open
  741.     @victory_score.open
  742.     @victory_rank.open
  743.     @victory_item_top.open
  744.     @victory_item.open
  745.     if CP::VICTORY::USE_IMAGES
  746.       @victory_score.active = true
  747.     else
  748.       @victory_item.active = true
  749.     end
  750.   end
  751.  
  752.   def create_leveled_windows
  753.     @leveled = []
  754.     return if @victory_main.leveled.empty?
  755.     @victory_main.leveled.each {|actor| @leveled.push(Window_LvlUp.new(actor))}
  756.     @leveled.each {|wind| wind.visible = false}
  757.   end
  758.  
  759.   def pack_and_send
  760.     ar1 = [@victory_main, @victory_top, @victory_score, @victory_rank,
  761.            @victory_item_top, @victory_item]
  762.     @victory_item.get_windows(ar1, @leveled)
  763.   end
  764.  
  765.   def remove_sprite
  766.     @victory_score.remove_sprite unless @victory_score.nil? || @victory_score.disposed?
  767.     return if @leveled.nil? || @leveled.empty?
  768.     @leveled.each {|wind| wind.dispose}
  769.   end
  770.  
  771.   ## This pushes the drop items to the drop window.
  772.   def drop_items(drops)
  773.     @victory_item.get_drops(drops)
  774.   end
  775. end
  776.  
  777. ## The main window with the character faces.
  778. class Window_VictoryMain < Window_Selectable
  779.   attr_reader :leveled
  780.  
  781.   def initialize
  782.     super(0, 48, Graphics.width, 152)
  783.     @index = -1
  784.     @leveled = []
  785.     draw_all_items
  786.   end
  787.  
  788.   def draw_all_items
  789.     item_max.times {|i| draw_item(i) }
  790.   end
  791.  
  792.   def redraw_exp(exp)
  793.     item_max.times {|i| draw_exp(i, exp) }
  794.   end
  795.  
  796.   def draw_item(index)
  797.     actor = $game_party.members[index]
  798.     rect = item_rect(index)
  799.     draw_victory_face(actor, rect)
  800.     draw_actor_exp_info(actor, rect.x, rect.y + 104, rect.width)
  801.   end
  802.  
  803.   def draw_victory_face(actor, orect)
  804.     bitmap = Cache.face(actor.face_name)
  805.     rect = Rect.new(actor.face_index % 4 * 96, actor.face_index / 4 * 96, 96, 96)
  806.     fx = (orect.width - 96) / 2
  807.     temp_bit = Bitmap.new(orect.width, orect.height)
  808.     temp_bit.blt(fx, 0, bitmap, rect)
  809.     contents.blt(orect.x, orect.y, temp_bit, temp_bit.rect)
  810.   end
  811.  
  812.   def draw_exp(index, exp)
  813.     actor = $game_party.members[index]
  814.     rect = item_rect(index)
  815.     draw_actor_exp_info(actor, rect.x, rect.y + 104, rect.width, exp)
  816.   end
  817.  
  818.   def draw_actor_exp_info(actor, x, y, width, aexp = 0)
  819.     x += (width - 96) / 2
  820.     width = [width, 96].min
  821.     aexr = aexp * actor.exr
  822.     cexp = actor.exp - actor.current_level_exp
  823.     nexp = actor.next_level_exp - actor.current_level_exp
  824.     if cexp - aexr >= 0
  825.       rate = cexp.to_f / nexp
  826.       rate = 1.0 if rate > 1.0
  827.       gc1 = text_color(CP::VICTORY::EXP_ADDED)
  828.       gc2 = text_color(CP::VICTORY::EXP_ADDED)
  829.       draw_gauge(x, y, width, rate, gc1, gc2)
  830.       cexp -= aexr
  831.       rate = cexp.to_f / nexp
  832.       rate = 1.0 if rate > 1.0
  833.       rate = 1.0 if actor.level == actor.max_level
  834.       gc1 = text_color(CP::VICTORY::EXP_GAUGE_1)
  835.       gc2 = text_color(CP::VICTORY::EXP_GAUGE_2)
  836.       draw_gauge_clear(x, y, width, rate, gc1, gc2)
  837.     else
  838.       rate = 1.0
  839.       gc1 = text_color(CP::VICTORY::EXP_ADDED)
  840.       gc2 = text_color(CP::VICTORY::EXP_ADDED)
  841.       draw_gauge(x, y, width, rate, gc1, gc2)
  842.       cexp = actor.exp - actor.last_level_exp - aexr
  843.       nexp = actor.current_level_exp - actor.last_level_exp
  844.       rate = cexp.to_f / nexp
  845.       gc1 = text_color(CP::VICTORY::EXP_GAUGE_1)
  846.       gc2 = text_color(CP::VICTORY::EXP_GAUGE_2)
  847.       draw_gauge_clear(x, y, width, rate, gc1, gc2)
  848.       change_color(normal_color)
  849.       draw_text(x, y, width, line_height, CP::VICTORY::LEVEL_UP, 1)
  850.       @leveled.push(actor)
  851.     end
  852.   end
  853.  
  854.   def draw_gauge_clear(x, y, width, rate, color1, color2)
  855.     fill_w = (width * rate).to_i
  856.     gauge_y = y + line_height - 8
  857.     contents.gradient_fill_rect(x, gauge_y, fill_w, 6, color1, color2)
  858.   end
  859.  
  860.   def item_max
  861.     $game_party.battle_members.size
  862.   end
  863.  
  864.   def item_height
  865.     return 128
  866.   end
  867.  
  868.   def col_max
  869.     $game_party.max_battle_members
  870.   end
  871.  
  872.   def spacing
  873.     return 0
  874.   end
  875. end
  876.  
  877. ## The window at the top that says victory stuff.
  878. class Window_VictoryTop < Window_Base
  879.   def initialize
  880.     super(0, 0, Graphics.width, 48)
  881.     draw_title
  882.   end
  883.  
  884.   def draw_title
  885.     title = sprintf(Vocab::Victory, $game_party.name)
  886.     change_color(normal_color)
  887.     draw_text(0, 0, contents.width, line_height, title, 1)
  888.   end
  889. end
  890.  
  891. ## The window that shows rank and score stuff.
  892. class Window_VictoryScore < Window_Base
  893.   attr_accessor :done
  894.  
  895.   def initialize
  896.     side = CP::VICTORY::FLIP_LOWER ? Graphics.width / 2 : 0
  897.     super(side, 200, Graphics.width / 2, Graphics.height - 272)
  898.     @done = false
  899.     setup_image if CP::VICTORY::USE_IMAGES
  900.   end
  901.  
  902.   def update
  903.     super
  904.     unless @rank.nil? or @done or !open?
  905.       @rank.opacity += 25
  906.       @rank.zoom_x -= 0.2
  907.       @rank.zoom_y -= 0.2
  908.       if @rank.zoom_y < 1.0
  909.         @done = true
  910.         @rank.zoom_x = 1.0
  911.         @rank.zoom_y = 1.0
  912.       end
  913.     end
  914.   end
  915.  
  916.   def setup_image
  917.     @rank = Sprite.new
  918.   end
  919.  
  920.   def hide_image
  921.     @rank.visible = false if @rank
  922.   end
  923.  
  924.   def remove_sprite
  925.     @rank.dispose unless @rank.nil?
  926.   end
  927.  
  928.   def draw_score(name, value, y)
  929.     change_color(system_color)
  930.     draw_text(16, y, contents.width-32, 24, name, 0)
  931.     change_color(normal_color)
  932.     draw_text(16, y, contents.width-32, 24, value, 2)
  933.   end
  934.  
  935.   def rank_stuff
  936.     draw_rank
  937.     draw_image if CP::VICTORY::USE_IMAGES
  938.   end
  939.  
  940.   def draw_image
  941.     ranking = CP::VICTORY::IMAGE_NAME + Grade.rate[0]
  942.     @rank.bitmap = Cache.system(ranking)
  943.     @rank.ox = @rank.bitmap.width / 2
  944.     @rank.oy = @rank.bitmap.height / 2
  945.     @rank.opacity = 0
  946.     @rank.zoom_x = 5.0
  947.     @rank.zoom_y = 5.0
  948.     @rank.x = x + width - padding - 16 - @rank.bitmap.width / 2
  949.     @rank.y = y + height - padding - 16
  950.     @rank.z = z + 800
  951.   end
  952.  
  953.   def draw_rank
  954.     color = Grade.rate[5]
  955.     rank = Grade.rate[0]
  956.     change_color(system_color)
  957.     contents.font.size = 32
  958.     fs = contents.font.size
  959.     draw_text(16, contents.height-fs, contents.width-32, fs, CP::VICTORY::RANK_NAME, 0)
  960.     change_color(normal_color) if color.nil?
  961.     change_color(text_color(color)) unless color.nil?
  962.     draw_text(16, contents.height-fs, contents.width-32, fs, rank, 2) unless CP::VICTORY::USE_IMAGES
  963.   end
  964. end
  965.  
  966. ## The window that shows exp and gold.
  967. class Window_VictoryRank < Window_Base
  968.   def initialize
  969.     side = CP::VICTORY::FLIP_LOWER ? Graphics.width / 2 : 0
  970.     super(side, Graphics.height - 72, Graphics.width / 2, 72)
  971.   end
  972.  
  973.   def get_rates(exp, gold)
  974.     draw_object(Grade.rate[2], CP::VICTORY::EXP_NAME, exp, 0)
  975.     draw_object(Grade.rate[3], Vocab.currency_unit, gold, 24)
  976.   end
  977.  
  978.   def draw_object(rate, name, value, y)
  979.     change_color(normal_color)
  980.     draw_text(16, y, contents.width - 32, 24, value, 0)
  981.     n = contents.text_size(value).width
  982.     change_color(system_color)
  983.     draw_text(n + 20, y, contents.width - n - 36, 24, name, 0)
  984.     change_color(normal_color)
  985.     text = rate.to_s + "%"
  986.     draw_text(16, y, contents.width - 32, 24, text, 2)
  987.   end
  988. end
  989.  
  990. ## The window that shows drop rate.
  991. class Window_VictoryItemTop < Window_Base
  992.   def initialize
  993.     side = CP::VICTORY::FLIP_LOWER ? 0 : Graphics.width / 2
  994.     super(side, 200, Graphics.width / 2, 48)
  995.   end
  996.  
  997.   def get_rates(rate)
  998.     change_color(system_color)
  999.     draw_text(16, 0, contents.width-32, 24, CP::VICTORY::SPOILS, 0)
  1000.     change_color(normal_color)
  1001.     text = rate.to_s + "%"
  1002.     draw_text(16, 0, contents.width-32, 24, text, 2)
  1003.   end
  1004. end
  1005.  
  1006. ## The window that shows items.  You can scroll through the items in it.
  1007. class Window_VictoryItem < Window_Selectable
  1008.   def initialize
  1009.     side = CP::VICTORY::FLIP_LOWER ? 0 : Graphics.width / 2
  1010.     super(side, 248, Graphics.width / 2, Graphics.height - 248)
  1011.     @index = 0
  1012.   end
  1013.  
  1014.   def item_max
  1015.     @data ? @data.size : 0
  1016.   end
  1017.  
  1018.   def draw_all_items
  1019.     return super if item_max > 0
  1020.     draw_null
  1021.   end
  1022.  
  1023.   def draw_item(index)
  1024.     item = @data[index]
  1025.     if item
  1026.       rect = item_rect(index)
  1027.       rect.width -= 4
  1028.       draw_item_name(item, rect.x, rect.y)
  1029.       draw_item_number(rect, index)
  1030.     end
  1031.   end
  1032.  
  1033.   def draw_null
  1034.     rect = item_rect(0)
  1035.     rect.width -= 4
  1036.     draw_text(rect, CP::VICTORY::NO_DROPS, 1)
  1037.   end
  1038.  
  1039.   def draw_item_number(rect, index)
  1040.     draw_text(rect, sprintf(":%2d", @number[index]), 2)
  1041.   end
  1042.  
  1043.   def get_drops(drops)
  1044.     @data = []
  1045.     @number = []
  1046.     for i in 0...drops.size
  1047.       ind = @data.index(drops[i])
  1048.       if ind.nil?
  1049.         @data.push(drops[i])
  1050.         @number.push(1)
  1051.       else
  1052.         @number[ind] += 1
  1053.       end
  1054.     end
  1055.     self.refresh
  1056.   end
  1057.  
  1058.   def get_windows(ar1, ar2)
  1059.     @done = 0
  1060.     @ar1 = ar1
  1061.     @ar2 = ar2
  1062.   end
  1063.  
  1064.   def process_handling
  1065.     return unless open? && active
  1066.     BattleManager.victory_end if Input.trigger?(:B)
  1067.     check_leveled_up if Input.trigger?(:C)
  1068.   end
  1069.  
  1070.   def check_leveled_up
  1071.     @done = 0 if @done.nil?; @done += 1
  1072.     return BattleManager.victory_end unless CP::VICTORY::LVL_UP_ENABLE
  1073.     return BattleManager.victory_end if @ar2.nil?
  1074.     return BattleManager.victory_end if @done > @ar2.size
  1075.     sfx = CP::VICTORY::LVL_SFX
  1076.     vol = CP::VICTORY::LVL_VOL
  1077.     pit = CP::VICTORY::LVL_PIT
  1078.     RPG::SE.new(sfx, vol, pit).play unless sfx.nil?
  1079.     @ar1.each {|wind| wind.visible = false}
  1080.     @ar2.each {|wind| wind.visible = false}
  1081.     @ar1[2].hide_image
  1082.     @ar2[@done - 1].visible = true
  1083.   end
  1084.  
  1085.   def update
  1086.     super
  1087.     if Audio.bgm_pos != 0
  1088.       BattleManager.play_battle_end_me
  1089.     end
  1090.   end
  1091.  
  1092.   def refresh
  1093.     contents.clear
  1094.     create_contents
  1095.     draw_all_items
  1096.   end
  1097. end
  1098.  
  1099. ## Modifies a skill's score modification when used.
  1100. class RPG::UsableItem < RPG::BaseItem
  1101.   def add_score
  1102.     karma_modif if @add_score.nil?
  1103.     return @add_score
  1104.   end
  1105.  
  1106.   def karma_modif
  1107.     @add_score = 0
  1108.     self.note.split(/[\r\n]+/).each do |line|
  1109.       case line
  1110.       when CP::VICTORY::KARMA
  1111.         @add_score = ($1.to_s + $2.to_s).to_i
  1112.       end
  1113.     end
  1114.   end
  1115. end
  1116.  
  1117. class RPG::Enemy::DropItem
  1118.   def req_grade
  1119.     return @req_grade ? @req_grade : 0
  1120.   end
  1121.  
  1122.   def req_grade=(val)
  1123.     @req_grade = val
  1124.   end
  1125. end
  1126.  
  1127. ## Modifies the enemy's drops from the database.
  1128. class RPG::Enemy < RPG::BaseItem
  1129.   def add_score
  1130.     add_drops if @add_score.nil?
  1131.     return @add_score
  1132.   end
  1133.  
  1134.   def one_hit
  1135.     add_drops if @one_hit.nil?
  1136.     return @one_hit
  1137.   end
  1138.  
  1139.   def drop_items
  1140.     add_drops if @added_drops.nil?
  1141.     return @drop_items
  1142.   end
  1143.  
  1144.   def add_drops
  1145.     @added_drops = true
  1146.     @add_score = 0
  1147.     @one_hit = CP::VICTORY::ONE_HIT
  1148.     self.note.split(/[\r\n]+/).each do |line|
  1149.       case line
  1150.       when CP::VICTORY::DROPS
  1151.         temp = RPG::Enemy::DropItem.new
  1152.         case $1.to_s
  1153.         when "I", "i"
  1154.           temp.kind = 1
  1155.         when "W", "w"
  1156.           temp.kind = 2
  1157.         when "A", "a"
  1158.           temp.kind = 3
  1159.         end
  1160.         temp.data_id = $2.to_i
  1161.         temp.denominator = $3.to_i
  1162.         temp.req_grade = $4.to_i
  1163.         @drop_items.push(temp)
  1164.       when CP::VICTORY::SCORE
  1165.         @add_score = $1.to_i
  1166.       when CP::VICTORY::ONEHIT
  1167.         @one_hit = $1.to_i
  1168.       end
  1169.     end
  1170.   end
  1171. end
  1172.  
  1173. ## Creates windows at the end of the victory screen that display level up stats.
  1174. class Window_LvlUp < Window_Base
  1175.   def initialize(actor)
  1176.     @actor = actor  ## Gets the actor, old level, and new skills.
  1177.     @old_level = BattleManager.old_levels(actor.actor_id)
  1178.     @skills = actor.skills - BattleManager.old_skills(actor.actor_id)
  1179.     create_params  ## Creates all params.  Here for custom params.
  1180.     super(0, 0, box_width, box_height)  ## Creates and moves the box.
  1181.     self.x = (Graphics.width - width) / 2
  1182.     self.y = (Graphics.height - height) / 2
  1183.     refresh
  1184.   end
  1185.  
  1186.   ## Creates the entire list of params.
  1187.   def create_params
  1188.     @params = []
  1189.     8.times do |i|
  1190.       p1 = @actor.class.params[i, @old_level]
  1191.       p2 = @actor.class.params[i, @actor.level]
  1192.       vocab = Vocab.param(i)
  1193.       add_param(vocab, p1, p2)
  1194.     end
  1195.   end
  1196.  
  1197.   ## Adds a param to the list.
  1198.   def add_param(vocab, p1, p2)
  1199.     @params.push([vocab, p1, p2])
  1200.   end
  1201.  
  1202.   ## Width of the box based on whether any new skills were learned.
  1203.   def box_width
  1204.     wd = @skills.empty? ? 240 : 480
  1205.     return wd + standard_padding * 2
  1206.   end
  1207.  
  1208.   ## Height of the box based on total params.
  1209.   def box_height
  1210.     return line_height + 104 + line_height * (@params.size + 1)
  1211.   end
  1212.  
  1213.   ## Refreshed the box contents.
  1214.   def refresh
  1215.     contents.clear
  1216.     draw_header
  1217.     draw_face_area(line_height * 1.5)
  1218.     draw_attr_area(0, line_height * 2 + 104)
  1219.     draw_skill_area(240, line_height * 2 + 104)
  1220.   end
  1221.  
  1222.   ## Draws the level up header.
  1223.   def draw_header
  1224.     x = (contents.width - 240) / 2
  1225.     ml = 0
  1226.     p1 = @old_level
  1227.     p2 = @actor.level
  1228.     ml = contents.text_size(p1).width if contents.text_size(p1).width > ml
  1229.     ml = contents.text_size(p2).width if contents.text_size(p2).width > ml
  1230.     ml += 4
  1231.     mo = 236 - ml
  1232.     change_color(system_color)
  1233.     draw_text(x + 2, 0, mo - ml - 22, line_height, CP::VICTORY::LEVEL_UP, 0)
  1234.     draw_text(x + mo - 22, 0, 22, line_height, "→", 1)
  1235.     change_color(normal_color)
  1236.     draw_text(x + mo - ml - 22, 0, ml, line_height, p1, 2)
  1237.     change_color(power_up_color)
  1238.     draw_text(x + mo, 0, ml, line_height, p2, 2)
  1239.   end
  1240.  
  1241.   ## Draws the params section.
  1242.   def draw_attr_area(x, y)
  1243.     ml = 0
  1244.     @params.each do |p|  ## Find the wides param.
  1245.       ml = contents.text_size(p[1]).width if contents.text_size(p[1]).width > ml
  1246.       ml = contents.text_size(p[2]).width if contents.text_size(p[2]).width > ml
  1247.     end
  1248.     ml += 4  ## Set params box size.
  1249.     mo = 236 - ml  ## Last object's location.
  1250.     @params.each_with_index do |para, i|
  1251.       ylh = y + i * line_height  ## Gets the y location.
  1252.       change_color(system_color)  ## Draws the name and arrow.
  1253.       draw_text(x + 2, ylh, mo - ml - 22, line_height, para[0], 0)
  1254.       draw_text(x + mo - 22, ylh, 22, line_height, "→", 1)
  1255.       change_color(normal_color)  ## Draws the old and new stats.
  1256.       draw_text(x + mo - ml - 22, ylh, ml, line_height, para[1], 2)
  1257.       change_color(para[2] > para[1] ? power_up_color : power_down_color)
  1258.       change_color(normal_color) if para[1] == para[2]
  1259.       draw_text(x + mo, ylh, ml, line_height, para[2], 2)
  1260.     end
  1261.   end
  1262.  
  1263.   def draw_face_area(y)  ## Draws the area with the face, name, and class.
  1264.     xi = (contents.width - 216) / 2
  1265.     draw_actor_name(@actor, xi + 104, y + 0 * line_height)
  1266.     draw_actor_class(@actor, xi + 104, y + 1 * line_height)
  1267.     draw_actor_face(@actor, xi + 4, y + 4)
  1268.   end
  1269.  
  1270.   def draw_skill_area(x, y)  ## Draw skill names.
  1271.     change_color(system_color)  ## First, draw the skill message.
  1272.     draw_text(x + 18, y, 220, line_height, CP::VICTORY::NEW_SKILLS, 1)
  1273.     change_color(normal_color)  ## Next, check if there are too many skills.
  1274.     if @skills.size > @params.size - 1
  1275.       total = @params.size-3
  1276.       total.times do |i|
  1277.         item = @skills[i]  ## Draws only so many skills.
  1278.         draw_item_name(item, x + 18, y + (i + 1) * line_height, true, 220)
  1279.       end  ## Draws the final message.
  1280.       draw_text(x + 18, y + (@params.size - 2) * line_height, 220, line_height,
  1281.                 more_skills, 1)
  1282.     else
  1283.       @skills.each_with_index do |item, i|  ## Draws all skills.
  1284.         draw_item_name(item, x + 18, y + (i + 1) * line_height, true, 220)
  1285.       end
  1286.     end
  1287.   end
  1288.  
  1289.   def more_skills  ## Gets the more skills text.
  1290.     more = @skills.size - @params.size
  1291.     return sprintf(CP::VICTORY::MORE_SKILLS, more)
  1292.   end
  1293. end
  1294.  
  1295.  
  1296. ###--------------------------------------------------------------------------###
  1297. #  End of script.                                                              #
  1298. ###--------------------------------------------------------------------------###
回复 支持 反对

使用道具 举报

Lv5.捕梦者

梦石
0
星屑
31681
在线时间
5077 小时
注册时间
2012-11-19
帖子
4877

开拓者

 楼主| 发表于 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 各类型脚本/插件定制
回复 支持 反对

使用道具 举报

Lv5.捕梦者

梦石
0
星屑
24057
在线时间
4983 小时
注册时间
2016-3-8
帖子
1613
发表于 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)
回复 支持 反对

使用道具 举报

Lv5.捕梦者

梦石
0
星屑
31681
在线时间
5077 小时
注册时间
2012-11-19
帖子
4877

开拓者

 楼主| 发表于 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 各类型脚本/插件定制
回复 支持 反对

使用道具 举报

Lv5.捕梦者

梦石
0
星屑
31681
在线时间
5077 小时
注册时间
2012-11-19
帖子
4877

开拓者

 楼主| 发表于 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 各类型脚本/插件定制
回复 支持 反对

使用道具 举报

Lv5.捕梦者

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


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

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

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-3-29 09:51

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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