1 | /* |
1 | /* |
2 | * static char *rcsid_skills_c = |
2 | * static char *rcsid_skills_c = |
3 | * "$Id: skills.c,v 1.1 2006/02/03 07:14:38 root Exp $"; |
3 | * "$Id: skills.c,v 1.6 2006/08/10 12:45:23 elmex Exp $"; |
4 | */ |
4 | */ |
5 | /* |
5 | /* |
6 | CrossFire, A Multiplayer game for X-windows |
6 | CrossFire, A Multiplayer game for X-windows |
7 | |
7 | |
8 | Copyright (C) 2003 Mark Wedel & Crossfire Development Team |
8 | Copyright (C) 2003 Mark Wedel & Crossfire Development Team |
… | |
… | |
117 | } |
117 | } |
118 | if (op->type == PLAYER && QUERY_FLAG(op, FLAG_WIZ)) { |
118 | if (op->type == PLAYER && QUERY_FLAG(op, FLAG_WIZ)) { |
119 | new_draw_info(NDI_UNIQUE, 0, who, "You can't steal from the dungeon master!\n"); |
119 | new_draw_info(NDI_UNIQUE, 0, who, "You can't steal from the dungeon master!\n"); |
120 | return 0; |
120 | return 0; |
121 | } |
121 | } |
|
|
122 | #ifdef PROHIBIT_PLAYERKILL |
|
|
123 | if(op->type == PLAYER && who->type == PLAYER && (who->contr->peaceful || op->contr->peaceful)) { |
|
|
124 | new_draw_info(NDI_UNIQUE, 0, who, "You can't steal from other players!\n"); |
|
|
125 | return 0; |
|
|
126 | } |
|
|
127 | #else |
122 | if(op->type == PLAYER && who->type == PLAYER && settings.no_player_stealing) { |
128 | if(op->type == PLAYER && who->type == PLAYER && settings.no_player_stealing) { |
123 | new_draw_info(NDI_UNIQUE, 0, who, "You can't steal from other players!\n"); |
129 | new_draw_info(NDI_UNIQUE, 0, who, "You can't steal from other players!\n"); |
124 | return 0; |
130 | return 0; |
125 | } |
131 | } |
|
|
132 | #endif |
126 | |
133 | |
127 | |
134 | |
128 | /* Ok then, go thru their inventory, stealing */ |
135 | /* Ok then, go thru their inventory, stealing */ |
129 | for(tmp = op->inv; tmp != NULL; tmp = next) { |
136 | for(tmp = op->inv; tmp != NULL; tmp = next) { |
130 | next = tmp->below; |
137 | next = tmp->below; |
… | |
… | |
285 | object *owner = get_owner(tmp); |
292 | object *owner = get_owner(tmp); |
286 | if (owner != NULL && owner->type == PLAYER) |
293 | if (owner != NULL && owner->type == PLAYER) |
287 | return 0; |
294 | return 0; |
288 | } |
295 | } |
289 | |
296 | |
290 | return (calc_skill_exp(op,tmp, skill)); |
297 | // reduce monster experience by experience we gained, as to |
|
|
298 | // limit the amount of exp that can be gained by stealing from monsters |
|
|
299 | // (jessies gave ~20,000,000 exp otherwise. |
|
|
300 | int exp = calc_skill_exp (op, tmp, skill); |
|
|
301 | exp = MIN (tmp->stats.exp, exp); |
|
|
302 | tmp->stats.exp -= exp; |
|
|
303 | return exp; |
291 | } |
304 | } |
292 | } |
305 | } |
293 | return 0; |
306 | return 0; |
294 | } |
307 | } |
295 | |
308 | |
… | |
… | |
608 | /* Helper function for do_skill_ident, so that we can loop |
621 | /* Helper function for do_skill_ident, so that we can loop |
609 | * over inventory AND objects on the ground conveniently. |
622 | * over inventory AND objects on the ground conveniently. |
610 | */ |
623 | */ |
611 | int do_skill_ident2(object *tmp,object *pl, int obj_class, object *skill) |
624 | int do_skill_ident2(object *tmp,object *pl, int obj_class, object *skill) |
612 | { |
625 | { |
613 | int success=0,chance, ip; |
626 | int success = 0, chance; |
614 | int skill_value = skill->level * pl->stats.Int?pl->stats.Int:10; |
627 | int skill_value = skill->level * pl->stats.Int ? pl->stats.Int : 10; |
615 | |
628 | |
616 | if(!QUERY_FLAG(tmp,FLAG_IDENTIFIED) && !QUERY_FLAG(tmp,FLAG_NO_SKILL_IDENT) |
629 | if (!QUERY_FLAG (tmp,FLAG_IDENTIFIED) && !QUERY_FLAG (tmp,FLAG_NO_SKILL_IDENT) |
617 | && need_identify(tmp) && !tmp->invisible && tmp->type==obj_class) { |
630 | && need_identify (tmp) && !tmp->invisible && tmp->type == obj_class) |
618 | ip = tmp->magic; |
631 | { |
619 | if (tmp->item_power > ip) ip=tmp->item_power; |
|
|
620 | |
|
|
621 | chance = die_roll(3, 10, pl, PREFER_LOW)-3 + |
632 | chance = die_roll(3, 10, pl, PREFER_LOW) - 3 |
622 | rndm(0, (tmp->magic ? tmp->magic*5 : 1)-1); |
633 | + rndm (0, (tmp->magic ? tmp->magic * 5 : 1) - 1); |
|
|
634 | |
623 | if(skill_value >= chance) { |
635 | if (skill_value >= chance) |
624 | identify(tmp); |
636 | { |
|
|
637 | identify(tmp); |
|
|
638 | |
625 | if (pl->type==PLAYER) { |
639 | if (pl->type==PLAYER) |
626 | new_draw_info_format(NDI_UNIQUE, 0, pl, |
640 | { |
627 | "You identify %s.", long_desc(tmp, pl)); |
641 | new_draw_info_format (NDI_UNIQUE, 0, pl, "You identify %s.", long_desc (tmp, pl)); |
|
|
642 | |
628 | if (tmp->msg) { |
643 | if (tmp->msg) |
|
|
644 | { |
629 | new_draw_info(NDI_UNIQUE, 0,pl, "The item has a story:"); |
645 | new_draw_info(NDI_UNIQUE, 0,pl, "The item has a story:"); |
630 | new_draw_info(NDI_UNIQUE, 0,pl, tmp->msg); |
646 | new_draw_info(NDI_UNIQUE, 0,pl, tmp->msg); |
|
|
647 | } |
|
|
648 | |
|
|
649 | /* identify will take care of updating the item if it is in the players inventory. IF on map, do it here */ |
|
|
650 | if (tmp->map) |
|
|
651 | esrv_send_item (pl, tmp); |
631 | } |
652 | } |
632 | /* identify will take care of updating the item if |
|
|
633 | * it is in the players inventory. IF on map, do it |
|
|
634 | * here |
|
|
635 | */ |
|
|
636 | if (tmp->map) |
|
|
637 | esrv_send_item(pl, tmp); |
|
|
638 | } |
|
|
639 | success += calc_skill_exp(pl,tmp, skill); |
653 | success += calc_skill_exp(pl,tmp, skill); |
640 | } else |
|
|
641 | SET_FLAG(tmp, FLAG_NO_SKILL_IDENT); |
|
|
642 | } |
654 | } |
|
|
655 | else |
|
|
656 | SET_FLAG (tmp, FLAG_NO_SKILL_IDENT); |
|
|
657 | } |
|
|
658 | |
643 | return success; |
659 | return success; |
644 | } |
660 | } |
645 | |
661 | |
646 | /* do_skill_ident() - workhorse for skill_ident() -b.t. |
662 | /* do_skill_ident() - workhorse for skill_ident() -b.t. |
647 | */ |
663 | */ |
648 | static int do_skill_ident(object *pl, int obj_class, object *skill) { |
664 | static int do_skill_ident(object *pl, int obj_class, object *skill) { |
… | |
… | |
1105 | /* write_note() - this routine allows players to inscribe messages in |
1121 | /* write_note() - this routine allows players to inscribe messages in |
1106 | * ordinary 'books' (anything that is type BOOK). b.t. |
1122 | * ordinary 'books' (anything that is type BOOK). b.t. |
1107 | */ |
1123 | */ |
1108 | |
1124 | |
1109 | static int write_note(object *pl, object *item, const char *msg, object *skill) { |
1125 | static int write_note(object *pl, object *item, const char *msg, object *skill) { |
1110 | char buf[BOOK_BUF]; |
1126 | char buf[1024]; |
1111 | object *newBook = NULL; |
1127 | object *newBook = NULL; |
1112 | |
1128 | |
1113 | /* a pair of sanity checks */ |
1129 | /* a pair of sanity checks */ |
1114 | if(!item||item->type!=BOOK) return 0; |
1130 | if(!item||item->type!=BOOK) return 0; |
1115 | |
1131 | |
… | |
… | |
1127 | /* Lauwenmark: Handle for plugin book writing (trigger) event */ |
1143 | /* Lauwenmark: Handle for plugin book writing (trigger) event */ |
1128 | if (execute_event(item, EVENT_TRIGGER,pl,NULL,msg,SCRIPT_FIX_ALL)!=0) |
1144 | if (execute_event(item, EVENT_TRIGGER,pl,NULL,msg,SCRIPT_FIX_ALL)!=0) |
1129 | return strlen(msg); |
1145 | return strlen(msg); |
1130 | |
1146 | |
1131 | buf[0] = 0; |
1147 | buf[0] = 0; |
1132 | if(!book_overflow(item->msg,msg,BOOK_BUF)) { /* add msg string to book */ |
1148 | if(!book_overflow(item->msg,msg,sizeof (buf))) { /* add msg string to book */ |
1133 | if(item->msg) |
1149 | if(item->msg) |
1134 | strcpy(buf,item->msg); |
1150 | strcpy(buf,item->msg); |
1135 | |
1151 | |
1136 | strcat(buf,msg); |
1152 | strcat(buf,msg); |
1137 | strcat(buf,"\n"); /* new msg needs a LF */ |
1153 | strcat(buf,"\n"); /* new msg needs a LF */ |
… | |
… | |
1259 | newscroll->value = newscroll->arch->clone.value * newscroll->inv->value * |
1275 | newscroll->value = newscroll->arch->clone.value * newscroll->inv->value * |
1260 | (newscroll->level +50) / (newscroll->inv->level + 50); |
1276 | (newscroll->level +50) / (newscroll->inv->level + 50); |
1261 | newscroll->stats.exp = newscroll->value/5; |
1277 | newscroll->stats.exp = newscroll->value/5; |
1262 | |
1278 | |
1263 | /* wait until finished manipulating the scroll before inserting it */ |
1279 | /* wait until finished manipulating the scroll before inserting it */ |
1264 | if (newscroll != scroll) |
1280 | if (newscroll == scroll) |
|
|
1281 | { |
|
|
1282 | /* Remove to correctly merge with other items which may exist in inventory */ |
|
|
1283 | remove_ob(newscroll); |
|
|
1284 | esrv_del_item(pl->contr,newscroll->count); |
|
|
1285 | } |
1265 | newscroll=insert_ob_in_ob(newscroll,pl); |
1286 | newscroll=insert_ob_in_ob(newscroll,pl); |
1266 | esrv_send_item(pl, newscroll); |
1287 | esrv_send_item(pl, newscroll); |
1267 | success = calc_skill_exp(pl,newscroll, skill); |
1288 | success = calc_skill_exp(pl,newscroll, skill); |
1268 | if(!confused) success *= 2; |
1289 | if(!confused) success *= 2; |
1269 | success = success * skill->level; |
1290 | success = success * skill->level; |
1270 | return success; |
1291 | return success; |