Crossfire Server, Trunk  1.75.0
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 
50 static method_ret deep_swamp_type_process(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)
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)
Find object in inventory.
Definition: object.cpp:4301
MSG_TYPE_ADMIN_PLAYER
#define MSG_TYPE_ADMIN_PLAYER
Player coming/going/death.
Definition: newclient.h:499
LOG
void LOG(LogLevel logLevel, const char *format,...)
Logs a message to stderr, or to file.
Definition: logger.cpp:58
FLAG_OVERLAY_FLOOR
#define FLAG_OVERLAY_FLOOR
Object is an 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
How much speed is left to spend this round.
Definition: object.h:338
register_move_on
void register_move_on(int ob_type, move_on_func method)
Registers the move_on method for the given type.
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
Also see SKILL_TOOL (74) below.
Definition: object.h:148
NDI_RED
#define NDI_RED
Definition: newclient.h:248
rndm
int rndm(int min, int max)
Returns a number between min and max.
Definition: utils.cpp:162
register_process
void register_process(int ob_type, process_func method)
Registers the process method for the given type.
Definition: ob_types.cpp:71
object::above
object * above
Pointer to the object stacked above this one.
Definition: object.h:296
MSG_TYPE_VICTIM
#define MSG_TYPE_VICTIM
Something bad is happening to the player.
Definition: newclient.h:418
FLAG_NO_PICK
#define FLAG_NO_PICK
Object can't be picked up.
Definition: define.h:239
FLAG_IS_FLOOR
#define FLAG_IS_FLOOR
Can't see what's underneath this object.
Definition: define.h:302
FLAG_ALIVE
#define FLAG_ALIVE
Object can fight (or be fought)
Definition: define.h:230
deep_swamp_type_move_on
static method_ret deep_swamp_type_move_on(object *trap, object *victim, object *originator)
Move on this Deep Swamp object.
Definition: deep_swamp.cpp:115
object_decrease_nrof_by_one
#define object_decrease_nrof_by_one(xyz)
Definition: compat.h:32
deep_swamp_type_process
static method_ret deep_swamp_type_process(object *op)
Processes a Deep Swamp.
Definition: deep_swamp.cpp:50
DEEP_SWAMP
@ DEEP_SWAMP
Definition: object.h:241
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
Player is sinking in a swamp.
Definition: newclient.h:653
object::move_type
MoveType move_type
Type of movement this object uses.
Definition: object.h:436
MOVE_FLYING
#define MOVE_FLYING
Combo of fly_low and fly_high.
Definition: define.h:395
object::type
uint8_t type
PLAYER, BULLET, etc.
Definition: object.h:348
living::food
int32_t food
How much food in stomach.
Definition: living.h:48
sproto.h
object::move_slow_penalty
float move_slow_penalty
How much this slows down the object.
Definition: object.h:442
init_type_deep_swamp
void init_type_deep_swamp(void)
Initializer for the DEEP_SWAMP object type.
Definition: deep_swamp.cpp:40
method_ret
char method_ret
Define some standard return values for callbacks which don't need to return any other results.
Definition: ob_methods.h:14
ob_types.h
above
Magical Runes Runes are magical inscriptions on the dungeon which cast a spell or detonate when something steps on them Flying objects don t detonate runes Beware ! Runes are invisible most of the time They are only visible occasionally ! There are several runes which are there are some special runes which may only be called with the invoke and people may apply it to read it Maybe useful for mazes ! This rune will not nor is it ordinarily invisible Partial Visibility of they ll be visible only part of the time They have so the higher your the better hidden the runes you make are Examples of whichever way you re facing invoke magic rune transfer as above
Definition: runes-guide.txt:50
sounds.h
FLAG_WIZ
#define FLAG_WIZ
Object has special privilegies.
Definition: define.h:231
SK_WOODSMAN
@ SK_WOODSMAN
Woodsman.
Definition: skills.h:40
NDI_UNIQUE
#define NDI_UNIQUE
Print immediately, don't buffer.
Definition: newclient.h:265
object::name
sstring name
The name of the object, obviously...
Definition: object.h:319
NDI_ALL
#define NDI_ALL
Inform all players of this message.
Definition: newclient.h:266
METHOD_ERROR
#define METHOD_ERROR
Definition: ob_methods.h:17
ob_methods.h
object::stats
living stats
Str, Con, Dex, etc.
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)
Handle a player's death.
Definition: player.cpp:3509
MSG_TYPE_ADMIN
#define MSG_TYPE_ADMIN
Definition: newclient.h:405
living::hp
int16_t hp
Hit Points.
Definition: living.h:40
llevDebug
@ llevDebug
Only for debugging purposes.
Definition: logger.h:13