The PokéCommunity Forums  

Go Back   The PokéCommunity Forums > Creative Discussions > Game Development > Scripts & Tutorials
Sign Up Rules/FAQ Live Battle Blogs Mark Forums Read

Notices

Scripts & Tutorials This forum is for scripts and code, as well as all kinds of tutorials, software, tools and so forth. Remember to give credit!
The thread revival limit does not apply here.


Reply
Click here to go to the first staff post in this thread.  
Thread Tools
  #1    
Old March 4th, 2012, 06:39 AM
FlipelyFlip
Arr teh Pirate
 
Join Date: Feb 2012
Location: Bregenz
Age: 23
Gender: Male
Nature: Relaxed
Send a message via ICQ to FlipelyFlip Send a message via Windows Live Messenger to FlipelyFlip Send a message via Skype™ to FlipelyFlip
PasswordGift v1.0
by FlipelyFlip


heyey,
I know there are some scripts out there doing the same like mine, but with mine you have a lot more power! You can set Items and Pokemons as gifts. It's easy used and you don't need a lot of scripting knowledge to use this snippet.

What does this Snippet do?
this little snippet allows you to create a Password Gift part.
You enter a password and if the password is correct, you will
gain a pre-defined item.

How to use it?
To call the script you have only use the call-script event code
and enter this:

Scene_PasswordGift.new(minlength, maxlength)

minlength = minimum of letters or symbols to enter (by default it's 1)
maxlength = maximum of letters or symbols to enter (by default it's 8)

How to setup?
To setup a password, it's important that you know, that you have to
put a PBItems:: before the item name or a PBSpecies:: before a pokemon name!
All items and Pokemons you will find in your PBS folder.

How to setup a Item-Password:

"password" => [PBItems::Item_Name, Switch_ID, pokemon=false]

"password" = "Password" which you have to choose. Don't forget this friends: ""
PBItems::Item_Name = Sets the Item
Switch_ID = Switch ID if you want. to set this password to nil for endless use.
pokemon=false = Items are no pokemons, so this is set to false. It's very important that this is set to false for items (Causes Errors)

How to setup a Pokemon-Password:


"password" => [PBSpecies:okemon_Name, Switch_ID, pokemon=true, Level]
"password" = "Password" which you have to choose. Don't forget this friends: ""
PBSpecies:okemon_Name = Sets the Pokemon
Switch_ID = Switch ID if you want. to set this password to nil for endless use.
pokemon=true = defines if it's a pokemon or not. So you're setting up a pokemon, this has to be true!
Level = Level of the pokemon when gained!

The Script itself
Spoiler:
Code:
=begin
                              PasswordGift v1.0
                               by FlipelyFlip

heyey,
this little snippet allows you to create a Password Gift part.
You enter a password and if the password is correct, you will
gain a pre-defined item.

To call the script you have only use the call-script event code
and enter this:

Scene_Gift.new(minlength, maxlength)

minlength = minimum of letters or symbols to enter (default 1)
maxlength = maximum of letters or symbols to enter (default 8)

To setup a password, it's important that you know, that you have to
put a PBItems:: before the item name or a PBSpecies:: before a pokemon name!
All items and Pokemons you will find in your PBS folder.

that's all you have to know in this snippet (:
=end

#=============================================================================
# Password Module
#-----------------------------------------------------------------------------
# Here you can define the Items you will gain for the different passwords
#=============================================================================
module Password
  # this is the hash to define
  Gifts = { # <-- do not remove!!
  # "password" => [PBItems::Item_Name, Switch_ID, pokemon=false]
  # "password" => [PBSpecies::Pokemon_Name, Switch_ID, pokemon=true, Level]
  "PASSWORD" => [PBItems::POTION, 198, false],
  # important!! if you add more passwords don't
  # forget the Komma until you reacht the last line
  "FUEL" => [PBItems::ETHER, 199, false, nil],
  "CLONE" => [PBSpecies::MEW, 200, true, 5]
  } # <-- do not remove!!
end  
#============================================================================#
#                   !!EDIT ONLY IF YOU KNOW WHAT YOU DO!!                    #
#============================================================================#

#=============================================================================
# Scene_PasswordGift
#-----------------------------------------------------------------------------
# The core of the whole script
# minlength = minimum of letters or symbols to enter
# maxlength = maximum of letters or symbols to enter
#=============================================================================
class Scene_PasswordGift
  #---------------------------------------------------------------------------
  # initialize
  #---------------------------------------------------------------------------
  def initialize(minlength = 1, maxlength = 8)
    enterPassword(minlength, maxlength)
  end
  
  #---------------------------------------------------------------------------
  # getPassword
  #---------------------------------------------------------------------------
  def enterPassword(minlength, maxlength)
    password = pbEnterText(_INTL("Enter the password"),minlength,maxlength)
    if password.scan(/\r/) == ["\r"]
      slicing = password.size - 1
      password.slice!(slicing)
    end
    if Password::Gifts.include?(password)
      if $game_switches[Password::Gifts[password][1]] == true
        Kernel.pbMessage(_INTL("Password already used"))
      else
        Kernel.pbMessage(_INTL("Correct password!"))
        if Password::Gifts[password][2] == true
          Kernel.pbAddPokemon(Password::Gifts[password][0], Password::Gifts[password][3])
        else
          Kernel.pbReceiveItem(Password::Gifts[password][0])
        end
        if Password::Gifts[password][1] != nil
          $game_switches[Password::Gifts[password][1]] = true
        end
      end
    else
      Kernel.pbMessage(_INTL("Incorrect password."))
    end
  end
end


Planed Features:
  • amount of use. Means: You can use the password for the potion 3 times but the password for a Mew only once.
  • if you have some ideas just say (:
that's all you have to know in this snippet (:
I hope you like it"

~Flip

Last edited by FlipelyFlip; March 5th, 2012 at 12:12 PM.
Reply With Quote
  #2    
Old March 4th, 2012, 07:30 AM
Ho-oh 112's Avatar
Ho-oh 112
Advance Scripter
 
Join Date: Feb 2011
Age: 18
Gender: Male
Nature: Hasty
Well, this is great as a starter but, for some better scripts you should atleast let people "compile" items/pokemon/eggs without needing pre-defined passwords(a password generator)
__________________
Scripting Level: Advance

RMXP Poke-Essentials MySQL Trading System Link:
http://www.pokecommunity.com/showthr...62#post7077162

RMXP Poke-Essentials Mystery Gift Link:
http://www.pokecommunity.com/showthread.php?t=270687

RMXP Poke-Essentials Award System Link:
http://www.pokecommunity.com/showthread.php?p=7111566
Reply With Quote
  #3    
Old March 4th, 2012, 07:44 AM
P-Sign's Avatar
P-Sign
Pokémon Nova Luna Lead Dev.
 
Join Date: Jun 2011
Location: The Netherlands
Age: 17
Gender: Male
Seems like a great script to me, I have yet to test it but this definitely looks promising. Really like the idea of passwords by the way. I do have a suggestion, how about adding Online support? I'd like to be able to add gifts after my game has been released.
__________________

Reply With Quote
  #4    
Old March 4th, 2012, 07:55 AM
Link's Avatar
Link
Rupee Moderator
 
Join Date: Apr 2009
This is pretty awesome to be frank. I would like to see online support a bit later, this would be really useful for events and so on. Good work!
__________________
Reply With Quote
  #5    
Old March 4th, 2012, 08:23 AM
help-14's Avatar
help-14
Trainer
 
Join Date: Jul 2007
Location: Viet Nam
Age: 21
Gender: Male
Nature: Adamant
Send a message via Windows Live Messenger to help-14
Quote:
Originally Posted by Ho-oh 112 View Post
Well, this is great as a starter but, for some better scripts you should atleast let people "compile" items/pokemon/eggs without needing pre-defined passwords(a password generator)
That's a really good idea and i think it is possible. First you need a key so no one will able to fake it:
Code:
$SecretKey = "some crazy text"
Encrypt method will be something like this:
Code:
def Encrypt(pokemon,switch)
   return  Zlib::Inflate.inflate(Zlib::Inflate.inflate(pokemon+"|"+switch)+$SecretKey)
end
And Decrypt mothod
Code:
def Decrypt(pass)
  arg = (Zlib::Deflate.deflate(Zlib::Deflate.deflate(pass).gsub($SecretKey, ""))).split("|")
  @pokemon = arg[0]
  @switch = arg[1]
  #Do something
end
__________________
My Deviantart: help-14.deviantart.com
Reply With Quote
  #6    
Old March 4th, 2012, 08:25 AM
Ho-oh 112's Avatar
Ho-oh 112
Advance Scripter
 
Join Date: Feb 2011
Age: 18
Gender: Male
Nature: Hasty
Quote:
Originally Posted by help-14 View Post
That's a really good idea and i think it is possible. First you need a key so no one will able to fake it:
Code:
$SecretKey = "some crazy text"
Encrypt method will be something like this:
Code:
def Encrypt(pokemon,switch)
   return  Zlib::Inflate.inflate(Zlib::Inflate.inflate(pokemon+"|"+switch)+$SecretKey)
end
And Decrypt mothod
Code:
def Decrypt(pass)
  arg = (Zlib::Deflate.deflate(Zlib::Deflate.deflate(pass).gsub($SecretKey, ""))).split("|")
  @pokemon = arg[0]
  @switch = arg[1]
  #Do something
end
yeah I knew that, but I was giving him a challenge of finding a method to do so....
(another method is the .pack/.unpack function)
__________________
Scripting Level: Advance

RMXP Poke-Essentials MySQL Trading System Link:
http://www.pokecommunity.com/showthr...62#post7077162

RMXP Poke-Essentials Mystery Gift Link:
http://www.pokecommunity.com/showthread.php?t=270687

RMXP Poke-Essentials Award System Link:
http://www.pokecommunity.com/showthread.php?p=7111566
Reply With Quote
  #7    
Old March 4th, 2012, 08:33 AM
help-14's Avatar
help-14
Trainer
 
Join Date: Jul 2007
Location: Viet Nam
Age: 21
Gender: Male
Nature: Adamant
Send a message via Windows Live Messenger to help-14
Quote:
Originally Posted by Ho-oh 112 View Post
yeah I knew that, but I was giving him a challenge of finding a method to do so....
(another method is the .pack/.unpack function)
Oh i don't know that method, silly me :
__________________
My Deviantart: help-14.deviantart.com
Reply With Quote
  #8    
Old March 4th, 2012, 09:04 AM
Awkward Squirtle
,@,e .ºoO
 
Join Date: Jul 2011
Gender: Male
FlipelyFlip: Nice script. Tip: you can use the chomp method to remove possible whitespace from the end of a string (instead of your current slice shenanigans). I like the way you've set up the switches - you could make a set of mutually exclusive passwords by giving them the same switch ID (such as a choice between Bulbasaur, Charmander and Squirtle)!

help-14: Deflate isn't an encryption algorithm, it's a data compression algorithm. Adding a 'secret key' on the end won't make it secure. You're not even checking the secret key after decompression - I can just make a message with an empty 'secret key' and your code will decrypt it as normal (try it). And even if you do check the secret key, I can find the game's actual secret key by decompressing the code and taking the bit off the end - then, I can fake a message and append the key before compressing, and the game will be none the wiser. Pack/unpack similarly doesn't do any encryption - it just converts an array into a string and vice-versa using a predefined format.

As an easier alternative, try the Marshal module - it provides data serialisation, meaning you can pack an actual Pokémon's data into a string with a single line of code. The default implementation is pretty inefficient, but I think there's a method you can override if you want to pack the data into a shorter string.

Pokémon Raptor uses deflate and a conversion to base-64 in its system - it's not encrypted in any way whatsoever. It's easy to fake a Mystery Gift/team code. But the Mystery Gift code there is loaded from a URL defined in the scripts, so you'd have to modify and redistribute the scripts file to change the loaded gift (as I did). And team codes don't really do anything in-game, so faking them doesn't really matter.

You should still have some sort of validation to prevent game crashes from malformed codes - for example, this guy's code is invalid, but the game handles it gracefully (when constructing the team's Pokémon, an invalid species exception is thrown; the script catches it, and displays a message to the screen saying so). FlipelyFlip's code doesn't really need this (as long as the game creator doesn't mess up); however, any code which constructs Pokémon from a user-supplied string should have this sort of error handling. You could also include a checksum, to spot any errors that could have been made when copying the code (rather than immediately trying to load an invalid code).
Reply With Quote
  #9    
Old March 4th, 2012, 09:15 AM
Ho-oh 112's Avatar
Ho-oh 112
Advance Scripter
 
Join Date: Feb 2011
Age: 18
Gender: Male
Nature: Hasty
Quote:
Originally Posted by help-14 View Post
Oh i don't know that method, silly me :
It's simple:
For compiler:
Code:
packcode = "*^%VVVC0283204cccCCv" # something random like that
pokemon = 493
level = 100
switch = [5, true]
ary=[pokemon,level,switch]
ary.pack(packcode)
for decompiler

Code:
packcode = "*^%VVVC0283204cccCCv" # something random like that
ary=code.unpack(packcode)
pbAddPokemon(ary[0], ary[1])
$game_switches[ary[2]] = ary[3]
 
rescue
Kernel.pbMessage(_INTL("Your gift file is corrupted..."))
now you just need the input code method for it...
__________________
Scripting Level: Advance

RMXP Poke-Essentials MySQL Trading System Link:
http://www.pokecommunity.com/showthr...62#post7077162

RMXP Poke-Essentials Mystery Gift Link:
http://www.pokecommunity.com/showthread.php?t=270687

RMXP Poke-Essentials Award System Link:
http://www.pokecommunity.com/showthread.php?p=7111566
Reply With Quote
  #10    
Old March 4th, 2012, 01:28 PM
FlipelyFlip
Arr teh Pirate
 
Join Date: Feb 2012
Location: Bregenz
Age: 23
Gender: Male
Nature: Relaxed
Send a message via ICQ to FlipelyFlip Send a message via Windows Live Messenger to FlipelyFlip Send a message via Skype™ to FlipelyFlip
@Awkward Squirrle:
The switch-thingy is still in
I'm just checking if the defined switch is true or not. If a password sets the switch to true, it'll be for all other passwords which uses this switch to true (:
And about the chomp, I've only worked with the included standard stuff from rgss. I haven't seen all new methods and functions for arrays and hashes. So I fought it would be better for me at first to work with standard than with the included stuff. But don't worry, I'm still testing and working to get all new stuff (:

@Ho-oh 112:
you mean to setup it in an event without a pre-defined password? I can put it in, it's not really a problem.

@all other who requested an online-function:
I have to say it would go over my actual scripting knowledge. I will add it, but it will take time until I know how the online function works ._.

~flipy

(btw: please call me flip or flipy, easier to write and it's a shorter form)

EDIT:

For a password not defined in the hash, you can also use this one:

Spoiler:
Code:
#=============================================================================
# Module Password
#-----------------------------------------------------------------------------
# password = "password"
# minlength = minimum of letters or symbols to enter
# maxlength = maximum of letters or symbols to enter
#=============================================================================
module Password
  def self.enter(password, minlength, maxlength)
    pass = pbEnterText(_INTL("Enter the password"),minlength,maxlength)
    if pass.scan(/\r/) == ["\r"]
      slicing = pass.size - 1
      pass.slice!(slicing)
    end
    if pass == password
      Kernel.pbMessage(_INTL("Correct password!"))
      return true
    else
      Kernel.pbMessage(_INTL("Incorrect password."))
      return false
    end
  end
end


to use it, just use the conditional branch script and type in: Password.enter("password", minlength, maxlength).
"password" = password used
minlength = minimum amount of characters
maxlength = maximum amount of characters

and thats it (:

~flipy

Last edited by FlipelyFlip; March 4th, 2012 at 02:27 PM.
Reply With Quote
  #11    
Old March 5th, 2012, 07:01 AM
Ho-oh 112's Avatar
Ho-oh 112
Advance Scripter
 
Join Date: Feb 2011
Age: 18
Gender: Male
Nature: Hasty
Quote:
Originally Posted by FlipelyFlip View Post
@Ho-oh 112:
you mean to setup it in an event without a pre-defined password? I can put it in, it's not really a problem.

No I meant like my mystery gift system you can generate your gifts instead of adding them in pre-game and using them before hand.
__________________
Scripting Level: Advance

RMXP Poke-Essentials MySQL Trading System Link:
http://www.pokecommunity.com/showthr...62#post7077162

RMXP Poke-Essentials Mystery Gift Link:
http://www.pokecommunity.com/showthread.php?t=270687

RMXP Poke-Essentials Award System Link:
http://www.pokecommunity.com/showthread.php?p=7111566
Reply With Quote
  #12    
Old March 5th, 2012, 08:30 AM
FlipelyFlip
Arr teh Pirate
 
Join Date: Feb 2012
Location: Bregenz
Age: 23
Gender: Male
Nature: Relaxed
Send a message via ICQ to FlipelyFlip Send a message via Windows Live Messenger to FlipelyFlip Send a message via Skype™ to FlipelyFlip
okay I'll see what I can do (:
but I think it's not very difficult (:
Reply With Quote
  #13    
Old March 5th, 2012, 08:36 AM
Ho-oh 112's Avatar
Ho-oh 112
Advance Scripter
 
Join Date: Feb 2011
Age: 18
Gender: Male
Nature: Hasty
Quote:
Originally Posted by FlipelyFlip View Post
okay I'll see what I can do (:
but I think it's not very difficult (:

No it's not difficult, if you have any trouble I can help.
__________________
Scripting Level: Advance

RMXP Poke-Essentials MySQL Trading System Link:
http://www.pokecommunity.com/showthr...62#post7077162

RMXP Poke-Essentials Mystery Gift Link:
http://www.pokecommunity.com/showthread.php?t=270687

RMXP Poke-Essentials Award System Link:
http://www.pokecommunity.com/showthread.php?p=7111566
Reply With Quote
Reply
Quick Reply

Sponsored Links


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Minimum Characters Per Post: 25



All times are UTC -8. The time now is 11:29 PM.


Style by Nymphadora, artwork by Sa-Dui.
Like our Facebook Page Follow us on Twitter © 2002 - 2014 The PokéCommunity™, pokecommunity.com.
Pokémon characters and images belong to The Pokémon Company International and Nintendo. This website is in no way affiliated with or endorsed by Nintendo, Creatures, GAMEFREAK, The Pokémon Company or The Pokémon Company International. We just love Pokémon.
All forum styles, their images (unless noted otherwise) and site designs are © 2002 - 2014 The PokéCommunity / PokéCommunity.com.
PokéCommunity™ is a trademark of The PokéCommunity. All rights reserved. Sponsor advertisements do not imply our endorsement of that product or service. User generated content remains the property of its creator.