ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/player.c
(Generate patch)

Comparing deliantra/server/server/player.c (file contents):
Revision 1.6 by elmex, Wed Feb 22 18:53:56 2006 UTC vs.
Revision 1.19 by pippijn, Fri Jun 2 01:32:36 2006 UTC

1/* 1/*
2 * static char *rcsid_player_c = 2 * static char *rcsid_player_c =
3 * "$Id: player.c,v 1.6 2006/02/22 18:53:56 elmex Exp $"; 3 * "$Id: player.c,v 1.19 2006/06/02 01:32:36 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
149 continue; 149 continue;
150 if ( *buf =='%'){ /* send one news */ 150 if ( *buf =='%'){ /* send one news */
151 if (size>0) 151 if (size>0)
152 draw_ext_info_format(NDI_UNIQUE | NDI_GREEN, 0, op, 152 draw_ext_info_format(NDI_UNIQUE | NDI_GREEN, 0, op,
153 MSG_TYPE_ADMIN, MSG_TYPE_ADMIN_NEWS, 153 MSG_TYPE_ADMIN, MSG_TYPE_ADMIN_NEWS,
154 "!! informations: %s\n%s", 154 "INFORMATION: %s\n%s",
155 "%s\n%s", 155 "%s\n%s",
156 subject, news); /*send previously read news*/ 156 subject, news); /*send previously read news*/
157 strcpy(subject,buf+1); 157 strcpy(subject,buf+1);
158 strip_endline(subject); 158 strip_endline(subject);
159 size=0; 159 size=0;
170 } 170 }
171 } 171 }
172 172
173 draw_ext_info_format(NDI_UNIQUE | NDI_GREEN, 0, op, 173 draw_ext_info_format(NDI_UNIQUE | NDI_GREEN, 0, op,
174 MSG_TYPE_ADMIN, MSG_TYPE_ADMIN_NEWS, 174 MSG_TYPE_ADMIN, MSG_TYPE_ADMIN_NEWS,
175 "!! informations: %s\n%s\n", 175 "INFORMATION: %s\n%s\n",
176 "%s\n%s", 176 "%s\n%s",
177 subject, news); 177 subject, news);
178 close_and_delete(fp, comp); 178 close_and_delete(fp, comp);
179} 179}
180 180
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;
253 op->speed_left=0.5; 253 op->speed_left=0.5;
254 op->speed=1.0; 254 op->speed=1.0;
255 op->direction=5; /* So player faces south */ 255 op->direction=5; /* So player faces south */
256 op->stats.wc=2; 256 op->stats.wc=2;
257 op->run_away = 25; /* Then we panick... */ 257 op->run_away = 25; /* Then we panick... */
258 p->socket.monitor_spells = 0; /* Needed because esrv_update_spells( ) gets called by roll_stats */
258 259
259 roll_stats(op); 260 roll_stats(op);
260 p->state=ST_ROLL_STAT; 261 p->state=ST_ROLL_STAT;
261 clear_los(op); 262 clear_los(op);
262 263
263 p->gen_sp_armour=10; 264 p->gen_sp_armour=10;
264 p->last_speed= -1; 265 p->last_speed= -1;
265 p->shoottype=range_none; 266 p->shoottype=range_none;
266 p->bowtype=bow_normal; 267 p->bowtype=bow_normal;
267 p->petmode=pet_normal; 268 p->petmode=pet_normal;
268 p->listening=9; 269 p->listening=10;
270 p->usekeys=containers;
269 p->last_weapon_sp= -1; 271 p->last_weapon_sp= -1;
270 p->peaceful=1; /* default peaceful */ 272 p->peaceful=1; /* default peaceful */
271 p->do_los=1; 273 p->do_los=1;
272 p->explore=0; 274 p->explore=0;
273 p->no_shout=0; /* default can shout */ 275 p->no_shout=0; /* default can shout */
315 317
316int add_player(NewSocket *ns) { 318int add_player(NewSocket *ns) {
317 player *p; 319 player *p;
318 320
319 p=get_player(NULL); 321 p=get_player(NULL);
320 memcpy(&p->socket, ns, sizeof(NewSocket)); 322 p->socket = *ns;
321 p->socket.faces_sent = malloc(p->socket.faces_sent_len*sizeof(*p->socket.faces_sent)); 323 p->socket.faces_sent = malloc(p->socket.faces_sent_len*sizeof(*p->socket.faces_sent));
322 if(p->socket.faces_sent == NULL) 324 if(p->socket.faces_sent == NULL)
323 fatal(OUT_OF_MEMORY); 325 fatal(OUT_OF_MEMORY);
324 memcpy(p->socket.faces_sent, ns->faces_sent, p->socket.faces_sent_len*sizeof(*p->socket.faces_sent)); 326 memcpy(p->socket.faces_sent, ns->faces_sent, p->socket.faces_sent_len*sizeof(*p->socket.faces_sent));
325 /* Needed because the socket we just copied over needs to be cleared. 327 /* Needed because the socket we just copied over needs to be cleared.
949 } 951 }
950 return 0; 952 return 0;
951} 953}
952 954
953/* This function takes the key that is passed, and does the 955/* This function takes the key that is passed, and does the
954 * appropriate action with it (change class, or other things. 956 * appropriate action with it (change race, or other things).
957 * The function name is for historical reasons - now we have
958 * separate race and class; this actually changes the RACE,
959 * not the class.
955 */ 960 */
956 961
957int key_change_class(object *op, char key) 962int key_change_class(object *op, char key)
958{ 963{
959 int tmp_loop; 964 int tmp_loop;
960 965
961 if(key=='q'||key=='Q') { 966 if(key=='q'||key=='Q') {
962 remove_ob(op); 967 remove_ob(op);
963 play_again(op); 968 play_again(op);
964 return 0; 969 return 0;
995 CLEAR_FLAG(op, FLAG_WIZ); 1000 CLEAR_FLAG(op, FLAG_WIZ);
996 give_initial_items(op,op->randomitems); 1001 give_initial_items(op,op->randomitems);
997 link_player_skills(op); 1002 link_player_skills(op);
998 esrv_send_inventory(op, op); 1003 esrv_send_inventory(op, op);
999 fix_player(op); 1004 fix_player(op);
1005
1006 /* This moves the player to a different start map, if there
1007 * is one for this race
1008 */
1009 if(*first_map_ext_path) {
1010 object *tmp;
1011 mapstruct *oldmap = op->map;
1012 char mapname[MAX_BUF];
1013 snprintf(mapname, MAX_BUF-1, "%s/%s",
1014 first_map_ext_path, op->arch->name);
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 }
1000 return 0; 1026 return 0;
1001 } 1027 }
1002 1028
1003 /* Following actually changes the class - this is the default command 1029 /* Following actually changes the race - this is the default command
1004 * if we don't match with one of the options above. 1030 * if we don't match with one of the options above.
1005 */ 1031 */
1006 1032
1007 tmp_loop = 0; 1033 tmp_loop = 0;
1008 while(!tmp_loop) { 1034 while(!tmp_loop) {
2091 * someone, but put it inside this loop so that you won't 2117 * someone, but put it inside this loop so that you won't
2092 * attack them either. 2118 * attack them either.
2093 */ 2119 */
2094 if ((mon->type==PLAYER || mon->enemy != op) && 2120 if ((mon->type==PLAYER || mon->enemy != op) &&
2095 (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)) &&
2096 (op->contr->peaceful && !on_battleground)) { 2122 (
2123#ifdef PROHIBIT_PLAYERKILL
2124 (op->contr->peaceful || (mon->type == PLAYER && mon->contr->peaceful)) &&
2125#else
2126 op->contr->peaceful &&
2127#endif
2128 !on_battleground
2129 )) {
2097 if (!op->contr->braced) { 2130 if (!op->contr->braced) {
2098 play_sound_map(tpl->map, tpl->x, tpl->y, SOUND_PUSH_PLAYER); 2131 play_sound_map(tpl->map, tpl->x, tpl->y, SOUND_PUSH_PLAYER);
2099 (void) push_ob(mon,dir,op); 2132 (void) push_ob(mon,dir,op);
2100 } else { 2133 } else {
2101 new_draw_info(0, 0,op,"You withhold your attack"); 2134 new_draw_info(0, 0,op,"You withhold your attack");
2639 2672
2640 /* Lauwenmark: Handle for plugin death event */ 2673 /* Lauwenmark: Handle for plugin death event */
2641 if (execute_event(op, EVENT_DEATH,NULL,NULL,NULL,SCRIPT_FIX_ALL) != 0) 2674 if (execute_event(op, EVENT_DEATH,NULL,NULL,NULL,SCRIPT_FIX_ALL) != 0)
2642 return; 2675 return;
2643 2676
2677 command_kill_pets (op, 0);
2678
2644 /* Lauwenmark: Handle for the global death event */ 2679 /* Lauwenmark: Handle for the global death event */
2645 execute_global_event(EVENT_PLAYER_DEATH, op); 2680 execute_global_event(EVENT_PLAYER_DEATH, op);
2646 if(op->stats.food<0) { 2681 if(op->stats.food<0) {
2647 if (op->contr->explore) { 2682 if (op->contr->explore) {
2648 new_draw_info(NDI_UNIQUE, 0,op,"You would have starved, but you are"); 2683 new_draw_info(NDI_UNIQUE, 0,op,"You would have starved, but you are");
2695 num_stats_lose = 1; 2730 num_stats_lose = 1;
2696 } 2731 }
2697 lost_a_stat = 0; 2732 lost_a_stat = 0;
2698 2733
2699 for (z=0; z<num_stats_lose; z++) { 2734 for (z=0; z<num_stats_lose; z++) {
2735 i = RANDOM() % NUM_STATS;
2736
2700 if (settings.stat_loss_on_death) { 2737 if (settings.stat_loss_on_death) {
2701 /* Pick a random stat and take a point off it. Tell the player 2738 /* Pick a random stat and take a point off it. Tell the player
2702 * what he lost. 2739 * what he lost.
2703 */ 2740 */
2704 i = RANDOM() % 7;
2705 change_attr_value(&(op->stats), i,-1); 2741 change_attr_value(&(op->stats), i,-1);
2706 check_stat_bounds(&(op->stats)); 2742 check_stat_bounds(&(op->stats));
2707 change_attr_value(&(op->contr->orig_stats), i,-1); 2743 change_attr_value(&(op->contr->orig_stats), i,-1);
2708 check_stat_bounds(&(op->contr->orig_stats)); 2744 check_stat_bounds(&(op->contr->orig_stats));
2709 new_draw_info(NDI_UNIQUE, 0,op, lose_msg[i]); 2745 new_draw_info(NDI_UNIQUE, 0,op, lose_msg[i]);
2711 } else { 2747 } else {
2712 /* deplete a stat */ 2748 /* deplete a stat */
2713 archetype *deparch=find_archetype("depletion"); 2749 archetype *deparch=find_archetype("depletion");
2714 object *dep; 2750 object *dep;
2715 2751
2716 i = RANDOM() % 7;
2717 dep = present_arch_in_ob(deparch,op); 2752 dep = present_arch_in_ob(deparch,op);
2718 if(!dep) { 2753 if(!dep) {
2719 dep = arch_to_object(deparch); 2754 dep = arch_to_object(deparch);
2720 insert_ob_in_ob(dep, op); 2755 insert_ob_in_ob(dep, op);
2721 } 2756 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines