Crossfire Server, Trunk
deep_swamp.cpp
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 
28 #include <global.h>
29 #include <ob_methods.h>
30 #include <ob_types.h>
31 #include <sounds.h>
32 #include <sproto.h>
33 
34 static method_ret deep_swamp_type_process(object *op);
35 static method_ret deep_swamp_type_move_on(object *trap, object *victim, object *originator);
36 
43 }
44 
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 
115 static method_ret deep_swamp_type_move_on(object *trap, object *victim, object *originator) {
116  if (common_pre_ob_move_on(trap, victim, originator) == METHOD_ERROR)
117  return METHOD_OK;
118  if (victim->type == PLAYER
119  && victim->stats.hp >= 0
120  && !(victim->move_type&MOVE_FLYING)) {
122  "You are down to your knees in the %s.", trap->name);
123  trap->stats.food = 1;
124  victim->speed_left -= trap->move_slow_penalty;
125  }
126  common_post_ob_move_on(trap, victim, originator);
127  return METHOD_OK;
128 }
PLAYER
@ PLAYER
Definition: object.h:112
global.h
object_find_by_type_subtype
object * object_find_by_type_subtype(const object *who, int type, int subtype)
Definition: object.cpp:4297
MSG_TYPE_ADMIN_PLAYER
#define MSG_TYPE_ADMIN_PLAYER
Definition: newclient.h:499
LOG
void LOG(LogLevel logLevel, const char *format,...)
Definition: logger.cpp:58
FLAG_OVERLAY_FLOOR
#define FLAG_OVERLAY_FLOOR
Definition: define.h:255
QUERY_FLAG
#define QUERY_FLAG(xyz, p)
Definition: define.h:226
METHOD_OK
#define METHOD_OK
Definition: ob_methods.h:15
object::speed_left
float speed_left
Definition: object.h:338
register_move_on
void register_move_on(int ob_type, move_on_func method)
Definition: ob_types.cpp:89
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,...) PRINTF_ARGS(6
SKILL
@ SKILL
Definition: object.h:148
NDI_RED
#define NDI_RED
Definition: newclient.h:248
rndm
int rndm(int min, int max)
Definition: utils.cpp:162
register_process
void register_process(int ob_type, process_func method)
Definition: ob_types.cpp:71
object::above
object * above
Definition: object.h:296
MSG_TYPE_VICTIM
#define MSG_TYPE_VICTIM
Definition: newclient.h:418
FLAG_NO_PICK
#define FLAG_NO_PICK
Definition: define.h:239
FLAG_ALIVE
#define FLAG_ALIVE
Definition: define.h:230
deep_swamp_type_move_on
static method_ret deep_swamp_type_move_on(object *trap, object *victim, object *originator)
Definition: deep_swamp.cpp:115
object::contr
struct player * contr
Definition: object.h:284
object_decrease_nrof_by_one
#define object_decrease_nrof_by_one(xyz)
Definition: compat.h:32
player::killer
char killer[BIG_NAME]
Definition: player.h:190
deep_swamp_type_process
static method_ret deep_swamp_type_process(object *op)
Definition: deep_swamp.cpp:50
DEEP_SWAMP
@ DEEP_SWAMP
Definition: object.h:241
sword_of_souls.victim
victim
Definition: sword_of_souls.py:12
common_pre_ob_move_on
method_ret common_pre_ob_move_on(object *trap, object *victim, object *originator)
Definition: common_apply.cpp:35
MSG_TYPE_VICTIM_SWAMP
#define MSG_TYPE_VICTIM_SWAMP
Definition: newclient.h:653
object::move_type
MoveType move_type
Definition: object.h:436
MOVE_FLYING
#define MOVE_FLYING
Definition: define.h:395
object::type
uint8_t type
Definition: object.h:348
living::food
int32_t food
Definition: living.h:48
sproto.h
object::move_slow_penalty
float move_slow_penalty
Definition: object.h:442
init_type_deep_swamp
void init_type_deep_swamp(void)
Definition: deep_swamp.cpp:40
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
NDI_UNIQUE
#define NDI_UNIQUE
Definition: newclient.h:265
object::name
sstring name
Definition: object.h:319
give.op
op
Definition: give.py:33
NDI_ALL
#define NDI_ALL
Definition: newclient.h:266
METHOD_ERROR
#define METHOD_ERROR
Definition: ob_methods.h:17
ob_methods.h
object::stats
living stats
Definition: object.h:378
common_post_ob_move_on
void common_post_ob_move_on(object *trap, object *victim, object *originator)
Definition: common_apply.cpp:67
kill_player
void kill_player(object *op, const object *killer)
Definition: player.cpp:3492
MSG_TYPE_ADMIN
#define MSG_TYPE_ADMIN
Definition: newclient.h:405
living::hp
int16_t hp
Definition: living.h:40
llevDebug
@ llevDebug
Definition: logger.h:13
FLAG_IS_FLOOR
#define FLAG_IS_FLOOR
Definition: define.h:302