Crossfire Server, Trunk  R20513
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  name);
68  return METHOD_OK;
69 
70  case 1:
72  "You succeed in learning %s",
73  scroll->skill);
75  "Type 'bind ready_skill %s to store the skill in a key.",
76  scroll->skill);
78  return METHOD_OK;
79 
80  default:
81  query_name(scroll, name, MAX_BUF);
83  "You fail to learn the knowledge of the %s.\n",
84  name);
86  return METHOD_OK;
87  }
88  }
89  return METHOD_OK;
90 }
void draw_ext_info_format(int flags, int pri, const object *pl, uint8_t type, uint8_t subtype, const char *format,...)
Sends message to player(s).
Definition: main.c:315
Sound-related defines.
Typedefs for ob_methods.
Definition: ob_methods.h:45
#define MSG_TYPE_APPLY_FAILURE
Apply OK, but no/bad result.
Definition: newclient.h:599
Global type definitions and header inclusions.
#define MSG_TYPE_APPLY
Applying objects.
Definition: newclient.h:384
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
static method_ret skillscroll_type_apply(ob_methods *context, object *lighter, object *applier, int aflags)
Applies a skillscroll.
Definition: skillscroll.c:57
#define METHOD_OK
Definition: ob_methods.h:15
#define MSG_TYPE_APPLY_ERROR
Definition: newclient.h:596
void register_apply(int ob_type, apply_func method)
Registers the apply method for the given type.
Definition: ob_types.c:62
void init_type_skillscroll(void)
Initializer for the SKILLSCROLL object type.
Definition: skillscroll.c:39
#define MAX_BUF
Used for all kinds of things.
Definition: define.h:35
can add a skill to player&#39;s inventory -bt.
Definition: object.h:234
const char * skill
Name of the skill this object uses/grants.
Definition: object.h:321
Object type variables.
int learn_skill(object *pl, object *scroll)
Player is trying to learn a skill.
Definition: skill_util.c:750
See Player.
Definition: object.h:107
#define object_decrease_nrof_by_one(xyz)
Definition: compat.h:28
uint8_t type
PLAYER, BULLET, etc.
Definition: object.h:338
#define MSG_TYPE_APPLY_SUCCESS
Was able to apply object.
Definition: newclient.h:598
#define NDI_UNIQUE
Print immediately, don&#39;t buffer.
Definition: newclient.h:245
void query_name(const object *op, char *buf, size_t size)
Describes an item.
Definition: item.c:625
Object type functions and variables.