1 |
/* |
2 |
CrossFire, A Multiplayer game for X-windows |
3 |
|
4 |
Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team |
5 |
Copyright (C) 2005 Mark Wedel & Crossfire Development Team |
6 |
Copyright (C) 1992 Frank Tore Johansen |
7 |
|
8 |
This program is free software; you can redistribute it and/or modify |
9 |
it under the terms of the GNU General Public License as published by |
10 |
the Free Software Foundation; either version 2 of the License, or |
11 |
(at your option) any later version. |
12 |
|
13 |
This program is distributed in the hope that it will be useful, |
14 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 |
GNU General Public License for more details. |
17 |
|
18 |
You should have received a copy of the GNU General Public License |
19 |
along with this program; if not, write to the Free Software |
20 |
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
21 |
|
22 |
The authors can be reached via e-mail at <crossfire@schmorp.de> |
23 |
*/ |
24 |
|
25 |
#include <global.h> |
26 |
#ifndef __CEXTRACT__ |
27 |
# include <sproto.h> |
28 |
#endif |
29 |
|
30 |
/* Note this code is very specialized for swamps, in terms of the messages |
31 |
* as well as handling of move types. |
32 |
*/ |
33 |
|
34 |
void |
35 |
walk_on_deep_swamp (object *op, object *victim) |
36 |
{ |
37 |
if (victim->type == PLAYER && victim->stats.hp >= 0 && !(victim->move_type & MOVE_FLYING)) |
38 |
{ |
39 |
new_draw_info_format (NDI_UNIQUE, 0, victim, "You are down to your knees in the %s.", &op->name); |
40 |
op->stats.food = 1; |
41 |
victim->speed_left -= op->move_slow_penalty; |
42 |
} |
43 |
} |
44 |
|
45 |
void |
46 |
move_deep_swamp (object *op) |
47 |
{ |
48 |
object *above = op->above; |
49 |
object *nabove; |
50 |
|
51 |
while (above) |
52 |
{ |
53 |
nabove = above->above; |
54 |
if (above->type == PLAYER && !(above->move_type & MOVE_FLYING) && above->stats.hp >= 0 && !QUERY_FLAG (above, FLAG_WIZ)) |
55 |
{ |
56 |
if (op->stats.food < 1) |
57 |
{ |
58 |
LOG (llevDebug, "move_deep_swamp(): player is here, but state is " "%d\n", op->stats.food); |
59 |
op->stats.food = 1; |
60 |
} |
61 |
|
62 |
switch (op->stats.food) |
63 |
{ |
64 |
case 1: |
65 |
if (rndm (0, 2) == 0) |
66 |
{ |
67 |
new_draw_info_format (NDI_UNIQUE, 0, above, "You are down to your waist in the wet %s.", &op->name); |
68 |
op->stats.food = 2; |
69 |
above->speed_left -= op->move_slow_penalty; |
70 |
} |
71 |
break; |
72 |
|
73 |
case 2: |
74 |
if (rndm (0, 2) == 0) |
75 |
{ |
76 |
new_draw_info_format (NDI_UNIQUE | NDI_RED, 0, above, "You are down to your NECK in the dangerous %s.", &op->name); |
77 |
op->stats.food = 3; |
78 |
sprintf (above->contr->killer, "drowning in a %s", &op->name); |
79 |
above->stats.hp--; |
80 |
above->speed_left -= op->move_slow_penalty; |
81 |
} |
82 |
break; |
83 |
|
84 |
case 3: |
85 |
if (rndm (0, 4) == 0) |
86 |
{ |
87 |
object *woodsman = find_obj_by_type_subtype (above, SKILL, SK_WOODSMAN); |
88 |
|
89 |
/* player is ready to drown - only woodsman skill can save him */ |
90 |
if (!woodsman) |
91 |
{ |
92 |
op->stats.food = 0; |
93 |
new_draw_info_format (NDI_UNIQUE | NDI_ALL, 1, NULL, "%s disappeared into a %s.", &above->name, &op->name); |
94 |
sprintf (above->contr->killer, "drowning in a %s", &op->name); |
95 |
|
96 |
above->stats.hp = -1; |
97 |
kill_player (above); /* player dies in the swamp */ |
98 |
} |
99 |
else |
100 |
{ |
101 |
op->stats.food = 2; |
102 |
new_draw_info_format (NDI_UNIQUE, 0, above, |
103 |
"You almost drowned in the %s! You survived due to your woodsman skill.", &op->name); |
104 |
} |
105 |
} |
106 |
break; |
107 |
} |
108 |
} |
109 |
else if (!QUERY_FLAG (above, FLAG_ALIVE) && !(above->move_type & MOVE_FLYING) && |
110 |
!(QUERY_FLAG (above, FLAG_IS_FLOOR)) && !(QUERY_FLAG (above, FLAG_OVERLAY_FLOOR)) && !(QUERY_FLAG (above, FLAG_NO_PICK))) |
111 |
{ |
112 |
if (rndm (0, 2) == 0) |
113 |
decrease_ob (above); |
114 |
} |
115 |
above = nabove; |
116 |
} |
117 |
} |