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

Turn Order needs to be handled how it is in-game #1157

Closed
DanUgore opened this issue Aug 22, 2014 · 15 comments
Closed

Turn Order needs to be handled how it is in-game #1157

DanUgore opened this issue Aug 22, 2014 · 15 comments
Labels

Comments

@DanUgore
Copy link
Collaborator

Mostly relevant to VGC and Triples. At the moment it is done using a sorting function which compares two pokemon at a time while ordering based on speed.
Properly handling this issue will involve:

  • determining turn order before any moves are played out
  • sorting the pokemon based on the in-game sort function. this includes using speed & 8191 over speed for comparisons.
  • using the battle's rng -- this.random() -- to determine speed-ties

This will also allow us to not require getStatCallback() for the "Trick Room Glitch"

@DanUgore DanUgore added the bug label Aug 22, 2014
@DanUgore
Copy link
Collaborator Author

Putting this here so I do not forget to work on it later.

@Joimer
Copy link
Contributor

Joimer commented Nov 12, 2014

@V4Victini question, was something changed about this?

@DanUgore
Copy link
Collaborator Author

It's partially done. I just need to handle residuals.

@bb010g
Copy link

bb010g commented Apr 9, 2015

bump

@ascriptmaster
Copy link
Contributor

What was the Trick Room Glitch?

@Slayer95
Copy link
Contributor

@ascriptmaster
Copy link
Contributor

I noticed recently in comparePriority that there's code to check sub-priorities as well. Could we fashion out some sort of ModifySubPriority that Trick Room can use instead of mucking with speed?

@DanUgore
Copy link
Collaborator Author

https://github.com/DanUgore/Pokemon-Showdown/blob/turn-order/battle-engine.js#L3181

Here's an example @ascriptmaster Just have Trick Room modify decision.speed and not decision.pokemon.speed

@ascriptmaster
Copy link
Contributor

That works too. ModifyDecisionSpeed?

@DanUgore
Copy link
Collaborator Author

Sure.

@DanUgore
Copy link
Collaborator Author

DanUgore commented Apr 25, 2016

Speed is compared...

  • Before the turn plays out
  • After Mega Evolution (still uses pre-mega evolution speed. its just the order that the mega evolution occurs)
  • Before residuals (since mega evolution has already occurred it uses that speed)

Determining who wins a speed tie

  • Make a list of tied pokemon in order. Host (P1) Position A (left) would be the start (0), P2/P4 Position C (right) would be the end.
  • Roll a number between 0 and tied_pokemon_total - 1. Put that position to go first.
  • Repeat Step 2 while decrementing until tied_pokemon_total == 1 and add the final pokemon to the end

@Zarel
Copy link
Member

Zarel commented Apr 25, 2016

Wait, that's known? Do you have a link?

@Zarel
Copy link
Member

Zarel commented Apr 25, 2016

Also, what happens in the case of multiple speed ties?

@DanUgore
Copy link
Collaborator Author

I don't have a link. I was talking with Kaphotics about the behavior back when I was working in the issue and needed to know how it worked. Also what do you mean by multiple speed ties? I don't see how that would cause different behavior.

@Zarel
Copy link
Member

Zarel commented Apr 26, 2016

Depending on how Game Freak implements multiple speed ties, this could work completely differently in that case.

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

No branches or pull requests

6 participants