Introduction
Welcome to the API documentation for the scripting engine of Pokémon Revolution Online.
You will find simple code examples for most functions in the area to the right.
Writing Python scripts
Decent autocompletion is available by using this stub file.
You can go about doing that by either just putting the file into your global Python library path (default %localAppData%\Programs\Python\Python310\Lib\site-packages
) or by using a virtualenv.
alternatively, you can just put the file into your project folder and import it through a relative import like this from .PRO_API import *
;
You won't be able to execute these Python scripts on your computer.
To test your scripts you will have to deploy the script to a map server.
You can find more details about this process in the Deploying Python scripts section below.
The most important difference between Python to other languages, which a lot of beginners stumble over, is Python's reliance on correct indentation.
A tab is treated as the same as space which can lead to code that looks like it's indented correctly but because a tab is typically displayed as being wider than a space Python won't be able to parse it.
To forestall a lot of headaches around this I strongly recommend using JetBrains PyCharm Community which will take care of the whole indentation mess for you as well as provide other helpful hints and suggestions.
def main():
# your python script
return
main()
Python scripts in PRO are executed inside an invisible function that enables you to use return
to exit scripts outside of functions.
These returns will get highlighted as errors by any decent IDE so if you want to rely on your IDE you can put your code into a dummy function just so returns get highlighted correctly as you can see in the example to the right.
If PyCharm doesn't suit you for whatever reason you can configure Notepad++ to handle spaces and tabs correctly by configuring it to automatically use spaces instead of tabs. I don't mind you using another IDE/Text-Editor of course. These suggestions are just intended as pointers to get you started. You don't even need to install Python if you only want to rely on static syntax highlighting.
PRO Scripts don't have access to the full range of Python's functionality and standard library. The version of Python that will run your script on the server uses complex AST transformations to effectively sandbox the Python runtime by disabling all language and library features that could be used to gain unauthorized access to parts of the server runtime or file system.
The current policy is better safe than sorry, so if there is a particular standard library function you want to use that isn't available then just ask and we can discuss if it is possible to enable it.
The Python API features themselves are always available in the global namespace of any script even without any imports.
Deploying Python scripts
Python scripts are detected via Shebang which means you have to add #!python
as the first line of your script for the server to recognize it as Python.
This is because older scripts were written in a horrible custom scripting language called xanascript which will otherwise be used by default.
To deploy a script you have to paste it into the Script text field of an NPC inside the PRO Editor and it will be executed as soon as a player interacts with the NPC.
The syntax highlighting of the text field inside the PRO Editor is very rudimentary and incomplete. So don't be alarmed if things might look a bit weird or are highlighted a bit wrong. If the code is correct it should just work anyway.
Don't forget to remove the stub-file import before deploying your script.
Authentication
Pokemon Revolution Online requires the PRO Editor access and deploy scripts. You are not allowed to share this PRO Editor.
Your login data are different from your in-game credentials. Only Administrators are able to create an account for you.
API Reference
user
user.say
user.say(f"Congratulation, you are the Kanto champion now, {user.username}.")
user.say(f"You have {user.coins} coins.")
def user.say(message)
Displays a text message.
user.teleport
Teleports the user to a selected map and coordinates (x, y).
user.teleport("Pokecenter Vermilion", 15, 17)
Parameters
Parameter | Type | Description |
---|---|---|
map | string | Target map name |
x | int | x coordinate |
y | int | y coordinate |
no_cache | bool | If True this forces the client to reload the map. Among other things, this will reset npc positions as if you freshly entered the map. |
Return value
Type | Description |
---|---|
bool | returns True if the teleport was successful |
user.battle
#Example 1:
user.battle(npc, no_exp=True)
#Example 2:
npc.team = [Pokemon("Clefable", 100), Pokemon("Starmie", 100), Pokemon("Dragonite", 100)]
user.battle(npc)
#Example 3:
user.battle(Pokemon("Venusaur", 57))
#Example 4:
for n in ["Starmie", "Lanturn", "Venusaur"]:
p = Pokemon(n, 100)
p.skills = ("Scald", "Thunderbolt", "Flamethrower", "Ice Beam")
npc.team.append(p)
user.battle(npc)
Starts a battle. If you don't pass a custom team the team defined in the Editor will be used.
Parameters for TrainerBattle
Parameter | Type | Description |
---|---|---|
npc | NPC | NPC you want to start a battle with |
no_exp | bool | this battle doesn't give exp if true |
no_teleport | bool | doesn't teleport you to pokecenter if you lose |
no_items | bool | user can't use items in battles if true |
Parameters for WildBattle
Parameter | Type | Description |
---|---|---|
Pokemon | pokemon | the pokemon you want to start a wildbattle with |
Returns
BattleResult enum
Int | Meaning |
---|---|
-1 | Battle ended unexpectedly (disconnect) |
0 | This player lost |
1 | This player won |
user.say_system
user.say_system("You cannot steal an item from this NPC!")
Sends a system message to the current user.
user.play_music
user.say("Damn, you are pretty strong, I had no chance at all!")
user.play_music(1)
Plays a music file for the current user.
Parameters
Type | Description |
---|---|
int | music file id |
user.play_sound
user.say("Welcome to Vermilion City Pokemon Center.")
choice = user.select("Would you like to me to heal your Pokemon?", ["Yes.", "Nope."])
if choice[0] == 0:
user.play_sound(0)
user.team.heal()
user.pause()
npc.emote(16)
user.say("There you go, take care of them!")
else:
user.say("Ok, have a nice day!")
Plays a sound file for the current user.
Parameters
Type | Description |
---|---|
int | sound file id |
user.play_cry
user.say("Oh, a wild Cherim is running around Viridian Forest!")
user.play_cry(421)
user.say("Cherrim!")
Plays a cry sound file for the current user.
Parameters
Type | Description |
---|---|
int | pokedex id |
user.move
Move the user but prevent him from going stuck against the NPC he talked to.
path = "UUU"
if npc.pos.y < user.pos.y:
path = "R" + path
user.move(path, True)
Forces the user walk a number of script defined steps automatically.
If wait is True
no other scripts will be triggered while walking the path. (Because there can only be one script executed at a time for any given user.)
If wait is False
dialogue from scripts triggered walking a path will be shown after the user finishes the path.
Currently walking past a los NPC with wait = False
will cause weird behaviour as the los npc starts to following the user trying to talk to him.
In the event a user disconnects while walking a path the server will try to simulate the user walking the path so the user will end up where he was supposed to walk. The path walk simulation does not incorporate interactions with los NPCs or TileScripts.
The user will pass through any NPCs that are following a path of their own while following the steps.
Parameters
Type | Description |
---|---|
string | The path to walk (U=Up, D=Down, L=Left, R=Right) |
bool | Wait for the user to finish the path before executing the rest of the script. |
return Union[None, bool]
None
if the user disconnects in the process, True
otherwise.
user.shop
items = {
'Air Balloon': 1,
'Akatsuki Robe': 250,
'Aqua Diva Dress': 200,
'Blue Punk Jacket': 200,
'Dragon Scale': 10
}
user.shop(Currency.PvECoins, items)
Opens a shop for the selected user.
enum Values
str | Values |
---|---|
Dollars | Pokedollars |
PvECoins | PvECoins |
PvPCoins | PvPCoins |
Parameters
Type | Description |
---|---|
currency | payment method of the shop |
dict | dict with item as key and price as value |
user.pause
user.say("Did you watch Harry Potter?")
# We pause here so it doesn't execute the battle before you have finished reading the dialogue
user.pause()
user.battle(npc)
if user.battle == 1:
user.say("Yep I watched it too.")
user.say("I got my magic inspiration from that movie...")
user.say("Now I gonna try one of my magic!")
user.say("Sim Salabim!")
user.pause()
user.teleport("Green Path Cave B2F", 56, 26)
else:
user.say("Seems like you didn't watch Harry Poter.")
Sends queued user.says and waits for user input before continuing the dialogue.
return Union[None, bool]
None
if the user disconnects, True
otherwise.
user.select
choice = user.select("Would you like me to heal your Pokemon?" , ["Yes, please.", "No, thanks."])
if choice[0] == 0:
user.team.heal()
user.say("There you go, take care of them!")
else:
user.say("Ok, have a nice day!")
The user has the option to select between different options in a NPC dialogue.
Parameters
Type | Description |
---|---|
string | question |
list | choices |
Return Tuple[int, str]
Type | Description |
---|---|
int | selected choice as index int, starts with 0 |
string | selected choice as string |
user.select_pokemon
poke = user.select_pokemon("From which Pokemon would you like me to check the Hidden Power?")
user.say("Your {} has Hidden Power type of {}.".format(poke.name, poke.hidden_power))
The user has to select a Pokemon that's currently in its team.
Parameters
Type | Description |
---|---|
string | question |
Returns
Type | Description |
---|---|
Pokemon | selected pokemon |
user.lockmove
All users are immediately locked on triggering a script and automatically get locked and unlocked as necessary.
user.faint
if user.battle(npc, no_teleport=True) < 1:
user.say("Let me tell you something before you black out...")
user.say("You lost!")
user.pause()
user.faint()
Moves the player to his last PC and heals his team.
user.send_pokemon_preview
legendary = Pokemon(poke.name, poke.level)
legendary.ivs = tuple([random.randint(1, 31) for i in range(6)])
user.send_pokemon_preview(legendary)
if user.select("I rolled your Pokemon's IVs, do you accept them?", ["Yes.", "No."])[0] == 0:
poke.ivs = legendary.ivs
Sends a Pokemon preview chart of a Pokemon
Parameters
Type | Description |
---|---|
Pokemon | The Pokemon whose preview should be shown. |
user properties
user.id
user.say("Your user id is: {0}".format(user.id))
Returns a unique UserID as integer.
user.username
user.say("Congratulation, you are the Kanto champion now, " + user.username + ".")
user.say("Hello {0}, you don't look well today!".format(user))
Returns the username as string.
User as string returns the username as well.
user.gender
pr_1, pr_2, pr_3 = ("he", "his", "him") if user.gender == Gender.Male else ("she", "her", "her")
user.say("Oh hello! I was told about a fascinating trainer! {} was on {} way to me, "
"so I could congratulate {} for beating the E4.".format(pr_1.title(), pr_2, pr_3))
user.say("I guess, you are this trainer! Congratulations!")
Returns the user's gender as Gender.
enum Gender
Int | Gender |
---|---|
63 | Neutral |
70 | Female |
77 | Male |
user.position, user.pos
#Example 1:
user.say("{} {}, {}".format(user.position[0], user.position[1], user.position[2]))
#Example 2:
user.say("{} {}, {}".format(user.position.map, user.position.x, user.position.y))
Returns the current position of the user as tuple of ints.
Return values (namedtuple)
Attribute | Type | Description |
---|---|---|
map | string | map name |
x | int | x coordinate |
y | int | y coordinate |
user.region
user.say(f"Your current region name: {user.region}")
user.say(f"Your current region id: {int(user.region)}")
Returns the current region as Enum.
enum Region
int | Region |
---|---|
0 | None |
1 | Kanto |
2 | Johto |
3 | Hoenn |
4 | Sinnoh |
5 | Unova |
6 | Kalos |
7 | Galar |
user.security
if user.security[0] > 0:
user.say("{0} are my favorite staff members!".format(user.security[1]))
else:
user.say("Go away!")
Returns the in-game rank as string and the rank id as int.
Return values
Type | Description |
---|---|
int | returns the rank id as int. |
string | returns the rank as string. |
user.money
reward = random.randint(300, 600)
user.money = user.money + reward
user.say("You found {} pokedollar.".format(reward))
user.say("You have {:0,} pokedollar.".format(user.money))
Returns your money as int, changes will be saved directly in the database.
Type | Description |
---|---|
int | returns your current money. |
user.coins
user.coins = user.coins - 100
user.items["Arcanine Mount"] = user.items["Arcanine Mount"] + 1
user.say("You received an Arcanine Mount")
Returns your coins as int, changes will be saved directly in the database.
Type | Description |
---|---|
int | returns your current coins. |
user.playtime
if user.playtime.total_seconds() / 3600 >= 100:
user.say("Nice to meet you.")
else:
user.say("You need at least 100h to talk with me.")
user.say("Your current playtime: {}.".format(user.playtime))
Returns the current playtime as timedelta object.
Type | Description |
---|---|
timedelta | returns your current playtime. |
user.guild
if user.guild.name in ["Blaze", "Chaos", "Unity", "TheBraveBirds"]:
user.say("You joined an awesome guild!")
else:
user.select("Do you want to join TheBraveBirds?", ["Yes", "No"])
Returns the GuildID as int, GuildName as string and GuildRank as int.
GuildRanks
Int | Rank |
---|---|
0 | Initiate |
1 | Member |
2 | Officer |
3 | Leader |
Return values (namedtuple)
Attribute | Type | Description |
---|---|---|
id | int | unique guild id |
name | string | guild name |
rank | int | rank as int |
user.vars
#Example 1:
if user.vars.ArcExp:
user.say("You earned 10 arc exp.")
user.vars.ArcExp = user.vars.ArcExp + 10
else:
user.vars.ArcExp = 10
#Example 2:
if not user.vars.WalrosskastanieBoss:
user.battle(npc)
user.vars.set("WalrosskastanieBoss", True, timedelta(days=12))
# Will be saved even when the user disconnect while the battle
else:
user.say("I'm too exhausted for a battle.")
Permits the access to the users variables.
Type | Description |
---|---|
UserVars | gives the possibility to save persistent variables for selected user |
user.pokes
#Example 1 + 2:
user.say("You have a " + user.pokes[0].name + " on your first position.")
user.say("You have a " + user.pokes[-1].name + " on your last position in your box.")
#Example 3:
if "Mew" in user.pokes:
user.say("You already caught a Mew!")
else:
user.battle(Pokemon("Mew", 30))
#Example 4:
user.pokes.add(Pokemon("Ditto", 30))
Permits the access to the users Pokemon.
Type | Description |
---|---|
Pokes | returns a pokemon object from selected user |
user.team
#Example 1:
if "Ditto" in user.team:
user.say("Welcome to the Amigos my friend!")
else:
user.say("You are not cool enough to join us.")
#Example 2:
user.say("You have {} pokemon in your team".format(len(user.team)))
#Example 3:
if all(p.level >= 100 for p in user.team):
user.say("Okay, you are ready to fight me!")
else:
user.say("You are too weak to fight me yet.")
#Example 4:
if all(p.region == region.Kanto for p in user.team):
user.say("Okay, you are truly a Kanto Pokemon trainer!")
else:
user.say("Sorry, but you have at least one Pokemon in your team that's not from Kanto!")
Permits the access to the users Pokemon that are currently in the team.
Type | Description |
---|---|
Pokes | returns a pokemon object from selected user |
user.temp_team
# build the npc team and the user's temporary team
npc.team = [Pokemon("Bulbasaur", 5), Pokemon("Charmander", 5), Pokemon("Squirtle", 5)]
user.temp_team = [Pokemon("Snivy", 5), Pokemon("Tepig", 5), Pokemon("Oshawott", 5)]
# first battle with lent Pokemon
user.say("Try defeating me with those lent Pokemon!")
user.pause()
if user.battle(npc, no_exp=True) == 1:
user.say("Wow, you won!")
# heal the NPC's Pokemon for the next battle
for p in npc.team:
p.health = p.stats.calc_HP(p.level, p.iv_hp, p.ev_hp)
# second battle with the user's original Pokemon
user.temp_team = []
user.say("Now fight me with your real team!")
user.pause()
user.battle(npc, no_exp=True)
Allows to set a temporary team for the next battle in the script.
Type | Description |
---|---|
Pokes | the list of Pokemon objects. |
user.items
#Example 1:
if "Leftovers" in user.items:
user.say("You have " + str(user.items["Leftovers"]) + " Leftovers, Snorlax would be proud.")
else:
user.say("Too bad, you don't have Leftovers.")
#Example 2:
user.items["Arcanine Mount"] += 1
user.say("You received an Arcanine Mount!")
Permits the access to the users items.
Type | Description |
---|---|
Items | returns an item object from selected user |
user.registration_date
user.say("You joined PRO on {0}".format(user.registration_date))
span = date.today() - user.registration_date
user.say("You created your account {0} days ago ".format(span.days))
Returns the registration date as date object.
user.membership
if user.membership:
user.say("Your membership is still active.")
else:
user.say("Your membership is not active.")
Returns true if membership is active.
Return values
Type | Description |
---|---|
bool | returns true if active |
user.black_membership
if user.black_membership:
user.say("Your black membership is still active.")
else:
user.say("Your black membership is not active.")
Returns true if black membership is active.
Return values
Type | Description |
---|---|
bool | returns true if active |
user.last_pokecenter
user.say("Ahoy! All Aboard!")
user.pause()
user.teleport("Eumi Island Town", 29,30)
user.last_pokecenter = "Eumi Island Pokecenter"
Returns the last visited Pokecenter.
Parameters
Type | Description |
---|---|
string | sets the map name of last visited Pokecenter |
Return values
Type | Description |
---|---|
string | returns the map name of last visited Pokecenter |
user.dex
Gives access to the Pokedex management object.
user.in_tile_script
# assume this script is in a TileScript
# we set to False because the TS only shows an information
user.in_tile_script = False
c = user.select("There will be much stronger trainers farther ahead. Do you want to continue?",
["Yes!", "No."])[0]
if c == 0:
user.say("Good luck!")
else:
user.say("You should return.")
Gives access to the behaviour of the script
Type | Description |
---|---|
bool | if True, the script will behave like a tile script. |
Pokes
With Pokes you can get access to the Pokemon from users. Pokes can be used as an iterator.
Pokes.__iter__
user.say("Let me see if you have a strong enough Pokemon in your team or box.")
good = None
for p in user.pokes:
if p and p.ivs >= 150: # Check if p is not None and has at least 150 IVs
good = p
break
if good:
user.say("Your " + good.name + " seems to be strong enough!")
else:
user.say("Your Pokemon are too weak.")
Returns an iterator that iterates through the users team and box and returns Pokemon as Pokemon objects.
The first six elements are always the team. Empty spots in your team return NoneType!
Pokes.__getitem__
user.say("You have a " + user.pokes[0].name + " on your first position.")
user.say("You have a " + user.pokes[-1].name + " on your last position in your box.")
Works the same as in regular Python with slices and so on. It returns the Pokemon and position.
Pokes.__delitem__
del user.pokes[0]
user.say("I deleted the first Pokemon in team!")
Deletes the Pokemon from your team or box.
Pokes.__contains__
#Example 1:
if "Mew" in user.pokes:
user.say("You already caught a Mew!")
else:
user.battle(Pokemon("Mew", 30))
#Example 2:
if 7 in user.pokes: # Squirtle
user.say("Welcome to the Squirtle Squad!")
else:
user.say("You are not cool enough.")
Searches through your team and box. You can search with the Pokemon name or dex ID.
Pokes.__contains__ is case sensitivity!
Pokes.add
p = Pokemon("Greninja", 30)
p.ability = 3
p.nature = Nature.Naive
p.iv_spd, p.iv_spatk, p.iv_atk = (31, 31, 31) #Unassigned IVs will be random
p.ev_spatk, p.ev_spd, p.ev_hp = (252, 252, 6)
user.pokes.add(p)
Adds a Pokemon to the selected users last team/box position.
Parameters
Parameter | Type | Description |
---|---|---|
poke | pokemon | the pokemon that you want to be added as a pokemon object |
Pokes.heal
choice = user.select("Would you like me to heal your Pokemon?", ["Yes, please.", "No, thanks."])
if choice[0] == 0:
user.say("Okay, let me take a look at those Pokemon.")
user.play_sound(0)
user.pokes.heal()
user.pause()
npc.emote(16)
else:
user.say("See you!")
Heals all Pokemon in the users team.
Pokes.update
poke = user.select_pokmeon("Which Pokemon should be sent to the PC?")
poke.pos = -1
user.team.update()
Updates the team's visual state within a script.
Pokemon
Pokemon.__init__
p1 = Pokemon("Pikachu",30)
p2 = Pokemon(150, 30, shiny=True)
user.battle(p1)
user.team.add(p2)
Returns the Pokemon object.
Parameters
Parameter | Type | Description |
---|---|---|
Pokemon name | string | the pokemon name as string |
Pokemon ID | int | the pokemon id as integer |
level | int | the pokemon level between 1 and 120 |
shiny | bool | true if shiny |
form | int | the form as integer |
ability | int | between 1 and 3 |
ball | Item | The Pokeball that was used to catch this Pokemon |
Pokemon.id
poke = user.select_pokemon()
user.say("Your pokemon has the ID: {}".format(poke.id))
Returns the unique Pokemon ID as int.
Attention: ID is 0 if the Pokemon was not saved in the database yet.
Pokemon.name
p = user.select_pokemon("Show me your strongest pokemon!")
if p.ivs > 150:
user.say("Your {} looks so powerful.".format(p.name))
else:
user.say(p.name + " is too weak.")
Returns the Pokemon name as string.
Pokemon.dex_id
poke = user.select_pokemon()
user.say("Your pokemon has the dex id: {}".format(poke.dex_id))
Returns the Pokedex ID as int.
Pokemon.gender
# create a male Ralts for a future Gallade
poke = Pokemon("Ralts", 50)
poke.gender = Gender.Male
user.pokes.add(poke)
poke = user.select_pokemon("Whose gender should I check?")
if poke.gender == "M":
user.say("Your {} is male!".format(poke.name))
elif poke.gender == "F":
user.say("Your {} is female!".format(poke.name))
else:
user.say("Your {} has no gender!".format(poke.name))
Type | Description |
---|---|
Gender | One of the possible genders as a Gender literal |
enum Gender
Int | Gender |
---|---|
63 | Neutral |
70 | Female |
77 | Male |
Return values
Type | Description |
---|---|
string | gender symbol (one of "?", "F", "M") |
Pokemon.item
p = Pokemon("Shedninja", 100)
p.item = "Focus Sash"
npc.team = [p]
user.battle(npc)
Returns the held item of the Pokemon as string.
Returns None
if the Pokemon has no item.
Type | Description |
---|---|
string | held item |
Pokemon.pos
#Example 1:
#Deletes the Pokemon poke from your team
poke = user.select_pokemon("Select a pokemon to release from your team")
#poke.pos contains the position of the Pokemon in the team and pokes lists respectively
del user.team[poke.pos]
#Example 2:
if user.vars.TradeNPC199:
return user.say("Your Diskull and I are best friends now!")
choice = user.select("Do you have a Duskull and want to trade it for my Jynx?", ["Yes.", "No, sorry."])
if choice[0] == 1:
return user.say("Okay, maybe another time!")
poke = user.select_pokemon("Select your Duskull")
if poke.name != "Duskull":
return user.say("That's not a Duskull!")
del user.pokes[poke.pos]
user.say("Trade complete.")
user.say("I hope you have fun with your new Jynx!")
user.vars.TradeNPC199 = 1
Returns the position of the selected Pokemon.
Return values
Type | Description |
---|---|
int | position of your pokemon |
Pokemon.ability
#Example 1:
user.say("Your Pokemon has the ability {}.".format(poke.ability))
#Example 2:
p = Pokemon("Clefable", 100)
p.ability = "Magic Guard" #Ability is case insensitive
user.team.add(p)
user.say("You received a Clefable with Magic Guard.")
Returns the ability as string.
Parameters
Type | Description |
---|---|
Union[int, string] | ability name or ability ID in dex (1-3) |
Return values
Type | Description |
---|---|
string | ability name |
Pokemon.shiny
if any(p and p.shiny for p in user.pokes[:6]):
user.say("You fulfill the requirments.")
else:
user.say("Too bad. Come back to me when you caught a shiny.")
Returns true if Pokemon is shiny.
Return values
Type | Description |
---|---|
bool | returns true if shiny |
Pokemon.form
if any(p.form > 0 for p in user.team):
user.say("You fulfill the requirments.")
else:
user.say("Too bad. Come back when you caught a Pokemon with a special form in your team.")
Returns the form as int.
Pokemon.ot
poke = user.select_pokemon("Show me a pokemon you caught yourself.")
if poke.ot == user.username:
user.say("Looks good.")
else:
user.say("This Pokemon was caught by someone else!")
Returns the OT as string.
Parameters
Type | Description |
---|---|
string | sets the OT |
Return values
Type | Description |
---|---|
string | returns the OT |
Pokemon.level
if all(p.level >= 100 for p in user.team):
user.say("Okay, you are ready to fight me!")
else:
user.say("You are too weak to fight me yet.")
Returns the Pokemon level as integer.
Pokemon.happiness
poke = user.select_pokemon("Show me a Pokemon that loves and adores you.")
if poke.happiness == 255:
user.say("This Pokemon seems to be very loved by you!")
else:
user.say("It seems that your love to this Pokemon is not strong enough.")
Returns the happiness as integer.
Happiness can be between 5 and 255.
Pokemon.region
if all(p.region == region.Kanto for p in user.team):
user.say("Okay, you are truly a Kanto Pokemon trainer!")
else:
user.say("Sorry, but you have at least one Pokemon in your team that's not from Kanto!")
Returns the Region as enum.
enum Region
Int | Region |
---|---|
1 | Kanto |
2 | Johto |
3 | Hoenn |
4 | Sinnoh |
5 | Unova |
6 | Kalos |
7 | Galar |
Pokemon.skills
for n in ["Starmie", "Lanturn", "Venusaur"]:
p = Pokemon(n, 100)
p.skills = ("Scald", "Thunderbolt", "Flamethrower", "Ice Beam")
npc.team.append(p)
user.battle(npc)
Returns a tuple with the move names as strings.
Has to be a list of strings with a maximum of four.
Pokemon.skill_data
Returns a skill data object that contains more information than the Pokemon.skills.
Pokemon.nature
p = Pokemon("Snorlax", 100)
p.ivs = (31, 31, 31, 31, 31, 31)
p.evs = (252, 252, 252, 252, 252, 252)
p.nature = Nature.Careful
p.skills = ("Curse", "Rest", "Body Slam", "Thunder Punch")
npc.team = [p]
user.battle(npc)
Returns the nature as nature enum.
enum Nature
int | nature |
---|---|
1 | Hardy |
2 | Lonely |
3 | Adamant |
4 | Naughty |
5 | Brave |
6 | Bold |
7 | Docile |
8 | Impish |
9 | Lax |
10 | Relaxed |
11 | Modest |
12 | Mild |
13 | Bashful |
14 | Rash |
15 | Quiet |
16 | Calm |
17 | Gentle |
18 | Careful |
19 | Quirky |
20 | Sassy |
21 | Timid |
22 | Hasty |
23 | Jolly |
24 | Naive |
25 | Serious |
Pokemon.types
poke = user.select_pokemon("From which Pokemon would you like me to check the types?")
user.say("Your {} has the types {}.".format(poke.name, ", ".join(poke.types)))
Returns the Pokemon types as tuple with 1 or 2 elements.
enum Type
int | type |
---|---|
1 | Normal |
2 | Fighting |
3 | Flying |
4 | Poison |
5 | Ground |
6 | Rock |
7 | Bug |
8 | Ghost |
9 | Steel |
10 | Fire |
11 | Water |
12 | Grass |
13 | Electric |
14 | Psychic |
15 | Ice |
16 | Dragon |
17 | Dark |
18 | Fairy |
Pokemon.legendary
user.say("Hey, I'm able to delete your Pokemon.")
if user.select("Do you need my help?", ["Yes", "No"])[0]: # 0 behaves like false, so "Yes" is false.
return user.say("See you!") # return exited the script
selected = user.select_pokemon("Please select your Pokemon.")
if selected.legendary:
user.say("Sorry, I can't delete legendaries.")
else:
del user.pokes[selected.pos]
Returns true if the Pokemon is a legendary.
Type | Description |
---|---|
bool | returns true if the Pokemon is a legendary |
Pokemon.chat_link
p = Pokemon("Riolu", 15, form=1, ability=3)
p.nature = Nature.Adamant
user.say_system("You received {}.".format(p.chat_link))
Returns a Pokemon string that's linkable in chat.
Return values
Type | Description |
---|---|
string | linkable Pokemon string |
Pokemon.caught_date
user.say("I'm a scientist from Hoenn, from Mossdeep City Space Center to be more exact.")
user.say("With our new technology, we're now able to calculate the time of when your Pokemon was caught.")
if user.select("Do you want me to check the caught date of your Pokemon?", ["Yes","No, Thanks"])[0]: # 0 behaves like false, so "Yes" is false.
return user.say("Ok, suit yourself.")
p = user.select_pokemon("Please select which Pokemon you want me to check.")
if not p.caught_date:
return user.say("That Pokemon's data is not wholly saved yet, try relogging to force-save it, and then speak to me again!")
user.say("Your {} was caught at {}.".format(p.name, p.caught_date))
user.say("Thank you for using our service. Have a nice day!")
Returns the caught date as datetime object.
Attention: Returns None
if the Pokemon was not saved in the database yet.
For more information about datetime check out the Python docs.
Return values
Type | Description |
---|---|
datetime | date you caught the Pokemon |
Pokemon.teach
move = "Icy Wind"
money = 15000
if user.select("Would you like to learn {} for ${:0,}?".format(move, money), ["Yes", "Not now"])[0] == 1:
return user.say("Okay, come back later.")
poke = user.select_pokemon("Select your pokemon.")
if not poke.can_learn(move, tutor=True):
return user.say("{} can not learn {}.".format(poke, move))
if "Icy Wind" in poke.skills:
return user.say("Your Pokemon already knows Icy Wind.")
msg = "Are you sure you want to teach {} {} for ${:0,}?".format(poke, move, money)
if user.select(msg, ["Yes.", "On second thought, no."])[0] == 1:
return user.say("Very well, then!")
if user.money < money:
return user.say("You don't have enough money.")
user.say("{} has learned {}.".format(poke, move))
poke.teach(move)
user.money -= money
Teaches a selected move. The user decides which move to remove.
Parameters
Type | Description |
---|---|
string | move name |
Pokemon.can_learn
poke = user.select_pokemon("Select your pokemon.")
if not poke.can_learn("Icy Wind", tutor=True): #Tutor move
return user.say("{} can not learn Icy Wind from a tutor.".format(poke, move))
if not poke.can_learn("Icy Wind", level_up=True, egg_move=True, tutor=True, tm=True): #Checks all learn methods
return user.say("{} can not learn Icy Wind.".format(poke, move))
Returns if selected Pokemon is able to learn a move as bool.
You have to use the parameters to decide which teaching method to check. It's possible to combine them.
Parameters
Parameter | Type | Description |
---|---|---|
move | string | move name |
level_up | bool | sets the learn method to level up |
egg_move | bool | sets the learn method to egg |
tm | bool | sets the learn method to TM/HM |
tutor | bool | sets the learn method to tutor |
Return values
Type | Description |
---|---|
bool | returns true if the Pokemon is able to learn the move |
Pokemon.possible_moves
p = Pokemon("Pikachu", 100)
#Set four random moves
p.moves = tuple(random.sample(p.possible_moves(level_up=True, tutor=True, tm=True, egg_move=True), 4))
user.team.add(p)
Returns possible moves a selected Pokemon is able to learn as a tuple of move names as string.
Parameters
Parameter | Type | Description |
---|---|---|
level_up | bool | sets the learn method to level up |
egg_move | bool | sets the learn method to egg |
tm | bool | sets the learn method to TM/HM |
tutor | bool | sets the learn method to tutor |
Return values
Type | Description |
---|---|
Tuple[str] | returns all moves the Pokemon is able to learn |
Pokemon.staff_reward
p = Pokemon("Dialga", 100)
p.staff_reward = True
user.team.add(p)
Returns if a Pokemon is a staff reward/tradable as bool.
Type | Description |
---|---|
bool | returns true if staff reward/untradeable |
Pokemon.iv_atk
poke = user.select_pokemon("Show me a Pokemon with at least 20 ATK IVs!")
if poke.iv_atk >= 20:
user.say("Awesome! This Pokemon hits like a truck!")
else:
user.say("This Pokemon is as weak as a Metapod!")
Returns the ATK IV as int.
Pokemon.iv_def
poke = user.select_pokemon("Show me a Pokemon with at least 23 DEF IVs!")
if poke.iv_def >= 23:
user.say("Wow, that's what I call wall!")
else:
user.say("Sorry, but this is pathetic.")
Returns the DEF IV as int.
Pokemon.iv_spd
poke = user.select_pokemon("Show me a Pokemon with at least 30 DEF IVs!")
if poke.iv_spd >= 30:
user.say("Wow, this Pokemon will be the next Sonic!")
else:
user.say("Is this a Munchlax?")
Returns the SPD IV as int.
Pokemon.iv_spatk
poke = user.select_pokemon("Show me a Pokemon with at least 30 SPATK IVs!")
if poke.iv_spatk >= 30:
user.say("Wow, Porygon-Z with Choice Specs would be proud of it!")
else:
user.say("Seems as effective as Snorlax with Surf.")
Returns the SPATK IV as int.
Pokemon.iv_spdef
poke = user.select_pokemon("Show me a Pokemon with less than 10 SPDEF IVs!")
if poke.iv_spdef <= 10:
user.say("Yes, I am looking for a Pokemon like this. My Starmie will destroy it!")
else:
user.say("This Pokemon is too tanky to fight my little star.")
Returns the SPDEF IV as int.
Pokemon.iv_hp
poke = user.select_pokemon("Show me a Pokemon with at least 30 HP IVs!")
if poke.iv_hp >= 30:
user.say("That's surely a tanky Pokemon!")
else:
user.say("Even my Alakazam laughs at this HP IV.")
Returns the HP IV as int.
Pokemon.total_ivs
poke = user.select_pokemon("Show me your best Pokemon!")
user.say("Your pokemon has " + str(poke.ivs) + " total IVs.")
Returns the total IVs as int.
Pokemon.ivs
#Example 1:
user.say("Hey, I'm able to change the IVs of your Pokemon.")
if user.select("Do you need my help?", ["Sure", "No"])[0]: # 0 behaves like false, so "Sure" is false.
return user.say("Have a nice day!")
p = user.select_pokemon("Please select your Pokemon.")
new_ivs = random.sample(range(1, 32), 6) # generate a list of ints between 1-31
p.ivs = tuple(new_ivs) # cast the list to tuple
#Example 2:
# Setting lists of Pokemon, Natures and Moveset to use
listPokes = ["Charizard", "Arcanine", "Entei", "Moltres", "Blaziken", "Dragonite"]
listNature = [Nature.Timid, Nature.Adamant, Nature.Adamant, Nature.Timid, Nature.Jolly, Nature.Adamant]
listMoves = [
("Flamethrower", "Solar Beam", "Focus Blast", "Roost"),
("Flare Blitz", "Wild Charge", "Extreme Speed", "Protect"),
("Flare Blitz", "Sacred Fire", "Extreme Speed", "Stone Edge"),
("Hurricane", "Fire Blast", "Roost", "Agility"),
("Flare Blitz", "Swords Dance", "Low Kick", "Knock Off"),
("Dragon Dance", "Fly", "Earthquake", "Extreme Speed")
]
# Zip those lists together so they can move on the same index
for l, m, n in zip(listPokes, listNature, listMoves):
# Create a pokemon "p" from list "l"
p = Pokemon(l, 120)
# Set all the IV values for pokemon "p" as tuple
p.ivs = 31, 31, 31, 31, 31, 31
# Set all the EV values for pokemon "p" as tuple
p.evs = 252, 252, 252, 252, 252, 252
# Set nature from list "m" to pokemon "p"
p.nature = m
# Set moveset from tuple "n" to pokemon "p"
p.skills = n
# -Add pokemon "p" to the NPC Poke-Team
npc.team.append(p)
# We pause here so it doesn't execute the battle before you have finished reading the dialogue
user.pause()
# Let the battle begin!
result = user.battle(npc)
Returns all IVs as tuple.
Pokemon.ev_atk
poke = user.select_pokemon("Can you show me a fully ATK EV trained Pokemon!")
if poke.ev_atk == 252:
user.say("Mohammed Ali would be proud of it!")
else:
user.say("That's not fully trained at all.")
Returns the ATK EV as int.
Pokemon.ev_def
poke = user.select_pokemon("Can you show me a fully DEF EV trained Pokemon!")
if poke.def_def == 252:
user.say("Wow, you fully DEF EV trained this Pokemon? Filthy Chansey player!")
else:
user.say("That's not fully trained at all.")
Returns the DEF EV as int.
Pokemon.ev_spd
poke = user.select_pokemon("Can you show me a fully SPD EV trained Pokemon!")
if poke.ev_spd == 252:
user.say("Wow, that's a fast Pokemon!")
else:
user.say("That's not fully trained at all.")
Returns the SPD EV as int.
Pokemon.ev_spatk
poke = user.select_pokemon("Can you show me a fully SPATK EV trained Pokemon!")
if poke.ev_spatk == 252:
user.say("That's surely a strong Pokemon!")
else:
user.say("That's not fully trained at all.")
Returns the SPATK EV as int.
Pokemon.ev_spdef
poke = user.select_pokemon("Can you show me a fully SPDEF EV trained Pokemon!")
if poke.ev_spdef == 252:
user.say("Not even my Porygon-Z could break this Pokemon!")
else:
user.say("Even my Happiny could beat this Pokemon.")
Returns the SPDEF EV as int.
Pokemon.ev_hp
poke = user.select_pokemon("Can you show me a fully HP EV trained Pokemon!")
if poke.ev_hp == 252:
user.say("That Pokemon surely has a lot HP, good job!")
else:
user.say("That's not fully trained at all.")
Returns the HP EV as int.
Pokemon.evs
#Example 1:
user.say("Hey, I'm able to reset all EVs from your Pokemon.")
if user.select("Do you need my help for $20.000?", ["Yes", "No"])[0]: # 0 behaves like false, so "Yes" is false.
return user.say("See you!") # return exited the script
selected = user.select_pokemon("Please select your Pokemon.")
if user.money >= 20000:
user.money =- 20000
selected.evs = 0, 0, 0, 0, 0, 0 # reset all evs
else:
user.say("You can't afford $20.000.")
#Example 2:
# Setting lists of Pokemon, Natures and Moveset to use
listPokes = ["Charizard", "Arcanine", "Entei", "Moltres", "Blaziken", "Dragonite"]
listNature = [Nature.Timid, Nature.Adamant, Nature.Adamant, Nature.Timid, Nature.Jolly, Nature.Adamant]
listMoves = [
("Flamethrower", "Solar Beam", "Focus Blast", "Roost"),
("Flare Blitz", "Wild Charge", "Extreme Speed", "Protect"),
("Flare Blitz", "Sacred Fire", "Extreme Speed", "Stone Edge"),
("Hurricane", "Fire Blast", "Roost", "Agility"),
("Flare Blitz", "Swords Dance", "Low Kick", "Knock Off"),
("Dragon Dance", "Fly", "Earthquake", "Extreme Speed")
]
# Zip those lists together so they can move on the same index
for l, m, n in zip(listPokes, listNature, listMoves):
# Create a pokemon "p" from list "l"
p = Pokemon(l, 120)
# Set all the IV values for pokemon "p" as tuple
p.ivs = 31, 31, 31, 31, 31, 31
# Set all the EV values for pokemon "p" as tuple
p.evs = 252, 252, 252, 252, 252, 252
# Set nature from list "m" to pokemon "p"
p.nature = m
# Set moveset from tuple "n" to pokemon "p"
p.skills = n
# -Add pokemon "p" to the NPC Poke-Team
npc.team.append(p)
# We pause here so it doesn't execute the battle before you have finished reading the dialogue
user.pause()
# Let the battle begin!
result = user.battle(npc)
Returns all EVs as tuple.
Pokemon.hidden_power
poke = user.select_pokemon("From which Pokemon would you like me to check the Hidden Power?")
user.say("Your {} has Hidden Power type of {}.".format(poke.name, poke.hidden_power))
Returns the Hidden Power as Type.
enum Type
int | type |
---|---|
1 | Normal |
2 | Fighting |
3 | Flying |
4 | Poison |
5 | Ground |
6 | Rock |
7 | Bug |
8 | Ghost |
9 | Steel |
10 | Fire |
11 | Water |
12 | Grass |
13 | Electric |
14 | Psychic |
15 | Ice |
16 | Dragon |
17 | Dark |
18 | Fairy |
Pokemon.caught_ball
poke = user.select_pokemon("Whose Pokemon's ball should I check?")
user.say("Your {} was caught in a {}.".format(poke.name, Item(poke.caught_ball).name))
Returns the ball that was used to catch this Pokemon as an Item.
Pokemon.health
# Example 1
p = random.choice(user.team)
p.health -= 50
user.say("Your {} lost 50 health.".format(p.name))
# Example 2
p = user.select_pokemon("Check Health.")
user.say("Your {} has {} health.".format(p.name, p.health))
Returns or sets the Pokemon's current health.
Pokemon.lent
poke = user.select_pokemon("Which Pokemon should I delete?")
if poke.lent:
user.say("I cannot delete lent Pokemon!")
else:
del user.pokes[poke.pos]
Returns true if the Pokemon is lent.
Type | Description |
---|---|
bool | returns true if the Pokemon is lent |
Pokemon.stats
Returns the stats of a Pokemon as a Stats object.
Pokemon.status
poke = user.select_pokemon("Which Pokemon would you like to burn?")
poke.status = StatusCondition.Burn
user.say("There you go, I hope it has Guts!")
Return the Pokemon's status as StatusCondition.
enum StatusCondition
Int | StatusCondition |
---|---|
0 | NONE |
1 | Burn |
2 | Sleep |
3 | Poison |
4 | Bad_poison |
5 | Paralyze |
6 | Freeze |
Items
You can add, delete and check if someone has an item with items.
items.__iter__
#Prints all items in users inventory with their quantity
#Example 1:
for n, q in user.items:
user.say_system(str(n) + ": " + str(q))
#Example 2:
for n, q in user.items:
user.say_system( "%s: %s" % (n, q) )
Iterates through all items of the current user.
Type | Description |
---|---|
string | item name |
int | returns the item quantity |
items.__getitem__
if "Leftovers" in user.items:
user.say("You have " + str(user.items["Leftovers"]) + " Leftovers, Snorlax would be proud.")
else:
user.say("Too bad, you don't have Leftovers.")
Works the same as a dict and you get the quantity with the item name as key.
If selected user does not have selected item it will return 0.
Parameters
Type | Description |
---|---|
string | item name |
Return values
Type | Description |
---|---|
int | item quantity |
items.__setitem__
#Example 1:
user.items["Arcanine Mount"] = user.items["Arcanine Mount"] + 1
user.say("You received an Arcanine Mount!")
user.items["Lum Berry"] = user.items["Lum Berry"] + 99
user.say("I'm the real Lum Berry farmer!")
#Example 2:
user.items["Arcanine Mount"] = 0
user.say("Team Rocket stole all your Arcanine mount and rode away!")
Changes the quantity of an item. If you set it on 0 it will disappear from the inventory.
If the item does not exist in the inventory it will added.
Parameters
Type | Description |
---|---|
string | item name |
Return values
Type | Description |
---|---|
int | item quantity |
items.__delitem__
user.say("Give me all your Thunder Stones!")
del user.items["Thunder Stone"]
user.say("All your Thunder Stones were stolen!")
Deletes an item. There is no difference between deleting and changing the quanitity to 0.
Parameters
Type | Description |
---|---|
string | item name |
items.__contains__
if "Rain Badge" in user.items:
user.battle(npc)
else:
user.say("You need the Rain Badge to fight me!")
Checks if someone has an item. It's case insensitive.
Parameters
Type | Description |
---|---|
string | item name |
Return values
Type | Description |
---|---|
bool | returns true if user has selected item |
UserVars
UserVars.__getattr__
if user.vars.SinnohChamp: #SinnohChamp is a script defined variable
user.say("Here take $10.000 pokedollars!")
user.money = user.money + 10000
else:
user.say("Mhhh... You are not Sinnoh champion yet!")
Gets the variable from the database, returns NoneType if user doesn't have the variable.
Attention: All variables that were created with xanascript are strings while Python can return everything that's serializable.
Parameters
Type | Description |
---|---|
string | variable name |
UserVars.__setattr__
#Example 1:
if user.vars.ArcExp:
user.say("You earned 10 arc exp.")
user.vars.ArcExp = user.vars.ArcExp + 10
else:
user.vars.ArcExp = 10
#Example 2:
user.vars.submitted_mons = [451, 945, 39, 520]
Saves variables in the database. It throws the exception TypeError if the data type can't be serialized.
Variables that originate from xanascript can only be strings.
Parameters
Type | Description |
---|---|
string | variable name |
any | variable value |
UserVars.get
if user.vars.get("SinnohChamp"): #SinnohChamp is a script defined variable
user.say("Here take $10.000 pokedollars!")
user.money = user.money + 10000
else:
user.say("Mhhh... You are not Sinnoh champion yet!")
Gets the variable from the database, returns NoneType if user doesn't have the variable.
Attention: All variables that were created with xanascript are strings while Python can return everything that's serializable.
Parameters
Type | Description |
---|---|
string | variable name |
UserVars.set
#Example 1:
if not user.vars.WalrosskastanieBoss:
user.battle(npc)
user.vars.set("WalrosskastanieBoss", True, timedelta(days=12))
# Will be saved even when the user disconnects while the battle
else:
user.say("I'm too exhausted for a battle.")
#Example 2:
if not user.vars.HourlyPokeball:
user.items["Pokeball"] = user.items["Pokeball"] + 1
user.vars.set("HourlyPokeball", True, timedelta(hours=1, minutes=1))
else:
user.say("Don't be greedy!")
#Example 3:
if not user.vars.WeeklyRareCandy:
user.items["Rare Candy"] = user.items["Rare Candy"] + 1
user.vars.set("WeeklyRareCandy", True, timedelta(weeks=1))
else:
user.say("Don't be greedy!")
Saves variables in the database with an expire time. It throws the exception TypeError if the data type can't be serialized.
Variables that originate from Xanascript can only be strings.
Parameters
Type | Description |
---|---|
string | variable name |
any | variable value |
timedelta | expire time |
For more information about timedelta check out the Python docs.
Expire
Expire.__getattr__
user.vars.set("testvar", True, timedelta(weeks=1))
user.say("Come back in: {}".format(user.expire.testvar))
Returns the expire duration of a variable as timedelta object.
If a user does not have the variable or there is no cooldown anymore it returns None
.
For more information about datetime check out the Python docs.
Return values
Type | Description |
---|---|
timedelta | variable cooldown |
Expire.get
user.vars.set("testvar", True, timedelta(weeks=1))
user.say("Come back in: {}".format(user.expire.get("testvar")))
Returns the expire duration of a variable as timedelta object.
If a user does not have the variable or there is no cooldown anymore it returns None
.
For more information about datetime check out the Python docs.
Return values
Type | Description |
---|---|
timedelta | variable cooldown |
NPC
NPC.id
user.vars.set("Trainer{}".format(npc.id), True)
Returns the NPC ID as int.
NPC.hide
user.play_sound(1)
user.say("You found a Pokeball")
user.items["Pokeball"] = user.items["Pokeball"] + 1
npc.hide = True
Hides the NPC and makes it impossible to interact with it.
NPC.hide hides the NPC in client after the script is done. To update it immediately you have to use NPC.update.
NPC.hide_for
user.say("Buh. See you in 2 days")
npc.hide_for(timedelta(days=2))
Hides the NPC and makes it impossible to interact with it for a selected time.
Parameters
Type | Description |
---|---|
timedelta | time to hide the NPC |
NPC.update
user.say("Wattson: Oh, you have the Machine Part!")
user.say("Wattson: Finally I can fix all systems now! Thank you for your help!")
npcs[34890].hide = False
npc.update()
Flushes visibility changes to the client.
NPC.team
p = Pokemon("Snorlax", 100)
p.iv_atk, p.iv_def, p.iv_spd, p.iv_spdef, p.iv_spatk, p.iv_hp = (31, 31, 31, 31, 31, 31)
p.ev_atk, p.ev_def, p.ev_spd, p.ev_spdef, p.ev_spatk, p.ev_hp = (252, 252, 252, 252, 252, 252)
p.nature = Nature.Bold
p.skills = ("Curse", "Rest", "Body Slam", "Thunder Punch")
npc.team = [p]
user.battle(npc)
npc.team = [Pokemon("Clefable", 100), Pokemon("Starmie", 100), Pokemon("Dragonite", 100)]
user.battle(npc)
Sets a team for selected NPC, overrides the team in PROEditor.
Has to be a list with Pokemon objects.
NPC.los
if user.battle(npc) == 1:
user.play_music(1)
user.say("Why are you not surprised?")
npc.los = False
Activates or deactivates a line of sight.
NPC.emote
npc.emote(10)
user.say("Now I need to take care of it by myself. Goodbye then!")
Displays an emote to the current user.
Parameters
Type | Description |
---|---|
int | emote id |
1 is the first emote at the top left and it goes up from left to right.
NPC.position, NPC.pos
#Example 1:
user.say(f"{npc.position[0]} {npc.position[1]}, {npc.position[2}")
#Example 2:
user.say(f"{npc.pos.map} {npc.pos.x}, {npc.pos.y}")
Those two examples are equivalent.
Returns the position of the npc as named tuple.
Return values (namedtuple)
Attribute | Type | Description |
---|---|---|
map | string | map name |
x | int | x coordinate |
y | int | y coordinate |
NPC.last_fight
if npc.last_fight:
period = datetime.now() - npc.last_fight
user.say("We already fought {} days ago".format(period.days))
else:
user.battle(npc)
Returns the date you fought the NPC the last time.
Return values
Type | Description |
---|---|
datetime | last time you fought the NPC, None if never |
NPCs
NPCs.__getitem__
npcs[563].emote(25)
user.items["Revival Herb"] = user.items["Revival Herb"] - 1
user.say("You gave the Revival Herb to Professor Rider.")
Returns an NPC object from the current map.
Parameters
Type | Description |
---|---|
int | npc id |
Server
Server.vars
poke_id = current_points = -1
if server.vars.xmas_hunt:
poke_id, username, p_name, ivs, current_points = server.vars.xmas_hunt
if poke_id == poke.id:
user.say("You already showed me this Pokemon!")
elif points > current_points:
user.say("Congratulations, you are first place now!")
server.vars.xmas_hunt = poke.id, user.username, poke.name, poke.ivs, points
else:
user.say("That's sadly not enough to claim the first place!")
user.say("{}'s {} {} is currently first with {} points.".format(username, p_name, ivs, current_points))
Permits the access to global variables.
Type | Description |
---|---|
ServerVars | gives the possibility to save persistent global variables |
Server.system_msg
server.system_msg("Don't forget to follow Deathwings instagram profile!")
Displays a server wide system message.
Type | Description |
---|---|
string | system message |
ServerVars
Server.__getattr__
if server.vars.xmas_hunt:
poke_id, username, p_name, ivs, current_points = server.vars.xmas_hunt
if user.username.lower() == username.lower():
server.vars.xmas_hunt = None
user.say("HO! HO! HO! Your {} is truly a blessing! ".format(p_name))
user.say("With this there will be a warm and happy Christmas again this year!")
user.say("As promised here's your reward for helping to heal this little soul.")
p = Pokemon("Riolu", 15, form=1, ability=3)
p.nature = Nature.Adamant
user.team.add(p)
user.play_sound(4)
user.say("A timid Xmas Riolu was added to your team.")
Gets the global variable from the database, returns NoneType if global variable doesn't exist.
Parameters
Type | Description |
---|---|
string | global variable name |
Server.__setattr__
user.say("Congratulations, you are first place now!")
server.vars.xmas_hunt = poke.id, user.username, poke.name, poke.ivs, points
Saves global variables in the database.
Parameters
Type | Description |
---|---|
string | global variable name |
any | variable value |
Server.get
if server.vars.get("xmas_hunt"):
poke_id, username, p_name, ivs, current_points = server.vars.get("xmas_hunt")
if user.username.lower() == username.lower():
server.vars.set("xmas_hunt", None)
user.say("HO! HO! HO! Your {} is truly a blessing! ".format(p_name))
user.say("With this there will be a warm and happy Christmas again this year!")
user.say("As promised here's your reward for helping to heal this little soul.")
p = Pokemon("Riolu", 15, form=1, ability=3)
p.nature = Nature.Adamant
user.team.add(p)
user.play_sound(4)
user.say("A timid Xmas Riolu was added to your team.")
Gets the global variable from the database, returns NoneType if global variable doesn't exist.
Parameters
Type | Description |
---|---|
string | global variable name |
Server.set
user.say("Congratulations, you are first place now!")
server.vars.set("xmas_hunt",( poke.id, user.username, poke.name, poke.ivs, points))
Saves global variables in the database.
Parameters
Type | Description |
---|---|
string | global variable name |
PokedexEntry
PokedexEntry.region
sinnoh_seen = sum(d.region == region.Sinnoh for d in user.dex)
user.say("You have seen {} Sinnoh Pokemon.".format(sinnoh_seen))
Returns a Region enum.
enum Region
Int | Region |
---|---|
1 | Kanto |
2 | Johto |
3 | Hoenn |
4 | Sinnoh |
5 | Unova |
6 | Kalos |
7 | Galar |
PokedexEntry.id
for entry in user.dex:
if 250<entry.id<350:
user.say("You have seen {} Pokemon between dex id 250-350.".format(sum(250<entry.id<350 for entry in user.dex)))
Returns the Pokemon ID of selected Pokemon.
Return values
Type | Description |
---|---|
int | dex id |
PokedexEntry.caught
#Example 1:
kanto_caught = sum(d.caught for d in user.dex if d.region == region.Kanto)
user.say("You have caught {} Kanto Pokemon.".format(kanto_caught))
#Example 2:
if user.dex[151] and user.dex[151].caught:
user.say("You have caught Mew.")
Returns if you have caught selected Pokemon.
Return values
Type | Description |
---|---|
bool | returns true if caught |
PokedexEntry.evolved
#Example 1:
johto_evolved = sum(d.evolved for d in user.dex if d.region == region.Johto)
user.say("You have evolved {} Johto Pokemon.".format(johto_evolved))
#Example 2:
if user.dex["Charmander"] and user.dex["Charmander"].evolved:
user.say("You have evolved Charmander.")
Checks if you have evolved selected Pokemon.
Return values
Type | Description |
---|---|
bool | returns true if evolved |
PokedexEntry.stats
Returns the stats of a Pokedex Entry as a Stats object.
Pokedex
With Pokedex you can get access to the users Pokedex. Pokedex can be used as an iterator.
Pokedex.__iter__
#Example 1:
evolved = sum(d.evolved for d in user.dex)
kanto_evolved = sum(d.evolved and d.region == region.Kanto for d in user.dex)
user.say("You evolved {} total Pokemon and {} Kanto Pokemon.".format(evolved, kanto_evolved))
#Example 2:
caught = sum(d.caught for d in user.dex)
user.say("You caught {} different Pokemon.".format(caught))
#Example 3:
for entry in user.dex:
user.say((entry.id, entry.caught)) #Troll over 9000
Returns an iterator to the users Pokedex which returns PokedexEntry objects.
Behaves like a vanilla Python list iterator.
Pokedex.__contains__
if "Mew" in user.dex:
user.say("You have already seen Mew.")
Checks if the user has seen the selected Pokemon.
Parameters
Type | Description |
---|---|
Union[int, string] | dex id or Pokemon name |
Pokedex.__getitem__
# Returns None if the user didn't Mew yet
if user.dex["Mew"]:
if not user.dex["Mew"].evolved:
user.say("You didn't evolve Mew yet.")
elif not user.dex["Mew"].caught:
user.say("You didn't catch Mew yet.")
else:
user.say("You didn't see Mew yet.")
Returns a Pokedex entry for selected Pokemon.
Parameters
Type | Description |
---|---|
int | dex id |
string | Pokemon name |
Pokedex.add
#Example 1:
user.play_cry(220)
user.say("Swinub!")
if 220 in user.dex:
user.dex.add(720)
user.pause()
user.say("Swinub's seen-data entry has been registered in your Pokedex!")
#Example 2:
user.say("Mew!")
if "Mew" in user.dex:
user.dex.add("Mew", caught=True, evolved=True)
user.pause()
user.say("Mew's evolve-data entry has been registered in your Pokedex!")
Adds an entry to the users Pokedex.
Parameters
Type | Description |
---|---|
Union[int, string] | dex id or Pokemon name |
bool | caught |
bool | evolved |
SkillData
With SkillData you can get access to the skill data from a Pokemon. Skilldata can be used as an iterator.
SkillData.__iter__
poke = user.select_pokemon("Show me the Pokemon with a good fighting-type move.")
for sd in poke.skill_data:
if sd.type == Type.Fighting:
user.say("{} is a good fighting-type move!".format(sd))
break
else:
user.say("Your Pokemon doesn't even have a fighting-type move!")
Returns an iterator that iterates through the Pokemon's skill data and returns them as PokeSkill objects.
Empty spots in the skill data return NoneType!
SkillData.__getitem__
user.say("You have " + poke.skill_data[0].name + " as the first move in your move set.")
user.say("You have " + poke.skill_data[-1].name + " as the last move in your move set.")
Works the same as in regular Python with slices and so on.
SkillData.__delitem__
del poke.skill_data[0]
user.say("I deleted the first move in {}'s move set!".format(poke.name))
Deletes the skill data / move from the Pokemon's move set.
SkillData.__contains__
poke = user.select_pokemon("Which Pokemon should learn Toxic?")
if "Toxic" in poke.skill_data:
user.say("Your {} already knows Toxic.".format(poke.name))
else:
poke.teach("Toxic")
Searches through the Pokemon's skill data. You can search with the poke skill name, ID or with the PokeSkill object directly.
Pokes.__contains__ is case sensitivity!
SkillData.add
p = Pokemon("Greninja", 30)
if len(p.skill_data) < 4:
p.skill_data.add("Toxic")
Adds a poke skill to the selected Pokemon's last skill data position.
Parameters
Parameter | Type | Description |
---|---|---|
poke_skill | Union[int, string, PokeSkill] | the poke skill that you want to add to the Pokemon's move set |
PokeSkill
PokeSkill.__init__
ps1 = PokeSkill("Hydro Pump")
ps2 = PokeSkill(ps1.name, pp=8, pp_left=8)
ps3 = PokeSkill(Skill.HYDRO_PUMP)
poke = Pokemon("Rotom-Wash", 30)
poke.skills = ("Volt Switch", "Will-O-Wisp", "Pain Split")
poke.skill_data.add(ps2.id)
Returns the poke skill object.
Parameters
Parameter | Type | Description |
---|---|---|
skill id | Union[int, string, Skill] | the poke skill's identifier |
pp | int | the max pp of this move |
pp_left | int | the amount of pp that are left for this move |
PokeSkill.id
ps = PokeSkill("Toxic")
user.say("Toxic has the move ID: {}".format(ps.id))
Returns the unique poke skill ID as int.
PokeSkill.name
p = user.select_pokemon("Show me your strongest pokemon!")
user.say("Its first move is {}".format(p.skill_data[0].name))
Returns the poke skill's name as string.
PokeSkill.type
poke = user.select_pokemon("Whose Pokemon move types should I check?")
move_types = [ps.type for ps in poke.skill_data]
user.say("Your {}'s moves cover the following types: {}.".format(poke.name, ", ".join(move_types)))
Returns the poke skill's type as Type.
enum Type
int | type |
---|---|
1 | Normal |
2 | Fighting |
3 | Flying |
4 | Poison |
5 | Ground |
6 | Rock |
7 | Bug |
8 | Ghost |
9 | Steel |
10 | Fire |
11 | Water |
12 | Grass |
13 | Electric |
14 | Psychic |
15 | Ice |
16 | Dragon |
17 | Dark |
18 | Fairy |
PokeSkill.power
poke = user.select_pokemon("Show me a Pokemon with a strong move!")
ps = max(poke.skill_data, key=lambda x: x.power)
user.say("Your {}'s strongest move is {} with {} base power.".format(poke.name, ps.name, ps.power))
Returns the move's base power as int.
PokeSkill.accuracy
poke = user.select_pokemon("Which Pokemon has some moves that might miss?")
if any(ps.accuracy < 1.0 for ps in poke.skill_data):
user.say("True, this one has a move that might miss.")
else:
user.say("That's wrong! All of its moves have 100 accuracy!")
Returns the move's accuracy as float.
PokeSkill.priority
poke = user.select_pokemon("May I see one of your Pokemon?")
if any(ps.priority > 0 for ps in poke.skill_data):
user.say("Your {} has a priority move!".format(poke.name))
Returns the move's priority as int.
PokeSkill.damage_type
poke = user.select_pokemon("Whose damage types should I check?")
t_status, t_physical, t_special = 0, 0, 0
for ps in poke.skill_data:
if ps.power == 0:
t_status += 1
elif ps.damage_type == DamageType.Physical:
t_physical += 1
elif ps.damage_type == DamageType.Special:
t_special += 1
user.say("Your Pokemon has {}x status, {}x physical and {}x special moves.".format(t_status, t_physical, t_special))
Returns the move's damage type as DamageType.
enum DamageType
int | damage type |
---|---|
1 | Physical |
2 | Special |
PokeSkill.pp_max
poke = user.select_pokemon("Which Pokemon's moves should I pp up?")
move_id, move_name = user.select("Which move should I pp up?", poke.skills)
pp_ups = user.select("How many PP Ups should I use?", [1, 2, 3])[1]
default_pp = PokeSkill(move_name).pp_max
new_pp = default_pp + pp_ups/5 * default_pp
poke.skill_data[move_id].pp_max = int(min(new_pp, 8/5 * default_pp))
Returns or sets the amount of the move's maximum PPs.
Return values
Type | Description |
---|---|
int | max pp of the move (capped at 1.6x of the default PPs) |
PokeSkill.pp_left
poke = user.select_pokemon("Whose Pokemon's pp should I refresh?")
for ps in poke.skill_data:
ps.pp_left = ps.pp_max
Returns or sets the amount for the move's PPs that are left.
Return values
Type | Description |
---|---|
int | left pp of the move (capped at the current's max PPs) |
Stats
You can look up a Pokemon's or Dex Entry's stats with this object.
Stats.dex_id
poke = user.select_pokemon("Whose dex ID would you like to know?")
user.say("The dex ID is {}.".format(poke.stats.dex_id))
Returns the dex ID of the Pokemon or Dex Entry as an int.
Stats.name
poke = user.select_pokemon("Whose name would you like to know?")
user.say("The name is {}.".format(poke.stats.dex_id))
Returns the name of the Pokemon or Dex Entry as a str.
Stats.desc
poke = user.select_pokemon("Whose dex entry would you like to read?")
user.say("{}.".format(poke.stats.desc))
Returns the dex description of the Pokemon or Dex Entry as a str.
Stats.species
poke = user.select_pokemon("Whose species would you like to know?")
user.say("The species is {}.".format(poke.stats.species))
Returns the species/title of the Pokemon or Dex Entry as a str.
Stats.height
poke = user.select_pokemon("Whose height would you like to know?")
user.say("Your {} is {} meters tall.".format(poke.name, poke.stats.height))
Returns the height of the Pokemon or Dex Entry as a float.
Stats.weight
poke = user.select_pokemon("Whose weight would you like to know?")
user.say("Your {} weights {} kg.".format(poke.name, poke.stats.weight))
Returns the weight of the Pokemon or Dex Entry as a float.
Stats.catch_rate
poke = user.select_pokemon("Whose catch rate would you like to know?")
user.say("Your {} has a catch rate of {}.".format(poke.name, poke.stats.catch_rate))
Returns the catch rate of the Pokemon or Dex Entry as an int.
Stats.egg_group_1
poke = user.select_pokemon("Whose first egg group would you like to know?")
user.say("Your {}'s first egg group is {}.".format(poke.name, poke.stats.egg_group_1))
Returns the first egg group of the Pokemon or Dex Entry as a str.
Stats.egg_group_2
poke1 = user.select_pokemon("I can check if two Pokemon are compatible. Which Pokemon should I check?")
poke2 = user.select_pokemon("Which one is the second Pokemon?")
groups1 = [poke1.stats.egg_group_1, poke1.stats.egg_group_2]
groups2 = [poke2.stats.egg_group_1, poke2.stats.egg_group_2]
if any(eg in [eg1 for eg1 in groups1 if eg1] for eg in groups2 if eg):
user.say("These two Pokemon are compatible.")
else:
user.say("These two Pokemon are not compatible.")
Returns the second egg group of the Pokemon or Dex Entry as a str.
Stats.gender_ratio
poke = user.select_pokemon("Whose gender ratio would you like to know?")
if poke.gender == "?":
user.say("{} has no gender!".format(poke.name))
else:
user.say("Around {}% of {} are male and {}% are female.".format(poke.stats.gender_ratio, poke.name, 100 - poke.stats.gender_ratio))
Returns the gender ratio of the Pokemon or Dex Entry as a float.
Stats.legendary
poke = user.select_pokemon("I can check if a Pokemon is a legendary!")
if poke.stats.legendary:
user.say("Your {} is a legendary Pokemon.".format(poke.name))
else:
user.say("Your {} is not a legendary Pokemon.".format(poke.name))
Returns True if the Pokemon or Dex Entry is a legendary.
Stats.mega
poke = user.select_pokemon("I can check if a Pokemon is a mega!")
if poke.stats.mega:
user.say("Your {} is a mega Pokemon.".format(poke.name))
else:
user.say("Your {} is not a mega Pokemon.".format(poke.name))
Returns True if the Pokemon or Dex Entry is a mega.
Stats.base_form
poke = user.select_pokemon("I can check the base form of a mega Pokemon!")
if poke.stats.mega:
user.say("Your {}'s base form is {}.".format(poke.name, user.dex[poke.stats.base_form].stats.name))
else:
user.say("Your {} is not a mega Pokemon.".format(poke.name))
Returns the base form's dex ID of a Pokemon or Dex ID as an int.
Stats.eviolite
poke = user.select_pokemon("I can check if a Pokemon can still evolve")
if poke.stats.eviolite:
user.say("Your {} can still evolve.".format(poke.name))
else:
user.say("Your {} cannot evolve.".format(poke.name))
Returns True if the Pokemon or Dex Entry can still evolve.
Stats.base_ATK
poke = user.select_pokemon("I can check the base attack of a Pokemon")
user.say("Your {} has {} base attack.".format(poke.name, poke.stats.base_ATK))
Returns the base attack of a Pokemon or Dex Entry as an int.
Stats.base_DEF
poke = user.select_pokemon("I can check the base defense of a Pokemon")
user.say("Your {} has {} base defense.".format(poke.name, poke.stats.base_DEF))
Returns the base defense of a Pokemon or Dex Entry as an int.
Stats.base_SPD
poke = user.select_pokemon("I can check the base speed of a Pokemon")
user.say("Your {} has {} base speed.".format(poke.name, poke.stats.base_SPD))
Returns the base speed of a Pokemon or Dex Entry as an int.
Stats.base_SPATK
poke = user.select_pokemon("I can check the base special attack of a Pokemon")
user.say("Your {} has {} base special attack.".format(poke.name, poke.stats.base_SPATK))
Returns the base special attack of a Pokemon or Dex Entry as an int.
Stats.base_SPDEF
poke = user.select_pokemon("I can check the base special defense of a Pokemon")
user.say("Your {} has {} base special defense.".format(poke.name, poke.stats.base_SPDEF))
Returns the base special defense of a Pokemon or Dex Entry as an int.
Stats.base_HP
poke = user.select_pokemon("I can check the base hp of a Pokemon")
user.say("Your {} has {} base hp.".format(poke.name, poke.stats.base_HP))
Returns the base hp of a Pokemon or Dex Entry as an int.
Stats.calc_ATK
poke = user.select_pokemon("Whose total attack should I calculate?")
total = poke.stats.calc_ATK(poke.level, poke.iv_atk, poke.ev_atk)
user.say("Your {} has {} total attack.".format(poke.name, total))
Returns the total attack for a Pokemon or Dex Entry as an int.
Parameters
Parameter | Type | Description |
---|---|---|
level | int | the level of the Pokemon |
iv | int | the atk IVs of the Pokemon |
ev | int | the atk EVs of the Pokemon |
Return values
Type | Description |
---|---|
int | returns the total attack. |
Stats.calc_DEF
poke = user.select_pokemon("Whose total defense should I calculate?")
total = poke.stats.calc_DEF(poke.level, poke.iv_def, poke.ev_def)
user.say("Your {} has {} total defense.".format(poke.name, total))
Returns the total defense for a Pokemon or Dex Entry as an int.
Parameters
Parameter | Type | Description |
---|---|---|
level | int | the level of the Pokemon |
iv | int | the def IVs of the Pokemon |
ev | int | the def EVs of the Pokemon |
Return values
Type | Description |
---|---|
int | returns the total defense. |
Stats.calc_SPD
poke = user.select_pokemon("Whose total speed should I calculate?")
total = poke.stats.calc_SPD(poke.level, poke.iv_spd, poke.ev_spd)
user.say("Your {} has {} total speed.".format(poke.name, total))
Returns the total speed for a Pokemon or Dex Entry as an int.
Parameters
Parameter | Type | Description |
---|---|---|
level | int | the level of the Pokemon |
iv | int | the spd IVs of the Pokemon |
ev | int | the spd EVs of the Pokemon |
Return values
Type | Description |
---|---|
int | returns the total speed. |
Stats.calc_SPATK
poke = user.select_pokemon("Whose total special attack should I calculate?")
total = poke.stats.calc_SPATK(poke.level, poke.iv_spatk, poke.ev_spatk)
user.say("Your {} has {} total special attack.".format(poke.name, total))
Returns the total special attack for a Pokemon or Dex Entry as an int.
Parameters
Parameter | Type | Description |
---|---|---|
level | int | the level of the Pokemon |
iv | int | the spatk IVs of the Pokemon |
ev | int | the spatk EVs of the Pokemon |
Return values
Type | Description |
---|---|
int | returns the total special attack. |
Stats.calc_SPDEF
poke = user.select_pokemon("Whose total special defense should I calculate?")
total = poke.stats.calc_SPDEF(poke.level, poke.iv_spdef, poke.ev_spdef)
user.say("Your {} has {} total special defense.".format(poke.name, total))
Returns the total attack for a Pokemon or Dex Entry as an int.
Parameters
Parameter | Type | Description |
---|---|---|
level | int | the level of the Pokemon |
iv | int | the spdef IVs of the Pokemon |
ev | int | the spdef EVs of the Pokemon |
Return values
Type | Description |
---|---|
int | returns the total special defense. |
Stats.calc_HP
poke = user.select_pokemon("Whose total hp should I calculate?")
total = poke.stats.calc_HP(poke.level, poke.iv_hp, poke.ev_hp)
user.say("Your {} has {} total hp.".format(poke.name, total))
Returns the total hp for a Pokemon or Dex Entry as an int.
Parameters
Parameter | Type | Description |
---|---|---|
level | int | the level of the Pokemon |
iv | int | the hp IVs of the Pokemon |
ev | int | the hp EVs of the Pokemon |
Return values
Type | Description |
---|---|
int | returns the total hp. |