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.110 by root, Thu Nov 17 04:59:33 2016 UTC vs.
Revision 1.111 by root, Sun Jan 29 02:47:06 2017 UTC

53 53
54 /* It's harder to steal from hostile beings! */ 54 /* It's harder to steal from hostile beings! */
55 if (!victim->flag [FLAG_UNAGGRESSIVE]) 55 if (!victim->flag [FLAG_UNAGGRESSIVE])
56 roll = roll / 2; 56 roll = roll / 2;
57 57
58 /* Easier to steal from sleeping beings, or if the thief is 58 /* Easier to steal from sleeping beings, or if the thief is
59 * unseen */ 59 * unseen */
60 if (victim->flag [FLAG_SLEEP]) 60 if (victim->flag [FLAG_SLEEP])
61 roll = roll * 3; 61 roll = roll * 3;
62 else if (op->invisible) 62 else if (op->invisible)
63 roll = roll * 2; 63 roll = roll * 2;
64 64
65 /* check stealing 'encumberance'. Having this equipment applied makes 65 /* check stealing 'encumberance'. Having this equipment applied makes
66 * it quite a bit harder to steal. 66 * it quite a bit harder to steal.
67 */ 67 */
68 for (equip = op->inv; equip; equip = equip->below) 68 for (equip = op->inv; equip; equip = equip->below)
69 { 69 {
70 if (equip->type == WEAPON && equip->flag [FLAG_APPLIED]) 70 if (equip->type == WEAPON && equip->flag [FLAG_APPLIED])
71 roll -= equip->weight / 10000; 71 roll -= equip->weight / 10000;
87 roll = 0; 87 roll = 0;
88 88
89 return roll; 89 return roll;
90} 90}
91 91
92/* 92/*
93 * When stealing: dependent on the intelligence/wisdom of whom you're 93 * When stealing: dependent on the intelligence/wisdom of whom you're
94 * stealing from (op in attempt_steal), offset by your dexterity and 94 * stealing from (op in attempt_steal), offset by your dexterity and
95 * skill at stealing. They may notice your attempt, whether successful 95 * skill at stealing. They may notice your attempt, whether successful
96 * or not. 96 * or not.
97 * op is the target (person being pilfered) 97 * op is the target (person being pilfered)
98 * who is the person doing the stealing. 98 * who is the person doing the stealing.
99 * skill is the skill object (stealing). 99 * skill is the skill object (stealing).
100 */ 100 */
101static int 101static int
107 107
108 stats_value = (who->stats.Dex + who->stats.Int) * 3 / 2; 108 stats_value = (who->stats.Dex + who->stats.Int) * 3 / 2;
109 109
110 /* if the victim is aware of a thief in the area (FLAG_NO_STEAL set on them) 110 /* if the victim is aware of a thief in the area (FLAG_NO_STEAL set on them)
111 * they will try to prevent stealing if they can. Only unseen theives will 111 * they will try to prevent stealing if they can. Only unseen theives will
112 * have much chance of success. 112 * have much chance of success.
113 */ 113 */
114 if (!op->is_player () && op->flag [FLAG_NO_STEAL]) 114 if (!op->is_player () && op->flag [FLAG_NO_STEAL])
115 { 115 {
116 if (can_detect_enemy (op, who, &rv)) 116 if (can_detect_enemy (op, who, &rv))
117 { 117 {
143 /* Ok then, go through their inventory, stealing */ 143 /* Ok then, go through their inventory, stealing */
144 for (tmp = op->inv; tmp; tmp = next) 144 for (tmp = op->inv; tmp; tmp = next)
145 { 145 {
146 next = tmp->below; 146 next = tmp->below;
147 147
148 /* you can't steal worn items, starting items, wiz stuff, 148 /* you can't steal worn items, starting items, wiz stuff,
149 * innate abilities, or items w/o a type. Generally 149 * innate abilities, or items w/o a type. Generally
150 * speaking, the invisibility flag prevents experience or 150 * speaking, the invisibility flag prevents experience or
151 * abilities from being stolen since these types are currently 151 * abilities from being stolen since these types are currently
152 * always invisible objects. I was implicit here so as to prevent 152 * always invisible objects. I was implicit here so as to prevent
153 * future possible problems. -b.t. 153 * future possible problems. -b.t.
154 * Flesh items generated w/ fix_flesh_item should have FLAG_NO_STEAL 154 * Flesh items generated w/ fix_flesh_item should have FLAG_NO_STEAL
155 * already -b.t. 155 * already -b.t.
156 */ 156 */
157 157
158 if (tmp->flag [FLAG_APPLIED] 158 if (tmp->flag [FLAG_APPLIED]
159 || !tmp->type 159 || !tmp->type
160 || tmp->type == SPELL 160 || tmp->type == SPELL
162 || tmp->flag [FLAG_NO_STEAL] 162 || tmp->flag [FLAG_NO_STEAL]
163 || tmp->invisible) 163 || tmp->invisible)
164 continue; 164 continue;
165 165
166 /* Okay, try stealing this item. Dependent on dexterity of thief, 166 /* Okay, try stealing this item. Dependent on dexterity of thief,
167 * skill level, see the adj_stealroll fctn for more detail. 167 * skill level, see the adj_stealroll fctn for more detail.
168 */ 168 */
169 169
170 roll = die_roll (2, 100, who, PREFER_LOW) / 2; /* weighted 1-100 */ 170 roll = die_roll (2, 100, who, PREFER_LOW) / 2; /* weighted 1-100 */
171 171
172 if ((chance = adj_stealchance (who, op, (stats_value + skill->level * 10 - op->level * 3))) == -1) 172 if ((chance = adj_stealchance (who, op, (stats_value + skill->level * 10 - op->level * 3))) == -1)
196 return 0; 196 return 0;
197 } 197 }
198 198
199 /* If you arent high enough level, you might get something BUT 199 /* If you arent high enough level, you might get something BUT
200 * the victim will notice your stealing attempt. Ditto if you 200 * the victim will notice your stealing attempt. Ditto if you
201 * attempt to steal something heavy off them, they're bound to notice 201 * attempt to steal something heavy off them, they're bound to notice
202 */ 202 */
203 203
204 if ((roll >= skill->level) || !chance 204 if ((roll >= skill->level) || !chance
205 || (tmp && tmp->weight > (250 * (random_roll (0, stats_value + skill->level * 10 - 1, who, PREFER_LOW))))) 205 || (tmp && tmp->weight > (250 * (random_roll (0, stats_value + skill->level * 10 - 1, who, PREFER_LOW)))))
206 { 206 {
216 npc_call_help (op); 216 npc_call_help (op);
217 new_draw_info_format (NDI_UNIQUE, 0, who, "%s notices your attempted pilfering!", query_name (op)); 217 new_draw_info_format (NDI_UNIQUE, 0, who, "%s notices your attempted pilfering!", query_name (op));
218 } 218 }
219 219
220 op->clr_flag (FLAG_UNAGGRESSIVE); 220 op->clr_flag (FLAG_UNAGGRESSIVE);
221 /* all remaining npc items are guarded now. Set flag NO_STEAL 221 /* all remaining npc items are guarded now. Set flag NO_STEAL
222 * on the victim. 222 * on the victim.
223 */ 223 */
224 op->set_flag (FLAG_NO_STEAL); 224 op->set_flag (FLAG_NO_STEAL);
225 } 225 }
226 else 226 else
227 { /* stealing from another player */ 227 { /* stealing from another player */
325{ 325{
326 int difficulty = pl->map->difficulty ? pl->map->difficulty : 0; 326 int difficulty = pl->map->difficulty ? pl->map->difficulty : 0;
327 int success = 0, number; /* did we get anything? */ 327 int success = 0, number; /* did we get anything? */
328 328
329 329
330 /* Try to pick the lock on this item (doors only for now). 330 /* Try to pick the lock on this item (doors only for now).
331 * Dependent on dexterity/skill SK_level of the player and 331 * Dependent on dexterity/skill SK_level of the player and
332 * the map level difficulty. 332 * the map level difficulty.
333 */ 333 */
334 number = (die_roll (2, 40, pl, PREFER_LOW) - 2) / 2; 334 number = (die_roll (2, 40, pl, PREFER_LOW) - 2) / 2;
335 if (number < (pl->stats.Dex + skill->level - difficulty)) 335 if (number < (pl->stats.Dex + skill->level - difficulty))
336 { 336 {
337 remove_door (door); 337 remove_door (door);
400 } 400 }
401} 401}
402 402
403/* HIDE CODE. The user becomes undetectable (not just 'invisible') for 403/* HIDE CODE. The user becomes undetectable (not just 'invisible') for
404 * a short while (success and duration dependant on player SK_level, 404 * a short while (success and duration dependant on player SK_level,
405 * dexterity, charisma, and map difficulty). 405 * dexterity, charisma, and map difficulty).
406 * Players have a good chance of becoming 'unhidden' if they move 406 * Players have a good chance of becoming 'unhidden' if they move
407 * and like invisiblity will be come visible if they attack 407 * and like invisiblity will be come visible if they attack
408 * Implemented by b.t. (thomas@astro.psu.edu) 408 * Implemented by b.t. (thomas@astro.psu.edu)
409 * July 7, 1995 - made hiding possible for monsters. -b.t. 409 * July 7, 1995 - made hiding possible for monsters. -b.t.
410 */ 410 */
416 416
417 if (terrain < -10) /* not enough cover here */ 417 if (terrain < -10) /* not enough cover here */
418 return 0; 418 return 0;
419 419
420 /* Hiding success and duration dependant on skill level, 420 /* Hiding success and duration dependant on skill level,
421 * op->stats.Dex, map difficulty and terrain. 421 * op->stats.Dex, map difficulty and terrain.
422 */ 422 */
423 number = (die_roll (2, 25, op, PREFER_LOW) - 2) / 2; 423 number = (die_roll (2, 25, op, PREFER_LOW) - 2) / 2;
424 424
425 if (!stand_near_hostile (op) && (number < (op->stats.Dex + skill->level + terrain - difficulty))) 425 if (!stand_near_hostile (op) && (number < (op->stats.Dex + skill->level + terrain - difficulty)))
426 { 426 {
469 469
470 new_draw_info (NDI_UNIQUE, 0, op, "You fail to conceal yourself."); 470 new_draw_info (NDI_UNIQUE, 0, op, "You fail to conceal yourself.");
471 return 0; 471 return 0;
472} 472}
473 473
474/* stop_jump() - End of jump. Clear flags, restore the map, and 474/* stop_jump() - End of jump. Clear flags, restore the map, and
475 * freeze the jumper a while to simulate the exhaustion 475 * freeze the jumper a while to simulate the exhaustion
476 * of jumping. 476 * of jumping.
477 */ 477 */
478static void 478static void
479stop_jump (object *pl, int dist, int spaces) 479stop_jump (object *pl, int dist, int spaces)
491 sint16 x, y; 491 sint16 x, y;
492 maptile *m; 492 maptile *m;
493 493
494 /* Jump loop. Go through spaces object wants to jump. Halt the 494 /* Jump loop. Go through spaces object wants to jump. Halt the
495 * jump if a wall or creature is in the way. We set FLAG_FLYING 495 * jump if a wall or creature is in the way. We set FLAG_FLYING
496 * temporarily to allow player to aviod exits/archs that are not 496 * temporarily to allow player to aviod exits/archs that are not
497 * fly_on, fly_off. This will also prevent pickup of objects 497 * fly_on, fly_off. This will also prevent pickup of objects
498 * while jumping over them. 498 * while jumping over them.
499 */ 499 */
500 pl->remove (); 500 pl->remove ();
501 pl->move_type |= MOVE_FLY_LOW; 501 pl->move_type |= MOVE_FLY_LOW;
502 502
503 for (i = 0; i <= spaces; i++) 503 for (i = 0; i <= spaces; i++)
658 658
659 return success; 659 return success;
660} 660}
661 661
662/* Helper function for do_skill_ident, so that we can loop 662/* Helper function for do_skill_ident, so that we can loop
663 * over inventory AND objects on the ground conveniently. 663 * over inventory AND objects on the ground conveniently.
664 */ 664 */
665static int 665static int
666do_skill_ident2 (object *tmp, object *pl, int obj_class, object *skill) 666do_skill_ident2 (object *tmp, object *pl, int obj_class, object *skill)
667{ 667{
668 int success = 0, chance; 668 int success = 0, chance;
783 783
784 return success; 784 return success;
785} 785}
786 786
787/* players using this skill can 'charm' a monster -- 787/* players using this skill can 'charm' a monster --
788 * into working for them. It can only be used on 788 * into working for them. It can only be used on
789 * non-special (see below) 'neutral' creatures. 789 * non-special (see below) 'neutral' creatures.
790 * -b.t. (thomas@astro.psu.edu) 790 * -b.t. (thomas@astro.psu.edu)
791 */ 791 */
792int 792int
793use_oratory (object *pl, int dir, object *skill) 793use_oratory (object *pl, int dir, object *skill)
794{ 794{
914 914
915 return 0; /* Fall through - if we get here, we didn't charm anything */ 915 return 0; /* Fall through - if we get here, we didn't charm anything */
916} 916}
917 917
918/* Singing() -this skill allows the player to pacify nearby creatures. 918/* Singing() -this skill allows the player to pacify nearby creatures.
919 * There are few limitations on who/what kind of 919 * There are few limitations on who/what kind of
920 * non-player creatures that may be pacified. Right now, a player 920 * non-player creatures that may be pacified. Right now, a player
921 * may pacify creatures which have Int == 0. In this routine, once 921 * may pacify creatures which have Int == 0. In this routine, once
922 * successfully pacified the creature gets Int=1. Thus, a player 922 * successfully pacified the creature gets Int=1. Thus, a player
923 * may only pacify a creature once. 923 * may only pacify a creature once.
924 * BTW, I appologize for the naming of the skill, I couldnt think 924 * BTW, I appologize for the naming of the skill, I couldnt think
925 * of anything better! -b.t. 925 * of anything better! -b.t.
926 */ 926 */
927int 927int
928singing (object *pl, int dir, object *skill) 928singing (object *pl, int dir, object *skill)
929{ 929{
930 int exp = 0; 930 int exp = 0;
1012 int i, expsum = 0, mflags; 1012 int i, expsum = 0, mflags;
1013 sint16 x, y; 1013 sint16 x, y;
1014 maptile *m; 1014 maptile *m;
1015 1015
1016 /* First we search all around us for runes and traps, which are 1016 /* First we search all around us for runes and traps, which are
1017 * all type RUNE 1017 * all type RUNE
1018 */ 1018 */
1019 for (i = 0; i < 9; i++) 1019 for (i = 0; i < 9; i++)
1020 { 1020 {
1021 x = pl->x + freearr_x[i]; 1021 x = pl->x + freearr_x[i];
1022 y = pl->y + freearr_y[i]; 1022 y = pl->y + freearr_y[i];
1064 1064
1065 new_draw_info (NDI_BLACK, 0, pl, "You search the area."); 1065 new_draw_info (NDI_BLACK, 0, pl, "You search the area.");
1066 return expsum; 1066 return expsum;
1067} 1067}
1068 1068
1069/* remove_trap() - This skill will disarm any previously discovered trap 1069/* remove_trap() - This skill will disarm any previously discovered trap
1070 * the algorithm is based (almost totally) on the old command_disarm() - b.t. 1070 * the algorithm is based (almost totally) on the old command_disarm() - b.t.
1071 */ 1071 */
1072int 1072int
1073remove_trap (object *op, int dir, object *skill) 1073remove_trap (object *op, int dir, object *skill)
1074{ 1074{
1075 object *tmp, *tmp2; 1075 object *tmp, *tmp2;
1169 } 1169 }
1170 1170
1171 return 0; 1171 return 0;
1172} 1172}
1173 1173
1174/* This skill allows the player to regain a few sp or hp for a 1174/* This skill allows the player to regain a few sp or hp for a
1175 * brief period of concentration. No armour or weapons may be 1175 * brief period of concentration. No armour or weapons may be
1176 * wielded/applied for this to work. The amount of time needed 1176 * wielded/applied for this to work. The amount of time needed
1177 * to concentrate and the # of points regained is dependant on 1177 * to concentrate and the # of points regained is dependant on
1178 * the level of the user. - b.t. thomas@astro.psu.edu 1178 * the level of the user. - b.t. thomas@astro.psu.edu
1179 */ 1179 */
1180void 1180void
1181meditate (object *pl, object *skill) 1181meditate (object *pl, object *skill)
1182{ 1182{
1183 object *tmp; 1183 object *tmp;
1491 break; 1491 break;
1492 } 1492 }
1493 1493
1494 /* this should prevent us from throwing away 1494 /* this should prevent us from throwing away
1495 * cursed items, worn armour, etc. Only weapons 1495 * cursed items, worn armour, etc. Only weapons
1496 * can be thrown from 'hand'. 1496 * can be thrown from 'hand'.
1497 */ 1497 */
1498 if (!tmp) 1498 if (!tmp)
1499 return 0; 1499 return 0;
1500 1500
1501 if (tmp->flag [FLAG_APPLIED]) 1501 if (tmp->flag [FLAG_APPLIED])
1592 return 0; 1592 return 0;
1593 } 1593 }
1594 1594
1595 /* Because throwing effectiveness must be reduced by the 1595 /* Because throwing effectiveness must be reduced by the
1596 * encumbrance of the thrower and weight of the object. THus, 1596 * encumbrance of the thrower and weight of the object. THus,
1597 * we use the concept of 'effective strength' as defined below. 1597 * we use the concept of 'effective strength' as defined below.
1598 */ 1598 */
1599 1599
1600 /* if str exceeds MAX_STAT (30, eg giants), lets assign a str_factor > 1 */ 1600 /* if str exceeds MAX_STAT (30, eg giants), lets assign a str_factor > 1 */
1601 if (str > MAX_STAT) 1601 if (str > MAX_STAT)
1602 { 1602 {
1657 } /* if object can't be thrown */ 1657 } /* if object can't be thrown */
1658 1658
1659 left = throw_ob; /* these are throwing objects left to the player */ 1659 left = throw_ob; /* these are throwing objects left to the player */
1660 1660
1661 /* sometimes get_split_ob can't split an object (because op->nrof==0?) 1661 /* sometimes get_split_ob can't split an object (because op->nrof==0?)
1662 * and returns NULL. We must use 'left' then 1662 * and returns NULL. We must use 'left' then
1663 */ 1663 */
1664 if (!(throw_ob = throw_ob->split ())) 1664 if (!(throw_ob = throw_ob->split ()))
1665 { 1665 {
1666 throw_ob = left; 1666 throw_ob = left;
1667 left->remove (); 1667 left->remove ();
1718 /* replace 25 with a call to clone.arch wc? messes up w/ NPC */ 1718 /* replace 25 with a call to clone.arch wc? messes up w/ NPC */
1719 throw_ob->stats.wc = 25 - dex_bonus[op->stats.Dex] - thaco_bonus[eff_str] - skill->level; 1719 throw_ob->stats.wc = 25 - dex_bonus[op->stats.Dex] - thaco_bonus[eff_str] - skill->level;
1720 1720
1721 /* the properties of objects which are meant to be thrown (ie dart, 1721 /* the properties of objects which are meant to be thrown (ie dart,
1722 * throwing knife, etc) will differ from ordinary items. Lets tailor 1722 * throwing knife, etc) will differ from ordinary items. Lets tailor
1723 * this stuff in here. 1723 * this stuff in here.
1724 */ 1724 */
1725 1725
1726 if (throw_ob->inv->flag [FLAG_IS_THROWN]) 1726 if (throw_ob->inv->flag [FLAG_IS_THROWN])
1727 { 1727 {
1728 throw_ob->last_sp += eff_str / 3; /* fly a little further */ 1728 throw_ob->last_sp += eff_str / 3; /* fly a little further */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines