… | |
… | |
160 | * matching item. |
160 | * matching item. |
161 | **/ |
161 | **/ |
162 | void |
162 | void |
163 | handle_apply_yield (object *tmp) |
163 | handle_apply_yield (object *tmp) |
164 | { |
164 | { |
165 | if (shstr yield = tmp->kv (shstr_on_use_yield)) |
165 | if (shstr_tmp yield = tmp->kv (shstr_on_use_yield)) |
166 | archetype::get (yield)->insert_at (tmp, tmp, INS_BELOW_ORIGINATOR); |
166 | archetype::get (yield)->insert_at (tmp, tmp, INS_BELOW_ORIGINATOR); |
167 | } |
167 | } |
168 | |
168 | |
169 | /** |
169 | /** |
170 | * Handles applying a potion. |
170 | * Handles applying a potion. |
… | |
… | |
406 | |
406 | |
407 | /** |
407 | /** |
408 | * This returns the sum of nrof of item (arch name). |
408 | * This returns the sum of nrof of item (arch name). |
409 | */ |
409 | */ |
410 | static int |
410 | static int |
411 | check_item (object *op, const char *item) |
411 | check_item (object *op, shstr_cmp item) |
412 | { |
412 | { |
413 | int count = 0; |
413 | int count = 0; |
414 | |
414 | |
415 | if (!item) |
415 | if (!item) |
416 | return 0; |
416 | return 0; |
417 | |
417 | |
418 | for (op = op->below; op; op = op->below) |
418 | for (op = op->below; op; op = op->below) |
419 | { |
|
|
420 | if (strcmp (op->arch->archname, item) == 0) |
419 | if (op->arch->archname == item) |
421 | { |
|
|
422 | if (!QUERY_FLAG (op, FLAG_CURSED) && !QUERY_FLAG (op, FLAG_DAMNED) |
420 | if (!QUERY_FLAG (op, FLAG_CURSED) && !QUERY_FLAG (op, FLAG_DAMNED) |
423 | /* Loophole bug? -FD- */ && !QUERY_FLAG (op, FLAG_UNPAID)) |
421 | && /* Loophole bug? -FD- */ !QUERY_FLAG (op, FLAG_UNPAID)) |
424 | { |
|
|
425 | if (op->nrof == 0) /* this is necessary for artifact sacrifices --FD-- */ |
|
|
426 | count++; |
|
|
427 | else |
|
|
428 | count += op->nrof; |
422 | count += op->number_of (); |
429 | } |
|
|
430 | } |
|
|
431 | } |
|
|
432 | |
423 | |
433 | return count; |
424 | return count; |
434 | } |
425 | } |
435 | |
426 | |
436 | /** |
427 | /** |
… | |
… | |
438 | * op is typically the player, which is only |
429 | * op is typically the player, which is only |
439 | * really used to determine what space to look at. |
430 | * really used to determine what space to look at. |
440 | * Modified to only eat 'nrof' of objects. |
431 | * Modified to only eat 'nrof' of objects. |
441 | */ |
432 | */ |
442 | static void |
433 | static void |
443 | eat_item (object *op, const char *item, uint32 nrof) |
434 | eat_item (object *op, shstr_cmp item, uint32 nrof) |
444 | { |
435 | { |
445 | object *prev; |
436 | object *prev; |
446 | |
437 | |
447 | prev = op; |
438 | prev = op; |
448 | op = op->below; |
439 | op = op->below; |
449 | |
440 | |
450 | while (op) |
441 | while (op) |
451 | { |
442 | { |
452 | if (strcmp (op->arch->archname, item) == 0) |
443 | if (op->arch->archname == item) |
453 | { |
444 | { |
454 | if (op->nrof >= nrof) |
445 | if (op->nrof >= nrof) |
455 | { |
446 | { |
456 | op->decrease (nrof); |
447 | op->decrease (nrof); |
457 | return; |
448 | return; |
… | |
… | |
1263 | * Handles applying a sign. |
1254 | * Handles applying a sign. |
1264 | */ |
1255 | */ |
1265 | static void |
1256 | static void |
1266 | apply_sign (object *op, object *sign, int autoapply) |
1257 | apply_sign (object *op, object *sign, int autoapply) |
1267 | { |
1258 | { |
|
|
1259 | if (!op->is_player()) |
|
|
1260 | return; |
|
|
1261 | |
1268 | if (sign->has_dialogue ()) |
1262 | if (sign->has_dialogue ()) |
1269 | { |
1263 | { |
1270 | op->statusmsg (format ("Maybe you should I<talk> to the %s instead?", &sign->name)); |
1264 | op->statusmsg (format ("Maybe you should I<talk> to the %s instead?", &sign->name)); |
1271 | return; |
1265 | return; |
1272 | } |
1266 | } |
… | |
… | |
1532 | if (victim->type == PLAYER && EXIT_PATH (trap)) |
1526 | if (victim->type == PLAYER && EXIT_PATH (trap)) |
1533 | { |
1527 | { |
1534 | /* Basically, don't show exits leading to random maps the |
1528 | /* Basically, don't show exits leading to random maps the |
1535 | * players output. |
1529 | * players output. |
1536 | */ |
1530 | */ |
1537 | if (trap->msg && strncmp (EXIT_PATH (trap), "/!", 2)) |
1531 | if (trap->msg && !EXIT_PATH (trap).starts_with ("/!")) |
1538 | victim->statusmsg (trap->msg, NDI_NAVY); |
1532 | victim->statusmsg (trap->msg, NDI_NAVY); |
1539 | |
1533 | |
1540 | trap->play_sound (trap->sound); |
1534 | trap->play_sound (trap->sound); |
1541 | victim->enter_exit (trap); |
1535 | victim->enter_exit (trap); |
1542 | } |
1536 | } |
… | |
… | |
2413 | if (!EXIT_PATH (tmp) || !is_legal_2ways_exit (op, tmp)) |
2407 | if (!EXIT_PATH (tmp) || !is_legal_2ways_exit (op, tmp)) |
2414 | op->failmsg (format ("The %s is closed.", query_name (tmp))); |
2408 | op->failmsg (format ("The %s is closed.", query_name (tmp))); |
2415 | else |
2409 | else |
2416 | { |
2410 | { |
2417 | /* Don't display messages for random maps. */ |
2411 | /* Don't display messages for random maps. */ |
2418 | if (tmp->msg && strncmp (EXIT_PATH (tmp), "/!", 2)) |
2412 | if (tmp->msg && !EXIT_PATH (tmp).starts_with ("/!")) |
2419 | op->statusmsg (tmp->msg, NDI_NAVY); |
2413 | op->statusmsg (tmp->msg, NDI_NAVY); |
2420 | |
2414 | |
2421 | op->enter_exit (tmp); |
2415 | op->enter_exit (tmp); |
2422 | } |
2416 | } |
2423 | |
2417 | |
… | |
… | |
3216 | return 1; |
3210 | return 1; |
3217 | } |
3211 | } |
3218 | |
3212 | |
3219 | //TODO: this obviously fails for players using a shorter prefix |
3213 | //TODO: this obviously fails for players using a shorter prefix |
3220 | // i.e. "R" can use Ragnarok's sword. |
3214 | // i.e. "R" can use Ragnarok's sword. |
3221 | if (op->level && (strncmp (op->name, who->name, strlen (who->name)))) |
3215 | if (op->level && !op->name.starts_with (who->name)) |
3222 | { |
3216 | { |
3223 | /* if the weapon does not have the name as the character, can't use it. */ |
3217 | /* if the weapon does not have the name as the character, can't use it. */ |
3224 | /* (Ragnarok's sword attempted to be used by Foo: won't work) */ |
3218 | /* (Ragnarok's sword attempted to be used by Foo: won't work) */ |
3225 | who->failmsg ("The weapon does not recognize you as its owner. H<Its name indicates that it belongs to somebody else.>"); |
3219 | who->failmsg ("The weapon does not recognize you as its owner. H<Its name indicates that it belongs to somebody else.>"); |
3226 | |
3220 | |
… | |
… | |
3399 | insert_ob_in_ob (tmp, who); |
3393 | insert_ob_in_ob (tmp, who); |
3400 | |
3394 | |
3401 | return 1; |
3395 | return 1; |
3402 | } |
3396 | } |
3403 | |
3397 | |
3404 | if (op->level && (strncmp (op->name, who->name, strlen (who->name)))) |
3398 | if (op->level && !op->name.starts_with (who->name)) |
3405 | { |
3399 | { |
3406 | who->failmsg ("The weapon does not recognize you as its owner. " |
3400 | who->failmsg ("The weapon does not recognize you as its owner. " |
3407 | "H<Its name indicates that it belongs to somebody else.>"); |
3401 | "H<Its name indicates that it belongs to somebody else.>"); |
3408 | if (tmp) |
3402 | if (tmp) |
3409 | insert_ob_in_ob (tmp, who); |
3403 | insert_ob_in_ob (tmp, who); |
… | |
… | |
3920 | } |
3914 | } |
3921 | |
3915 | |
3922 | /* insert the randomitems from the change's treasurelist into |
3916 | /* insert the randomitems from the change's treasurelist into |
3923 | * the player ref: player.c |
3917 | * the player ref: player.c |
3924 | */ |
3918 | */ |
3925 | if (change->randomitems != NULL) |
3919 | if (change->randomitems) |
3926 | give_initial_items (pl, change->randomitems); |
3920 | give_initial_items (pl, change->randomitems); |
3927 | |
3921 | |
3928 | /* set up the face, for some races. */ |
3922 | /* set up the face, for some races. */ |
3929 | |
3923 | |
3930 | /* first, look for the force object banning |
3924 | /* first, look for the force object banning |
3931 | * changing the face. Certain races never change face with class. |
3925 | * changing the face. Certain races never change face with class. |
3932 | */ |
3926 | */ |
3933 | for (walk = pl->inv; walk != NULL; walk = walk->below) |
3927 | for (walk = pl->inv; walk; walk = walk->below) |
3934 | if (!strcmp (walk->name, "NOCLASSFACECHANGE")) |
3928 | if (walk->name == shstr_NOCLASSFACECHANGE) |
3935 | flag_change_face = 0; |
3929 | flag_change_face = 0; |
3936 | |
3930 | |
3937 | if (flag_change_face) |
3931 | if (flag_change_face) |
3938 | { |
3932 | { |
3939 | pl->face = change->face; |
3933 | pl->face = change->face; |
… | |
… | |
3941 | pl->flag [FLAG_ANIMATE] = change->flag [FLAG_ANIMATE]; |
3935 | pl->flag [FLAG_ANIMATE] = change->flag [FLAG_ANIMATE]; |
3942 | } |
3936 | } |
3943 | |
3937 | |
3944 | /* check the special case of can't use weapons */ |
3938 | /* check the special case of can't use weapons */ |
3945 | /*if(QUERY_FLAG(change,FLAG_USE_WEAPON)) CLEAR_FLAG(pl,FLAG_USE_WEAPON); */ |
3939 | /*if(QUERY_FLAG(change,FLAG_USE_WEAPON)) CLEAR_FLAG(pl,FLAG_USE_WEAPON); */ |
3946 | if (!strcmp (change->name, "monk")) |
3940 | if (change->name == shstr_monk) |
3947 | CLEAR_FLAG (pl, FLAG_USE_WEAPON); |
3941 | CLEAR_FLAG (pl, FLAG_USE_WEAPON); |
3948 | |
3942 | |
3949 | break; |
3943 | break; |
3950 | } |
3944 | } |
3951 | } |
3945 | } |
… | |
… | |
3988 | pl->failmsg (format ("You can't use the %s with your %s!", query_name (transformer), query_name (marked))); |
3982 | pl->failmsg (format ("You can't use the %s with your %s!", query_name (transformer), query_name (marked))); |
3989 | return; |
3983 | return; |
3990 | } |
3984 | } |
3991 | |
3985 | |
3992 | /* check whether they are compatible or not */ |
3986 | /* check whether they are compatible or not */ |
3993 | find = strstr (marked->slaying, transformer->arch->archname); |
3987 | find = strstr (&marked->slaying, transformer->arch->archname); |
3994 | if (!find || (*(find + strlen (transformer->arch->archname)) != ':')) |
3988 | if (!find || (*(find + strlen (transformer->arch->archname)) != ':')) |
3995 | { |
3989 | { |
3996 | pl->failmsg (format ("You can't use the %s with your %s!", query_name (transformer), query_name (marked))); |
3990 | pl->failmsg (format ("You can't use the %s with your %s!", query_name (transformer), query_name (marked))); |
3997 | return; |
3991 | return; |
3998 | } |
3992 | } |