smogon / pokemon-showdown

Pokémon battle simulator.
https://pokemonshowdown.com
MIT License
4.77k stars 2.79k forks source link

Custom Pokemon? #7517

Closed TheYellowArchitect closed 4 years ago

TheYellowArchitect commented 4 years ago

Hello!

To explain what I need, first I need to explain my use-case. I am used to playing a pokemon game with a friend, then importing our teams at pokemon showdown and fighting. However, we want to play "Pokemon Infinite Fusion" this time, and ofc it is impossible to make a team, and that's a good thing

I would like to have a choice as a user to make a custom pokemon. It kinda is there, as you can have any pokemon's abilities and moves, in a pokemon. But for it to fully work, you have to be able to: [ ]Put any custom sprite (could help non-Pokemon Infinite Fusion players, by putting hats or w/e at their pokemon) [ ]Choose out of any type combination. [ ]Select stats unrestricted from pokemon species at any level

I haven't contributed before, but if it is fairly easy, I will consider it, so my question really is: "How easy is it to make a feature like this?"

Edit: Custom Sprites are optional. Yes, they have a lot of issues attached to their implementation.

mia-pi-git commented 4 years ago

It's pretty difficult, all things considered. This suggestions thread goes over it https://www.smogon.com/forums/threads/possibility-of-changing-base-stats-for-custom-games.3669135/. Not something that would be recommended for a junior dev. It'd also be a lot of client work that'd be difficult to complete with the client Preact rewrite ongoing. You'd need a teambuilder UI that would then message the data back to the server, which would have to validate, then update the data cache, plus you'd need to find a good way to store it. Plus, you'd need to update the teambuilder to handle the Pokémon post-creation. Large undertaking that's likely to be blocked on Preact client.

AnnikaCodes commented 4 years ago

Also, I don't think we want to support custom sprites in any case; they take up space on the server and can be abused to display images that break the global rules.

TheYellowArchitect commented 4 years ago

Custom sprites are definitely the "hardest" thing in here, and shouldn't be stored on the server I agree, so it would have to be done locally or have an "Mod spritesheet" server reference.

and can be abused to display images that break the global rules.

This kind of custom game mode won't be used by any player but friends, no matchmaking, only direct duel choice just like custom mons currently is

Aside of that, the other 2 features should make it playable aside of the sprite, I am looking over the thread, thanks for that <3

TheYellowArchitect commented 4 years ago

14 14 @Zarel Seeing there is a bounty, could you give me an overview of what would have to be done for each? And if possible some documentation on these parts hahaha

I am new to this project, but I am no new developer, and since I doubt this functionality needs expansion, I could try to hard-code it to save time

mia-pi-git commented 4 years ago

You'd still have to moderate sprites, even if it's just between two people. What if someone uses porn as an image and challenges a random user? (Also see my post for an overview of what would need to be done)

mia-pi-git commented 4 years ago

Hard-coding also wouldn't be advised, in the case of future overhauls. This would be an issue particularly in the teambuilder, since that is actively being rewritten.

TheYellowArchitect commented 4 years ago

What if someone uses porn as an image and challenges a random user?

Custom Sprites should be allowed only for pokemon, so no NSFW images until duel is accepted (would anyone accept a random duel with ultra custom mons?)

You'd need a teambuilder UI

Can't the current teambuilder simply be expanded? Clicking types for example to change them and ofc getting a warning Same for stats, perhaps press Shift while writing the number and it allows you to enter any value (ofc denied as well)

then update the data cache, plus you'd need to find a good way to store it

What is inside this data cache? And good way to store it = ? Aside of the custom pokemon sprite, the custom typing and stats could be as simple as they are now, just with a "tag"/flag that they are not legit for any duel except custom mons

Large undertaking that's likely to be blocked on Preact client. It'd also be a lot of client work that'd be difficult to complete with the client Preact rewrite ongoing.

Hmmm... For not knowing the codebase, it does sound tough, especially when I don't even know what the rewrite will change lel

Before I give up completely, could you redirect me to the following code locations, so I can skim and judge myself? :P []Server validation of client data sent []Update&Store data cache

@mia-pi-git

KrisXV commented 4 years ago

People can use the nsfw images as the custom sprite for the Pokémon is what Mia is saying.

mia-pi-git commented 4 years ago

Server validation of client data sent

Server is done with the chat command /vtm, which uses the TeamValidatorAsync interface (server/team-validate-async.ts), plus you'd need a new command for this. Data cache is held in sim/dex.ts (mostly.) What I'm saying about nsfw is what kris said, what if someone uses nsfw images as a sprite and then challenges someone? A lot of people would probably accept, so it's something that would be a problem.

TheYellowArchitect commented 4 years ago

What I'm saying about nsfw is what kris said, what if someone uses nsfw images as a sprite and then challenges someone? A lot of people would probably accept, so it's something that would be a problem.

It is kind of surprising to see so much focus on the custom sprites' disadvantages, instead of their actual implementation, since there are many ways to bypass it like only friends can see the custom sprites

And regarding the custom sprites, they are not necessary, though I consider them essential for my original goal

The bounty mentioned above, does not even mention custom sprites, and it is true, custom sprites are the hardest thing in this.

Server is done with the chat command /vtm, which uses the TeamValidatorAsync interface (server/team-validate-async.ts), plus you'd need a new command for this. Data cache is held in sim/dex.ts (mostly.)

Thanks for this, I will look into it sometime tomorrow, will sleep for now

Zarel commented 4 years ago

I am new to this project, but I am no new developer, and since I doubt this functionality needs expansion, I could try to hard-code it to save time

It's unclear to me what you mean by "hard-code".

I suspect you mean it differently from how others here are interpreting it, though. I think as long as it actually works (in that users would be able to choose stats for pokemon), it's probably fine, though.

It is kind of surprising to see so much focus on the custom sprites' disadvantages, instead of their actual implementation, since there are many ways to bypass it like only friends can see the custom sprites

We don't want friends to share porn, either, especially since "friends" is just "whoever you can trick into adding as a friend, which most users don't consider possible".

This is unfortunately a fundamental problem with not banning below-13 users from our sim – we have an unavoidable obligation to be much more careful with this sort of thing than usual.

But maybe it would be OK if we had very specific "I promise I'm over 18 and that PS doesn't know what these images will look like" opt-in for them?

TheYellowArchitect commented 4 years ago

We don't want friends to share porn, either, especially since "friends" is just "whoever you can trick into adding as a friend, which most users don't consider possible".

This is unfortunately a fundamental problem with not banning below-13 users from our sim – we have an unavoidable obligation to be much more careful with this sort of thing than usual.

But maybe it would be OK if we had very specific "I promise I'm over 18 and that PS doesn't know what these images will look like" opt-in for them?

The NSFW Custom Sprite Solution

Since the original goal is for friends to duel having finished pokemon games with custom pokemon, this whole custom sprites issue can be easily solved by making the sprites changed exclusively on the client/locally, by giving a filepath. How this applies to the one you duel with? He has the same spritepacks, and he just puts them on the same filepath (InfiniteFusions has like 50 sprite pack folders at this point) I honestly think that people fighting with 100% custom pokemon (species, typing, sprites), which their opponent does not know, to be horrible and harmful to pokemon showdown.

==

Aside of the custom sprites issue which I think is doable, but negligible, I have to look into the other 2, typing combination and custom stat adjustments. I haven't skimmed that code yet, once done I will write a long list of things to consider given its bounty importance, will skim the code later today hopefully :+1:

Once done, this should help not just me to play with my friend, but make every custom ROM playable online :)

sparkyneko commented 4 years ago

Pretty sure PS doesn't support/allow discussion or ROMs so like that's probably already a not a good thing to encourage. If im not misunderstanding, user supplied custom sprites probably also have an issue (beyond pooooorrrrnnnn) in that other users can get your IP address, and maybe do a lot more by sending images to the other user without the other user's "consent" to download em. (Unless you do ehat discord does and completely rebuild the RGB of the image on the server before serving it to users in battle)

TheYellowArchitect commented 4 years ago

If im not misunderstanding, user supplied custom sprites probably also have an issue (beyond pooooorrrrnnnn) in that other users can get your IP address

What? How can other users get your IP? When duel happens, does the server allow the players to see the opponent's IP?

and maybe do a lot more by sending images to the other user without the other user's "consent" to download em

Sounds like a security vulnerability irrelevant to custom sprites

Anyway, please note my above post. Custom Sprites if they are to be implemented, should be implemented locally only, and after that, there should be no such problems

Aside of that, it seems I have to edit the original post, as a lot of people seem to just read the first post and reply with why custom sprites are bad, instead of guiding on implementation of custom pokemon, custom sprites aren't even 1/3rd of this implementation

TheYellowArchitect commented 4 years ago

Alright, looked into the code, thank you all for your help, especially @mia-pi-git

I do not know javascript/typescript, nor have experience with this codebase, nor does it have any comments I thought I could achieve this in a few days, but it's obviously unrealistic to put such a deadline on me, given if it does work, there will be many bugs to sort here and there, since I would be editing in the dark trial&error style, not knowing what even a fraction of the functions do

I would like to at least drop what I had in mind, assuming the code was ultra clean and easy to edit:

[]Type Combination Just like all the other fields which are clickable/editable on a pokemon window, the type fields (above ability window) would be clickable and editable as well, with a checkbox style configuration (2 max selectable) This means a small UI change []Unrestricted stat values, by simply pressing Shift on the stat fields of the pokemon

Each of the above would mean a boolean tag would be made for every pokemon instance, in one case for "Not Legal/Possible Stats", and the other for "Not Legal/Possible Typing for this Species". With this boolean tag/flag, server validation would be a simple if-check, just like it does currently with custom mons on other modes (I would copy-paste and edit that part but I can't even find this)

The above 2 would be able to be achieved in every pokemon, so it would be an extension of the current data-bases, no real refactoring. Hence, you would be able to fight with 100% custom pokemon, mechanics-wise.

==

Then I would move for the Custom Sprites, which theoritically is a simple filepath import. The only way to properly do custom sprites is by using local files, so even if 2 players want to play some custom pokemon game, they can get the same spritesheet folder of the pokemon in that game, on the same filepath location, and they will be easily done with this.

However, this would mean replacing existing pokemon slots with custom sprites alternatives, instead of creating new pokemon...

It's just a mess. Because this feature is extremely niche, and pokemon server creator tool is needless without the custom sprites... Aside of niche users like myself, it would be used once per pokemon generation, and that is rare. But since the bounty above mentions it, I may as well explain what could be done for this:

Every player can create as many pokemon he wants, with the same data structure as the server has them hard-coded currently These are locally saved, in a .txt file, kind of like pokemon teams are stored (or .JSON) And there should be the option for custom duels, to use local pokemon (these local pokemon should be transferred on opponent on the start of combat) Local pokemon are not even a thing right now, and would have to be made from scratch, and refactor how the code works since it currently allows only server pokemon. And while the "NSFW sprites" problem is solved, the .txt pokemon parsing could be abused for sure, to crash the opponent's game, to worse, though I doubt anyone of knowledge of this codebase would bother ruining games of randoms

100$ bounty for functional pokemon creator tool given what it entails? If more, definitely some experienced contributor could give it a try and hopefully use some of my design suggestions/ideas above, surely in the following years someone will have more experience and will than me

For those of you contributing to the rewrite, I honestly wish you the best of success given this codebase is not accessible at all and I bet it's hard to maintain or even expand (e.g. seeing how some gen8 stuff were slapsticked)

Zarel commented 4 years ago

To be clear, I do think $100 is low for something like this. In the end, we're just fans doing things for fun and none of the people who want this can afford to pay a real developer's salary. I don't think online pokemon is a good field to go into if you want to be well-paid.

I agree that the battle engine is currently rather badly documented. If you had any specific feedback for which parts were confusing, that would help us a lot.

TheYellowArchitect commented 4 years ago

To be clear, I do think $100 is low for something like this. In the end, we're just fans doing things for fun and none of the people who want this can afford to pay a real developer's salary. I don't think online pokemon is a good field to go into if you want to be well-paid.

The bounty doesn't matter to me, I was hyped to do this so me and my friend play together, seeing the bounty however gives a slight more motivation. If I was sniping bounties I wouldn't be doing this obviously

I agree that the battle engine is currently rather badly documented. If you had any specific feedback for which parts were confusing, that would help us a lot.

Pretty much nothing had comments. Calling functions from other classes with confusing naming atop of that, without any idea how anything works or happens

Just having comments on what each line does would help a ton, since accessibility barrier would lower and hence there would be more contributors

Or at least a summary on some classes or functions :(

Currently I am certain the only ones who can implement major features are those who have more than 1 year of experience in the codebase, because aside of the experience of writing it, there is no other way to understand how it all works imo

I am not saying it in any bad way, it is impressive it all works and the user experience is so good. Especially given it is free, made by people with free time, but exploring the codebase reminded me of seeing some kind of big assembly system architecture xD

Anyhow, I wish you success if you are part of the rewriting :+1: