Piexplode

Cmd_if_type_effectiveness

Jan 20th, 2024
1,019
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.46 KB | None | 0 0
  1. static void Cmd_if_type_effectiveness(void)
  2. {
  3.     u8 damageVar;
  4.  
  5.     gDynamicBasePower = 0;
  6.     gBattleStruct->dynamicMoveType = 0;
  7.     gBattleScripting.dmgMultiplier = 1;
  8.     gMoveResultFlags = 0;
  9.     gCritMultiplier = 1;
  10.  
  11.     gBattleMoveDamage = AI_EFFECTIVENESS_x1;
  12.     gCurrentMove = AI_THINKING_STRUCT->moveConsidered;
  13.  
  14.     // TypeCalc does not assign to gMoveResultFlags, Cmd_typecalc does
  15.     // This makes the check for gMoveResultFlags below always fail
  16.     // This is how you get the "dual non-immunity" glitch, where AI
  17.     // will use ineffective moves on immune pokémon if the second type
  18.     // has a non-neutral, non-immune effectiveness
  19.     // This bug is fixed in this mod
  20.     gMoveResultFlags = TypeCalc(gCurrentMove, sBattler_AI, gBattlerTarget);
  21.  
  22.     if (gBattleMoveDamage >= 180)
  23.         gBattleMoveDamage = AI_EFFECTIVENESS_x4;
  24.     if (gBattleMoveDamage <= 15)
  25.         gBattleMoveDamage = AI_EFFECTIVENESS_x0_25;
  26.     if (gBattleMoveDamage >= 90)
  27.         gBattleMoveDamage = AI_EFFECTIVENESS_x2;
  28.     if (gBattleMoveDamage <= 30)
  29.         gBattleMoveDamage = AI_EFFECTIVENESS_x0_5;
  30.  
  31.     if (gMoveResultFlags & MOVE_RESULT_DOESNT_AFFECT_FOE)
  32.         gBattleMoveDamage = AI_EFFECTIVENESS_x0;
  33.  
  34.     // Store gBattleMoveDamage in a u8 variable because gAIScriptPtr[1] is a u8.
  35.     damageVar = gBattleMoveDamage;
  36.  
  37.     if (damageVar == gAIScriptPtr[1])
  38.         gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 2);
  39.     else
  40.         gAIScriptPtr += 6;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment