… | |
… | |
37 | player * |
37 | player * |
38 | find_player (const char *plname) |
38 | find_player (const char *plname) |
39 | { |
39 | { |
40 | player *pl; |
40 | player *pl; |
41 | |
41 | |
42 | for (pl = first_player; pl != NULL; pl = pl->next) |
42 | for (pl = first_player; pl; pl = pl->next) |
43 | { |
43 | { |
44 | if (pl->ob != NULL && !strcmp (query_name (pl->ob), plname)) |
44 | if (pl->obL && !strcmp (query_name (pl->ob), plname)) |
45 | return pl; |
45 | return pl; |
46 | }; |
46 | }; |
|
|
47 | |
47 | return NULL; |
48 | return 0; |
48 | } |
49 | } |
49 | |
50 | |
50 | player * |
51 | player * |
51 | find_player_partial_name (const char *plname) |
52 | find_player_partial_name (const char *plname) |
52 | { |
53 | { |
53 | player *pl; |
54 | player *pl; |
54 | player *found = NULL; |
55 | player *found = NULL; |
55 | size_t namelen = strlen (plname); |
56 | size_t namelen = strlen (plname); |
56 | |
57 | |
57 | for (pl = first_player; pl != NULL; pl = pl->next) |
58 | for (pl = first_player; pl; pl = pl->next) |
58 | { |
59 | { |
59 | if ((size_t) strlen (pl->ob->name) < namelen) |
60 | if ((size_t) strlen (pl->ob->name) < namelen) |
60 | continue; |
61 | continue; |
61 | |
62 | |
62 | if (!strcmp (pl->ob->name, plname)) |
63 | if (!strcmp (pl->ob->name, plname)) |
63 | return pl; |
64 | return pl; |
64 | |
65 | |
65 | if (!strncasecmp (pl->ob->name, plname, namelen)) |
66 | if (!strncasecmp (pl->ob->name, plname, namelen)) |
66 | { |
67 | { |
67 | if (found) |
68 | if (found) |
68 | return NULL; |
69 | return 0; |
69 | |
70 | |
70 | found = pl; |
71 | found = pl; |
71 | } |
72 | } |
72 | } |
73 | } |
|
|
74 | |
73 | return found; |
75 | return found; |
74 | } |
76 | } |
75 | |
77 | |
76 | void |
78 | void |
77 | display_motd (const object *op) |
79 | display_motd (const object *op) |
… | |
… | |
87 | return; |
89 | return; |
88 | |
90 | |
89 | motd[0] = '\0'; |
91 | motd[0] = '\0'; |
90 | size = 0; |
92 | size = 0; |
91 | |
93 | |
92 | while (fgets (buf, MAX_BUF, fp) != NULL) |
94 | while (fgets (buf, MAX_BUF, fp)) |
93 | { |
95 | { |
94 | if (*buf == '#') |
96 | if (*buf == '#') |
95 | continue; |
97 | continue; |
96 | |
98 | |
97 | strncat (motd + size, buf, HUGE_BUF - size); |
99 | strncat (motd + size, buf, HUGE_BUF - size); |
… | |
… | |
116 | return; |
118 | return; |
117 | |
119 | |
118 | rules[0] = '\0'; |
120 | rules[0] = '\0'; |
119 | size = 0; |
121 | size = 0; |
120 | |
122 | |
121 | while (fgets (buf, MAX_BUF, fp) != NULL) |
123 | while (fgets (buf, MAX_BUF, fp)) |
122 | { |
124 | { |
123 | if (*buf == '#') |
125 | if (*buf == '#') |
124 | continue; |
126 | continue; |
125 | |
127 | |
126 | if (size + strlen (buf) >= HUGE_BUF) |
128 | if (size + strlen (buf) >= HUGE_BUF) |
… | |
… | |
244 | op->direction = 5; /* So player faces south */ |
246 | op->direction = 5; /* So player faces south */ |
245 | op->stats.wc = 2; |
247 | op->stats.wc = 2; |
246 | op->run_away = 25; /* Then we panick... */ |
248 | op->run_away = 25; /* Then we panick... */ |
247 | |
249 | |
248 | { |
250 | { |
249 | int oldmon = p->socket->monitor_spells; // what a hack |
251 | int oldmon = p->ns->monitor_spells; // what a hack |
250 | p->socket->monitor_spells = 0; /* Needed because esrv_update_spells( ) gets called by roll_stats */ |
252 | p->ns->monitor_spells = 0; /* Needed because esrv_update_spells( ) gets called by roll_stats */ |
251 | roll_stats (op); |
253 | roll_stats (op); |
252 | p->socket->monitor_spells = oldmon; |
254 | p->ns->monitor_spells = oldmon; |
253 | } |
255 | } |
254 | p->state = ST_ROLL_STAT; |
256 | p->ns->state = ST_ROLL_STAT; |
255 | clear_los (op); |
257 | clear_los (op); |
256 | |
258 | |
257 | p->gen_sp_armour = 10; |
259 | p->gen_sp_armour = 10; |
258 | p->last_speed = -1; |
260 | p->last_speed = -1; |
259 | p->shoottype = range_none; |
261 | p->shoottype = range_none; |
… | |
… | |
286 | p->last_resist[i] = -1; |
288 | p->last_resist[i] = -1; |
287 | |
289 | |
288 | p->last_stats.exp = -1; |
290 | p->last_stats.exp = -1; |
289 | p->last_weight = (uint32) - 1; |
291 | p->last_weight = (uint32) - 1; |
290 | |
292 | |
291 | p->socket->update_look = 0; |
293 | p->ns->update_look = 0; |
292 | p->socket->look_position = 0; |
294 | p->ns->look_position = 0; |
293 | |
295 | |
294 | return p; |
296 | return p; |
295 | } |
297 | } |
296 | |
298 | |
297 | /* This loads the first map an puts the player on it. */ |
299 | /* This loads the first map an puts the player on it. */ |
… | |
… | |
312 | int |
314 | int |
313 | add_player (client *ns) |
315 | add_player (client *ns) |
314 | { |
316 | { |
315 | player *p = new player; |
317 | player *p = new player; |
316 | |
318 | |
317 | p->socket = ns; |
319 | p->ns = ns; |
318 | ns->pl = p; |
320 | ns->pl = p; |
319 | |
321 | |
320 | p->next = first_player; |
322 | p->next = first_player; |
321 | first_player = p; |
323 | first_player = p; |
322 | |
324 | |
… | |
… | |
327 | CLEAR_FLAG (p->ob, FLAG_FRIENDLY); |
329 | CLEAR_FLAG (p->ob, FLAG_FRIENDLY); |
328 | add_friendly_object (p->ob); |
330 | add_friendly_object (p->ob); |
329 | send_rules (p->ob); |
331 | send_rules (p->ob); |
330 | send_news (p->ob); |
332 | send_news (p->ob); |
331 | display_motd (p->ob); |
333 | display_motd (p->ob); |
|
|
334 | |
332 | get_name (p->ob); |
335 | get_name (p->ob); |
333 | |
336 | |
334 | return 0; |
337 | return 0; |
335 | } |
338 | } |
336 | |
339 | |
… | |
… | |
697 | |
700 | |
698 | void |
701 | void |
699 | get_name (object *op) |
702 | get_name (object *op) |
700 | { |
703 | { |
701 | op->contr->write_buf[0] = '\0'; |
704 | op->contr->write_buf[0] = '\0'; |
702 | op->contr->state = ST_GET_NAME; |
705 | op->contr->ns->state = ST_GET_NAME; |
703 | send_query (op->contr->socket, 0, "What is your name?\n:"); |
706 | send_query (op->contr->ns, 0, "What is your name?\n:"); |
704 | } |
707 | } |
705 | |
708 | |
706 | void |
709 | void |
707 | get_password (object *op) |
710 | get_password (object *op) |
708 | { |
711 | { |
709 | op->contr->write_buf[0] = '\0'; |
712 | op->contr->write_buf[0] = '\0'; |
710 | op->contr->state = ST_GET_PASSWORD; |
713 | op->contr->ns->state = ST_GET_PASSWORD; |
711 | send_query (op->contr->socket, CS_QUERY_HIDEINPUT, "What is your password?\n:"); |
714 | send_query (op->contr->ns, CS_QUERY_HIDEINPUT, "What is your password?\n:"); |
712 | } |
715 | } |
713 | |
716 | |
714 | void |
717 | void |
715 | play_again (object *op) |
718 | play_again (object *op) |
716 | { |
719 | { |
717 | op->contr->state = ST_PLAY_AGAIN; |
720 | op->contr->ns->state = ST_PLAY_AGAIN; |
718 | op->chosen_skill = NULL; |
721 | op->chosen_skill = NULL; |
719 | send_query (op->contr->socket, CS_QUERY_SINGLECHAR, "Do you want to play again (a/q)?"); |
722 | send_query (op->contr->ns, CS_QUERY_SINGLECHAR, "Do you want to play again (a/q)?"); |
720 | /* a bit of a hack, but there are various places early in th |
723 | /* a bit of a hack, but there are various places early in th |
721 | * player creation process that a user can quit (eg, roll |
724 | * player creation process that a user can quit (eg, roll |
722 | * stats) that isn't removing the player. Taking a quick |
725 | * stats) that isn't removing the player. Taking a quick |
723 | * look, there are many places that call play_again without |
726 | * look, there are many places that call play_again without |
724 | * removing the player - it probably makes more sense |
727 | * removing the player - it probably makes more sense |
725 | * to leave it to play_again to remove the object in all |
728 | * to leave it to play_again to remove the object in all |
726 | * cases. |
729 | * cases. |
727 | */ |
730 | */ |
728 | if (!QUERY_FLAG (op, FLAG_REMOVED)) |
731 | if (!QUERY_FLAG (op, FLAG_REMOVED)) |
729 | op->remove (); |
732 | op->remove (); |
|
|
733 | |
730 | /* Need to set this to null - otherwise, it could point to garbage, |
734 | /* Need to set this to null - otherwise, it could point to garbage, |
731 | * and draw() doesn't check to see if the player is removed, only if |
735 | * and draw() doesn't check to see if the player is removed, only if |
732 | * the map is null or not swapped out. |
736 | * the map is null or not swapped out. |
733 | */ |
737 | */ |
734 | op->map = NULL; |
738 | op->map = NULL; |
… | |
… | |
772 | void |
776 | void |
773 | confirm_password (object *op) |
777 | confirm_password (object *op) |
774 | { |
778 | { |
775 | |
779 | |
776 | op->contr->write_buf[0] = '\0'; |
780 | op->contr->write_buf[0] = '\0'; |
777 | op->contr->state = ST_CONFIRM_PASSWORD; |
781 | op->contr->ns->state = ST_CONFIRM_PASSWORD; |
778 | send_query (op->contr->socket, CS_QUERY_HIDEINPUT, "Please type your password again.\n:"); |
782 | send_query (op->contr->ns, CS_QUERY_HIDEINPUT, "Please type your password again.\n:"); |
779 | } |
783 | } |
780 | |
784 | |
781 | void |
785 | void |
782 | get_party_password (object *op, partylist *party) |
786 | get_party_password (object *op, partylist *party) |
783 | { |
787 | { |
… | |
… | |
785 | { |
789 | { |
786 | LOG (llevError, "get_party_password(): tried to make player %s join a NULL party", &op->name); |
790 | LOG (llevError, "get_party_password(): tried to make player %s join a NULL party", &op->name); |
787 | return; |
791 | return; |
788 | } |
792 | } |
789 | op->contr->write_buf[0] = '\0'; |
793 | op->contr->write_buf[0] = '\0'; |
790 | op->contr->state = ST_GET_PARTY_PASSWORD; |
794 | op->contr->ns->state = ST_GET_PARTY_PASSWORD; |
791 | op->contr->party_to_join = party; |
795 | op->contr->party_to_join = party; |
792 | send_query (op->contr->socket, CS_QUERY_HIDEINPUT, "What is the password?\n:"); |
796 | send_query (op->contr->ns, CS_QUERY_HIDEINPUT, "What is the password?\n:"); |
793 | } |
797 | } |
794 | |
798 | |
795 | |
799 | |
796 | /* This rolls four 1-6 rolls and sums the best 3 of the 4. */ |
800 | /* This rolls four 1-6 rolls and sums the best 3 of the 4. */ |
797 | int |
801 | int |
… | |
… | |
894 | |
898 | |
895 | void |
899 | void |
896 | Roll_Again (object *op) |
900 | Roll_Again (object *op) |
897 | { |
901 | { |
898 | esrv_new_player (op->contr, 0); |
902 | esrv_new_player (op->contr, 0); |
899 | send_query (op->contr->socket, CS_QUERY_SINGLECHAR, |
903 | send_query (op->contr->ns, CS_QUERY_SINGLECHAR, |
900 | "[y] to roll new stats [n] to use stats\n[1-7] [1-7] to swap stats.\nRoll again (y/n/1-7)? "); |
904 | "[y] to roll new stats [n] to use stats\n[1-7] [1-7] to swap stats.\nRoll again (y/n/1-7)? "); |
901 | } |
905 | } |
902 | |
906 | |
903 | void |
907 | void |
904 | Swap_Stat (object *op, int Swap_Second) |
908 | Swap_Stat (object *op, int Swap_Second) |
… | |
… | |
971 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
975 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
972 | } |
976 | } |
973 | else |
977 | else |
974 | Swap_Stat (op, stat_trans[keynum]); |
978 | Swap_Stat (op, stat_trans[keynum]); |
975 | |
979 | |
976 | send_query (op->contr->socket, CS_QUERY_SINGLECHAR, ""); |
980 | send_query (op->contr->ns, CS_QUERY_SINGLECHAR, ""); |
977 | return 1; |
981 | return 1; |
978 | } |
982 | } |
979 | switch (key) |
983 | switch (key) |
980 | { |
984 | { |
981 | case 'n': |
985 | case 'n': |
… | |
… | |
995 | enter_exit (op, NULL); |
999 | enter_exit (op, NULL); |
996 | #endif |
1000 | #endif |
997 | SET_ANIMATION (op, 2); /* So player faces south */ |
1001 | SET_ANIMATION (op, 2); /* So player faces south */ |
998 | /* Enter exit adds a player otherwise */ |
1002 | /* Enter exit adds a player otherwise */ |
999 | add_statbonus (op); |
1003 | add_statbonus (op); |
1000 | send_query (op->contr->socket, CS_QUERY_SINGLECHAR, |
1004 | send_query (op->contr->ns, CS_QUERY_SINGLECHAR, |
1001 | "Now choose a character.\nPress any key to change outlook.\nPress `d' when you're pleased.\n"); |
1005 | "Now choose a character.\nPress any key to change outlook.\nPress `d' when you're pleased.\n"); |
1002 | op->contr->state = ST_CHANGE_CLASS; |
1006 | op->contr->ns->state = ST_CHANGE_CLASS; |
1003 | if (op->msg) |
1007 | if (op->msg) |
1004 | new_draw_info (NDI_BLUE, 0, op, op->msg); |
1008 | new_draw_info (NDI_BLUE, 0, op, op->msg); |
1005 | return 0; |
1009 | return 0; |
1006 | } |
1010 | } |
1007 | case 'y': |
1011 | case 'y': |
1008 | case 'Y': |
1012 | case 'Y': |
1009 | roll_stats (op); |
1013 | roll_stats (op); |
1010 | send_query (op->contr->socket, CS_QUERY_SINGLECHAR, ""); |
1014 | send_query (op->contr->ns, CS_QUERY_SINGLECHAR, ""); |
1011 | return 1; |
1015 | return 1; |
1012 | |
1016 | |
1013 | case 'q': |
1017 | case 'q': |
1014 | case 'Q': |
1018 | case 'Q': |
1015 | play_again (op); |
1019 | play_again (op); |
1016 | return 1; |
1020 | return 1; |
1017 | |
1021 | |
1018 | default: |
1022 | default: |
1019 | send_query (op->contr->socket, CS_QUERY_SINGLECHAR, "Yes, No, Quit or 1-6. Roll again?"); |
1023 | send_query (op->contr->ns, CS_QUERY_SINGLECHAR, "Yes, No, Quit or 1-6. Roll again?"); |
1020 | return 0; |
1024 | return 0; |
1021 | } |
1025 | } |
1022 | return 0; |
1026 | return 0; |
1023 | } |
1027 | } |
1024 | |
1028 | |
… | |
… | |
1052 | create_treasure (tl, op, 0, 0, 0); |
1056 | create_treasure (tl, op, 0, 0, 0); |
1053 | |
1057 | |
1054 | INVOKE_PLAYER (BIRTH, op->contr); |
1058 | INVOKE_PLAYER (BIRTH, op->contr); |
1055 | INVOKE_PLAYER (LOGIN, op->contr); |
1059 | INVOKE_PLAYER (LOGIN, op->contr); |
1056 | |
1060 | |
1057 | op->contr->state = ST_PLAYING; |
1061 | op->contr->ns->state = ST_PLAYING; |
1058 | |
1062 | |
1059 | if (op->msg) |
1063 | if (op->msg) |
1060 | op->msg = NULL; |
1064 | op->msg = NULL; |
1061 | |
1065 | |
1062 | /* We create this now because some of the unique maps will need it |
1066 | /* We create this now because some of the unique maps will need it |
… | |
… | |
1133 | op->stats.grace = 0; |
1137 | op->stats.grace = 0; |
1134 | |
1138 | |
1135 | if (op->msg) |
1139 | if (op->msg) |
1136 | new_draw_info (NDI_BLUE, 0, op, op->msg); |
1140 | new_draw_info (NDI_BLUE, 0, op, op->msg); |
1137 | |
1141 | |
1138 | send_query (op->contr->socket, CS_QUERY_SINGLECHAR, "Press any key for the next race.\nPress `d' to play this race.\n"); |
1142 | send_query (op->contr->ns, CS_QUERY_SINGLECHAR, "Press any key for the next race.\nPress `d' to play this race.\n"); |
1139 | return 0; |
1143 | return 0; |
1140 | } |
1144 | } |
1141 | |
1145 | |
1142 | int |
1146 | int |
1143 | key_confirm_quit (object *op, char key) |
1147 | key_confirm_quit (object *op, char key) |
1144 | { |
1148 | { |
1145 | char buf[MAX_BUF]; |
1149 | char buf[MAX_BUF]; |
1146 | |
1150 | |
1147 | if (key != 'y' && key != 'Y' && key != 'q' && key != 'Q') |
1151 | if (key != 'y' && key != 'Y' && key != 'q' && key != 'Q') |
1148 | { |
1152 | { |
1149 | op->contr->state = ST_PLAYING; |
1153 | op->contr->ns->state = ST_PLAYING; |
1150 | new_draw_info (NDI_UNIQUE, 0, op, "OK, continuing to play."); |
1154 | new_draw_info (NDI_UNIQUE, 0, op, "OK, continuing to play."); |
1151 | return 1; |
1155 | return 1; |
1152 | } |
1156 | } |
1153 | |
1157 | |
1154 | INVOKE_PLAYER (LOGOUT, op->contr); |
1158 | INVOKE_PLAYER (LOGOUT, op->contr); |
… | |
… | |
1223 | { |
1227 | { |
1224 | op->enemy = NULL; |
1228 | op->enemy = NULL; |
1225 | CLEAR_FLAG (op, FLAG_SCARED); |
1229 | CLEAR_FLAG (op, FLAG_SCARED); |
1226 | return; |
1230 | return; |
1227 | } |
1231 | } |
|
|
1232 | |
1228 | get_rangevector (op, op->enemy, &rv, 0); |
1233 | get_rangevector (op, op->enemy, &rv, 0); |
1229 | |
1234 | |
1230 | dir = absdir (4 + rv.direction); |
1235 | dir = absdir (4 + rv.direction); |
1231 | for (diff = 0; diff < 3; diff++) |
1236 | for (diff = 0; diff < 3; diff++) |
1232 | { |
1237 | { |
1233 | int m = 1 - (RANDOM () & 2); |
1238 | int m = 1 - (RANDOM () & 2); |
1234 | |
1239 | |
1235 | if (move_ob (op, absdir (dir + diff * m), op) || (diff == 0 && move_ob (op, absdir (dir - diff * m), op))) |
1240 | if (move_ob (op, absdir (dir + diff * m), op) || (diff == 0 && move_ob (op, absdir (dir - diff * m), op))) |
1236 | { |
|
|
1237 | return; |
1241 | return; |
1238 | } |
|
|
1239 | } |
1242 | } |
|
|
1243 | |
1240 | /* Cornered, get rid of scared */ |
1244 | /* Cornered, get rid of scared */ |
1241 | CLEAR_FLAG (op, FLAG_SCARED); |
1245 | CLEAR_FLAG (op, FLAG_SCARED); |
1242 | op->enemy = NULL; |
1246 | op->enemy = NULL; |
1243 | } |
1247 | } |
1244 | |
1248 | |
… | |
… | |
2050 | CLEAR_FLAG (item, FLAG_ANIMATE); |
2054 | CLEAR_FLAG (item, FLAG_ANIMATE); |
2051 | item->face = item->arch->clone.face; |
2055 | item->face = item->arch->clone.face; |
2052 | item->speed = 0; |
2056 | item->speed = 0; |
2053 | update_ob_speed (item); |
2057 | update_ob_speed (item); |
2054 | } |
2058 | } |
2055 | if ((tmp = is_player_inv (item))) |
2059 | if ((tmp = item->in_player ())) |
2056 | esrv_update_item (UPD_ANIM, tmp, item); |
2060 | esrv_update_item (UPD_ANIM, tmp, item); |
2057 | } |
2061 | } |
2058 | } |
2062 | } |
2059 | else if (item->type == ROD || item->type == HORN) |
2063 | else if (item->type == ROD || item->type == HORN) |
2060 | { |
2064 | { |
… | |
… | |
2210 | * 0 otherwise |
2214 | * 0 otherwise |
2211 | */ |
2215 | */ |
2212 | static int |
2216 | static int |
2213 | player_attack_door (object *op, object *door) |
2217 | player_attack_door (object *op, object *door) |
2214 | { |
2218 | { |
2215 | |
|
|
2216 | /* If its a door, try to find a use a key. If we do destroy the door, |
2219 | /* If its a door, try to find a use a key. If we do destroy the door, |
2217 | * might as well return immediately as there is nothing more to do - |
2220 | * might as well return immediately as there is nothing more to do - |
2218 | * otherwise, we fall through to the rest of the code. |
2221 | * otherwise, we fall through to the rest of the code. |
2219 | */ |
2222 | */ |
2220 | object *key = find_key (op, op, door); |
2223 | object *key = find_key (op, op, door); |
… | |
… | |
2258 | * It should keep the code cleaner. |
2261 | * It should keep the code cleaner. |
2259 | * When this is called, the players direction has been updated |
2262 | * When this is called, the players direction has been updated |
2260 | * (taking into account confusion.) The player is also actually |
2263 | * (taking into account confusion.) The player is also actually |
2261 | * going to try and move (not fire weapons). |
2264 | * going to try and move (not fire weapons). |
2262 | */ |
2265 | */ |
2263 | |
|
|
2264 | void |
2266 | void |
2265 | move_player_attack (object *op, int dir) |
2267 | move_player_attack (object *op, int dir) |
2266 | { |
2268 | { |
2267 | object *tmp, *mon; |
2269 | object *tmp, *mon; |
2268 | sint16 nx, ny; |
2270 | sint16 nx, ny; |
… | |
… | |
2270 | maptile *m; |
2272 | maptile *m; |
2271 | |
2273 | |
2272 | nx = freearr_x[dir] + op->x; |
2274 | nx = freearr_x[dir] + op->x; |
2273 | ny = freearr_y[dir] + op->y; |
2275 | ny = freearr_y[dir] + op->y; |
2274 | |
2276 | |
2275 | on_battleground = op_on_battleground (op, NULL, NULL); |
2277 | on_battleground = op_on_battleground (op, 0, 0); |
2276 | |
2278 | |
2277 | /* If braced, or can't move to the square, and it is not out of the |
2279 | /* If braced, or can't move to the square, and it is not out of the |
2278 | * map, attack it. Note order of if statement is important - don't |
2280 | * map, attack it. Note order of if statement is important - don't |
2279 | * want to be calling move_ob if braced, because move_ob will move the |
2281 | * want to be calling move_ob if braced, because move_ob will move the |
2280 | * player. This is a pretty nasty hack, because if we could |
2282 | * player. This is a pretty nasty hack, because if we could |
… | |
… | |
2292 | return; /* Don't think this should happen */ |
2294 | return; /* Don't think this should happen */ |
2293 | } |
2295 | } |
2294 | else |
2296 | else |
2295 | m = op->map; |
2297 | m = op->map; |
2296 | |
2298 | |
2297 | if ((tmp = get_map_ob (m, nx, ny)) == NULL) |
2299 | if ((tmp = GET_MAP_OB (m, nx, ny)) == NULL) |
2298 | { |
2300 | { |
2299 | /* LOG(llevError,"player_move_attack: get_map_ob returns NULL, but player can not more there.\n"); */ |
2301 | /* LOG(llevError,"player_move_attack: GET_MAP_OB returns NULL, but player can not move there.\n"); */ |
2300 | return; |
2302 | return; |
2301 | } |
2303 | } |
2302 | |
2304 | |
2303 | mon = NULL; |
2305 | mon = 0; |
2304 | /* Go through all the objects, and find ones of interest. Only stop if |
2306 | /* Go through all the objects, and find ones of interest. Only stop if |
2305 | * we find a monster - that is something we know we want to attack. |
2307 | * we find a monster - that is something we know we want to attack. |
2306 | * if its a door or barrel (can roll) see if there may be monsters |
2308 | * if its a door or barrel (can roll) see if there may be monsters |
2307 | * on the space |
2309 | * on the space |
2308 | */ |
2310 | */ |
2309 | while (tmp != NULL) |
2311 | while (tmp) |
2310 | { |
2312 | { |
2311 | if (tmp == op) |
2313 | if (tmp == op) |
2312 | { |
2314 | { |
2313 | tmp = tmp->above; |
2315 | tmp = tmp->above; |
2314 | continue; |
2316 | continue; |
… | |
… | |
2324 | mon = tmp; |
2326 | mon = tmp; |
2325 | |
2327 | |
2326 | tmp = tmp->above; |
2328 | tmp = tmp->above; |
2327 | } |
2329 | } |
2328 | |
2330 | |
2329 | if (mon == NULL) /* This happens anytime the player tries to move */ |
2331 | if (!mon) /* This happens anytime the player tries to move */ |
2330 | return; /* into a wall */ |
2332 | return; /* into a wall */ |
2331 | |
2333 | |
2332 | if (mon->head != NULL) |
2334 | if (mon->head) |
2333 | mon = mon->head; |
2335 | mon = mon->head; |
2334 | |
2336 | |
2335 | if ((mon->type == DOOR && mon->stats.hp >= 0) || (mon->type == LOCKED_DOOR)) |
2337 | if ((mon->type == DOOR && mon->stats.hp >= 0) || (mon->type == LOCKED_DOOR)) |
2336 | if (player_attack_door (op, mon)) |
2338 | if (player_attack_door (op, mon)) |
2337 | return; |
2339 | return; |
… | |
… | |
2374 | * attack them either. |
2376 | * attack them either. |
2375 | */ |
2377 | */ |
2376 | if ((mon->type == PLAYER || mon->enemy != op) && |
2378 | if ((mon->type == PLAYER || mon->enemy != op) && |
2377 | (mon->type == PLAYER || QUERY_FLAG (mon, FLAG_UNAGGRESSIVE) || QUERY_FLAG (mon, FLAG_FRIENDLY)) && ( |
2379 | (mon->type == PLAYER || QUERY_FLAG (mon, FLAG_UNAGGRESSIVE) || QUERY_FLAG (mon, FLAG_FRIENDLY)) && ( |
2378 | #ifdef PROHIBIT_PLAYERKILL |
2380 | #ifdef PROHIBIT_PLAYERKILL |
2379 | (op->contr->peaceful |
2381 | (op->contr->peaceful |
2380 | || (mon->type == PLAYER |
2382 | || (mon->type == PLAYER |
2381 | && mon->contr-> |
2383 | && mon->contr-> |
2382 | peaceful)) && |
2384 | peaceful)) && |
2383 | #else |
2385 | #else |
2384 | op->contr->peaceful && |
2386 | op->contr->peaceful && |
2385 | #endif |
2387 | #endif |
2386 | !on_battleground)) |
2388 | !on_battleground)) |
2387 | { |
2389 | { |
2388 | if (!op->contr->braced) |
2390 | if (!op->contr->braced) |
2389 | { |
2391 | { |
2390 | play_sound_map (op->map, op->x, op->y, SOUND_PUSH_PLAYER); |
2392 | play_sound_map (op->map, op->x, op->y, SOUND_PUSH_PLAYER); |
2391 | (void) push_ob (mon, dir, op); |
2393 | (void) push_ob (mon, dir, op); |
2392 | } |
2394 | } |
2393 | else |
2395 | else |
2394 | { |
|
|
2395 | new_draw_info (0, 0, op, "You withhold your attack"); |
2396 | new_draw_info (0, 0, op, "You withhold your attack"); |
2396 | } |
2397 | |
2397 | if (op->contr->tmp_invis || op->hide) |
2398 | if (op->contr->tmp_invis || op->hide) |
2398 | make_visible (op); |
2399 | make_visible (op); |
2399 | } |
2400 | } |
2400 | |
2401 | |
2401 | /* If the object is a boulder or other rollable object, then |
2402 | /* If the object is a boulder or other rollable object, then |
… | |
… | |
2429 | op->speed_left += op->speed / op->contr->weapon_sp; |
2430 | op->speed_left += op->speed / op->contr->weapon_sp; |
2430 | |
2431 | |
2431 | op->contr->has_hit = 1; /* The last action was to hit, so use weapon_sp */ |
2432 | op->contr->has_hit = 1; /* The last action was to hit, so use weapon_sp */ |
2432 | } |
2433 | } |
2433 | |
2434 | |
2434 | skill_attack (mon, op, 0, NULL, NULL); |
2435 | skill_attack (mon, op, 0, 0, 0); |
2435 | |
2436 | |
2436 | /* If attacking another player, that player gets automatic |
2437 | /* If attacking another player, that player gets automatic |
2437 | * hitback, and doesn't loose luck either. |
2438 | * hitback, and doesn't loose luck either. |
2438 | * Disable hitback on the battleground or if the target is |
2439 | * Disable hitback on the battleground or if the target is |
2439 | * the wiz. |
2440 | * the wiz. |
… | |
… | |
2441 | if (mon->type == PLAYER && mon->stats.hp >= 0 && !mon->contr->has_hit && !on_battleground && !QUERY_FLAG (mon, FLAG_WIZ)) |
2442 | if (mon->type == PLAYER && mon->stats.hp >= 0 && !mon->contr->has_hit && !on_battleground && !QUERY_FLAG (mon, FLAG_WIZ)) |
2442 | { |
2443 | { |
2443 | short luck = mon->stats.luck; |
2444 | short luck = mon->stats.luck; |
2444 | |
2445 | |
2445 | mon->contr->has_hit = 1; |
2446 | mon->contr->has_hit = 1; |
2446 | skill_attack (op, mon, 0, NULL, NULL); |
2447 | skill_attack (op, mon, 0, 0, 0); |
2447 | mon->stats.luck = luck; |
2448 | mon->stats.luck = luck; |
2448 | } |
2449 | } |
|
|
2450 | |
2449 | if (action_makes_visible (op)) |
2451 | if (action_makes_visible (op)) |
2450 | make_visible (op); |
2452 | make_visible (op); |
2451 | } |
2453 | } |
2452 | } /* if player should attack something */ |
2454 | } /* if player should attack something */ |
2453 | } |
2455 | } |
… | |
… | |
2488 | |
2490 | |
2489 | /* Add special check for newcs players and fire on - this way, the |
2491 | /* Add special check for newcs players and fire on - this way, the |
2490 | * server can handle repeat firing. |
2492 | * server can handle repeat firing. |
2491 | */ |
2493 | */ |
2492 | if (op->contr->fire_on || (op->contr->run_on && pick != 0)) |
2494 | if (op->contr->fire_on || (op->contr->run_on && pick != 0)) |
2493 | { |
|
|
2494 | op->direction = dir; |
2495 | op->direction = dir; |
2495 | } |
|
|
2496 | else |
2496 | else |
2497 | { |
|
|
2498 | op->direction = 0; |
2497 | op->direction = 0; |
2499 | } |
2498 | |
2500 | /* Update how the player looks. Use the facing, so direction may |
2499 | /* Update how the player looks. Use the facing, so direction may |
2501 | * get reset to zero. This allows for full animation capabilities |
2500 | * get reset to zero. This allows for full animation capabilities |
2502 | * for players. |
2501 | * for players. |
2503 | */ |
2502 | */ |
2504 | animate_object (op, op->facing); |
2503 | animate_object (op, op->facing); |
… | |
… | |
2557 | /* call this here - we also will call this in do_ericserver, but |
2556 | /* call this here - we also will call this in do_ericserver, but |
2558 | * the players time has been increased when doericserver has been |
2557 | * the players time has been increased when doericserver has been |
2559 | * called, so we recheck it here. |
2558 | * called, so we recheck it here. |
2560 | */ |
2559 | */ |
2561 | //TODO: better than handling 8 commands, use some more intelligent rate-limiting |
2560 | //TODO: better than handling 8 commands, use some more intelligent rate-limiting |
2562 | for (int rep = 8; --rep && op->contr->socket->handle_command (); ) |
2561 | for (int rep = 8; --rep && op->contr->ns->handle_command (); ) |
2563 | ; |
2562 | ; |
2564 | |
2563 | |
2565 | if (op->speed_left < 0) |
2564 | if (op->speed_left < 0) |
2566 | return 0; |
2565 | return 0; |
2567 | |
2566 | |
… | |
… | |
2714 | for (i = 0; i < NUM_OUTPUT_BUFS; i++) |
2713 | for (i = 0; i < NUM_OUTPUT_BUFS; i++) |
2715 | if (op->contr->outputs[i].buf != NULL && (op->contr->outputs[i].first_update + op->contr->outputs_sync) < (uint16) pticks) |
2714 | if (op->contr->outputs[i].buf != NULL && (op->contr->outputs[i].first_update + op->contr->outputs_sync) < (uint16) pticks) |
2716 | flush_output_element (op, &op->contr->outputs[i]); |
2715 | flush_output_element (op, &op->contr->outputs[i]); |
2717 | } |
2716 | } |
2718 | |
2717 | |
2719 | if (op->contr->state == ST_PLAYING) |
2718 | if (op->contr->ns->state == ST_PLAYING) |
2720 | { |
2719 | { |
2721 | |
2720 | |
2722 | /* these next three if clauses make it possible to SLOW DOWN |
2721 | /* these next three if clauses make it possible to SLOW DOWN |
2723 | hp/grace/spellpoint regeneration. */ |
2722 | hp/grace/spellpoint regeneration. */ |
2724 | if (op->contr->gen_hp >= 0) |
2723 | if (op->contr->gen_hp >= 0) |
… | |
… | |
2866 | if (!QUERY_FLAG (op, FLAG_WIZ)) |
2865 | if (!QUERY_FLAG (op, FLAG_WIZ)) |
2867 | op->stats.food--; |
2866 | op->stats.food--; |
2868 | } |
2867 | } |
2869 | } |
2868 | } |
2870 | |
2869 | |
2871 | if (op->contr->state == ST_PLAYING && op->stats.food < 0 && op->stats.hp >= 0) |
2870 | if (op->contr->ns->state == ST_PLAYING && op->stats.food < 0 && op->stats.hp >= 0) |
2872 | { |
2871 | { |
2873 | object *tmp, *flesh = NULL; |
2872 | object *tmp, *flesh = NULL; |
2874 | |
2873 | |
2875 | for (tmp = op->inv; tmp != NULL; tmp = tmp->below) |
2874 | for (tmp = op->inv; tmp != NULL; tmp = tmp->below) |
2876 | { |
2875 | { |
… | |
… | |
2898 | } /* end if player is starving */ |
2897 | } /* end if player is starving */ |
2899 | |
2898 | |
2900 | while (op->stats.food < 0 && op->stats.hp > 0) |
2899 | while (op->stats.food < 0 && op->stats.hp > 0) |
2901 | op->stats.food++, op->stats.hp--; |
2900 | op->stats.food++, op->stats.hp--; |
2902 | |
2901 | |
2903 | if (!op->contr->state && !QUERY_FLAG (op, FLAG_WIZ) && (op->stats.hp < 0 || op->stats.food < 0)) |
2902 | if (!op->contr->ns->state && !QUERY_FLAG (op, FLAG_WIZ) && (op->stats.hp < 0 || op->stats.food < 0)) |
2904 | kill_player (op); |
2903 | kill_player (op); |
2905 | } |
2904 | } |
2906 | |
2905 | |
2907 | |
2906 | |
2908 | |
2907 | |
… | |
… | |
3228 | * at his savebed location, and that can have long lasting |
3227 | * at his savebed location, and that can have long lasting |
3229 | * spell effects. So first see if there is a spell effect |
3228 | * spell effects. So first see if there is a spell effect |
3230 | * on the space that might harm the player. |
3229 | * on the space that might harm the player. |
3231 | */ |
3230 | */ |
3232 | will_kill_again = 0; |
3231 | will_kill_again = 0; |
3233 | for (tmp = get_map_ob (op->map, op->x, op->y); tmp; tmp = tmp->above) |
3232 | for (tmp = GET_MAP_OB (op->map, op->x, op->y); tmp; tmp = tmp->above) |
3234 | if (tmp->type == SPELL_EFFECT) |
3233 | if (tmp->type == SPELL_EFFECT) |
3235 | will_kill_again |= tmp->attacktype; |
3234 | will_kill_again |= tmp->attacktype; |
3236 | |
3235 | |
3237 | if (will_kill_again) |
3236 | if (will_kill_again) |
3238 | { |
3237 | { |
… | |
… | |
3335 | } |
3334 | } |
3336 | |
3335 | |
3337 | for (tmp = op->inv; tmp != NULL; tmp = next) |
3336 | for (tmp = op->inv; tmp != NULL; tmp = next) |
3338 | { |
3337 | { |
3339 | next = tmp->below; |
3338 | next = tmp->below; |
3340 | if (tmp->type == EXPERIENCE || tmp->invisible) |
3339 | if (tmp->invisible) |
3341 | continue; |
3340 | continue; |
3342 | tmp->remove (); |
3341 | tmp->remove (); |
3343 | tmp->x = op->x, tmp->y = op->y; |
3342 | tmp->x = op->x, tmp->y = op->y; |
3344 | if (tmp->type == CONTAINER) |
3343 | if (tmp->type == CONTAINER) |
3345 | { /* empty container to ground */ |
3344 | { /* empty container to ground */ |
… | |
… | |
3387 | fix_luck (void) |
3386 | fix_luck (void) |
3388 | { |
3387 | { |
3389 | player *pl; |
3388 | player *pl; |
3390 | |
3389 | |
3391 | for (pl = first_player; pl != NULL; pl = pl->next) |
3390 | for (pl = first_player; pl != NULL; pl = pl->next) |
3392 | if (!pl->ob->contr->state) |
3391 | if (!pl->ob->contr->ns->state) |
3393 | change_luck (pl->ob, 0); |
3392 | change_luck (pl->ob, 0); |
3394 | } |
3393 | } |
3395 | |
3394 | |
3396 | |
3395 | |
3397 | /* cast_dust() - handles op throwing objects of type 'DUST'. |
3396 | /* cast_dust() - handles op throwing objects of type 'DUST'. |
… | |
… | |
3451 | object *tmp = NULL; |
3450 | object *tmp = NULL; |
3452 | |
3451 | |
3453 | if (QUERY_FLAG (&op->arch->clone, FLAG_UNDEAD)) |
3452 | if (QUERY_FLAG (&op->arch->clone, FLAG_UNDEAD)) |
3454 | return 1; |
3453 | return 1; |
3455 | |
3454 | |
3456 | if (op->type == PLAYER) |
|
|
3457 | for (tmp = op->inv; tmp; tmp = tmp->below) |
|
|
3458 | if (tmp->type == EXPERIENCE && tmp->stats.Wis) |
|
|
3459 | if (QUERY_FLAG (tmp, FLAG_UNDEAD)) |
|
|
3460 | return 1; |
|
|
3461 | return 0; |
3455 | return 0; |
3462 | } |
3456 | } |
3463 | |
3457 | |
3464 | /* look at the surrounding terrain to determine |
3458 | /* look at the surrounding terrain to determine |
3465 | * the hideability of this object. Positive levels |
3459 | * the hideability of this object. Positive levels |
… | |
… | |
3580 | if (mflags & P_OUT_OF_MAP) |
3574 | if (mflags & P_OUT_OF_MAP) |
3581 | continue; |
3575 | continue; |
3582 | if (OB_TYPE_MOVE_BLOCK (who, GET_MAP_MOVE_BLOCK (m, x, y))) |
3576 | if (OB_TYPE_MOVE_BLOCK (who, GET_MAP_MOVE_BLOCK (m, x, y))) |
3583 | continue; |
3577 | continue; |
3584 | |
3578 | |
3585 | for (tmp = get_map_ob (m, x, y); tmp; tmp = tmp->above) |
3579 | for (tmp = GET_MAP_OB (m, x, y); tmp; tmp = tmp->above) |
3586 | { |
3580 | { |
3587 | if ((player ||friendly) &&QUERY_FLAG (tmp, FLAG_MONSTER) && !QUERY_FLAG (tmp, FLAG_UNAGGRESSIVE)) |
3581 | if ((player ||friendly) &&QUERY_FLAG (tmp, FLAG_MONSTER) && !QUERY_FLAG (tmp, FLAG_UNAGGRESSIVE)) |
3588 | return 1; |
3582 | return 1; |
3589 | else if (tmp->type == PLAYER) |
3583 | else if (tmp->type == PLAYER) |
3590 | { |
3584 | { |
… | |
… | |
3644 | |
3638 | |
3645 | /* only the viewable area the player sees is updated by LOS |
3639 | /* only the viewable area the player sees is updated by LOS |
3646 | * code, so we need to restrict ourselves to that range of values |
3640 | * code, so we need to restrict ourselves to that range of values |
3647 | * for any meaningful values. |
3641 | * for any meaningful values. |
3648 | */ |
3642 | */ |
3649 | if (FABS (dx) <= (pl->contr->socket->mapx / 2) && |
3643 | if (FABS (dx) <= (pl->contr->ns->mapx / 2) && |
3650 | FABS (dy) <= (pl->contr->socket->mapy / 2) && |
3644 | FABS (dy) <= (pl->contr->ns->mapy / 2) && |
3651 | !pl->contr->blocked_los[dx + (pl->contr->socket->mapx / 2)][dy + (pl->contr->socket->mapy / 2)]) |
3645 | !pl->contr->blocked_los[dx + (pl->contr->ns->mapx / 2)][dy + (pl->contr->ns->mapy / 2)]) |
3652 | return 1; |
3646 | return 1; |
3653 | op = op->more; |
3647 | op = op->more; |
3654 | } |
3648 | } |
3655 | return 0; |
3649 | return 0; |
3656 | } |
3650 | } |
… | |
… | |
3842 | { |
3836 | { |
3843 | /* forces in the treasurelist can alter the player's stats */ |
3837 | /* forces in the treasurelist can alter the player's stats */ |
3844 | object *skin; |
3838 | object *skin; |
3845 | |
3839 | |
3846 | /* first get the dragon skin force */ |
3840 | /* first get the dragon skin force */ |
|
|
3841 | shstr_cmp dragon_skin_force ("dragon_skin_force"); |
3847 | for (skin = who->inv; skin != NULL && strcmp (skin->arch->name, "dragon_skin_force") != 0; skin = skin->below); |
3842 | for (skin = who->inv; skin && !(skin->arch->name == dragon_skin_force); skin = skin->below) |
|
|
3843 | ; |
|
|
3844 | |
3848 | if (skin == NULL) |
3845 | if (!skin) |
3849 | return; |
3846 | return; |
3850 | |
3847 | |
3851 | /* adding new spellpath attunements */ |
3848 | /* adding new spellpath attunements */ |
3852 | if (item->path_attuned > 0 && !(skin->path_attuned & item->path_attuned)) |
3849 | if (item->path_attuned > 0 && !(skin->path_attuned & item->path_attuned)) |
3853 | { |
3850 | { |