bind lua functions for questlog/npc trade/trade/channels/text edit/list edit/containers
This commit is contained in:
parent
55fbb5f1a6
commit
a8c9980a5c
5
TODO
5
TODO
|
@ -28,7 +28,7 @@ use hardware buffer
|
|||
use indices
|
||||
fix opacity and cached framebuffers conflict
|
||||
map zoom rendering could be optimized using framebuffer caches
|
||||
make low/medium/high settings for economizing graphics memory thus allowing client smoothily in smartphones
|
||||
make low/medium/high settings for economizing graphics memory thus allowing to run the client smoothily in smartphones
|
||||
|
||||
== Lua
|
||||
make possible to bind non LuaObject derived classes on lua engine (for usage with Point,Rect,Color,Size)
|
||||
|
@ -41,7 +41,6 @@ port to MacOs and iphone
|
|||
multiline rich text widget
|
||||
move layout proprieties to widget style
|
||||
multiline text editor widget
|
||||
rework UIMessageBox, UIToolTip and UIInputBox
|
||||
fix style inheretance using a style translator
|
||||
find a way to add new widgets without focusing them
|
||||
review UI/style loader and make more error prone with more warnings
|
||||
|
@ -57,7 +56,6 @@ cache or preload otui files to avoid freezes because of hd reading
|
|||
change Align/Anchors lua API from enum to text
|
||||
|
||||
== Client
|
||||
make possible to reload modules
|
||||
fix modules recursivity, it makes client crash
|
||||
implement left panel with dragging windows
|
||||
clean sprites cache periodically
|
||||
|
@ -79,4 +77,3 @@ edit texts
|
|||
trade window
|
||||
shop window
|
||||
battle window
|
||||
hotkeys window
|
||||
|
|
|
@ -54,7 +54,7 @@ function Containers.onOpenContainer(containerId, itemId, name, capacity, hasPare
|
|||
m_containers[containerId] = container
|
||||
end
|
||||
|
||||
function Containers.onContainerClose(containerId)
|
||||
function Containers.onCloseContainer(containerId)
|
||||
local container = m_containers[containerId]
|
||||
if container then
|
||||
g_game.gameRightPanel:removeChild(container)
|
||||
|
@ -131,7 +131,7 @@ end
|
|||
connect(g_game, { onGameStart = Containers.clean,
|
||||
onGameEnd = Containers.clean,
|
||||
onOpenContainer = Containers.onOpenContainer,
|
||||
onContainerClose = Containers.onContainerClose,
|
||||
onCloseContainer = Containers.onCloseContainer,
|
||||
onContainerAddItem = Containers.onContainerAddItem,
|
||||
onContainerUpdateItem = Containers.onContainerUpdateItem,
|
||||
onContainerRemoveItem = Containers.onContainerRemoveItem })
|
||||
|
|
|
@ -36,12 +36,12 @@ function HealthBar.toggle()
|
|||
end
|
||||
|
||||
-- hooked events
|
||||
function HealthBar.onHealthChange(health, maxHealth)
|
||||
function HealthBar.onHealthChange(localPlayer, health, maxHealth)
|
||||
healthLabel:setText(health .. ' / ' .. maxHealth)
|
||||
healthBar:setPercent(health / maxHealth * 100)
|
||||
end
|
||||
|
||||
function HealthBar.onManaChange(mana, maxMana)
|
||||
function HealthBar.onManaChange(localPlayer, mana, maxMana)
|
||||
manaLabel:setText(mana .. ' / ' .. maxMana)
|
||||
|
||||
local percent
|
||||
|
@ -54,6 +54,6 @@ function HealthBar.onManaChange(mana, maxMana)
|
|||
end
|
||||
|
||||
connect(g_game, { onGameStart = HealthBar.create,
|
||||
onGameEnd = HealthBar.destroy,
|
||||
onHealthChange = HealthBar.onHealthChange,
|
||||
onGameEnd = HealthBar.destroy })
|
||||
connect(LocalPlayer, { onHealthChange = HealthBar.onHealthChange,
|
||||
onManaChange = HealthBar.onManaChange })
|
||||
|
|
|
@ -75,32 +75,32 @@ function Skills.onSkillButtonClick(button)
|
|||
end
|
||||
|
||||
-- hooked events
|
||||
function Skills.onExperienceChange(value)
|
||||
function Skills.onExperienceChange(localPlayer, value)
|
||||
setSkillValue('experience', getNumberString(value))
|
||||
end
|
||||
|
||||
function Skills.onLevelChange(value, percent)
|
||||
function Skills.onLevelChange(localPlayer, value, percent)
|
||||
setSkillValue('level', getNumberString(value))
|
||||
setSkillPercent('level', percent, 'You have ' .. (100 - percent) .. ' percent to go')
|
||||
end
|
||||
|
||||
function Skills.onHealthChange(health, maxHealth)
|
||||
function Skills.onHealthChange(localPlayer, health, maxHealth)
|
||||
setSkillValue('health', getNumberString(health))
|
||||
end
|
||||
|
||||
function Skills.onManaChange(mana, maxMana)
|
||||
function Skills.onManaChange(localPlayer, mana, maxMana)
|
||||
setSkillValue('mana', getNumberString(mana))
|
||||
end
|
||||
|
||||
function Skills.onSoulChange(soul)
|
||||
function Skills.onSoulChange(localPlayer, soul)
|
||||
setSkillValue('soul', soul)
|
||||
end
|
||||
|
||||
function Skills.onFreeCapacityChange(freeCapacity)
|
||||
function Skills.onFreeCapacityChange(localPlayer, freeCapacity)
|
||||
setSkillValue('capacity', freeCapacity)
|
||||
end
|
||||
|
||||
function Skills.onStaminaChange(stamina)
|
||||
function Skills.onStaminaChange(localPlayer, stamina)
|
||||
local hours = math.floor(stamina / 60)
|
||||
local minutes = stamina % 60
|
||||
if minutes < 10 then
|
||||
|
@ -112,18 +112,20 @@ function Skills.onStaminaChange(stamina)
|
|||
setSkillPercent('stamina', percent, 'You have ' .. percent .. ' percent')
|
||||
end
|
||||
|
||||
function Skills.onMagicLevelChange(value, percent)
|
||||
function Skills.onMagicLevelChange(localPlayer, value, percent)
|
||||
setSkillValue('magiclevel', value)
|
||||
setSkillPercent('magiclevel', percent, 'You have ' .. (100 - percent) .. ' percent to go')
|
||||
end
|
||||
|
||||
function Skills.onSkillChange(id, level, percent)
|
||||
function Skills.onSkillChange(localPlayer, id, level, percent)
|
||||
setSkillValue('skillId' .. id, level)
|
||||
setSkillPercent('skillId' .. id, percent, 'You have ' .. (100 - percent) .. ' percent to go')
|
||||
end
|
||||
|
||||
connect(g_game, { onGameStart = Skills.create,
|
||||
onGameEnd = Skills.destroy,
|
||||
onGameEnd = Skills.destroy })
|
||||
|
||||
connect(LocalPlayer, {
|
||||
onExperienceChange = Skills.onExperienceChange,
|
||||
onLevelChange = Skills.onLevelChange,
|
||||
onHealthChange = Skills.onHealthChange,
|
||||
|
|
|
@ -154,12 +154,6 @@ namespace Otc
|
|||
LastSkill
|
||||
};
|
||||
|
||||
enum SkillType {
|
||||
SkillLevel = 0,
|
||||
SkillPercent,
|
||||
LastSkillType
|
||||
};
|
||||
|
||||
enum Direction {
|
||||
North = 0,
|
||||
East,
|
||||
|
@ -246,7 +240,7 @@ namespace Otc
|
|||
EmblemBlue
|
||||
};
|
||||
|
||||
enum PlayerIcons {
|
||||
enum PlayerStates {
|
||||
IconNone = 0,
|
||||
IconPoison = 1,
|
||||
IconBurn = 2,
|
||||
|
|
|
@ -38,9 +38,9 @@ public:
|
|||
};
|
||||
|
||||
Creature();
|
||||
virtual ~Creature() { }
|
||||
|
||||
virtual void draw(const Point& dest, float scaleFactor, bool animate);
|
||||
|
||||
void internalDrawOutfit(const Point& dest, float scaleFactor, bool animateWalk, bool animateIdle, Otc::Direction direction);
|
||||
void drawOutfit(const Rect& destRect, bool resize);
|
||||
void drawInformation(const Point& point, bool useGray, const Rect& parentRect);
|
||||
|
|
|
@ -146,69 +146,6 @@ void Game::processPing()
|
|||
g_lua.callGlobalField("g_game", "onPing");
|
||||
}
|
||||
|
||||
void Game::processPlayerStats(double health, double maxHealth,
|
||||
double freeCapacity, double experience,
|
||||
double level, double levelPercent,
|
||||
double mana, double maxMana,
|
||||
double magicLevel, double magicLevelPercent,
|
||||
double soul, double stamina)
|
||||
{
|
||||
if(m_localPlayer->getHealth() != health ||
|
||||
m_localPlayer->getMaxHealth() != maxHealth) {
|
||||
m_localPlayer->setStatistic(Otc::Health, health);
|
||||
m_localPlayer->setStatistic(Otc::MaxHealth, maxHealth);
|
||||
g_lua.callGlobalField("g_game", "onHealthChange", health, maxHealth);
|
||||
|
||||
// cannot walk while dying
|
||||
if(health == 0) {
|
||||
if(m_localPlayer->isPreWalking())
|
||||
m_localPlayer->stopWalk();
|
||||
m_localPlayer->lockWalk();
|
||||
}
|
||||
}
|
||||
|
||||
if(m_localPlayer->getStatistic(Otc::FreeCapacity) != freeCapacity) {
|
||||
m_localPlayer->setStatistic(Otc::FreeCapacity, freeCapacity);
|
||||
g_lua.callGlobalField("g_game", "onFreeCapacityChange", freeCapacity);
|
||||
}
|
||||
|
||||
if(m_localPlayer->getStatistic(Otc::Experience) != experience) {
|
||||
m_localPlayer->setStatistic(Otc::Experience, experience);
|
||||
g_lua.callGlobalField("g_game", "onExperienceChange", experience);
|
||||
}
|
||||
|
||||
if(m_localPlayer->getStatistic(Otc::Level) != level ||
|
||||
m_localPlayer->getStatistic(Otc::LevelPercent) != levelPercent) {
|
||||
m_localPlayer->setStatistic(Otc::Level, level);
|
||||
m_localPlayer->setStatistic(Otc::LevelPercent, levelPercent);
|
||||
g_lua.callGlobalField("g_game", "onLevelChange", level, levelPercent);
|
||||
}
|
||||
|
||||
if(m_localPlayer->getStatistic(Otc::Mana) != mana ||
|
||||
m_localPlayer->getStatistic(Otc::MaxMana) != maxMana) {
|
||||
m_localPlayer->setStatistic(Otc::Mana, mana);
|
||||
m_localPlayer->setStatistic(Otc::MaxMana, maxMana);
|
||||
g_lua.callGlobalField("g_game", "onManaChange", mana, maxMana);
|
||||
}
|
||||
|
||||
if(m_localPlayer->getStatistic(Otc::MagicLevel) != magicLevel ||
|
||||
m_localPlayer->getStatistic(Otc::MagicLevelPercent) != magicLevelPercent) {
|
||||
m_localPlayer->setStatistic(Otc::MagicLevel, magicLevel);
|
||||
m_localPlayer->setStatistic(Otc::MagicLevelPercent, magicLevelPercent);
|
||||
g_lua.callGlobalField("g_game", "onMagicLevelChange", magicLevel, magicLevelPercent);
|
||||
}
|
||||
|
||||
if(m_localPlayer->getStatistic(Otc::Soul) != soul) {
|
||||
m_localPlayer->setStatistic(Otc::Soul, soul);
|
||||
g_lua.callGlobalField("g_game", "onSoulChange", soul);
|
||||
}
|
||||
|
||||
if(m_localPlayer->getStatistic(Otc::Stamina) != stamina) {
|
||||
m_localPlayer->setStatistic(Otc::Stamina, stamina);
|
||||
g_lua.callGlobalField("g_game", "onStaminaChange", stamina);
|
||||
}
|
||||
}
|
||||
|
||||
void Game::processTextMessage(const std::string& type, const std::string& message)
|
||||
{
|
||||
g_lua.callGlobalField("g_game","onTextMessage", type, message);
|
||||
|
@ -230,12 +167,27 @@ void Game::processOpenContainer(int containerId, int itemId, const std::string&
|
|||
g_lua.callGlobalField("g_game", "onOpenContainer", containerId, itemId, name, capacity, hasParent, items);
|
||||
}
|
||||
|
||||
void Game::processCloseContainer(int containerId)
|
||||
{
|
||||
g_lua.callGlobalField("g_game", "onCloseContainer", containerId);
|
||||
}
|
||||
|
||||
void Game::processContainerAddItem(int containerId, const ItemPtr& item)
|
||||
{
|
||||
item->setPosition(Position(65535, containerId + 0x40, 0));
|
||||
g_lua.callGlobalField("g_game", "onContainerAddItem", containerId, item);
|
||||
}
|
||||
|
||||
void Game::processContainerUpdateItem(int containerId, int slot, const ItemPtr& item)
|
||||
{
|
||||
g_lua.callGlobalField("g_game", "onContainerUpdateItem", containerId, slot, item);
|
||||
}
|
||||
|
||||
void Game::processContainerRemoveItem(int containerId, int slot)
|
||||
{
|
||||
g_lua.callGlobalField("g_game", "onContainerRemoveItem", containerId, slot);
|
||||
}
|
||||
|
||||
void Game::processInventoryChange(int slot, const ItemPtr& item)
|
||||
{
|
||||
if(item)
|
||||
|
@ -261,6 +213,95 @@ void Game::processCreatureTeleport(const CreaturePtr& creature)
|
|||
m_localPlayer->lockWalk();
|
||||
}
|
||||
|
||||
void Game::processChannelList(const std::vector<std::tuple<int, std::string>>& channelList)
|
||||
{
|
||||
g_lua.callGlobalField("g_game", "onChannelList", channelList);
|
||||
}
|
||||
|
||||
void Game::processOpenChannel(int channelId, const std::string& name)
|
||||
{
|
||||
g_lua.callGlobalField("g_game", "onOpenChannel", channelId, name);
|
||||
}
|
||||
|
||||
void Game::processOpenPrivateChannel(const std::string& name)
|
||||
{
|
||||
g_lua.callGlobalField("g_game", "onOpenPrivateChannel", name);
|
||||
}
|
||||
|
||||
void Game::processOpenOwnPrivateChannel(int channelId, const std::string& name)
|
||||
{
|
||||
g_lua.callGlobalField("g_game", "onOpenOwnPrivateChannel", channelId, name);
|
||||
}
|
||||
|
||||
void Game::processCloseChannel(int channelId)
|
||||
{
|
||||
g_lua.callGlobalField("g_game", "onCloseChannel", channelId);
|
||||
}
|
||||
|
||||
void Game::processVipAdd(uint id, const std::string& name, bool online)
|
||||
{
|
||||
g_lua.callGlobalField("g_game", "onAddVip", id, name, online);
|
||||
}
|
||||
|
||||
void Game::processVipStateChange(uint id, bool online)
|
||||
{
|
||||
g_lua.callGlobalField("g_game", "onVipStateChange", id, online);
|
||||
}
|
||||
|
||||
void Game::processOpenOutfitWindow(const Outfit& currentOufit, const std::vector<std::tuple<int, std::string, int>>& outfitList)
|
||||
{
|
||||
CreaturePtr virtualCreature = CreaturePtr(new Creature);
|
||||
virtualCreature->setDirection(Otc::South);
|
||||
virtualCreature->setOutfit(currentOufit);
|
||||
|
||||
g_lua.callGlobalField("g_game", "onOpenOutfitWindow", virtualCreature, outfitList);
|
||||
}
|
||||
|
||||
void Game::processOpenNpcTrade(const std::vector<std::tuple<ItemPtr, std::string, int, int, int>>& items)
|
||||
{
|
||||
g_lua.callGlobalField("g_game", "onOpenNpcTrade", items);
|
||||
}
|
||||
|
||||
void Game::processPlayerGoods(int money, const std::vector<std::tuple<ItemPtr, int>>& goods)
|
||||
{
|
||||
g_lua.callGlobalField("g_game", "onPlayerGoods", goods);
|
||||
}
|
||||
|
||||
void Game::processCloseNpcTrade()
|
||||
{
|
||||
g_lua.callGlobalField("g_game", "onCloseNpcTrade");
|
||||
}
|
||||
|
||||
void Game::processOpenTrade(const std::string& name, const std::vector<ItemPtr>& items)
|
||||
{
|
||||
g_lua.callGlobalField("g_game", "onOpenTrade", name, items);
|
||||
}
|
||||
|
||||
void Game::processCloseTrade()
|
||||
{
|
||||
g_lua.callGlobalField("g_game", "onCloseTrade");
|
||||
}
|
||||
|
||||
void Game::processEditText(int id, int itemId, int maxLength, const std::string& text, const std::string& writter, const std::string& date)
|
||||
{
|
||||
g_lua.callGlobalField("g_game", "onEditText", id, itemId, maxLength, text, writter, date);
|
||||
}
|
||||
|
||||
void Game::processEditList(int listId, int id, const std::string& text)
|
||||
{
|
||||
g_lua.callGlobalField("g_game", "onEditList", listId, id, text);
|
||||
}
|
||||
|
||||
void Game::processQuestLog(const std::vector<std::tuple<int, std::string, bool>>& questList)
|
||||
{
|
||||
g_lua.callGlobalField("g_game", "onQuestLog", questList);
|
||||
}
|
||||
|
||||
void Game::processQuestLine(int questId, const std::vector<std::tuple<std::string, std::string>>& questMissions)
|
||||
{
|
||||
g_lua.callGlobalField("g_game", "onQuestLine", questId, questMissions);
|
||||
}
|
||||
|
||||
void Game::processAttackCancel()
|
||||
{
|
||||
if(isAttacking())
|
||||
|
@ -688,7 +729,7 @@ void Game::addVip(const std::string& name)
|
|||
|
||||
void Game::removeVip(int playerId)
|
||||
{
|
||||
if(!isOnline() || !checkBotProtection())
|
||||
if(!canPerformGameAction())
|
||||
return;
|
||||
m_protocolGame->sendRemoveVip(playerId);
|
||||
}
|
||||
|
@ -715,11 +756,95 @@ void Game::setSafeFight(bool on)
|
|||
{
|
||||
if(!canPerformGameAction())
|
||||
return;
|
||||
|
||||
m_safeFight = on;
|
||||
m_protocolGame->sendChangeFightModes(m_fightMode, m_chaseMode, m_safeFight);
|
||||
}
|
||||
|
||||
|
||||
void Game::inspectNpcTrade(const ItemPtr& item)
|
||||
{
|
||||
if(!canPerformGameAction() || !item)
|
||||
return;
|
||||
m_protocolGame->sendInspectNpcTrade(item->getId(), item->getCount());
|
||||
}
|
||||
|
||||
void Game::buyItem(const ItemPtr& item, int amount, bool ignoreCapacity, bool buyWithBackpack)
|
||||
{
|
||||
if(!canPerformGameAction() || !item)
|
||||
return;
|
||||
m_protocolGame->sendBuyItem(item->getId(), item->getCount(), amount, ignoreCapacity, buyWithBackpack);
|
||||
}
|
||||
|
||||
void Game::sellItem(const ItemPtr& item, int amount, bool ignoreEquipped)
|
||||
{
|
||||
if(!canPerformGameAction() || !item)
|
||||
return;
|
||||
m_protocolGame->sendSellItem(item->getId(), item->getCount(), amount, ignoreEquipped);
|
||||
}
|
||||
|
||||
void Game::closeNpcTrade()
|
||||
{
|
||||
if(!canPerformGameAction())
|
||||
return;
|
||||
m_protocolGame->sendCloseNpcTrade();
|
||||
}
|
||||
|
||||
void Game::requestTrade(const ItemPtr& item, const CreaturePtr& creature)
|
||||
{
|
||||
if(!canPerformGameAction())
|
||||
return;
|
||||
m_protocolGame->sendRequestTrade(item->getPosition(), item->getId(), item->getStackpos(), creature->getId());
|
||||
}
|
||||
|
||||
void Game::inspectTrade(bool counterOffer, int index)
|
||||
{
|
||||
if(!canPerformGameAction())
|
||||
return;
|
||||
m_protocolGame->sendInspectTrade(counterOffer, index);
|
||||
}
|
||||
|
||||
void Game::acceptTrade()
|
||||
{
|
||||
if(!canPerformGameAction())
|
||||
return;
|
||||
m_protocolGame->sendAcceptTrade();
|
||||
}
|
||||
|
||||
void Game::rejectTrade()
|
||||
{
|
||||
if(!canPerformGameAction())
|
||||
return;
|
||||
m_protocolGame->sendRejectTrade();
|
||||
}
|
||||
|
||||
void Game::editText(uint id, const std::string& text)
|
||||
{
|
||||
if(!canPerformGameAction())
|
||||
return;
|
||||
m_protocolGame->sendEditText(id, text);
|
||||
}
|
||||
|
||||
void Game::editList(int listId, uint id, const std::string& text)
|
||||
{
|
||||
if(!canPerformGameAction())
|
||||
return;
|
||||
m_protocolGame->sendEditList(listId, id, text);
|
||||
}
|
||||
|
||||
void Game::requestQuestLog()
|
||||
{
|
||||
if(!canPerformGameAction())
|
||||
return;
|
||||
m_protocolGame->sendRequestQuestLog();
|
||||
}
|
||||
|
||||
void Game::requestQuestLine(int questId)
|
||||
{
|
||||
if(!canPerformGameAction())
|
||||
return;
|
||||
m_protocolGame->sendRequestQuestLine(questId);
|
||||
}
|
||||
|
||||
bool Game::checkBotProtection()
|
||||
{
|
||||
#ifdef BOT_PROTECTION
|
||||
|
|
|
@ -38,66 +38,6 @@ private:
|
|||
void resetGameStates();
|
||||
|
||||
protected:
|
||||
|
||||
/*
|
||||
void parseMapDescription(InputMessage& msg);
|
||||
void parseMapMoveNorth(InputMessage& msg);
|
||||
void parseMapMoveEast(InputMessage& msg);
|
||||
void parseMapMoveSouth(InputMessage& msg);
|
||||
void parseMapMoveWest(InputMessage& msg);
|
||||
void parseUpdateTile(InputMessage& msg);
|
||||
void parseTileAddThing(InputMessage& msg);
|
||||
void parseTileTransformThing(InputMessage& msg);
|
||||
void parseTileRemoveThing(InputMessage& msg);
|
||||
void parseCreatureMove(InputMessage& msg);
|
||||
|
||||
void parseOpenContainer(InputMessage& msg);
|
||||
void parseCloseContainer(InputMessage& msg);
|
||||
void parseContainerAddItem(InputMessage& msg);
|
||||
void parseContainerUpdateItem(InputMessage& msg);
|
||||
void parseContainerRemoveItem(InputMessage& msg);
|
||||
|
||||
void parseAddInventoryItem(InputMessage& msg);
|
||||
void parseRemoveInventoryItem(InputMessage& msg);
|
||||
|
||||
void parseNpcOffer(InputMessage& msg);
|
||||
void parsePlayerCash(InputMessage& msg);
|
||||
void parseCloseShopWindow(InputMessage&);
|
||||
|
||||
void parseWorldLight(InputMessage& msg);
|
||||
|
||||
void parseMagicEffect(InputMessage& msg);
|
||||
void parseAnimatedText(InputMessage& msg);
|
||||
void parseDistanceMissile(InputMessage& msg);
|
||||
|
||||
void parseCreatureSquare(InputMessage& msg);
|
||||
void parseCreatureHealth(InputMessage& msg);
|
||||
void parseCreatureLight(InputMessage& msg);
|
||||
void parseCreatureOutfit(InputMessage& msg);
|
||||
void parseCreatureSpeed(InputMessage& msg);
|
||||
void parseCreatureSkulls(InputMessage& msg);
|
||||
void parseCreatureShields(InputMessage& msg);
|
||||
void parseCreatureTurn(InputMessage& msg);
|
||||
|
||||
void parseItemTextWindow(InputMessage& msg);
|
||||
void parseHouseTextWindow(InputMessage& msg);
|
||||
void parsePlayerStats(InputMessage& msg);
|
||||
void parsePlayerSkills(InputMessage& msg);
|
||||
void parsePlayerIcons(InputMessage& msg);
|
||||
void parsePlayerCancelAttack(InputMessage& msg);
|
||||
void parseCreatureSpeak(InputMessage& msg);
|
||||
void parseCloseChannel(InputMessage& msg);
|
||||
void parseSafeTradeRequest(InputMessage& msg);
|
||||
void parseSafeTradeClose(InputMessage&);
|
||||
void parseTextMessage(InputMessage& msg);
|
||||
void parseCancelWalk(InputMessage& msg);
|
||||
void parseFloorChangeUp(InputMessage& msg);
|
||||
void parseFloorChangeDown(InputMessage& msg);
|
||||
void parseOutfitWindow(InputMessage& msg);
|
||||
void parseShowTutorial(InputMessage& msg);
|
||||
void parseAddMarker(InputMessage& msg);
|
||||
*/
|
||||
|
||||
void processConnectionError(const boost::system::error_code& error);
|
||||
void processDisconnect();
|
||||
void processPing();
|
||||
|
@ -119,11 +59,6 @@ protected:
|
|||
double mana, double maxMana,
|
||||
double magicLevel, double magicLevelPercent,
|
||||
double soul, double stamina);
|
||||
void processTextMessage(const std::string& type, const std::string& message);
|
||||
void processCreatureSpeak(const std::string& name, int level, Otc::SpeakType type, const std::string& message, int channelId, const Position& creaturePos);
|
||||
|
||||
void processOpenContainer(int containerId, int itemId, const std::string& name, int capacity, bool hasParent, const std::vector<ItemPtr>& items);
|
||||
void processContainerAddItem(int containerId, const ItemPtr& item);
|
||||
|
||||
void processInventoryChange(int slot, const ItemPtr& item);
|
||||
void processCreatureMove(const CreaturePtr& creature, const Position& oldPos, const Position& newPos);
|
||||
|
@ -131,18 +66,47 @@ protected:
|
|||
void processAttackCancel();
|
||||
void processWalkCancel(Otc::Direction direction);
|
||||
|
||||
// processChannelList
|
||||
// processOpenChannel
|
||||
// processOpenPrivateChannel
|
||||
// processOpenOwnPrivateChannel
|
||||
// message related
|
||||
void processTextMessage(const std::string& type, const std::string& message);
|
||||
void processCreatureSpeak(const std::string& name, int level, Otc::SpeakType type, const std::string& message, int channelId, const Position& creaturePos);
|
||||
|
||||
// vip
|
||||
// processVipList
|
||||
// processVipLogin
|
||||
// processVipLogout
|
||||
// container related
|
||||
void processOpenContainer(int containerId, int itemId, const std::string& name, int capacity, bool hasParent, const std::vector<ItemPtr>& items);
|
||||
void processCloseContainer(int containerId);
|
||||
void processContainerAddItem(int containerId, const ItemPtr& item);
|
||||
void processContainerUpdateItem(int containerId, int slot, const ItemPtr& item);
|
||||
void processContainerRemoveItem(int containerId, int slot);
|
||||
|
||||
// processQuestLog
|
||||
// processQuestLine
|
||||
// channel related
|
||||
void processChannelList(const std::vector<std::tuple<int, std::string>>& channelList);
|
||||
void processOpenChannel(int channelId, const std::string& name);
|
||||
void processOpenPrivateChannel(const std::string& name);
|
||||
void processOpenOwnPrivateChannel(int channelId, const std::string& name);
|
||||
void processCloseChannel(int channelId);
|
||||
|
||||
// vip related
|
||||
void processVipAdd(uint id, const std::string& name, bool online);
|
||||
void processVipStateChange(uint id, bool online);
|
||||
|
||||
// outfit
|
||||
void processOpenOutfitWindow(const Outfit& currentOufit, const std::vector<std::tuple<int, std::string, int>>& outfitList);
|
||||
|
||||
// npc trade
|
||||
void processOpenNpcTrade(const std::vector<std::tuple<ItemPtr, std::string, int, int, int>>& items);
|
||||
void processPlayerGoods(int money, const std::vector<std::tuple<ItemPtr, int>>& goods);
|
||||
void processCloseNpcTrade();
|
||||
|
||||
// player trade
|
||||
void processOpenTrade(const std::string& name, const std::vector<ItemPtr>& items);
|
||||
void processCloseTrade();
|
||||
|
||||
// edit text/list
|
||||
void processEditText(int id, int itemId, int maxLength, const std::string& text, const std::string& writter, const std::string& date);
|
||||
void processEditList(int listId, int id, const std::string& text);
|
||||
|
||||
// questlog
|
||||
void processQuestLog(const std::vector<std::tuple<int, std::string, bool>>& questList);
|
||||
void processQuestLine(int questId, const std::vector<std::tuple<std::string, std::string>>& questMissions);
|
||||
|
||||
friend class ProtocolGame;
|
||||
friend class Map;
|
||||
|
@ -225,24 +189,24 @@ public:
|
|||
bool isSafeFight() { return m_safeFight; }
|
||||
|
||||
// npc trade related
|
||||
//void inspectNpcTrade();
|
||||
//void buyItem();
|
||||
//void sellItem();
|
||||
//void closeNpcTrade();
|
||||
void inspectNpcTrade(const ItemPtr& item);
|
||||
void buyItem(const ItemPtr& item, int amount, bool ignoreCapacity, bool buyWithBackpack);
|
||||
void sellItem(const ItemPtr& item, int amount, bool ignoreEquipped);
|
||||
void closeNpcTrade();
|
||||
|
||||
// player trade related
|
||||
//void requestTrade();
|
||||
//void inspectTrade();
|
||||
//void acceptTrade();
|
||||
//void rejectTrade();
|
||||
void requestTrade(const ItemPtr& item, const CreaturePtr& creature);
|
||||
void inspectTrade(bool counterOffer, int index);
|
||||
void acceptTrade();
|
||||
void rejectTrade();
|
||||
|
||||
// house window and editable items related
|
||||
//void editText();
|
||||
//void editList();
|
||||
void editText(uint id, const std::string& text);
|
||||
void editList(int listId, uint id, const std::string& text);
|
||||
|
||||
// questlog related
|
||||
//void requestQuestLog();
|
||||
//void requestQuestLogLine();
|
||||
void requestQuestLog();
|
||||
void requestQuestLine(int questId);
|
||||
|
||||
bool canPerformGameAction();
|
||||
bool checkBotProtection();
|
||||
|
|
|
@ -39,11 +39,10 @@ Item::Item() : Thing()
|
|||
|
||||
ItemPtr Item::create(int id)
|
||||
{
|
||||
if(id < g_thingsType.getFirstItemId() || id > g_thingsType.getMaxItemid()) {
|
||||
logTraceError("invalid item id ", id);
|
||||
return nullptr;
|
||||
}
|
||||
ItemPtr item = ItemPtr(new Item);
|
||||
if(id < g_thingsType.getFirstItemId() || id > g_thingsType.getMaxItemid())
|
||||
logTraceError("invalid item id ", id);
|
||||
else
|
||||
item->setId(id);
|
||||
return item;
|
||||
}
|
||||
|
|
|
@ -28,13 +28,26 @@
|
|||
LocalPlayer::LocalPlayer()
|
||||
{
|
||||
m_preWalking = false;
|
||||
m_known = false;
|
||||
m_walkLocked = false;
|
||||
m_lastPrewalkDone = true;
|
||||
m_icons = 0;
|
||||
m_known = false;
|
||||
m_states = 0;
|
||||
|
||||
for(int i = 0; i < Otc::LastStatistic; ++i)
|
||||
m_statistics[i] = -1; // sets an invalid value to ensure lua event will be sent
|
||||
m_skillsLevel.fill(-1);
|
||||
m_skillsLevelPercent.fill(-1);
|
||||
|
||||
m_health = -1;
|
||||
m_maxHealth = -1;
|
||||
m_freeCapacity = -1;
|
||||
m_experience = -1;
|
||||
m_level = -1;
|
||||
m_levelPercent = -1;
|
||||
m_mana = -1;
|
||||
m_maxMana = -1;
|
||||
m_magicLevel = -1;
|
||||
m_magicLevelPercent = -1;
|
||||
m_soul = -1;
|
||||
m_stamina = -1;
|
||||
}
|
||||
|
||||
void LocalPlayer::lockWalk()
|
||||
|
@ -47,6 +60,28 @@ void LocalPlayer::lockWalk()
|
|||
m_walkLockTimer.restart();
|
||||
}
|
||||
|
||||
bool LocalPlayer::canWalk(Otc::Direction direction)
|
||||
{
|
||||
// prewalk has a timeout, because for some reason that I don't know yet the server sometimes doesn't answer the prewalk
|
||||
bool prewalkTimeouted = m_walking && m_preWalking && m_walkTimer.ticksElapsed() >= m_walkInterval + PREWALK_TIMEOUT;
|
||||
|
||||
// cannot walk while already walking
|
||||
if(m_walking && !prewalkTimeouted)
|
||||
return false;
|
||||
|
||||
// avoid doing more walks than wanted when receiving a lot of walks from server
|
||||
if(!m_lastPrewalkDone && m_preWalking && !prewalkTimeouted)
|
||||
return false;
|
||||
|
||||
// cannot walk while locked
|
||||
if(m_walkLocked && m_walkLockTimer.ticksElapsed() <= WALK_LOCK_INTERVAL)
|
||||
return false;
|
||||
else
|
||||
m_walkLocked = false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void LocalPlayer::walk(const Position& oldPos, const Position& newPos)
|
||||
{
|
||||
Otc::Direction direction = oldPos.getDirectionFromPosition(newPos);
|
||||
|
@ -76,28 +111,6 @@ void LocalPlayer::preWalk(Otc::Direction direction)
|
|||
Creature::walk(m_position, newPos);
|
||||
}
|
||||
|
||||
bool LocalPlayer::canWalk(Otc::Direction direction)
|
||||
{
|
||||
// prewalk has a timeout, because for some reason that I don't know yet the server sometimes doesn't answer the prewalk
|
||||
bool prewalkTimeouted = m_walking && m_preWalking && m_walkTimer.ticksElapsed() >= m_walkInterval + PREWALK_TIMEOUT;
|
||||
|
||||
// cannot walk while already walking
|
||||
if(m_walking && !prewalkTimeouted)
|
||||
return false;
|
||||
|
||||
// avoid doing more walks than wanted when receiving a lot of walks from server
|
||||
if(!m_lastPrewalkDone && m_preWalking && !prewalkTimeouted)
|
||||
return false;
|
||||
|
||||
// cannot walk while locked
|
||||
if(m_walkLocked && m_walkLockTimer.ticksElapsed() <= WALK_LOCK_INTERVAL)
|
||||
return false;
|
||||
else
|
||||
m_walkLocked = false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void LocalPlayer::cancelWalk(Otc::Direction direction)
|
||||
{
|
||||
// only cancel client side walks
|
||||
|
@ -156,3 +169,120 @@ void LocalPlayer::terminateWalk()
|
|||
Creature::terminateWalk();
|
||||
m_preWalking = false;
|
||||
}
|
||||
|
||||
void LocalPlayer::setStates(int states)
|
||||
{
|
||||
if(m_states != states) {
|
||||
int oldStates = m_states;
|
||||
m_states = states;
|
||||
callLuaField("onStatesChange", states, oldStates);
|
||||
}
|
||||
}
|
||||
|
||||
void LocalPlayer::setSkill(Otc::Skill skill, int level, int levelPercent)
|
||||
{
|
||||
int oldLevel = m_skillsLevel[skill];
|
||||
int oldLevelPercent = m_skillsLevelPercent[skill];
|
||||
|
||||
if(level != oldLevel && levelPercent != oldLevelPercent) {
|
||||
m_skillsLevel[skill] = level;
|
||||
m_skillsLevelPercent[skill] = levelPercent;
|
||||
|
||||
callLuaField("onSkillChange", skill, level, levelPercent, oldLevel, oldLevelPercent);
|
||||
}
|
||||
}
|
||||
|
||||
void LocalPlayer::setHealth(double health, double maxHealth)
|
||||
{
|
||||
if(m_health != health || m_maxHealth != maxHealth) {
|
||||
double oldHealth = m_health;
|
||||
double oldMaxHealth = m_maxHealth;
|
||||
m_health = health;
|
||||
m_maxHealth = maxHealth;
|
||||
|
||||
callLuaField("onHealthChange", health, maxHealth, oldHealth, oldMaxHealth);
|
||||
|
||||
// cannot walk while dying
|
||||
if(health == 0) {
|
||||
if(isPreWalking())
|
||||
stopWalk();
|
||||
lockWalk();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LocalPlayer::setFreeCapacity(double freeCapacity)
|
||||
{
|
||||
if(m_freeCapacity != freeCapacity) {
|
||||
double oldFreeCapacity = m_freeCapacity;
|
||||
m_freeCapacity = freeCapacity;
|
||||
|
||||
callLuaField("onFreeCapacityChange", freeCapacity, oldFreeCapacity);
|
||||
}
|
||||
}
|
||||
|
||||
void LocalPlayer::setExperience(double experience)
|
||||
{
|
||||
if(m_experience != experience) {
|
||||
double oldExperience = m_experience;
|
||||
m_experience = experience;
|
||||
|
||||
callLuaField("onExperienceChange", experience, oldExperience);
|
||||
}
|
||||
}
|
||||
|
||||
void LocalPlayer::setLevel(double level, double levelPercent)
|
||||
{
|
||||
if(m_level != level || m_levelPercent != m_levelPercent) {
|
||||
double oldLevel = m_level;
|
||||
double oldLevelPercent = m_levelPercent;
|
||||
m_level = level;
|
||||
m_levelPercent = levelPercent;
|
||||
|
||||
callLuaField("onLevelChange", level, levelPercent, oldLevel, oldLevelPercent);
|
||||
}
|
||||
}
|
||||
|
||||
void LocalPlayer::setMana(double mana, double maxMana)
|
||||
{
|
||||
if(m_mana != mana || m_maxMana != maxMana) {
|
||||
double oldMana = m_mana;
|
||||
double oldMaxMana;
|
||||
m_mana = mana;
|
||||
m_maxMana = maxMana;
|
||||
|
||||
callLuaField("onManaChange", mana, maxMana, oldMana, oldMaxMana);
|
||||
}
|
||||
}
|
||||
|
||||
void LocalPlayer::setMagicLevel(double magicLevel, double magicLevelPercent)
|
||||
{
|
||||
if(m_magicLevel != magicLevel || m_magicLevelPercent != magicLevelPercent) {
|
||||
double oldMagicLevel = m_magicLevel;
|
||||
double oldMagicLevelPercent = m_magicLevelPercent;
|
||||
m_magicLevel = magicLevel;
|
||||
m_magicLevelPercent = magicLevelPercent;
|
||||
|
||||
callLuaField("onMagicLevelChange", magicLevel, magicLevelPercent, oldMagicLevel, oldMagicLevelPercent);
|
||||
}
|
||||
}
|
||||
|
||||
void LocalPlayer::setSoul(double soul)
|
||||
{
|
||||
if(m_soul != soul) {
|
||||
double oldSoul = m_soul;
|
||||
m_soul = soul;
|
||||
|
||||
callLuaField("onSoulChange", soul, oldSoul);
|
||||
}
|
||||
}
|
||||
|
||||
void LocalPlayer::setStamina(double stamina)
|
||||
{
|
||||
if(m_stamina != stamina) {
|
||||
double oldStamina = m_stamina;
|
||||
m_stamina = stamina;
|
||||
|
||||
callLuaField("onStaminaChange", stamina, oldStamina);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,43 +31,54 @@ class LocalPlayer : public Player
|
|||
WALK_LOCK_INTERVAL = 250,
|
||||
PREWALK_TIMEOUT = 1000
|
||||
};
|
||||
|
||||
public:
|
||||
LocalPlayer();
|
||||
|
||||
void setSkill(Otc::Skill skill, Otc::SkillType skillType, int value) { m_skills[skill][skillType] = value; }
|
||||
void setStatistic(Otc::Statistic statistic, double value) { m_statistics[statistic] = value; }
|
||||
void setIcons(int icons) { m_icons = icons; }
|
||||
void unlockWalk() { m_walkLocked = false; }
|
||||
void lockWalk();
|
||||
bool canWalk(Otc::Direction direction);
|
||||
|
||||
void setStates(int states);
|
||||
void setSkill(Otc::Skill skill, int level, int levelPercent);
|
||||
void setHealth(double health, double maxHealth);
|
||||
void setFreeCapacity(double freeCapacity);
|
||||
void setExperience(double experience);
|
||||
void setLevel(double level, double levelPercent);
|
||||
void setMana(double mana, double maxMana);
|
||||
void setMagicLevel(double magicLevel, double magicLevelPercent);
|
||||
void setSoul(double soul);
|
||||
void setStamina(double stamina);
|
||||
void setKnown(bool known) { m_known = known; }
|
||||
|
||||
int getSkill(Otc::Skill skill, Otc::SkillType skillType) { return m_skills[skill][skillType]; }
|
||||
double getStatistic(Otc::Statistic statistic) { return m_statistics[statistic]; }
|
||||
int getIcons() { return m_icons; }
|
||||
int getStates() { return m_states; }
|
||||
int getSkillLevel(Otc::Skill skill) { return m_skillsLevel[skill]; }
|
||||
int getSkillLevelPercent(Otc::Skill skill) { return m_skillsLevelPercent[skill]; }
|
||||
double getHealth() { return m_health; }
|
||||
double getMaxHealth() { return m_maxHealth; }
|
||||
double getFreeCapacity() { return m_freeCapacity; }
|
||||
double getExperience() { return m_experience; }
|
||||
double getLevel() { return m_level; }
|
||||
double getLevelPercent() { return m_levelPercent; }
|
||||
double getMana() { return m_mana; }
|
||||
double getMaxMana() { return m_maxMana; }
|
||||
double getMagicLevel() { return m_magicLevel; }
|
||||
double getMagicLevelPercent() { return m_magicLevelPercent; }
|
||||
double getSoul() { return m_soul; }
|
||||
double getStamina() { return m_stamina; }
|
||||
|
||||
bool isKnown() { return m_known; }
|
||||
bool isPreWalking() { return m_preWalking; }
|
||||
|
||||
void unlockWalk() { m_walkLocked = false; }
|
||||
void lockWalk();
|
||||
LocalPlayerPtr asLocalPlayer() { return std::static_pointer_cast<LocalPlayer>(shared_from_this()); }
|
||||
|
||||
protected:
|
||||
void walk(const Position& oldPos, const Position& newPos);
|
||||
void preWalk(Otc::Direction direction);
|
||||
bool canWalk(Otc::Direction direction);
|
||||
void cancelWalk(Otc::Direction direction = Otc::InvalidDirection);
|
||||
void stopWalk();
|
||||
|
||||
LocalPlayerPtr asLocalPlayer() { return std::static_pointer_cast<LocalPlayer>(shared_from_this()); }
|
||||
|
||||
double getHealth() { return getStatistic(Otc::Health); }
|
||||
double getMaxHealth() { return getStatistic(Otc::MaxHealth); }
|
||||
double getFreeCapacity() { return getStatistic(Otc::FreeCapacity); }
|
||||
double getExperience() { return getStatistic(Otc::Experience); }
|
||||
double getLevel() { return getStatistic(Otc::Level); }
|
||||
double getLevelPercent() { return getStatistic(Otc::LevelPercent); }
|
||||
double getMana() { return getStatistic(Otc::Mana); }
|
||||
double getMaxMana() { return getStatistic(Otc::MaxMana); }
|
||||
double getMagicLevel() { return getStatistic(Otc::MagicLevel); }
|
||||
double getMagicLevelPercent() { return getStatistic(Otc::MagicLevelPercent); }
|
||||
double getSoul() { return getStatistic(Otc::Soul); }
|
||||
double getStamina() { return getStatistic(Otc::Stamina); }
|
||||
friend class Game;
|
||||
|
||||
protected:
|
||||
void updateWalkOffset(int totalPixelsWalked);
|
||||
|
@ -82,10 +93,24 @@ private:
|
|||
Position m_lastPrewalkDestionation;
|
||||
Timer m_walkLockTimer;
|
||||
|
||||
std::array<int, Otc::LastSkill> m_skillsLevel;
|
||||
std::array<int, Otc::LastSkill> m_skillsLevelPercent;
|
||||
|
||||
bool m_known;
|
||||
int m_icons;
|
||||
int m_skills[Otc::LastSkill][Otc::LastSkillType];
|
||||
double m_statistics[Otc::LastStatistic];
|
||||
int m_states;
|
||||
|
||||
double m_health;
|
||||
double m_maxHealth;
|
||||
double m_freeCapacity;
|
||||
double m_experience;
|
||||
double m_level;
|
||||
double m_levelPercent;
|
||||
double m_mana;
|
||||
double m_maxMana;
|
||||
double m_magicLevel;
|
||||
double m_magicLevelPercent;
|
||||
double m_soul;
|
||||
double m_stamina;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -128,6 +128,18 @@ void OTClient::registerLuaFunctions()
|
|||
g_lua.bindClassStaticFunction("g_game", "getChaseMode", std::bind(&Game::getChaseMode, &g_game));
|
||||
g_lua.bindClassStaticFunction("g_game", "getFightMode", std::bind(&Game::getFightMode, &g_game));
|
||||
g_lua.bindClassStaticFunction("g_game", "isSafeFight", std::bind(&Game::isSafeFight, &g_game));
|
||||
g_lua.bindClassStaticFunction("g_game", "inspectNpcTrade", std::bind(&Game::inspectNpcTrade, &g_game, _1));
|
||||
g_lua.bindClassStaticFunction("g_game", "buyItem", std::bind(&Game::buyItem, &g_game, _1, _2, _3, _4));
|
||||
g_lua.bindClassStaticFunction("g_game", "sellItem", std::bind(&Game::sellItem, &g_game, _1, _2, _3));
|
||||
g_lua.bindClassStaticFunction("g_game", "closeNpcTrade", std::bind(&Game::closeNpcTrade, &g_game));
|
||||
g_lua.bindClassStaticFunction("g_game", "requestTrade", std::bind(&Game::requestTrade, &g_game, _1, _2));
|
||||
g_lua.bindClassStaticFunction("g_game", "inspectTrade", std::bind(&Game::inspectTrade, &g_game, _1, _2));
|
||||
g_lua.bindClassStaticFunction("g_game", "acceptTrade", std::bind(&Game::acceptTrade, &g_game));
|
||||
g_lua.bindClassStaticFunction("g_game", "rejectTrade", std::bind(&Game::rejectTrade, &g_game));
|
||||
g_lua.bindClassStaticFunction("g_game", "editText", std::bind(&Game::editText, &g_game, _1, _2));
|
||||
g_lua.bindClassStaticFunction("g_game", "editList", std::bind(&Game::editList, &g_game, _1, _2, _3));
|
||||
g_lua.bindClassStaticFunction("g_game", "requestQuestLog", std::bind(&Game::requestQuestLog, &g_game));
|
||||
g_lua.bindClassStaticFunction("g_game", "requestQuestLine", std::bind(&Game::requestQuestLine, &g_game, _1));
|
||||
g_lua.bindClassStaticFunction("g_game", "canPerformGameAction", std::bind(&Game::canPerformGameAction, &g_game));
|
||||
g_lua.bindClassStaticFunction("g_game", "checkBotProtection", std::bind(&Game::checkBotProtection, &g_game));
|
||||
g_lua.bindClassStaticFunction("g_game", "isOnline", std::bind(&Game::isOnline, &g_game));
|
||||
|
@ -212,7 +224,25 @@ void OTClient::registerLuaFunctions()
|
|||
g_lua.bindClassMemberFunction<Creature>("isWalking", &Creature::isWalking);
|
||||
g_lua.registerClass<Npc, Creature>();
|
||||
g_lua.registerClass<Monster, Creature>();
|
||||
|
||||
g_lua.registerClass<LocalPlayer, Player>();
|
||||
g_lua.bindClassMemberFunction<LocalPlayer>("unlockWalk", &LocalPlayer::unlockWalk);
|
||||
g_lua.bindClassMemberFunction<LocalPlayer>("lockWalk", &LocalPlayer::lockWalk);
|
||||
g_lua.bindClassMemberFunction<LocalPlayer>("canWalk", &LocalPlayer::canWalk);
|
||||
g_lua.bindClassMemberFunction<LocalPlayer>("setStates", &LocalPlayer::setStates);
|
||||
g_lua.bindClassMemberFunction<LocalPlayer>("setSkill", &LocalPlayer::setSkill);
|
||||
g_lua.bindClassMemberFunction<LocalPlayer>("setHealth", &LocalPlayer::setHealth);
|
||||
g_lua.bindClassMemberFunction<LocalPlayer>("setFreeCapacity", &LocalPlayer::setFreeCapacity);
|
||||
g_lua.bindClassMemberFunction<LocalPlayer>("setExperience", &LocalPlayer::setExperience);
|
||||
g_lua.bindClassMemberFunction<LocalPlayer>("setLevel", &LocalPlayer::setLevel);
|
||||
g_lua.bindClassMemberFunction<LocalPlayer>("setMana", &LocalPlayer::setMana);
|
||||
g_lua.bindClassMemberFunction<LocalPlayer>("setMagicLevel", &LocalPlayer::setMagicLevel);
|
||||
g_lua.bindClassMemberFunction<LocalPlayer>("setSoul", &LocalPlayer::setSoul);
|
||||
g_lua.bindClassMemberFunction<LocalPlayer>("setStamina", &LocalPlayer::setStamina);
|
||||
g_lua.bindClassMemberFunction<LocalPlayer>("setKnown", &LocalPlayer::setKnown);
|
||||
g_lua.bindClassMemberFunction<LocalPlayer>("getStates", &LocalPlayer::getStates);
|
||||
g_lua.bindClassMemberFunction<LocalPlayer>("getSkillLevel", &LocalPlayer::getSkillLevel);
|
||||
g_lua.bindClassMemberFunction<LocalPlayer>("getSkillLevelPercent", &LocalPlayer::getSkillLevelPercent);
|
||||
g_lua.bindClassMemberFunction<LocalPlayer>("getHealth", &LocalPlayer::getHealth);
|
||||
g_lua.bindClassMemberFunction<LocalPlayer>("getMaxHealth", &LocalPlayer::getMaxHealth);
|
||||
g_lua.bindClassMemberFunction<LocalPlayer>("getFreeCapacity", &LocalPlayer::getFreeCapacity);
|
||||
|
@ -225,6 +255,9 @@ void OTClient::registerLuaFunctions()
|
|||
g_lua.bindClassMemberFunction<LocalPlayer>("getMagicLevelPercent", &LocalPlayer::getMagicLevelPercent);
|
||||
g_lua.bindClassMemberFunction<LocalPlayer>("getSoul", &LocalPlayer::getSoul);
|
||||
g_lua.bindClassMemberFunction<LocalPlayer>("getStamina", &LocalPlayer::getStamina);
|
||||
g_lua.bindClassMemberFunction<LocalPlayer>("isKnown", &LocalPlayer::isKnown);
|
||||
g_lua.bindClassMemberFunction<LocalPlayer>("isPreWalking", &LocalPlayer::isPreWalking);
|
||||
g_lua.bindClassMemberFunction<LocalPlayer>("asLocalPlayer", &LocalPlayer::asLocalPlayer);
|
||||
|
||||
g_lua.registerClass<Tile>();
|
||||
g_lua.bindClassMemberFunction<Tile>("clean", &Tile::clean);
|
||||
|
|
|
@ -93,11 +93,11 @@ namespace Proto {
|
|||
GameServerDeleteInContainer = 114,
|
||||
GameServerSetInventory = 120,
|
||||
GameServerDeleteInventory = 121,
|
||||
GameServerNpcOffer = 122,
|
||||
GameServerOpenNpcTrade = 122,
|
||||
GameServerPlayerGoods = 123,
|
||||
GameServerCloseNpcTrade = 124,
|
||||
GameServerOwnOffer = 125,
|
||||
GameServerCounterOffer = 126,
|
||||
GameServerOwnTrade = 125,
|
||||
GameServerCounterTrade = 126,
|
||||
GameServerCloseTrade = 127,
|
||||
GameServerAmbient = 130,
|
||||
GameServerGraphicalEffect = 131,
|
||||
|
@ -135,7 +135,7 @@ namespace Proto {
|
|||
GameServerWait = 182,
|
||||
GameServerFloorChangeUp = 190,
|
||||
GameServerFloorChangeDown = 191,
|
||||
GameServerOutfit = 200,
|
||||
GameServerChooseOutfit = 200,
|
||||
GameServerVipAdd = 210,
|
||||
GameServerVipLogin = 211,
|
||||
GameServerVipLogout = 212,
|
||||
|
|
|
@ -56,10 +56,10 @@ public:
|
|||
void sendTurnEast();
|
||||
void sendTurnSouth();
|
||||
void sendTurnWest();
|
||||
void sendMove(const Position& fromPos, int thingId, int stackpos, const Position& toPos, int count);
|
||||
void sendInspectNpcTrade(int thingId, int count);
|
||||
void sendBuyItem(int thingId, int count, int amount, bool ignoreCapacity, bool buyWithBackpack);
|
||||
void sendSellItem(int thingId, int count, int amount, bool ignoreEquipped);
|
||||
void sendMove(const Position& fromPos, int itemId, int stackpos, const Position& toPos, int count);
|
||||
void sendInspectNpcTrade(int itemId, int count);
|
||||
void sendBuyItem(int itemId, int count, int amount, bool ignoreCapacity, bool buyWithBackpack);
|
||||
void sendSellItem(int itemId, int count, int amount, bool ignoreEquipped);
|
||||
void sendCloseNpcTrade();
|
||||
void sendRequestTrade(const Position& pos, int thingId, int stackpos, uint playerId);
|
||||
void sendInspectTrade(bool counterOffer, int index);
|
||||
|
@ -71,7 +71,7 @@ public:
|
|||
void sendRotateItem(const Position& pos, int thingId, int stackpos);
|
||||
void sendCloseContainer(int containerId);
|
||||
void sendUpContainer(int containerId);
|
||||
void sendEditText(uint textId, const std::string& text);
|
||||
void sendEditText(uint id, const std::string& text);
|
||||
void sendEditList(int listId, uint id, const std::string& text);
|
||||
void sendLook(const Position& position, int thingId, int stackpos);
|
||||
void sendTalk(Otc::SpeakType speakType, int channelId, const std::string& receiver, const std::string& message);
|
||||
|
@ -99,7 +99,7 @@ public:
|
|||
void sendAddVip(const std::string& name);
|
||||
void sendRemoveVip(uint playerId);
|
||||
void sendRequestQuestLog();
|
||||
void sendRequestQuestLine(int questLine);
|
||||
void sendRequestQuestLine(int questId);
|
||||
|
||||
private:
|
||||
void sendLoginPacket(uint timestamp, uint8 unknown);
|
||||
|
@ -131,14 +131,14 @@ private:
|
|||
void parseContainerRemoveItem(InputMessage& msg);
|
||||
void parseAddInventoryItem(InputMessage& msg);
|
||||
void parseRemoveInventoryItem(InputMessage& msg);
|
||||
void parseNpcOffer(InputMessage& msg);
|
||||
void parsePlayerCash(InputMessage& msg);
|
||||
void parseCloseShopWindow(InputMessage&);
|
||||
void parseOpenNpcTrade(InputMessage& msg);
|
||||
void parsePlayerGoods(InputMessage& msg);
|
||||
void parseCloseNpcTrade(InputMessage&);
|
||||
void parseWorldLight(InputMessage& msg);
|
||||
void parseMagicEffect(InputMessage& msg);
|
||||
void parseAnimatedText(InputMessage& msg);
|
||||
void parseDistanceMissile(InputMessage& msg);
|
||||
void parseCreatureSquare(InputMessage& msg);
|
||||
void parseCreatureMark(InputMessage& msg);
|
||||
void parseCreatureHealth(InputMessage& msg);
|
||||
void parseCreatureLight(InputMessage& msg);
|
||||
void parseCreatureOutfit(InputMessage& msg);
|
||||
|
@ -146,11 +146,11 @@ private:
|
|||
void parseCreatureSkulls(InputMessage& msg);
|
||||
void parseCreatureShields(InputMessage& msg);
|
||||
void parseCreatureTurn(InputMessage& msg);
|
||||
void parseItemTextWindow(InputMessage& msg);
|
||||
void parseHouseTextWindow(InputMessage& msg);
|
||||
void parseEditText(InputMessage& msg);
|
||||
void parseEditList(InputMessage& msg);
|
||||
void parsePlayerStats(InputMessage& msg);
|
||||
void parsePlayerSkills(InputMessage& msg);
|
||||
void parsePlayerIcons(InputMessage& msg);
|
||||
void parsePlayerState(InputMessage& msg);
|
||||
void parsePlayerCancelAttack(InputMessage& msg);
|
||||
void parseCreatureSpeak(InputMessage& msg);
|
||||
void parseChannelList(InputMessage& msg);
|
||||
|
@ -158,13 +158,13 @@ private:
|
|||
void parseOpenPrivateChannel(InputMessage& msg);
|
||||
void parseOpenOwnPrivateChannel(InputMessage& msg);
|
||||
void parseCloseChannel(InputMessage& msg);
|
||||
void parseSafeTradeRequest(InputMessage& msg);
|
||||
void parseSafeTradeClose(InputMessage&);
|
||||
void parseOpenTrade(InputMessage& msg);
|
||||
void parseCloseTrade(InputMessage&);
|
||||
void parseTextMessage(InputMessage& msg);
|
||||
void parseCancelWalk(InputMessage& msg);
|
||||
void parseFloorChangeUp(InputMessage& msg);
|
||||
void parseFloorChangeDown(InputMessage& msg);
|
||||
void parseOutfit(InputMessage& msg);
|
||||
void parseOpenOutfitWindow(InputMessage& msg);
|
||||
void parseVipAdd(InputMessage& msg);
|
||||
void parseVipLogin(InputMessage& msg);
|
||||
void parseVipLogout(InputMessage& msg);
|
||||
|
|
|
@ -113,23 +113,23 @@ void ProtocolGame::parseMessage(InputMessage& msg)
|
|||
case Proto::GameServerDeleteInventory:
|
||||
parseRemoveInventoryItem(msg);
|
||||
break;
|
||||
case Proto::GameServerNpcOffer:
|
||||
parseNpcOffer(msg);
|
||||
case Proto::GameServerOpenNpcTrade:
|
||||
parseOpenNpcTrade(msg);
|
||||
break;
|
||||
case Proto::GameServerPlayerGoods:
|
||||
parsePlayerCash(msg);
|
||||
parsePlayerGoods(msg);
|
||||
break;
|
||||
case Proto::GameServerCloseNpcTrade:
|
||||
parseCloseShopWindow(msg);
|
||||
parseCloseNpcTrade(msg);
|
||||
break;
|
||||
case Proto::GameServerOwnOffer:
|
||||
parseSafeTradeRequest(msg);
|
||||
case Proto::GameServerOwnTrade:
|
||||
parseOpenTrade(msg);
|
||||
break;
|
||||
case Proto::GameServerCounterOffer:
|
||||
parseSafeTradeRequest(msg);
|
||||
case Proto::GameServerCounterTrade:
|
||||
parseOpenTrade(msg);
|
||||
break;
|
||||
case Proto::GameServerCloseTrade:
|
||||
parseSafeTradeClose(msg);
|
||||
parseCloseTrade(msg);
|
||||
break;
|
||||
case Proto::GameServerAmbient:
|
||||
parseWorldLight(msg);
|
||||
|
@ -144,7 +144,7 @@ void ProtocolGame::parseMessage(InputMessage& msg)
|
|||
parseDistanceMissile(msg);
|
||||
break;
|
||||
case Proto::GameServerMarkCreature:
|
||||
parseCreatureSquare(msg);
|
||||
parseCreatureMark(msg);
|
||||
break;
|
||||
//case Proto::GameServerTrappers
|
||||
case Proto::GameServerCreatureHealth:
|
||||
|
@ -167,10 +167,10 @@ void ProtocolGame::parseMessage(InputMessage& msg)
|
|||
break;
|
||||
// case Proto::GameServerCreatureUnpass
|
||||
case Proto::GameServerEditText:
|
||||
parseItemTextWindow(msg);
|
||||
parseEditText(msg);
|
||||
break;
|
||||
case Proto::GameServerEditList:
|
||||
parseHouseTextWindow(msg);
|
||||
parseEditList(msg);
|
||||
break;
|
||||
case Proto::GameServerPlayerData:
|
||||
parsePlayerStats(msg);
|
||||
|
@ -179,7 +179,7 @@ void ProtocolGame::parseMessage(InputMessage& msg)
|
|||
parsePlayerSkills(msg);
|
||||
break;
|
||||
case Proto::GameServerPlayerState:
|
||||
parsePlayerIcons(msg);
|
||||
parsePlayerState(msg);
|
||||
break;
|
||||
case Proto::GameServerClearTarget:
|
||||
parsePlayerCancelAttack(msg);
|
||||
|
@ -228,8 +228,8 @@ void ProtocolGame::parseMessage(InputMessage& msg)
|
|||
case Proto::GameServerFloorChangeDown:
|
||||
parseFloorChangeDown(msg);
|
||||
break;
|
||||
case Proto::GameServerOutfit:
|
||||
parseOutfit(msg);
|
||||
case Proto::GameServerChooseOutfit:
|
||||
parseOpenOutfitWindow(msg);
|
||||
break;
|
||||
case Proto::GameServerVipAdd:
|
||||
parseVipAdd(msg);
|
||||
|
@ -454,7 +454,7 @@ void ProtocolGame::parseOpenContainer(InputMessage& msg)
|
|||
void ProtocolGame::parseCloseContainer(InputMessage& msg)
|
||||
{
|
||||
int containerId = msg.getU8();
|
||||
g_lua.callGlobalField("g_game", "onContainerClose", containerId);
|
||||
g_game.processCloseContainer(containerId);
|
||||
}
|
||||
|
||||
void ProtocolGame::parseContainerAddItem(InputMessage& msg)
|
||||
|
@ -469,14 +469,14 @@ void ProtocolGame::parseContainerUpdateItem(InputMessage& msg)
|
|||
int containerId = msg.getU8();
|
||||
int slot = msg.getU8();
|
||||
ItemPtr item = internalGetItem(msg);
|
||||
g_lua.callGlobalField("g_game", "onContainerUpdateItem", containerId, slot, item);
|
||||
g_game.processContainerUpdateItem(containerId, slot, item);
|
||||
}
|
||||
|
||||
void ProtocolGame::parseContainerRemoveItem(InputMessage& msg)
|
||||
{
|
||||
int containerId = msg.getU8();
|
||||
int slot = msg.getU8();
|
||||
g_lua.callGlobalField("g_game", "onContainerRemoveItem", containerId, slot);
|
||||
g_game.processContainerRemoveItem(containerId, slot);
|
||||
}
|
||||
|
||||
void ProtocolGame::parseAddInventoryItem(InputMessage& msg)
|
||||
|
@ -492,45 +492,65 @@ void ProtocolGame::parseRemoveInventoryItem(InputMessage& msg)
|
|||
g_game.processInventoryChange(slot, ItemPtr());
|
||||
}
|
||||
|
||||
void ProtocolGame::parseNpcOffer(InputMessage& msg)
|
||||
void ProtocolGame::parseOpenNpcTrade(InputMessage& msg)
|
||||
{
|
||||
std::vector<std::tuple<ItemPtr, std::string, int, int, int>> items;
|
||||
int listCount = msg.getU8();
|
||||
for(int i = 0; i < listCount; ++i) {
|
||||
msg.getU16(); // item id
|
||||
msg.getU8(); // runecharges
|
||||
msg.getString(); // item name
|
||||
msg.getU32(); // weight
|
||||
msg.getU32(); // buy price
|
||||
msg.getU32(); // sell price
|
||||
}
|
||||
int itemId = msg.getU16();
|
||||
int countOrSubType = msg.getU8();
|
||||
|
||||
ItemPtr item = Item::create(itemId);
|
||||
if(item->isStackable() || item->isFluidContainer() || item->isFluid())
|
||||
item->setCountOrSubType(countOrSubType);
|
||||
|
||||
std::string name = msg.getString();
|
||||
int weight = msg.getU32();
|
||||
int buyPrice = msg.getU32();
|
||||
int sellPrice = msg.getU32();
|
||||
|
||||
items.push_back(std::make_tuple(item, name, weight, buyPrice, sellPrice));
|
||||
}
|
||||
|
||||
void ProtocolGame::parsePlayerCash(InputMessage& msg)
|
||||
g_game.processOpenNpcTrade(items);
|
||||
}
|
||||
|
||||
void ProtocolGame::parsePlayerGoods(InputMessage& msg)
|
||||
{
|
||||
msg.getU32();
|
||||
std::vector<std::tuple<ItemPtr, int>> goods;
|
||||
|
||||
int money = msg.getU32();
|
||||
int size = msg.getU8();
|
||||
|
||||
for(int i = 0; i < size; i++) {
|
||||
msg.getU16(); // itemid
|
||||
msg.getU8(); // runecharges
|
||||
}
|
||||
}
|
||||
|
||||
void ProtocolGame::parseCloseShopWindow(InputMessage&)
|
||||
{
|
||||
}
|
||||
|
||||
void ProtocolGame::parseSafeTradeRequest(InputMessage& msg)
|
||||
{
|
||||
msg.getString(); // name
|
||||
int itemId = msg.getU16();
|
||||
int count = msg.getU8();
|
||||
|
||||
for(int i = 0; i < count; i++)
|
||||
internalGetItem(msg);
|
||||
goods.push_back(std::make_tuple(Item::create(itemId), count));
|
||||
}
|
||||
|
||||
void ProtocolGame::parseSafeTradeClose(InputMessage&)
|
||||
g_game.processPlayerGoods(money, goods);
|
||||
}
|
||||
|
||||
void ProtocolGame::parseCloseNpcTrade(InputMessage&)
|
||||
{
|
||||
g_game.processCloseNpcTrade();
|
||||
}
|
||||
|
||||
void ProtocolGame::parseOpenTrade(InputMessage& msg)
|
||||
{
|
||||
std::string name = msg.getString();
|
||||
int count = msg.getU8();
|
||||
|
||||
std::vector<ItemPtr> items(count);
|
||||
for(int i = 0; i < count; i++)
|
||||
items[i] = internalGetItem(msg);
|
||||
|
||||
g_game.processOpenTrade(name, items);
|
||||
}
|
||||
|
||||
void ProtocolGame::parseCloseTrade(InputMessage&)
|
||||
{
|
||||
g_game.processCloseTrade();
|
||||
}
|
||||
|
||||
void ProtocolGame::parseWorldLight(InputMessage& msg)
|
||||
|
@ -549,7 +569,6 @@ void ProtocolGame::parseMagicEffect(InputMessage& msg)
|
|||
|
||||
EffectPtr effect = EffectPtr(new Effect());
|
||||
effect->setId(effectId);
|
||||
|
||||
g_map.addThing(effect, pos);
|
||||
}
|
||||
|
||||
|
@ -562,7 +581,6 @@ void ProtocolGame::parseAnimatedText(InputMessage& msg)
|
|||
AnimatedTextPtr animatedText = AnimatedTextPtr(new AnimatedText);
|
||||
animatedText->setColor(color);
|
||||
animatedText->setText(text);
|
||||
|
||||
g_map.addThing(animatedText, position);
|
||||
}
|
||||
|
||||
|
@ -578,7 +596,7 @@ void ProtocolGame::parseDistanceMissile(InputMessage& msg)
|
|||
g_map.addThing(missile, fromPos);
|
||||
}
|
||||
|
||||
void ProtocolGame::parseCreatureSquare(InputMessage& msg)
|
||||
void ProtocolGame::parseCreatureMark(InputMessage& msg)
|
||||
{
|
||||
uint id = msg.getU32();
|
||||
int color = msg.getU8();
|
||||
|
@ -586,6 +604,8 @@ void ProtocolGame::parseCreatureSquare(InputMessage& msg)
|
|||
CreaturePtr creature = g_map.getCreatureById(id);
|
||||
if(creature)
|
||||
creature->addTimedSquare(color);
|
||||
else
|
||||
logTraceError("could not get greature");
|
||||
}
|
||||
|
||||
void ProtocolGame::parseCreatureHealth(InputMessage& msg)
|
||||
|
@ -596,6 +616,8 @@ void ProtocolGame::parseCreatureHealth(InputMessage& msg)
|
|||
CreaturePtr creature = g_map.getCreatureById(id);
|
||||
if(creature)
|
||||
creature->setHealthPercent(healthPercent);
|
||||
else
|
||||
logTraceError("could not get greature");
|
||||
}
|
||||
|
||||
void ProtocolGame::parseCreatureLight(InputMessage& msg)
|
||||
|
@ -609,6 +631,8 @@ void ProtocolGame::parseCreatureLight(InputMessage& msg)
|
|||
CreaturePtr creature = g_map.getCreatureById(id);
|
||||
if(creature)
|
||||
creature->setLight(light);
|
||||
else
|
||||
logTraceError("could not get greature");
|
||||
}
|
||||
|
||||
void ProtocolGame::parseCreatureOutfit(InputMessage& msg)
|
||||
|
@ -619,6 +643,8 @@ void ProtocolGame::parseCreatureOutfit(InputMessage& msg)
|
|||
CreaturePtr creature = g_map.getCreatureById(id);
|
||||
if(creature)
|
||||
creature->setOutfit(outfit);
|
||||
else
|
||||
logTraceError("could not get greature");
|
||||
}
|
||||
|
||||
void ProtocolGame::parseCreatureSpeed(InputMessage& msg)
|
||||
|
@ -629,6 +655,8 @@ void ProtocolGame::parseCreatureSpeed(InputMessage& msg)
|
|||
CreaturePtr creature = g_map.getCreatureById(id);
|
||||
if(creature)
|
||||
creature->setSpeed(speed);
|
||||
else
|
||||
logTraceError("could not get greature");
|
||||
}
|
||||
|
||||
void ProtocolGame::parseCreatureSkulls(InputMessage& msg)
|
||||
|
@ -639,6 +667,8 @@ void ProtocolGame::parseCreatureSkulls(InputMessage& msg)
|
|||
CreaturePtr creature = g_map.getCreatureById(id);
|
||||
if(creature)
|
||||
creature->setSkull(skull);
|
||||
else
|
||||
logTraceError("could not get greature");
|
||||
}
|
||||
|
||||
void ProtocolGame::parseCreatureShields(InputMessage& msg)
|
||||
|
@ -649,6 +679,8 @@ void ProtocolGame::parseCreatureShields(InputMessage& msg)
|
|||
CreaturePtr creature = g_map.getCreatureById(id);
|
||||
if(creature)
|
||||
creature->setShield(shield);
|
||||
else
|
||||
logTraceError("could not get greature");
|
||||
}
|
||||
|
||||
void ProtocolGame::parseCreatureTurn(InputMessage& msg)
|
||||
|
@ -659,23 +691,29 @@ void ProtocolGame::parseCreatureTurn(InputMessage& msg)
|
|||
CreaturePtr creature = g_map.getCreatureById(id);
|
||||
if(creature)
|
||||
creature->turn(direction);
|
||||
else
|
||||
logTraceError("could not get greature");
|
||||
}
|
||||
|
||||
void ProtocolGame::parseItemTextWindow(InputMessage& msg)
|
||||
void ProtocolGame::parseEditText(InputMessage& msg)
|
||||
{
|
||||
msg.getU32(); // windowId
|
||||
msg.getU16(); // itemid
|
||||
msg.getU16(); // max length
|
||||
msg.getString(); // text
|
||||
msg.getString(); // writter
|
||||
msg.getString(); // date
|
||||
int id = msg.getU32();
|
||||
int itemId = msg.getU16();
|
||||
int maxLength = msg.getU16();
|
||||
std::string text = msg.getString();
|
||||
std::string writter = msg.getString();
|
||||
std::string date = msg.getString();
|
||||
|
||||
g_game.processEditText(id, itemId, maxLength, text, writter, date);
|
||||
}
|
||||
|
||||
void ProtocolGame::parseHouseTextWindow(InputMessage& msg)
|
||||
void ProtocolGame::parseEditList(InputMessage& msg)
|
||||
{
|
||||
msg.getU8(); // unknown
|
||||
msg.getU32(); // windowId
|
||||
msg.getString(); // text
|
||||
int listId = msg.getU8();
|
||||
int id = msg.getU32();
|
||||
const std::string& text = msg.getString();
|
||||
|
||||
g_game.processEditList(listId, id, text);
|
||||
}
|
||||
|
||||
void ProtocolGame::parsePlayerStats(InputMessage& msg)
|
||||
|
@ -693,26 +731,30 @@ void ProtocolGame::parsePlayerStats(InputMessage& msg)
|
|||
double soul = msg.getU8();
|
||||
double stamina = msg.getU16();
|
||||
|
||||
g_game.processPlayerStats(health, maxHealth, freeCapacity, experience, level, levelPercent, mana, maxMana, magicLevel, magicLevelPercent, soul, stamina);
|
||||
m_localPlayer->setHealth(health, maxHealth);
|
||||
m_localPlayer->setFreeCapacity(freeCapacity);
|
||||
m_localPlayer->setExperience(experience);
|
||||
m_localPlayer->setLevel(level, levelPercent);
|
||||
m_localPlayer->setMana(mana, maxMana);
|
||||
m_localPlayer->setMagicLevel(magicLevel, magicLevelPercent);
|
||||
m_localPlayer->setSoul(soul);
|
||||
m_localPlayer->setStamina(stamina);
|
||||
}
|
||||
|
||||
void ProtocolGame::parsePlayerSkills(InputMessage& msg)
|
||||
{
|
||||
for(int skill = 0; skill < Otc::LastSkill; skill++) {
|
||||
int values[Otc::LastSkillType];
|
||||
for(int skillType = 0; skillType < Otc::LastSkillType; skillType++) {
|
||||
values[skillType] = msg.getU8();
|
||||
m_localPlayer->setSkill((Otc::Skill)skill, (Otc::SkillType)skillType, values[skillType]);
|
||||
}
|
||||
int level = msg.getU8();
|
||||
int levelPercent = msg.getU8();
|
||||
|
||||
g_lua.callGlobalField("g_game", "onSkillChange", skill, values[Otc::SkillLevel], values[Otc::SkillPercent]);
|
||||
m_localPlayer->setSkill((Otc::Skill)skill, level, levelPercent);
|
||||
}
|
||||
}
|
||||
|
||||
void ProtocolGame::parsePlayerIcons(InputMessage& msg)
|
||||
void ProtocolGame::parsePlayerState(InputMessage& msg)
|
||||
{
|
||||
int icons = msg.getU16();
|
||||
m_localPlayer->setIcons((Otc::PlayerIcons)icons);
|
||||
int states = msg.getU16();
|
||||
m_localPlayer->setStates((Otc::PlayerStates)states);
|
||||
}
|
||||
|
||||
void ProtocolGame::parsePlayerCancelAttack(InputMessage& msg)
|
||||
|
@ -775,7 +817,7 @@ void ProtocolGame::parseChannelList(InputMessage& msg)
|
|||
channelList.push_back(std::make_tuple(id, name));
|
||||
}
|
||||
|
||||
g_lua.callGlobalField("g_game", "onChannelList", channelList);
|
||||
g_game.processChannelList(channelList);
|
||||
}
|
||||
|
||||
void ProtocolGame::parseOpenChannel(InputMessage& msg)
|
||||
|
@ -783,29 +825,29 @@ void ProtocolGame::parseOpenChannel(InputMessage& msg)
|
|||
int channelId = msg.getU16();
|
||||
std::string name = msg.getString();
|
||||
|
||||
g_lua.callGlobalField("g_game", "onOpenChannel", channelId, name);
|
||||
g_game.processOpenChannel(channelId, name);
|
||||
}
|
||||
|
||||
void ProtocolGame::parseOpenPrivateChannel(InputMessage& msg)
|
||||
{
|
||||
std::string name = msg.getString();
|
||||
|
||||
g_lua.callGlobalField("g_game", "onOpenPrivateChannel", name);
|
||||
g_game.processOpenPrivateChannel(name);
|
||||
}
|
||||
|
||||
void ProtocolGame::parseOpenOwnPrivateChannel(InputMessage& msg)
|
||||
{
|
||||
int id = msg.getU16(); // channel id
|
||||
std::string name = msg.getString(); // channel name
|
||||
int channelId = msg.getU16();
|
||||
std::string name = msg.getString();
|
||||
|
||||
g_lua.callGlobalField("g_game", "onOpenOwnPrivateChannel", id, name);
|
||||
g_game.processOpenOwnPrivateChannel(channelId, name);
|
||||
}
|
||||
|
||||
void ProtocolGame::parseCloseChannel(InputMessage& msg)
|
||||
{
|
||||
int id = msg.getU16(); // channel id
|
||||
int channelId = msg.getU16();
|
||||
|
||||
g_lua.callGlobalField("g_game", "onCloseChannel", id);
|
||||
g_game.processCloseChannel(channelId);
|
||||
}
|
||||
|
||||
void ProtocolGame::parseTextMessage(InputMessage& msg)
|
||||
|
@ -861,27 +903,21 @@ void ProtocolGame::parseFloorChangeDown(InputMessage& msg)
|
|||
g_map.setCentralPosition(pos);
|
||||
}
|
||||
|
||||
void ProtocolGame::parseOutfit(InputMessage& msg)
|
||||
void ProtocolGame::parseOpenOutfitWindow(InputMessage& msg)
|
||||
{
|
||||
Outfit outfit = internalGetOutfit(msg);
|
||||
Outfit currentOutfit = internalGetOutfit(msg);
|
||||
|
||||
typedef std::tuple<int, std::string, int> OutfitInfo;
|
||||
std::vector<OutfitInfo> outfitList;
|
||||
|
||||
uint8 outfitCount = msg.getU8();
|
||||
std::vector<std::tuple<int, std::string, int>> outfitList;
|
||||
int outfitCount = msg.getU8();
|
||||
for(int i = 0; i < outfitCount; i++) {
|
||||
uint16 outfitId = msg.getU16();
|
||||
int outfitId = msg.getU16();
|
||||
std::string outfitName = msg.getString();
|
||||
uint8 outfitAddons = msg.getU8();
|
||||
int outfitAddons = msg.getU8();
|
||||
|
||||
outfitList.push_back(OutfitInfo(outfitId, outfitName, outfitAddons));
|
||||
outfitList.push_back(std::make_tuple(outfitId, outfitName, outfitAddons));
|
||||
}
|
||||
|
||||
CreaturePtr creature = CreaturePtr(new Creature);
|
||||
creature->setDirection(Otc::South);
|
||||
creature->setOutfit(outfit);
|
||||
|
||||
g_lua.callGlobalField("g_game", "onOpenOutfitWindow", creature, outfitList);
|
||||
g_game.processOpenOutfitWindow(currentOutfit, outfitList);
|
||||
}
|
||||
|
||||
void ProtocolGame::parseVipAdd(InputMessage& msg)
|
||||
|
@ -890,30 +926,30 @@ void ProtocolGame::parseVipAdd(InputMessage& msg)
|
|||
std::string name = msg.getString();
|
||||
bool online = msg.getU8() != 0;
|
||||
|
||||
g_lua.callGlobalField("g_game", "onAddVip", id, name, online);
|
||||
g_game.processVipAdd(id, name, online);
|
||||
}
|
||||
|
||||
void ProtocolGame::parseVipLogin(InputMessage& msg)
|
||||
{
|
||||
uint id = msg.getU32();
|
||||
|
||||
g_lua.callGlobalField("g_game", "onVipStateChange", id, true);
|
||||
g_game.processVipStateChange(id, true);
|
||||
}
|
||||
|
||||
void ProtocolGame::parseVipLogout(InputMessage& msg)
|
||||
{
|
||||
uint id = msg.getU32();
|
||||
|
||||
g_lua.callGlobalField("g_game", "onVipStateChange", id, false);
|
||||
g_game.processVipStateChange(id, false);
|
||||
}
|
||||
|
||||
void ProtocolGame::parseTutorialHint(InputMessage& msg)
|
||||
{
|
||||
// ignored
|
||||
msg.getU8(); // tutorial id
|
||||
}
|
||||
|
||||
void ProtocolGame::parseAutomapFlag(InputMessage& msg)
|
||||
{
|
||||
// ignored
|
||||
parsePosition(msg); // position
|
||||
msg.getU8(); // icon
|
||||
msg.getString(); // message
|
||||
|
@ -921,22 +957,30 @@ void ProtocolGame::parseAutomapFlag(InputMessage& msg)
|
|||
|
||||
void ProtocolGame::parseQuestLog(InputMessage& msg)
|
||||
{
|
||||
std::vector<std::tuple<int, std::string, bool>> questList;
|
||||
int questsCount = msg.getU16();
|
||||
for(int i = 0; i < questsCount; i++) {
|
||||
msg.getU16(); // quest id
|
||||
msg.getString(); // quest name
|
||||
msg.getU8(); // quest state
|
||||
int id = msg.getU16();
|
||||
std::string name = msg.getString();
|
||||
bool completed = msg.getU8();
|
||||
questList.push_back(std::make_tuple(id, name, completed));
|
||||
}
|
||||
|
||||
g_game.processQuestLog(questList);
|
||||
}
|
||||
|
||||
void ProtocolGame::parseQuestLine(InputMessage& msg)
|
||||
{
|
||||
msg.getU16(); // quest id
|
||||
std::vector<std::tuple<std::string, std::string>> questMissions;
|
||||
int questId = msg.getU16();
|
||||
int missionCount = msg.getU8();
|
||||
for(int i = 0; i < missionCount; i++) {
|
||||
msg.getString(); // quest name
|
||||
msg.getString(); // quest description
|
||||
std::string missionName = msg.getString();
|
||||
std::string missionDescrition = msg.getString();
|
||||
questMissions.push_back(std::make_tuple(missionName, missionDescrition));
|
||||
}
|
||||
|
||||
g_game.processQuestLine(questId, questMissions);
|
||||
}
|
||||
|
||||
void ProtocolGame::setMapDescription(InputMessage& msg, int32 x, int32 y, int32 z, int32 width, int32 height)
|
||||
|
@ -1085,7 +1129,7 @@ ThingPtr ProtocolGame::internalGetThing(InputMessage& msg)
|
|||
g_map.addCreature(creature);
|
||||
}
|
||||
|
||||
uint8 healthPercent = msg.getU8();
|
||||
int healthPercent = msg.getU8();
|
||||
Otc::Direction direction = (Otc::Direction)msg.getU8();
|
||||
Outfit outfit = internalGetOutfit(msg);
|
||||
|
||||
|
@ -1097,8 +1141,9 @@ ThingPtr ProtocolGame::internalGetThing(InputMessage& msg)
|
|||
int skull = msg.getU8();
|
||||
int shield = msg.getU8();
|
||||
|
||||
// emblem is sent only when the creature is not known
|
||||
int emblem = -1;
|
||||
if(thingId == 0x0061) // emblem is sent only in packet type 0x61
|
||||
if(thingId == 0x0061)
|
||||
emblem = msg.getU8();
|
||||
|
||||
bool passable = (msg.getU8() == 0);
|
||||
|
|
|
@ -191,20 +191,20 @@ void ProtocolGame::sendMove(const Position& fromPos, int thingId, int stackpos,
|
|||
send(msg);
|
||||
}
|
||||
|
||||
void ProtocolGame::sendInspectNpcTrade(int thingId, int count)
|
||||
void ProtocolGame::sendInspectNpcTrade(int itemId, int count)
|
||||
{
|
||||
OutputMessage msg;
|
||||
msg.addU8(Proto::ClientInspectNpcTrade);
|
||||
msg.addU16(thingId);
|
||||
msg.addU16(itemId);
|
||||
msg.addU8(count);
|
||||
send(msg);
|
||||
}
|
||||
|
||||
void ProtocolGame::sendBuyItem(int thingId, int count, int amount, bool ignoreCapacity, bool buyWithBackpack)
|
||||
void ProtocolGame::sendBuyItem(int itemId, int count, int amount, bool ignoreCapacity, bool buyWithBackpack)
|
||||
{
|
||||
OutputMessage msg;
|
||||
msg.addU8(Proto::ClientBuyItem);
|
||||
msg.addU16(thingId);
|
||||
msg.addU16(itemId);
|
||||
msg.addU8(count);
|
||||
msg.addU8(amount);
|
||||
msg.addU8(ignoreCapacity ? 0x01 : 0x00);
|
||||
|
@ -212,11 +212,11 @@ void ProtocolGame::sendBuyItem(int thingId, int count, int amount, bool ignoreCa
|
|||
send(msg);
|
||||
}
|
||||
|
||||
void ProtocolGame::sendSellItem(int thingId, int count, int amount, bool ignoreEquipped)
|
||||
void ProtocolGame::sendSellItem(int itemId, int count, int amount, bool ignoreEquipped)
|
||||
{
|
||||
OutputMessage msg;
|
||||
msg.addU8(Proto::ClientSellItem);
|
||||
msg.addU16(thingId);
|
||||
msg.addU16(itemId);
|
||||
msg.addU8(count);
|
||||
msg.addU8(amount);
|
||||
msg.addU8(ignoreEquipped ? 0x01 : 0x00);
|
||||
|
@ -230,14 +230,14 @@ void ProtocolGame::sendCloseNpcTrade()
|
|||
send(msg);
|
||||
}
|
||||
|
||||
void ProtocolGame::sendRequestTrade(const Position& pos, int thingId, int stackpos, uint playerId)
|
||||
void ProtocolGame::sendRequestTrade(const Position& pos, int thingId, int stackpos, uint creatureId)
|
||||
{
|
||||
OutputMessage msg;
|
||||
msg.addU8(Proto::ClientRequestTrade);
|
||||
addPosition(msg, pos);
|
||||
msg.addU16(thingId);
|
||||
msg.addU8(stackpos);
|
||||
msg.addU32(playerId);
|
||||
msg.addU32(creatureId);
|
||||
send(msg);
|
||||
}
|
||||
|
||||
|
@ -325,11 +325,11 @@ void ProtocolGame::sendUpContainer(int containerId)
|
|||
send(msg);
|
||||
}
|
||||
|
||||
void ProtocolGame::sendEditText(uint textId, const std::string& text)
|
||||
void ProtocolGame::sendEditText(uint id, const std::string& text)
|
||||
{
|
||||
OutputMessage msg;
|
||||
msg.addU8(Proto::ClientEditText);
|
||||
msg.addU32(textId);
|
||||
msg.addU32(id);
|
||||
msg.addString(text);
|
||||
send(msg);
|
||||
}
|
||||
|
@ -576,11 +576,11 @@ void ProtocolGame::sendRequestQuestLog()
|
|||
send(msg);
|
||||
}
|
||||
|
||||
void ProtocolGame::sendRequestQuestLine(int questLine)
|
||||
void ProtocolGame::sendRequestQuestLine(int questId)
|
||||
{
|
||||
OutputMessage msg;
|
||||
msg.addU8(Proto::ClientRequestQuestLine);
|
||||
msg.addU16(questLine);
|
||||
msg.addU16(questId);
|
||||
send(msg);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue