Crossfire Server  1.75.0
dragon_focus.cpp
Go to the documentation of this file.
1 /*
2  CrossFire, A Multiplayer game for X-windows
3 
4  Copyright (C) 2008,2010 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 */
27 #include <global.h>
28 #include <ob_methods.h>
29 #include <ob_types.h>
30 #include <sounds.h>
31 #include <sproto.h>
32 #include <math.h>
33 
34 static method_ret dragon_focus_type_apply(object *focus, object *applier, int aflags);
35 
36 
42 }
43 
52 static method_ret dragon_focus_type_apply(object *focus, object *applier, int aflags) {
53  (void)aflags;
54 
55  object *abil = NULL; /* pointer to dragon ability force*/
56 
57  if (applier->type != PLAYER)
58  return METHOD_ERROR;
59 
60  if (!is_dragon_pl(applier))
61  return METHOD_ERROR;
62 
63  abil = object_find_by_type_and_arch_name(applier, FORCE, "dragon_ability_force");
64 
65  if (abil == NULL)
66  return METHOD_ERROR;
67 
68  abil->stats.exp = focus->stats.exp;
69 
70  if (focus->face) {
71  applier->face = focus->face;
72 
73  /* It only makes sense to change the animation if the
74  * face is also changing.
75  */
76  if (focus->animation)
77  applier->animation = focus->animation;
78  }
79  if (focus->title) {
80  if (applier->title) free_string(applier->title);
81  applier->title = add_refcount(focus->title);
82  }
83  return 0;
84 }
Sound-related defines.
#define METHOD_ERROR
Definition: ob_methods.h:17
void init_type_dragon_focus(void)
Initializer for the food object type.
int is_dragon_pl(const object *op)
Checks if player is a dragon.
Definition: player.cpp:123
sstring add_refcount(sstring str)
Like add_string(), but the string is already a shared string.
Definition: shstr.cpp:224
Global type definitions and header inclusions.
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
Used during character creation.
Definition: object.h:121
void free_string(sstring str)
This will reduce the refcount, and if it has reached 0, str will be freed.
Definition: shstr.cpp:294
object * object_find_by_type_and_arch_name(const object *who, int type, const char *name)
Find object in inventory by type and archetype name.
Definition: object.cpp:4262
const Animations * animation
Animation of this item, NULL if not animated.
Definition: object.h:428
const Face * face
Face with colors.
Definition: object.h:341
living stats
Str, Con, Dex, etc.
Definition: object.h:378
Object type variables.
See Player.
Definition: object.h:112
sstring title
Of foo, etc.
Definition: object.h:325
uint8_t type
PLAYER, BULLET, etc.
Definition: object.h:348
int64_t exp
Experience.
Definition: living.h:47
static method_ret dragon_focus_type_apply(object *focus, object *applier, int aflags)
Handles applying food.
Object type functions and variables.
Definition: object.h:229
void register_apply(int ob_type, apply_func method)
Registers the apply method for the given type.
Definition: ob_types.cpp:62