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

Comparing deliantra/server/server/skills.C (file contents):
Revision 1.50 by root, Tue Apr 22 07:01:47 2008 UTC vs.
Revision 1.64 by root, Tue May 5 04:51:56 2009 UTC

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
138 /* Ok then, go thru their inventory, stealing */ 142 /* Ok then, go through their inventory, stealing */
139 for (tmp = op->inv; tmp; tmp = next) 143 for (tmp = op->inv; tmp; tmp = next)
140 { 144 {
141 next = tmp->below; 145 next = tmp->below;
142 146
143 /* you can't steal worn items, starting items, wiz stuff, 147 /* you can't steal worn items, starting items, wiz stuff,
197 */ 201 */
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
203 /* victim figures out where the thief is! */ 206 /* victim figures out where the thief is! */
204 if (who->hide) 207 if (who->flag [FLAG_HIDDEN])
205 make_visible (who); 208 make_visible (who);
206 209
207 if (op->type != PLAYER) 210 if (op->type != PLAYER)
208 { 211 {
209 /* The unaggressives look after themselves 8) */ 212 /* The unaggressives look after themselves 8) */
210 if (who->type == PLAYER) 213 if (who->type == PLAYER)
211 { 214 {
212 npc_call_help (op); 215 npc_call_help (op);
213 new_draw_info_format (NDI_UNIQUE, 0, who, "%s notices your attempted pilfering!", query_name (op)); 216 new_draw_info_format (NDI_UNIQUE, 0, who, "%s notices your attempted pilfering!", query_name (op));
214 } 217 }
218
215 CLEAR_FLAG (op, FLAG_UNAGGRESSIVE); 219 CLEAR_FLAG (op, FLAG_UNAGGRESSIVE);
216 /* all remaining npc items are guarded now. Set flag NO_STEAL 220 /* all remaining npc items are guarded now. Set flag NO_STEAL
217 * on the victim. 221 * on the victim.
218 */ 222 */
219 SET_FLAG (op, FLAG_NO_STEAL); 223 SET_FLAG (op, FLAG_NO_STEAL);
222 { /* stealing from another player */ 226 { /* stealing from another player */
223 char buf[MAX_BUF]; 227 char buf[MAX_BUF];
224 228
225 /* Notify the other player */ 229 /* Notify the other player */
226 if (success && who->stats.Int > random_roll (0, 19, op, PREFER_LOW)) 230 if (success && who->stats.Int > random_roll (0, 19, op, PREFER_LOW))
227 {
228 sprintf (buf, "Your %s is missing!", query_name (success)); 231 sprintf (buf, "Your %s is missing!", query_name (success));
229 }
230 else 232 else
231 {
232 sprintf (buf, "Your pack feels strangely lighter."); 233 sprintf (buf, "Your pack feels strangely lighter.");
233 } 234
234 new_draw_info (NDI_UNIQUE, 0, op, buf); 235 new_draw_info (NDI_UNIQUE, 0, op, buf);
235 if (!success) 236 if (!success)
236 { 237 {
237 if (who->invisible) 238 if (who->invisible)
238 {
239 sprintf (buf, "you feel itchy fingers getting at your pack."); 239 sprintf (buf, "you feel itchy fingers getting at your pack.");
240 }
241 else 240 else
242 {
243 sprintf (buf, "%s looks very shifty.", query_name (who)); 241 sprintf (buf, "%s looks very shifty.", query_name (who));
244 } 242
245 new_draw_info (NDI_UNIQUE, 0, op, buf); 243 new_draw_info (NDI_UNIQUE, 0, op, buf);
246 } 244 }
247 } /* else stealing from another player */ 245 } /* else stealing from another player */
248 /* play_sound("stop! thief!"); kindofthing */ 246 /* play_sound("stop! thief!"); kindofthing */
249 } /* if you weren't 100% successful */ 247 } /* if you weren't 100% successful */
248
250 return success ? 1 : 0; 249 return success ? 1 : 0;
251} 250}
252 251
253int 252int
254steal (object *op, int dir, object *skill) 253steal (object *op, int dir, object *skill)
431 op->invisible += 100; /* set the level of 'hiddeness' */ 430 op->invisible += 100; /* set the level of 'hiddeness' */
432 431
433 if (op->type == PLAYER) 432 if (op->type == PLAYER)
434 op->contr->tmp_invis = 1; 433 op->contr->tmp_invis = 1;
435 434
436 op->hide = 1; 435 op->flag [FLAG_HIDDEN] = 1;
437 return 1; 436 return 1;
438 } 437 }
439 438
440 return 0; 439 return 0;
441} 440}
450 if (QUERY_FLAG (op, FLAG_MAKE_INVIS)) 449 if (QUERY_FLAG (op, FLAG_MAKE_INVIS))
451 { 450 {
452 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!");
453 return 0; 452 return 0;
454 } 453 }
455 else if (!op->hide && op->invisible > 0 && op->type == PLAYER) 454 else if (!op->flag [FLAG_HIDDEN] && op->invisible > 0 && op->type == PLAYER)
456 { 455 {
457 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!");
458 make_visible (op); 457 make_visible (op);
459 } 458 }
460 459
482static void 481static void
483stop_jump (object *pl, int dist, int spaces) 482stop_jump (object *pl, int dist, int spaces)
484{ 483{
485 pl->update_stats (); 484 pl->update_stats ();
486 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);
487} 487}
488 488
489static int 489static int
490attempt_jump (object *pl, int dir, int spaces, object *skill) 490attempt_jump (object *pl, int dir, int spaces, object *skill)
491{ 491{
492 object *tmp; 492 object *tmp;
493 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;
494 sint16 x, y; 494 sint16 x, y;
495 maptile *m; 495 maptile *m;
496 496
497 /* Jump loop. Go through spaces object wants to jump. Halt the 497 /* Jump loop. Go through spaces object wants to jump. Halt the
498 * 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
499 * temporarily to allow player to aviod exits/archs that are not 499 * temporarily to allow player to aviod exits/archs that are not
500 * fly_on, fly_off. This will also prevent pickup of objects 500 * fly_on, fly_off. This will also prevent pickup of objects
501 * while jumping over them. 501 * while jumping over them.
502 */ 502 */
503 pl->remove (); 503 pl->remove ();
504
505 /*
506 * I don't think this is actually needed - all the movement
507 * code is handled in this function, and I don't see anyplace
508 * that cares about the move_type being flying.
509 */
510 pl->move_type |= MOVE_FLY_LOW; 504 pl->move_type |= MOVE_FLY_LOW;
511 505
512 for (i = 0; i <= spaces; i++) 506 for (i = 0; i <= spaces; i++)
513 { 507 {
514 x = pl->x + dx; 508 x = pl->x + dx;
521 { 515 {
522 stop_jump (pl, i, spaces); 516 stop_jump (pl, i, spaces);
523 return 0; 517 return 0;
524 } 518 }
525 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
526 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)))
527 { 542 {
528 new_draw_info (NDI_UNIQUE, 0, pl, "Your jump is blocked."); 543 new_draw_info (NDI_UNIQUE, 0, pl, "Your jump is blocked.");
529 stop_jump (pl, i, spaces); 544 stop_jump (pl, i, spaces);
530 return 0; 545 return 0;
531 } 546 }
532 547
533 for (tmp = GET_MAP_OB (m, x, y); tmp; tmp = tmp->above)
534 {
535 /* Jump into creature */
536 if (QUERY_FLAG (tmp, FLAG_MONSTER) || (tmp->type == PLAYER && (!QUERY_FLAG (tmp, FLAG_WIZ) || !tmp->contr->hidden)))
537 {
538 new_draw_info_format (NDI_UNIQUE, 0, pl, "You jump into %s%s.", tmp->type == PLAYER ? "" : "the ", &tmp->name);
539
540 stop_jump (pl, i, spaces);
541
542 if (tmp->type != PLAYER ||
543 (pl->type == PLAYER && pl->contr->party == NULL) ||
544 (pl->type == PLAYER && tmp->type == PLAYER && pl->contr->party != tmp->contr->party))
545 exp = skill_attack (tmp, pl, pl->facing, "kicked", skill); /* pl makes an attack */
546
547 return exp; /* note that calc_skill_exp() is already called by skill_attack() */
548 }
549
550 /* If the space has fly on set (no matter what the space is),
551 * we should get the effects - after all, the player is
552 * effectively flying.
553 */
554 if (tmp->move_on & MOVE_FLY_LOW)
555 {
556 pl->x = x;
557 pl->y = y;
558 pl->map = m;
559 stop_jump (pl, i, spaces);
560 return calc_skill_exp (pl, NULL, skill);
561 }
562 }
563
564 pl->x = x; 548 pl->x = x;
565 pl->y = y; 549 pl->y = y;
566 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 }
567 } 558 }
568 559
569 stop_jump (pl, i, spaces); 560 stop_jump (pl, i, spaces);
570 561
571 return calc_skill_exp (pl, NULL, skill); 562 return calc_skill_exp (pl, NULL, skill);
885 /* Ok, got a 'sucker' lets try to make them a follower */ 876 /* Ok, got a 'sucker' lets try to make them a follower */
886 if (level > 0 && tmp->level < (random_roll (0, level - 1, pl, PREFER_HIGH) - 1)) 877 if (level > 0 && tmp->level < (random_roll (0, level - 1, pl, PREFER_HIGH) - 1))
887 { 878 {
888 new_draw_info_format (NDI_UNIQUE, 0, pl, "You convince the %s to become your follower.\n", query_name (tmp)); 879 new_draw_info_format (NDI_UNIQUE, 0, pl, "You convince the %s to become your follower.\n", query_name (tmp));
889 880
881 INVOKE_OBJECT (KILL, tmp, ARG_OBJECT (pl));
890 tmp->set_owner (pl); 882 tmp->set_owner (pl);
891 tmp->skill = skill->skill; 883 tmp->skill = skill->skill;
892 tmp->stats.exp = 0; 884 tmp->stats.exp = 0;
893 tmp->attack_movement = PETMOVE; 885 tmp->attack_movement = PETMOVE;
894 886
1223 * ordinary inscribable 'books' (anything that is not a SPELL). b.t. 1215 * ordinary inscribable 'books' (anything that is not a SPELL). b.t.
1224 */ 1216 */
1225static int 1217static int
1226write_note (object *pl, object *item, const char *msg, object *skill) 1218write_note (object *pl, object *item, const char *msg, object *skill)
1227{ 1219{
1228
1229 if (strstr (msg, "\nendmsg")) 1220 if (strstr (msg, "\nendmsg"))
1230 { 1221 {
1231 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?");
1232 return 0; 1223 return 0;
1233 } 1224 }
1406 object *item = find_marked_object (pl); 1397 object *item = find_marked_object (pl);
1407 1398
1408 /* find an item of correct type to write on */ 1399 /* find an item of correct type to write on */
1409 if (!item) 1400 if (!item)
1410 { 1401 {
1411 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.>");
1412 return 0; 1403 return 0;
1413 } 1404 }
1414 1405
1415 if (item->type != INSCRIBABLE) 1406 if (item->type != INSCRIBABLE)
1416 { 1407 {
1489 for (tmp = op->inv; tmp != NULL; tmp = tmp->below) 1480 for (tmp = op->inv; tmp != NULL; tmp = tmp->below)
1490 { 1481 {
1491 /* can't toss invisible or inv-locked items */ 1482 /* can't toss invisible or inv-locked items */
1492 if (tmp->invisible || QUERY_FLAG (tmp, FLAG_INV_LOCKED)) 1483 if (tmp->invisible || QUERY_FLAG (tmp, FLAG_INV_LOCKED))
1493 continue; 1484 continue;
1494 if (!request || !strcmp (query_name (tmp), request) || !strcmp (tmp->name, request)) 1485 if (!request || !strcmp (query_name (tmp), request) || !strcmp (&tmp->name, request))
1495 break; 1486 break;
1496 } 1487 }
1497 } 1488 }
1498 1489
1499 /* this should prevent us from throwing away 1490 /* this should prevent us from throwing away
1538 return tmp; 1529 return tmp;
1539} 1530}
1540 1531
1541/* make_throw_ob() We construct the 'carrier' object in 1532/* make_throw_ob() We construct the 'carrier' object in
1542 * which we will insert the object that is being thrown. 1533 * which we will insert the object that is being thrown.
1543 * This combination becomes the 'thrown object'. -b.t. 1534 * This combination becomes the 'thrown object'. -b.t.
1544 */ 1535 */
1545static object * 1536static object *
1546make_throw_ob (object *orig) 1537make_throw_ob (object *orig)
1547{ 1538{
1548 if (!orig) 1539 if (!orig)
1549 return NULL; 1540 return 0;
1550 1541
1551 if (QUERY_FLAG (orig, FLAG_APPLIED)) 1542 if (QUERY_FLAG (orig, FLAG_APPLIED))
1552 { 1543 {
1553 LOG (llevError, "BUG: make_throw_ob(): ob is applied\n"); 1544 LOG (llevError, "BUG: make_throw_ob(): ob is applied\n");
1554 /* insufficient workaround, but better than nothing */ 1545 /* insufficient workaround, but better than nothing */
1730 { 1721 {
1731 throw_ob->last_sp += eff_str / 3; /* fly a little further */ 1722 throw_ob->last_sp += eff_str / 3; /* fly a little further */
1732 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;
1733 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;
1734 /* only throw objects get directional faces */ 1725 /* only throw objects get directional faces */
1735 if (GET_ANIM_ID (throw_ob) && NUM_ANIMATIONS (throw_ob)) 1726 if (throw_ob->has_anim () && throw_ob->anim_frames ())
1736 SET_ANIMATION (throw_ob, dir); 1727 throw_ob->set_anim_frame (dir);
1737 } 1728 }
1738 else 1729 else
1739 { 1730 {
1740 uint16 mat = throw_ob->materials; 1731 uint16 mat = throw_ob->materials;
1741 1732

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines