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,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (©) 2001,2007 Mark Wedel & Crossfire Development Team |
5 | * Copyright (©) 2001 Mark Wedel & Crossfire Development Team |
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
6 | * Copyright (©) 1992 Frank Tore Johansen |
7 | * |
7 | * |
8 | * Deliantra is free software: you can redistribute it and/or modify it under |
8 | * Deliantra is free software: you can redistribute it and/or modify it under |
9 | * the terms of the Affero GNU General Public License as published by the |
9 | * the terms of the Affero GNU General Public License as published by the |
10 | * Free Software Foundation, either version 3 of the License, or (at your |
10 | * Free Software Foundation, either version 3 of the License, or (at your |
11 | * option) any later version. |
11 | * option) any later version. |
… | |
… | |
172 | */ |
172 | */ |
173 | int |
173 | int |
174 | apply_potion (object *op, object *tmp) |
174 | apply_potion (object *op, object *tmp) |
175 | { |
175 | { |
176 | int got_one = 0, i; |
176 | int got_one = 0, i; |
177 | object *force = 0, *floor = 0; |
177 | object *force = 0; |
178 | |
178 | |
179 | floor = GET_MAP_OB (op->map, op->x, op->y); |
179 | object *floor = GET_MAP_OB (op->map, op->x, op->y); |
180 | |
180 | |
181 | if (get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_SAFE) |
181 | if (get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_SAFE) |
182 | { |
182 | { |
183 | op->failmsg ("Gods prevent you from using this here, it's sacred ground!"); |
183 | op->failmsg ("Gods prevent you from using this here, it's sacred ground!"); |
184 | |
184 | |
… | |
… | |
1488 | if (victim->type == PLAYER && EXIT_PATH (trap)) |
1488 | if (victim->type == PLAYER && EXIT_PATH (trap)) |
1489 | { |
1489 | { |
1490 | /* Basically, don't show exits leading to random maps the |
1490 | /* Basically, don't show exits leading to random maps the |
1491 | * players output. |
1491 | * players output. |
1492 | */ |
1492 | */ |
1493 | if (trap->msg && !EXIT_PATH (trap).starts_with ("/!")) |
1493 | if (trap->msg && EXIT_PATH (trap) != shstr_random_map_exit) |
1494 | victim->statusmsg (trap->msg, NDI_NAVY); |
1494 | victim->statusmsg (trap->msg, NDI_NAVY); |
1495 | |
1495 | |
1496 | trap->play_sound (trap->sound); |
1496 | trap->play_sound (trap->sound); |
1497 | victim->enter_exit (trap); |
1497 | victim->enter_exit (trap); |
1498 | } |
1498 | } |
… | |
… | |
1576 | : lev_diff < 15 ? "This book is way beyond your comprehension." |
1576 | : lev_diff < 15 ? "This book is way beyond your comprehension." |
1577 | : "This book is totally beyond your comprehension."); |
1577 | : "This book is totally beyond your comprehension."); |
1578 | return; |
1578 | return; |
1579 | } |
1579 | } |
1580 | |
1580 | |
|
|
1581 | // we currently don't use the message types for anything. |
1581 | readable_message_type *msgType = get_readable_message_type (tmp); |
1582 | // readable_message_type *msgType = get_readable_message_type (tmp); |
|
|
1583 | |
|
|
1584 | tmp->play_sound (tmp->sound ? tmp->sound : sound_find ("apply_book")); |
1582 | |
1585 | |
1583 | if (player *pl = op->contr) |
1586 | if (player *pl = op->contr) |
1584 | if (client *ns = pl->ns) |
1587 | if (client *ns = pl->ns) |
1585 | pl->infobox (MSG_CHANNEL ("book"), format ("T<%s>\n\n%s", (char *)long_desc (tmp, op), &tmp->msg)); |
1588 | pl->infobox (MSG_CHANNEL ("book"), format ("T<%s>\n\n%s", (char *)long_desc (tmp, op), &tmp->msg)); |
1586 | |
1589 | |
… | |
… | |
2269 | op->stats.food -= op->stats.food / 4; |
2272 | op->stats.food -= op->stats.food / 4; |
2270 | poison->destroy (); |
2273 | poison->destroy (); |
2271 | } |
2274 | } |
2272 | |
2275 | |
2273 | /** |
2276 | /** |
2274 | * This function return true if the exit is not a 2 ways one or it is 2 ways, valid exit. |
|
|
2275 | * A valid 2 way exit means: |
|
|
2276 | * -You can come back (there is another exit at the other side) |
|
|
2277 | * -You are |
|
|
2278 | * ° the owner of the exit |
|
|
2279 | * ° or in the same party as the owner |
|
|
2280 | * |
|
|
2281 | * Note: a owner in a 2 way exit is saved as the owner's name |
|
|
2282 | * in the field exit->name cause the field exit->owner doesn't |
|
|
2283 | * survive in the swapping (in fact the whole exit doesn't survive). |
|
|
2284 | */ |
|
|
2285 | static int |
|
|
2286 | is_legal_2ways_exit (object *op, object *exit) |
|
|
2287 | { |
|
|
2288 | if (exit->stats.exp != 1) |
|
|
2289 | return 1; /*This is not a 2 way, so it is legal */ |
|
|
2290 | |
|
|
2291 | #if 0 //TODO |
|
|
2292 | if (!has_been_loaded (EXIT_PATH (exit)) && exit->race) |
|
|
2293 | return 0; /* This is a reset town portal */ |
|
|
2294 | #endif |
|
|
2295 | |
|
|
2296 | LOG (llevError | logBacktrace, "sync map load due to %s\n", exit->debug_desc ()); |
|
|
2297 | |
|
|
2298 | maptile *exitmap = maptile::find_sync (EXIT_PATH (exit), exit->map); |
|
|
2299 | |
|
|
2300 | if (exitmap) |
|
|
2301 | { |
|
|
2302 | exitmap->load_sync (); |
|
|
2303 | |
|
|
2304 | object *tmp = exitmap->at (EXIT_X (exit), EXIT_Y (exit)).bot; |
|
|
2305 | |
|
|
2306 | if (!tmp) |
|
|
2307 | return 0; |
|
|
2308 | |
|
|
2309 | for (; tmp; tmp = tmp->above) |
|
|
2310 | { |
|
|
2311 | if (tmp->type != EXIT) |
|
|
2312 | continue; /*Not an exit */ |
|
|
2313 | |
|
|
2314 | if (!EXIT_PATH (tmp)) |
|
|
2315 | continue; /*Not a valid exit */ |
|
|
2316 | |
|
|
2317 | if ((EXIT_X (tmp) != exit->x) || (EXIT_Y (tmp) != exit->y)) |
|
|
2318 | continue; /*Not in the same place */ |
|
|
2319 | |
|
|
2320 | if (exit->map->path != EXIT_PATH (tmp)) |
|
|
2321 | continue; /*Not in the same map */ |
|
|
2322 | |
|
|
2323 | /* From here we have found the exit is valid. However we do |
|
|
2324 | * here the check of the exit owner. It is important for the |
|
|
2325 | * town portals to prevent strangers from visiting your appartments |
|
|
2326 | */ |
|
|
2327 | if (!exit->race) |
|
|
2328 | return 1; /*No owner, free for all! */ |
|
|
2329 | |
|
|
2330 | object *exit_owner = 0; |
|
|
2331 | |
|
|
2332 | for_all_players (pp) |
|
|
2333 | { |
|
|
2334 | if (!pp->ob) |
|
|
2335 | continue; |
|
|
2336 | |
|
|
2337 | if (pp->ob->name != exit->race) |
|
|
2338 | continue; |
|
|
2339 | |
|
|
2340 | exit_owner = pp->ob; /*We found a player which correspond to the player name */ |
|
|
2341 | break; |
|
|
2342 | } |
|
|
2343 | |
|
|
2344 | if (!exit_owner) |
|
|
2345 | return 0; /* No more owner */ |
|
|
2346 | |
|
|
2347 | if (exit_owner->contr == op->contr) |
|
|
2348 | return 1; /*It is your exit */ |
|
|
2349 | |
|
|
2350 | if (exit_owner && /*There is a owner */ |
|
|
2351 | (op->contr) && /*A player tries to pass */ |
|
|
2352 | ((exit_owner->contr->party == NULL) || /*No pass if controller has no party */ |
|
|
2353 | (exit_owner->contr->party != op->contr->party))) /* Or not the same as op */ |
|
|
2354 | return 0; |
|
|
2355 | |
|
|
2356 | return 1; |
|
|
2357 | } |
|
|
2358 | } |
|
|
2359 | |
|
|
2360 | return 0; |
|
|
2361 | } |
|
|
2362 | |
|
|
2363 | /** |
|
|
2364 | * This function will try to apply a lighter and in case no lighter |
2277 | * This function will try to apply a lighter and in case no lighter |
2365 | * is specified it will try to find a lighter in the players inventory, |
2278 | * is specified it will try to find a lighter in the players inventory, |
2366 | * and inform him about this requirement. |
2279 | * and inform him about this requirement. |
2367 | * |
2280 | * |
2368 | * who - the player |
2281 | * who - the player |
… | |
… | |
2673 | while (*find == ' ') |
2586 | while (*find == ' ') |
2674 | find++; |
2587 | find++; |
2675 | |
2588 | |
2676 | memset (got, 0, MAX_BUF); |
2589 | memset (got, 0, MAX_BUF); |
2677 | |
2590 | |
2678 | if ((separator = strchr (find, ';'))) |
2591 | if ((separator = (char *) strchr (find, ';'))) |
2679 | len = separator - find; |
2592 | len = separator - find; |
2680 | else |
2593 | else |
2681 | len = strlen (find); |
2594 | len = strlen (find); |
2682 | |
2595 | |
2683 | min_it (len, MAX_BUF - 1); |
2596 | min_it (len, MAX_BUF - 1); |
… | |
… | |
2767 | |
2680 | |
2768 | case EXIT: |
2681 | case EXIT: |
2769 | if (who->type != PLAYER) |
2682 | if (who->type != PLAYER) |
2770 | return 0; |
2683 | return 0; |
2771 | |
2684 | |
2772 | if (!EXIT_PATH (op) || !is_legal_2ways_exit (who, op)) |
2685 | if (!EXIT_PATH (op)) |
2773 | who->failmsg (format ("The %s is closed. H<And will stay closed, until somebody fires up the map editor and adds it.>", query_name (op))); |
2686 | who->failmsg (format ("The %s is closed. H<And will stay closed, until somebody fires up the map editor and adds it.>", query_name (op))); |
2774 | else |
2687 | else |
2775 | { |
2688 | { |
2776 | /* Don't display messages for random maps. */ |
2689 | /* Don't display messages for random maps. */ |
2777 | if (op->msg && !EXIT_PATH (op).starts_with ("/!")) |
2690 | if (op->msg && EXIT_PATH (op) != shstr_random_map_exit) |
2778 | who->statusmsg (op->msg, NDI_NAVY); |
2691 | who->statusmsg (op->msg, NDI_NAVY); |
2779 | |
2692 | |
2780 | who->enter_exit (op); |
2693 | who->enter_exit (op); |
2781 | } |
2694 | } |
2782 | |
2695 | |
… | |
… | |
3599 | case SKILL: |
3512 | case SKILL: |
3600 | if (player *pl = who->contr) |
3513 | if (player *pl = who->contr) |
3601 | { |
3514 | { |
3602 | if (IS_COMBAT_SKILL (op->subtype)) |
3515 | if (IS_COMBAT_SKILL (op->subtype)) |
3603 | { |
3516 | { |
3604 | if (skill_flags [op->subtype] & SF_NEED_WEAPON) |
3517 | if (skill_flags [op->subtype] & SF_NEED_ITEM) |
3605 | { |
3518 | { |
3606 | for (object *item = who->inv; item; item = item->below) |
3519 | for (object *item = who->inv; item; item = item->below) |
3607 | if (item->type == WEAPON && item->flag [FLAG_APPLIED]) |
3520 | if (item->type == op->weapontype && item->flag [FLAG_APPLIED]) |
3608 | { |
3521 | { |
3609 | if (item->skill == op->skill) |
3522 | if (item->skill == op->skill) |
3610 | { |
3523 | { |
3611 | who->change_weapon (pl->combat_ob = item); |
3524 | who->change_weapon (pl->combat_ob = item); |
3612 | goto found_weapon; |
3525 | goto found_weapon; |
… | |
… | |
3625 | else |
3538 | else |
3626 | who->change_weapon (pl->combat_ob = op); |
3539 | who->change_weapon (pl->combat_ob = op); |
3627 | } |
3540 | } |
3628 | else if (IS_RANGED_SKILL (op->subtype)) |
3541 | else if (IS_RANGED_SKILL (op->subtype)) |
3629 | { |
3542 | { |
3630 | if (skill_flags [op->subtype] & SF_NEED_BOW) |
3543 | if (skill_flags [op->subtype] & SF_NEED_ITEM) |
3631 | { |
3544 | { |
3632 | for (object *item = who->inv; item; item = item->below) |
3545 | for (object *item = who->inv; item; item = item->below) |
3633 | if (item->type == BOW && item->flag [FLAG_APPLIED]) |
3546 | if (item->type == op->weapontype && item->flag [FLAG_APPLIED]) |
3634 | { |
3547 | { |
3635 | //TODO: bows should/must all have skill missile weapon right now |
3548 | //TODO: bows should/must all have skill missile weapon right now |
3636 | who->change_weapon (pl->ranged_ob = item); |
3549 | who->change_weapon (pl->ranged_ob = item); |
3637 | goto found_bow; |
3550 | goto found_bow; |
3638 | } |
3551 | } |