PDA

View Full Version : [Essentials tutorial] Basic Mystery Gift Tutorial


|Maximus|
December 13th, 2009, 04:47 PM
Okay, so I have actually decided to make my first tutorial. This tutorial is going to be how to create a Basic Mystery Gift Person Dude Thingy :P

Okay, so I am going to break this up into steps.

1) Checking for a File

So first you want to create a Conditional Branch with this line of script.


@> Conditional Branch: Script: FileTest.exist?("Arceus.pkmn")
@>
: Else
@>
: Branch End
@>

Basically, it checks if you have "Arceus.pkmn" inside of your game folder. View the video inside of my signature for how to create custom files.

2) Adding the Effect

So, what happens if you do have the file? Easy, we can add the Arceus.


@> Conditional Branch: Script: FileTest.exist?("Arceus.pkmn")
@> Text: You have the Mystery Gift.
@> Conditional Branch: Script: Kernel.pbAddPokemon(PBSpecies::ARCEUS,80)
@> Self Switch: A = ON
@>
: Else
@>
: Branch End
@>
: Else
@>
: Branch End
@>


3)What if you don't have it?

Well, thats easy. Just add whatever you want under 'else'



@> Conditional Branch: Script: FileTest.exist?("Arceus.pkmn")
@> Text: You have the Mystery Gift.
@> Conditional Branch: Script: Kernel.pbAddPokemon(PBSpecies::ARCEUS,80)
@> Self Switch: A = ON
@>
: Else
@>
: Branch End
@>
: Else
@> Text: The Gift is not for everyone.
@>
: Branch End
@>


Well, that's my tutorial I hope you enjoyed it, and found it useful! Check out the video in the spoiler in my signature because that is where you will find out how to convert TXT files into .PKMN files.

PHEW, that's a lot of typing!

Klofkac
December 15th, 2009, 12:30 PM
I always wondered how to check file existing. And now I know it!
I have question: How I check, what's in that file written?

Poeman
December 15th, 2009, 02:15 PM
I have done something like this before except it read data from a website after downloading it, much better because that way you can set events on the website :D
Maybe we could implement my method into Sparkling Yellow?

darkerarceus
December 28th, 2009, 06:08 PM
Well I have viewed the video in your siganture 2 weeks ago and the point is wouldn't it be easy to just make the file Arceus.pkmn and errrr... Cheat?

Poeman
December 28th, 2009, 06:09 PM
Thats why reading from a server is safer.

|Maximus|
December 28th, 2009, 08:34 PM
Well I have viewed the video in your siganture 2 weeks ago and the point is wouldn't it be easy to just make the file Arceus.pkmn and errrr... Cheat?

Well, people could-- Well I suppose -- I got nothing. Yeah, I guess that's true. Maybe, people could create a file that nobody else would think of. Like in example instead of "Arceus.pkmn" put "Crayon.pkmn" I don't know I was looking at a box of crayons when I typed this :P

davidthefat
December 28th, 2009, 10:11 PM
Ok heres my Idea, Im assuming this is obtainable through the game. You can have a entry in the database for a boolean (true, false) check if true, if true, check ID (When the mystery gift is obtained, the server generates random numbers and stores it as the ID and the client gets the ID and writes it in the file) and compared both IDs, if the same, allow it to take effect, if not, disable mystery gift forever, but that wont allow multiple accounts or sharing accounts...

Wichu
December 29th, 2009, 02:24 AM
Naming it something random isn't a good idea; security through obscurity isn't really security at all. It would take a single person to decrypt the game data, check the filenames needed, and post them on a forum, to completely ruin the whole thing.

The best way to do it is to implement everything on the server. The game doesn't do any checking whatsoever; instead, it pulls data off a website and creates a Pokémon from that.

That way, you can add new gifts after the game has been published, and make sure players can't cheat (short of hacking the site where it's stored). You could even add the code to a fixed forum post (the first post in the thread), and have the game read from that.

I'm probably going to make a tutorial for my method, and more :P

Ty 101
December 29th, 2009, 05:50 AM
Naming it something random isn't a good idea; security through obscurity isn't really security at all. It would take a single person to decrypt the game data, check the filenames needed, and post them on a forum, to completely ruin the whole thing.

The best way to do it is to implement everything on the server. The game doesn't do any checking whatsoever; instead, it pulls data off a website and creates a Pokémon from that.

That way, you can add new gifts after the game has been published, and make sure players can't cheat (short of hacking the site where it's stored). You could even add the code to a fixed forum post (the first post in the thread), and have the game read from that.

I'm probably going to make a tutorial for my method, and more :P

Whether you remember or not, about a half year ago you greatly helped me write a mystery gift event that read text from my website.
I knew pretty much nothing about scripting then and you helped me along.

It is still the only real feature in my game but with all of these tutorials, I guess that I will have to make something new.

Nyu~♥!
December 29th, 2009, 06:06 PM
Naming it something random isn't a good idea; security through obscurity isn't really security at all. It would take a single person to decrypt the game data, check the filenames needed, and post them on a forum, to completely ruin the whole thing.

The best way to do it is to implement everything on the server. The game doesn't do any checking whatsoever; instead, it pulls data off a website and creates a Pokémon from that.

That way, you can add new gifts after the game has been published, and make sure players can't cheat (short of hacking the site where it's stored). You could even add the code to a fixed forum post (the first post in the thread), and have the game read from that.

I'm probably going to make a tutorial for my method, and more :P

Yeah, that'd be better. Though, I was thinking a different way before seeing this:
The player gets a secret code from the games site, which they can then enter into a certain computer. (of course, this code would be something totally unpredictable, like fhyd80292 or watev, lol) By doing this the player can pick up a certain item from a little map I created called the Delivery Office.
They would then activate it, by using it in a certain area, or using the item in it's own specialty(like the flutes playing) to start an event.


..but, I totally suck at scripting such items. :/ And I don't know anything about inputting text. |o

|Maximus|
December 30th, 2009, 08:01 AM
Yeah, that'd be better. Though, I was thinking a different way before seeing this:
The player gets a secret code from the games site, which they can then enter into a certain computer. (of course, this code would be something totally unpredictable, like fhyd80292 or watev, lol) By doing this the player can pick up a certain item from a little map I created called the Delivery Office.
They would then activate it, by using it in a certain area, or using the item in it's own specialty(like the flutes playing) to start an event.


..but, I totally suck at scripting such items. :/ And I don't know anything about inputting text. |o

By inputting text you could probably modify the name input method a little bit. And store the value of the "name" into a variable. Kind of like how it is done with the Rival's name input. But instead of having "Rival's Name?" put something like "Gift Code?" or something I don't know.

darkerarceus
December 31st, 2009, 02:34 AM
Still about your inputting ideas couldn't you TELL someone the code?
Server Based could be good but it would take a good amount of scripting to do.

Wichu
December 31st, 2009, 03:21 AM
Yeah, that'd be better. Though, I was thinking a different way before seeing this:
The player gets a secret code from the games site, which they can then enter into a certain computer. (of course, this code would be something totally unpredictable, like fhyd80292 or watev, lol) By doing this the player can pick up a certain item from a little map I created called the Delivery Office.
They would then activate it, by using it in a certain area, or using the item in it's own specialty(like the flutes playing) to start an event.


..but, I totally suck at scripting such items. :/ And I don't know anything about inputting text. |o
That way, you'd still have to store the codes in an event in-game (you have to use a conditional branch somewhere); it would be easy to find them and cheat.
Still about your inputting ideas couldn't you TELL someone the code?
Server Based could be good but it would take a good amount of scripting to do.
Come on, it's not that hard to search through the scripts. In the Essentials intro event, there's a pbTrainerName script call which opens the text entry screen. Searching for 'pbTrainerName' in the scripts, and then seeing what methods are called within it, gets you this script:
trname=pbEnterText("Your name?",0,7)
This is obviously the text entry method. It appears to return the entered text, which here is assigned to the trname variable. Now you need to know what the arguments mean. Searching for 'def pbEnterText' gets you this:
def pbEnterText(helptext,minlength,maxlength,initialText="")
So, the first argument is the help text (could be "Enter the password."), the second is the minimum length (for example, if the password is 8 letters long, it would be 8), the third is the maximum length (same as before), and the last is the starting text (this should probably be left blank).
RMXP's variables are stored in the $game_variables array. So to store the password in, say, variable 100, you'd use:
$game_variables[100]=pbEnterText(_INTL("Enter the password"),8,8)
Then, you could use a conditional branch to check the password. However, doing it through events is convoluted; a script for this would be better. For example:
def getPassword
password=pbEnterText(_INTL("Enter the password"),8,8
case password
when "khdsggad"
Kernel.pbMessage(_INTL("Correct password!"))
Kernel.pbReceiveItem(PBItems::MEMBERSPASS)
when "adhosdgf"
Kernel.pbMessage(_INTL("Correct password!"))
Kernel.pbReceiveItem(PBItems::OAKSLETTER)
else
Kernel.pbMessage(_INTL("Incorrect password..."))
end
end

Server-based isn't difficult with Essentials' features; for example, the pbDownloadToString method is perfect for this. Using regular expression matching, you can even post the code directly in a thread.

darkerarceus
December 31st, 2009, 03:25 AM
I get your point but the problem is that you can easily tell someone else the password.

Wichu
December 31st, 2009, 03:31 AM
Isn't the point of Mystery Gift that it allows events to be made public?
A server-based system would be better anyway, as a password system can be easily abused...

darkerarceus
December 31st, 2009, 03:34 AM
Yup besides I think you would need it as events can expire...

Nyu~♥!
December 31st, 2009, 01:56 PM
I get your point but the problem is that you can easily tell someone else the password.

Isn't the point of Mystery Gift that it allows events to be made public?
A server-based system would be better anyway, as a password system can be easily abused...

erm.. yea..
but anyway, Wichu has a great point that totally kills my idea. D:
So.. does anyone know anything about a server based system? :/

That way, you'd still have to store the codes in an event in-game (you have to use a conditional branch somewhere); it would be easy to find them and cheat.

Come on, it's not that hard to search through the scripts. In the Essentials intro event, there's a pbTrainerName script call which opens the text entry screen. Searching for 'pbTrainerName' in the scripts, and then seeing what methods are called within it, gets you this script:
trname=pbEnterText("Your name?",0,7)This is obviously the text entry method. It appears to return the entered text, which here is assigned to the trname variable. Now you need to know what the arguments mean. Searching for 'def pbEnterText' gets you this:
def pbEnterText(helptext,minlength,maxlength,initialText="")So, the first argument is the help text (could be "Enter the password."), the second is the minimum length (for example, if the password is 8 letters long, it would be 8), the third is the maximum length (same as before), and the last is the starting text (this should probably be left blank).
RMXP's variables are stored in the $game_variables array. So to store the password in, say, variable 100, you'd use:
$game_variables[100]=pbEnterText(_INTL("Enter the password"),8,8)Then, you could use a conditional branch to check the password. However, doing it through events is convoluted; a script for this would be better. For example:
def getPassword
password=pbEnterText(_INTL("Enter the password"),8,8
case password
when "khdsggad"
Kernel.pbMessage(_INTL("Correct password!"))
Kernel.pbReceiveItem(PBItems::MEMBERSPASS)
when "adhosdgf"
Kernel.pbMessage(_INTL("Correct password!"))
Kernel.pbReceiveItem(PBItems::OAKSLETTER)
else
Kernel.pbMessage(_INTL("Incorrect password..."))
end
endServer-based isn't difficult with Essentials' features; for example, the pbDownloadToString method is perfect for this. Using regular expression matching, you can even post the code directly in a thread.

great script ideas right there. I'll need to try it until i figure out the server method.

|Maximus|
December 31st, 2009, 10:29 PM
Um...hehe...didn't I say, basic mystery gift lol?

Nyu~♥!
January 1st, 2010, 05:33 PM
basic is always to be improved on.. can't we share our ideas? :/

Gigatom~
January 30th, 2010, 11:31 AM
Nice, I'm using it.
Now i'm making a mystery gift with Giratina ;)
Thank you for this.

Gigatom~

|Maximus|
January 30th, 2010, 02:11 PM
Nice, I'm using it.
Now i'm making a mystery gift with Giratina ;)
Thank you for this.

Gigatom~

Ooh. That's nice!

No problem!

PokemonManiac1
January 6th, 2011, 02:31 AM
Please have you got a mystery gift that goes online and stores data from the pokemon?

Because if i release my pokemon game how it's going to has diferrent mystery gift without to update my game?