Advertisement
estriole

EST - BRIBE AND BATTLE ROYALE

Dec 7th, 2012
796
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 9.07 KB | None | 0 0
  1. =begin
  2.  ** EST - BRIBE AND BATTLE ROYALE v1.3
  3.  author : estriole
  4.  
  5.  licences:
  6.  Free to use in all project (except the one containing pornography)
  7.  as long as i credited (ESTRIOLE).
  8.  
  9.  version history
  10.  v1.0 - finish the script
  11.  v1.1 - change some method to alias for better compatibility
  12.  v1.2 - add some method alive and dead method for each faction & bribed
  13.  v1.3 - fix some bugs where the faction a or b cannot target bribed member
  14.  
  15.  now you could use
  16.  $game_party.alive_faction_a_members.size
  17.  to check how many faction_a members still alive
  18.  or
  19.  $game_party.alive_bribed_members.size
  20.  to check how many bribed members still alive
  21.  (will be use for actor recruiting system add on later. but still stuck a little
  22.  on it :D)
  23.  
  24.  this script have two function:
  25.  1) make bribed enemy:
  26.  bribed enemy will attack other enemy beside all bribed members. how you make the
  27.  enemy to be bribed. just add the state to that enemy.
  28.  (for the bribe system is up to you ex: bribed by hitting enemy with skill that
  29.  give money, for complex one... enemy have loyalty, etc)
  30.  
  31.  note: bribed enemy is excluded from $game_troop.alive_members
  32.  so you cannot hit them (hey they are your allies... don't hit kill them will you)
  33.  unfortunately i haven't added function so our actor could heal the bribed enemy.
  34.  since it need to rewrite the windows actor selection. and could be problems
  35.  with compatibility with other script.
  36.  
  37.  2) do battle royale
  38.  currently this support battle royale.
  39.  we assign enemy to faction. example:
  40.  slimeA, slimeB is faction A
  41.  batA, batB is faction B
  42.  then slime will hit either our party or faction B members.
  43.  and bat will hit either our party or faction A members.
  44.  thus the battle royale begin
  45.  
  46.  to set the faction just add the state at battle start using troop event pages
  47.  example : turn 0.
  48.  slimeA +faction A state, slimeB +faction A state
  49.  BatA +faction B state, BatB +faction B state.
  50.  
  51.  this script already tested to work with normal battle system and
  52.  victor animated battle system (victor map battle havent tested yet)
  53.  i also used it with yanfly ace battle engine.
  54.  if any bugs occur using above system just tell me and i will try to fix it.
  55.  
  56.  unfortunately i don't use other battle system and thus i might not make
  57.  compatibility with other battle system. especially tankentai (just because it's
  58.  hard to make compatibility with tankentai)..
  59.    
  60.  FOR SCRIPTER ONLY
  61.  if you want more than two factions... example 6 team battle royale...
  62.  (althought i doubt how you set the troops position :D)  
  63.  just do this following steps
  64.  1) add in module ESTRIOLE the faction state
  65.  2) define the faction_x? method (see faction a and b example)
  66.  3) add one more conditional in check_custom_opponents_unit_value
  67.     if faction_x?
  68.     faction_opponents_unit = Game_Troop.new
  69.     faction_opponents_unit.setup_faction_opponents(ESTRIOLE::FACTION_X_STATE)
  70.     @custom_opponents_unit = faction_opponents_unit
  71.     end
  72.    
  73.     after if faction_b? condition and above if bribed? condition
  74.    
  75.  4) do the same with def check_custom_friends_unit_value
  76.     if faction_x?
  77.     faction_friends_unit = Game_Troop.new
  78.     faction_friends_unit.setup_faction_friends(ESTRIOLE::FACTION_X_STATE)
  79.     @custom_friends_unit = faction_friends_unit
  80.     end
  81.    
  82.     after if faction_b? condition and above if bribed? condition
  83.    
  84.  done. now you have 3 faction for 4 way battle
  85.  
  86. =end
  87.  
  88. ############### CONFIGURATION ##################################################
  89.  
  90. module ESTRIOLE
  91.   BRIBE_STATE     = 48
  92.   FACTION_A_STATE = 46
  93.   FACTION_B_STATE = 47
  94. end
  95.  
  96. ######### DO NOT EDIT PAST THIS LINE UNLESS YOU KNOW WHAT YOU'RE DOING #########
  97.  
  98. class Game_Enemy < Game_Battler
  99.   attr_accessor :manual_opponents_unit
  100.   attr_accessor :manual_friends_unit
  101.  
  102.   alias battle_royale_opponents_unit opponents_unit
  103.   def opponents_unit
  104.   return @manual_opponents_unit if manual_opponents_unit
  105.   check_custom_opponents_unit_value
  106.   return @custom_opponents_unit
  107.   end
  108.  
  109.   alias battle_royale_friends_unit friends_unit
  110.   def friends_unit
  111.   return @manual_friends_unit if manual_friends_unit
  112.   check_custom_friends_unit_value
  113.   return @custom_friends_unit
  114.   end
  115.  
  116.   def alive_opponents_unit
  117.   opponents_unit.select {|actor| actor.alive? }
  118.   end
  119.   def dead_opponents_unit
  120.   opponents_unit.select {|actor| actor.dead? }    
  121.   end
  122.   def alive_friends_unit
  123.   friends_unit.select {|actor| actor.alive? }
  124.   end
  125.   def dead_friends_unit
  126.   friends_unit.select {|actor| actor.dead? }    
  127.   end
  128.  
  129.   def check_custom_opponents_unit_value
  130.     @custom_opponents_unit = battle_royale_opponents_unit
  131.     if faction_a?
  132.     faction_opponents_unit = Game_Troop.new
  133.     faction_opponents_unit.royale_flag = true
  134.     faction_opponents_unit.setup_faction_opponents(ESTRIOLE::FACTION_A_STATE)
  135.     @custom_opponents_unit = faction_opponents_unit
  136.     end
  137.     if faction_b?
  138.     faction_opponents_unit = Game_Troop.new
  139.     faction_opponents_unit.royale_flag = true
  140.     faction_opponents_unit.setup_faction_opponents(ESTRIOLE::FACTION_B_STATE)
  141.     @custom_opponents_unit = faction_opponents_unit
  142.     end
  143.     if bribed?
  144.     bribed_opponents_unit = Game_Troop.new
  145.     bribed_opponents_unit.royale_flag = true
  146.     bribed_opponents_unit.setup_bribed_opponents
  147.     @custom_opponents_unit = bribed_opponents_unit
  148.     end
  149.   end
  150.  
  151.   def check_custom_friends_unit_value
  152.     @custom_friends_unit = battle_royale_friends_unit
  153.     if faction_a?
  154.     faction_friends_unit = Game_Troop.new
  155.     faction_friends_unit.royale_flag = true
  156.     faction_friends_unit.setup_faction_friends(ESTRIOLE::FACTION_A_STATE)
  157.     @custom_friends_unit = faction_friends_unit
  158.     end
  159.     if faction_b?
  160.     faction_friends_unit = Game_Troop.new
  161.     faction_friends_unit.royale_flag = true
  162.     faction_friends_unit.setup_faction_friends(ESTRIOLE::FACTION_B_STATE)
  163.     @custom_friends_unit = faction_friends_unit
  164.     end
  165.     if bribed?
  166.     faction_friends_unit = Game_Troop.new
  167.     faction_friends_unit.royale_flag = true
  168.     faction_friends_unit.setup_bribed_friends
  169.     @custom_friends_unit = faction_friends_unit
  170.     end  
  171.   end
  172.  
  173.   def bribed?
  174.   state?(ESTRIOLE::BRIBE_STATE) #bribe state here
  175.   end
  176.  
  177.   def faction_a?
  178.   state?(ESTRIOLE::FACTION_A_STATE) #state that mark faction A
  179.   end
  180.  
  181.   def faction_b?
  182.   state?(ESTRIOLE::FACTION_B_STATE) #state that mark faction B
  183.   end
  184.  
  185. end
  186.  
  187. class Game_Troop < Game_Unit
  188.   attr_reader   :enemies
  189.   attr_accessor :royale_flag
  190.  
  191.   def battle_members
  192.     @enemies.select {|member| member.exist? }
  193.   end
  194.  
  195.   def alive_faction_a_members
  196.     members.select {|member| member.alive? and member.faction_a? }
  197.   end
  198.  
  199.   def dead_faction_a_members
  200.     members.select {|member| member.dead? and member.faction_a? }
  201.   end
  202.  
  203.   def alive_faction_b_members
  204.     members.select {|member| member.alive? and member.faction_b? }
  205.   end
  206.  
  207.   def dead_faction_b_members
  208.     members.select {|member| member.dead? and member.faction_b? }
  209.   end
  210.  
  211.   def alive_bribed_members
  212.     members.select {|member| member.alive? and member.bribed? }
  213.   end
  214.  
  215.   def dead_bribed_members
  216.     members.select {|member| member.dead? and member.bribed? }
  217.   end
  218.  
  219.   def setup_bribed_opponents
  220.     @enemies = []
  221.     for i in 0..$game_troop.enemies.size-1
  222. #~     @enemies.push($game_troop.enemies[i]) if $game_troop.enemies[i]!=ex_enemy
  223.     @enemies.push($game_troop.enemies[i]) if !$game_troop.enemies[i].state?(ESTRIOLE::BRIBE_STATE)
  224.     end #all troop except bribed
  225.   end
  226.  
  227.   def setup_bribed_friends
  228.     @enemies = []
  229.     for i in 0..$game_party.actors.size-1
  230.     @enemies.push($game_actors[$game_party.actors[i]])
  231.     end #all actors
  232.     for i in 0..$game_troop.enemies.size-1
  233. #~     @enemies.push($game_troop.enemies[i]) if $game_troop.enemies[i]==inc_enemy
  234.     @enemies.push($game_troop.enemies[i]) if $game_troop.enemies[i].state?(ESTRIOLE::BRIBE_STATE)
  235.     end #all bribed troop
  236.   end
  237.  
  238.   def setup_faction_opponents(faction_state)
  239.     @enemies = []
  240.     for i in 0..$game_party.actors.size-1
  241.     @enemies.push($game_actors[$game_party.actors[i]])
  242.     end #all actors
  243.     for i in 0..$game_troop.enemies.size-1
  244.       if !$game_troop.enemies[i].state?(faction_state) || $game_troop.enemies[i].state?(ESTRIOLE::BRIBE_STATE)
  245.         @enemies.push($game_troop.enemies[i])
  246.       end
  247.     end #all troop that not faction member
  248.   end
  249.  
  250.   def setup_faction_friends(faction_state)
  251.     @enemies = []
  252.     for i in 0..$game_troop.enemies.size-1
  253.       if $game_troop.enemies[i].state?(faction_state) && !$game_troop.enemies[i].state?(ESTRIOLE::BRIBE_STATE)
  254.         @enemies.push($game_troop.enemies[i])
  255.       end
  256.     end #all troop that faction member
  257.   end
  258.  
  259.   alias alive_members_battle_royale alive_members
  260.   def alive_members
  261.     return @enemies if @royale_flag
  262.     bribed_members = members.select {|member| member.alive? && member.state?(ESTRIOLE::BRIBE_STATE) }
  263.     final_alive_members = alive_members_battle_royale - bribed_members
  264.     return final_alive_members
  265.   end
  266.   #changed to alias to make it compatible if anyone modify game troop alive members
  267.  
  268. end
  269.  
  270. class Game_Party < Game_Unit
  271.   attr_reader   :actors
  272. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement