diff options
author | Eugenio Favalli <elvenprogrammer@gmail.com> | 2005-03-04 16:34:02 +0000 |
---|---|---|
committer | Eugenio Favalli <elvenprogrammer@gmail.com> | 2005-03-04 16:34:02 +0000 |
commit | 7a57cee0d153a4db1d82369aae9160e8ece9ba26 (patch) | |
tree | a64fd35942c72d8eb1250effaaca0f4b82768cfc | |
parent | 47ddb7669a56c32597510d8153a6aa156bb4a397 (diff) | |
download | mana-7a57cee0d153a4db1d82369aae9160e8ece9ba26.tar.gz mana-7a57cee0d153a4db1d82369aae9160e8ece9ba26.tar.bz2 mana-7a57cee0d153a4db1d82369aae9160e8ece9ba26.tar.xz mana-7a57cee0d153a4db1d82369aae9160e8ece9ba26.zip |
A bunch of updates:
- inventory fixes
- equipment fixes
- graphic updates (items and monsters)
- weaponary system
- fixed status window
-rw-r--r-- | The Mana World.dev | 74 | ||||
-rw-r--r-- | src/engine.cpp | 7 | ||||
-rw-r--r-- | src/game.cpp | 209 | ||||
-rw-r--r-- | src/gui/equipment.cpp | 21 | ||||
-rw-r--r-- | src/gui/equipment.h | 11 | ||||
-rw-r--r-- | src/gui/inventory.cpp | 9 | ||||
-rw-r--r-- | src/gui/itemcontainer.cpp | 5 | ||||
-rw-r--r-- | src/gui/itemcontainer.h | 2 | ||||
-rw-r--r-- | src/gui/stats.cpp | 23 | ||||
-rw-r--r-- | src/gui/stats.h | 1 | ||||
-rw-r--r-- | src/main.h | 1 |
11 files changed, 287 insertions, 76 deletions
diff --git a/The Mana World.dev b/The Mana World.dev index fee6e214..1e0b99e6 100644 --- a/The Mana World.dev +++ b/The Mana World.dev @@ -1,7 +1,7 @@ [Project] FileName=The Mana World.dev Name=tmw -UnitCount=107 +UnitCount=109 Type=0 Ver=1 ObjFiles= @@ -340,16 +340,6 @@ Priority=1000 OverrideBuildCmd=0 BuildCmd= -[Unit11] -FileName=src\gui\stats.h -CompileCpp=1 -Folder=gui -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - [Unit37] FileName=src\gui\npc.cpp CompileCpp=1 @@ -1063,7 +1053,7 @@ OverrideBuildCmd=0 BuildCmd= [Unit102] -FileName=src\floor_item.cpp +FileName=src\graphics.h CompileCpp=1 Folder=tmw Compile=1 @@ -1073,7 +1063,7 @@ OverrideBuildCmd=0 BuildCmd= [Unit103] -FileName=src\floor_item.h +FileName=src\base64.cpp CompileCpp=1 Folder=tmw Compile=1 @@ -1083,7 +1073,7 @@ OverrideBuildCmd=0 BuildCmd= [Unit104] -FileName=src\graphics.cpp +FileName=src\base64.h CompileCpp=1 Folder=tmw Compile=1 @@ -1093,7 +1083,7 @@ OverrideBuildCmd=0 BuildCmd= [Unit105] -FileName=src\graphics.h +FileName=src\engine.cpp CompileCpp=1 Folder=tmw Compile=1 @@ -1103,7 +1093,7 @@ OverrideBuildCmd=0 BuildCmd= [Unit106] -FileName=src\engine.cpp +FileName=src\engine.h CompileCpp=1 Folder=tmw Compile=1 @@ -1113,7 +1103,27 @@ OverrideBuildCmd=0 BuildCmd= [Unit107] -FileName=src\engine.h +FileName=src\floor_item.cpp +CompileCpp=1 +Folder=tmw +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit108] +FileName=src\floor_item.h +CompileCpp=1 +Folder=tmw +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit109] +FileName=src\graphics.cpp CompileCpp=1 Folder=tmw Compile=1 @@ -1122,3 +1132,33 @@ Priority=1000 OverrideBuildCmd=0 BuildCmd= +[Unit110] +FileName=src\floor_item.h +CompileCpp=1 +Folder=tmw +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit111] +FileName=src\graphics.cpp +CompileCpp=1 +Folder=tmw +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit11] +FileName=src\gui\stats.h +CompileCpp=1 +Folder=gui +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + diff --git a/src/engine.cpp b/src/engine.cpp index 9e0d6b62..7a37af25 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -335,7 +335,8 @@ void Engine::draw() int pf = being->frame + being->action; if (being->action == ATTACK) { - pf += 4 * being->weapon; + if(being->weapon > 0) + pf += 4 * (being->weapon - 1); } playerset->spriteset[4 * pf + dir]->draw(screen, @@ -389,11 +390,11 @@ void Engine::draw() int mf = being->frame + being->action; if (being->action == MONSTER_DEAD) { - monsterset->spriteset[sprnum + 12 * MONSTER_DEAD]->draw(screen, + monsterset->spriteset[sprnum + 16 * MONSTER_DEAD]->draw(screen, being->text_x + 30, being->text_y + 40); } else { - monsterset->spriteset[sprnum + 12 * mf]->draw(screen, + monsterset->spriteset[sprnum + 16 * mf]->draw(screen, being->text_x + 30, being->text_y + 40); } diff --git a/src/game.cpp b/src/game.cpp index 1d704f2b..b5f0a9be 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -148,8 +148,10 @@ void do_init() player_node->speed = 150; player_node->hair_color = char_info->hair_color; player_node->hair_style = char_info->hair_style; + std::cout << char_info->weapon << "\n"; if (char_info->weapon == 11) { - char_info->weapon = 1; + char_info->weapon = 2; + std::cout << char_info->weapon << "\n"; } player_node->weapon = char_info->weapon; add_node(player_node); @@ -368,7 +370,7 @@ void do_input() if (keys[SDLK_UP] || keys[SDLK_KP8]) { - // UP + // Up if (tiledMap->getWalk(x, y - 1) != 0) { walk(x, y-1, NORTH); @@ -601,17 +603,25 @@ void do_parse() { case 0x007b: //case 0x01da: being = find_node(RFIFOL(2)); - if(being==NULL) { + if(being == NULL) { being = new Being(); - being->action = STAND; - being->x = get_src_x(RFIFOP(50)); - being->y = get_src_y(RFIFOP(50)); - being->direction = 0; - being->id = RFIFOL(2); - being->speed = RFIFOW(6); - being->job = RFIFOW(14); add_node(being); } + being->action = STAND; + being->x = get_src_x(RFIFOP(50)); + being->y = get_src_y(RFIFOP(50)); + being->direction = 0; + being->id = RFIFOL(2); + being->speed = RFIFOW(6); + being->job = RFIFOW(14); + being->weapon = RFIFOW(18); + + /*if(being->id==char_info->id) { + char plr_wpn[20]; + sprintf(plr_wpn, "7b %i %i", being->id, being->weapon); + chatBox->chat_log(plr_wpn,BY_SERVER); + }*/ + being->setPath(tiledMap->findPath( get_src_x(RFIFOP(50)), get_src_y(RFIFOP(50)), @@ -661,6 +671,13 @@ void do_parse() { inventoryWindow->addItem(RFIFOW(4 + loop * 18), RFIFOW(4 + loop * 18 + 2), RFIFOW(4 + loop * 18 + 6), false); + // Trick because arrows are not considered equipment + if (RFIFOW(4 + loop * 18 + 2) == 1199) + inventoryWindow->items->setEquipment( + RFIFOW(4 + loop * 18), true); + /*char info[40]; + sprintf(info, "1ee %i", RFIFOW(4+loop*18+2)); + chatBox->chat_log(info, BY_SERVER);*/ } break; // Get the equipments @@ -676,16 +693,18 @@ void do_parse() { RFIFOB(4+loop*20+10), RFIFOB(4+loop*20+11)); chatBox->chat_log(info, BY_SERVER);*/ if(RFIFOW(4+loop*20+8)) { - int slot = 1; + int mask = 1; int position = 0; - while(RFIFOW(4+loop*20+8) != slot) { - slot *= 2; + while(!(RFIFOW(4+loop*20+8) & mask)) { + mask *= 2; position++; } - /*sprintf(info, "%i %i", slot, position); + /*sprintf(info, "%i %i", mask, position); chatBox->chat_log(info, BY_SERVER);*/ equipmentWindow->addEquipment(position - 1, RFIFOW(4+loop*20+2)); + equipmentWindow->equipments[position - 1].inventoryIndex = + RFIFOW(4+loop*20); inventoryWindow->items->setEquipped( RFIFOW(4+loop*20), true); } @@ -781,11 +800,17 @@ void do_parse() { case 0x0037: char_info->job_lv = RFIFOW(4); break; - //case 0x0009: - // try to get the stats point to attribute... - // FIXME : Wrong or misplaced... - //char_info->statsPointsToAttribute = RFIFOW(4); - //break; + case 0x0009: + char_info->statsPointsToAttribute = RFIFOW(4); + /*char points[20]; + sprintf(points, "b0 0x0009 %i", RFIFOL(4)); + chatBox->chat_log(points, BY_SERVER);*/ + break; + default: + /*char unknown[20]; + sprintf(unknown, "b0 %x %i", RFIFOW(2),RFIFOL(4)); + chatBox->chat_log(unknown, BY_SERVER);*/ + break; } statusWindow->update(); if (char_info->hp == 0 && deathNotice == NULL) { @@ -924,6 +949,9 @@ void do_parse() { char_info->LUK = RFIFOL(6) + RFIFOL(10); break; } + /*char unknown2[20]; + sprintf(unknown2, "141 %i %i %i", RFIFOL(2),RFIFOL(6),RFIFOL(10)); + chatBox->chat_log(unknown2, BY_SERVER);*/ break; // Buy/Sell dialog case 0x00c4: @@ -1100,33 +1128,48 @@ void do_parse() { chatBox->chat_log("Unable to equip.", BY_SERVER); else { if(RFIFOW(4)) { - int slot = 1; + int mask = 1; int position = 0; - while(RFIFOW(4) != slot) { - slot *= 2; + while(!(RFIFOW(4) & mask)) { + mask *= 2; position++; } + int equippedId = equipmentWindow->equipments[position - 1].id; + if (equippedId > 0) + inventoryWindow->items->setEquipped( + equipmentWindow->equipments[position - 1].inventoryIndex, + false); + /*char info3[40]; + sprintf(info3, "info3 %i %i", position-1,equippedId); + chatBox->chat_log(info3, BY_SERVER);*/ + inventoryWindow->items->setEquipped(RFIFOW(2), true); equipmentWindow->addEquipment(position - 1, inventoryWindow->items->getId(RFIFOW(2))); - + equipmentWindow->equipments[position - 1].inventoryIndex = RFIFOW(2); + + // Trick to use the proper graphic until I find + // the right packet + switch(inventoryWindow->items->getId(RFIFOW(2))) { + case 1201: + player_node->weapon = 1; + break; + case 1200: + player_node->weapon = 2; + break; + } } } + /*char info[40]; + sprintf(info, "aa %i %i %i", RFIFOW(2),RFIFOW(4),RFIFOB(6)); + chatBox->chat_log(info, BY_SERVER);*/ break; // Equipment related case 0x01d7: /*char content[40]; - sprintf(content, "%i %i %i", RFIFOB(6), RFIFOW(7), RFIFOW(9)); + sprintf(content, "1d7 %i %i %i", RFIFOB(6), RFIFOW(7), RFIFOW(9)); chatBox->chat_log(content, BY_SERVER);*/ - /*equipmentWindow->addEquipment(RFIFOB(6), RFIFOW(7)); - if(inventoryWindow->items->getIndex(RFIFOW(7))); - inventoryWindow->items->setEquipped( - inventoryWindow->items->getIndex(RFIFOW(7)), true);*/ - /*char info[40]; - sprintf(info, "1d7 %i %i %i %i", RFIFOL(2), RFIFOB(6), - RFIFOW(7), RFIFOW(9)); - chatBox->chat_log(info, BY_SERVER);*/ break; // Answer to unequip item case 0x00ac: @@ -1134,17 +1177,113 @@ void do_parse() { chatBox->chat_log("Unable to unequip.", BY_SERVER); else { if(RFIFOW(4)) { - int slot = 1; + int mask = 1; int position = 0; - while(RFIFOW(4) != slot) { - slot *= 2; + while(!(RFIFOW(4) & mask)) { + mask *= 2; position++; } + int equipmentId = equipmentWindow->equipments[position-1].id; + if (equipmentId > 0) + inventoryWindow->items->setEquipped( + equipmentWindow->equipments[position-1].inventoryIndex, false); equipmentWindow->removeEquipment(position - 1); inventoryWindow->items->setEquipped( inventoryWindow->items->getIndex(), false); + player_node->weapon = 0; } } + /*char info2[40]; + sprintf(info2, "ac %i %i %i", RFIFOW(2),RFIFOW(4),RFIFOB(6)); + chatBox->chat_log(info2, BY_SERVER);*/ + break; + // Arrows equipped + case 0x013c: + /*char info3[40]; + sprintf(info3, "13c %i", RFIFOW(2)); + chatBox->chat_log(info3, BY_SERVER);*/ + inventoryWindow->items->setEquipped(RFIFOW(2), true); + break; + // Various messages + case 0x013b: + /*char msg[40]; + sprintf(msg, "13b %i", RFIFOW(2)); + chatBox->chat_log(msg, BY_SERVER);*/ + if (RFIFOW(2) == 0) + chatBox->chat_log("Equip arrows first", BY_SERVER); + break; + // Updates a stat value + case 0x00bc: + /*char stat[20]; + sprintf(stat, "bc %x %i %i", RFIFOW(2),RFIFOB(4),RFIFOB(5)); + chatBox->chat_log(stat, BY_SERVER);*/ + if(RFIFOB(4)) { + switch(RFIFOW(2)) { + case 0x000d: + char_info->STR = RFIFOB(5); + break; + case 0x000e: + char_info->AGI = RFIFOB(5); + break; + case 0x000f: + char_info->VIT = RFIFOB(5); + break; + case 0x0010: + char_info->INT = RFIFOB(5); + break; + case 0x0011: + char_info->DEX = RFIFOB(5); + break; + case 0x0012: + char_info->LUK = RFIFOB(5); + break; + } + } + break; + // Updates stats and status points + case 0x00bd: + char_info->statsPointsToAttribute = RFIFOW(2); + char_info->STR = RFIFOB(4); + char_info->STRUp = RFIFOB(5); + char_info->AGI = RFIFOB(6); + char_info->AGIUp = RFIFOB(7); + char_info->VIT = RFIFOB(8); + char_info->VITUp = RFIFOB(9); + char_info->INT = RFIFOB(10); + char_info->INTUp = RFIFOB(11); + char_info->DEX = RFIFOB(12); + char_info->DEXUp = RFIFOB(13); + char_info->LUK = RFIFOB(14); + char_info->LUKUp = RFIFOB(15); + /*char stats[100]; + sprintf(stats, "%i %i %i %i %i %i %i %i %i %i %i %i", + RFIFOB(4),RFIFOB(5),RFIFOB(6),RFIFOB(7),RFIFOB(8),RFIFOB(9), + RFIFOB(10),RFIFOB(11),RFIFOB(12),RFIFOB(13),RFIFOB(14),RFIFOB(15)); + chatBox->chat_log(stats,BY_SERVER);*/ + statusWindow->update(); + break; + // Updates status point + case 0x00be: + switch(RFIFOW(2)) { + case 0x0020: + char_info->STRUp = RFIFOB(4); + break; + case 0x0021: + char_info->AGIUp = RFIFOB(4); + break; + case 0x0022: + char_info->VITUp = RFIFOB(4); + break; + case 0x0023: + char_info->INTUp = RFIFOB(4); + break; + case 0x0024: + char_info->DEXUp = RFIFOB(4); + break; + case 0x0025: + char_info->LUKUp = RFIFOB(4); + break; + } break; // Manage non implemented packets default: diff --git a/src/gui/equipment.cpp b/src/gui/equipment.cpp index 410be42b..770a88df 100644 --- a/src/gui/equipment.cpp +++ b/src/gui/equipment.cpp @@ -38,7 +38,8 @@ EquipmentWindow::EquipmentWindow(): itemset = new Spriteset(itemImg, 20, 20); for (int i = 0; i < 10; i++ ) { - equipments[i] = 0; + equipments[i].id = 0; + equipments[i].inventoryIndex = -1; } } @@ -55,12 +56,14 @@ void EquipmentWindow::draw(gcn::Graphics *graphics) Window::draw(graphics); for (int i = 0; i < 8; i++) { - if (equipments[i] > 0) { - itemset->spriteset[equipments[i] - 501]->draw(screen, + if (equipments[i].id > 0) { + itemset->spriteset[equipments[i].id - 501]->draw(screen, x + 22, y + 24 * i + 20); } graphics->setColor(gcn::Color(0, 0, 0)); graphics->drawRectangle(gcn::Rectangle(22, 24 * i + 20, 20, 20)); + + } } @@ -69,10 +72,18 @@ void EquipmentWindow::action(const std::string &eventId) } void EquipmentWindow::addEquipment(int index, int id) { - equipments[index] = id; + equipments[index].id = id; } void EquipmentWindow::removeEquipment(int index) { - equipments[index] = 0; + equipments[index].id = 0; +} + +void EquipmentWindow::setInventoryIndex(int index, int inventoryIndex) { + equipments[index].inventoryIndex = inventoryIndex; +} + +int EquipmentWindow::getInventoryIndex(int index) { + return equipments[index].inventoryIndex; } diff --git a/src/gui/equipment.h b/src/gui/equipment.h index 79f229d4..7a945f4c 100644 --- a/src/gui/equipment.h +++ b/src/gui/equipment.h @@ -28,6 +28,11 @@ #include "gui.h" #include "window.h" +typedef struct { + int id; + int inventoryIndex; +} EQUIPMENT_HOLDER; + /** * Equipment dialog. * @@ -59,7 +64,11 @@ class EquipmentWindow : public Window, gcn::ActionListener { void removeEquipment(int index); - int equipments[10]; + void setInventoryIndex(int index, int inventoryIndex); + + int getInventoryIndex(int index); + + EQUIPMENT_HOLDER equipments[10]; private: diff --git a/src/gui/inventory.cpp b/src/gui/inventory.cpp index 326a8e70..4681d047 100644 --- a/src/gui/inventory.cpp +++ b/src/gui/inventory.cpp @@ -66,19 +66,11 @@ void InventoryWindow::draw(gcn::Graphics *graphics) int InventoryWindow::addItem(int index, int id, int quantity, bool equipment) { - /*items[index].id = id; - items[index].quantity += quantity;*/ items->addItem(index, id, quantity, equipment); return 0; } int InventoryWindow::removeItem(int id) { - /*for (int i = 0; i < INVENTORY_SIZE; i++) { - if (items[i].id == id) { - items[i].id = -1; - items[i].quantity = 0; - } - }*/ items->removeItem(id); return 0; } @@ -128,7 +120,6 @@ void InventoryWindow::unequipItem(int index) { WFIFOW(2) = net_w_value(index); WFIFOSET(4); while ((out_size > 0)) flush(); - } void InventoryWindow::action(const std::string &eventId) diff --git a/src/gui/itemcontainer.cpp b/src/gui/itemcontainer.cpp index 30d6bde3..4398fcb2 100644 --- a/src/gui/itemcontainer.cpp +++ b/src/gui/itemcontainer.cpp @@ -184,3 +184,8 @@ void ItemContainer::setEquipped(int index, bool equipped) { items[index].equipped = equipped; } + +void ItemContainer::setEquipment(int index, bool equipment) +{ + items[index].equipment = equipment; +} diff --git a/src/gui/itemcontainer.h b/src/gui/itemcontainer.h index dc88655a..3dbc3b7c 100644 --- a/src/gui/itemcontainer.h +++ b/src/gui/itemcontainer.h @@ -130,6 +130,8 @@ class ItemContainer : public gcn::Widget bool isEquipped(int index); void setEquipped(int index, bool equipped); + + void setEquipment(int index, bool equipment); }; #endif diff --git a/src/gui/stats.cpp b/src/gui/stats.cpp index bc2e4f34..4629d5fa 100644 --- a/src/gui/stats.cpp +++ b/src/gui/stats.cpp @@ -33,6 +33,7 @@ StatsWindow::StatsWindow(): for (i = 0; i < 6; i++) { statsLabel[i] = new gcn::Label(); statsDisplayLabel[i] = new gcn::Label(); + pointsLabel[i] = new gcn::Label("0"); } remainingStatsPointsLabel = new gcn::Label(); @@ -51,9 +52,10 @@ StatsWindow::StatsWindow(): // Set position for (i = 0; i < 6; i++) { - statsLabel[i]->setPosition(10,(i*23)+10); - statsDisplayLabel[i]->setPosition(120,(i*23)+10); - statsButton[i]->setPosition(170,(i*23)+10); + statsLabel[i]->setPosition(10,(i * 23) + 10); + statsDisplayLabel[i]->setPosition(120,(i * 23) + 10); + statsButton[i]->setPosition(150, (i * 23) + 5); + pointsLabel[i]->setPosition(180, (i * 23) + 10); } remainingStatsPointsLabel->setPosition(10, 156); @@ -62,6 +64,7 @@ StatsWindow::StatsWindow(): add(statsLabel[i]); add(statsDisplayLabel[i]); add(statsButton[i]); + add(pointsLabel[i]); statsButton[i]->addActionListener(this); } add(remainingStatsPointsLabel); @@ -75,6 +78,7 @@ StatsWindow::StatsWindow(): void StatsWindow::update(){ std::stringstream statsStr[6]; std::stringstream figureStr[6]; + std::stringstream pointsStr[6]; std::stringstream remainingStatsPointsStr; statsStr[0] << "Strength:"; @@ -90,9 +94,14 @@ void StatsWindow::update(){ statsStr[5] << "Luck:"; figureStr[5] << (int)char_info->LUK; - // for testing only... - - //remainingStatsPointsStr << "Remaining Status Points : " << char_info->statsPointsToAttribute; + remainingStatsPointsStr << "Remaining Status Points : " << char_info->statsPointsToAttribute; + + pointsStr[0] << (int)char_info->STRUp; + pointsStr[1] << (int)char_info->AGIUp; + pointsStr[2] << (int)char_info->VITUp; + pointsStr[3] << (int)char_info->INTUp; + pointsStr[4] << (int)char_info->DEXUp; + pointsStr[5] << (int)char_info->LUKUp; // Update labels for (i = 0; i < 6; i++) { @@ -100,6 +109,8 @@ void StatsWindow::update(){ statsLabel[i]->adjustSize(); statsDisplayLabel[i]->setCaption(figureStr[i].str()); statsDisplayLabel[i]->adjustSize(); + pointsLabel[i]->setCaption(pointsStr[i].str()); + pointsLabel[i]->adjustSize(); } remainingStatsPointsLabel->setCaption(remainingStatsPointsStr.str()); remainingStatsPointsLabel->adjustSize(); diff --git a/src/gui/stats.h b/src/gui/stats.h index e03c2a86..edd94a73 100644 --- a/src/gui/stats.h +++ b/src/gui/stats.h @@ -57,6 +57,7 @@ class StatsWindow : public Window, public gcn::ActionListener { * Stats captions. */ gcn::Label *statsLabel[6]; + gcn::Label *pointsLabel[6]; gcn::Label *statsDisplayLabel[6]; gcn::Label *remainingStatsPointsLabel; @@ -79,6 +79,7 @@ typedef struct { int xp, xpForNextLevel, gp, job_xp, jobXpForNextLevel, job_lv; short statp, skill_point, hair_color, hair_style; char STR, AGI, VIT, INT, DEX, LUK; + char STRUp, AGIUp, VITUp, INTUp, DEXUp, LUKUp; short weapon; // skill list declaration std::vector<SKILL> m_Skill; // array of N_SKILLS skills |