Crossfire Server, Trunk
dragon_focus.c
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 */
26 #include <global.h>
27 #include <ob_methods.h>
28 #include <ob_types.h>
29 #include <sounds.h>
30 #include <sproto.h>
31 #include <math.h>
32 
33 static method_ret dragon_focus_type_apply(object *focus, object *applier, int aflags);
34 
35 
41 }
42 
51 static method_ret dragon_focus_type_apply(object *focus, object *applier, int aflags) {
52  (void)aflags;
53 
54  object *abil = NULL; /* pointer to dragon ability force*/
55 
56  if (applier->type != PLAYER)
57  return METHOD_ERROR;
58 
59  if (!is_dragon_pl(applier))
60  return METHOD_ERROR;
61 
62  abil = object_find_by_type_and_arch_name(applier, FORCE, "dragon_ability_force");
63 
64  if (abil == NULL)
65  return METHOD_ERROR;
66 
67  abil->stats.exp = focus->stats.exp;
68 
69  if (focus->face) {
70  applier->face = focus->face;
71 
72  /* It only makes sense to change the animation if the
73  * face is also changing.
74  */
75  if (focus->animation)
76  applier->animation = focus->animation;
77  }
78  if (focus->title) {
79  if (applier->title) free_string(applier->title);
80  applier->title = add_refcount(focus->title);
81  }
82  return 0;
83 }
PLAYER
@ PLAYER
Definition: object.h:107
global.h
add_refcount
sstring add_refcount(sstring str)
Definition: shstr.c:210
obj::face
const Face * face
Definition: object.h:336
object_find_by_type_and_arch_name
object * object_find_by_type_and_arch_name(const object *who, int type, const char *name)
Definition: object.c:4248
init_type_dragon_focus
void init_type_dragon_focus(void)
Definition: dragon_focus.c:39
free_string
void free_string(sstring str)
Definition: shstr.c:280
liv::exp
int64_t exp
Definition: living.h:47
DRAGON_FOCUS
@ DRAGON_FOCUS
Definition: object.h:116
sproto.h
is_dragon_pl
int is_dragon_pl(const object *op)
Definition: player.c:122
obj::animation
const Animations * animation
Definition: object.h:421
nlohmann::detail::void
j template void())
Definition: json.hpp:4099
obj::title
sstring title
Definition: object.h:320
register_apply
void register_apply(int ob_type, apply_func method)
Definition: ob_types.c:62
method_ret
char method_ret
Definition: ob_methods.h:14
ob_types.h
sounds.h
obj::type
uint8_t type
Definition: object.h:343
obj::stats
living stats
Definition: object.h:373
METHOD_ERROR
#define METHOD_ERROR
Definition: ob_methods.h:17
ob_methods.h
dragon_focus_type_apply
static method_ret dragon_focus_type_apply(object *focus, object *applier, int aflags)
Definition: dragon_focus.c:51
FORCE
@ FORCE
Definition: object.h:224