From 164304107f38397434a0b251c3a2f0ee106ecdbe Mon Sep 17 00:00:00 2001 From: Eugenio Favalli Date: Sun, 7 Nov 2004 17:13:29 +0000 Subject: NPC lists --- The Mana World.dev | 22 ++++++++++++- docs/INSTALL/debian.txt | 73 ++++++++++++++++++++++++++++++++++++++++ src/game.cpp | 29 ++++++++++++++++ src/graphic/graphic.cpp | 38 +++++++++++++++++++-- src/graphic/graphic.h | 2 ++ src/gui/char_select.cpp | 2 +- src/gui/npc.cpp | 88 +++++++++++++++++++++++++++++++++++++++++++++++++ src/gui/npc.h | 38 +++++++++++++++++++++ 8 files changed, 287 insertions(+), 5 deletions(-) create mode 100644 docs/INSTALL/debian.txt create mode 100644 src/gui/npc.cpp create mode 100644 src/gui/npc.h diff --git a/The Mana World.dev b/The Mana World.dev index 3313f2ce..a9094a10 100644 --- a/The Mana World.dev +++ b/The Mana World.dev @@ -1,7 +1,7 @@ [Project] FileName=The Mana World.dev Name=tmw -UnitCount=41 +UnitCount=43 Type=0 Ver=1 ObjFiles= @@ -463,3 +463,23 @@ OverrideBuildCmd=0 BuildCmd= ########Text Field info##### +[Unit42] +FileName=src\gui\npc.h +CompileCpp=1 +Folder=gui +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit43] +FileName=src\gui\npc.cpp +CompileCpp=1 +Folder=gui +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + diff --git a/docs/INSTALL/debian.txt b/docs/INSTALL/debian.txt new file mode 100644 index 00000000..146a84c9 --- /dev/null +++ b/docs/INSTALL/debian.txt @@ -0,0 +1,73 @@ +How to install TMW on my GNU/Debian Box +================================================== + +Author: FERREIRA Yohann (Bertram) +Email: Bertram25@hotmail.com +Homepage: http://www.behemoth.fr.fm (Take a tour on it with mozilla !) + +The Mana World project +====================== +Homepage: themanaworld.sourceforge.net +IRC: irc.freenode.net / #manaworld + +1) Installing The Mana World Dependancies +2) Make the latest Mana World Debian package and install it +3) Notes + +1. Installing The Mana World Dependancies +============================================= + +The Mana World Debian Package can be installed under the Debian Testing and Unstable (Sarge/Cid). +In order to have Mana World working, you'll need the following packages that are situed in : + +- JGMod : +http://themanaworl.sourceforge.net/files/jgmod_0.99_i386.deb +- AlFont : +http://themanaworl.sourceforge.net/files/libalfont_1.9.2_i386.deb + +Note : If the packages names mismatches, check the page : http://themanaworl.sourceforge.net/files/ +to look for the latest version of these packages. + +When you've grabbed them, install them (as root) with the commands : + dpkg -i jgmod_0.99_i386.deb + dpkg -i libalfont_1.9.2_i386.deb + +liballegro4.1 must be installed before doing the previous commands, you can do install it by typing (as root) : + apt-get install liballegro4.1 + +2. Make the latest Mana World Debian Package and install it +========================================================== + +The next step is now to download the latest CVS version or a tarball in the Download Section of the Mana World WebSite. +(I think you've got it because you're reading this file which is included in, right !) + +you must have gcc and g++ installed, and also liballegro-dev. +Don't forget them : + apt-get install gcc g++ liballegro-dev + +Now open a shell and go in the root of the new extracted tarball. You should see a file named GenDeb.sh. +Become root, +Make it executable : + chmod +x GenDeb.sh +And now create the Debian Package !!! : + ./GenDeb.sh + +Let it work : and TADAM ! +The new package should be in the same directory as GenDeb.sh and should be named : + manaworld_XXXXXX_i386.deb (XXXXXX is the version number...) +Install it : + dpkg -i manaworld_XXXXXX_i386.deb +(If you've got a previous one already installed with the same version number, don't forget to remove it with :) + apt-get remove manaworld + (Don't worry, you configuratio files are not removed...) + +And now the final step : type 'manaworld' as a normal user in a shell and you're in !!! + +(Don't forget : To create a new account, add a '_M' after your account name the first time. After that just type your account name normally...) + +3. Notes +======== + +you can always join team people in the IRC of Manaworld : +irc://irc.freenode.net#manaworld + diff --git a/src/game.cpp b/src/game.cpp index 0a50dd44..0dec4268 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -34,6 +34,7 @@ #include "./gui/gui.h" #include "./gui/inventory.h" #include "./gui/shop.h" +#include "./gui/npc.h" #include "./graphic/graphic.h" #include "./sound/sound.h" @@ -799,6 +800,34 @@ void do_parse() { WFIFOL(2) = net_l_value(RFIFOL(2)); WFIFOSET(6); break; + // Next button in NPC dialog + case 0x00b5: + strcpy(npc_button, "Next"); + current_npc = RFIFOL(2); + break; + // Close button in NPC dialog + case 0x00b6: + strcpy(npc_button, "Close"); + current_npc = RFIFOL(2); + break; + // List in NPC dialog + case 0x00b7: + current_npc = RFIFOL(4); + alert(RFIFOP(8),"","","","",0,0); + parse_items(RFIFOP(8), RFIFOW(2)); + show_npc_dialog = 5; + break; + // Look change + case 0x00c3: + // Change hair color + if(RFIFOB(6)==6) { + node = find_node(RFIFOL(2)); + node->hair_color = RFIFOB(7); + /*char prova[100]; + sprintf(prova, "%i %i %i", RFIFOL(2), RFIFOB(6), RFIFOB(7)); + alert(prova,"","","","",0,0);*/ + } + break; // Manage non implemented packets default: //printf("%x\n",id); diff --git a/src/graphic/graphic.cpp b/src/graphic/graphic.cpp index 9a323379..3cc90377 100644 --- a/src/graphic/graphic.cpp +++ b/src/graphic/graphic.cpp @@ -39,7 +39,7 @@ DATAFILE *tileset; char itemCurrenyQ[10] = "0"; char page_num; int map_x, map_y, camera_x, camera_y; -DIALOG_PLAYER *chat_player, *npc_player, *skill_player, *buy_sell_player, *buy_player, *sell_player, *stats_player, *skill_list_player; +DIALOG_PLAYER *chat_player, *npc_player, *skill_player, *buy_sell_player, *buy_player, *sell_player, *stats_player, *skill_list_player, *npc_list_player; char speech[255] = ""; char npc_text[1000] = ""; char statsString2[255] = "n/a"; @@ -49,11 +49,12 @@ Chat chatlog("./docs/chatlog.txt", 20); int show_npc_dialog = 0; bool show_skill_dialog = false; bool show_skill_list_dialog = false; +char npc_button[10] = "Close"; DIALOG npc_dialog[] = { /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */ { tmw_dialog_proc, 300, 200, 260, 150, 0, 0, 0, 0, 0, 0, (char *)"NPC", NULL, NULL }, - { tmw_button_proc, 508, 326, 50, 20, 255, 0, 'c', D_EXIT, 0, 0, (char *)"&Close", NULL, NULL }, + { tmw_button_proc, 508, 326, 50, 20, 255, 0, 'c', D_EXIT, 0, 0, (char *)npc_button, NULL, NULL }, { tmw_textbox_proc, 304, 224, 252, 100, 0, 0, 0, 0, 0, 0, npc_text, NULL, NULL }, { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL } }; @@ -107,6 +108,15 @@ DIALOG chat_dialog[] = { { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL } }; +DIALOG npc_list_dialog[] = { + /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */ + { tmw_dialog_proc, 300, 200, 260, 200, 0, 0, 0, 0, 0, 0, (char *)"NPC", NULL, NULL }, + { tmw_button_proc, 450, 376, 50, 20, 255, 0, 'o', D_EXIT, 0, 0, (char *)"&Ok", NULL, NULL }, + { tmw_button_proc, 508, 376, 50, 20, 255, 0, 'c', D_EXIT, 0, 0, (char *)"&Cancel", NULL, NULL }, + { tmw_list_proc, 304, 224, 252, 100, 0, 0, 0, 0, 0, 0, (char *)item_list, NULL, NULL }, + { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL } +}; + char hairtable[10][4][2] = { // S(x,y) W(x,y) N(x,y) E(x,y) { { 0, 0}, {-1, 2}, {-1, 2}, {0, 2} }, // STAND @@ -181,6 +191,7 @@ void init_graphic() { buy_player = init_dialog(buy_dialog, -1); sell_player = init_dialog(sell_dialog, -1); skill_list_player = init_dialog(skill_list_dialog, -1); + npc_list_player = init_dialog(npc_list_dialog, -1); gui_bitmap = double_buffer; alfont_text_mode(-1); inventory.create(100, 100); @@ -361,7 +372,13 @@ void do_graphic(void) { switch(show_npc_dialog) { case 1: dialog_message(npc_dialog, MSG_DRAW, 0, 0); - if(!(show_npc_dialog = gui_update(npc_player)))strcpy(npc_text, ""); + if(!(show_npc_dialog = gui_update(npc_player))) { + strcpy(npc_text, ""); + WFIFOW(0) = net_w_value(0x00b9); + //alert("","","","","",0,0); + WFIFOL(2) = net_l_value(current_npc); + WFIFOSET(6); + } break; case 2: dialog_message(buy_sell_dialog, MSG_DRAW, 0, 0); @@ -425,6 +442,21 @@ void do_graphic(void) { close_shop(); } break; + case 5: + dialog_message(npc_list_dialog, MSG_DRAW, 0, 0); + if(!gui_update(npc_list_player)) { + show_npc_dialog = shutdown_dialog(npc_list_player); + if(show_npc_dialog==1) { + WFIFOW(0) = net_w_value(0x00b8); + WFIFOL(2) = net_l_value(current_npc); + WFIFOB(6) = net_b_value(npc_list_dialog[3].d1+1); + WFIFOSET(7); + } + show_npc_dialog = 0; + npc_list_player = init_dialog(npc_list_dialog, -1); + remove_all_items(); + } + break; } if(show_skill_dialog) { diff --git a/src/graphic/graphic.h b/src/graphic/graphic.h index a652b5cf..571f5136 100644 --- a/src/graphic/graphic.h +++ b/src/graphic/graphic.h @@ -39,6 +39,7 @@ #include "../gui/shop.h" #include "../gui/chat.h" #include "../gui/inventory.h" +#include "../gui/npc.h" #include "../../data/graphic/gfx_data.h" extern BITMAP *buffer, *double_buffer; @@ -51,6 +52,7 @@ extern int show_npc_dialog; extern TmwInventory inventory; extern int map_x, map_y, camera_x, camera_y; extern BITMAP *hairset; +extern char npc_button[10]; void set_npc_dialog(int show); void do_graphic(void); diff --git a/src/gui/char_select.cpp b/src/gui/char_select.cpp index ad151f25..b4294f3d 100644 --- a/src/gui/char_select.cpp +++ b/src/gui/char_select.cpp @@ -58,7 +58,7 @@ DIALOG char_create_dialog[] = { { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }, }; -#define MAX_HAIR_COLOR 6 +#define MAX_HAIR_COLOR 10 int tmw_incbutt_proc(int msg, DIALOG *d, int c) { if(msg==MSG_CLICK) { diff --git a/src/gui/npc.cpp b/src/gui/npc.cpp new file mode 100644 index 00000000..43deb1a8 --- /dev/null +++ b/src/gui/npc.cpp @@ -0,0 +1,88 @@ +/** + + The Mana World + Copyright 2004 The Mana World Development Team + + This file is part of The Mana World. + + The Mana World is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + any later version. + + The Mana World is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with The Mana World; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + By ElvenProgrammer aka Eugenio Favalli (umperio@users.sourceforge.net) + +*/ + +#include +#include +#include + +#include "npc.h" + +ITEM *item_head = NULL; +int item_number = 0; + +char *item_list(int index, int *list_size) { + if(index<0) { + *list_size = item_number; + return NULL; + } else { + int iterator = 0; + ITEM *temp = item_head; + while(iteratornext; + iterator++; + } + return temp->name; + } +} + +void add_item(char *name) { + ITEM *item = item_head; + ITEM *temp = (ITEM *)malloc(sizeof(ITEM)); + temp->name = name; + temp->next = NULL; + if(!item_head) + item_head = temp; + else { + while(item->next) + item = item->next; + item->next = temp; + } + item_number++; +} + +void parse_items(char *string, short len) { + char *token = strtok(string, ":"); + while(token!=NULL) { + char *temp = (char *)malloc(strlen(token)); + strcpy(temp, token); + add_item(temp); + token = strtok(NULL, ":"); + } +} + +void remove_all_items() { + ITEM *temp, *next; + temp = item_head; + while(temp) { + next = temp->next; + free(temp->name); + free(temp); + temp = next; + } + item_head = NULL; + item_number = 0; +} + + diff --git a/src/gui/npc.h b/src/gui/npc.h new file mode 100644 index 00000000..ed2e3e88 --- /dev/null +++ b/src/gui/npc.h @@ -0,0 +1,38 @@ +/** + + The Mana World + Copyright 2004 The Mana World Development Team + + This file is part of The Mana World. + + The Mana World is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + any later version. + + The Mana World is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with The Mana World; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + By ElvenProgrammer aka Eugenio Favalli (umperio@users.sourceforge.net) + +*/ + +#ifndef _NPC_H +#define _NPC_H + +struct ITEM { + char *name; + ITEM *next; +}; + +char *item_list(int index, int *list_size); +void parse_items(char *string, short len); +void remove_all_items(); + +#endif -- cgit v1.2.3-70-g09d2