Debian Codegraph @

types/skillscroll/skillscroll.c

raw symbols SCIP
1 /*
2 CrossFire, A Multiplayer game for X-windows
3
4 Copyright (C) 2007 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 [email protected]
22 */
23
24 /**
25 * @file skillscroll.c
26 * Implimentation of skill scrolls.
27 */
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 skillscroll_type_apply(ob_methods *context, object *lighter, object *applier, int aflags);
35
36 /**
37 * Initializer for the SKILLSCROLL object type.
38 */
39 void init_type_skillscroll(void) {
40 register_apply(SKILLSCROLL, skillscroll_type_apply);
41 }
42
43 /**
44 * Applies a skillscroll.
45 *
46 * @param context
47 * method context.
48 * @param scroll
49 * Skillscroll to apply.
50 * @param applier
51 * object attempting to apply the scroll. Should be a player.
52 * @param aflags
53 * special flags (always apply/unapply).
54 * @return
55 * METHOD_OK always.
56 */
57 static method_ret skillscroll_type_apply(ob_methods *context, object *scroll, object *applier, int aflags) {
58 char name[MAX_BUF];
59
60 /* Must be applied by a player. */
61 if (applier->type == PLAYER) {
62 switch ((int)learn_skill(applier, scroll)) {
63 case 0:
64 query_name(scroll, name, MAX_BUF);
65 draw_ext_info_format(NDI_UNIQUE, 0, applier, MSG_TYPE_APPLY, MSG_TYPE_APPLY_ERROR,
66 "You already possess the knowledge held within the %s.",
67 name);
68 return METHOD_OK;
69
70 case 1:
71 draw_ext_info_format(NDI_UNIQUE, 0, applier, MSG_TYPE_APPLY, MSG_TYPE_APPLY_SUCCESS,
72 "You succeed in learning %s",
73 scroll->skill);
74 draw_ext_info_format(NDI_UNIQUE, 0, applier, MSG_TYPE_APPLY, MSG_TYPE_APPLY_SUCCESS,
75 "Type 'bind ready_skill %s to store the skill in a key.",
76 scroll->skill);
77 object_decrease_nrof_by_one(scroll);
78 return METHOD_OK;
79
80 default:
81 query_name(scroll, name, MAX_BUF);
82 draw_ext_info_format(NDI_UNIQUE, 0, applier, MSG_TYPE_APPLY, MSG_TYPE_APPLY_FAILURE,
83 "You fail to learn the knowledge of the %s.\n",
84 name);
85 object_decrease_nrof_by_one(scroll);
86 return METHOD_OK;
87 }
88 }
89 return METHOD_OK;
90 }