159 lines
6.1 KiB
Plaintext
159 lines
6.1 KiB
Plaintext
// This file documents the entire Host interface API currently used by the WebAssembly script resolver, so the methods
|
|
// that can be used from the client wasm.
|
|
// Currently, we only define a bunch of functions, but in the future when interface types are actually implemented,
|
|
// we'd like to implement those as well.
|
|
|
|
// Core functions
|
|
// These are the core utility functions for use.
|
|
// _error can be used for crash handling in the script handler. It takes a message string, file name string, line and position.
|
|
_error: function(i32 message_pointer, s32 message_length, i32 file_pointer, i32 file_length, i32 line, i32 position)
|
|
// _print can be used to print a message to the hosts stdout
|
|
_print: function(i32 message_pointer, s32 message_length)
|
|
|
|
// StringView class
|
|
type const_string = u64;
|
|
const_string_get_hash: function(const_string ptr) -> u32
|
|
// Returns a pointer to the WASM memory where the string can be found.
|
|
// NOTE: This requires us to copy the string into WASM memory.
|
|
const_string_get_str: function(const_string ptr) -> s32
|
|
|
|
// List class
|
|
type list = u64
|
|
list_get_length: function(list) -> u64
|
|
list_get_at: function(list, u64) -> u64
|
|
|
|
// Library types
|
|
type pokemon_library = u64
|
|
type library_settings = u64
|
|
type species_library = u64
|
|
type move_library = u64
|
|
type item_library = u64
|
|
type growth_rate_library = u64
|
|
type type_library = u64
|
|
type talent_library = u64
|
|
type nature_library = u64
|
|
|
|
type level_int = u8
|
|
|
|
type species = u64
|
|
type move = u64
|
|
type item = u64
|
|
type nature = u64
|
|
type forme = u64
|
|
type ability = u64
|
|
|
|
enum Statistic {
|
|
Health,
|
|
Attack,
|
|
Defense
|
|
SpecialAttack,
|
|
SpecialDefense,
|
|
Speed,
|
|
}
|
|
|
|
// PokemonLibrary class
|
|
data_library_get_settings: function(pokemon_library ptr) -> library_settings
|
|
data_library_get_species_library: function(pokemon_library ptr) -> species_library
|
|
data_library_get_move_library: function(pokemon_library ptr) -> move_library
|
|
data_library_get_item_library: function(pokemon_library ptr) -> item_library
|
|
data_library_get_growth_rates: function(pokemon_library ptr) -> growth_rate_library
|
|
data_library_get_type_library: function(pokemon_library ptr) -> type_library
|
|
data_library_get_talent_library: function(pokemon_library ptr) -> talent_library
|
|
data_library_get_nature_library: function(pokemon_library ptr) -> nature_library
|
|
|
|
// LibrarySettings class
|
|
library_settings_get_max_level: function(library_settings ptr) -> level_int
|
|
library_settings_get_max_moves: function(library_settings ptr) -> u8
|
|
library_settings_get_shiny_rate: function(library_settings ptr) -> u16
|
|
|
|
// SpeciesLibrary class
|
|
species_library_get_species_by_hash: function(species_library library, u32 hash) -> species
|
|
|
|
// MoveLibrary class
|
|
move_library_get_move_by_hash: function(move_library library, u32 hash) -> move
|
|
|
|
// ItemLibrary class
|
|
item_library_get_item_by_hash: function(item_library library, u32 hash) -> item
|
|
|
|
// GrowthRateLibrary class
|
|
growthrate_library_calculate_level_by_hash: function(growth_rate_library library, u32 hash, u32 experience) -> level_int
|
|
growthrate_library_calculate_experience_by_hash: function(growth_rate_library library, u32 hash, level_int level) -> u32
|
|
|
|
// TypeLibrary class
|
|
type_library_get_type_id_by_hash: function(type_library, u32 hash) -> u8
|
|
type_library_get_single_effectiveness: function(type_library, u8 attacking, u8 offensive) -> f32
|
|
type_library_get_type_name: function(type_library, u8 type) -> const_string
|
|
|
|
// NatureLibrary class
|
|
nature_library_get_nature_by_hash: function(nature_library, u32 hash) -> nature
|
|
nature_library_get_nature_name: function(nature_library, nature) -> const_string
|
|
|
|
// Nature class
|
|
nature_get_increased_modifier: function(nature) -> f32
|
|
nature_get_decreased_modifier: function(nature) -> f32
|
|
nature_get_increased_stat: function(nature) -> Statistic
|
|
nature_get_decreased_stat: function(nature) -> Statistic
|
|
|
|
// MoveData class
|
|
enum MoveCategory {
|
|
Physical, Special, Status,
|
|
}
|
|
enum MoveTarget {
|
|
Adjacent, AdjacentAlly, AdjacentAllySelf, AdjacentOpponent,
|
|
All, AllAdjacent, AllAdjacentOpponent, AllAlly, AllOpponent,
|
|
Any,
|
|
RandomOpponent, Self
|
|
}
|
|
|
|
move_data_get_name: function(move) -> const_string
|
|
move_data_get_type: function(move) -> u8
|
|
move_data_get_category: function(move) -> MoveCategory
|
|
move_data_get_base_power: function(move) -> u8
|
|
move_data_get_accuracy: function(move) -> u8
|
|
move_data_get_base_usages: function(move) -> u8
|
|
move_data_get_target: function(move) -> MoveTarget
|
|
move_data_get_priority: function(move) -> s8
|
|
move_data_has_secondary_effect: function(move) -> bool
|
|
move_data_has_flag_by_hash: function(move, u32 hash) -> bool
|
|
|
|
// Item class
|
|
enum ItemCategory {
|
|
Misc, Pokeball, Medicine, Berry, MoveLearner, FormeChanger, KeyItem, Mail
|
|
}
|
|
enum ItemBattleCategory {
|
|
None, Healing, StatusHealing, Pokeball, MiscBattleItem
|
|
}
|
|
item_get_name: function(item) -> const_string
|
|
item_get_category: function(item) -> ItemCategory
|
|
item_get_battle_category: function(item) -> ItemBattleCategory
|
|
item_get_price: function(item) -> s32
|
|
item_get_fling_power: function(item) -> u8
|
|
item_has_flag_by_hash: function(item, u32 hash) -> bool
|
|
|
|
// Species class
|
|
species_get_id: function(species) -> u16
|
|
species_get_name: function(species) -> const_string
|
|
species_get_gender_rate: function(species) -> f32
|
|
species_get_growth_rate: function(species) -> const_string
|
|
species_get_capture_rate: function(species) -> u8
|
|
species_get_base_happiness: function(species) -> u8
|
|
species_has_forme_by_hash: function(species, u32) -> bool
|
|
species_get_forme_by_hash: function(species, u32) -> forme
|
|
species_has_flag_by_hash: function(species, u32) -> bool
|
|
species_has_egg_group_by_hash: function(species, u32) -> bool
|
|
|
|
// Forme class
|
|
forme_get_name: function(forme) -> const_string
|
|
forme_get_height: function(forme) -> float
|
|
forme_get_weight: function(forme) -> float
|
|
forme_get_base_experience: function(forme) -> u32
|
|
forme_get_type_count: function(forme) -> u64
|
|
forme_get_type: function(forme, u64) -> u8
|
|
forme_get_statistic: function(forme, Statistic) -> u16
|
|
forme_get_ability_count: function(forme) -> u64
|
|
forme_get_hidden_ability_count: function(forme) -> u64
|
|
forme_get_ability: function(forme, bool hidden, u8 index) -> ability
|
|
forme_has_flag_by_hash: function(forme, u32) -> bool
|
|
|
|
// Ability class
|