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