1 | /* |
1 | /* |
2 | * static char *rcsid_player_c = |
2 | * static char *rcsid_player_c = |
3 | * "$Id: player.c,v 1.10 2006/03/24 06:06:23 root Exp $"; |
3 | * "$Id: player.c,v 1.13 2006/04/21 14:40:31 pippijn Exp $"; |
4 | */ |
4 | */ |
5 | |
5 | |
6 | /* |
6 | /* |
7 | CrossFire, A Multiplayer game for X-windows |
7 | CrossFire, A Multiplayer game for X-windows |
8 | |
8 | |
… | |
… | |
228 | } |
228 | } |
229 | |
229 | |
230 | /* Clears basically the entire player structure except |
230 | /* Clears basically the entire player structure except |
231 | * for next and socket. |
231 | * for next and socket. |
232 | */ |
232 | */ |
233 | memset((void*)((char*)p + offsetof(player, maplevel)), 0, |
233 | memset((void*)((char*)p + offsetof(player, ob)), 0, |
234 | sizeof(player) - offsetof(player, maplevel)); |
234 | sizeof(player) - offsetof(player, ob)); |
235 | |
235 | |
236 | /* There are some elements we want initialized to non zero value - |
236 | /* There are some elements we want initialized to non zero value - |
237 | * we deal with that below this point. |
237 | * we deal with that below this point. |
238 | */ |
238 | */ |
239 | p->party=NULL; |
239 | p->party=NULL; |
… | |
… | |
950 | } |
950 | } |
951 | return 0; |
951 | return 0; |
952 | } |
952 | } |
953 | |
953 | |
954 | /* This function takes the key that is passed, and does the |
954 | /* This function takes the key that is passed, and does the |
955 | * appropriate action with it (change class, or other things. |
955 | * appropriate action with it (change race, or other things). |
|
|
956 | * The function name is for historical reasons - now we have |
|
|
957 | * separate race and class; this actually changes the RACE, |
|
|
958 | * not the class. |
956 | */ |
959 | */ |
957 | |
960 | |
958 | int key_change_class(object *op, char key) |
961 | int key_change_class(object *op, char key) |
959 | { |
962 | { |
960 | int tmp_loop; |
963 | int tmp_loop; |
961 | |
964 | |
962 | if(key=='q'||key=='Q') { |
965 | if(key=='q'||key=='Q') { |
963 | remove_ob(op); |
966 | remove_ob(op); |
964 | play_again(op); |
967 | play_again(op); |
965 | return 0; |
968 | return 0; |
… | |
… | |
996 | CLEAR_FLAG(op, FLAG_WIZ); |
999 | CLEAR_FLAG(op, FLAG_WIZ); |
997 | give_initial_items(op,op->randomitems); |
1000 | give_initial_items(op,op->randomitems); |
998 | link_player_skills(op); |
1001 | link_player_skills(op); |
999 | esrv_send_inventory(op, op); |
1002 | esrv_send_inventory(op, op); |
1000 | fix_player(op); |
1003 | fix_player(op); |
|
|
1004 | |
|
|
1005 | /* This moves the player to a different start map, if there |
|
|
1006 | * is one for this race |
|
|
1007 | */ |
|
|
1008 | if(*first_map_ext_path) { |
|
|
1009 | object *tmp; |
|
|
1010 | mapstruct *oldmap = op->map; |
|
|
1011 | char mapname[MAX_BUF]; |
|
|
1012 | snprintf(mapname, MAX_BUF-1, "%s/%s", |
|
|
1013 | first_map_ext_path, op->arch->name); |
|
|
1014 | printf("%s\n", mapname); |
|
|
1015 | tmp=get_object(); |
|
|
1016 | EXIT_PATH(tmp) = add_string(mapname); |
|
|
1017 | EXIT_X(tmp) = op->x; |
|
|
1018 | EXIT_Y(tmp) = op->y; |
|
|
1019 | enter_exit(op,tmp); /* we don't really care if it succeeded; |
|
|
1020 | * if the map isn't there, then stay on the |
|
|
1021 | * default initial map */ |
|
|
1022 | free_object(tmp); |
|
|
1023 | } else { |
|
|
1024 | LOG(llevDebug,"first_map_ext_path not set\n"); |
|
|
1025 | } |
1001 | return 0; |
1026 | return 0; |
1002 | } |
1027 | } |
1003 | |
1028 | |
1004 | /* Following actually changes the class - this is the default command |
1029 | /* Following actually changes the race - this is the default command |
1005 | * if we don't match with one of the options above. |
1030 | * if we don't match with one of the options above. |
1006 | */ |
1031 | */ |
1007 | |
1032 | |
1008 | tmp_loop = 0; |
1033 | tmp_loop = 0; |
1009 | while(!tmp_loop) { |
1034 | while(!tmp_loop) { |
… | |
… | |
2093 | * attack them either. |
2118 | * attack them either. |
2094 | */ |
2119 | */ |
2095 | if ((mon->type==PLAYER || mon->enemy != op) && |
2120 | if ((mon->type==PLAYER || mon->enemy != op) && |
2096 | (mon->type==PLAYER || QUERY_FLAG(mon,FLAG_UNAGGRESSIVE) || QUERY_FLAG(mon, FLAG_FRIENDLY)) && |
2121 | (mon->type==PLAYER || QUERY_FLAG(mon,FLAG_UNAGGRESSIVE) || QUERY_FLAG(mon, FLAG_FRIENDLY)) && |
2097 | ( |
2122 | ( |
2098 | #ifndef PROHIBIT_PLAYERKILL |
2123 | #ifdef PROHIBIT_PLAYERKILL |
|
|
2124 | (op->contr->peaceful || (mon->type == PLAYER && mon->contr->peaceful)) && |
|
|
2125 | #else |
2099 | op->contr->peaceful && |
2126 | op->contr->peaceful && |
2100 | #endif |
2127 | #endif |
2101 | !on_battleground |
2128 | !on_battleground |
2102 | )) { |
2129 | )) { |
2103 | if (!op->contr->braced) { |
2130 | if (!op->contr->braced) { |