Advertisement
TechSkylander1518

PhoenixDex Moves AI changes

May 30th, 2023 (edited)
1,096
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 17.18 KB | None | 0 0
  1. #AI_Move_EffectScores_1, change this line:
  2.     when "LowerTargetSpDef1"
  3. #to:
  4.     when "LowerTargetSpDef1", "LowerTargetSpDef1AlwaysHitsInRain"
  5. #Under this section
  6.     #---------------------------------------------------------------------------
  7.     when "RaiseTargetAtkSpAtk2"
  8.       if target.opposes?(user)
  9.         score -= 100
  10.       elsif skill >= PBTrainerAI.mediumSkill && target.hasActiveAbility?(:CONTRARY)
  11.         score -= 90
  12.       else
  13.         score -= target.stages[:ATTACK] * 20
  14.         score -= target.stages[:SPECIAL_ATTACK] * 20
  15.       end
  16. #add
  17.     #---------------------------------------------------------------------------
  18.     when "RaiseTargetAtkSpAtk1"
  19.       if target.opposes?(user)
  20.         score -= 100
  21.       elsif skill >= PBTrainerAI.mediumSkill && target.hasActiveAbility?(:CONTRARY)
  22.         score -= 90
  23.       else
  24.         score -= target.stages[:ATTACK] * 10
  25.         score -= target.stages[:SPECIAL_ATTACK] * 10
  26.       end
  27.     #---------------------------------------------------------------------------
  28.     when "RaiseTargetAtkSpeed1"
  29.       if target.opposes?(user)
  30.         score -= 100
  31.       elsif skill >= PBTrainerAI.mediumSkill && target.hasActiveAbility?(:CONTRARY)
  32.         score -= 90
  33.       else
  34.         score -= target.stages[:ATTACK] * 10
  35.         score -= target.stages[:SPEED] * 10
  36.       end
  37.     #---------------------------------------------------------------------------
  38.     when "RaiseTargetSpAtkSpeed1"
  39.       if target.opposes?(user)
  40.         score -= 100
  41.       elsif skill >= PBTrainerAI.mediumSkill && target.hasActiveAbility?(:CONTRARY)
  42.         score -= 90
  43.       else
  44.         score -= target.stages[:SPECIAL_ATTACK] * 10
  45.         score -= target.stages[:SPEED] * 10
  46.       end
  47. #Under
  48.     #---------------------------------------------------------------------------
  49.     when "LowerTargetAtkSpAtk1"
  50.       avg  = target.stages[:ATTACK] * 10
  51.       avg += target.stages[:SPECIAL_ATTACK] * 10
  52.       score += avg / 2
  53. #add
  54.     #---------------------------------------------------------------------------
  55.     when "LowerTargetSpAtkSpDef1"
  56.       avg  = target.stages[:SPECIAL_ATTACK] * 10
  57.       avg += target.stages[:SPECIAL_DEFENSE] * 10
  58.       score += avg / 2
  59. #Under
  60.     #---------------------------------------------------------------------------
  61.     when "RaiseUserAtkAcc1"
  62.       if user.statStageAtMax?(:ATTACK) &&
  63.          user.statStageAtMax?(:ACCURACY)
  64.         score -= 90
  65.       else
  66.         score -= user.stages[:ATTACK] * 10
  67.         score -= user.stages[:ACCURACY] * 10
  68.         if skill >= PBTrainerAI.mediumSkill
  69.           hasPhysicalAttack = false
  70.           user.eachMove do |m|
  71.             next if !m.physicalMove?(m.type)
  72.             hasPhysicalAttack = true
  73.             break
  74.           end
  75.           if hasPhysicalAttack
  76.             score += 20
  77.           elsif skill >= PBTrainerAI.highSkill
  78.             score -= 90
  79.           end
  80.         end
  81.       end
  82. #add
  83.     #---------------------------------------------------------------------------
  84.     when "RaiseUserSpAtkAcc1"
  85.       if user.statStageAtMax?(:SPECIAL_ATTACK) &&
  86.          user.statStageAtMax?(:ACCURACY)
  87.         score -= 90
  88.       else
  89.         score -= user.stages[:SPECIAL_ATTACK] * 10
  90.         score -= user.stages[:ACCURACY] * 10
  91.         if skill >= PBTrainerAI.mediumSkill
  92.           hasSpecialAttack = false
  93.           user.eachMove do |m|
  94.             next if !m.specialMove?(m.type)
  95.             hasSpecialAttack = true
  96.             break
  97.           end
  98.           if hasSpecialAttack
  99.             score += 20
  100.           elsif skill >= PBTrainerAI.highSkill
  101.             score -= 90
  102.           end
  103.         end
  104.       end
  105. #Under this section:
  106.     #---------------------------------------------------------------------------
  107.     when "RaiseUserAtkSpAtk1", "RaiseUserAtkSpAtk1Or2InSun"
  108.       if user.statStageAtMax?(:ATTACK) &&
  109.          user.statStageAtMax?(:SPECIAL_ATTACK)
  110.         score -= 90
  111.       else
  112.         score -= user.stages[:ATTACK] * 10
  113.         score -= user.stages[:SPECIAL_ATTACK] * 10
  114.         if skill >= PBTrainerAI.mediumSkill
  115.           hasDamagingAttack = false
  116.           user.eachMove do |m|
  117.             next if !m.damagingMove?
  118.             hasDamagingAttack = true
  119.             break
  120.           end
  121.           if hasDamagingAttack
  122.             score += 20
  123.           elsif skill >= PBTrainerAI.highSkill
  124.             score -= 90
  125.           end
  126.         end
  127.         if move.function == "RaiseUserAtkSpAtk1Or2InSun"   # Growth
  128.           score += 20 if [:Sun, :HarshSun].include?(user.effectiveWeather)
  129.         end
  130.       end
  131. #add
  132.     #---------------------------------------------------------------------------
  133.     when "RaiseUserDefSpDef1Or2InHailSand"
  134.       if user.statStageAtMax?(:DEFENSE) &&
  135.          user.statStageAtMax?(:SPECIAL_DEFENSE)
  136.         score -= 90
  137.       else
  138.         score -= user.stages[:DEFENSE] * 10
  139.         score -= user.stages[:SPECIAL_DEFENSE] * 10
  140.         if move.function == "RaiseUserDefSpDef1Or2InHailSand"   # Crystallize
  141.           score += 20 if [:Sandstorm, :Hail].include?(user.effectiveWeather)
  142.         end
  143.       end
  144. #Under this section:
  145.     #---------------------------------------------------------------------------
  146.     when "RaiseUserSpAtkSpDefSpd1"
  147.       if user.statStageAtMax?(:SPEED) &&
  148.          user.statStageAtMax?(:SPECIAL_ATTACK) &&
  149.          user.statStageAtMax?(:SPECIAL_DEFENSE)
  150.         score -= 90
  151.       else
  152.         score -= user.stages[:SPECIAL_ATTACK] * 10
  153.         score -= user.stages[:SPECIAL_DEFENSE] * 10
  154.         score -= user.stages[:SPEED] * 10
  155.         if skill >= PBTrainerAI.mediumSkill
  156.           hasSpecicalAttack = false
  157.           user.eachMove do |m|
  158.             next if !m.specialMove?(m.type)
  159.             hasSpecicalAttack = true
  160.             break
  161.           end
  162.           if hasSpecicalAttack
  163.             score += 20
  164.           elsif skill >= PBTrainerAI.highSkill
  165.             score -= 90
  166.           end
  167.         end
  168.         if skill >= PBTrainerAI.highSkill
  169.           aspeed = pbRoughStat(user, :SPEED, skill)
  170.           ospeed = pbRoughStat(target, :SPEED, skill)
  171.           if aspeed < ospeed && aspeed * 2 > ospeed
  172.             score += 20
  173.           end
  174.         end
  175.       end
  176. #add
  177.     #---------------------------------------------------------------------------
  178.     when "RaiseUserSpAtkSpd1"
  179.       if user.statStageAtMax?(:SPEED) &&
  180.          user.statStageAtMax?(:SPECIAL_ATTACK)
  181.         score -= 90
  182.       else
  183.         score -= user.stages[:SPECIAL_ATTACK] * 10
  184.         score -= user.stages[:SPEED] * 10
  185.         if skill >= PBTrainerAI.mediumSkill
  186.           hasSpecicalAttack = false
  187.           user.eachMove do |m|
  188.             next if !m.specialMove?(m.type)
  189.             hasSpecicalAttack = true
  190.             break
  191.           end
  192.           if hasSpecicalAttack
  193.             score += 20
  194.           elsif skill >= PBTrainerAI.highSkill
  195.             score -= 90
  196.           end
  197.         end
  198.         if skill >= PBTrainerAI.highSkill
  199.           aspeed = pbRoughStat(user, :SPEED, skill)
  200.           ospeed = pbRoughStat(target, :SPEED, skill)
  201.           if aspeed < ospeed && aspeed * 2 > ospeed
  202.             score += 20
  203.           end
  204.         end
  205.       end
  206. #Under this section
  207.     #---------------------------------------------------------------------------
  208.     when "RaiseTargetSpDef1"
  209.       if target.statStageAtMax?(:SPECIAL_DEFENSE)
  210.         score -= 90
  211.       else
  212.         score -= target.stages[:SPECIAL_DEFENSE] * 10
  213.       end
  214. #add
  215.     #---------------------------------------------------------------------------
  216.     when "RaiseTargetSpeed1"
  217.       if target.statStageAtMax?(:SPEED)
  218.         score -= 90
  219.       else
  220.         score -= target.stages[:SPEED] * 10
  221.       end
  222. #Under this section:
  223.     #---------------------------------------------------------------------------
  224.     when "RaiseUserSpDef1PowerUpElectricMove"
  225.       foundMove = false
  226.       user.eachMove do |m|
  227.         next if m.type != :ELECTRIC || !m.damagingMove?
  228.         foundMove = true
  229.         break
  230.       end
  231.       score += 20 if foundMove
  232.       if move.statusMove?
  233.         if user.statStageAtMax?(:SPECIAL_DEFENSE)
  234.           score -= 90
  235.         else
  236.           score -= user.stages[:SPECIAL_DEFENSE] * 20
  237.         end
  238.       elsif user.stages[:SPECIAL_DEFENSE] < 0
  239.         score += 20
  240.       end
  241. #add
  242.     #---------------------------------------------------------------------------
  243.     when "RaiseUserSpDef1PowerUpFireMove"
  244.       foundMove = false
  245.       user.eachMove do |m|
  246.         next if m.type != :FIRE || !m.damagingMove?
  247.         foundMove = true
  248.         break
  249.       end
  250.       score += 20 if foundMove
  251.       if move.statusMove?
  252.         if user.statStageAtMax?(:SPECIAL_DEFENSE)
  253.           score -= 90
  254.         else
  255.           score -= user.stages[:SPECIAL_DEFENSE] * 20
  256.         end
  257.       elsif user.stages[:SPECIAL_DEFENSE] < 0
  258.         score += 20
  259.       end
  260.  
  261.  
  262. #AI_Move_EffectScores_2, under this section:
  263.     #---------------------------------------------------------------------------
  264.     when "SetTargetTypesToWater"
  265.       if target.effects[PBEffects::Substitute] > 0 || !target.canChangeType?
  266.         score -= 90
  267.       elsif !target.pbHasOtherType?(:WATER)
  268.         score -= 90
  269.       end
  270. #add:
  271.     #---------------------------------------------------------------------------
  272.     when "SetTargetTypesToRock"
  273.       if target.effects[PBEffects::Substitute] > 0 || !target.canChangeType?
  274.         score -= 90
  275.       elsif !target.pbHasOtherType?(:ROCK)
  276.         score -= 90
  277.       end
  278.  
  279. #AI_Move_EffectScores_2, in this section
  280.     #---------------------------------------------------------------------------
  281.     when "ParalyzeTarget", "ParalyzeTargetIfNotTypeImmune",
  282.          "ParalyzeTargetAlwaysHitsInRainHitsTargetInSky", "ParalyzeFlinchTarget"
  283.  
  284. #add EffectivenessIncludesDarkTypeParalyzeFlinchTarget, like so
  285.     #---------------------------------------------------------------------------
  286.     when "ParalyzeTarget", "ParalyzeTargetIfNotTypeImmune",
  287.          "ParalyzeTargetAlwaysHitsInRainHitsTargetInSky", "ParalyzeFlinchTarget",
  288.          "EffectivenessIncludesDarkTypeParalyzeFlinchTarget"
  289.  
  290. #AI_Move_EffectScores_2,
  291.     #---------------------------------------------------------------------------
  292.     when "ParalyzeBurnOrFreezeTarget"
  293.       score += 30 if target.status == :NONE
  294. #add ParalyzeOrBurnTarget and RandomStatusTarget, like so
  295.     #---------------------------------------------------------------------------
  296.     when "ParalyzeBurnOrFreezeTarget", "ParalyzeOrBurnTarget", "RandomStatusTarget"
  297.       score += 30 if target.status == :NONE
  298. #In AI_Move_EffectScores_3, under this section
  299.     #---------------------------------------------------------------------------
  300.     when "HealUserDependingOnWeather"
  301.       if user.hp == user.totalhp || (skill >= PBTrainerAI.mediumSkill && !user.canHeal?)
  302.         score -= 90
  303.       else
  304.         case user.effectiveWeather
  305.         when :Sun, :HarshSun
  306.           score += 30
  307.         when :None
  308.         else
  309.           score -= 30
  310.         end
  311.         score += 50
  312.         score -= user.hp * 100 / user.totalhp
  313.       end
  314. #add
  315.     #---------------------------------------------------------------------------
  316.     when "HealUserDependingOnWeather"
  317.       if user.hp == user.totalhp || (skill >= PBTrainerAI.mediumSkill && !user.canHeal?)
  318.         score -= 90
  319.       else
  320.         case user.effectiveWeather
  321.         when :Rain, :HeavyRain
  322.           score += 30
  323.         when :None
  324.         else
  325.           score -= 30
  326.         end
  327.         score += 50
  328.         score -= user.hp * 100 / user.totalhp
  329.       end
  330. #In this section
  331.     when "RecoilThirdOfDamageDealtParalyzeTarget"
  332.       score -= 30
  333.       if target.pbCanParalyze?(user, false)
  334.         score += 30
  335.         if skill >= PBTrainerAI.mediumSkill
  336.           aspeed = pbRoughStat(user, :SPEED, skill)
  337.           ospeed = pbRoughStat(target, :SPEED, skill)
  338.           if aspeed < ospeed
  339.             score += 30
  340.           elsif aspeed > ospeed
  341.             score -= 40
  342.           end
  343.         end
  344.         if skill >= PBTrainerAI.highSkill
  345.           score -= 40 if target.hasActiveAbility?([:GUTS, :MARVELSCALE, :QUICKFEET])
  346.         end
  347.       end
  348. #add RecoilHalfOfDamageDealtParalyzeTarget, like so
  349.     when "RecoilThirdOfDamageDealtParalyzeTarget", "RecoilHalfOfDamageDealtParalyzeTarget"
  350.       score -= 30
  351.       if target.pbCanParalyze?(user, false)
  352.         score += 30
  353.         if skill >= PBTrainerAI.mediumSkill
  354.           aspeed = pbRoughStat(user, :SPEED, skill)
  355.           ospeed = pbRoughStat(target, :SPEED, skill)
  356.           if aspeed < ospeed
  357.             score += 30
  358.           elsif aspeed > ospeed
  359.             score -= 40
  360.           end
  361.         end
  362.         if skill >= PBTrainerAI.highSkill
  363.           score -= 40 if target.hasActiveAbility?([:GUTS, :MARVELSCALE, :QUICKFEET])
  364.         end
  365.       end
  366. #Under this section
  367.     #---------------------------------------------------------------------------
  368.     when "DoublePowerIfTargetAsleepCureTarget"
  369.       score -= 20 if target.status == :SLEEP &&   # Will cure status
  370.                      target.statusCount > 1
  371. #add
  372.     #---------------------------------------------------------------------------
  373.     when "DoublePowerIfTargetFrozenCureTarget"
  374.       score -= 20 if target.status == :FROZEN &&   # Will cure status
  375.                      target.statusCount > 1
  376. #AI_Move_Utilities, under this line
  377.          "PowerHigherWithUserHappiness",
  378. #add
  379.          "PowerHigherWithUserCoolness", #Amaze and Dragon Dive
  380.          "PowerHigherWithTargetSpAtk", #Brain Squeeze
  381.          "PowerHigherWithUserSmart", #Confound, Phantasmata
  382.          "PowerHigherWithUserCuteness", #Dazzle, Prism Shower
  383.          "PowerHigherWithUserToughness", #Demolish, Wild Maul
  384.          "PowerHigherWithUserBeauty", #Elegant Wave and Enthrall
  385.          "DoublePowerIfTargetFrozenCureTarget", #Ice Drill
  386.          "DoublePowerIfTargetDarkDragonFairy", #Knight Sword
  387.  
  388. #AI_Move_Utilities, change this line:
  389.     when "AlwaysCriticalHit", "HitTwoTimes", "HitTwoTimesPoisonTarget"   # Frost Breath, Double Kick, Twineedle
  390. #to
  391.     when "AlwaysCriticalHit", "HitTwoTimes", "HitTwoTimesPoisonTarget", "TwoTurnAttackInvulnerableAlwaysCriticalHit"   # Frost Breath, Double Kick, Twineedle, Backstab
  392. #Under this section
  393.     when "TwoTurnAttackOneTurnInSun"   # Solar Beam
  394.       baseDmg = move.pbBaseDamageMultiplier(baseDmg, user, target)
  395. #add
  396.     when "TwoTurnAttackOneTurnInSun", "TwoTurnAttackOneTurnInHail"  # Solar Beam, Glacier Rush
  397.       baseDmg = move.pbBaseDamageMultiplier(baseDmg, user, target)
  398. #AI_Move_Utilities, this section:
  399.     when "DoublePowerIfTargetUnderwater", "DoublePowerIfTargetUnderground",
  400.          "BindTargetDoublePowerIfTargetUnderwater"
  401.       baseDmg = move.pbModifyDamage(baseDmg, user, target)
  402. #add DamageTargetAllyDoublePowerIfTargetUnderwater to the list
  403.     when "DoublePowerIfTargetUnderwater", "DoublePowerIfTargetUnderground",
  404.          "BindTargetDoublePowerIfTargetUnderwater", "DamageTargetAllyDoublePowerIfTargetUnderwater"
  405.       baseDmg = move.pbModifyDamage(baseDmg, user, target)
  406. #AI_Move_Utilities, under this section:
  407.     when "EffectivenessIncludesFlyingType"   # Flying Press
  408.       if GameData::Type.exists?(:FLYING)
  409.         if skill >= PBTrainerAI.highSkill
  410.           targetTypes = target.pbTypes(true)
  411.           mult = Effectiveness.calculate(
  412.             :FLYING, targetTypes[0], targetTypes[1], targetTypes[2]
  413.           )
  414.         else
  415.           mult = Effectiveness.calculate(
  416.             :FLYING, target.types[0], target.types[1], target.effects[PBEffects::Type3]
  417.           )
  418.         end
  419.         baseDmg = (baseDmg.to_f * mult / Effectiveness::NORMAL_EFFECTIVE).round
  420.       end
  421.       baseDmg *= 2 if skill >= PBTrainerAI.mediumSkill && target.effects[PBEffects::Minimize]
  422. #add:
  423.     when "EffectivenessIncludesDarkTypeParalyzeFlinchTarget"   # Flying Press
  424.       if GameData::Type.exists?(:DARK)
  425.         if skill >= PBTrainerAI.highSkill
  426.           targetTypes = target.pbTypes(true)
  427.           mult = Effectiveness.calculate(
  428.             :DARK, targetTypes[0], targetTypes[1], targetTypes[2]
  429.           )
  430.         else
  431.           mult = Effectiveness.calculate(
  432.             :DARK, target.types[0], target.types[1], target.effects[PBEffects::Type3]
  433.           )
  434.         end
  435.         baseDmg = (baseDmg.to_f * mult / Effectiveness::NORMAL_EFFECTIVE).round
  436.       end
  437.       baseDmg *= 2 if skill >= PBTrainerAI.mediumSkill && target.effects[PBEffects::Minimize]
  438.  
  439. #Under this section:
  440.     # Charge
  441.     if skill >= PBTrainerAI.mediumSkill &&
  442.        user.effects[PBEffects::Charge] > 0 && type == :ELECTRIC
  443.       multipliers[:base_damage_multiplier] *= 2
  444.     end
  445. #add
  446.     # Stoke
  447.     if skill >= PBTrainerAI.mediumSkill &&
  448.        user.effects[PBEffects::Stoke] > 0 && type == :FIRE
  449.       multipliers[:base_damage_multiplier] *= 2
  450.     end
  451.  
  452. #In AI_Move, change this line
  453.         elsif target.inTwoTurnAttack?("TwoTurnAttackInvulnerableRemoveProtections")
  454. to
  455.         elsif target.inTwoTurnAttack?("TwoTurnAttackInvulnerableRemoveProtections", "TwoTurnAttackInvulnerableAlwaysCriticalHit")
  456. #and this line
  457.         elsif target.inTwoTurnAttack?("TwoTurnAttackInvulnerableUnderwater")
  458. to
  459.         elsif target.inTwoTurnAttack?("TwoTurnAttackInvulnerableUnderwater","TwoTurnAttackInvulnerableUnderwaterTargetCannotAct")
  460.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement