Crossfire Server, Trunk
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(object *op);
34 static method_ret deep_swamp_type_move_on(object *trap, object *victim, object *originator);
35 
42 }
43 
50  object *above = op->above;
51  object *nabove;
52  int got_player = 0;
53 
54  while (above) {
55  nabove = above->above;
56  if (above->type == PLAYER
57  && !(above->move_type&MOVE_FLYING)
58  && above->stats.hp >= 0
59  && !QUERY_FLAG(above, FLAG_WIZ)) {
60  object *woodsman = object_find_by_type_subtype(above, SKILL, SK_WOODSMAN);
61  got_player = 1;
62  if (op->stats.food < 1) {
63  LOG(llevDebug, "move_deep_swamp(): player is here, but state is %d\n", op->stats.food);
64  op->stats.food = 1;
65  }
66  if (op->stats.food < 10) {
67  if (rndm(0, 2) == 0) {
69  "You are down to your waist in the wet %s.",
70  op->name);
71  op->stats.food = woodsman ? op->stats.food+1 : 10;
72  above->speed_left -= op->move_slow_penalty;
73  }
74  } else if (op->stats.food < 20) {
75  if (rndm(0, 2) == 0) {
77  "You are down to your NECK in the dangerous %s.",
78  op->name);
79  op->stats.food = woodsman ? op->stats.food+1 : 20;
80  snprintf(above->contr->killer, sizeof(above->contr->killer), "drowning in a %s", op->name);
81  above->stats.hp--;
82  above->speed_left -= op->move_slow_penalty;
83  }
84  } else if (rndm(0, 4) == 0) {
85  op->stats.food = 0;
87  "%s disappeared into a %s.", above->name, op->name);
88  snprintf(above->contr->killer, sizeof(above->contr->killer), "drowning in a %s", op->name);
89  above->stats.hp = -1;
90  kill_player(above, op); /* player dies in the swamp */
91  }
92  } else if (!QUERY_FLAG(above, FLAG_ALIVE)
93  && !(above->move_type&MOVE_FLYING)
94  && !(QUERY_FLAG(above, FLAG_IS_FLOOR))
95  && !(QUERY_FLAG(above, FLAG_OVERLAY_FLOOR))
96  && !(QUERY_FLAG(above, FLAG_NO_PICK))) {
97  if (rndm(0, 2) == 0)
99  }
100  above = nabove;
101  }
102  if (!got_player)
103  op->stats.food = 1;
104  return METHOD_OK;
105 }
106 
114 static method_ret deep_swamp_type_move_on(object *trap, object *victim, object *originator) {
115  if (common_pre_ob_move_on(trap, victim, originator) == METHOD_ERROR)
116  return METHOD_OK;
117  if (victim->type == PLAYER
118  && victim->stats.hp >= 0
119  && !(victim->move_type&MOVE_FLYING)) {
121  "You are down to your knees in the %s.", trap->name);
122  trap->stats.food = 1;
123  victim->speed_left -= trap->move_slow_penalty;
124  }
125  common_post_ob_move_on(trap, victim, originator);
126  return METHOD_OK;
127 }
PLAYER
@ PLAYER
Definition: object.h:107
global.h
MSG_TYPE_ADMIN_PLAYER
#define MSG_TYPE_ADMIN_PLAYER
Definition: newclient.h:496
FLAG_OVERLAY_FLOOR
#define FLAG_OVERLAY_FLOOR
Definition: define.h:255
QUERY_FLAG
#define QUERY_FLAG(xyz, p)
Definition: define.h:226
register_process
void register_process(int ob_type, process_func method)
Definition: ob_types.c:71
METHOD_OK
#define METHOD_OK
Definition: ob_methods.h:15
liv::hp
int16_t hp
Definition: living.h:40
SKILL
@ SKILL
Definition: object.h:143
NDI_RED
#define NDI_RED
Definition: newclient.h:245
MSG_TYPE_VICTIM
#define MSG_TYPE_VICTIM
Definition: newclient.h:415
FLAG_NO_PICK
#define FLAG_NO_PICK
Definition: define.h:239
FLAG_ALIVE
#define FLAG_ALIVE
Definition: define.h:230
object_find_by_type_subtype
object * object_find_by_type_subtype(const object *who, int type, int subtype)
Definition: object.c:4272
object_decrease_nrof_by_one
#define object_decrease_nrof_by_one(xyz)
Definition: compat.h:32
obj::name
sstring name
Definition: object.h:314
DEEP_SWAMP
@ DEEP_SWAMP
Definition: object.h:236
common_pre_ob_move_on
method_ret common_pre_ob_move_on(object *trap, object *victim, object *originator)
Definition: common_apply.c:51
MSG_TYPE_VICTIM_SWAMP
#define MSG_TYPE_VICTIM_SWAMP
Definition: newclient.h:650
obj::speed_left
float speed_left
Definition: object.h:333
MOVE_FLYING
#define MOVE_FLYING
Definition: define.h:395
register_move_on
void register_move_on(int ob_type, move_on_func method)
Definition: ob_types.c:89
rndm
int rndm(int min, int max)
Definition: utils.c:162
sproto.h
liv::food
int32_t food
Definition: living.h:48
obj::move_slow_penalty
float move_slow_penalty
Definition: object.h:435
deep_swamp_type_move_on
static method_ret deep_swamp_type_move_on(object *trap, object *victim, object *originator)
Definition: deep_swamp.c:114
method_ret
char method_ret
Definition: ob_methods.h:14
ob_types.h
sounds.h
FLAG_WIZ
#define FLAG_WIZ
Definition: define.h:231
SK_WOODSMAN
@ SK_WOODSMAN
Definition: skills.h:40
obj::type
uint8_t type
Definition: object.h:343
NDI_UNIQUE
#define NDI_UNIQUE
Definition: newclient.h:262
obj::stats
living stats
Definition: object.h:373
obj::contr
struct pl * contr
Definition: object.h:279
reputation.victim
victim
Definition: reputation.py:14
LOG
void LOG(LogLevel logLevel, const char *format,...)
Definition: logger.c:51
give.op
op
Definition: give.py:33
NDI_ALL
#define NDI_ALL
Definition: newclient.h:263
pl::killer
char killer[BIG_NAME]
Definition: player.h:189
obj::move_type
MoveType move_type
Definition: object.h:429
deep_swamp_type_process
static method_ret deep_swamp_type_process(object *op)
Definition: deep_swamp.c:49
METHOD_ERROR
#define METHOD_ERROR
Definition: ob_methods.h:17
ob_methods.h
obj::above
struct obj * above
Definition: object.h:291
common_post_ob_move_on
void common_post_ob_move_on(object *trap, object *victim, object *originator)
Definition: common_apply.c:86
init_type_deep_swamp
void init_type_deep_swamp(void)
Definition: deep_swamp.c:39
kill_player
void kill_player(object *op, const object *killer)
Definition: player.c:3463
MSG_TYPE_ADMIN
#define MSG_TYPE_ADMIN
Definition: newclient.h:402
draw_ext_info_format
void draw_ext_info_format(int flags, int pri, const object *pl, uint8_t type, uint8_t subtype, const char *format,...)
Definition: main.c:319
llevDebug
@ llevDebug
Definition: logger.h:13
FLAG_IS_FLOOR
#define FLAG_IS_FLOOR
Definition: define.h:302