Advertisement
Dekita

Untitled

Jan 15th, 2013
528
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.98 KB | None | 0 0
  1. =begin =========================================================================
  2. Dekita's v1.2
  3. ★ Pokémon Natures ENEMY ADDON™ ★
  4.  
  5. ================================================================================
  6. Script Information:
  7. ====================
  8. This script replicates the natures / iv / ev / levels feature from pokemon,
  9. e.g each pokemon, (in this case ENEMY) is given a random nature, iv/ev value
  10. and level upon encounter, That enemies stats are then determined by that.
  11. Use map notetags toset enemy levels and use script calls to make fixed encounters
  12. e.g set nature iv, ev and lvl.
  13.  
  14. NOTE: This works 98% like pokemon.
  15. (minus trainer and wild calculations in the formula)
  16.  
  17. ================================================================================
  18. ★☆★☆★☆★☆★☆★☆★☆★ TERMS AND CONDITIONS: ☆★☆★☆★☆★☆★☆★☆★☆★☆
  19. ================================================================================
  20. 1. You must give credit to "Dekita"
  21. 2. You are NOT allowed to repost this script.(or modified versions)
  22. 3. You are NOT allowed to convert this script.(into other game engines e.g RGSS2)
  23. 4. You are NOT allowed to use this script for Commercial games.
  24. 5. ENJOY!
  25.  
  26. "FINE PRINT"
  27. By using this script you hereby agree to the above terms and conditions,
  28. if any violation of the above terms occurs "legal action" may be taken.
  29. Not understanding the above terms and conditions does NOT mean that
  30. they do not apply to you.
  31. If you wish to discuss the terms and conditions in further detail you can
  32. contact me at http://dekitarpg.wordpress.com/ or DekitaRPG@gmail.com
  33.  
  34. ================================================================================
  35. History:
  36. =========
  37. D /M /Y
  38. 14/o1/2o13 - added enemy ev's,
  39. - fixed exp gain formula,
  40. - fixed gold gain formula,
  41. - fixed script header,
  42. 16/11/2o12 - finished,
  43.  
  44. ================================================================================
  45. Credit and Thanks to :
  46. =======================
  47.  
  48. ================================================================================
  49. Known Bugs:
  50. ============
  51. N/A
  52.  
  53. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  54. If a new bug is found please contact me at
  55. http://dekitarpg.wordpress.com/
  56.  
  57. ================================================================================
  58. INSTRUCTIONS:
  59. ==============
  60. Place this script UNDER "▼ Materials" and ABOVE "▼ Main" in your script editor.
  61.  
  62. =end #==========================================================================#
  63. module Dekita__Pokemon_Enemies
  64.  
  65. # NOTETAGS :
  66.  
  67. # <lv: min, max>
  68. # <ene lv: enemy_id, min, max>
  69. # these go in map noteboxes, replace min with the maps minimum map level, max
  70. # with the maximum,
  71. # enemy_id = the enemy id in the database.
  72.  
  73. # SCRIPT CALLS :
  74. # fix_lv_battle(val)
  75. # fix_nature_battle(val)
  76.  
  77. # fix_iv_battle(mhp, mmp, atk, def, mat, mdf, agi, luk)
  78. # val = an integer
  79. # replace mhp, mmp, atk, def, mat, mdf, agi and luk with values between 0 - 31
  80. # and this will change that enemies iv values to whatever you set.
  81. # REMEMBER iv values are different from the acctual param value, but they do
  82. # affect param values
  83.  
  84. # fix_ev_battle(mhp, mmp, atk, def, mat, mdf, agi, luk)
  85. # val = an integer
  86. # replace mhp, mmp, atk, def, mat, mdf, agi and luk with values between 0 - 255
  87. # and this will change that enemies ev values to whatever you set.
  88. # REMEMBER ev values are different from the acctual param value, but they do
  89. # affect param values
  90. # ALSO a total ev amount should never go above 512, but you can if you want...
  91.  
  92. # The maximum level for enemies
  93. Max_Level = 100
  94.  
  95. # enemies will randomly gain UPTO and including this amount of
  96. # Ev points which can make a significant difference in later levels.
  97. Random_Ev_Amount = 100
  98.  
  99. Use_Exp_Gain_Formula = true
  100.  
  101. Use_Gold_Gain_Formula = true
  102.  
  103. # as enemy levels are based on maps and during battle test there is no map id,
  104. # you have to set the min and max level for enemies in test battles here.
  105. BattleTest_Level = [5, 10] # [min, max]
  106.  
  107. end
  108.  
  109. $imported = {} if $imported.nil?
  110. $imported[:Dekita_Pokémon_Enemies] = true
  111.  
  112. #################################################################################
  113. #################################################################################
  114. # As team rocket where once again "blasting off" Ash, Brock and Misty slowly #
  115. # lifted their bodies from the ground, turning, gasping at the horror they could#
  116. # see before them... #
  117. #################################################################################
  118. #################### !! DONT MODIFY SHIT AFTER HERE !! ##########################
  119. #################################################################################
  120. class RPG::Map
  121. #===============================================================================#
  122.  
  123. attr_accessor :map_level_range
  124. attr_accessor :map_level_rangeind_poks
  125.  
  126. def load_enemy_levels
  127. @map_level_range = [1, Dekita__Pokemon_Enemies::Max_Level]
  128. @map_level_rangeind_poks = []
  129. self.note.split(/[\r\n]+/).each { |line|
  130. case line
  131. when /<lv: (.*), (.*)>/i
  132. @map_level_range = [$1.to_i, $2.to_i]
  133. #---
  134. when /<ene lv: (.*), (.*), (.*)>/i
  135. @map_level_rangeind_poks.push([$1.to_i, $2.to_i, $3.to_i])
  136. #---
  137. end
  138. } # self.note.split
  139. end
  140.  
  141. end
  142.  
  143. #===============================================================================#
  144. class Game_Map
  145. #===============================================================================#
  146.  
  147. attr_reader :level_range_min
  148. attr_reader :level_range_max
  149. attr_reader :map_level_rangeind_poks
  150.  
  151. alias enemylevelsmapsetup setup
  152. def setup(map_id)
  153. enemylevelsmapsetup(map_id)
  154. @map.load_enemy_levels
  155. @level_range_min = @map.map_level_range[0]
  156. @level_range_max = @map.map_level_range[1]
  157. @map_level_rangeind_poks = @map.map_level_rangeind_poks
  158. # p "@map_level_rangeind_poks = #{@map_level_rangeind_poks}"
  159. end
  160.  
  161. end
  162.  
  163. #===============================================================================#
  164. class Game_Temp
  165. #===============================================================================#
  166.  
  167. attr_accessor :fixed_level_battle
  168. attr_accessor :fixed_nature_battle
  169. attr_accessor :fixed_iv_battle
  170. attr_accessor :fixed_ev_battle
  171.  
  172. alias pokenemylvsgtinit initialize
  173. def initialize
  174. pokenemylvsgtinit
  175. init_fixed_enemies_info
  176. end
  177.  
  178. def init_fixed_enemies_info
  179. @fixed_level_battle = [false, 0]
  180. @fixed_nature_battle = [false, 0]
  181. @fixed_iv_battle = [false, 0, 0, 0, 0, 0, 0, 0, 0]
  182. @fixed_ev_battle = [false, 0, 0, 0, 0, 0, 0, 0, 0]
  183. end
  184.  
  185. def clear_fixed_level_data
  186. @fixed_level_battle = [false, 0]
  187. end
  188.  
  189. def clear_fixed_nature_data
  190. @fixed_nature_battle = [false, 0]
  191. end
  192.  
  193. def clear_fixed_iv_data
  194. @fixed_iv_battle = [false, 0, 0, 0, 0, 0, 0, 0, 0]
  195. end
  196.  
  197. def clear_fixed_ev_data
  198. @fixed_ev_battle = [false, 0, 0, 0, 0, 0, 0, 0, 0]
  199. end
  200.  
  201. end # Game_Temp
  202.  
  203. #===============================================================================#
  204. class Game_Enemy < Game_Battler
  205. #===============================================================================#
  206.  
  207. attr_accessor :level
  208. attr_accessor :nature
  209. attr_accessor :init_ivs
  210. attr_accessor :curr_evs
  211.  
  212. alias init_for_enemy_levels initialize
  213. def initialize(index, enemy_id)
  214. setup_enemies_pokestylee(enemy_id)
  215. init_for_enemy_levels(index, enemy_id)
  216. end
  217.  
  218. def setup_enemies_pokestylee(enemy_id)
  219. dekita_natures_for_enemies_agogo
  220. get_enemy_level(enemy_id)
  221. end
  222.  
  223. def dekita_natures_for_enemies_agogo
  224. return if !$imported[:Dekita_Pokémon_Natures]
  225. @init_ivs = [0] * 8
  226. @curr_evs = [0] * 8
  227. @nature = get_rand_nature
  228. get_init_ivs
  229. get_init_evs
  230. end
  231.  
  232. def get_enemy_level(enemy_id)
  233. @level = 1
  234. if $game_temp.fixed_level_battle[0] == true
  235. @level = $game_temp.fixed_level_battle[1]
  236. $game_temp.clear_fixed_level_data
  237. elsif $BTEST
  238. min = Dekita__Pokemon_Enemies::BattleTest_Level[0]
  239. max = Dekita__Pokemon_Enemies::BattleTest_Level[1]
  240. @level = (min+rand(max-min+1))
  241. else
  242. $game_map.map_level_rangeind_poks.size.times {|i|
  243. p "Checked"
  244. if $game_map.map_level_rangeind_poks[i][0] == enemy_id
  245. p "Returned"
  246. checker = $game_map.map_level_rangeind_poks[i]
  247. @level = (checker[1] + rand(checker[2] - checker[1]+1))
  248. else
  249. p "Not Returned"
  250. @level = ($game_map.level_range_min + rand($game_map.level_range_max - $game_map.level_range_min+1))
  251. end
  252. }
  253. end
  254. @level = [[@level, Dekita__Pokemon_Enemies::Max_Level].min, 1].max
  255. end
  256.  
  257. def fixed_enemy_level_for_map(check)
  258. checker = $game_map.map_level_rangeind_poks[check]
  259. @level = (checker[1] + rand(checker[2] - checker[1]+1))
  260. end
  261.  
  262. def get_init_ivs
  263. return get_fixed_ivs if $game_temp.fixed_iv_battle[0]
  264. 8.times {|i|
  265. @init_ivs[i] = (rand(Dekita__Pokémon_Nature::Max_IV_Amount+1))
  266. p "Got enemies iv's #{@init_ivs[i]}"
  267. }
  268. end
  269.  
  270. def get_init_evs
  271. return get_fixed_evs if $game_temp.fixed_iv_battle[0]
  272. 8.times {|i|
  273. @curr_evs[i] = rand(Dekita__Pokemon_Enemies::Random_Ev_Amount)
  274. p "Got enemies ev's #{@curr_evs[i]}"
  275. }
  276. end
  277.  
  278. def get_fixed_ivs
  279. fixed_val = $game_temp.fixed_iv_battle
  280. 8.times {|i|
  281. @init_ivs[i] = fixed_val[i+1]
  282. p "Got enemies iv's #{@init_ivs[i]}"
  283. }
  284. $game_temp.clear_fixed_iv_data
  285. end
  286.  
  287. def get_fixed_evs
  288. fixed_val = $game_temp.fixed_ev_battle
  289. 8.times {|i|
  290. @curr_evs[i] = fixed_val[i+1]
  291. p "Got enemies ev's #{@curr_evs[i]}"
  292. }
  293. $game_temp.clear_fixed_ev_data
  294. end
  295.  
  296. def get_rand_nature
  297. t1_ = $game_temp.fixed_nature_battle[0]
  298. dnar = (Dekita__Pokémon_Nature::Nature.size)
  299. val = rand(dnar)
  300. if t1_
  301. val = $game_temp.fixed_nature_battle[1]
  302. $game_temp.clear_fixed_nature_data
  303. return Dekita__Pokémon_Nature::Nature[val]
  304. end
  305. return Dekita__Pokémon_Nature::Nature[val]
  306. end
  307.  
  308. alias enemiesparbase param_base
  309. def param_base(param_id)
  310. if $imported[:Dekita_Pokémon_Natures]
  311. par_id = param_id
  312. case par_id
  313. when 0, 1 # NOTE : if you change these calculations your a fucking moron ! ijs...
  314. return ( (((@init_ivs[par_id]+2*enemy.params[par_id]+(0/4))*@level/100)+10+@level)*@nature[par_id+1]).to_i
  315. when 2, 3, 4, 5, 6, 7
  316. return ( (((@init_ivs[par_id]+2*enemy.params[par_id]+(0/4))*@level/100)+5)*@nature[par_id+1]).to_i
  317. end
  318. else
  319. enemiesparbase(param_id)
  320. end
  321. end
  322.  
  323. alias :nme_exp_natures :exp
  324. def exp
  325. if Dekita__Pokemon_Enemies::Use_Exp_Gain_Formula
  326. #(((enemy.exp * @level)) / 7).to_i#.round
  327. _A = ((@level * 2) + 10)
  328. _B = (enemy.exp * @level / 5)
  329. _C = (@level + $game_party.battle_members[0].level + 10)
  330. val = ((_A)*(_A*_A).floor).floor*_B/((_C)*(_C*_C)).floor+1
  331. return val
  332. else
  333. return nme_exp_natures
  334. end
  335. end
  336. #floor
  337. # floor(floor(√(A)*(A*A))*B/floor(√(C)*(C*C)))+1
  338. # Here, value A is equal to the (OpponentLevel * 2) + 10
  339. # Value C is (OpponentLevel + UserLevel + 10)
  340. # Value B is a more complicated variable and is where things start seeing changes.
  341. # Normally, Value B is a simple (OpponentBaseExperience * OpponentLevel / 5).
  342. # However, there are multiple additions and are calculated in order.
  343. # In trainer battles, value B is multiplied by 1.5
  344. # If a Pokémon has EXP. Share, then B is halved
  345. # Value B is then divided by the amount of team members who have been in
  346. # battle against the Pokémon that has been defeated.
  347.  
  348.  
  349. alias :pokgold :gold
  350. def gold
  351. if Dekita__Pokemon_Enemies::Use_Gold_Gain_Formula
  352. _A = ((@level * 2) + 10)
  353. _B = (enemy.gold * @level / 5)
  354. _C = (@level + $game_party.battle_members[0].level + 10)
  355. val = ((_A)*(_A*_A).floor).floor*_B/((_C)*(_C*_C)).floor+1
  356. return val
  357. else
  358. pokgold
  359. end
  360. end
  361.  
  362.  
  363. end # Game_Enemy < Game_Battler
  364.  
  365. #==============================================================================
  366. class Game_Interpreter
  367. #==============================================================================
  368.  
  369. def fix_lv_battle(val)
  370. $game_temp.fixed_level_battle[0] = true
  371. $game_temp.fixed_level_battle[1] = val
  372. end
  373.  
  374. def fix_nature_battle(val)
  375. $game_temp.fixed_nature_battle[0] = true
  376. $game_temp.fixed_nature_battle[1] = val
  377. end
  378.  
  379. def fix_iv_battle(val_1,val_2,val_3,val_4,val_5,val_6,val_7,val_8)
  380. $game_temp.fixed_iv_battle[0] = true
  381. $game_temp.fixed_iv_battle[1] = val_1
  382. $game_temp.fixed_iv_battle[2] = val_2
  383. $game_temp.fixed_iv_battle[3] = val_3
  384. $game_temp.fixed_iv_battle[4] = val_4
  385. $game_temp.fixed_iv_battle[5] = val_5
  386. $game_temp.fixed_iv_battle[6] = val_6
  387. $game_temp.fixed_iv_battle[7] = val_7
  388. $game_temp.fixed_iv_battle[8] = val_8
  389. end
  390.  
  391. def fix_ev_battle(val_1,val_2,val_3,val_4,val_5,val_6,val_7,val_8)
  392. $game_temp.fixed_ev_battle[0] = true
  393. $game_temp.fixed_ev_battle[1] = val_1
  394. $game_temp.fixed_ev_battle[2] = val_2
  395. $game_temp.fixed_ev_battle[3] = val_3
  396. $game_temp.fixed_ev_battle[4] = val_4
  397. $game_temp.fixed_ev_battle[5] = val_5
  398. $game_temp.fixed_ev_battle[6] = val_6
  399. $game_temp.fixed_ev_battle[7] = val_7
  400. $game_temp.fixed_ev_battle[8] = val_8
  401. end
  402.  
  403. end # Game_Interpreter
  404.  
  405. #===============================================================================#
  406. # - SCRIPT END - #
  407. #===============================================================================#
  408. # http://dekitarpg.wordpress.com/ #
  409. #===============================================================================#
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement