This is a good question, and something I might look more in depth when I have free time.
I know of one function in Fire Red that can do this, and that would be the Magikarp guy on Route 4.
Now, I did this a couple of weeks ago, but I basically transferred ALL the offsets on that script into XSE @'s, and in doing so, I understood it more.
Today, because of your question, I understood it even more.
When a Pokemon is giving, AFAIK, a value is returned into variable 0x800D, or LASTRESULT. The variables, as I understand them, are this.
When 0x800D = 0, the players party has a free space.
When 0x800D = 1, the players party is full. The game will then use a PC box.
When 0x800D = 2, the players party
and PC Boxes are full. You can no longer obtain anymore Pokemon until you release one.
Now, you'll need the second one, to move the players pokemon into a box.
To achieve this, and again this is theory at this point, you can find the text in the below script of:
Below that, you'll see:
Now, you"d replace this:
With this:
That will automatically, in theory, jump to a function as if the player had a Pokemon going to the box.
Now, I'm going to point you to what you need, please follow me to these offsets.
Go to #org @boxandsetflag
This calls #org @bufferboxandpokemon, go there
Now, take a look at this at #org @bufferboxandpokemon:
It looks like this sets the variables for our next part.
We now goto #org @sendtosomeonespc
This is the important part:
And:
The first part basically runs a special that, in theory, actually moves your Pokemon to the current box. Failing that, it does the second part, which is to run a special that changes the box, and put's a new Pokemon into it.
Now, this is all very straight foward if you read carefully. In short:
1. After giving a pokemon, the game checks the party pokemon to see if you have room left, then boxes to see if their full or not, then finally it checks to see if you have anyroom at all.
By creating a new script that simply by passes this part, you can make it
directly store a pokemon into the box. That code'd would look like what we have above in the second spoiler.
2. The game checks if you have seen bill or not, etc. It'll display different messages based on if you do or don't.
3. The game runs two specials. One if for putting a pokemon into a box. If that fails, the second will change the box and
then transfer the pokemon.
Final notes:
This is research on the subject. For this part, I won't be writing a script for you. This is research on a theory that is most likely true.
As a result,
you will have to create a script based on these very informative notes. You will also have to analyze the parts that you need on the script. Follow the train of offsets above and you'll see
how this works.
Here is the Magikarp script with a pretty good break down:
Good luck with this one. It's a lot easier then you think.
Have fun and happy hacking!