Advertisement
estriole

EST - ENEMY POSITION

Dec 13th, 2012
2,834
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 57.53 KB | None | 0 0
  1. $imported = {} if $imported.nil?
  2. $imported["EST - ENEMY POSITION"] = true
  3. =begin
  4. ==============================================================================
  5.  ** EST - ENEMY POSITION v3.4  
  6.  
  7.  (front row, back row, underground, underwater, flying, custom scope)
  8. ------------------------------------------------------------------------------
  9.  Author             : ESTRIOLE
  10.  Usage Level        : Easy
  11.  Modification level : Easy
  12.  
  13.  licences:
  14.  Free to use in all project (except the one containing pornography)
  15.  as long as i credited (ESTRIOLE).
  16.  
  17.  also credits to TSUKIHIME since i use his target scope script as my target
  18.  scope base (in early version) and some helping from him/her to adjust it to my need.
  19.  and his/her advice after v 1.4 finish which made me rewrite the whole script.
  20.  
  21.  another credits to DoubleX for his patch to auto battle actor.
  22.  
  23.  modification for your own usage is permitted just don't claim this is yours
  24.  just add below the author: Modded by : ....
  25.  
  26.  Version History:
  27.   v 3.4 - 2015.08.25 > -  another bug on custom_smooth_target (again... c'mon >.<)
  28.                           if having skill that target one ally which using
  29.                           scope_condition... it will messed the index
  30.   v 3.3 - 2015.02.10 > -  compatibility patch to Euphoria threat system 1.4 script
  31.   v 3.2 - 2014.08.08 > -  fix another bug with custom_smooth_target
  32.                        -  add compatibility with EST - BRIBE AND BATTLE ROYALE SCRIPT
  33.   v 3.1 - 2014.02.12 > -  added patch by DoubleX for auto battle actor.
  34.   v 3.0 - 2013.05.28 > -  version increased by a lot because this is quite major update
  35.                        -  fix bug with custom_smooth_target.
  36.                        -  compatibility with moghunter battle cursor
  37.                        -  added scope_condition feature. this script can work with
  38.                           custom scope condition.
  39.                           you could notetags:
  40.                           <scope_cond>
  41.                           b.name[/slime/i]
  42.                           </scope_cond>
  43.                           to make skill that only target enemy containing 'slime' in
  44.                           the name. need to be careful since notetags box is small.
  45.                           using this new feature make we easily create 'new' scope.
  46.                           search
  47.                           "NEW FEATURE FROM v.3.0"
  48.                           for detail
  49.                        -  added scope description text when using yanfly ace battle engine
  50.                           you can set the chosen item/skill to shown custom text rather than
  51.                           using "All Foes". give notetags to the skill/item:
  52.                           <scope_desc>
  53.                           All Enemy You Hate
  54.                           </scope_desc>
  55.                           it will shown "All Enemy You Hate" if the skill/item scope is for_all?
  56.                           this used as combo with scope condition
  57.                          
  58.   v 2.3 - 2013.03.29 > -  patch for enemy will pick skill that have valid target
  59.                           if they have it instead picking skill that don't have target.
  60.   v 2.2 - 2013.03.15 > -  add ability to modify any ALL scope to become random with numbers of target
  61.                           you specify. ex: you set the scope to ALL BACKROW ENEMIES
  62.                           then you give notetags <random: 3>
  63.                           it will become skill that attack 3 random backrow enemies
  64.                           search
  65.                           "NEW FEATURE FROM v.2.2"
  66.                           for detail
  67.                            
  68.   v 2.1 - 2013.03.14 > -  add configuration to disable the skill/item and attack command
  69.                           when NO VALID TARGET for that skill. i put the configuration in the top most of the module
  70.   v 2.0 - 2013.01.23 > -  fix the M range. it's been long time i play that and forgot how it work.
  71.   v 1.9 - 2013.01.16 > -  fix bug if subclass is nil
  72.   v 1.8 - 2013.01.11 > -  add compatibility patch for yanfly weapon attack replace
  73.                      >    with yanfly class system to able use sublass attack skill
  74.   v 1.7 - 2012.10.01 > -  add more scopes like suikoden series (including gun)
  75.                      > -  bugfix to yea attack replace patch that ignore the
  76.                      >    notetags at actors
  77.   v 1.6 - 2012.09.20 > -  fix bug with dead friend issues
  78.   v 1.5 - 2012.09.09 > -  Completely rewrite the whole script from the window,
  79.                      >    scopes, compatibility patch. but i guess now it really
  80.                      >    compatible with other scripts. and it become so easy to
  81.                      >    add more scope (ex: hit front and underwater?)
  82.                      > -  Added item support for scopes. now you can tag item
  83.                      >    to have the same scope with skills. means... net item
  84.                      >    available now.
  85.                      > -  Added item / skill for friend support. you can now use
  86.                      >    skill that hit your front row only or back row only
  87.                      > -  Added more scope (friend related)
  88.                      > -  Several bugfix again since i rewritten this scipt
  89.                      > -  Removed the switch requirement
  90.                      > -  Since rewrite. script become only exact 1000 lines
  91.                      >    (ok i cheated a little at bottom). but have more function. this
  92.                      >    shows how modular/abstract thing is better than hardcode
  93.                      >    (quoting Tsukihime)
  94.   v 1.4 - 2012.09.08 > -  removed the necessary to put the the skill id to array
  95.                      > now only need to put scope tag instead
  96.                      > -  script level downgraded to easy now
  97.                      > -  add scopes to hit front row and back row (either row)
  98.                      > -  some logical bugfix for underground smooth target
  99.                      > -  add some bugfix when no yanfly script presents. when
  100.                      > using skills without selection. even though no valid enemy
  101.                      > exist. actor skill can select the skills and waste his
  102.                      > precious turn hitting nothing.
  103.                      > -  some minor bugfix with either attack[all] can still selected
  104.                      > after using all skill that have valid target.
  105.                      > -  add patch for yanfly attack replace script with bugfix
  106.                      > to make the script work correctly (original has bugs
  107.                      > when equiping weapon without notetags your attack skill
  108.                      > is default regardless your class/actor attack skill
  109.                      > -  change the arrangement of yanfly attack replace priority
  110.                      > from : weapon > actor > class to weapon > class > actor
  111.                      > since it's more make sense. warrior hit using short range
  112.                      > archer long range, etc.
  113.   v 1.3 - 2012.09.07 > -  Add three more position : flying, underwater, underground
  114.                      > -  several scope targeting bugfix
  115.                      > -  some switch bugfix
  116.                      > -  make the all front row skill to be able to target back row when
  117.                      > no more front row enemy
  118.                      > -  make the same with all back row skill and make suikoden style permanent
  119.                      > -  hopefully remove all bugs
  120.   v 1.2 - 2012.09.06 > -  Fixed bug that make editor single enemy scope to only
  121.                      > show front row only target
  122.                      > -  Added Yanfly Battle Engine v1.22 patch
  123.                      > -  Added Yanfly Enemy HP Bars v1.10 patch
  124.                      > -  Fixed some visual bugs
  125.   v 1.1 - 2012.09.05 > -  Manage to fix the scope
  126.   v 1.0 - 2012.09.04 > -  First release
  127.  
  128. ------------------------------------------------------------------------------
  129.   This script is to make certain enemies (using state) cannot be selected as
  130.   target by normal attack / skill. only certain skill can (and if you use yanfly
  131.   attack replace script. certain actor can select it too with normal attack.
  132.   in this version there's also flying, underwater, underground state + suikoden
  133.   series attack range.
  134. ------------------------------------------------------------------------------
  135.  Feature
  136.  - FROM 3.0 above. CAN SET CUSTOM SCOPE CONDITION
  137.  - can set enemy front row / back row using states
  138.  - can set enemy flying, underwater, underground using states
  139.  - can make suikoden attack range *new in 1.7
  140.  - can make skill to attack only front row[single]
  141.  - can make skill to attack only front row[all]
  142.  - can make skill to attack only back row[single]
  143.  - can make skill to attack only back row[all]
  144.  - can make skill to attack only flying[single]
  145.  - can make skill to attack only flying[all]
  146.  - can make skill to attack only underwater[single]
  147.  - can make skill to attack only underwater[all]
  148.  - can make skill to attack only underground[single]
  149.  - can make skill to attack only underground[all]
  150.  - can make skill to attack both row[single]
  151.  - can make skill to attack both row[all] (all skills see advanced instructions)
  152.  - NOW CAN make RANDOM Skill
  153.  - have good algorithm for the scopes so when enemy dead before you hit it will
  154.    search only next valid target.
  155.  - prevent player to select non valid targets
  156.  - prevent player to waste his action (except if the dead enemy before strike
  157.    situation)
  158.  - you add it yourself... don't know what to add again :D.
  159.  
  160.  Compatibility
  161.  - almost all script (i use yanfly, victor, moghunter, etc total about 120++ scripts)
  162.  - and i especially tailor this to compatible with yanfly battle system since majority
  163.    use that scripts.
  164.  - also made compatibility to yanfly enemy hp bar
  165.  
  166.  Instructions:
  167.   To instal the script, open you script editor and paste this script on
  168.   a new section on bellow the Materials section. This script best put below
  169.   other script(especially battle script)
  170.  
  171.  Advanced Instructions:
  172.  1) to make the enemy have position
  173.   set the module estriole for configuration for the states.
  174.   then in database editor troops tab. set to add the state at beginning of battle.
  175.   YES set them for every troop you have.
  176.   back row - just add back row state
  177.   flying - just add flying state
  178.   underwater - just add underwater state
  179.   underground - just add underground state
  180.   the enemy could also use skills that add those state. and after use the state
  181.   the position will treated like the state(immediately). just make sure they don't add two state
  182.   such as back row + flying, flying + underwater, flying + underground. maybe i will
  183.   make add on later so the states are unique.
  184.  
  185.   and once again YES... it's manual. except you want to make your own script to flag the
  186.   enemy back row / flying and add the state at battle start. or use other scripter script
  187.   i think i have seen victor script something like that (state-auto-apply). but
  188.   i have no idea about the compatibility since i don't use the script (not compatible
  189.   with my battlesystem script)
  190.  
  191.  2) since this is state related you can custom the state example underwater state
  192.     weak to electric attack, etc.
  193.     if you want to make dig, float, dive state (after 3 turn disappear). just add
  194.     those state in coresponding state array ex : dig in underground array
  195.     then add the automatic timed released to remove after 3 turn and after battle
  196.  
  197.  3) finally the most important parts
  198.     this is the step to set the skills that you want.
  199.     all this is using default scope setting without modifying the configuration
  200.     if you modify it you have to take the risk yourself. since i set
  201.     the scope high number i guess it won't have incompatibility with tsukihime
  202.     target-scope script and no need to change. now let's get to the point...
  203.    
  204.     first note: only front row and back row have swap ability. other state is not.
  205.  
  206.     a) skill that can hit front row only [single] (ex-sword normal attack)
  207.        - add this notetags to the skill : <scope: 82>
  208.        note:      
  209.        edit : after adding flying, underwater, underground state i guess i will make
  210.        the suikoden style permanent. meaning if no front row you can hit back row
  211.        
  212.        and if you want your normal attack cannot attack other position just set
  213.        your normal attack to this.
  214.        
  215.     b) skill that can hit back row only [single] (ex skill that only attack back rows)
  216.        - add this notetags to the skill : <scope: 81>
  217.        note:
  218.        edit : now also with suikoden style support. when no back row can hit
  219.        front row
  220.        
  221.     c) skill that can hit front row only[all] (ex: one of suikoden rune skill that hit all front)
  222.        - add this notetags to the skill : <scope: 84>
  223.        note :
  224.        hit all front rows. when no front row enemy it will hit back row
  225.     d) skill that can hit back_row_only[all] (ex: suikoden rune skill that hit all back)  
  226.       - add this notetags to the skill : <scope: 83>
  227.       note : hit all back rows. when no back row enemy it will hit front row.
  228.     e) skill that can attack flying_only[single] (ex:net skill to bring down the enemy)
  229.       - <scope: 85>
  230.     f) skill that can attack flying_only[all] (ex:turbulance that hit the flyings)
  231.       - <scope: 86>
  232.     g) skill that can attack underwater_only[single] (ex:fishing rod skill to pull the enemy to surface)
  233.       - <scope: 87>
  234.     h) skill that can attack underwater_only[all] (ex:Electric attack that shock all swimmers)
  235.       - <scope: 88>
  236.     i) skill that can attack underground_only[single] (ex:have no idea for this)
  237.       - <scope: 89>
  238.     j) skill that can attack underground_only[all] (ex:you fog the hole with poison so all underground poisoned)
  239.       - <scope: 90>      
  240.     k) skill that can attack front_row and back row[single] (ex:spear medium range weapon)
  241.       - <scope: 91>      
  242.     l) skill that can attack front_row and back row[all] (ex:earthquake that hit ground members)
  243.       - <scope: 92>            
  244.     k) skill that can hit all target [single] (ex: magic attack)  
  245.        - basicly you just create regular skill that target single enemy.
  246.     l) skill that can hit all front row and back row [all] (ex: magic area skill)
  247.       - basicly you just create regular skill that target all enemies.
  248.     m) for the new scope just basicly add the scope to the skill like above example  
  249.  
  250.   4) you can also use the back row or other state on your actor. the rule is the same
  251.     just give the enemy appropriate skill setting in no3. but it's better not set it
  252.     permanent.
  253.  
  254.  scope note :
  255.  for easier access i provide the notetags for the skill to use(if you not change
  256.  the config of course). just add them in your skill notetags
  257.  <scope: 81> -> one back enemy
  258.  <scope: 82> -> one front enemy
  259.  <scope: 83> -> all back enemy
  260.  <scope: 84> -> all front enemy
  261.  <scope: 85> -> one flying enemy
  262.  <scope: 86> -> all flying enemy
  263.  <scope: 87> -> one underwater enemy
  264.  <scope: 88> -> all underwater enemy
  265.  <scope: 89> -> one underground enemy
  266.  <scope: 90> -> all underground enemy
  267.  <scope: 91> -> one either row enemy
  268.  <scope: 92> -> all either row enemy
  269.  <scope: 93> -> one back ally
  270.  <scope: 94> -> one front ally
  271.  <scope: 95> -> all back ally
  272.  <scope: 96> -> all front ally
  273.  <scope: 97> -> one enemy - short range weapon suikoden style
  274.  <scope: 98> -> one enemy - mid range weapon suikoden style
  275.  <scope: 99> -> one enemy - long range weapon suikoden style + hit flying (gun)
  276.  <scope: 100> -> all enemy - short range weapon suikoden style
  277.  <scope: 101> -> all enemy - mid range weapon suikoden style
  278.  <scope: 102> -> all enemy - long range weapon suikoden style + hit flying (gun)
  279.  
  280.  new scope series: suikoden style
  281.  short -> if actor at front row hit front row. if at back row hit nothing
  282.  mid -> if actor at front row hit front row. if at back row hit front row
  283.  long -> hit either row + flying (gun)
  284.  
  285.  what the difference front row and short range?
  286.  front row will hit front row enemy anytime (best used as skill)
  287.  short range will hit front row enemy only when actor not at back row
  288.  (best used as weapon attack skill)
  289.  
  290.  if you want skill that hit all just use the editor instead.
  291.  notes: since now easy to add scopes. request is welcome. just post in the forum
  292.  what the scope you want. ex: the one i currently have in plan = gun_attack
  293.  can hit front row, back row, flying.
  294.    
  295.  NEW FEATURE FROM v.2.2
  296.  you could make skill/item that attack X random POS Enemy.
  297.  X -> number of target    POS -> backrow / frontrow / flying / etc
  298.  how to do that?
  299.  1) first make that skill to attack ALL X Position. Example attack ALL FLYING ENEMY
  300.  use notetags: <scope: 86>
  301.  2) give notetags to make it random plus how many random target it will attack.
  302.  example you want it to attack 3 random flying enemy
  303.  use notetags: <random: 3>
  304.  then in the skill will contain notetags:
  305.  <scope: 86>
  306.  <random: 3>
  307.  it will make the skill attack 3 random flying enemies.
  308.  I also make compatibility patch for yanfly ace battle engine to show
  309.  X Random POS Enemies in the help text.
  310.  
  311.  also note this use default random targeting. so if you set it to 4 random enemies
  312.  while your damage is one hit kill. you might hit less than 4 enemies.
  313.  because the targetting work like this
  314.  hit 1: enemy A
  315.  hit 2: enemy B
  316.  hit 3: enemy A
  317.  hit 4: enemy A
  318.  but enemy A dies in first hit. so you'll only score 2 hit.
  319.  if anyone write more good random target script. i could write compatibility patch
  320.  for using that.
  321.  
  322.  NEW FEATURE FROM v.3.0
  323.  -  added scope_condition feature. this script can work with  custom scope condition.
  324.   give the skill/item notetags:
  325.   <scope_cond>
  326.   your condition here
  327.   </scope_cond>
  328.   I also assign some variable to shorten the writing:
  329.   a -> user
  330.   b -> target
  331.   o -> user opponent
  332.   f -> user friend
  333.   s -> switch
  334.   v -> variable
  335.  
  336.   |> WARNING PREMADE SCOPE HAS HIGHER PRIORITY THAN SCOPE CONDITION. so if you want
  337.   to use scope condition. don't use <scope: x> feature.
  338.  
  339.   |> you could change the area of effect to switch target from friend or foe...
  340.   |> you could change the area of effect to switch target from single or all...
  341.  
  342.   it's better to put
  343.     b.alive? &&
  344.   as the first line condition if your skill target alive target only.....
  345.   since if not it will also able to target dead member as well.
  346.   why i'm not adding it automatically. since there's possibility that we want
  347.   to target dead target (revive it perhaps). also mix of dead and alive target.
  348.   (ex: miracle skill that heal all living and revived dead to full hp)
  349.  
  350.   example condition usage:
  351.   <scope_cond>
  352.   b.id == 2 &&
  353.   b.id == 1
  354.   </scope_cond>
  355.   means that item/skill will only target OBJ that
  356.   the first and second id in database...
  357.   if area of effect single enemy -> target one enemy that match the condition
  358.   if area of effect all enemy -> target all enemy that match the condition
  359.   if area of effect single ally -> target one ally that match the condition
  360.   if area of effect single ally -> target all allies that match the condition
  361.   also if you realize i create .id method for game_enemy. so it won't crash
  362.   if the skill used by enemy too.
  363.  
  364.   some interesting idea: hate slayer. slay the target that the [actor/enemy] hate  
  365.   i use case syntax in this condition
  366.   <scope_cond>
  367.   !b.state?(1) &&
  368.   case a.id
  369.   when 1; b.name[/slime/i]
  370.   when 2; b.name[/mimic/i]
  371.   when 3; b.name[/rate/i]
  372.   else; b.name[/hornet/i]
  373.   end
  374.   </scope_cond>
  375.   means: first the target must NOT dead(alive)
  376.   then [actor/enemy] 1 will able to target [actor/enemy] contain 'slimes' in the name
  377.   then [actor/enemy] 2 will able to target [actor/enemy] contain 'mimic' in the name
  378.   then [actor/enemy] 3 will able to target [actor/enemy] contain 'rate' in the name
  379.   then other [actor/enemy] will able to target [actor/enemy] contain 'hornet' in the name
  380.  
  381.   if you want real complex filter. then you can create method in game_battler.
  382.   you can pass the a, b, o, f, s, v in the method (if neccessary).
  383.  
  384.  Known Bugs:
  385.   TELL ME if there's a bug and i'll try to fix it.
  386.  Future plan:
  387.  tell me
  388.  
  389.  SCRIPTER LOG
  390.  decide to delete the scripter log. since made real major changes in this script
  391. #------------------------------------------------------------------------------
  392. =end
  393. module ESTRIOLE
  394. ################################################################################
  395. #  - CONFIGURATION PART
  396. ################################################################################
  397.   #DISABLE SKILL IF NO VALID TARGET MODE
  398.   DISABLE_SKILL_IF_NO_VALID_TARGET = true
  399.  
  400.   #if above set to true. the skill will be disabled when no valid target.
  401.   #if false. the skill not disabled but will show no valid target warning (old mode)
  402.  
  403.   #WARNING ALL STATE ARRAY MUST NOT HAVE DUPLICATES IN OTHER ARRAY
  404.   BACK_ROW_STATE               = [49,50]  #state id that flag the enemy back_row  
  405.   FLYING_STATE                 = [51,52]  
  406.   UNDERWATER_STATE             = [53,54]    
  407.   UNDERGROUND_STATE            = [55,56]
  408.   ALLMOD_STATE = BACK_ROW_STATE+FLYING_STATE+UNDERWATER_STATE+UNDERGROUND_STATE  
  409.   TEXT_NO_VALID_TARGET = "No Valid Target"   #text to show if no valid target                                    
  410.   #CREDIT TSUKIHIME FOR THIS TARGET SCOPE - IT'S BASED ON HIS/HER SCRIPTS.
  411.   #SCOPE_RELATED CONFIG BETTER IF UNTOUCHED. TOUCH IT AT YOUR OWN RISK
  412.   ONE_BACK_ENEMY        = 81
  413.   ONE_FRONT_ENEMY       = 82
  414.   ALL_BACK_ENEMY        = 83
  415.   ALL_FRONT_ENEMY       = 84
  416.   ONE_FLYING_ENEMY      = 85
  417.   ALL_FLYING_ENEMY      = 86
  418.   ONE_UNDERWATER_ENEMY  = 87
  419.   ALL_UNDERWATER_ENEMY  = 88
  420.   ONE_UNDERGROUND_ENEMY = 89
  421.   ALL_UNDERGROUND_ENEMY = 90
  422.   ONE_EITHER_ROW_ENEMY  = 91
  423.   ALL_EITHER_ROW_ENEMY  = 92
  424.   #ally series
  425.   ONE_BACK_ALLY         = 93
  426.   ONE_FRONT_ALLY        = 94
  427.   ALL_BACK_ALLY         = 95
  428.   ALL_FRONT_ALLY        = 96
  429.   #suikoden series
  430.   ONE_SHORT_WEAPON          = 97
  431.   ONE_MID_WEAPON            = 98
  432.   ONE_LONG_WEAPON           = 99
  433.   ALL_SHORT_WEAPON          = 100
  434.   ALL_MID_WEAPON            = 101
  435.   ALL_LONG_WEAPON           = 102
  436.  
  437. ####DO NOT EDIT BELOW THIS EXCEPT YOU KNOW WHAT YOU'RE DOING ####################
  438. #PUT ALL CUSTOM SCOPES THAT TARGET ALL X ENEMY
  439.   SCOPE_ENEMY_ALL_X_ARRAY = [ALL_FRONT_ENEMY, ALL_BACK_ENEMY,ALL_FLYING_ENEMY,
  440.                               ALL_UNDERWATER_ENEMY,ALL_UNDERGROUND_ENEMY,
  441.                               ALL_EITHER_ROW_ENEMY,ALL_SHORT_WEAPON,
  442.                               ALL_MID_WEAPON,ALL_LONG_WEAPON]
  443.                              
  444. #PUT ALL CUSTOM SCOPES THAT TARGET SINGLE X ENEMY
  445.   SCOPE_ENEMY_SINGLE_X_ARRAY = [ONE_FRONT_ENEMY, ONE_BACK_ENEMY,
  446.   ONE_FLYING_ENEMY, ONE_UNDERWATER_ENEMY, ONE_UNDERGROUND_ENEMY,
  447.   ONE_EITHER_ROW_ENEMY,ONE_SHORT_WEAPON,ONE_MID_WEAPON,ONE_LONG_WEAPON]
  448. # NO NEED TO PUT IT HERE SINCE ALREADY USING ADDITION
  449.   ALL_CUSTOM_ENEMY_SCOPE_ARRAY = SCOPE_ENEMY_SINGLE_X_ARRAY + SCOPE_ENEMY_ALL_X_ARRAY
  450. #PUT ALL CUSTOM SCOPES THAT TARGET ALL X ALLY
  451.   SCOPE_FRIEND_ALL_X_ARRAY = [ALL_BACK_ALLY,ALL_FRONT_ALLY]
  452. #PUT ALL CUSTOM SCOPES THAT TARGET SINGLE X ALLY
  453.   SCOPE_FRIEND_SINGLE_X_ARRAY = [ONE_BACK_ALLY,ONE_FRONT_ALLY]
  454. # NO NEED TO PUT IT HERE SINCE ALREADY USING ADDITION
  455.   ALL_CUSTOM_FRIEND_SCOPE_ARRAY = SCOPE_FRIEND_ALL_X_ARRAY + SCOPE_FRIEND_SINGLE_X_ARRAY
  456.  
  457.   Scope_Regex = /<scope:?\s*(\d+)\s*/i  
  458. end
  459.  
  460. if $imported["YEA-BattleEngine"] == true
  461. module YEA
  462.   module BATTLE
  463.     HELP_TEXT_ALL_FRONT_FOES       = "All Front Row Foes"
  464.     HELP_TEXT_ALL_BACK_FOES        = "All Back Row Foes"
  465.     HELP_TEXT_ALL_FLYING_FOES      = "All Flying Foes"
  466.     HELP_TEXT_ALL_UNDERWATER_FOES  = "All Underwater Foes"
  467.     HELP_TEXT_ALL_UNDERGROUND_FOES = "All Underground Foes"
  468.     HELP_TEXT_ALL_EITHER_ROW_FOES  = "All Ground Foes"
  469.     HELP_TEXT_ALL_BACK_ALLY        = "All Back Row Allies"
  470.     HELP_TEXT_ALL_FRONT_ALLY       = "All Front Row Allies"
  471.     HELP_TEXT_ALL_SHORT_WEAPON     = "All Front Row Foes"
  472.     HELP_TEXT_ALL_MID_WEAPON       = "All Mid Range Weapon Target Foes"
  473.     HELP_TEXT_ALL_LONG_WEAPON      = "All Ground and Flying Foes"
  474.   end
  475. end
  476. end
  477.  
  478.  
  479. ################################################################################
  480. # - END CONFIGURATION
  481. ################################################################################
  482. #-------DO NOT EDIT PAST THIS LINE EXCEPT YOU KNOW WHAT YOU'RE DOING-----------#
  483. class Game_Party < Game_Unit
  484.   attr_accessor :suikoden_style
  485.   alias game_party_initialize_estriole777 initialize
  486.   def initialize
  487.     game_party_initialize_estriole777
  488.     @suikoden_style = true
  489.   end
  490. end
  491.  
  492. class Game_Temp
  493.   attr_accessor :est_enemy
  494.   attr_accessor :est_friend
  495.   attr_accessor :est_skill
  496.   attr_accessor :est_valid_target
  497.   alias game_temp_initialize_estriole777 initialize
  498.   def initialize
  499.     game_temp_initialize_estriole777
  500.   end
  501. end
  502.  
  503. module RPG
  504.   class UsableItem < BaseItem
  505.       include ESTRIOLE          
  506.      
  507.       def scope_cond
  508.       return nil if !note[/<scope_cond?>(?:[^<]|<[^\/])*<\/scope_cond?>/i]
  509.       a = note[/<scope_cond?>(?:[^<]|<[^\/])*<\/scope_cond?>/i].scan(/(?:!<scope_cond?>|(.*)\r)/)
  510.       a.delete_at(0)    
  511.       return noteargs = a.join("\r\n")
  512.       end
  513.    
  514.       alias est_for_opponent? for_opponent?
  515.       def for_opponent?
  516.       return true if ALL_CUSTOM_ENEMY_SCOPE_ARRAY.include?(@scope) #81
  517.       est_for_opponent?
  518.       end
  519.  
  520.       alias est_for_friend? for_friend?
  521.       def for_friend?
  522.       return true if ALL_CUSTOM_FRIEND_SCOPE_ARRAY.include?(@scope) #81
  523.       est_for_friend?
  524.       end
  525.  
  526.       alias est_for_all? for_all?
  527.       def for_all?
  528.       temp = SCOPE_ENEMY_ALL_X_ARRAY + SCOPE_FRIEND_ALL_X_ARRAY
  529.       return true if temp.include?(@scope) #81
  530.       est_for_all?
  531.       end
  532.  
  533.       alias est_for_one? for_one?
  534.       def for_one?
  535.       temp = SCOPE_ENEMY_SINGLE_X_ARRAY + SCOPE_FRIEND_SINGLE_X_ARRAY
  536.       return true if temp.include?(@scope) #81
  537.       est_for_one?
  538.       end
  539.      
  540.       def custom_random?
  541.         return nil if !@note[/<random:(.*)>/i]
  542.         a = @note[/<random:(.*)>/i].scan(/:(.*)/).flatten[0].scan(/(?:"(.*?)"| (\w+)|(\w+),|,(\w+))/).flatten.compact
  543.         a.collect!{|x| x.to_i}
  544.         return noteargs = a[0]
  545.       end
  546.      
  547.       alias custom_random_number_of_targets number_of_targets
  548.       def number_of_targets
  549.         return custom_random? if custom_random?
  550.         custom_random_number_of_targets
  551.       end
  552.      
  553.       alias est_for_random? for_random?
  554.       def for_random?
  555.       return true if custom_random?
  556.       est_for_random?
  557.       end
  558.      
  559.       def for_one_back_ally?
  560.       [ONE_BACK_ALLY].include?(@scope) #81
  561.       end
  562.       def for_one_front_ally?
  563.       [ONE_FRONT_ALLY].include?(@scope) #81
  564.       end
  565.       def for_all_back_ally?
  566.       [ALL_BACK_ALLY].include?(@scope) #81
  567.       end
  568.       def for_all_front_ally?
  569.       [ALL_FRONT_ALLY].include?(@scope) #81
  570.       end
  571.    
  572.       def for_one_back_enemy?
  573.       [ONE_BACK_ENEMY].include?(@scope) #81
  574.       end
  575.       def for_one_front_enemy?
  576.       [ONE_FRONT_ENEMY].include?(@scope) #82
  577.       end
  578.       def for_all_back_enemy?
  579.       [ALL_BACK_ENEMY].include?(@scope) #83
  580.       end
  581.        def for_all_front_enemy?
  582.       [ALL_FRONT_ENEMY].include?(@scope) #84
  583.       end
  584.       def for_one_flying_enemy?
  585.       [ONE_FLYING_ENEMY].include?(@scope) #81
  586.       end
  587.       def for_all_flying_enemy?
  588.       [ALL_FLYING_ENEMY].include?(@scope) #83
  589.       end
  590.       def for_one_underwater_enemy?
  591.       [ONE_UNDERWATER_ENEMY].include?(@scope) #81
  592.       end
  593.       def for_all_underwater_enemy?
  594.       [ALL_UNDERWATER_ENEMY].include?(@scope) #83
  595.       end
  596.       def for_one_underground_enemy?
  597.       [ONE_UNDERGROUND_ENEMY].include?(@scope) #81
  598.       end
  599.       def for_all_underground_enemy?
  600.       [ALL_UNDERGROUND_ENEMY].include?(@scope) #83
  601.       end
  602.       def for_one_either_row_enemy?
  603.       [ONE_EITHER_ROW_ENEMY].include?(@scope) #83
  604.       end
  605.       def for_all_either_row_enemy?
  606.       [ALL_EITHER_ROW_ENEMY].include?(@scope) #83
  607.       end
  608.       #suikoden range series
  609.       def for_one_short_weapon_enemy?
  610.       [ONE_SHORT_WEAPON].include?(@scope) #83
  611.       end
  612.       def for_one_mid_weapon_enemy?
  613.       [ONE_MID_WEAPON].include?(@scope) #83
  614.       end
  615.       def for_one_long_weapon_enemy?
  616.       [ONE_LONG_WEAPON].include?(@scope) #83
  617.       end
  618.       def for_all_short_weapon_enemy?
  619.       [ALL_SHORT_WEAPON].include?(@scope) #83
  620.       end
  621.       def for_all_mid_weapon_enemy?
  622.       [ALL_MID_WEAPON].include?(@scope) #83
  623.       end
  624.       def for_all_long_weapon_enemy?
  625.       [ALL_LONG_WEAPON].include?(@scope) #83
  626.       end
  627.      
  628.       alias :est_target_scope_selection? :need_selection?
  629.       def need_selection?
  630.        temp = SCOPE_ENEMY_SINGLE_X_ARRAY + SCOPE_FRIEND_SINGLE_X_ARRAY
  631.        temp.include?(@scope) || est_target_scope_selection?
  632.       end
  633.      
  634.       def back_row?(actor)
  635.         for i in 0..ESTRIOLE::BACK_ROW_STATE.size
  636.         return actor.state?(ESTRIOLE::BACK_ROW_STATE[i]) if actor.state?(ESTRIOLE::BACK_ROW_STATE[i])==true
  637.         end
  638.         return false
  639.       end
  640.  
  641.       #patch for enemy choosing skill that have valid target if there's any.
  642.       def enemy_any_valid_target(enemy)
  643.         return true if !SceneManager.scene.is_a?(Scene_Battle)
  644.         target = enemy.friends_unit
  645.         target = enemy.opponents_unit if for_opponent?
  646.         val_target = valid_target(target,enemy)
  647.         return true if val_target.size > 0
  648.         return false
  649.       end
  650.      
  651.       def any_valid_target?
  652.         return true if !SceneManager.scene.is_a?(Scene_Battle)
  653.         return false if !BattleManager.actor
  654.         target = BattleManager.actor.friends_unit
  655.         target = BattleManager.actor.opponents_unit if for_opponent?
  656.         val_target = valid_target(target,BattleManager.actor)
  657.         return true if val_target.size > 0
  658.         return false
  659.       end
  660.      
  661.       def valid_target(target,user = nil)
  662.       ##########################################################################
  663.       #
  664.       #   THIS PREBUILD SCOPE (not using custom scope condition)
  665.       #   prebuild scope take priority above custom scope condition
  666.       #  
  667.       ###########################################################################  
  668.       #ACTUALLY IT'S POSSIBLE TO MERGE THEM TOGETHER USING || BUT FOR THE SAKE
  669.       #OF EASIER EDITING I PURPOSELY SPLIT IT TO OPPONENT AND ALLY PART
  670.       ########OPPONENT PART ##############################################################################
  671.       if for_one_back_enemy? || for_all_back_enemy?
  672.         if $game_party.suikoden_style ==true
  673.           if target.alive_back_row_members.size == 0
  674.             return target.alive_front_row_members
  675.           else
  676.             return target.alive_back_row_members
  677.           end
  678.         else
  679.         return target.alive_back_row_members
  680.         end  
  681.       end
  682.       if for_one_front_enemy? || for_all_front_enemy?
  683.         if $game_party.suikoden_style ==true
  684.           if target.alive_front_row_members.size == 0
  685.             return target.alive_back_row_members
  686.           else
  687.           return target.alive_front_row_members            
  688.           end
  689.         else
  690.         return target.alive_front_row_members
  691.         end  
  692.       end
  693.       return target.alive_flying_members if for_one_flying_enemy? || for_all_flying_enemy?
  694.       return target.alive_underwater_members if for_one_underwater_enemy? || for_all_underwater_enemy?
  695.       return target.alive_underground_members if for_one_underground_enemy? ||for_all_underground_enemy?
  696.       return target.alive_either_row_members if for_one_either_row_enemy? || for_all_either_row_enemy?
  697.       ####### suikoden weapon ####################################################
  698.       if for_one_short_weapon_enemy? || for_all_short_weapon_enemy?
  699.         if back_row?(user)
  700.         return []
  701.         else
  702.           if $game_party.suikoden_style ==true
  703.             if target.alive_front_row_members.size == 0
  704.               return target.alive_back_row_members
  705.             else
  706.             return target.alive_front_row_members            
  707.             end
  708.           else
  709.           return target.alive_front_row_members
  710.           end  
  711.         end
  712.       end
  713.       if for_one_mid_weapon_enemy? || for_all_mid_weapon_enemy?
  714.         if back_row?(user)
  715.           if $game_party.suikoden_style ==true
  716.             if target.alive_front_row_members.size == 0
  717.               return target.alive_back_row_members
  718.             else
  719.             return target.alive_front_row_members            
  720.             end
  721.           else
  722.           return target.alive_front_row_members
  723.           end  
  724.         else
  725.           if $game_party.suikoden_style ==true
  726.             if target.alive_front_row_members.size == 0
  727.               return target.alive_back_row_members
  728.             else
  729.             return target.alive_front_row_members            
  730.             end
  731.           else
  732.           return target.alive_front_row_members
  733.           end  
  734.         end
  735.       end
  736.       if for_one_long_weapon_enemy? || for_all_long_weapon_enemy?
  737.         if back_row?(user)
  738.           valid = target.alive_either_row_members + target.alive_flying_members
  739.           return valid          
  740.         else
  741.           valid = target.alive_either_row_members + target.alive_flying_members
  742.           return valid          
  743.         end
  744.       end
  745.      
  746.       #######ALLY PART#####################################################################################
  747.       if for_one_back_ally? || for_all_back_ally?
  748.         return target.alive_back_row_members
  749.       end  
  750.       if for_one_front_ally? || for_all_front_ally?
  751.         return target.alive_front_row_members
  752.       end
  753.       #######DEFAULT CUSTOM SCOPES#############################
  754.       all_custom = ALL_CUSTOM_ENEMY_SCOPE_ARRAY + ALL_CUSTOM_FRIEND_SCOPE_ARRAY
  755.       if all_custom.include?(self.scope)
  756.       return []
  757.       end
  758.       return target.dead_members if for_dead_friend?
  759.       #######DEFAULT NO SCOPES#############################
  760.       ##########################################################################
  761.       #
  762.       #   BELOW IS THE CODE WHICH RETURN SCOPE CONDITION TARGET
  763.       #  
  764.       ###########################################################################  
  765.       a = user
  766.       o = user.opponents_unit
  767.       f = user.friends_unit
  768.       v = $game_variables
  769.       s = $game_switches
  770.       cond = scope_cond ? scope_cond : "true"
  771.       return target.alive_members if !scope_cond
  772.       return target.members.select {|b|eval(cond)}
  773.       end #end def valid target enemy
  774.  
  775.     #yea battle patch
  776.     if $imported["YEA-BattleEngine"] == true
  777.       #scope_description (shown in yanfly engine)
  778.       def scope_desc
  779.       return nil if !note[/<scope_desc?>(?:[^<]|<[^\/])*<\/scope_desc?>/i]
  780.       a = note[/<scope_desc?>(?:[^<]|<[^\/])*<\/scope_desc?>/i].scan(/(?:!<scope_desc?>|(.*)\r)/)
  781.       a.delete_at(0)    
  782.       return noteargs = a.join("\r\n")        
  783.       end
  784.      
  785.       def yea_special_text
  786.       number = $game_temp.battle_aid.number_of_targets
  787.       if for_random?
  788.       help = "%d Random Foes" if for_all? && for_opponent?
  789.       help = "%d Random Allies" if for_all? && for_friend?
  790.       help = "%d Random Front Row Foes" if for_all_front_enemy?
  791.       help = "%d Random Back Row Foes" if for_all_back_enemy?
  792.       help = "%d Random Flying Foes" if for_all_flying_enemy?
  793.       help = "%d Random Underwater Foes" if for_all_underwater_enemy?
  794.       help = "%d Random Underground Foes" if for_all_underground_enemy?
  795.       help = "%d Random Ground Foes" if for_all_either_row_enemy?
  796.       help = "%d Random Front Row Foes" if for_all_short_weapon_enemy?
  797.       help = "%d Random Mid Range Weapon Target Foes" if for_all_mid_weapon_enemy?
  798.       help = "%d Random Ground and Flying Foes" if for_all_long_weapon_enemy?
  799.       help = "%d Random Back Row Allies" if for_all_back_ally?
  800.       help = "%d Random Front Row Allies" if for_all_front_ally?
  801.       help = "%d Random Target" if !help
  802.       text = sprintf(help, number)
  803.       return text
  804.       end  
  805.       return YEA::BATTLE::HELP_TEXT_ALL_BACK_FOES if for_all_back_enemy?
  806.       return YEA::BATTLE::HELP_TEXT_ALL_FRONT_FOES if for_all_front_enemy?
  807.       return YEA::BATTLE::HELP_TEXT_ALL_FLYING_FOES if for_all_flying_enemy?
  808.       return YEA::BATTLE::HELP_TEXT_ALL_UNDERWATER_FOES if for_all_underwater_enemy?
  809.       return YEA::BATTLE::HELP_TEXT_ALL_UNDERGROUND_FOES if for_all_underground_enemy?
  810.       return YEA::BATTLE::HELP_TEXT_ALL_EITHER_ROW_FOES if for_all_either_row_enemy?
  811.       return YEA::BATTLE::HELP_TEXT_ALL_SHORT_WEAPON if for_all_short_weapon_enemy?
  812.       return YEA::BATTLE::HELP_TEXT_ALL_MID_WEAPON if for_all_mid_weapon_enemy?
  813.       return YEA::BATTLE::HELP_TEXT_ALL_LONG_WEAPON if for_all_long_weapon_enemy?
  814.       return YEA::BATTLE::HELP_TEXT_ALL_BACK_ALLY if for_all_back_ally?
  815.       return YEA::BATTLE::HELP_TEXT_ALL_FRONT_ALLY if for_all_front_ally?
  816.       return nil
  817.       end  
  818.     end #end yea battle patch
  819.          
  820.       def est_ts_load_notetags
  821.       matches = Scope_Regex.match(self.note)
  822.       if matches
  823.       @scope = matches[1].to_i
  824.       end
  825.     end
  826.   end
  827. end
  828.  
  829. module DataManager
  830.  
  831.   class << self
  832.     alias est_target_skill_load_database load_database
  833.     alias est_target_skill_init init
  834.   end
  835.  
  836.   def self.init
  837.     est_target_skill_init
  838.     load_notetags_est_target_skill
  839.   end
  840.  
  841.   def self.load_database
  842.     est_target_skill_load_database
  843.     if $BTEST
  844.     load_notetags_est_target_skill
  845.     end
  846.   end
  847.        
  848.   def self.load_notetags_est_target_skill
  849.     groups = [$data_skills, $data_items]
  850.     for group in groups
  851.     for obj in group
  852.     next if obj.nil?
  853.     obj.est_ts_load_notetags
  854.     end
  855.     end
  856.   end
  857. end
  858.  
  859. class Game_Action
  860.   #overwrite targets for opponents to use valid target
  861.   def targets_for_opponents
  862.     enemy = item.valid_target(opponents_unit,@subject)
  863.     if item.for_random?
  864.       Array.new(item.number_of_targets) { opponents_unit.custom_random_target(enemy) }
  865.     elsif item.for_one?
  866.       num = 1 + (attack? ? subject.atk_times_add.to_i : 0)
  867.       if @target_index < 0
  868.         [opponents_unit.custom_random_target(enemy)] * num
  869.       else
  870.         [opponents_unit.custom_smooth_target(@target_index,enemy)] * num
  871.       end
  872.     else
  873.       enemy
  874.     end
  875.   end
  876. #  #overwrite targets for friends to use valid target
  877. #  def targets_for_friends
  878. #    friend = item.valid_target(friends_unit,@subject)
  879. #    if item.for_user?
  880. #      [@subject]
  881. #    elsif item.for_dead_friend?
  882. #      if item.for_one?
  883. #        [friends_unit.smooth_dead_target(@target_index)]
  884. #      else
  885. #        friends_unit.dead_members
  886. #      end
  887. #    elsif item.for_friend?
  888. #      if item.for_one?
  889. #        [friends_unit.custom_smooth_target(@target_index,friend)]
  890. #      else
  891. #        friend
  892. #      end
  893. #    end
  894. #  end  
  895. #  method overwritten in patch below
  896.  
  897. end
  898.  
  899. class Window_SkillList < Window_Selectable
  900.   alias disable_skill_if_no_valid_target? enable?
  901.   def enable?(item)
  902.     disable_skill_if_no_valid_target?(item) &&
  903.     (!ESTRIOLE::DISABLE_SKILL_IF_NO_VALID_TARGET||item.any_valid_target?)
  904.   end
  905. end
  906.  
  907. class Window_ItemList < Window_Selectable
  908.   alias disable_item_if_no_valid_target? enable?
  909.   def enable?(item)
  910.     disable_item_if_no_valid_target?(item) &&
  911.     (!ESTRIOLE::DISABLE_SKILL_IF_NO_VALID_TARGET||item.any_valid_target?)
  912.   end  
  913. end
  914.  
  915. # first part below is class game unit and battler base
  916. class Game_BattlerBase
  917.   alias disable_attack_command_if_no_valid_target? attack_usable?
  918.   def attack_usable?
  919.     disable_attack_command_if_no_valid_target? &&
  920.     (!ESTRIOLE::DISABLE_SKILL_IF_NO_VALID_TARGET||$data_skills[attack_skill_id].any_valid_target?)
  921.   end
  922.  
  923.   def back_row_state?
  924.     for i in 0..ESTRIOLE::BACK_ROW_STATE.size
  925.     return state?(ESTRIOLE::BACK_ROW_STATE[i]) if state?(ESTRIOLE::BACK_ROW_STATE[i])==true
  926.     end
  927.     return false
  928.   end
  929.   def flying_state?
  930.     for i in 0..ESTRIOLE::FLYING_STATE.size
  931.     return state?(ESTRIOLE::FLYING_STATE[i]) if state?(ESTRIOLE::FLYING_STATE[i])==true
  932.     end
  933.     return false
  934.   end
  935.   def underwater_state?    
  936.     for i in 0..ESTRIOLE::UNDERWATER_STATE.size
  937.     return state?(ESTRIOLE::UNDERWATER_STATE[i]) if state?(ESTRIOLE::UNDERWATER_STATE[i])==true
  938.     end
  939.     return false
  940.   end
  941.   def underground_state?
  942.     for i in 0..ESTRIOLE::UNDERGROUND_STATE.size
  943.     return state?(ESTRIOLE::UNDERGROUND_STATE[i]) if state?(ESTRIOLE::UNDERGROUND_STATE[i])==true
  944.     end
  945.     return false
  946.   end
  947.   def front_row?
  948.     exist? && !back_row_state? &&
  949.      !flying_state? && !underwater_state? && !underground_state?
  950.   end
  951.   def back_row?
  952.     exist? && back_row_state?
  953.   end
  954.   def flying?
  955.     exist? && flying_state?
  956.   end
  957.   def underwater?
  958.     exist? && underwater_state?
  959.   end
  960.   def underground?
  961.     exist? && underground_state?
  962.   end
  963.   def either_row?
  964.     exist? && !flying_state? && !underwater_state? && !underground_state?
  965.   end
  966.  
  967. end
  968.  
  969. class Game_Unit
  970.   def alive_front_row_members
  971.     members.select {|member| member.alive? && member.front_row?}
  972.   end
  973.   def alive_back_row_members
  974.     members.select {|member| member.alive? && member.back_row? }
  975.   end
  976.   def alive_flying_members
  977.     members.select {|member| member.alive? && member.flying? }
  978.   end
  979.   def alive_underwater_members
  980.     members.select {|member| member.alive? && member.underwater? }
  981.   end
  982.   def alive_underground_members
  983.     members.select {|member| member.alive? && member.underground? }
  984.   end
  985.   def alive_either_row_members
  986.     members.select {|member| member.alive? && member.either_row? }
  987.   end  
  988.   def custom_random_target(target)
  989.     tgr_rand = rand * tgr_sum
  990.     target.each do |member|
  991.       tgr_rand -= member.tgr
  992.       return member if tgr_rand < 0
  993.     end
  994.     target[0]
  995.   end
  996.   def custom_smooth_target(index,target,scope_cond = nil)
  997.     member = members[index]
  998.     member = target[index] if scope_cond
  999.     (member && member.alive?) ? member : target.sample
  1000.   end
  1001. end
  1002.  
  1003. # below is the window select enemy modified to only able to select front only / back only / all
  1004. class Window_BattleEnemy < Window_Selectable
  1005.   def item_max
  1006.     return 1 if $game_temp.est_valid_target == nil
  1007.     return 1 if $game_temp.est_valid_target.size == 0
  1008.     return $game_temp.est_valid_target.size
  1009.   end
  1010.  
  1011.   def enemy  
  1012.     return $game_troop.alive_members[@index] if $game_temp.est_valid_target == nil
  1013.     return $game_troop.alive_members[@index] if $game_temp.est_valid_target.size == 0
  1014.     return $game_temp.est_valid_target[@index]
  1015.   end
  1016.  
  1017.   def name_est
  1018.     return nil if $game_temp.est_valid_target == nil
  1019.     return nil if $game_temp.est_valid_target.size == 0
  1020.     return $game_temp.est_valid_target
  1021.   end
  1022.  
  1023.   def draw_item(index)
  1024.     change_color(normal_color)
  1025.     enemy = name_est
  1026.     if enemy != nil
  1027.       name = enemy[index].name
  1028.     else
  1029.     name = ESTRIOLE::TEXT_NO_VALID_TARGET
  1030.     end  
  1031.     draw_text(item_rect_for_text(index), name)
  1032.   end
  1033.    
  1034.   alias process_ok_est process_ok
  1035.   def process_ok
  1036.     if $game_temp.est_valid_target.size == 0
  1037.       process_cancel
  1038.     else
  1039.     process_ok_est
  1040.     end
  1041.   end
  1042.  
  1043.   #yea battle patch
  1044.   if $imported["YEA-BattleEngine"] == true    
  1045.     def update
  1046.       super
  1047.       return unless active
  1048.         if $game_temp.est_valid_target.size == 0
  1049.         else
  1050.         enemy.sprite_effect_type = :whiten
  1051.         end
  1052.       return unless $game_temp.est_skill.for_all?
  1053.       for enemy in $game_temp.est_valid_target
  1054.         enemy.sprite_effect_type = :whiten
  1055.       end        
  1056.     end
  1057.    
  1058.     def update_cursor
  1059.       if $game_temp.est_skill == nil
  1060.       help = false
  1061.       else
  1062.       help = $game_temp.est_skill.for_all?
  1063.       end
  1064.       if help
  1065.       cursor_rect.set(0, 0, contents.width, contents.height)
  1066.       self.top_row = 0
  1067.       elsif @index < 0
  1068.       cursor_rect.empty
  1069.       else
  1070.       ensure_cursor_visible
  1071.       cursor_rect.set(item_rect(@index))
  1072.       end
  1073.     end #end update_cursor
  1074.  
  1075.   end #end yea battle patch
  1076.  
  1077. end #end window_battleenemy
  1078.  
  1079. #yea battle patch
  1080. if $imported["YEA-BattleEngine"] == true
  1081. class Window_BattleHelp < Window_Help
  1082.   def refresh_special_case(battler)
  1083.     if $game_temp.battle_aid.for_opponent?
  1084.       if $game_temp.battle_aid.for_all?
  1085.         text = $game_temp.battle_aid.yea_special_text
  1086.         text = YEA::BATTLE::HELP_TEXT_ALL_FOES if text == nil
  1087.       else
  1088.         text = $game_temp.battle_aid.yea_special_text
  1089.         case $game_temp.battle_aid.number_of_targets
  1090.         when 1
  1091.           text = YEA::BATTLE::HELP_TEXT_ONE_RANDOM_FOE if !text
  1092.         else
  1093.           number = $game_temp.battle_aid.number_of_targets
  1094.           text = sprintf(YEA::BATTLE::HELP_TEXT_MANY_RANDOM_FOE, number) if !text
  1095.         end      
  1096.       end
  1097.     else
  1098.       if $game_temp.battle_aid.for_dead_friend?
  1099.         text = YEA::BATTLE::HELP_TEXT_ALL_DEAD_ALLIES
  1100.       else
  1101.         text = $game_temp.battle_aid.yea_special_text
  1102.         text = YEA::BATTLE::HELP_TEXT_ALL_ALLIES if text == nil
  1103.       end
  1104.     end
  1105.       if $game_temp.est_valid_target.size == 0
  1106.       text = ESTRIOLE::TEXT_NO_VALID_TARGET
  1107.       end
  1108.       text = $game_temp.battle_aid.scope_desc if $game_temp.battle_aid.scope_desc
  1109.       return if text == @text
  1110.       @text = text
  1111.       contents.clear
  1112.       reset_font_settings
  1113.       draw_text(0, 0, contents.width, line_height*2, @text, 1)
  1114.   end
  1115.  
  1116.   def update_battler_name
  1117.     return unless @actor_window.active || @enemy_window.active
  1118.     if @actor_window.active
  1119.       battler = $game_party.battle_members[@actor_window.index]
  1120.     elsif @enemy_window.active
  1121.       battler = @enemy_window.enemy
  1122.     end
  1123.     if special_display?
  1124.       refresh_special_case(battler)
  1125.     else
  1126.       if $game_temp.est_valid_target.size == 0
  1127.       refresh_special_case(battler)      
  1128.       else
  1129.       refresh_battler_name(battler) if battler_name(battler) != @text
  1130.       end
  1131.     end
  1132.   end
  1133.  
  1134. end#end class battle_help
  1135. end#end yea battle patch
  1136.  
  1137. #yea enemy hp patch
  1138. if $imported["YEA-EnemyHPBars"] == true
  1139. class Enemy_HP_Gauge_Viewport < Viewport
  1140.   def gauge_visible?
  1141.     update_original_hide
  1142.     return false if @original_hide
  1143.     return false if case_original_hide?
  1144.     return true if @visible_counter > 0
  1145.     return true if @gauge_width != @target_gauge_width
  1146.     if SceneManager.scene_is?(Scene_Battle)
  1147.       return false if SceneManager.scene.enemy_window.nil?
  1148.       unless @battler.dead?
  1149.         if SceneManager.scene.enemy_window.active
  1150.           if SceneManager.scene.enemy_window.enemy == @battler
  1151.           return false if !$game_temp.est_valid_target.include?(@battler)
  1152.           return true if $game_temp.est_valid_target.include?(@battler)
  1153.           end
  1154.           if SceneManager.scene.enemy_window.select_all?
  1155.           return false if !$game_temp.est_valid_target.include?(@battler)
  1156.           return true if $game_temp.est_valid_target.include?(@battler)
  1157.           end
  1158.           return true if highlight_aoe?
  1159.         end
  1160.       end
  1161.     end
  1162.     return false    
  1163.   end
  1164. end #end yea enemy hp gauge viewport
  1165. end #end yea enemy hp patch
  1166.  
  1167. class Scene_Battle < Scene_Base
  1168.   alias on_skill_ok_est on_skill_ok
  1169.   def on_skill_ok
  1170.     @skillchk = @skill_window.item
  1171.     cur_actor                   = BattleManager.actor
  1172.     cur_enemy                   = BattleManager.actor.opponents_unit
  1173.     cur_friend                  = BattleManager.actor.friends_unit
  1174.     $game_temp.est_skill        = @skillchk
  1175.     if @skillchk.for_opponent?
  1176.     $game_temp.est_valid_target  = $game_temp.est_skill.valid_target(cur_enemy, cur_actor)
  1177.     else
  1178.     $game_temp.est_valid_target  = $game_temp.est_skill.valid_target(cur_friend, cur_actor)
  1179.     end
  1180.     if !@skillchk.need_selection?
  1181.       #if yea battle engine not present
  1182.       if $imported["YEA-BattleEngine"] == true
  1183.       else
  1184.         if $game_temp.est_valid_target.size == 0
  1185.         on_skill_cancel
  1186.         @log_window.add_text(ESTRIOLE::TEXT_NO_VALID_TARGET)
  1187.         3.times do @log_window.wait end
  1188.         @log_window.back_one
  1189.         return
  1190.         end
  1191.       end#end yea battle engine not present    
  1192.     end
  1193.     on_skill_ok_est
  1194.   end
  1195.  
  1196.   alias on_item_ok_est on_item_ok
  1197.   def on_item_ok
  1198.     @itemchk = @item_window.item
  1199.     cur_actor                   = BattleManager.actor
  1200.     cur_enemy                   = BattleManager.actor.opponents_unit
  1201.     cur_friend                  = BattleManager.actor.friends_unit
  1202.     $game_temp.est_skill        = @itemchk
  1203.     if @itemchk.for_opponent?
  1204.     $game_temp.est_valid_target  = $game_temp.est_skill.valid_target(cur_enemy, cur_actor)
  1205.     else
  1206.     $game_temp.est_valid_target  = $game_temp.est_skill.valid_target(cur_friend, cur_actor)
  1207.     end
  1208.     if !@itemchk.need_selection?
  1209.       #if yea battle engine not present
  1210.       if $imported["YEA-BattleEngine"] == true
  1211.       else
  1212.         if $game_temp.est_valid_target.size == 0
  1213.         on_item_cancel
  1214.         @log_window.add_text(ESTRIOLE::TEXT_NO_VALID_TARGET)
  1215.         3.times do @log_window.wait end
  1216.         @log_window.back_one
  1217.         return
  1218.         end
  1219.       end#end yea battle engine not present    
  1220.     end
  1221.     on_item_ok_est    
  1222.   end
  1223.  
  1224.   alias command_attack_est command_attack
  1225.   def command_attack
  1226.     @attack = $data_skills[BattleManager.actor.attack_skill_id]
  1227.     cur_actor                   = BattleManager.actor
  1228.     cur_enemy                   = BattleManager.actor.opponents_unit
  1229.     cur_friend                  = BattleManager.actor.friends_unit
  1230.     $game_temp.est_skill        = @attack
  1231.     if @attack.for_opponent?
  1232.     $game_temp.est_valid_target  = $game_temp.est_skill.valid_target(cur_enemy, cur_actor)
  1233.     else
  1234.     $game_temp.est_valid_target  = $game_temp.est_skill.valid_target(cur_friend, cur_actor)
  1235.     end
  1236.     if !@attack.need_selection?
  1237.       #if yea battle engine not present
  1238.       if $imported["YEA-BattleEngine"] == true
  1239.       else
  1240.         if $game_temp.est_valid_target.size == 0
  1241.         on_skill_cancel
  1242.         @log_window.add_text(ESTRIOLE::TEXT_NO_VALID_TARGET)
  1243.         3.times do @log_window.wait end
  1244.         @log_window.back_one
  1245.         return
  1246.         end
  1247.       end#end yea battle engine not present    
  1248.     end
  1249.     command_attack_est
  1250.   end    
  1251.  
  1252.   alias select_enemy_selection_est select_enemy_selection
  1253.   def select_enemy_selection
  1254.     select_enemy_selection_est
  1255.   end
  1256. end
  1257.  
  1258. class Window_BattleActor < Window_BattleStatus
  1259.   def item_max
  1260.     return $game_party.battle_members.size if $game_temp.est_valid_target == nil
  1261.     return 1 if $game_temp.est_valid_target.size == 0
  1262.     return $game_temp.est_valid_target.size
  1263.     #$game_party.battle_members.size
  1264.   end
  1265.  
  1266.   if $imported["YEA-BattleEngine"] == true
  1267.   #--------------------------------------------------------------------------
  1268.   # overwrite method: draw_item
  1269.   #--------------------------------------------------------------------------
  1270.   def draw_item(index)
  1271.     return if index.nil?
  1272.     clear_item(index)
  1273.     actor = battle_members[index]
  1274.       if $game_temp.est_valid_target != nil
  1275.         if $game_temp.est_valid_target.size == 0
  1276.           name = ""
  1277.           rect = item_rect(index)
  1278.           draw_text(rect.x, rect.y, rect.width, line_height, name)
  1279.           return
  1280.         end
  1281.       actor = $game_temp.est_valid_target[index]        
  1282.       end
  1283.     rect = item_rect(index)
  1284.     return if actor.nil?
  1285.     draw_actor_face(actor, rect.x+2, rect.y+2, actor.alive?)
  1286.     draw_actor_name(actor, rect.x, rect.y, rect.width-8)
  1287.     draw_actor_action(actor, rect.x, rect.y)
  1288.     draw_actor_icons(actor, rect.x, line_height*1, rect.width)
  1289.     gx = YEA::BATTLE::BATTLESTATUS_HPGAUGE_Y_PLUS
  1290.     contents.font.size = YEA::BATTLE::BATTLESTATUS_TEXT_FONT_SIZE
  1291.     draw_actor_hp(actor, rect.x+2, line_height*2+gx, rect.width-4)
  1292.     if draw_tp?(actor) && draw_mp?(actor)
  1293.       dw = rect.width/2-2
  1294.       dw += 1 if $imported["YEA-CoreEngine"] && YEA::CORE::GAUGE_OUTLINE
  1295.       draw_actor_tp(actor, rect.x+2, line_height*3, dw)
  1296.       dw = rect.width - rect.width/2 - 2
  1297.       draw_actor_mp(actor, rect.x+rect.width/2, line_height*3, dw)
  1298.     elsif draw_tp?(actor) && !draw_mp?(actor)
  1299.       draw_actor_tp(actor, rect.x+2, line_height*3, rect.width-4)
  1300.     else
  1301.       draw_actor_mp(actor, rect.x+2, line_height*3, rect.width-4)
  1302.     end
  1303.   end
  1304.  
  1305.   else #else yea battle engine
  1306.    
  1307.   def draw_item(index)
  1308.     actor = $game_party.battle_members[index]
  1309.       if $game_temp.est_valid_target != nil
  1310.         if $game_temp.est_valid_target.size == 0
  1311.           name = ESTRIOLE::TEXT_NO_VALID_TARGET
  1312.           draw_text(item_rect_for_text(index), name)
  1313.           return
  1314.         end
  1315.       actor = $game_temp.est_valid_target[index]        
  1316.       end
  1317.     draw_basic_area(basic_area_rect(index), actor)
  1318.     draw_gauge_area(gauge_area_rect(index), actor)
  1319.   end
  1320.   def name_est
  1321.     return nil if $game_temp.est_valid_target == nil
  1322.     return nil if $game_temp.est_valid_target.size == 0
  1323.     return $game_temp.est_valid_target
  1324.   end
  1325.  
  1326.   end #end yea battle not present
  1327.  
  1328.   def process_ok
  1329.     if $game_temp.est_valid_target.size == 0
  1330.       process_cancel
  1331.     else
  1332.       Sound.play_ok
  1333.       Input.update
  1334.       deactivate
  1335.       call_ok_handler
  1336.     end
  1337.   end  
  1338. end
  1339.  
  1340. #patch for enemy choosing skill that have valid target if there's any.
  1341. #and patch for grabbing enemy id
  1342. class Game_Enemy < Game_Battler
  1343.   alias est_pos_action_valid? action_valid?
  1344.   def action_valid?(action)
  1345.    est_pos_action_valid?(action) && $data_skills[action.skill_id].enemy_any_valid_target(self)
  1346.   end
  1347.   def id
  1348.     @enemy_id
  1349.   end
  1350. end
  1351.  
  1352. #MOG battle cursor patch. now only able to hover valid target
  1353. module Battle_Cursor_index
  1354.   def set_cursor_position_enemy
  1355.   return if !self.active
  1356.    $game_temp.battle_cursor[0] = $game_temp.est_valid_target[self.index].screen_x + CURSOR_POSITION[0] rescue nil
  1357.    $game_temp.battle_cursor[1] = $game_temp.est_valid_target[self.index].screen_y + CURSOR_POSITION[1] rescue nil
  1358.    $game_temp.battle_cursor[3] = $game_temp.est_valid_target[self.index].name rescue nil
  1359.    $game_temp.battle_cursor = [0,0,false,0] if $game_temp.battle_cursor[0] == nil
  1360.   end
  1361.   def set_cursor_position_actor
  1362.    return if !self.active
  1363.    $game_temp.battle_cursor[0] = $game_temp.est_valid_target[self.index].screen_x + CURSOR_POSITION[0] rescue nil
  1364.    $game_temp.battle_cursor[1] = $game_temp.est_valid_target[self.index].screen_y + CURSOR_POSITION[1] rescue nil
  1365.    $game_temp.battle_cursor[3] = $game_temp.est_valid_target[self.index].name rescue nil
  1366.    $game_temp.battle_cursor = [0,0,false,0] if $game_temp.battle_cursor[0] == nil
  1367.   end  
  1368. end
  1369.  
  1370. #yea attack replace patch and bugfix when equiping weapon without tags it will
  1371. #make default attack even actor / class have tags. also rearrange the priority
  1372. #to weapon, class, actor. so class could override the actor attack skill.
  1373. #because it's more make sense. you change the class of an actor.
  1374. if $imported["YEA-WeaponAttackReplace"] == true
  1375.  
  1376. class Game_Actor < Game_Battler
  1377.   def weapon_attack_skill_id
  1378.     for weapon in weapons
  1379.       next if weapon.nil?
  1380.       return weapon.attack_skill if weapon.attack_skill != YEA::WEAPON_ATTACK_REPLACE::DEFAULT_ATTACK_SKILL_ID
  1381.     end
  1382.     return self.class.attack_skill if !self.class.attack_skill.nil? &&
  1383.                                   self.class.attack_skill != YEA::WEAPON_ATTACK_REPLACE::DEFAULT_ATTACK_SKILL_ID
  1384.     if $imported["YEA-ClassSystem"] == true
  1385.     return self.subclass.attack_skill if self.subclass &&!self.subclass.attack_skill.nil? &&
  1386.                                   self.subclass.attack_skill != YEA::WEAPON_ATTACK_REPLACE::DEFAULT_ATTACK_SKILL_ID
  1387.     end                          
  1388.     return self.actor.attack_skill if !self.actor.attack_skill.nil? &&
  1389.                                   self.actor.attack_skill != YEA::WEAPON_ATTACK_REPLACE::DEFAULT_ATTACK_SKILL_ID
  1390.     return YEA::WEAPON_ATTACK_REPLACE::DEFAULT_ATTACK_SKILL_ID                              
  1391.   end  
  1392. end # Game_Actor
  1393.  
  1394. end #end yea attack replace patch
  1395.  
  1396.  
  1397. #patch from DoubleX for auto battle actor
  1398. class Game_BattlerBase
  1399.   alias est_pos_usable? usable?
  1400.   def usable?(item)
  1401.     est_pos_usable?(item) && ((item.for_dead_friend? || item.for_friend?) &&
  1402.     item.valid_target(self.friends_unit, self).size > 0 || item.for_opponent? &&
  1403.     item.valid_target(self.opponents_unit, self).size > 0 || !item.for_dead_friend? &&
  1404.     !item.for_friend? && !item.for_opponent?)
  1405.   end
  1406. end
  1407.  
  1408. # patch for targeting friends... compatibility for battle royale script
  1409. # so bribed enemy can heal actor...
  1410. # based on victor basic module... default scripts is faulty by default... omg.
  1411. class Game_Action
  1412.   #overwrite targets for friends to use valid target
  1413.   def targets_for_friends
  1414.     friend = item.valid_target(friends_unit,@subject)
  1415.     if item.for_user?
  1416.       [@subject]
  1417.     elsif item.for_dead_friend?
  1418.       if item.for_one?
  1419.         [friends_unit.smooth_dead_target(@target_index)]
  1420.       else
  1421.         friends_unit.dead_members
  1422.       end
  1423.     elsif item.for_friend?
  1424.       if item.for_one?
  1425.         if @target_index < 0
  1426.         [friends_unit.custom_random_target(friend)]
  1427.         else
  1428.         [friends_unit.custom_smooth_target(@target_index,friend, item.scope_cond)]
  1429.         end
  1430.       else
  1431.         friend
  1432.       end
  1433.     end
  1434.   end  
  1435. end
  1436.  
  1437. if $imported["EuphoriaThreatSystem"] == true
  1438. class Game_Unit
  1439.   alias est_euphoria_custom_random_target custom_random_target  
  1440.   def custom_random_target(target)
  1441.       case Euphoria::Threat::RANDOM_CHNC
  1442.       when 1
  1443.         threat_rand = rand * tgr_sum
  1444.         target.each do |member|
  1445.           threat_rand -= member.threat
  1446.           return member if threat_rand < 0
  1447.         end
  1448.       when 2
  1449.         chance = rand(Euphoria::Threat::RANDOM_NUM)
  1450.         return est_euphoria_custom_random_target(target) if chance == 0        
  1451.       end #end case
  1452.       target.sort! {|a,b| b.threat - a.threat}
  1453.       return target[0]
  1454.   end#end custom random member  
  1455. end#end game unit
  1456. end#end if imported threat system
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement