Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Battle 2k & 2k3 - Verify and implement correct escape algo #2150

Closed
2 tasks done
fmatthew5876 opened this issue Apr 14, 2020 · 2 comments · Fixed by #2151
Closed
2 tasks done

Battle 2k & 2k3 - Verify and implement correct escape algo #2150

fmatthew5876 opened this issue Apr 14, 2020 · 2 comments · Fixed by #2151

Comments

@fmatthew5876
Copy link
Contributor

fmatthew5876 commented Apr 14, 2020

Making a separate issue for this since it's complex

  • Verify rules for 2k escape and fix if needed
  • Verify rules for 2k3 escape and implement
@fmatthew5876
Copy link
Contributor Author

2k Escape Rules

The offsets here are from 2ke

  • AvgActorAgi 0x832D8
max(1, sum(actor.agi) / num_actors)
  • AvgMonsterAgi 0x486C94
max(1, sum(monster.agi) / num_monsters)
  • Initial flee chance 0x4795A4:49
int ratio = 100.0 * ((double)avg_monster_agi / (double)avg_actor_agi);
fleeChance = clamp(150 - ratio, 64, 100)
  • Rules for allowing escape at the option window 0x47a434:75
if (escapeAllowed)
  • Success check on escape command 0x47AEF8:25
randInclusive(0,99) < fleeChance || firstStrike
  • What happens if you fail? 0x47AEF8:38
fleeChance += 10
  • After the first round
firstStrike = 0

@fmatthew5876
Copy link
Contributor Author

2k3 Escape Rules

  • Initial flee chance

Same as 2k

  • Rules for allowing escape at the option window
escapeAllowed && (numTurns == 0) && 
    (firstStrike || encounterCondition == surround || encounterCondition == surround)
  • Rules for allowing actor escape
escapeAllowed && encounterCondition != pincer
  • What happens when you escape from option window

fleeChance not checked, escape automatically succeeds

  • Success check on actor escape command
  if ( rand(0, 99) < fleeChance || firstStrike )

RPG_RT bug: Escape is not guaranteed for initiative or surround! Only for normal battles with first strike flag set. ❗

  • What happens if you fail
fleeChance += 10;
  • When an actor takes a non-escape action

0x49A04C

firstStrike = 0;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

2 participants