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,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
4 | * Copyright (©) 2005,2006,2007,2008,2009,2010,2011 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (©) 2002 Mark Wedel & Crossfire Development Team |
5 | * Copyright (©) 2002 Mark Wedel & Crossfire Development Team |
6 | * Copyright (©) 1992 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 |
… | |
… | |
22 | * The authors can be reached via e-mail to <support@deliantra.net> |
22 | * The authors can be reached via e-mail to <support@deliantra.net> |
23 | */ |
23 | */ |
24 | |
24 | |
25 | //+GPL |
25 | //+GPL |
26 | |
26 | |
|
|
27 | #include <algorithm> |
|
|
28 | #include <functional> |
|
|
29 | |
27 | #include <global.h> |
30 | #include <global.h> |
28 | #include <sproto.h> |
31 | #include <sproto.h> |
29 | #include <sounds.h> |
32 | #include <sounds.h> |
30 | #include <living.h> |
33 | #include <living.h> |
31 | #include <object.h> |
34 | #include <object.h> |
32 | #include <spells.h> |
35 | #include <spells.h> |
33 | #include <skills.h> |
36 | #include <skills.h> |
34 | |
|
|
35 | #include <algorithm> |
|
|
36 | #include <functional> |
|
|
37 | |
37 | |
38 | playervec players; |
38 | playervec players; |
39 | |
39 | |
40 | /* This loads the first map an puts the player on it. */ |
40 | /* This loads the first map an puts the player on it. */ |
41 | static void |
41 | static void |
… | |
… | |
1870 | } |
1870 | } |
1871 | |
1871 | |
1872 | /* no monster == player tries to move into a wall or so */ |
1872 | /* no monster == player tries to move into a wall or so */ |
1873 | if (!mon) |
1873 | if (!mon) |
1874 | { |
1874 | { |
1875 | if (op->contr->ns->bumpmsg) |
|
|
1876 | for (object *ob = m->at (nx, ny).top; ob; ob = ob->below) |
1875 | for (object *ob = m->at (nx, ny).top; ob; ob = ob->below) |
1877 | if (op->move_type & ob->move_block) |
1876 | if (op->move_type & ob->move_block) |
1878 | { |
1877 | { |
1879 | if (ob->move_block == MOVE_ALL) |
1878 | if (ob->move_block == MOVE_ALL) |
|
|
1879 | move_into_wall (op, ob); |
|
|
1880 | else |
|
|
1881 | { |
|
|
1882 | if (op->contr->ns->bumpmsg) |
1880 | { |
1883 | { |
1881 | op->play_sound (sound_find ("bump_wall")); |
|
|
1882 | |
|
|
1883 | op->statusmsg (ob->invisible |
|
|
1884 | ? "You bump into something." |
|
|
1885 | : format ("You bump into the %s.", query_name (ob)) |
|
|
1886 | ); |
|
|
1887 | } |
|
|
1888 | else |
|
|
1889 | { |
|
|
1890 | op->play_sound (sound_find ("blocked_move")); |
1884 | op->play_sound (sound_find ("blocked_move")); |
1891 | |
1885 | |
1892 | op->statusmsg (ob->invisible |
1886 | op->statusmsg (ob->invisible |
1893 | ? "Something blocks you." |
1887 | ? "Something blocks you." |
1894 | : format ("Something blocks you from entering the %s.", query_name (ob)) |
1888 | : format ("Something blocks you from entering the %s.", query_name (ob)) |
1895 | ); |
1889 | ); |
1896 | } |
1890 | } |
|
|
1891 | } |
1897 | |
1892 | |
1898 | break; |
1893 | break; |
1899 | } |
1894 | } |
1900 | |
1895 | |
1901 | return false; |
1896 | return false; |
1902 | } |
1897 | } |
1903 | |
1898 | |
1904 | mon = mon->head_ (); |
1899 | mon = mon->head_ (); |
… | |
… | |
2022 | } |
2017 | } |
2023 | |
2018 | |
2024 | bool |
2019 | bool |
2025 | move_player (object *op, int dir) |
2020 | move_player (object *op, int dir) |
2026 | { |
2021 | { |
2027 | if (!op->map || op->map->in_memory != MAP_ACTIVE) |
2022 | if (!op->map || op->map->state != MAP_ACTIVE) |
2028 | return 0; |
2023 | return 0; |
2029 | |
2024 | |
2030 | /* Sanity check: make sure dir is valid */ |
2025 | /* Sanity check: make sure dir is valid */ |
2031 | if (dir < 0 || dir > 8) |
2026 | if (dir < 0 || dir > 8) |
2032 | { |
2027 | { |
… | |
… | |
2188 | op->invisible = 1000; |
2183 | op->invisible = 1000; |
2189 | /* the socket code flashes the player visible/invisible |
2184 | /* the socket code flashes the player visible/invisible |
2190 | * depending on the value of invisible, so we need to |
2185 | * depending on the value of invisible, so we need to |
2191 | * alternate it here for it to work correctly. |
2186 | * alternate it here for it to work correctly. |
2192 | */ |
2187 | */ |
2193 | if (pticks & 2) |
2188 | if (server_tick & 2) |
2194 | op->invisible--; |
2189 | op->invisible--; |
2195 | } |
2190 | } |
2196 | else if (op->invisible && !(op->flag [FLAG_MAKE_INVIS])) |
2191 | else if (op->invisible && !(op->flag [FLAG_MAKE_INVIS])) |
2197 | { |
2192 | { |
2198 | if (!op->invisible--) |
2193 | if (!op->invisible--) |
… | |
… | |
2687 | if (will_kill_again) |
2682 | if (will_kill_again) |
2688 | { |
2683 | { |
2689 | object *force; |
2684 | object *force; |
2690 | int at; |
2685 | int at; |
2691 | |
2686 | |
2692 | force = get_archetype (FORCE_NAME); |
2687 | force = archetype::get (FORCE_NAME); |
2693 | /* 50 ticks should be enough time for the spell to abate */ |
2688 | /* 50 ticks should be enough time for the spell to abate */ |
2694 | force->speed_left = -5.f; |
2689 | force->speed_left = -5.f; |
2695 | force->set_speed (0.1f); |
2690 | force->set_speed (0.1f); |
2696 | force->set_flag (FLAG_APPLIED); |
2691 | force->set_flag (FLAG_APPLIED); |
2697 | |
2692 | |