ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/swamp.C
Revision: 1.5
Committed: Thu Sep 14 22:34:05 2006 UTC (17 years, 9 months ago) by root
Content type: text/plain
Branch: MAIN
Changes since 1.4: +1 -7 lines
Log Message:
indent

File Contents

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