Crossfire Server, Trunk
skillscroll.cpp
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
(
object
*lighter,
object
*applier,
int
aflags);
35
39
void
init_type_skillscroll
(
void
) {
40
register_apply
(
SKILLSCROLL
,
skillscroll_type_apply
);
41
}
42
55
static
method_ret
skillscroll_type_apply
(
object
*scroll,
object
*applier,
int
aflags) {
56
char
name
[
MAX_BUF
];
57
(
void
)aflags;
58
59
/* Must be applied by a player. */
60
if
(applier->
type
==
PLAYER
) {
61
switch
((
int
)
learn_skill
(applier, scroll)) {
62
case
0:
63
query_name
(scroll,
name
,
MAX_BUF
);
64
draw_ext_info_format
(
NDI_UNIQUE
, 0, applier,
MSG_TYPE_APPLY
,
MSG_TYPE_APPLY_ERROR
,
65
"You already possess the knowledge held within the %s."
,
66
name
);
67
return
METHOD_OK
;
68
69
case
1:
70
draw_ext_info_format
(
NDI_UNIQUE
, 0, applier,
MSG_TYPE_APPLY
,
MSG_TYPE_APPLY_SUCCESS
,
71
"You succeed in learning %s"
,
72
scroll->
skill
);
73
draw_ext_info_format
(
NDI_UNIQUE
, 0, applier,
MSG_TYPE_APPLY
,
MSG_TYPE_APPLY_SUCCESS
,
74
"Type 'bind ready_skill %s to store the skill in a key."
,
75
scroll->
skill
);
76
object_decrease_nrof_by_one
(scroll);
77
return
METHOD_OK
;
78
79
default
:
80
query_name
(scroll,
name
,
MAX_BUF
);
81
draw_ext_info_format
(
NDI_UNIQUE
, 0, applier,
MSG_TYPE_APPLY
,
MSG_TYPE_APPLY_FAILURE
,
82
"You fail to learn the knowledge of the %s.\n"
,
83
name
);
84
object_decrease_nrof_by_one
(scroll);
85
return
METHOD_OK
;
86
}
87
}
88
return
METHOD_OK
;
89
}
PLAYER
@ PLAYER
Definition:
object.h:112
global.h
skillscroll_type_apply
static method_ret skillscroll_type_apply(object *lighter, object *applier, int aflags)
Definition:
skillscroll.cpp:55
register_apply
void register_apply(int ob_type, apply_func method)
Definition:
ob_types.cpp:62
METHOD_OK
#define METHOD_OK
Definition:
ob_methods.h:15
draw_ext_info_format
void draw_ext_info_format(int flags, int pri, const object *pl, uint8_t type, uint8_t subtype, const char *format,...) PRINTF_ARGS(6
learn_skill
int learn_skill(object *pl, object *scroll)
Definition:
skill_util.cpp:759
object_decrease_nrof_by_one
#define object_decrease_nrof_by_one(xyz)
Definition:
compat.h:32
MSG_TYPE_APPLY_SUCCESS
#define MSG_TYPE_APPLY_SUCCESS
Definition:
newclient.h:606
query_name
void query_name(const object *op, char *buf, size_t size)
Definition:
item.cpp:588
object::type
uint8_t type
Definition:
object.h:348
SKILLSCROLL
@ SKILLSCROLL
Definition:
object.h:239
sproto.h
nlohmann::detail::void
j template void())
Definition:
json.hpp:4099
MAX_BUF
#define MAX_BUF
Definition:
define.h:35
method_ret
char method_ret
Definition:
ob_methods.h:14
ob_types.h
sounds.h
NDI_UNIQUE
#define NDI_UNIQUE
Definition:
newclient.h:265
object::skill
sstring skill
Definition:
object.h:329
MSG_TYPE_APPLY_FAILURE
#define MSG_TYPE_APPLY_FAILURE
Definition:
newclient.h:607
init_type_skillscroll
void init_type_skillscroll(void)
Definition:
skillscroll.cpp:39
ob_methods.h
MSG_TYPE_APPLY
#define MSG_TYPE_APPLY
Definition:
newclient.h:411
MSG_TYPE_APPLY_ERROR
#define MSG_TYPE_APPLY_ERROR
Definition:
newclient.h:604
give.name
name
Definition:
give.py:27
crossfire-crossfire-server
types
skillscroll
skillscroll.cpp
Generated by
1.8.17