Crossfire Server, Branches 1.12  R18729
skillscroll.c
Go to the documentation of this file.
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 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 skillscroll_type_apply(ob_methods *context, object *lighter, object *applier, int aflags);
35 
41 }
42 
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);
66  "You already possess the knowledge held within the %s.",
67  "You already possess the knowledge held within the %s.",
68  name);
69  return METHOD_OK;
70 
71  case 1:
73  "You succeed in learning %s",
74  "You succeed in learning %s",
75  scroll->skill);
77  "Type 'bind ready_skill %s to store the skill in a key.",
78  "Type 'bind ready_skill %s to store the skill in a key.",
79  scroll->skill);
80  decrease_ob(scroll);
81  return METHOD_OK;
82 
83  default:
84  query_name(scroll, name, MAX_BUF);
86  "You fail to learn the knowledge of the %s.\n",
87  "You fail to learn the knowledge of the %s.\n",
88  name);
89  decrease_ob(scroll);
90  return METHOD_OK;
91  }
92  }
93  return METHOD_OK;
94 }
#define SKILLSCROLL
Definition: define.h:313
#define MSG_TYPE_APPLY_FAILURE
Definition: newclient.h:519
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
#define METHOD_OK
Definition: ob_methods.h:42
void register_apply(int ob_type, apply_func method)
Definition: ob_types.c:79
static method_ret skillscroll_type_apply(ob_methods *context, object *lighter, object *applier, int aflags)
Definition: skillscroll.c:57
#define MSG_TYPE_APPLY
Definition: newclient.h:330
void init_type_skillscroll(void)
Definition: skillscroll.c:39
#define MAX_BUF
Definition: define.h:81
const char * skill
Definition: object.h:174
int learn_skill(object *pl, object *scroll)
Definition: skill_util.c:690
#define decrease_ob(xyz)
Definition: global.h:276
#define MSG_TYPE_APPLY_SUCCESS
Definition: newclient.h:518
#define MSG_TYPE_APPLY_ERROR
Definition: newclient.h:516
#define NDI_UNIQUE
Definition: newclient.h:219
void query_name(const object *op, char *buf, size_t size)
Definition: item.c:628
uint8 type
Definition: object.h:189