diff options
-rw-r--r-- | src/being.cpp | 8 | ||||
-rw-r--r-- | src/game.cpp | 32 | ||||
-rw-r--r-- | src/graphic/graphic.cpp | 11 | ||||
-rw-r--r-- | src/graphic/graphic.h | 2 | ||||
-rw-r--r-- | src/net/protocol.cpp | 50 | ||||
-rw-r--r-- | src/net/protocol.h | 3 | ||||
-rw-r--r-- | tmw.ini | 6 |
7 files changed, 50 insertions, 62 deletions
diff --git a/src/being.cpp b/src/being.cpp index ca527882..c2e93ca1 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -156,11 +156,11 @@ unsigned int find_npc(unsigned short x, unsigned short y) { unsigned int find_monster(unsigned short x, unsigned short y) { NODE *node = head; while(node) { - //if((node->job>=46)&&(node->job<=125)) { // Check if is a NPC (only low job ids) - if((get_x(node->coordinates)==x)&&(get_y(node->coordinates)==y)) + if(node->job>200) { // Check if is a MONSTER + if(get_x(node->coordinates)==x && get_y(node->coordinates)==y) return node->id; - else node = node->next; - //} else node = node->next; + } + node = node->next; } return 0; } diff --git a/src/game.cpp b/src/game.cpp index 90aac57b..b6d21c5a 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -200,7 +200,7 @@ void do_input() { if(player_node->action==STAND) if(key[KEY_LCONTROL]) { player_node->action = ATTACK; - attack(x, y, get_direction(player_node->coordinates)); + attack(get_x(player_node->coordinates), get_y(player_node->coordinates), get_direction(player_node->coordinates)); player_node->tick_time = tick_time; } @@ -230,22 +230,6 @@ void do_input() { } } - //rect(screen, (mouse_x/32)*32,(mouse_y/32)*32, ((mouse_x/32)+1)*32, ((mouse_y/32)+1)*32, makecol(255,255,255)); - - if(mouse_b&2) { - if(!show_npc_dialog) { - int npc_x = mouse_x/32+map_x/32; - int npc_y = mouse_y/32+map_y/32; - int id = find_npc(npc_x, npc_y); - if(id!=0) { - WFIFOW(0) = net_w_value(0x0090); - WFIFOL(2) = net_l_value(id); - WFIFOB(6) = 0; - WFIFOSET(7); - } - } - } - // Emotions, Skill dialog if(key_shifts & KB_ALT_FLAG && action_time == true) { if(player_node->emotion==0) { @@ -283,6 +267,20 @@ void do_input() { action_time = false; } } + + if(mouse_b&2) { + if(!show_npc_dialog) { + int npc_x = mouse_x/32+camera_x; + int npc_y = mouse_y/32+camera_y; + int id = find_npc(npc_x, npc_y); + if(id!=0) { + WFIFOW(0) = net_w_value(0x0090); + WFIFOL(2) = net_l_value(id); + WFIFOB(6) = 0; + WFIFOSET(7); + } + } + } if(key[KEY_ESC])state = EXIT; diff --git a/src/graphic/graphic.cpp b/src/graphic/graphic.cpp index 3799c4fb..7cda470f 100644 --- a/src/graphic/graphic.cpp +++ b/src/graphic/graphic.cpp @@ -43,7 +43,7 @@ BITMAP *buffer, *double_buffer, *chat_background; DATAFILE *tileset; char page_num; -int map_x, map_y; +int map_x, map_y, camera_x, camera_y; DIALOG_PLAYER *chat_player, *npc_player, *skill_player; char speech[255] = ""; char npc_text[1000] = ""; @@ -127,8 +127,8 @@ void do_graphic(void) { map_x = (get_x(player_node->coordinates)-13)*16+get_x_offset(player_node); map_y = (get_y(player_node->coordinates)-9)*16+get_y_offset(player_node); - int camera_x = map_x >> 4; - int camera_y = map_y >> 4; + camera_x = map_x >> 4; + camera_y = map_y >> 4; int offset_x = map_x & 15; int offset_y = map_y & 15; @@ -214,9 +214,10 @@ void do_graphic(void) { // Draw player speech node = get_head(); while(node) { + //alfont_textprintf_aa(double_buffer, gui_font, node->text_x+260, node->text_y+100, node->speech_color, "%i,%i", get_x(node->coordinates),get_y(node->coordinates)); if(node->speech!=NULL) { alfont_textprintf_aa(double_buffer, gui_font, node->text_x+260-alfont_text_length(gui_font, node->speech)/2, node->text_y+100, node->speech_color, "%s", node->speech); - + node->speech_time--; if(node->speech_time==0) { free(node->speech); @@ -245,7 +246,7 @@ void do_graphic(void) { } - alfont_textprintf_aa(double_buffer, gui_font, 0, 0, MAKECOL_WHITE, "FPS:%i %i %i", fps,get_x(player_node->coordinates),get_y(player_node->coordinates)); + alfont_textprintf(double_buffer, gui_font, 0, 0, MAKECOL_WHITE, "FPS:%i", fps); blit(double_buffer, screen, 0, 0, 0, 0, 800, 600); diff --git a/src/graphic/graphic.h b/src/graphic/graphic.h index f8b477ee..3622a665 100644 --- a/src/graphic/graphic.h +++ b/src/graphic/graphic.h @@ -41,7 +41,7 @@ extern Chat chatlog; extern bool show_skill_dialog; extern int show_npc_dialog; extern TmwInventory inventory; -extern int map_x, map_y; +extern int map_x, map_y, camera_x, camera_y; void do_graphic(void); void init_graphic(void); diff --git a/src/net/protocol.cpp b/src/net/protocol.cpp index 2c33d092..d2b1ceb7 100644 --- a/src/net/protocol.cpp +++ b/src/net/protocol.cpp @@ -218,11 +218,11 @@ void speak(char *speech) { WFIFOSET(len+4); } -/** request action */ -void action(short type, int id) { +/** Request action */ +void action(char type, int id) { WFIFOW(0) = net_w_value(0x0089); WFIFOL(2) = net_l_value(id); - WFIFOB(6) = net_l_value(type); + WFIFOB(6) = net_b_value(type); WFIFOSET(7); } @@ -231,34 +231,22 @@ void action(short type, int id) { void attack(unsigned short x, unsigned short y, unsigned char direction) { int monster_id = 0; - if(direction==2) { - for(int j=-1;j<2;j++) - for(int i=-1;i<1;i++) { - monster_id = find_monster(x+i, y+j); - if(monster_id!=0) - action(0x07, monster_id); - } - } else if(direction==6) { - for(int j=-1;j<2;j++) - for(int i=0;i<2;i++) { - monster_id = find_monster(x+i, y+j); - if(monster_id!=0) - action(0x07, monster_id); - } - } else if(direction==4) { - for(int j=-1;j<1;j++) - for(int i=-1;i<2;i++) { - monster_id = find_monster(x+i, y+j); - if(monster_id!=0) - action(0x07, monster_id); - } - } else if(direction==0) { - for(int j=0;j<1;j++) - for(int i=-1;i<2;i++) { - monster_id = find_monster(x+i, y+j); - if(monster_id!=0) - action(0x07, monster_id); - } + if(direction==SOUTH) { + monster_id = find_monster(x, y+1); + if(monster_id!=0) + action(0, monster_id); + } else if(direction==WEST) { + monster_id = find_monster(x-1, y); + if(monster_id!=0) + action(0, monster_id); + } else if(direction==NORTH) { + monster_id = find_monster(x, y-1); + if(monster_id!=0) + action(0, monster_id); + } else if(direction==EAST) { + monster_id = find_monster(x+1, y); + if(monster_id!=0) + action(0, monster_id); } } diff --git a/src/net/protocol.h b/src/net/protocol.h index 60293e4a..0a781ee2 100644 --- a/src/net/protocol.h +++ b/src/net/protocol.h @@ -53,5 +53,6 @@ void map_start(); void walk(unsigned short x, unsigned short y, unsigned char direction); void speak(char *speech); void attack(unsigned short x, unsigned short y, unsigned char direction); -void action(short, int); +void action(char type, int id); + #endif @@ -4,8 +4,8 @@ keyboard = en language = [server] -host = animesites.de -;host = themanaworld.homeip.net +;host = animesites.de +host = themanaworld.homeip.net ;host = telekommunisten.dyndns.org port = 6901 @@ -28,4 +28,4 @@ stretch = 1 [login] remember = 1 -username = test2 +username = elven |