Crossfire Server, Trunk  R20805
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 = object_find_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  op->name);
72  op->stats.food = woodsman ? op->stats.food+1 : 10;
73  above->speed_left -= op->move_slow_penalty;
74  }
75  } else if (op->stats.food < 20) {
76  if (rndm(0, 2) == 0) {
78  "You are down to your NECK in the dangerous %s.",
79  op->name);
80  op->stats.food = woodsman ? op->stats.food+1 : 20;
81  snprintf(above->contr->killer, sizeof(above->contr->killer), "drowning in a %s", op->name);
82  above->stats.hp--;
83  above->speed_left -= op->move_slow_penalty;
84  }
85  } else if (rndm(0, 4) == 0) {
86  op->stats.food = 0;
88  "%s disappeared into a %s.", above->name, op->name);
89  snprintf(above->contr->killer, sizeof(above->contr->killer), "drowning in a %s", op->name);
90  above->stats.hp = -1;
91  kill_player(above, op); /* player dies in the swamp */
92  }
93  } else if (!QUERY_FLAG(above, FLAG_ALIVE)
94  && !(above->move_type&MOVE_FLYING)
95  && !(QUERY_FLAG(above, FLAG_IS_FLOOR))
96  && !(QUERY_FLAG(above, FLAG_OVERLAY_FLOOR))
97  && !(QUERY_FLAG(above, FLAG_NO_PICK))) {
98  if (rndm(0, 2) == 0)
100  }
101  above = nabove;
102  }
103  if (!got_player)
104  op->stats.food = 1;
105  return METHOD_OK;
106 }
107 
116 static method_ret deep_swamp_type_move_on(ob_methods *context, object *trap, object *victim, object *originator) {
117  if (common_pre_ob_move_on(trap, victim, originator) == METHOD_ERROR)
118  return METHOD_OK;
119  if (victim->type == PLAYER
120  && victim->stats.hp >= 0
121  && !(victim->move_type&MOVE_FLYING)) {
123  "You are down to your knees in the %s.", trap->name);
124  trap->stats.food = 1;
125  victim->speed_left -= trap->move_slow_penalty;
126  }
127  common_post_ob_move_on(trap, victim, originator);
128  return METHOD_OK;
129 }
void draw_ext_info_format(int flags, int pri, const object *pl, uint8_t type, uint8_t subtype, const char *format,...)
Definition: main.c:315
#define FLAG_IS_FLOOR
Definition: define.h:303
MoveType move_type
Definition: object.h:424
void init_type_deep_swamp(void)
Definition: deep_swamp.c:39
#define NDI_ALL
Definition: newclient.h:246
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:17
struct obj * above
Definition: object.h:288
int16_t hp
Definition: living.h:39
char method_ret
Definition: ob_methods.h:14
int rndm(int min, int max)
Definition: utils.c:162
#define NDI_RED
Definition: newclient.h:224
#define FLAG_ALIVE
Definition: define.h:230
void kill_player(object *op, const object *killer)
Definition: player.c:3469
#define MSG_TYPE_VICTIM
Definition: newclient.h:392
float speed_left
Definition: object.h:329
void register_move_on(int ob_type, move_on_func method)
Definition: ob_types.c:89
#define METHOD_OK
Definition: ob_methods.h:15
#define MSG_TYPE_ADMIN_PLAYER
Definition: newclient.h:474
#define snprintf
Definition: win32.h:46
#define MOVE_FLYING
Definition: define.h:410
const char * name
Definition: object.h:311
#define MSG_TYPE_VICTIM_SWAMP
Definition: newclient.h:646
#define FLAG_OVERLAY_FLOOR
Definition: define.h:255
struct pl * contr
Definition: object.h:276
#define QUERY_FLAG(xyz, p)
Definition: define.h:225
#define FLAG_WIZ
Definition: define.h:231
#define MSG_TYPE_ADMIN
Definition: newclient.h:377
void common_post_ob_move_on(object *trap, object *victim, object *originator)
Definition: common_apply.c:87
Definition: object.h:107
object * object_find_by_type_subtype(const object *who, int type, int subtype)
Definition: object.c:4198
char killer[BIG_NAME]
Definition: player.h:171
#define object_decrease_nrof_by_one(xyz)
Definition: compat.h:28
Definition: object.h:143
living stats
Definition: object.h:368
uint8_t type
Definition: object.h:338
static method_ret deep_swamp_type_move_on(ob_methods *context, object *trap, object *victim, object *originator)
Definition: deep_swamp.c:116
void register_process(int ob_type, process_func method)
Definition: ob_types.c:71
#define NDI_UNIQUE
Definition: newclient.h:245
void LOG(LogLevel logLevel, const char *format,...)
Definition: logger.c:51
float move_slow_penalty
Definition: object.h:430
#define FLAG_NO_PICK
Definition: define.h:239
int32_t food
Definition: living.h:47