1 | /* |
1 | /* |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
3 | * |
3 | * |
4 | * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
4 | * Copyright (©) 2005,2006,2007,2008,2009 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (©) 2003,2007 Mark Wedel & Crossfire Development Team |
5 | * Copyright (©) 2003,2007 Mark Wedel & Crossfire Development Team |
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
7 | * |
7 | * |
8 | * Deliantra is free software: you can redistribute it and/or modify |
8 | * Deliantra is free software: you can redistribute it and/or modify |
9 | * it under the terms of the GNU General Public License as published by |
9 | * it under the terms of the GNU General Public License as published by |
… | |
… | |
41 | /* Only prohibit stealing if the player does not have a free |
41 | /* Only prohibit stealing if the player does not have a free |
42 | * hand available and in fact does have hands. |
42 | * hand available and in fact does have hands. |
43 | */ |
43 | */ |
44 | if (op->type == PLAYER && op->slot[body_arm].used <= 0 && op->slot[body_arm].info) |
44 | if (op->type == PLAYER && op->slot[body_arm].used <= 0 && op->slot[body_arm].info) |
45 | { |
45 | { |
46 | new_draw_info (NDI_UNIQUE, 0, op, "But you have no free hands to steal with!"); |
46 | new_draw_info (NDI_UNIQUE, 0, op, "But you have no free hands to steal with! " |
|
|
47 | "H<Try to unapply weapons or things you hold in your hands, use the C<body> command.>"); |
47 | return -1; |
48 | return -1; |
48 | } |
49 | } |
49 | |
50 | |
50 | /* ADJUSTMENTS */ |
51 | /* ADJUSTMENTS */ |
51 | |
52 | |
… | |
… | |
64 | * it quite a bit harder to steal. |
65 | * it quite a bit harder to steal. |
65 | */ |
66 | */ |
66 | for (equip = op->inv; equip; equip = equip->below) |
67 | for (equip = op->inv; equip; equip = equip->below) |
67 | { |
68 | { |
68 | if (equip->type == WEAPON && QUERY_FLAG (equip, FLAG_APPLIED)) |
69 | if (equip->type == WEAPON && QUERY_FLAG (equip, FLAG_APPLIED)) |
69 | { |
|
|
70 | roll -= equip->weight / 10000; |
70 | roll -= equip->weight / 10000; |
71 | } |
71 | |
72 | if (equip->type == BOW && QUERY_FLAG (equip, FLAG_APPLIED)) |
72 | if (equip->type == BOW && QUERY_FLAG (equip, FLAG_APPLIED)) |
73 | roll -= equip->weight / 5000; |
73 | roll -= equip->weight / 5000; |
|
|
74 | |
74 | if (equip->type == SHIELD && QUERY_FLAG (equip, FLAG_APPLIED)) |
75 | if (equip->type == SHIELD && QUERY_FLAG (equip, FLAG_APPLIED)) |
75 | { |
|
|
76 | roll -= equip->weight / 2000; |
76 | roll -= equip->weight / 2000; |
77 | } |
77 | |
78 | if (equip->type == ARMOUR && QUERY_FLAG (equip, FLAG_APPLIED)) |
78 | if (equip->type == ARMOUR && QUERY_FLAG (equip, FLAG_APPLIED)) |
79 | roll -= equip->weight / 5000; |
79 | roll -= equip->weight / 5000; |
|
|
80 | |
80 | if (equip->type == GLOVES && QUERY_FLAG (equip, FLAG_APPLIED)) |
81 | if (equip->type == GLOVES && QUERY_FLAG (equip, FLAG_APPLIED)) |
81 | roll -= equip->weight / 100; |
82 | roll -= equip->weight / 100; |
82 | } |
83 | } |
|
|
84 | |
83 | if (roll < 0) |
85 | if (roll < 0) |
84 | roll = 0; |
86 | roll = 0; |
|
|
87 | |
85 | return roll; |
88 | return roll; |
86 | } |
89 | } |
87 | |
90 | |
88 | /* |
91 | /* |
89 | * When stealing: dependent on the intelligence/wisdom of whom you're |
92 | * When stealing: dependent on the intelligence/wisdom of whom you're |
… | |
… | |
99 | { |
102 | { |
100 | object *success = NULL, *tmp = NULL, *next; |
103 | object *success = NULL, *tmp = NULL, *next; |
101 | int roll = 0, chance = 0, stats_value; |
104 | int roll = 0, chance = 0, stats_value; |
102 | rv_vector rv; |
105 | rv_vector rv; |
103 | |
106 | |
104 | stats_value = ((who->stats.Dex + who->stats.Int) * 3) / 2; |
107 | stats_value = (who->stats.Dex + who->stats.Int) * 3 / 2; |
105 | |
108 | |
106 | /* if the victim is aware of a thief in the area (FLAG_NO_STEAL set on them) |
109 | /* if the victim is aware of a thief in the area (FLAG_NO_STEAL set on them) |
107 | * they will try to prevent stealing if they can. Only unseen theives will |
110 | * they will try to prevent stealing if they can. Only unseen theives will |
108 | * have much chance of success. |
111 | * have much chance of success. |
109 | */ |
112 | */ |
110 | if (op->type != PLAYER && QUERY_FLAG (op, FLAG_NO_STEAL)) |
113 | if (!op->is_player () && op->flag [FLAG_NO_STEAL]) |
111 | { |
114 | { |
112 | if (can_detect_enemy (op, who, &rv)) |
115 | if (can_detect_enemy (op, who, &rv)) |
113 | { |
116 | { |
114 | npc_call_help (op); |
117 | npc_call_help (op); |
115 | CLEAR_FLAG (op, FLAG_UNAGGRESSIVE); |
118 | CLEAR_FLAG (op, FLAG_UNAGGRESSIVE); |
116 | new_draw_info (NDI_UNIQUE, 0, who, "Your attempt is prevented!"); |
119 | new_draw_info (NDI_UNIQUE, 0, who, "Your attempt is prevented!"); |
117 | return 0; |
120 | return 0; |
118 | } |
121 | } |
119 | else /* help npc to detect thief next time by raising its wisdom */ |
122 | else /* help npc to detect thief next time by raising its wisdom */ |
120 | op->stats.Wis += (op->stats.Int / 5) + 1; |
123 | op->stats.Wis += (op->stats.Int / 5) + 1; |
|
|
124 | |
121 | if (op->stats.Wis > MAX_STAT) |
125 | if (op->stats.Wis > MAX_STAT) |
122 | op->stats.Wis = MAX_STAT; |
126 | op->stats.Wis = MAX_STAT; |
123 | } |
127 | } |
124 | |
128 | |
125 | if (op->type == PLAYER && QUERY_FLAG (op, FLAG_WIZ)) |
129 | if (op->is_player () && op->flag [FLAG_WIZ]) |
126 | { |
130 | { |
127 | new_draw_info (NDI_UNIQUE, 0, who, "You can't steal from the dungeon master!\n"); |
131 | new_draw_info (NDI_UNIQUE, 0, who, "You can't steal from the dungeon master!\n"); |
128 | return 0; |
132 | return 0; |
129 | } |
133 | } |
130 | |
134 | |
131 | // only allow stealing between hostile players (TODO: probably should change) |
135 | // only allow stealing between hostile players (TODO: probably should change) |
132 | if (op->type == PLAYER && who->type == PLAYER && (who->contr->peaceful || op->contr->peaceful)) |
136 | if (op->is_player () && who->is_player () && (who->contr->peaceful || op->contr->peaceful)) |
133 | { |
137 | { |
134 | new_draw_info (NDI_UNIQUE, 0, who, "You can't steal from other players!\n"); |
138 | new_draw_info (NDI_UNIQUE, 0, who, "You can't steal from other players!\n"); |
135 | return 0; |
139 | return 0; |
136 | } |
140 | } |
137 | |
141 | |
… | |
… | |
198 | |
202 | |
199 | if ((roll >= skill->level) || !chance |
203 | if ((roll >= skill->level) || !chance |
200 | || (tmp && tmp->weight > (250 * (random_roll (0, stats_value + skill->level * 10 - 1, who, PREFER_LOW))))) |
204 | || (tmp && tmp->weight > (250 * (random_roll (0, stats_value + skill->level * 10 - 1, who, PREFER_LOW))))) |
201 | { |
205 | { |
202 | /* victim figures out where the thief is! */ |
206 | /* victim figures out where the thief is! */ |
203 | if (who->hide) |
207 | if (who->flag [FLAG_HIDDEN]) |
204 | make_visible (who); |
208 | make_visible (who); |
205 | |
209 | |
206 | if (op->type != PLAYER) |
210 | if (op->type != PLAYER) |
207 | { |
211 | { |
208 | /* The unaggressives look after themselves 8) */ |
212 | /* The unaggressives look after themselves 8) */ |
… | |
… | |
426 | op->invisible += 100; /* set the level of 'hiddeness' */ |
430 | op->invisible += 100; /* set the level of 'hiddeness' */ |
427 | |
431 | |
428 | if (op->type == PLAYER) |
432 | if (op->type == PLAYER) |
429 | op->contr->tmp_invis = 1; |
433 | op->contr->tmp_invis = 1; |
430 | |
434 | |
431 | op->hide = 1; |
435 | op->flag [FLAG_HIDDEN] = 1; |
432 | return 1; |
436 | return 1; |
433 | } |
437 | } |
434 | |
438 | |
435 | return 0; |
439 | return 0; |
436 | } |
440 | } |
… | |
… | |
445 | if (QUERY_FLAG (op, FLAG_MAKE_INVIS)) |
449 | if (QUERY_FLAG (op, FLAG_MAKE_INVIS)) |
446 | { |
450 | { |
447 | new_draw_info (NDI_UNIQUE, 0, op, "You don't need to hide while invisible!"); |
451 | new_draw_info (NDI_UNIQUE, 0, op, "You don't need to hide while invisible!"); |
448 | return 0; |
452 | return 0; |
449 | } |
453 | } |
450 | else if (!op->hide && op->invisible > 0 && op->type == PLAYER) |
454 | else if (!op->flag [FLAG_HIDDEN] && op->invisible > 0 && op->type == PLAYER) |
451 | { |
455 | { |
452 | new_draw_info (NDI_UNIQUE, 0, op, "Your attempt to hide breaks the invisibility spell!"); |
456 | new_draw_info (NDI_UNIQUE, 0, op, "Your attempt to hide breaks the invisibility spell!"); |
453 | make_visible (op); |
457 | make_visible (op); |
454 | } |
458 | } |
455 | |
459 | |
… | |
… | |
477 | static void |
481 | static void |
478 | stop_jump (object *pl, int dist, int spaces) |
482 | stop_jump (object *pl, int dist, int spaces) |
479 | { |
483 | { |
480 | pl->update_stats (); |
484 | pl->update_stats (); |
481 | pl->map->insert (pl, pl->x, pl->y, pl); |
485 | pl->map->insert (pl, pl->x, pl->y, pl); |
|
|
486 | pl->speed_left -= fabs (pl->speed * 8); |
482 | } |
487 | } |
483 | |
488 | |
484 | static int |
489 | static int |
485 | attempt_jump (object *pl, int dir, int spaces, object *skill) |
490 | attempt_jump (object *pl, int dir, int spaces, object *skill) |
486 | { |
491 | { |
487 | object *tmp; |
492 | object *tmp; |
488 | int i, exp = 0, dx = freearr_x[dir], dy = freearr_y[dir], mflags; |
493 | int i, dx = freearr_x[dir], dy = freearr_y[dir], mflags; |
489 | sint16 x, y; |
494 | sint16 x, y; |
490 | maptile *m; |
495 | maptile *m; |
491 | |
496 | |
492 | /* Jump loop. Go through spaces object wants to jump. Halt the |
497 | /* Jump loop. Go through spaces object wants to jump. Halt the |
493 | * jump if a wall or creature is in the way. We set FLAG_FLYING |
498 | * jump if a wall or creature is in the way. We set FLAG_FLYING |
494 | * temporarily to allow player to aviod exits/archs that are not |
499 | * temporarily to allow player to aviod exits/archs that are not |
495 | * fly_on, fly_off. This will also prevent pickup of objects |
500 | * fly_on, fly_off. This will also prevent pickup of objects |
496 | * while jumping over them. |
501 | * while jumping over them. |
497 | */ |
502 | */ |
498 | pl->remove (); |
503 | pl->remove (); |
499 | |
|
|
500 | /* |
|
|
501 | * I don't think this is actually needed - all the movement |
|
|
502 | * code is handled in this function, and I don't see anyplace |
|
|
503 | * that cares about the move_type being flying. |
|
|
504 | */ |
|
|
505 | pl->move_type |= MOVE_FLY_LOW; |
504 | pl->move_type |= MOVE_FLY_LOW; |
506 | |
505 | |
507 | for (i = 0; i <= spaces; i++) |
506 | for (i = 0; i <= spaces; i++) |
508 | { |
507 | { |
509 | x = pl->x + dx; |
508 | x = pl->x + dx; |
… | |
… | |
516 | { |
515 | { |
517 | stop_jump (pl, i, spaces); |
516 | stop_jump (pl, i, spaces); |
518 | return 0; |
517 | return 0; |
519 | } |
518 | } |
520 | |
519 | |
|
|
520 | for (tmp = GET_MAP_OB (m, x, y); tmp; tmp = tmp->above) |
|
|
521 | { |
|
|
522 | /* Jump into creature */ |
|
|
523 | if (QUERY_FLAG (tmp, FLAG_MONSTER) |
|
|
524 | || (tmp->type == PLAYER && (!QUERY_FLAG (tmp, FLAG_WIZ) || !tmp->contr->hidden))) |
|
|
525 | { |
|
|
526 | new_draw_info_format (NDI_UNIQUE, 0, pl, "You jump into %s%s.", tmp->type == PLAYER ? "" : "the ", &tmp->name); |
|
|
527 | |
|
|
528 | stop_jump (pl, i, spaces); |
|
|
529 | |
|
|
530 | int exp = 0; |
|
|
531 | |
|
|
532 | if (tmp->type != PLAYER |
|
|
533 | || (pl->type == PLAYER && !pl->contr->party) |
|
|
534 | || (pl->type == PLAYER && tmp->type == PLAYER && pl->contr->party != tmp->contr->party)) |
|
|
535 | exp = skill_attack (tmp, pl, pl->facing, "kicked", skill); /* pl makes an attack */ |
|
|
536 | |
|
|
537 | return exp; /* note that calc_skill_exp() is already called by skill_attack() */ |
|
|
538 | } |
|
|
539 | } |
|
|
540 | |
521 | if (OB_TYPE_MOVE_BLOCK (pl, GET_MAP_MOVE_BLOCK (m, x, y))) |
541 | if (OB_TYPE_MOVE_BLOCK (pl, GET_MAP_MOVE_BLOCK (m, x, y))) |
522 | { |
542 | { |
523 | new_draw_info (NDI_UNIQUE, 0, pl, "Your jump is blocked."); |
543 | new_draw_info (NDI_UNIQUE, 0, pl, "Your jump is blocked."); |
524 | stop_jump (pl, i, spaces); |
544 | stop_jump (pl, i, spaces); |
525 | return 0; |
545 | return 0; |
526 | } |
546 | } |
527 | |
547 | |
528 | for (tmp = GET_MAP_OB (m, x, y); tmp; tmp = tmp->above) |
|
|
529 | { |
|
|
530 | /* Jump into creature */ |
|
|
531 | if (QUERY_FLAG (tmp, FLAG_MONSTER) || (tmp->type == PLAYER && (!QUERY_FLAG (tmp, FLAG_WIZ) || !tmp->contr->hidden))) |
|
|
532 | { |
|
|
533 | new_draw_info_format (NDI_UNIQUE, 0, pl, "You jump into %s%s.", tmp->type == PLAYER ? "" : "the ", &tmp->name); |
|
|
534 | |
|
|
535 | stop_jump (pl, i, spaces); |
|
|
536 | |
|
|
537 | if (tmp->type != PLAYER || |
|
|
538 | (pl->type == PLAYER && pl->contr->party == NULL) || |
|
|
539 | (pl->type == PLAYER && tmp->type == PLAYER && pl->contr->party != tmp->contr->party)) |
|
|
540 | exp = skill_attack (tmp, pl, pl->facing, "kicked", skill); /* pl makes an attack */ |
|
|
541 | |
|
|
542 | return exp; /* note that calc_skill_exp() is already called by skill_attack() */ |
|
|
543 | } |
|
|
544 | |
|
|
545 | /* If the space has fly on set (no matter what the space is), |
|
|
546 | * we should get the effects - after all, the player is |
|
|
547 | * effectively flying. |
|
|
548 | */ |
|
|
549 | if (tmp->move_on & MOVE_FLY_LOW) |
|
|
550 | { |
|
|
551 | pl->x = x; |
|
|
552 | pl->y = y; |
|
|
553 | pl->map = m; |
|
|
554 | stop_jump (pl, i, spaces); |
|
|
555 | return calc_skill_exp (pl, NULL, skill); |
|
|
556 | } |
|
|
557 | } |
|
|
558 | |
|
|
559 | pl->x = x; |
548 | pl->x = x; |
560 | pl->y = y; |
549 | pl->y = y; |
561 | pl->map = m; |
550 | pl->map = m; |
|
|
551 | |
|
|
552 | if (m->at (x, y).move_on & pl->move_type) |
|
|
553 | { |
|
|
554 | new_draw_info (NDI_UNIQUE, 0, pl, "Your jump is stopped."); |
|
|
555 | stop_jump (pl, i, spaces); |
|
|
556 | return 0; |
|
|
557 | } |
562 | } |
558 | } |
563 | |
559 | |
564 | stop_jump (pl, i, spaces); |
560 | stop_jump (pl, i, spaces); |
565 | |
561 | |
566 | return calc_skill_exp (pl, NULL, skill); |
562 | return calc_skill_exp (pl, NULL, skill); |
… | |
… | |
1219 | * ordinary inscribable 'books' (anything that is not a SPELL). b.t. |
1215 | * ordinary inscribable 'books' (anything that is not a SPELL). b.t. |
1220 | */ |
1216 | */ |
1221 | static int |
1217 | static int |
1222 | write_note (object *pl, object *item, const char *msg, object *skill) |
1218 | write_note (object *pl, object *item, const char *msg, object *skill) |
1223 | { |
1219 | { |
1224 | |
|
|
1225 | if (strstr (msg, "\nendmsg")) |
1220 | if (strstr (msg, "\nendmsg")) |
1226 | { |
1221 | { |
1227 | new_draw_info (NDI_UNIQUE, 0, pl, "Trying to cheat now are we?"); |
1222 | new_draw_info (NDI_UNIQUE, 0, pl, "Trying to cheat now are we?"); |
1228 | return 0; |
1223 | return 0; |
1229 | } |
1224 | } |
… | |
… | |
1402 | object *item = find_marked_object (pl); |
1397 | object *item = find_marked_object (pl); |
1403 | |
1398 | |
1404 | /* find an item of correct type to write on */ |
1399 | /* find an item of correct type to write on */ |
1405 | if (!item) |
1400 | if (!item) |
1406 | { |
1401 | { |
1407 | new_draw_info (NDI_UNIQUE, 0, pl, "You don't have any marked item to write on. H<Use the mark command or the popup menu to makr an item.>"); |
1402 | new_draw_info (NDI_UNIQUE, 0, pl, "You don't have any marked item to write on. H<Use the mark command or the popup menu to make an item.>"); |
1408 | return 0; |
1403 | return 0; |
1409 | } |
1404 | } |
1410 | |
1405 | |
1411 | if (item->type != INSCRIBABLE) |
1406 | if (item->type != INSCRIBABLE) |
1412 | { |
1407 | { |
… | |
… | |
1485 | for (tmp = op->inv; tmp != NULL; tmp = tmp->below) |
1480 | for (tmp = op->inv; tmp != NULL; tmp = tmp->below) |
1486 | { |
1481 | { |
1487 | /* can't toss invisible or inv-locked items */ |
1482 | /* can't toss invisible or inv-locked items */ |
1488 | if (tmp->invisible || QUERY_FLAG (tmp, FLAG_INV_LOCKED)) |
1483 | if (tmp->invisible || QUERY_FLAG (tmp, FLAG_INV_LOCKED)) |
1489 | continue; |
1484 | continue; |
1490 | if (!request || !strcmp (query_name (tmp), request) || !strcmp (tmp->name, request)) |
1485 | if (!request || !strcmp (query_name (tmp), request) || !strcmp (&tmp->name, request)) |
1491 | break; |
1486 | break; |
1492 | } |
1487 | } |
1493 | } |
1488 | } |
1494 | |
1489 | |
1495 | /* this should prevent us from throwing away |
1490 | /* this should prevent us from throwing away |
… | |
… | |
1726 | { |
1721 | { |
1727 | throw_ob->last_sp += eff_str / 3; /* fly a little further */ |
1722 | throw_ob->last_sp += eff_str / 3; /* fly a little further */ |
1728 | throw_ob->stats.dam += throw_ob->inv->stats.dam + throw_ob->magic + 2; |
1723 | throw_ob->stats.dam += throw_ob->inv->stats.dam + throw_ob->magic + 2; |
1729 | throw_ob->stats.wc -= throw_ob->magic + throw_ob->inv->stats.wc; |
1724 | throw_ob->stats.wc -= throw_ob->magic + throw_ob->inv->stats.wc; |
1730 | /* only throw objects get directional faces */ |
1725 | /* only throw objects get directional faces */ |
1731 | if (GET_ANIM_ID (throw_ob) && NUM_ANIMATIONS (throw_ob)) |
1726 | if (throw_ob->has_anim () && throw_ob->anim_frames ()) |
1732 | SET_ANIMATION (throw_ob, dir); |
1727 | throw_ob->set_anim_frame (dir); |
1733 | } |
1728 | } |
1734 | else |
1729 | else |
1735 | { |
1730 | { |
1736 | uint16 mat = throw_ob->materials; |
1731 | uint16 mat = throw_ob->materials; |
1737 | |
1732 | |