Crossfire Server, Trunk  R20513
Go to the documentation of this file.
1 /*
2  CrossFire, A Multiplayer game for X-windows
4  Copyright (C) 2007 Mark Wedel & Crossfire Development Team
5  Copyright (C) 1992 Frank Tore Johansen
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.
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  GNU General Public License for more details.
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.
21  The authors can be reached via e-mail at
22 */
27 #include <global.h>
28 #include <ob_methods.h>
29 #include <ob_types.h>
30 #include <sounds.h>
31 #include <sproto.h>
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);
42 }
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;
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-> < 1) {
64  LOG(llevDebug, "move_deep_swamp(): player is here, but state is %d\n", op->;
65  op-> = 1;
66  }
67  if (op-> < 10) {
68  if (rndm(0, 2) == 0) {
70  "You are down to your waist in the wet %s.",
71  op->name);
72  op-> = woodsman ? op-> : 10;
73  above->speed_left -= op->move_slow_penalty;
74  }
75  } else if (op-> < 20) {
76  if (rndm(0, 2) == 0) {
78  "You are down to your NECK in the dangerous %s.",
79  op->name);
80  op-> = woodsman ? op-> : 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-> = 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))
97  && !(QUERY_FLAG(above, FLAG_NO_PICK))) {
98  if (rndm(0, 2) == 0)
100  }
101  above = nabove;
102  }
103  if (!got_player)
104  op-> = 1;
105  return METHOD_OK;
106 }
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-> = 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,...)
Sends message to player(s).
Definition: main.c:315
Sound-related defines.
Can&#39;t see what&#39;s underneath this object.
Definition: define.h:303
MoveType move_type
Type of movement this object uses.
Definition: object.h:424
void init_type_deep_swamp(void)
Initializer for the DEEP_SWAMP object type.
Definition: deep_swamp.c:39
Typedefs for ob_methods.
Definition: ob_methods.h:45
#define NDI_ALL
Inform all players of this message.
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)
Processes a Deep Swamp.
Definition: deep_swamp.c:50
Definition: ob_methods.h:17
struct obj * above
Pointer to the object stacked above this one.
Definition: object.h:288
Global type definitions and header inclusions.
int16_t hp
Hit Points.
Definition: living.h:39
Definition: skills.h:40
char method_ret
Define some standard return values for callbacks which don&#39;t need to return any other results...
Definition: ob_methods.h:14
int rndm(int min, int max)
Returns a number between min and max.
Definition: utils.c:161
#define NDI_RED
Definition: newclient.h:224
#define FLAG_ALIVE
Object can fight (or be fought)
Definition: define.h:230
void kill_player(object *op, const object *killer)
Handle a player&#39;s death.
Definition: player.c:3465
Something bad is happening to the player.
Definition: newclient.h:392
float speed_left
How much speed is left to spend this round.
Definition: object.h:329
void register_move_on(int ob_type, move_on_func method)
Registers the move_on method for the given type.
Definition: ob_types.c:89
#define METHOD_OK
Definition: ob_methods.h:15
Player coming/going/death.
Definition: newclient.h:474
#define snprintf
Definition: win32.h:46
Combo of fly_low and fly_high.
Definition: define.h:410
const char * name
The name of the object, obviously...
Definition: object.h:311
Player is sinking in a swamp.
Definition: newclient.h:646
Object is an overlay floor.
Definition: define.h:255
struct pl * contr
Pointer to the player which control this object.
Definition: object.h:276
#define QUERY_FLAG(xyz, p)
Definition: define.h:225
#define FLAG_WIZ
Object has special privilegies.
Definition: define.h:231
Definition: newclient.h:377
Object type variables.
void common_post_ob_move_on(object *trap, object *victim, object *originator)
Definition: common_apply.c:87
See Player.
Definition: object.h:107
object * object_find_by_type_subtype(const object *who, int type, int subtype)
Find object in inventory.
Definition: object.c:4195
char killer[BIG_NAME]
Who killed this player.
Definition: player.h:171
#define object_decrease_nrof_by_one(xyz)
Definition: compat.h:28
Also see SKILL_TOOL (74) below.
Definition: object.h:143
living stats
Str, Con, Dex, etc.
Definition: object.h:368
Only for debugging purposes.
Definition: logger.h:13
uint8_t type
Definition: object.h:338
static method_ret deep_swamp_type_move_on(ob_methods *context, object *trap, object *victim, object *originator)
Move on this Deep Swamp object.
Definition: deep_swamp.c:116
void register_process(int ob_type, process_func method)
Registers the process method for the given type.
Definition: ob_types.c:71
#define NDI_UNIQUE
Print immediately, don&#39;t buffer.
Definition: newclient.h:245
void LOG(LogLevel logLevel, const char *format,...)
Logs a message to stderr, or to file.
Definition: logger.c:51
float move_slow_penalty
How much this slows down the object.
Definition: object.h:430
See Swamp.
Definition: object.h:236
#define FLAG_NO_PICK
Object can&#39;t be picked up.
Definition: define.h:239
Object type functions and variables.
int32_t food
How much food in stomach.
Definition: living.h:47