From 657640c270d1d45354a9b97083acaad1a4ba89d3 Mon Sep 17 00:00:00 2001 From: Eduardo Bart Date: Thu, 26 Jul 2012 08:18:49 -0300 Subject: [PATCH] Mounts Show creature mounts Fix outfit window Fix some 9.6 protocol issues --- modules/game_outfit/outfitwindow.otui | 18 +++++++++--------- modules/game_playermount/playermount.lua | 16 ++++++++-------- src/otclient/creature.cpp | 21 +++++++++++++++------ src/otclient/creature.h | 2 +- src/otclient/game.cpp | 8 +++++--- src/otclient/outfit.cpp | 1 + src/otclient/protocolgameparse.cpp | 5 +---- 7 files changed, 40 insertions(+), 31 deletions(-) diff --git a/modules/game_outfit/outfitwindow.otui b/modules/game_outfit/outfitwindow.otui index 3c98113b..eb94ce60 100644 --- a/modules/game_outfit/outfitwindow.otui +++ b/modules/game_outfit/outfitwindow.otui @@ -18,8 +18,8 @@ Window anchors.horizontalCenter: parent.horizontalCenter anchors.verticalCenter: parent.verticalCenter - @onEnter: accept() - @onEscape: destroy() + @onEnter: modules.game_outfit.accept() + @onEscape: modules.game_outfit.destroy() // Creature Boxes @@ -46,7 +46,7 @@ Window anchors.verticalCenter: outfitCreatureBox.verticalCenter margin-left: 3 enabled: true - @onClick: nextOutfitType() + @onClick: modules.game_outfit.nextOutfitType() PrevOutfitButton id: outfitPrevButton @@ -54,7 +54,7 @@ Window anchors.verticalCenter: outfitCreatureBox.verticalCenter margin-right: 3 enabled: true - @onClick: previousOutfitType() + @onClick: modules.game_outfit.previousOutfitType() Creature id: mountCreatureBox @@ -79,7 +79,7 @@ Window anchors.verticalCenter: mountCreatureBox.verticalCenter margin-left: 3 enabled: true - @onClick: nextMountType() + @onClick: modules.game_outfit.nextMountType() PrevMountButton id: mountPrevButton @@ -87,7 +87,7 @@ Window anchors.verticalCenter: mountCreatureBox.verticalCenter margin-right: 3 enabled: true - @onClick: previousMountType() + @onClick: modules.game_outfit.previousMountType() // Addon Check Boxes @@ -176,7 +176,7 @@ Window anchors.left: prev.left anchors.top: prev.bottom margin-right: 16 - @onClick: randomize() + @onClick: modules.game_outfit.randomize() HorizontalSeparator anchors.left: parent.left @@ -195,7 +195,7 @@ Window anchors.bottom: parent.bottom margin-bottom: 16 margin-right: 16 - @onClick: accept() + @onClick: modules.game_outfit.accept() Button id: outfitCancelButton @@ -205,4 +205,4 @@ Window anchors.bottom: parent.bottom margin-bottom: 16 margin-right: 16 - @onClick: destroy() + @onClick: modules.game_outfit.destroy() diff --git a/modules/game_playermount/playermount.lua b/modules/game_playermount/playermount.lua index 72bb4cae..05040b14 100644 --- a/modules/game_playermount/playermount.lua +++ b/modules/game_playermount/playermount.lua @@ -1,19 +1,19 @@ function init() - if g_game.getFeature(GamePlayerMount) then - g_keyboard.bindKeyDown('Ctrl+R', toggleMount, gameRootPanel) - end + g_keyboard.bindKeyDown('Ctrl+R', toggleMount, gameRootPanel) end function terminate() - if g_game.getFeature(GamePlayerMount) then - g_keyboard.unbindKeyDown('Ctrl+R', gameRootPanel) - end + g_keyboard.unbindKeyDown('Ctrl+R', gameRootPanel) end function toggleMount() - g_game.mount(not g_game.isMounted()) + if g_game.getFeature(GamePlayerMounts) then + g_game.mount(not g_game.isMounted()) + end end function dismount() - g_game.mount(false) + if g_game.getFeature(GamePlayerMounts) then + g_game.mount(false) + end end diff --git a/src/otclient/creature.cpp b/src/otclient/creature.cpp index 25ac69d8..457d1b51 100644 --- a/src/otclient/creature.cpp +++ b/src/otclient/creature.cpp @@ -77,7 +77,7 @@ void Creature::draw(const Point& dest, float scaleFactor, bool animate) m_footStepDrawn = true; } -void Creature::internalDrawOutfit(const Point& dest, float scaleFactor, bool animateWalk, bool animateIdle, Otc::Direction direction) +void Creature::internalDrawOutfit(Point dest, float scaleFactor, bool animateWalk, bool animateIdle, Otc::Direction direction) { // outfit is a real creature if(m_outfit.getCategory() == ThingCategoryCreature) { @@ -97,6 +97,15 @@ void Creature::internalDrawOutfit(const Point& dest, float scaleFactor, bool ani else xPattern = direction; + int zPattern = 0; + if(m_outfit.getMount() != 0) { + auto datType = g_things.rawGetThingType(m_outfit.getMount(), ThingCategoryCreature); + dest -= datType->getDisplacement() * scaleFactor; + datType->draw(dest, scaleFactor, 0, xPattern, 0, 0, animationPhase); + dest += getDisplacement() * scaleFactor; + zPattern = 1; + } + // yPattern => creature addon for(int yPattern = 0; yPattern < getNumPatternY(); yPattern++) { @@ -105,20 +114,20 @@ void Creature::internalDrawOutfit(const Point& dest, float scaleFactor, bool ani continue; auto datType = rawGetThingType(); - datType->draw(dest, scaleFactor, 0, xPattern, yPattern, 0, animationPhase); + datType->draw(dest, scaleFactor, 0, xPattern, yPattern, zPattern, animationPhase); if(getLayers() > 1) { Color oldColor = g_painter->getColor(); Painter::CompositionMode oldComposition = g_painter->getCompositionMode(); g_painter->setCompositionMode(Painter::CompositionMode_Multiply); g_painter->setColor(m_outfit.getHeadColor()); - datType->draw(dest, scaleFactor, SpriteMaskYellow, xPattern, yPattern, 0, animationPhase); + datType->draw(dest, scaleFactor, SpriteMaskYellow, xPattern, yPattern, zPattern, animationPhase); g_painter->setColor(m_outfit.getBodyColor()); - datType->draw(dest, scaleFactor, SpriteMaskRed, xPattern, yPattern, 0, animationPhase); + datType->draw(dest, scaleFactor, SpriteMaskRed, xPattern, yPattern, zPattern, animationPhase); g_painter->setColor(m_outfit.getLegsColor()); - datType->draw(dest, scaleFactor, SpriteMaskGreen, xPattern, yPattern, 0, animationPhase); + datType->draw(dest, scaleFactor, SpriteMaskGreen, xPattern, yPattern, zPattern, animationPhase); g_painter->setColor(m_outfit.getFeetColor()); - datType->draw(dest, scaleFactor, SpriteMaskBlue, xPattern, yPattern, 0, animationPhase); + datType->draw(dest, scaleFactor, SpriteMaskBlue, xPattern, yPattern, zPattern, animationPhase); g_painter->setColor(oldColor); g_painter->setCompositionMode(oldComposition); } diff --git a/src/otclient/creature.h b/src/otclient/creature.h index c127b439..587616fa 100644 --- a/src/otclient/creature.h +++ b/src/otclient/creature.h @@ -43,7 +43,7 @@ public: 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 internalDrawOutfit(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); diff --git a/src/otclient/game.cpp b/src/otclient/game.cpp index f59477ba..5f499744 100644 --- a/src/otclient/game.cpp +++ b/src/otclient/game.cpp @@ -328,7 +328,10 @@ void Game::processOpenOutfitWindow(const Outfit& currentOufit, const std::vector // create virtual creature outfit CreaturePtr virtualOutfitCreature = CreaturePtr(new Creature); virtualOutfitCreature->setDirection(Otc::South); - virtualOutfitCreature->setOutfit(currentOufit); + + Outfit outfit = currentOufit; + outfit.setMount(0); + virtualOutfitCreature->setOutfit(outfit); // creature virtual mount outfit CreaturePtr virtualMountCreature = nullptr; @@ -336,8 +339,7 @@ void Game::processOpenOutfitWindow(const Outfit& currentOufit, const std::vector { virtualMountCreature = CreaturePtr(new Creature); virtualMountCreature->setDirection(Otc::South); - if(currentOufit.getMount() > 0) - { + if(currentOufit.getMount() > 0) { Outfit mountOutfit; mountOutfit.setId(currentOufit.getMount()); virtualMountCreature->setOutfit(mountOutfit); diff --git a/src/otclient/outfit.cpp b/src/otclient/outfit.cpp index a4cc767d..5e50974d 100644 --- a/src/otclient/outfit.cpp +++ b/src/otclient/outfit.cpp @@ -126,4 +126,5 @@ void Outfit::resetClothes() setBody(0); setLegs(0); setFeet(0); + setMount(0); } diff --git a/src/otclient/protocolgameparse.cpp b/src/otclient/protocolgameparse.cpp index 7fa1d4b8..651fd0cb 100644 --- a/src/otclient/protocolgameparse.cpp +++ b/src/otclient/protocolgameparse.cpp @@ -832,7 +832,7 @@ void ProtocolGame::parsePlayerInfo(const InputMessagePtr& msg) int vocation = msg->getU8(); // vocation int spellCount = msg->getU16(); for(int i=0;igetU16(); // spell id - TODO: add to local player + int spellId = msg->getU8(); // spell id - TODO: add to local player } m_localPlayer->setPremium(premium); @@ -1034,7 +1034,6 @@ void ProtocolGame::parseCloseChannel(const InputMessagePtr& msg) g_game.processCloseChannel(channelId); } - void ProtocolGame::parseRuleViolationChannel(const InputMessagePtr& msg) { int channelId = msg->getU16(); @@ -1096,8 +1095,6 @@ void ProtocolGame::parseTextMessage(const InputMessagePtr& msg) Position pos = getPosition(msg); uint value = msg->getU32(); int color = msg->getU8(); - msg->getU32(); // ?? - msg->getU8(); // ?? text = msg->getString(); AnimatedTextPtr animatedText = AnimatedTextPtr(new AnimatedText);