Crossfire Server, Branches 1.12  R18729
altar.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 altar_type_move_on(ob_methods *context, object *trap, object *victim, object *originator);
34 
38 void init_type_altar(void) {
40 }
41 
50 static method_ret altar_type_move_on(ob_methods *context, object *trap, object *victim, object *originator) {
51  if (trap->head)
52  trap = trap->head;
53 
54  if (common_pre_ob_move_on(trap, victim, originator) == METHOD_ERROR)
55  return METHOD_OK;
56 
57  /* sacrifice victim on trap */
58  /* Only players can make sacrifices on spell casting altars. */
59  if (trap->inv && (!originator || originator->type != PLAYER)) {
60  common_post_ob_move_on(trap, victim, originator);
61  return METHOD_OK;
62  }
63  if (operate_altar(trap, &victim)) {
64  /* Simple check. Unfortunately, it means you can't cast magic bullet
65  * with an altar. We call it a Potion - altars are stationary - it
66  * is up to map designers to use them properly.
67  */
68  if (trap->inv && trap->inv->type == SPELL) {
70  "The altar casts %s.", "The altar casts %s.", trap->inv->name);
71  cast_spell(originator, trap, 0, trap->inv, NULL);
72  } else {
73  trap->value = 1; /* works only once */
74  push_button(trap);
75  }
76  }
77  common_post_ob_move_on(trap, victim, originator);
78  return METHOD_OK;
79 }
void init_type_altar(void)
Definition: altar.c:38
void push_button(object *op)
Definition: button.c:165
method_ret common_pre_ob_move_on(object *trap, object *victim, object *originator)
Definition: common_apply.c:51
#define METHOD_ERROR
Definition: ob_methods.h:44
#define NDI_BLACK
Definition: newclient.h:195
void draw_ext_info_format(int flags, int pri, const object *pl, uint8 type, uint8 subtype, const char *new_format, const char *old_format,...)
Definition: standalone.c:175
#define PLAYER
Definition: define.h:113
char method_ret
Definition: ob_methods.h:41
static method_ret altar_type_move_on(ob_methods *context, object *trap, object *victim, object *originator)
Definition: altar.c:50
void register_move_on(int ob_type, move_on_func method)
Definition: ob_types.c:106
#define METHOD_OK
Definition: ob_methods.h:42
const char * name
Definition: object.h:167
#define SPELL
Definition: define.h:283
int operate_altar(object *altar, object **sacrifice)
Definition: button.c:470
#define MSG_TYPE_APPLY
Definition: newclient.h:330
void common_post_ob_move_on(object *trap, object *victim, object *originator)
Definition: common_apply.c:88
#define MSG_TYPE_APPLY_SUCCESS
Definition: newclient.h:518
#define ALTAR
Definition: define.h:130
struct obj * inv
Definition: object.h:148
struct obj * head
Definition: object.h:154
sint32 value
Definition: object.h:201
int cast_spell(object *op, object *caster, int dir, object *spell_ob, char *stringarg)
Definition: spell_util.c:1308
uint8 type
Definition: object.h:189