map position, skills
This commit is contained in:
		
							parent
							
								
									00484b96c8
								
							
						
					
					
						commit
						33573e957d
					
				|  | @ -75,6 +75,23 @@ namespace Otc | |||
|         SpriteNoMask = 255 | ||||
|     }; | ||||
| 
 | ||||
|     enum Skill { | ||||
|         Fist = 0, | ||||
|         Club, | ||||
|         Sword, | ||||
|         Axe, | ||||
|         Distance, | ||||
|         Shielding, | ||||
|         Fishing, | ||||
|         LastSkill | ||||
|     }; | ||||
| 
 | ||||
|     enum SkillType { | ||||
|         SkillLevel, | ||||
|         SkillPercent, | ||||
|         LastSkillType | ||||
|     }; | ||||
| 
 | ||||
|     enum Direction { | ||||
|         North = 0, | ||||
|         East, | ||||
|  |  | |||
|  | @ -36,11 +36,16 @@ public: | |||
|     void setCanReportBugs(uint8 canReportBugs) { m_canReportBugs = (canReportBugs != 0); } | ||||
|     bool getCanReportBugs() { return m_canReportBugs; } | ||||
| 
 | ||||
|     void setSkill(Otc::Skill skill, Otc::SkillType skillType, int value) { m_skills[skill][skillType] = value; } | ||||
|     int getSkill(Otc::Skill skill, Otc::SkillType skillType) { return m_skills[skill][skillType]; } | ||||
| 
 | ||||
|     LocalPlayerPtr asLocalPlayer() { return std::static_pointer_cast<LocalPlayer>(shared_from_this()); } | ||||
| 
 | ||||
| private: | ||||
|     uint16 m_drawSpeed; | ||||
|     bool m_canReportBugs; | ||||
| 
 | ||||
|     int m_skills[Otc::LastSkill][Otc::LastSkillType]; | ||||
| }; | ||||
| 
 | ||||
| #endif | ||||
|  |  | |||
|  | @ -38,14 +38,13 @@ void Map::draw(const Rect& rect) | |||
|     m_framebuffer->bind(); | ||||
| 
 | ||||
|     LocalPlayerPtr player = g_game.getLocalPlayer(); | ||||
|     Position playerPos = player->getPosition(); | ||||
|     int walkOffsetX = player->getWalkOffsetX(); | ||||
|     int walkOffsetY = player->getWalkOffsetY(); | ||||
| 
 | ||||
|     // player is above 7
 | ||||
| 
 | ||||
|     int drawFloorStop = 0; | ||||
|     if(playerPos.z <= 7) { | ||||
|     if(m_centralPosition.z <= 7) { | ||||
| 
 | ||||
|         // player pos it 8-6. check if we can draw upper floors.
 | ||||
| 
 | ||||
|  | @ -64,9 +63,9 @@ void Map::draw(const Rect& rect) | |||
| 
 | ||||
|         // if we have something covering us, dont show floors above.
 | ||||
|         for(int jz = 6; jz >= 0; --jz) { | ||||
|             Position coverPos = Position(playerPos.x+(7-jz)-1, playerPos.y+(7-jz)-1, jz); | ||||
|             Position coverPos = Position(m_centralPosition.x+(7-jz)-1, m_centralPosition.y+(7-jz)-1, jz); | ||||
|             if(const TilePtr& tile = m_tiles[coverPos]) { | ||||
|                 if(tile->getStackSize(3) > 0 && jz < playerPos.z) { | ||||
|                 if(tile->getStackSize(3) > 0 && jz < m_centralPosition.z) { | ||||
|                     drawFloorStop = jz; | ||||
|                     break; | ||||
|                 } | ||||
|  | @ -80,11 +79,11 @@ void Map::draw(const Rect& rect) | |||
|             // +1 in draws cause 64x64 items may affect view.
 | ||||
| 
 | ||||
|             for(int step = 0; step < 2; ++step) { | ||||
|                 for(int ix = -8+(playerPos.z-iz); ix < + 8+7; ++ix) { | ||||
|                     for(int iy = -6+(playerPos.z-iz); iy < + 6+7; ++iy) { | ||||
|                         Position itemPos = Position(playerPos.x + ix, playerPos.y + iy, iz); | ||||
|                 for(int ix = -8+(m_centralPosition.z-iz); ix < + 8+7; ++ix) { | ||||
|                     for(int iy = -6+(m_centralPosition.z-iz); iy < + 6+7; ++iy) { | ||||
|                         Position itemPos = Position(m_centralPosition.x + ix, m_centralPosition.y + iy, iz); | ||||
|                         if(const TilePtr& tile = m_tiles[itemPos]) | ||||
|                             tile->draw((ix + 7 - (playerPos.z-iz))*32 - walkOffsetX, (iy + 5 - (playerPos.z-iz))*32 - walkOffsetY, step); | ||||
|                             tile->draw((ix + 7 - (m_centralPosition.z-iz))*32 - walkOffsetX, (iy + 5 - (m_centralPosition.z-iz))*32 - walkOffsetY, step); | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
|  | @ -107,7 +106,7 @@ void Map::draw(const Rect& rect) | |||
|     // draw player names and health bars
 | ||||
|     for(int ix = -7; ix <= 7; ++ix) { | ||||
|         for(int iy = -5; iy <= 5; ++iy) { | ||||
|             Position itemPos = Position(playerPos.x + ix, playerPos.y + iy, playerPos.z); | ||||
|             Position itemPos = Position(m_centralPosition.x + ix, m_centralPosition.y + iy, m_centralPosition.z); | ||||
|             if(const TilePtr& tile = m_tiles[itemPos]) { | ||||
|                 auto& creatures = tile->getCreatures(); | ||||
|                 for(auto it = creatures.rbegin(), end = creatures.rend(); it != end; ++it) { | ||||
|  | @ -125,7 +124,7 @@ void Map::draw(const Rect& rect) | |||
| 
 | ||||
| 
 | ||||
|                     // TODO: create isCovered function.
 | ||||
|                     bool useGray = (drawFloorStop != playerPos.z-1); | ||||
|                     bool useGray = (drawFloorStop != m_centralPosition.z-1); | ||||
| 
 | ||||
|                     creature->drawInformation(x*horizontalStretchFactor, y*verticalStretchFactor, useGray); | ||||
|                 } | ||||
|  |  | |||
|  | @ -42,6 +42,9 @@ public: | |||
|     void setLight(const Light& light) { m_light = light; } | ||||
|     Light getLight() { return m_light; } | ||||
| 
 | ||||
|     void setCentralPosition(const Position& centralPosition) { m_centralPosition = centralPosition; } | ||||
|     Position getCentralPosition() { return m_centralPosition; } | ||||
| 
 | ||||
|     CreaturePtr getCreatureById(uint32 id); | ||||
|     void removeCreatureById(uint32 id); | ||||
| 
 | ||||
|  | @ -50,6 +53,7 @@ private: | |||
|     std::map<uint32, CreaturePtr> m_creatures; | ||||
| 
 | ||||
|     Light m_light; | ||||
|     Position m_centralPosition; | ||||
| 
 | ||||
| 
 | ||||
|     FrameBufferPtr m_framebuffer; | ||||
|  |  | |||
|  | @ -307,32 +307,44 @@ void ProtocolGame::parseCanReportBugs(InputMessage& msg) | |||
| void ProtocolGame::parseMapDescription(InputMessage& msg) | ||||
| { | ||||
|     Position pos = parsePosition(msg); | ||||
|     m_localPlayer->setPosition(pos); | ||||
|     g_map.setCentralPosition(pos); | ||||
|     setMapDescription(msg, pos.x - 8, pos.y - 6, pos.z, 18, 14); | ||||
| } | ||||
| 
 | ||||
| void ProtocolGame::parseMoveNorth(InputMessage& msg) | ||||
| { | ||||
|     Position pos = m_localPlayer->getPosition(); | ||||
|     Position pos = g_map.getCentralPosition(); | ||||
|     pos.y--; | ||||
| 
 | ||||
|     setMapDescription(msg, pos.x - 8, pos.y - 6, pos.z, 18, 1); | ||||
|     g_map.setCentralPosition(pos); | ||||
| } | ||||
| 
 | ||||
| void ProtocolGame::parseMoveEast(InputMessage& msg) | ||||
| { | ||||
|     Position pos = m_localPlayer->getPosition(); | ||||
|     Position pos = g_map.getCentralPosition(); | ||||
|     pos.x++; | ||||
| 
 | ||||
|     setMapDescription(msg, pos.x + 9, pos.y - 6, pos.z, 1, 14); | ||||
|     g_map.setCentralPosition(pos); | ||||
| } | ||||
| 
 | ||||
| void ProtocolGame::parseMoveSouth(InputMessage& msg) | ||||
| { | ||||
|     Position pos = m_localPlayer->getPosition(); | ||||
|     Position pos = g_map.getCentralPosition(); | ||||
|     pos.y++; | ||||
| 
 | ||||
|     setMapDescription(msg, pos.x - 8, pos.y + 7, pos.z, 18, 1); | ||||
|     g_map.setCentralPosition(pos); | ||||
| } | ||||
| 
 | ||||
| void ProtocolGame::parseMoveWest(InputMessage& msg) | ||||
| { | ||||
|     Position pos = m_localPlayer->getPosition(); | ||||
|     Position pos = g_map.getCentralPosition(); | ||||
|     pos.x--; | ||||
| 
 | ||||
|     setMapDescription(msg, pos.x - 8, pos.y - 6, pos.z, 1, 14); | ||||
|     g_map.setCentralPosition(pos); | ||||
| } | ||||
| 
 | ||||
| void ProtocolGame::parseUpdateTile(InputMessage& msg) | ||||
|  | @ -640,26 +652,9 @@ void ProtocolGame::parsePlayerStats(InputMessage& msg) | |||
| 
 | ||||
| void ProtocolGame::parsePlayerSkills(InputMessage& msg) | ||||
| { | ||||
|     msg.getU8(); // fist skill
 | ||||
|     msg.getU8(); // fist percent
 | ||||
| 
 | ||||
|     msg.getU8(); // club skill
 | ||||
|     msg.getU8(); // club percent
 | ||||
| 
 | ||||
|     msg.getU8(); // sword skill
 | ||||
|     msg.getU8(); // sword percent
 | ||||
| 
 | ||||
|     msg.getU8(); // axe skill
 | ||||
|     msg.getU8(); // axe percent
 | ||||
| 
 | ||||
|     msg.getU8(); // distance skill
 | ||||
|     msg.getU8(); // distance percent
 | ||||
| 
 | ||||
|     msg.getU8(); // shielding skill
 | ||||
|     msg.getU8(); // shielding percent
 | ||||
| 
 | ||||
|     msg.getU8(); // fishing skill
 | ||||
|     msg.getU8(); // fishing percent
 | ||||
|     for(int skill = 0; skill < Otc::LastSkill; skill++) | ||||
|         for(int skillType = 0; skillType < Otc::LastSkillType; skillType++) | ||||
|             m_localPlayer->setSkill((Otc::Skill)skill, (Otc::SkillType)skillType, msg.getU8()); | ||||
| } | ||||
| 
 | ||||
| void ProtocolGame::parsePlayerIcons(InputMessage& msg) | ||||
|  | @ -773,25 +768,29 @@ void ProtocolGame::parseCancelWalk(InputMessage& msg) | |||
| 
 | ||||
| void ProtocolGame::parseFloorChangeUp(InputMessage& msg) | ||||
| { | ||||
|     Position pos = m_localPlayer->getPosition(); | ||||
|     logDebug("[ProtocolGame::parseFloorChangeUp]: This function has never been tested."); | ||||
| 
 | ||||
|     Position pos = g_map.getCentralPosition(); | ||||
|     pos.z--; | ||||
| 
 | ||||
|     int32 skip = 0; | ||||
|     if(m_localPlayer->getPosition().z == 7) | ||||
|     if(pos.z == 7) | ||||
|         for(int32 i = 5; i >= 0; i--) | ||||
|             setFloorDescription(msg, pos.x - 8, pos.y - 6, i, 18, 14, 8 - i, &skip); | ||||
|     else if(m_localPlayer->getPosition().z > 7) | ||||
|     else if(pos.z > 7) | ||||
|         setFloorDescription(msg, pos.x - 8, pos.y - 6, pos.z - 2, 18, 14, 3, &skip); | ||||
| 
 | ||||
|     //pos.x++;
 | ||||
|     //pos.y++;
 | ||||
|     //m_localPlayer->setPosition(pos);
 | ||||
|     pos.x++; | ||||
|     pos.y++; | ||||
|     g_map.setCentralPosition(pos); | ||||
| } | ||||
| 
 | ||||
| void ProtocolGame::parseFloorChangeDown(InputMessage& msg) | ||||
| { | ||||
|     Position pos = m_localPlayer->getPosition(); | ||||
|     //pos.z++;
 | ||||
|     logDebug("[ProtocolGame::parseFloorChangeDown]: This function has never been tested."); | ||||
| 
 | ||||
|     Position pos = g_map.getCentralPosition(); | ||||
|     pos.z++; | ||||
| 
 | ||||
|     int skip = 0; | ||||
|     if(pos.z == 8) { | ||||
|  | @ -802,9 +801,9 @@ void ProtocolGame::parseFloorChangeDown(InputMessage& msg) | |||
|     else if(pos.z > 8 && pos.z < 14) | ||||
|         setFloorDescription(msg, pos.x - 8, pos.y - 6, pos.z + 2, 18, 14, -3, &skip); | ||||
| 
 | ||||
|     //pos.x--;
 | ||||
|     //pos.y--;
 | ||||
|     //m_localPlayer->setPosition(pos);
 | ||||
|     pos.x--; | ||||
|     pos.y--; | ||||
|     g_map.setCentralPosition(pos); | ||||
| } | ||||
| 
 | ||||
| void ProtocolGame::parseOutfitWindow(InputMessage& msg) | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	 Henrique
						Henrique