Pastebin
API
tools
faq
paste
Login
Sign up
Please fix the following errors:
New Paste
Syntax Highlighting
From 5f36834a1c24d39e378e694f1bbfab47115bd7fd Mon Sep 17 00:00:00 2001 From: eduardovicente <dudugt500@gmail.com> Date: Fri, 22 Sep 2017 19:16:04 -0300 Subject: [PATCH] Pokeball System 1.0 --- forgottenserver-1.2/data/actions/actions.xml | 3 + .../data/actions/scripts/tools/pokeball.lua | 32 ++++ forgottenserver-1.2/data/events/scripts/player.lua | 94 ++++++----- forgottenserver-1.2/data/items/items.xml | 1 + forgottenserver-1.2/src/enums.h | 10 ++ forgottenserver-1.2/src/item.cpp | 10 ++ forgottenserver-1.2/src/item.h | 8 + forgottenserver-1.2/src/items.cpp | 2 + forgottenserver-1.2/src/items.h | 6 +- forgottenserver-1.2/src/luascript.cpp | 186 +++++++++++++++++++++ forgottenserver-1.2/src/luascript.h | 21 +++ forgottenserver-1.2/src/pokeball.cpp | 98 +++++++++++ forgottenserver-1.2/src/pokeball.h | 49 ++++++ 13 files changed, 476 insertions(+), 44 deletions(-) create mode 100644 forgottenserver-1.2/data/actions/scripts/tools/pokeball.lua create mode 100644 forgottenserver-1.2/src/pokeball.cpp create mode 100644 forgottenserver-1.2/src/pokeball.h diff --git a/forgottenserver-1.2/data/actions/actions.xml b/forgottenserver-1.2/data/actions/actions.xml index af4f559..89695bf 100644 --- a/forgottenserver-1.2/data/actions/actions.xml +++ b/forgottenserver-1.2/data/actions/actions.xml @@ -1,5 +1,8 @@ <?xml version="1.0" encoding="UTF-8"?> <actions> + <!-- Pokeball --> + <action itemid="2467" script="tools/pokeball.lua" /> + <!-- Quests --> <action itemid="1740" script="quests/quests.lua" /> <action fromid="1747" toid="1749" script="quests/quests.lua" /> diff --git a/forgottenserver-1.2/data/actions/scripts/tools/pokeball.lua b/forgottenserver-1.2/data/actions/scripts/tools/pokeball.lua new file mode 100644 index 0000000..de6d6f2 --- /dev/null +++ b/forgottenserver-1.2/data/actions/scripts/tools/pokeball.lua @@ -0,0 +1,32 @@ +function table.dump(t, depth) + if not depth then depth = 0 end + for k,v in pairs(t) do + str = (' '):rep(depth * 2) .. k .. ': ' + if type(v) ~= "table" then + print(str .. tostring(v)) + else + print(str) + table.dump(v, depth+1) + end + end +end + +function onUse(player, pokeball, fromPosition, target, toPosition, isHotkey) + local nameList = {"Amazon", "Troll", "Orc", "Fire Devil", "Dragon", "Frost Dragon"} + + if (pokeball:getPokemonName() == "") then + pokeball:setPokemonName(nameList[math.random(1, 6)]) + pokeball:setLevel(math.random(1,100)) + pokeball:setMaxHealth(100 * pokeball:getLevel()) + pokeball:setHealth(pokeball:getMaxHealth()) + else + local pokemon = Game.createMonster(pokeball:getPokemonName(), player:getPosition()) + pokemon:setMaster(player) + + pokemon:setMaxHealth(pokeball:getMaxHealth()) + local currentHealth = -(pokemon:getHealth() - 1) + pokemon:addHealth(currentHealth) + pokemon:addHealth(pokeball:getHealth() - 1) + end + return true +end \ No newline at end of file diff --git a/forgottenserver-1.2/data/events/scripts/player.lua b/forgottenserver-1.2/data/events/scripts/player.lua index 472f1ac..40d1694 100644 --- a/forgottenserver-1.2/data/events/scripts/player.lua +++ b/forgottenserver-1.2/data/events/scripts/player.lua @@ -3,55 +3,63 @@ function Player:onBrowseField(position) end function Player:onLook(thing, position, distance) - local description = "You see " .. thing:getDescription(distance) - if self:getGroup():getAccess() then - if thing:isItem() then - description = string.format("%s\nItem ID: %d", description, thing:getId()) - - local actionId = thing:getActionId() - if actionId ~= 0 then - description = string.format("%s, Action ID: %d", description, actionId) - end - - local uniqueId = thing:getAttribute(ITEM_ATTRIBUTE_UNIQUEID) - if uniqueId > 0 and uniqueId < 65536 then - description = string.format("%s, Unique ID: %d", description, uniqueId) - end - - local itemType = thing:getType() - - local transformEquipId = itemType:getTransformEquipId() - local transformDeEquipId = itemType:getTransformDeEquipId() - if transformEquipId ~= 0 then - description = string.format("%s\nTransforms to: %d (onEquip)", description, transformEquipId) - elseif transformDeEquipId ~= 0 then - description = string.format("%s\nTransforms to: %d (onDeEquip)", description, transformDeEquipId) - end - - local decayId = itemType:getDecayId() - if decayId ~= -1 then - description = string.format("%s\nDecays to: %d", description, decayId) - end - elseif thing:isCreature() then - local str = "%s\nHealth: %d / %d" - if thing:getMaxMana() > 0 then - str = string.format("%s, Mana: %d / %d", str, thing:getMana(), thing:getMaxMana()) + local description = "" + + if thing:isPokeball() then + description = "You see an ".. thing:getPokemonName() + description = description.. ", Level: ".. thing:getLevel().. ", [Hp: ".. thing:getHealth().. " / Max.Hp: ".. thing:getMaxHealth().. "]." + else + description = "You see " .. thing:getDescription(distance) + if self:getGroup():getAccess() then + if thing:isItem() then + description = string.format("%s\nItem ID: %d", description, thing:getId()) + + local actionId = thing:getActionId() + if actionId ~= 0 then + description = string.format("%s, Action ID: %d", description, actionId) + end + + local uniqueId = thing:getAttribute(ITEM_ATTRIBUTE_UNIQUEID) + if uniqueId > 0 and uniqueId < 65536 then + description = string.format("%s, Unique ID: %d", description, uniqueId) + end + + local itemType = thing:getType() + + local transformEquipId = itemType:getTransformEquipId() + local transformDeEquipId = itemType:getTransformDeEquipId() + if transformEquipId ~= 0 then + description = string.format("%s\nTransforms to: %d (onEquip)", description, transformEquipId) + elseif transformDeEquipId ~= 0 then + description = string.format("%s\nTransforms to: %d (onDeEquip)", description, transformDeEquipId) + end + + local decayId = itemType:getDecayId() + if decayId ~= -1 then + description = string.format("%s\nDecays to: %d", description, decayId) + end + elseif thing:isCreature() then + local str = "%s\nHealth: %d / %d" + if thing:getMaxMana() > 0 then + str = string.format("%s, Mana: %d / %d", str, thing:getMana(), thing:getMaxMana()) + end + description = string.format(str, description, thing:getHealth(), thing:getMaxHealth()) .. "." end - description = string.format(str, description, thing:getHealth(), thing:getMaxHealth()) .. "." - end - local position = thing:getPosition() - description = string.format( - "%s\nPosition: %d, %d, %d", - description, position.x, position.y, position.z - ) + local position = thing:getPosition() + description = string.format( + "%s\nPosition: %d, %d, %d", + description, position.x, position.y, position.z + ) - if thing:isCreature() then - if thing:isPlayer() then - description = string.format("%s\nIP: %s.", description, Game.convertIpToString(thing:getIp())) + if thing:isCreature() then + if thing:isPlayer() then + description = string.format("%s\nIP: %s.", description, Game.convertIpToString(thing:getIp())) + end end end end + self:sendTextMessage(MESSAGE_INFO_DESCR, description) end diff --git a/forgottenserver-1.2/data/items/items.xml b/forgottenserver-1.2/data/items/items.xml index 134c7cd..da0c5be 100644 --- a/forgottenserver-1.2/data/items/items.xml +++ b/forgottenserver-1.2/data/items/items.xml @@ -3753,6 +3753,7 @@ <attribute key="weight" value="6000" /> <attribute key="armor" value="4" /> <attribute key="slotType" value="body" /> + <attribute key="type" value="pokeball" /> </item> <item id="2468" name="studded legs"> <attribute key="weight" value="2600" /> diff --git a/forgottenserver-1.2/src/enums.h b/forgottenserver-1.2/src/enums.h index 032dada..f927825 100644 --- a/forgottenserver-1.2/src/enums.h +++ b/forgottenserver-1.2/src/enums.h @@ -546,6 +546,16 @@ struct CombatDamage } }; +struct PokemonStatus +{ + double attack = 0; + double defense = 0; + double hp = 0; + double specialAttack = 0; + double specialDefense = 0; + double speed = 0; +}; + typedef std::list<MarketOffer> MarketOfferList; typedef std::list<HistoryMarketOffer> HistoryMarketOfferList; typedef std::list<ShopInfo> ShopInfoList; diff --git a/forgottenserver-1.2/src/item.cpp b/forgottenserver-1.2/src/item.cpp index ca23ee4..a0bc884 100644 --- a/forgottenserver-1.2/src/item.cpp +++ b/forgottenserver-1.2/src/item.cpp @@ -27,6 +27,7 @@ #include "house.h" #include "game.h" #include "bed.h" +#include "pokeball.h" #include "actions.h" #include "spells.h" @@ -67,6 +68,8 @@ Item* Item::CreateItem(const uint16_t type, uint16_t count /*= 0*/) newItem = new Mailbox(type); } else if (it.isBed()) { newItem = new BedItem(type); + } else if (it.isPokeball()) { + newItem = new Pokeball(type); } else if (it.id >= 2210 && it.id <= 2212) { newItem = new Item(type - 3, count); } else if (it.id == 2215 || it.id == 2216) { @@ -617,6 +620,13 @@ Attr_ReadValue Item::readAttr(AttrTypes_t attr, PropStream& propStream) return ATTR_READ_ERROR; } + //Pokeball class + case ATTR_POKEBALLINFO: { + if (!propStream.skip(6)) { + return ATTR_READ_ERROR; + } + break; + } default: return ATTR_READ_ERROR; } diff --git a/forgottenserver-1.2/src/item.h b/forgottenserver-1.2/src/item.h index 0004522..a8be5fb 100644 --- a/forgottenserver-1.2/src/item.h +++ b/forgottenserver-1.2/src/item.h @@ -36,6 +36,7 @@ class Mailbox; class Door; class MagicField; class BedItem; +class Pokeball; enum ITEMPROPERTY { CONST_PROP_BLOCKSOLID = 0, @@ -97,6 +98,7 @@ enum AttrTypes_t { ATTR_ARMOR = 31, ATTR_HITCHANCE = 32, ATTR_SHOOTRANGE = 33, + ATTR_POKEBALLINFO = 34, }; enum Attr_ReadValue { @@ -360,6 +362,12 @@ class Item : virtual public Thing virtual const BedItem* getBed() const { return nullptr; } + virtual Pokeball* getPokeball() { + return nullptr; + } + virtual const Pokeball* getPokeball() const { + return nullptr; + } const std::string& getStrAttr(itemAttrTypes type) const { if (!attributes) { diff --git a/forgottenserver-1.2/src/items.cpp b/forgottenserver-1.2/src/items.cpp index a05149e..37a1201 100644 --- a/forgottenserver-1.2/src/items.cpp +++ b/forgottenserver-1.2/src/items.cpp @@ -400,6 +400,8 @@ void Items::parseItemNode(const pugi::xml_node& itemNode, uint16_t id) it.type = ITEM_TYPE_BED; } else if (tmpStrValue == "rune") { it.type = ITEM_TYPE_RUNE; + } else if (tmpStrValue == "pokeball") { + it.type = ITEM_TYPE_POKEBALL; } else { std::cout << "[Warning - Items::parseItemNode] Unknown type: " << valueAttribute.as_string() << std::endl; } diff --git a/forgottenserver-1.2/src/items.h b/forgottenserver-1.2/src/items.h index 44c9a0c..de58d18 100644 --- a/forgottenserver-1.2/src/items.h +++ b/forgottenserver-1.2/src/items.h @@ -54,6 +54,7 @@ enum ItemTypes_t { ITEM_TYPE_BED, ITEM_TYPE_KEY, ITEM_TYPE_RUNE, + ITEM_TYPE_POKEBALL, ITEM_TYPE_LAST }; @@ -142,7 +143,10 @@ class ItemType return (type == ITEM_TYPE_BED); } bool isRune() const { - return type == ITEM_TYPE_RUNE; + return (type == ITEM_TYPE_RUNE); + } + bool isPokeball() const { + return (type == ITEM_TYPE_POKEBALL); } bool hasSubType() const { return (isFluidContainer() || isSplash() || stackable || charges != 0); diff --git a/forgottenserver-1.2/src/luascript.cpp b/forgottenserver-1.2/src/luascript.cpp index bd2d52f..6c975d6 100644 --- a/forgottenserver-1.2/src/luascript.cpp +++ b/forgottenserver-1.2/src/luascript.cpp @@ -35,6 +35,7 @@ #include "monster.h" #include "scheduler.h" #include "databasetasks.h" +#include "pokeball.h" extern Chat* g_chat; extern Game g_game; @@ -674,6 +675,8 @@ void LuaScriptInterface::setItemMetatable(lua_State* L, int32_t index, const Ite luaL_getmetatable(L, "Container"); } else if (item->getTeleport()) { luaL_getmetatable(L, "Teleport"); + } else if (item->getPokeball()) { + luaL_getmetatable(L, "Pokeball"); } else { luaL_getmetatable(L, "Item"); } @@ -807,6 +810,9 @@ Thing* LuaScriptInterface::getThing(lua_State* L, int32_t arg) case LuaData_Npc: thing = getUserdata<Npc>(L, arg); break; + case LuaData_Pokeball: + thing = getUserdata<Pokeball>(L, arg); + break; default: thing = nullptr; break; @@ -1427,6 +1433,7 @@ void LuaScriptInterface::registerFunctions() registerEnum(ITEM_TYPE_BED) registerEnum(ITEM_TYPE_KEY) registerEnum(ITEM_TYPE_RUNE) + registerEnum(ITEM_TYPE_POKEBALL) registerEnum(ITEM_BAG) registerEnum(ITEM_GOLD_COIN) @@ -1954,6 +1961,7 @@ void LuaScriptInterface::registerFunctions() registerMetaMethod("Item", "__eq", LuaScriptInterface::luaUserdataCompare); registerMethod("Item", "isItem", LuaScriptInterface::luaItemIsItem); + registerMethod("Item", "isPokeball", LuaScriptInterface::luaItemIsPokeball); registerMethod("Item", "getParent", LuaScriptInterface::luaItemGetParent); registerMethod("Item", "getTopParent", LuaScriptInterface::luaItemGetTopParent); @@ -2018,6 +2026,25 @@ void LuaScriptInterface::registerFunctions() registerMethod("Teleport", "getDestination", LuaScriptInterface::luaTeleportGetDestination); registerMethod("Teleport", "setDestination", LuaScriptInterface::luaTeleportSetDestination); + // Pokeball + registerClass("Pokeball", "Item", LuaScriptInterface::luaPokeballCreate); + registerMetaMethod("Pokeball", "__eq", LuaScriptInterface::luaUserdataCompare); + + registerMethod("Pokeball", "getPokemonName", LuaScriptInterface::luaPokeballGetPokemonName); + registerMethod("Pokeball", "setPokemonName", LuaScriptInterface::luaPokeballSetPokemonName); + + registerMethod("Pokeball", "getLevel", LuaScriptInterface::luaPokeballGetLevel); + registerMethod("Pokeball", "setLevel", LuaScriptInterface::luaPokeballSetLevel); + + registerMethod("Pokeball", "getExperience", LuaScriptInterface::luaPokeballGetExperience); + registerMethod("Pokeball", "setExperience", LuaScriptInterface::luaPokeballSetExperience); + + registerMethod("Pokeball", "getHealth", LuaScriptInterface::luaPokeballGetHealth); + registerMethod("Pokeball", "setHealth", LuaScriptInterface::luaPokeballSetHealth); + + registerMethod("Pokeball", "getMaxHealth", LuaScriptInterface::luaPokeballGetMaxHealth); + registerMethod("Pokeball", "setMaxHealth", LuaScriptInterface::luaPokeballSetMaxHealth); + // Creature registerClass("Creature", "", LuaScriptInterface::luaCreatureCreate); registerMetaMethod("Creature", "__eq", LuaScriptInterface::luaUserdataCompare); @@ -2613,6 +2640,8 @@ void LuaScriptInterface::registerClass(const std::string& className, const std:: lua_pushnumber(luaState, LuaData_Npc); } else if (className == "Tile") { lua_pushnumber(luaState, LuaData_Tile); + } else if (className == "Pokeball") { + lua_pushnumber(luaState, LuaData_Pokeball); } else { lua_pushnumber(luaState, LuaData_Unknown); } @@ -3594,6 +3623,7 @@ int LuaScriptInterface::luaAddEvent(lua_State* L) switch (entry.second) { case LuaData_Item: case LuaData_Container: + case LuaData_Pokeball: case LuaData_Teleport: { lua_getglobal(globalState, "Item"); lua_getfield(globalState, -1, "getUniqueId"); @@ -5767,6 +5797,14 @@ int LuaScriptInterface::luaItemIsItem(lua_State* L) return 1; } + +int LuaScriptInterface::luaItemIsPokeball(lua_State* L) +{ + // item:isPokeball() + pushBoolean(L, getUserdata<const Item>(L, 1)->getPokeball() != nullptr); + return 1; +} + int LuaScriptInterface::luaItemGetParent(lua_State* L) { // item:getParent() @@ -6580,6 +6618,154 @@ int LuaScriptInterface::luaTeleportSetDestination(lua_State* L) return 1; } +// Pokeball +int LuaScriptInterface::luaPokeballCreate(lua_State* L) +{ + // Pokeball(uid) + uint32_t id = getNumber<uint32_t>(L, 2); + Item* item = getScriptEnv()->getItemByUID(id); + + if (item && item->getPokeball()) { + pushUserdata<Pokeball>(L, item->getPokeball()); + setMetatable(L, -1, "Pokeball"); + } else { + lua_pushnil(L); + } + return 1; +} + +int LuaScriptInterface::luaPokeballGetPokemonName(lua_State* L) +{ + // Pokeball:getPokemonName() + Pokeball* pokeball = getUserdata<Pokeball>(L, 1); + if (pokeball) { + pushString(L, pokeball->getPokemonName()); + } else { + lua_pushnil(L); + } + + return 1; +} + +int LuaScriptInterface::luaPokeballSetPokemonName(lua_State* L) +{ + // Pokeball:setPokemonName(name) + Pokeball* pokeball = getUserdata<Pokeball>(L, 1); + if (pokeball) { + std::string name = getString(L, 2); + pokeball->setPokemonName(name); + } else { + lua_pushnil(L); + } + + return 1; +} + +int LuaScriptInterface::luaPokeballGetLevel(lua_State* L) +{ + // Pokeball:getLevel() + Pokeball* pokeball = getUserdata<Pokeball>(L, 1); + if (pokeball) { + lua_pushnumber(L, pokeball->getLevel()); + } else { + lua_pushnil(L); + } + return 1; +} + +int LuaScriptInterface::luaPokeballSetLevel(lua_State* L) +{ + // Pokeball:setLevel(lvl) + Pokeball* pokeball = getUserdata<Pokeball>(L, 1); + if (pokeball) { + uint32_t lvl = getNumber<uint32_t>(L, 2); + pokeball->setLevel(lvl); + } + else { + lua_pushnil(L); + } + + return 1; +} + +int LuaScriptInterface::luaPokeballGetExperience(lua_State* L) +{ + // Pokeball:getExperience() + Pokeball* pokeball = getUserdata<Pokeball>(L, 1); + if (pokeball) { + lua_pushnumber(L, pokeball->getExperience()); + } else { + lua_pushnil(L); + } + return 1; +} + +int LuaScriptInterface::luaPokeballSetExperience(lua_State* L) +{ + // Pokeball:setExperience(exp) + Pokeball* pokeball = getUserdata<Pokeball>(L, 1); + if (pokeball) { + uint64_t experience = getNumber<uint64_t>(L, 2); + pokeball->setExperience(experience); + } else { + lua_pushnil(L); + } + + return 1; +} + +int LuaScriptInterface::luaPokeballGetHealth(lua_State* L) +{ + // Pokeball:getHealth() + Pokeball* pokeball = getUserdata<Pokeball>(L, 1); + if (pokeball) { + lua_pushnumber(L, pokeball->getHealth()); + } else { + lua_pushnil(L); + } + return 1; +} + +int LuaScriptInterface::luaPokeballSetHealth(lua_State* L) +{ + // Pokeball:setHealth(health) + Pokeball* pokeball = getUserdata<Pokeball>(L, 1); + if (pokeball) { + int32_t health = getNumber<int32_t>(L, 2); + pokeball->setHealth(health); + } else { + lua_pushnil(L); + } + + return 1; +} + +int LuaScriptInterface::luaPokeballGetMaxHealth(lua_State* L) +{ + // Pokeball:getMaxHealth() + Pokeball* pokeball = getUserdata<Pokeball>(L, 1); + if (pokeball) { + lua_pushnumber(L, pokeball->getMaxHealth()); + } else { + lua_pushnil(L); + } + return 1; +} + +int LuaScriptInterface::luaPokeballSetMaxHealth(lua_State* L) +{ + // Pokeball:setMaxHealth(mHealth) + Pokeball* pokeball = getUserdata<Pokeball>(L, 1); + if (pokeball) { + int32_t mHealth = getNumber<int32_t>(L, 2); + pokeball->setMaxHealth(mHealth); + } else { + lua_pushnil(L); + } + + return 1; +} + // Creature int LuaScriptInterface::luaCreatureCreate(lua_State* L) { diff --git a/forgottenserver-1.2/src/luascript.h b/forgottenserver-1.2/src/luascript.h index b109527..6b3e933 100644 --- a/forgottenserver-1.2/src/luascript.h +++ b/forgottenserver-1.2/src/luascript.h @@ -46,6 +46,7 @@ class Combat; class Condition; class Npc; class Monster; +class Pokeball; enum { EVENT_ID_LOADING = 1, @@ -71,6 +72,7 @@ enum LuaDataType { LuaData_Monster, LuaData_Npc, LuaData_Tile, + LuaData_Pokeball, }; struct LuaVariant { @@ -668,6 +670,7 @@ class LuaScriptInterface static int luaItemCreate(lua_State* L); static int luaItemIsItem(lua_State* L); + static int luaItemIsPokeball(lua_State* L); static int luaItemGetParent(lua_State* L); static int luaItemGetTopParent(lua_State* L); @@ -730,6 +733,24 @@ class LuaScriptInterface static int luaTeleportGetDestination(lua_State* L); static int luaTeleportSetDestination(lua_State* L); + // Pokeball + static int luaPokeballCreate(lua_State* L); + + static int luaPokeballGetPokemonName(lua_State* L); + static int luaPokeballSetPokemonName(lua_State* L); + + static int luaPokeballGetLevel(lua_State* L); + static int luaPokeballSetLevel(lua_State* L); + + static int luaPokeballGetExperience(lua_State* L); + static int luaPokeballSetExperience(lua_State* L); + + static int luaPokeballGetHealth(lua_State* L); + static int luaPokeballSetHealth(lua_State* L); + + static int luaPokeballGetMaxHealth(lua_State* L); + static int luaPokeballSetMaxHealth(lua_State* L); + // Creature static int luaCreatureCreate(lua_State* L); diff --git a/forgottenserver-1.2/src/pokeball.cpp b/forgottenserver-1.2/src/pokeball.cpp new file mode 100644 index 0000000..129f8d7 --- /dev/null +++ b/forgottenserver-1.2/src/pokeball.cpp @@ -0,0 +1,98 @@ +#include "otpch.h" +#include "Pokeball.h" + +Attr_ReadValue Pokeball::readAttr(AttrTypes_t attr, PropStream& propStream) +{ + if (attr == ATTR_POKEBALLINFO) { + if (!propStream.read<std::string>(name)) { + return ATTR_READ_ERROR; + } + else if (!propStream.read<uint32_t>(level)) { + return ATTR_READ_ERROR; + } + else if (!propStream.read<uint64_t>(experience)) { + return ATTR_READ_ERROR; + } + else if (!propStream.read<int32_t>(health)) { + return ATTR_READ_ERROR; + } + else if (!propStream.read<int32_t>(healthMax)) { + return ATTR_READ_ERROR; + } + return ATTR_READ_CONTINUE; + } + + return Item::readAttr(attr, propStream); + +} +void Pokeball::serializeAttr(PropWriteStream& propWriteStream) const +{ + Item::serializeAttr(propWriteStream); + + propWriteStream.write<uint8_t>(ATTR_POKEBALLINFO); + propWriteStream.write<std::string>(name); + propWriteStream.write<uint32_t>(level); + propWriteStream.write<uint64_t>(experience); + propWriteStream.write<int32_t>(health); + propWriteStream.write<int32_t>(healthMax); +} + +std::string Pokeball::getPokemonName() +{ + return name; +} + +void Pokeball::setPokemonName(std::string nName) +{ + name = nName; +} + +uint32_t Pokeball::getLevel() +{ + return level; +} + +void Pokeball::setLevel(uint32_t lvl) +{ + level = lvl; +} + +uint64_t Pokeball::getExperience() +{ + return experience; +} + +void Pokeball::setExperience(uint64_t exp) +{ + experience = exp; + +} +int32_t Pokeball::getHealth() +{ + return health; +} + +void Pokeball::setHealth(int32_t nhealth) +{ + health = nhealth; +} + +int32_t Pokeball::getMaxHealth() +{ + return healthMax; +} + +void Pokeball::setMaxHealth(int32_t mhealth) +{ + healthMax = mhealth; +} + +PokemonStatus Pokeball::getPokemonStatus() +{ + return status; +} + +void Pokeball::setPokemonStatus(PokemonStatus nStatus) +{ + status = nStatus; +} \ No newline at end of file diff --git a/forgottenserver-1.2/src/pokeball.h b/forgottenserver-1.2/src/pokeball.h new file mode 100644 index 0000000..859098f --- /dev/null +++ b/forgottenserver-1.2/src/pokeball.h @@ -0,0 +1,49 @@ +#include "item.h" + +class Pokeball final : public Item { +public: + explicit Pokeball(uint16_t type) : Item(type) {}; + + Pokeball* getPokeball() final { + return this; + } + + const Pokeball* getPokeball() const final { + return this; + } + + Attr_ReadValue readAttr(AttrTypes_t attr, PropStream& propStream) final; + void serializeAttr(PropWriteStream& propWriteStream) const; + + std::string getPokemonName(); + void setPokemonName(std::string name); + + uint32_t getLevel(); + void setLevel(uint32_t health); + + uint64_t getExperience(); + void setExperience(uint64_t exp); + + int32_t getHealth(); + void setHealth(int32_t health); + + int32_t getMaxHealth(); + void setMaxHealth(int32_t maxHealth); + + PokemonStatus getPokemonStatus(); + void setPokemonStatus(PokemonStatus status); + +private: + std::string name = ""; + std::string nick = ""; + + uint32_t level = 1; + uint64_t experience = 100; + + int32_t health = 100; + int32_t healthMax = 100; + + PokemonStatus status; +}; + + -- 2.7.4.1.g5468f9e
Optional Paste Settings
Category:
None
Cryptocurrency
Cybersecurity
Fixit
Food
Gaming
Haiku
Help
History
Housing
Jokes
Legal
Money
Movies
Music
Pets
Photo
Science
Software
Source Code
Spirit
Sports
Travel
TV
Writing
Tags:
Syntax Highlighting:
None
Bash
C
C#
C++
CSS
HTML
JSON
Java
JavaScript
Lua
Markdown (PRO members only)
Objective C
PHP
Perl
Python
Ruby
Swift
4CS
6502 ACME Cross Assembler
6502 Kick Assembler
6502 TASM/64TASS
ABAP
AIMMS
ALGOL 68
APT Sources
ARM
ASM (NASM)
ASP
ActionScript
ActionScript 3
Ada
Apache Log
AppleScript
Arduino
Asymptote
AutoIt
Autohotkey
Avisynth
Awk
BASCOM AVR
BNF
BOO
Bash
Basic4GL
Batch
BibTeX
Blitz Basic
Blitz3D
BlitzMax
BrainFuck
C
C (WinAPI)
C Intermediate Language
C for Macs
C#
C++
C++ (WinAPI)
C++ (with Qt extensions)
C: Loadrunner
CAD DCL
CAD Lisp
CFDG
CMake
COBOL
CSS
Ceylon
ChaiScript
Chapel
Clojure
Clone C
Clone C++
CoffeeScript
ColdFusion
Cuesheet
D
DCL
DCPU-16
DCS
DIV
DOT
Dart
Delphi
Delphi Prism (Oxygene)
Diff
E
ECMAScript
EPC
Easytrieve
Eiffel
Email
Erlang
Euphoria
F#
FO Language
Falcon
Filemaker
Formula One
Fortran
FreeBasic
FreeSWITCH
GAMBAS
GDB
GDScript
Game Maker
Genero
Genie
GetText
Go
Godot GLSL
Groovy
GwBasic
HQ9 Plus
HTML
HTML 5
Haskell
Haxe
HicEst
IDL
INI file
INTERCAL
IO
ISPF Panel Definition
Icon
Inno Script
J
JCL
JSON
Java
Java 5
JavaScript
Julia
KSP (Kontakt Script)
KiXtart
Kotlin
LDIF
LLVM
LOL Code
LScript
Latex
Liberty BASIC
Linden Scripting
Lisp
Loco Basic
Logtalk
Lotus Formulas
Lotus Script
Lua
M68000 Assembler
MIX Assembler
MK-61/52
MPASM
MXML
MagikSF
Make
MapBasic
Markdown (PRO members only)
MatLab
Mercury
MetaPost
Modula 2
Modula 3
Motorola 68000 HiSoft Dev
MySQL
Nagios
NetRexx
Nginx
Nim
NullSoft Installer
OCaml
OCaml Brief
Oberon 2
Objeck Programming Langua
Objective C
Octave
Open Object Rexx
OpenBSD PACKET FILTER
OpenGL Shading
Openoffice BASIC
Oracle 11
Oracle 8
Oz
PARI/GP
PCRE
PHP
PHP Brief
PL/I
PL/SQL
POV-Ray
ParaSail
Pascal
Pawn
Per
Perl
Perl 6
Phix
Pic 16
Pike
Pixel Bender
PostScript
PostgreSQL
PowerBuilder
PowerShell
ProFTPd
Progress
Prolog
Properties
ProvideX
Puppet
PureBasic
PyCon
Python
Python for S60
QBasic
QML
R
RBScript
REBOL
REG
RPM Spec
Racket
Rails
Rexx
Robots
Roff Manpage
Ruby
Ruby Gnuplot
Rust
SAS
SCL
SPARK
SPARQL
SQF
SQL
SSH Config
Scala
Scheme
Scilab
SdlBasic
Smalltalk
Smarty
StandardML
StoneScript
SuperCollider
Swift
SystemVerilog
T-SQL
TCL
TeXgraph
Tera Term
TypeScript
TypoScript
UPC
Unicon
UnrealScript
Urbi
VB.NET
VBScript
VHDL
VIM
Vala
Vedit
VeriLog
Visual Pro Log
VisualBasic
VisualFoxPro
WHOIS
WhiteSpace
Winbatch
XBasic
XML
XPP
Xojo
Xorg Config
YAML
YARA
Z80 Assembler
ZXBasic
autoconf
jQuery
mIRC
newLISP
q/kdb+
thinBasic
Paste Expiration:
Never
Burn after read
10 Minutes
1 Hour
1 Day
1 Week
2 Weeks
1 Month
6 Months
1 Year
Paste Exposure:
Public
Unlisted
Private
Folder:
(members only)
Password
NEW
Enabled
Disabled
Burn after read
NEW
Paste Name / Title:
Create New Paste
Hello
Guest
Sign Up
or
Login
Sign in with Facebook
Sign in with Twitter
Sign in with Google
You are currently not logged in, this means you can not edit or delete anything you paste.
Sign Up
or
Login
Public Pastes
Free Crypto Method
CSS | 31 min ago | 0.72 KB
Crypto admin access
32 min ago | 0.43 KB
+12,000$ in 2 days
CSS | 32 min ago | 0.72 KB
Documents
33 min ago | 0.43 KB
OG OLDHAM CODE
7 hours ago | 27.75 KB
remove current bid and bid now button from au...
PHP | 16 hours ago | 0.80 KB
AppUseUA
JSON | 20 hours ago | 0.27 KB
Notices blood
1 day ago | 0.81 KB
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the
Cookies Policy
.
OK, I Understand
Not a member of Pastebin yet?
Sign Up
, it unlocks many cool features!