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.23 by root, Thu Sep 14 22:34:04 2006 UTC vs.
Revision 1.28 by root, Mon Nov 13 20:57:16 2006 UTC

329 player *p; 329 player *p;
330 330
331 p = get_player (NULL); 331 p = get_player (NULL);
332 p->socket = *ns; 332 p->socket = *ns;
333 p->socket.faces_sent = (uint8 *) malloc (p->socket.faces_sent_len * sizeof (*p->socket.faces_sent)); 333 p->socket.faces_sent = (uint8 *) malloc (p->socket.faces_sent_len * sizeof (*p->socket.faces_sent));
334
334 if (p->socket.faces_sent == NULL) 335 if (p->socket.faces_sent == NULL)
335 fatal (OUT_OF_MEMORY); 336 fatal (OUT_OF_MEMORY);
337
336 memcpy (p->socket.faces_sent, ns->faces_sent, p->socket.faces_sent_len * sizeof (*p->socket.faces_sent)); 338 memcpy (p->socket.faces_sent, ns->faces_sent, p->socket.faces_sent_len * sizeof (*p->socket.faces_sent));
337 /* Needed because the socket we just copied over needs to be cleared. 339 /* Needed because the socket we just copied over needs to be cleared.
338 * Note that this can result in a client reset if there is partial data 340 * Note that this can result in a client reset if there is partial data
339 * on the uncoming socket. 341 * on the uncoming socket.
340 */ 342 */
345 add_friendly_object (p->ob); 347 add_friendly_object (p->ob);
346 send_rules (p->ob); 348 send_rules (p->ob);
347 send_news (p->ob); 349 send_news (p->ob);
348 display_motd (p->ob); 350 display_motd (p->ob);
349 get_name (p->ob); 351 get_name (p->ob);
352
350 return 0; 353 return 0;
351} 354}
352 355
353/* 356/*
354 * get_player_archetype() return next player archetype from archetype 357 * get_player_archetype() return next player archetype from archetype
489path_to_player (object *mon, object *pl, unsigned mindiff) 492path_to_player (object *mon, object *pl, unsigned mindiff)
490{ 493{
491 rv_vector rv; 494 rv_vector rv;
492 sint16 x, y; 495 sint16 x, y;
493 int lastx, lasty, dir, i, diff, firstdir = 0, lastdir, max = MAX_SPACES, mflags, blocked; 496 int lastx, lasty, dir, i, diff, firstdir = 0, lastdir, max = MAX_SPACES, mflags, blocked;
494 mapstruct *m, *lastmap; 497 maptile *m, *lastmap;
495 498
496 get_rangevector (mon, pl, &rv, 0); 499 get_rangevector (mon, pl, &rv, 0);
497 500
498 if (rv.distance < mindiff) 501 if (rv.distance < mindiff)
499 return 0; 502 return 0;
765 player *pl = op->contr; 768 player *pl = op->contr;
766 shstr name = op->name; 769 shstr name = op->name;
767 770
768 op->contr = 0; 771 op->contr = 0;
769 op->type = 0; 772 op->type = 0;
770 op->free (1); 773 op->destroy (1);
771 pl = get_player (pl); 774 pl = get_player (pl);
772 op = pl->ob; 775 op = pl->ob;
773 add_friendly_object (op); 776 add_friendly_object (op);
774 op->contr->password[0] = '~'; 777 op->contr->password[0] = '~';
775 op->name = op->name_pl = 0; 778 op->name = op->name_pl = 0;
1180 if (settings.set_title == TRUE) 1183 if (settings.set_title == TRUE)
1181 op->contr->own_title[0] = '\0'; 1184 op->contr->own_title[0] = '\0';
1182 1185
1183 if (!QUERY_FLAG (op, FLAG_WAS_WIZ)) 1186 if (!QUERY_FLAG (op, FLAG_WAS_WIZ))
1184 { 1187 {
1185 mapstruct *mp, *next; 1188 maptile *mp, *next;
1186 1189
1187 /* We need to hunt for any per player unique maps in memory and 1190 /* We need to hunt for any per player unique maps in memory and
1188 * get rid of them. The trailing slash in the path is intentional, 1191 * get rid of them. The trailing slash in the path is intentional,
1189 * so that players named 'Ab' won't match against players 'Abe' pathname 1192 * so that players named 'Ab' won't match against players 'Abe' pathname
1190 */ 1193 */
1264 */ 1267 */
1265int 1268int
1266check_pick (object *op) 1269check_pick (object *op)
1267{ 1270{
1268 object *tmp, *next; 1271 object *tmp, *next;
1269 tag_t next_tag = 0, op_tag;
1270 int stop = 0; 1272 int stop = 0;
1271 int j, k, wvratio; 1273 int j, k, wvratio;
1272 char putstring[128], tmpstr[16]; 1274 char putstring[128], tmpstr[16];
1273 1275
1274
1275 /* if you're flying, you cna't pick up anything */ 1276 /* if you're flying, you cna't pick up anything */
1276 if (op->move_type & MOVE_FLYING) 1277 if (op->move_type & MOVE_FLYING)
1277 return 1; 1278 return 1;
1278 1279
1279 op_tag = op->count;
1280
1281 next = op->below; 1280 next = op->below;
1282 if (next)
1283 next_tag = next->count;
1284 1281
1285 /* loop while there are items on the floor that are not marked as 1282 /* loop while there are items on the floor that are not marked as
1286 * destroyed */ 1283 * destroyed */
1287 while (next && !was_destroyed (next, next_tag)) 1284 while (next && !next->destroyed ())
1288 { 1285 {
1289 tmp = next; 1286 tmp = next;
1290 next = tmp->below; 1287 next = tmp->below;
1291 if (next)
1292 next_tag = next->count;
1293 1288
1294 if (was_destroyed (op, op_tag)) 1289 if (op->destroyed ())
1295 return 0; 1290 return 0;
1296 1291
1297 if (!can_pick (op, tmp)) 1292 if (!can_pick (op, tmp))
1298 continue; 1293 continue;
1299 1294
1770 1765
1771object * 1766object *
1772pick_arrow_target (object *op, const char *type, int dir) 1767pick_arrow_target (object *op, const char *type, int dir)
1773{ 1768{
1774 object *tmp = NULL; 1769 object *tmp = NULL;
1775 mapstruct *m; 1770 maptile *m;
1776 int i, mflags, found, number; 1771 int i, mflags, found, number;
1777 sint16 x, y; 1772 sint16 x, y;
1778 1773
1779 if (op->map == NULL) 1774 if (op->map == NULL)
1780 return find_arrow (op, type); 1775 return find_arrow (op, type);
1840 */ 1835 */
1841int 1836int
1842fire_bow (object *op, object *part, object *arrow, int dir, int wc_mod, sint16 sx, sint16 sy) 1837fire_bow (object *op, object *part, object *arrow, int dir, int wc_mod, sint16 sx, sint16 sy)
1843{ 1838{
1844 object *left, *bow; 1839 object *left, *bow;
1845 tag_t left_tag, tag;
1846 int bowspeed, mflags; 1840 int bowspeed, mflags;
1847 mapstruct *m; 1841 maptile *m;
1848 1842
1849 if (!dir) 1843 if (!dir)
1850 { 1844 {
1851 new_draw_info (NDI_UNIQUE, 0, op, "You can't shoot yourself!"); 1845 new_draw_info (NDI_UNIQUE, 0, op, "You can't shoot yourself!");
1852 return 0; 1846 return 0;
1912 free_object (arrow); 1906 free_object (arrow);
1913 return 0; 1907 return 0;
1914 } 1908 }
1915 1909
1916 left = arrow; /* these are arrows left to the player */ 1910 left = arrow; /* these are arrows left to the player */
1917 left_tag = left->count;
1918 arrow = get_split_ob (arrow, 1); 1911 arrow = get_split_ob (arrow, 1);
1919 if (arrow == NULL) 1912 if (arrow == NULL)
1920 { 1913 {
1921 new_draw_info_format (NDI_UNIQUE, 0, op, "You have no %s left.", &bow->race); 1914 new_draw_info_format (NDI_UNIQUE, 0, op, "You have no %s left.", &bow->race);
1922 return 0; 1915 return 0;
1965 arrow->level = op->chosen_skill ? op->chosen_skill->level : op->level; 1958 arrow->level = op->chosen_skill ? op->chosen_skill->level : op->level;
1966 } 1959 }
1967 else 1960 else
1968 { 1961 {
1969 arrow->stats.wc = op->stats.wc - bow->magic - arrow->magic - arrow->stats.wc + wc_mod; 1962 arrow->stats.wc = op->stats.wc - bow->magic - arrow->magic - arrow->stats.wc + wc_mod;
1970
1971 arrow->level = op->level; 1963 arrow->level = op->level;
1972 } 1964 }
1965
1973 if (arrow->attacktype == AT_PHYSICAL) 1966 if (arrow->attacktype == AT_PHYSICAL)
1974 arrow->attacktype |= bow->attacktype; 1967 arrow->attacktype |= bow->attacktype;
1968
1975 if (bow->slaying != NULL) 1969 if (bow->slaying != NULL)
1976 arrow->slaying = bow->slaying; 1970 arrow->slaying = bow->slaying;
1977 1971
1978 arrow->map = m; 1972 arrow->map = m;
1979 arrow->move_type = MOVE_FLY_LOW; 1973 arrow->move_type = MOVE_FLY_LOW;
1980 arrow->move_on = MOVE_FLY_LOW | MOVE_WALK; 1974 arrow->move_on = MOVE_FLY_LOW | MOVE_WALK;
1981 1975
1982 play_sound_map (op->map, op->x, op->y, SOUND_FIRE_ARROW); 1976 play_sound_map (op->map, op->x, op->y, SOUND_FIRE_ARROW);
1983 tag = arrow->count;
1984 insert_ob_in_map (arrow, m, op, 0); 1977 insert_ob_in_map (arrow, m, op, 0);
1985 1978
1986 if (!was_destroyed (arrow, tag)) 1979 if (!arrow->destroyed ())
1987 move_arrow (arrow); 1980 move_arrow (arrow);
1988 1981
1989 if (op->type == PLAYER) 1982 if (op->type == PLAYER)
1990 { 1983 {
1991 if (was_destroyed (left, left_tag)) 1984 if (left->destroyed ())
1992 esrv_del_item (op->contr, left_tag); 1985 esrv_del_item (op->contr, left->count);
1993 else 1986 else
1994 esrv_send_item (op, left); 1987 esrv_send_item (op, left);
1995 } 1988 }
1989
1996 return 1; 1990 return 1;
1997} 1991}
1998 1992
1999/* Special fire code for players - this takes into 1993/* Special fire code for players - this takes into
2000 * account the special fire modes players can have 1994 * account the special fire modes players can have
2312move_player_attack (object *op, int dir) 2306move_player_attack (object *op, int dir)
2313{ 2307{
2314 object *tmp, *mon; 2308 object *tmp, *mon;
2315 sint16 nx, ny; 2309 sint16 nx, ny;
2316 int on_battleground; 2310 int on_battleground;
2317 mapstruct *m; 2311 maptile *m;
2318 2312
2319 nx = freearr_x[dir] + op->x; 2313 nx = freearr_x[dir] + op->x;
2320 ny = freearr_y[dir] + op->y; 2314 ny = freearr_y[dir] + op->y;
2321 2315
2322 on_battleground = op_on_battleground (op, NULL, NULL); 2316 on_battleground = op_on_battleground (op, NULL, NULL);
2358 if (tmp == op) 2352 if (tmp == op)
2359 { 2353 {
2360 tmp = tmp->above; 2354 tmp = tmp->above;
2361 continue; 2355 continue;
2362 } 2356 }
2357
2363 if (QUERY_FLAG (tmp, FLAG_ALIVE)) 2358 if (QUERY_FLAG (tmp, FLAG_ALIVE))
2364 { 2359 {
2365 mon = tmp; 2360 mon = tmp;
2366 break; 2361 break;
2367 } 2362 }
2363
2368 if (tmp->type == LOCKED_DOOR || QUERY_FLAG (tmp, FLAG_CAN_ROLL)) 2364 if (tmp->type == LOCKED_DOOR || QUERY_FLAG (tmp, FLAG_CAN_ROLL))
2369 mon = tmp; 2365 mon = tmp;
2366
2370 tmp = tmp->above; 2367 tmp = tmp->above;
2371 } 2368 }
2372 2369
2373 if (mon == NULL) /* This happens anytime the player tries to move */ 2370 if (mon == NULL) /* This happens anytime the player tries to move */
2374 return; /* into a wall */ 2371 return; /* into a wall */
2952{ 2949{
2953 char buf[MAX_BUF]; 2950 char buf[MAX_BUF];
2954 int x, y; 2951 int x, y;
2955 2952
2956 //int i; 2953 //int i;
2957 mapstruct *map; /* this is for resurrection */ 2954 maptile *map; /* this is for resurrection */
2958 2955
2959 /* int z; 2956 /* int z;
2960 int num_stats_lose; 2957 int num_stats_lose;
2961 int lost_a_stat; 2958 int lost_a_stat;
2962 int lose_this_stat; 2959 int lose_this_stat;
3178 /* determine_god() seems to not work sometimes... why is this? 3175 /* determine_god() seems to not work sometimes... why is this?
3179 Should I be using something else? GD */ 3176 Should I be using something else? GD */
3180 const char *god = determine_god (op); 3177 const char *god = determine_god (op);
3181 3178
3182 if (god && (strcmp (god, "none"))) 3179 if (god && (strcmp (god, "none")))
3183 new_draw_info_format (NDI_UNIQUE, 0, op, "For a brief " "moment you feel the holy presence of %s protecting" " you.", god); 3180 new_draw_info_format (NDI_UNIQUE, 0, op, "For a brief moment you feel the holy presence of %s protecting" " you.", god);
3184 else 3181 else
3185 new_draw_info (NDI_UNIQUE, 0, op, "For a brief moment you" " feel a holy presence protecting you."); 3182 new_draw_info (NDI_UNIQUE, 0, op, "For a brief moment you feel a holy presence protecting you.");
3186 } 3183 }
3184#else
3185 new_draw_info (NDI_UNIQUE, 0, op, "For a brief moment you" " feel a holy presence protecting you from losing yourself completely.");
3187#endif 3186#endif
3188 new_draw_info (NDI_UNIQUE, 0, op, "For a brief moment you" " feel a holy presence protecting you from losing yourself completely.");
3189 3187
3190 /* Put a gravestone up where the character 'almost' died. List the 3188 /* Put a gravestone up where the character 'almost' died. List the
3191 * exp loss on the stone. 3189 * exp loss on the stone.
3192 */ 3190 */
3193 tmp = arch_to_object (archetype::find ("gravestone")); 3191 tmp = arch_to_object (archetype::find ("gravestone"));
3198 sprintf (buf, "RIP\nHere rests the hero %s the %s,\n" "who was killed\n" "by %s.\n", &op->name, op->contr->title, op->contr->killer); 3196 sprintf (buf, "RIP\nHere rests the hero %s the %s,\n" "who was killed\n" "by %s.\n", &op->name, op->contr->title, op->contr->killer);
3199 tmp->msg = buf; 3197 tmp->msg = buf;
3200 tmp->x = op->x, tmp->y = op->y; 3198 tmp->x = op->x, tmp->y = op->y;
3201 insert_ob_in_map (tmp, op->map, NULL, 0); 3199 insert_ob_in_map (tmp, op->map, NULL, 0);
3202 3200
3203 /**************************************/ 3201 /**************************************/
3204 /* */ 3202 /* */
3205 /* Subtract the experience points, */ 3203 /* Subtract the experience points, */
3206 /* if we died cause of food, give us */ 3204 /* if we died cause of food, give us */
3207 /* food, and reset HP's... */ 3205 /* food, and reset HP's... */
3208 /* */ 3206 /* */
3209
3210 /**************************************/ 3207 /**************************************/
3211 3208
3212 /* remove any poisoning and confusion the character may be suffering. */ 3209 /* remove any poisoning and confusion the character may be suffering. */
3213 /* restore player */ 3210 /* restore player */
3214 at = archetype::find ("poisoning"); 3211 at = archetype::find ("poisoning");
3215 tmp = present_arch_in_ob (at, op); 3212 tmp = present_arch_in_ob (at, op);
3226 { 3223 {
3227 remove_ob (tmp); 3224 remove_ob (tmp);
3228 free_object (tmp); 3225 free_object (tmp);
3229 new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer"); 3226 new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer");
3230 } 3227 }
3228
3231 cure_disease (op, 0); /* remove any disease */ 3229 cure_disease (op, 0); /* remove any disease */
3232 3230
3233 /*add_exp(op, (op->stats.exp * -0.20)); */ 3231 /*add_exp(op, (op->stats.exp * -0.20)); */
3234 apply_death_exp_penalty (op); 3232 apply_death_exp_penalty (op);
3235 if (op->stats.food < 100) 3233 if (op->stats.food < 100)
3245 */ 3243 */
3246 3244
3247 if (is_in_shop (op)) 3245 if (is_in_shop (op))
3248 remove_unpaid_objects (op->inv, op); 3246 remove_unpaid_objects (op->inv, op);
3249 3247
3250 /****************************************/ 3248 /****************************************/
3251 /* */ 3249 /* */
3252 /* Move player to his current respawn- */ 3250 /* Move player to his current respawn- */
3253 /* position (usually last savebed) */ 3251 /* position (usually last savebed) */
3254 /* */ 3252 /* */
3255
3256 /****************************************/ 3253 /****************************************/
3257 3254
3258 enter_player_savebed (op); 3255 enter_player_savebed (op);
3259 3256
3260 /* Save the player before inserting the force to reduce 3257 /* Save the player before inserting the force to reduce
3261 * chance of abuse. 3258 * chance of abuse.
3268 * spell effects. So first see if there is a spell effect 3265 * spell effects. So first see if there is a spell effect
3269 * on the space that might harm the player. 3266 * on the space that might harm the player.
3270 */ 3267 */
3271 will_kill_again = 0; 3268 will_kill_again = 0;
3272 for (tmp = get_map_ob (op->map, op->x, op->y); tmp; tmp = tmp->above) 3269 for (tmp = get_map_ob (op->map, op->x, op->y); tmp; tmp = tmp->above)
3273 {
3274 if (tmp->type == SPELL_EFFECT) 3270 if (tmp->type == SPELL_EFFECT)
3275 will_kill_again |= tmp->attacktype; 3271 will_kill_again |= tmp->attacktype;
3276 } 3272
3277 if (will_kill_again) 3273 if (will_kill_again)
3278 { 3274 {
3279 object *force; 3275 object *force;
3280 int at; 3276 int at;
3281 3277
3283 /* 50 ticks should be enough time for the spell to abate */ 3279 /* 50 ticks should be enough time for the spell to abate */
3284 force->speed = 0.1; 3280 force->speed = 0.1;
3285 force->speed_left = -5.0; 3281 force->speed_left = -5.0;
3286 SET_FLAG (force, FLAG_APPLIED); 3282 SET_FLAG (force, FLAG_APPLIED);
3287 for (at = 0; at < NROFATTACKS; at++) 3283 for (at = 0; at < NROFATTACKS; at++)
3288 {
3289 if (will_kill_again & (1 << at)) 3284 if (will_kill_again & (1 << at))
3290 force->resist[at] = 100; 3285 force->resist[at] = 100;
3291 } 3286
3292 insert_ob_in_ob (force, op); 3287 insert_ob_in_ob (force, op);
3293 fix_player (op); 3288 fix_player (op);
3294 3289
3295 } 3290 }
3296 3291
3596int 3591int
3597stand_near_hostile (object *who) 3592stand_near_hostile (object *who)
3598{ 3593{
3599 object *tmp = NULL; 3594 object *tmp = NULL;
3600 int i, friendly = 0, player = 0, mflags; 3595 int i, friendly = 0, player = 0, mflags;
3601 mapstruct *m; 3596 maptile *m;
3602 sint16 x, y; 3597 sint16 x, y;
3603 3598
3604 if (!who) 3599 if (!who)
3605 return 0; 3600 return 0;
3606 3601

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines