Advertisement
Scinaya

Enemy Upgrading by Sky

Apr 28th, 2011
697
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 9.01 KB | None | 0 0
  1. #===========================================================================
  2. #
  3. # Sky's Enemy (Up/De)grading by Turn
  4. # Version 1.0
  5. # Started May 21, 2010
  6. # Comlete May 22, 2010
  7. #
  8. #===========================================================================
  9. #
  10. # Features :
  11. #    Version 1.0 -
  12. #       - Enemies get stronger or weaker every
  13. #         certain amount of turns.
  14. #
  15. #===========================================================================
  16. #
  17. # Credit (be sure to credit the following and rpgmakervx.net)
  18. # Sky00Valentine :creator and editor (You aren't required to include me, but I wouldn't mind if you did.)
  19. #    //mitch.exe :for requesting the script
  20. #
  21. #===========================================================================
  22. #
  23. # Terms of Use
  24. # ------------
  25. #
  26. #     Crediting Rpgmakervx.net and //mitch.exe is the only thing I ask.
  27. #     However feel free to credit Sky00Valentine if you
  28. #     see fit.
  29. #
  30. #===========================================================================
  31. #
  32. # Future improvement
  33. # ------------------
  34. #  
  35. #    - Adding the ability to add or change states also(im lazy right now)
  36. #    - Adding the ability to stop upgrading or degrading after a set number
  37. #      of times.
  38. #    - Adding the ability to change stats based on a different stat.
  39. #    - Maybe adding in custom stats as well.
  40. #
  41. #===========================================================================
  42. #
  43. # Instructions & Installation
  44. # ---------------------------
  45. # - add under any custom battle scripts and/or Materials
  46. #
  47. # - These are the 'commands' you add to an enemy's notebox
  48. #  
  49. #  command is basically what you want to do
  50. #   x:y  (x is the number you want to use)
  51. #        (: stands for per)
  52. #        (y is the number of turns)
  53. #  so 3:2 means 3 per 2 turns
  54. #  this will be repeated below to help understand after you see the actual
  55. #  commands
  56. #
  57. # command  x:y
  58. #    |      |
  59. #    |      |
  60. #    V      V
  61. # <ATKCON+ x:y>  --> Adds a constant number to enemy attack
  62. # <DEFCON+ x:y>  --> Adds a constant number to enemy defense
  63. # <AGICON+ x:y>  --> Adds a constant number to enemy agility
  64. # <SPICON+ x:y>  --> Adds a constant number to enemy spirit
  65. # <ATKCON- x:y>  --> Subracts a constant number from enemy attack
  66. # <DEFCON- x:y>  --> Subracts a constant number from enemy defense
  67. # <AGICON- x:y>  --> Subracts a constant number from enemy agility
  68. # <SPICON- x:y>  --> Subracts a constant number from enemy spirit
  69. # <ATKPER+ x:y>  --> Adds a percentage of enemy attack to enemy attack
  70. # <DEFPER+ x:y>  --> Adds a percentage of enemy attack to enemy defense
  71. # <AGIPER+ x:y>  --> Adds a percentage of enemy attack to enemy agility
  72. # <SPIPER+ x:y>  --> Adds a percentage of enemy attack to enemy spirit
  73. # <ATKPER- x:y>  --> Subtracts a percentage of enemy attack from enemy attack
  74. # <DEFPER- x:y>  --> Subtracts a percentage of enemy attack from enemy defense
  75. # <AGIPER- x:y>  --> Subtracts a percentage of enemy attack from enemy agility
  76. # <SPIPER- x:y>  --> Subtracts a percentage of enemy attack from enemy spirit
  77. #
  78. #
  79. #  command is basically what you want to do
  80. #   x:y  (x is the number you want to use)
  81. #        (: stands for per)
  82. #        (y is the number of turns)
  83. #  so <ATKCON+ 10:4>  means this enemy will gain 10 more attack every 4 turns
  84. #     <AGIPER- 5:10>  means this enemy will lose 5 percent of thier current
  85. #                     agility every 10 turns
  86. #
  87. #===========================================================================
  88. #
  89. # Compatibility & Bugs
  90. # --------------------
  91. # Not sure if this will work with other custom battle scripts but
  92. # it should as far as I can tell.
  93. #
  94. #===========================================================================
  95.  
  96. class Scene_Battle
  97.   alias get_stronger_by_turn turn_end
  98.   def turn_end
  99.     for i in 0...$game_troop.members.size
  100.       text = $game_troop.members[i].enemy.note
  101.       unless $game_troop.members[i].dead?
  102.         text.each_line{|x| line = x[0,x.index(">") + 1]
  103.           unless line == nil
  104.             variable_list = line[9..(line.index('>') - 1)]
  105.             variables =  variable_list.split(":")
  106.             if line.include?("<ATKCON")
  107.               if line[7,1] == "+"
  108.                 if ($game_troop.turn_count % variables[1].to_i) == 0
  109.                   $game_troop.members[i].atk += variables[0].to_i
  110.                 end
  111.               elsif line[7,1] == "-"
  112.                 if ($game_troop.turn_count % variables[1].to_i) == 0
  113.                   $game_troop.members[i].atk -= variables[0].to_i
  114.                 end
  115.               else
  116.                 raise Exception.new("#{line[7,1]} is not a valid function")
  117.               end
  118.             end
  119.             if line.include?("<DEFCON")
  120.               if line[7,1] == "+"
  121.                 if ($game_troop.turn_count % variables[1].to_i) == 0
  122.                   $game_troop.members[i].def += variables[0].to_i
  123.                 end
  124.               elsif line[7,1] == "-"
  125.                 if ($game_troop.turn_count % variables[1].to_i) == 0
  126.                   $game_troop.members[i].def -= variables[0].to_i
  127.                 end
  128.               else
  129.                 raise Exception.new("#{line[7,1]} is not a valid function")
  130.               end
  131.             end
  132.             if line.include?("<AGICON")
  133.               if line[7,1] == "+"
  134.                 if ($game_troop.turn_count % variables[1].to_i) == 0
  135.                   $game_troop.members[i].agi += variables[0].to_i
  136.                 end
  137.               elsif line[7,1] == "-"
  138.                 if ($game_troop.turn_count % variables[1].to_i) == 0
  139.                   $game_troop.members[i].agi -= variables[0].to_i
  140.                 end
  141.               else
  142.                 raise Exception.new("#{line[7,1]} is not a valid function")
  143.               end
  144.             end
  145.             if line.include?("<SPICON")
  146.               if line[7,1] == "+"
  147.                 if ($game_troop.turn_count % variables[1].to_i) == 0
  148.                   $game_troop.members[i].spi += variables[0].to_i
  149.                 end
  150.               elsif line[7,1] == "-"
  151.                 if ($game_troop.turn_count % variables[1].to_i) == 0
  152.                   $game_troop.members[i].spi -= variables[0].to_i
  153.                 end
  154.               else
  155.                 raise Exception.new("#{line[7,1]} is not a valid function")
  156.               end
  157.             end
  158.             if line.include?("<ATKPER")
  159.               if line[7,1] == "+"
  160.                 if ($game_troop.turn_count % variables[1].to_i) == 0
  161.                   $game_troop.members[i].atk += (($game_troop.members[i].atk / 100.0 * variables[0].to_i).round).to_i
  162.                 end
  163.               elsif line[7,1] == "-"
  164.                 if ($game_troop.turn_count % variables[1].to_i) == 0
  165.                   $game_troop.members[i].atk -= (($game_troop.members[i].atk / 100.0 * variables[0].to_i).round).to_i
  166.                 end
  167.               else
  168.                 raise Exception.new("#{line[7,1]} is not a valid function")
  169.               end
  170.             end
  171.             if line.include?("<DEFPER")
  172.               if line[7,1] == "+"
  173.                 if ($game_troop.turn_count % variables[1].to_i) == 0
  174.                   $game_troop.members[i].def += (($game_troop.members[i].def / 100.0 * variables[0].to_i).round).to_i
  175.                 end
  176.               elsif line[7,1] == "-"
  177.                 if ($game_troop.turn_count % variables[1].to_i) == 0
  178.                   $game_troop.members[i].def -= (($game_troop.members[i].def / 100.0 * variables[0].to_i).round).to_i
  179.                 end
  180.               else
  181.                 raise Exception.new("#{line[7,1]} is not a valid function")
  182.               end
  183.             end
  184.             if line.include?("<AGIPER")
  185.               if line[7,1] == "+"
  186.                 if ($game_troop.turn_count % variables[1].to_i) == 0
  187.                   $game_troop.members[i].agi += (($game_troop.members[i].agi / 100.0 * variables[0].to_i).round).to_i
  188.                 end
  189.               elsif line[7,1] == "-"
  190.                 if ($game_troop.turn_count % variables[1].to_i) == 0
  191.                   $game_troop.members[i].agi -= (($game_troop.members[i].agi / 100.0 * variables[0].to_i).round).to_i
  192.                 end
  193.               else
  194.                 raise Exception.new("#{line[7,1]} is not a valid function")
  195.               end
  196.             end
  197.             if line.include?("<SPIPER")
  198.               if line[7,1] == "+"
  199.                 if ($game_troop.turn_count % variables[1].to_i) == 0
  200.                   $game_troop.members[i].spi += (($game_troop.members[i].spi / 100.0 * variables[0].to_i).round).to_i
  201.                 end
  202.               elsif line[7,1] == "-"
  203.                 if ($game_troop.turn_count % variables[1].to_i) == 0
  204.                   $game_troop.members[i].spi -= (($game_troop.members[i].spi / 100.0 * variables[0].to_i).round).to_i
  205.                 end
  206.               else
  207.                 raise Exception.new("#{line[7,1]} is not a valid function")
  208.               end
  209.             end
  210.           end
  211.         }
  212.       end
  213.     end
  214.     get_stronger_by_turn
  215.   end
  216. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement