Crossfire Server, Branches 1.12  R18729
deep_swamp.c
Go to the documentation of this file.
1 /*
2  CrossFire, A Multiplayer game for X-windows
3 
4  Copyright (C) 2007 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-devel@real-time.com
22 */
23 
27 #include <global.h>
28 #include <ob_methods.h>
29 #include <ob_types.h>
30 #include <sounds.h>
31 #include <sproto.h>
32 
33 static method_ret deep_swamp_type_process(ob_methods *context, object *op);
34 static method_ret deep_swamp_type_move_on(ob_methods *context, object *trap, object *victim, object *originator);
35 
42 }
43 
50 static method_ret deep_swamp_type_process(ob_methods *context, object *op) {
51  object *above = op->above;
52  object *nabove;
53  int got_player = 0;
54 
55  while (above) {
56  nabove = above->above;
57  if (above->type == PLAYER
58  && !(above->move_type&MOVE_FLYING)
59  && above->stats.hp >= 0
60  && !QUERY_FLAG(above, FLAG_WIZ)) {
61  object *woodsman = find_obj_by_type_subtype(above, SKILL, SK_WOODSMAN);
62  got_player = 1;
63  if (op->stats.food < 1) {
64  LOG(llevDebug, "move_deep_swamp(): player is here, but state is %d\n", op->stats.food);
65  op->stats.food = 1;
66  }
67  if (op->stats.food < 10) {
68  if (rndm(0, 2) == 0) {
70  "You are down to your waist in the wet %s.",
71  "You are down to your waist in the wet %s.",
72  op->name);
73  op->stats.food = woodsman ? op->stats.food+1 : 10;
74  above->speed_left -= op->move_slow_penalty;
75  }
76  } else if (op->stats.food < 20) {
77  if (rndm(0, 2) == 0) {
79  "You are down to your NECK in the dangerous %s.",
80  "You are down to your NECK in the dangerous %s.",
81  op->name);
82  op->stats.food = woodsman ? op->stats.food+1 : 20;
83  snprintf(above->contr->killer, sizeof(above->contr->killer), "drowning in a %s", op->name);
84  above->stats.hp--;
85  above->speed_left -= op->move_slow_penalty;
86  }
87  } else if (rndm(0, 4) == 0) {
88  op->stats.food = 0;
90  "%s disappeared into a %s.", "%s disappeared into a %s.",
91  above->name, op->name);
92  snprintf(above->contr->killer, sizeof(above->contr->killer), "drowning in a %s", op->name);
93  above->stats.hp = -1;
94  kill_player(above); /* player dies in the swamp */
95  }
96  } else if (!QUERY_FLAG(above, FLAG_ALIVE)
97  && !(above->move_type&MOVE_FLYING)
98  && !(QUERY_FLAG(above, FLAG_IS_FLOOR))
99  && !(QUERY_FLAG(above, FLAG_OVERLAY_FLOOR))
100  && !(QUERY_FLAG(above, FLAG_NO_PICK))) {
101  if (rndm(0, 2) == 0)
102  decrease_ob(above);
103  }
104  above = nabove;
105  }
106  if (!got_player)
107  op->stats.food = 1;
108  return METHOD_OK;
109 }
110 
119 static method_ret deep_swamp_type_move_on(ob_methods *context, object *trap, object *victim, object *originator) {
120  if (common_pre_ob_move_on(trap, victim, originator) == METHOD_ERROR)
121  return METHOD_OK;
122  if (victim->type == PLAYER
123  && victim->stats.hp >= 0
124  && !(victim->move_type&MOVE_FLYING)) {
126  "You are down to your knees in the %s.",
127  "You are down to your knees in the %s.", trap->name);
128  trap->stats.food = 1;
129  victim->speed_left -= trap->move_slow_penalty;
130  }
131  common_post_ob_move_on(trap, victim, originator);
132  return METHOD_OK;
133 }
#define FLAG_IS_FLOOR
Definition: define.h:599
MoveType move_type
Definition: object.h:277
void init_type_deep_swamp(void)
Definition: deep_swamp.c:39
object * find_obj_by_type_subtype(const object *who, int type, int subtype)
Definition: object.c:3656
#define NDI_ALL
Definition: newclient.h:220
method_ret common_pre_ob_move_on(object *trap, object *victim, object *originator)
Definition: common_apply.c:51
static method_ret deep_swamp_type_process(ob_methods *context, object *op)
Definition: deep_swamp.c:50
#define METHOD_ERROR
Definition: ob_methods.h:44
#define MSG_TYPE_ADMIN_PLAYER
Definition: newclient.h:414
struct obj * above
Definition: object.h:146
void draw_ext_info_format(int flags, int pri, const object *pl, uint8 type, uint8 subtype, const char *new_format, const char *old_format,...)
Definition: standalone.c:175
#define PLAYER
Definition: define.h:113
sint16 hp
Definition: living.h:81
char method_ret
Definition: ob_methods.h:41
int rndm(int min, int max)
Definition: utils.c:174
#define NDI_RED
Definition: newclient.h:198
#define FLAG_ALIVE
Definition: define.h:526
float speed_left
Definition: object.h:182
#define MSG_TYPE_VICTIM
Definition: newclient.h:336
void register_move_on(int ob_type, move_on_func method)
Definition: ob_types.c:106
#define METHOD_OK
Definition: ob_methods.h:42
#define MOVE_FLYING
Definition: define.h:703
const char * name
Definition: object.h:167
#define DEEP_SWAMP
Definition: define.h:316
#define SK_WOODSMAN
Definition: skills.h:68
#define FLAG_OVERLAY_FLOOR
Definition: define.h:551
struct pl * contr
Definition: object.h:134
#define QUERY_FLAG(xyz, p)
Definition: define.h:514
#define FLAG_WIZ
Definition: define.h:527
#define MSG_TYPE_ADMIN
Definition: newclient.h:324
void common_post_ob_move_on(object *trap, object *victim, object *originator)
Definition: common_apply.c:88
int snprintf(char *dest, int max, const char *format,...)
Definition: porting.c:498
#define decrease_ob(xyz)
Definition: global.h:276
char killer[BIG_NAME]
Definition: player.h:222
living stats
Definition: object.h:219
#define MSG_TYPE_VICTIM_SWAMP
Definition: newclient.h:566
#define SKILL
Definition: define.h:157
static method_ret deep_swamp_type_move_on(ob_methods *context, object *trap, object *victim, object *originator)
Definition: deep_swamp.c:119
void register_process(int ob_type, process_func method)
Definition: ob_types.c:88
#define NDI_UNIQUE
Definition: newclient.h:219
void LOG(LogLevel logLevel, const char *format,...)
Definition: logger.c:63
void kill_player(object *op)
Definition: player.c:3238
float move_slow_penalty
Definition: object.h:283
#define FLAG_NO_PICK
Definition: define.h:535
uint8 type
Definition: object.h:189
sint32 food
Definition: living.h:89