diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/game.cpp | 70 | ||||
-rw-r--r-- | src/graphic/graphic.cpp | 11 | ||||
-rw-r--r-- | src/graphic/graphic.h | 2 | ||||
-rw-r--r-- | src/gui/buy.cpp | 3 | ||||
-rw-r--r-- | src/gui/equipment.cpp | 8 | ||||
-rw-r--r-- | src/gui/inventory.cpp | 2 | ||||
-rw-r--r-- | src/gui/itemcontainer.cpp | 2 | ||||
-rw-r--r-- | src/gui/sell.cpp | 3 | ||||
-rw-r--r-- | src/gui/shop.cpp | 98 |
9 files changed, 175 insertions, 24 deletions
diff --git a/src/game.cpp b/src/game.cpp index 5feeeeb1..3d7fa64f 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -620,15 +620,23 @@ void do_parse() { for (int loop = 0; loop < (RFIFOW(2) - 4) / 20; loop++) { inventoryWindow->addItem(RFIFOW(4 + loop * 20), RFIFOW(4 + loop * 20 + 2), 1, true); - char info[40]; + /*char info[40]; sprintf(info, "a4 %i %i %i %i %i %i %i %i", RFIFOW(4+loop*20), RFIFOW(4+loop*20+2), RFIFOB(4+loop*20+4), RFIFOB(4+loop*20+5), RFIFOW(4+loop*20+6), RFIFOW(4+loop*20+8), RFIFOB(4+loop*20+10), RFIFOB(4+loop*20+11)); - chatBox->chat_log(info, BY_SERVER); + chatBox->chat_log(info, BY_SERVER);*/ if(RFIFOW(4+loop*20+8)) { - equipmentWindow->addEquipment(RFIFOB(4+loop*20), + int slot = 1; + int position = 0; + while(RFIFOW(4+loop*20+8) != slot) { + slot *= 2; + position++; + } + /*sprintf(info, "%i %i", slot, position); + chatBox->chat_log(info, BY_SERVER);*/ + equipmentWindow->addEquipment(position - 1, RFIFOW(4+loop*20+2)); inventoryWindow->items->setEquipped( RFIFOW(4+loop*20), true); @@ -919,8 +927,22 @@ void do_parse() { case 0x00a0: if (RFIFOB(22) > 0) chatBox->chat_log("Unable to pick up item", BY_SERVER); - else - inventoryWindow->addItem(RFIFOW(2), RFIFOW(6), RFIFOW(4), false); + else { + if(RFIFOW(19)) { + inventoryWindow->addItem(RFIFOW(2), RFIFOW(6), + RFIFOW(4), true); + } + else { + inventoryWindow->addItem(RFIFOW(2), RFIFOW(6), + RFIFOW(4), false); + } + /*char info[40]; + sprintf(info, "a0 %i %i %i %i %i %i %i %i", + RFIFOW(2), RFIFOW(4), RFIFOW(6), + RFIFOB(8), RFIFOB(9), RFIFOB(10), + RFIFOW(19), RFIFOB(21)); + chatBox->chat_log(info, BY_SERVER);*/ + } break; // Decrease quantity of an item in inventory case 0x00af: @@ -957,7 +979,9 @@ void do_parse() { } } } - } break; + } + break; + // MVP experience case 0x010b: break; @@ -1006,9 +1030,19 @@ void do_parse() { if (RFIFOB(6) == 0) chatBox->chat_log("Unable to equip.", BY_SERVER); else { - inventoryWindow->items->setEquipped(RFIFOW(2), true); - equipmentWindow->addEquipment(RFIFOW(2), - inventoryWindow->items->getId(RFIFOW(2))); + if(RFIFOW(4)) { + int slot = 1; + int position = 0; + while(RFIFOW(4) != slot) { + slot *= 2; + position++; + } + inventoryWindow->items->setEquipped(RFIFOW(2), + true); + equipmentWindow->addEquipment(position - 1, + inventoryWindow->items->getId(RFIFOW(2))); + + } } break; // Equipment related @@ -1020,19 +1054,27 @@ void do_parse() { if(inventoryWindow->items->getIndex(RFIFOW(7))); inventoryWindow->items->setEquipped( inventoryWindow->items->getIndex(RFIFOW(7)), true);*/ - char info[40]; + /*char info[40]; sprintf(info, "1d7 %i %i %i %i", RFIFOL(2), RFIFOB(6), RFIFOW(7), RFIFOW(9)); - chatBox->chat_log(info, BY_SERVER); + chatBox->chat_log(info, BY_SERVER);*/ break; // Answer to unequip item case 0x00ac: if (RFIFOB(6) == 0) chatBox->chat_log("Unable to unequip.", BY_SERVER); else { - equipmentWindow->removeEquipment(RFIFOW(2)); - inventoryWindow->items->setEquipped( - inventoryWindow->items->getIndex(), false); + if(RFIFOW(4)) { + int slot = 1; + int position = 0; + while(RFIFOW(4) != slot) { + slot *= 2; + position++; + } + equipmentWindow->removeEquipment(position - 1); + inventoryWindow->items->setEquipped( + inventoryWindow->items->getIndex(), false); + } } break; // Manage non implemented packets diff --git a/src/graphic/graphic.cpp b/src/graphic/graphic.cpp index 8b13e0e9..39938dcb 100644 --- a/src/graphic/graphic.cpp +++ b/src/graphic/graphic.cpp @@ -310,14 +310,18 @@ Engine::Engine() "core/graphics/sprites/emotions.png"); Image *monsterbitmap = resman->getImage( "core/graphics/sprites/monsters.png"); + Image *weaponbitmap = resman->getImage( + "core/graphics/sprites/weapons.png"); if (!npcbmp) error("Unable to load npcs.png"); if (!emotionbmp) error("Unable to load emotions.png"); if (!monsterbitmap) error("Unable to load monsters.png"); + if (!weaponbitmap) error("Unable to load weapons.png"); npcset = new Spriteset(npcbmp, 50, 80); emotionset = new Spriteset(emotionbmp, 19, 19); monsterset = new Spriteset(monsterbitmap, 60, 60); + weaponset = new Spriteset(weaponbitmap, 160, 120); } Engine::~Engine() @@ -339,6 +343,7 @@ Engine::~Engine() delete monsterset; delete npcset; delete emotionset; + delete weaponset; } void Engine::draw() @@ -413,6 +418,10 @@ void Engine::draw() playerset->spriteset[4 * pf + dir]->draw(screen, being->text_x - 64, being->text_y - 80); + if (being->weapon != 0 && being->action == ATTACK) { + weaponset->spriteset[4 * being->frame + dir]->draw(screen, + being->text_x - 64, being->text_y - 80); + } if (being->hair_color <= 10) { int hf = being->hair_color - 1 + 10 * (dir + 4 * @@ -574,7 +583,7 @@ void Engine::draw() std::stringstream debugStream; debugStream << "[" << fps << " fps] " << - (mouseX / 32 + camera_x) << ", " << (mouseY / 32 + camera_y); + (mouseX / 32 + camera_x) << ", " << (mouseY / 32 + camera_y) << " " << player_node->weapon; debugInfo->setCaption(debugStream.str()); debugInfo->adjustSize(); } diff --git a/src/graphic/graphic.h b/src/graphic/graphic.h index c660f49c..b85c29ae 100644 --- a/src/graphic/graphic.h +++ b/src/graphic/graphic.h @@ -162,7 +162,7 @@ class Graphics : public gcn::SDLGraphics { */ class Engine { private: - Spriteset *emotionset, *npcset, *monsterset; + Spriteset *emotionset, *npcset, *monsterset, *weaponset; public: Engine(); diff --git a/src/gui/buy.cpp b/src/gui/buy.cpp index 059ba4e8..ab350363 100644 --- a/src/gui/buy.cpp +++ b/src/gui/buy.cpp @@ -44,6 +44,7 @@ BuyDialog::BuyDialog(): setSize(260, 175); scrollArea->setDimension(gcn::Rectangle(5, 5, 250, 110)); + itemList->setDimension(gcn::Rectangle(5, 5, 240, 110)); slider->setDimension(gcn::Rectangle(5, 120, 200, 10)); quantityLabel->setPosition(215, 120); moneyLabel->setPosition(5, 135); @@ -99,7 +100,7 @@ void BuyDialog::addItem(short id, int price) { ITEM_SHOP item_shop; - if (id - 501 >= 0 && id - 501 <= 11) { + if (id >= 501 && id <= 2301) { sprintf(item_shop.name, "%s %i gp", item_db[id - 501], price); } else { diff --git a/src/gui/equipment.cpp b/src/gui/equipment.cpp index ccc4d403..c7507475 100644 --- a/src/gui/equipment.cpp +++ b/src/gui/equipment.cpp @@ -29,7 +29,7 @@ EquipmentWindow::EquipmentWindow(): Window("Equipment") { - setSize(70, 200); + setSize(60, 200); setPosition(40, 40); ResourceManager *resman = ResourceManager::getInstance(); @@ -54,11 +54,13 @@ void EquipmentWindow::draw(gcn::Graphics *graphics) // Draw window graphics Window::draw(graphics); - for (int i = 0; i < 10; i++) { + for (int i = 0; i < 8; i++) { if (equipments[i] > 0) { itemset->spriteset[equipments[i] - 501]->draw(screen, - x + 20, y + 24 * i); + x + 22, y + 24 * i + 20); } + graphics->setColor(gcn::Color(0, 0, 0)); + graphics->drawRectangle(gcn::Rectangle(22, 24 * i + 20, 20, 20)); } } diff --git a/src/gui/inventory.cpp b/src/gui/inventory.cpp index d891db48..23520ba2 100644 --- a/src/gui/inventory.cpp +++ b/src/gui/inventory.cpp @@ -32,7 +32,7 @@ InventoryWindow::InventoryWindow(): Window("Inventory") { - setSize(322, 80); + setSize(322, 100); useButton = new Button("Use"); useButton->setPosition(20, 50); dropButton = new Button("Drop"); diff --git a/src/gui/itemcontainer.cpp b/src/gui/itemcontainer.cpp index 195f9188..49a6278b 100644 --- a/src/gui/itemcontainer.cpp +++ b/src/gui/itemcontainer.cpp @@ -60,7 +60,7 @@ void ItemContainer::draw(gcn::Graphics* graphics) for (int i = 0; i < INVENTORY_SIZE; i++) { if (items[i].quantity > 0) { - if (items[i].id >= 501 && items[i].id <= 2301) { + if (items[i].id >= 501 && items[i].id <= 1202) { itemset->spriteset[items[i].id - 501]->draw(screen, x + 24 * i, y + 2); diff --git a/src/gui/sell.cpp b/src/gui/sell.cpp index d8e6eb02..bcb72590 100644 --- a/src/gui/sell.cpp +++ b/src/gui/sell.cpp @@ -43,6 +43,7 @@ SellDialog::SellDialog(): setSize(260, 175); scrollArea->setDimension(gcn::Rectangle(5, 5, 250, 110)); + itemList->setDimension(gcn::Rectangle(5, 5, 240, 110)); slider->setDimension(gcn::Rectangle(5, 120, 200, 10)); quantityLabel->setPosition(215, 120); okButton->setPosition(180, 145); @@ -89,7 +90,7 @@ void SellDialog::addItem(short index, int price) int id = inventoryWindow->items->getId(index); ITEM_SHOP item_shop; - if (id >= 501 && id <= 511) { + if (id >= 501 && id <= 2301) { sprintf(item_shop.name, "%s %i gp", item_db[id - 501], price); } else { diff --git a/src/gui/shop.cpp b/src/gui/shop.cpp index 77e33ee0..7509d480 100644 --- a/src/gui/shop.cpp +++ b/src/gui/shop.cpp @@ -23,6 +23,8 @@ #include "shop.h" +// TODO: replace it with item database + char *item_db[] = { "Cactus Drink", "Cactus potion", @@ -34,5 +36,99 @@ char *item_db[] = { "Xmas Cake", "Chocolate", "Candy", - "Santa Hat" + "Santa Hat", + + "","","","","","","","","", + "","","","","","","","","","", + "","","","","","","","","","", + "","","","","","","","","","", + "","","","","","","","","","", + "","","","","","","","","","", + "","","","","","","","","","", + "","","","","","","","","","", + "","","","","","","","","","", + + // 601 + "","","","","","","","","","", + "","","","","","","","","","", + "","","","","","","","","","", + "","","","","","","","","","", + "","","","","","","","","","", + "","","","","","","","","","", + "","","","","","","","","","", + "","","","","","","","","","", + "","","","","","","","","","", + "","","","","","","","","","", + + // 701 + "","","","","","","","","","", + "","","","","","","","","","", + "","","","","","","","","","", + "","","","","","","","","","", + "","","","","","","","","","", + "","","","","","","","","","", + "","","","","","","","","","", + "","","","","","","","","","", + "","","","","","","","","","", + "","","","","","","","","","", + + // 801 + "","","","","","","","","","", + "","","","","","","","","","", + "","","","","","","","","","", + "","","","","","","","","","", + "","","","","","","","","","", + "","","","","","","","","","", + "","","","","","","","","","", + "","","","","","","","","","", + "","","","","","","","","","", + "","","","","","","","","","", + + // 901 + "","","","","","","","","","", + "","","","","","","","","","", + "","","","","","","","","","", + "","","","","","","","","","", + "","","","","","","","","","", + "","","","","","","","","","", + "","","","","","","","","","", + "","","","","","","","","","", + "","","","","","","","","","", + "","","","","","","","","","", + + // 1001 + "","","","","","","","","","", + "","","","","","","","","","", + "","","","","","","","","","", + "","","","","","","","","","", + "","","","","","","","","","", + "","","","","","","","","","", + "","","","","","","","","","", + "","","","","","","","","","", + "","","","","","","","","","", + "","","","","","","","","","", + + // 1101 + "","","","","","","","","","", + "","","","","","","","","","", + "","","","","","","","","","", + "","","","","","","","","","", + "","","","","","","","","","", + "","","","","","","","","","", + "","","","","","","","","","", + "","","","","","","","","","", + "","","","","","","","","","", + "","","","","","","","","","", + + // 1201 + "Knife","Cotton Shirt","","","","","","","","", + "","","","","","","","","","", + "","","","","","","","","","", + "","","","","","","","","","", + "","","","","","","","","","", + "","","","","","","","","","", + "","","","","","","","","","", + "","","","","","","","","","", + "","","","","","","","","","", + "","","","","","","","","","", }; |