3 * Iter Vehemens ad Necem (IVAN)
4 * Copyright (C) Timo Kiviluoto
5 * Released under the GNU General
8 * See LICENSING which should be included
9 * along with this file for more details
24 typedef action
*(*actionspawner
) (character
*);
27 class actionprototype
{
29 actionprototype (actionspawner
, cchar
*);
30 action
*SpawnAndLoad (inputfile
&) const;
31 cchar
*GetClassID () const { return ClassID
; }
32 int GetIndex () const { return Index
; }
36 actionspawner Spawner
;
43 typedef actionprototype prototype
;
44 action () : Actor(0), Flags(0) {}
46 virtual void Handle () = 0;
47 virtual void Terminate (truth
);
48 character
*GetActor () const { return Actor
; }
49 void SetActor (character
*What
) { Actor
= What
; }
50 virtual truth
IsVoluntary () const { return true; }
51 virtual truth
AllowUnconsciousness () const { return true; }
52 virtual truth
AllowFoodConsumption () const { return true; }
53 virtual truth
TryDisplace () { return true; }
54 virtual void Save (outputfile
&) const;
55 virtual void Load (inputfile
&);
56 virtual truth
IsRest () const { return false; }
57 virtual const prototype
*GetProtoType () const = 0;
58 int GetType () const { return GetProtoType()->GetIndex(); }
59 virtual cchar
*GetDescription () const = 0;
60 truth
InDNDMode () const { return Flags
& IN_DND_MODE
; }
61 void ActivateInDNDMode () { Flags
|= IN_DND_MODE
; }
62 virtual truth
ShowEnvironment () const { return true; }
63 virtual cchar
*GetDeathExplanation () const { return ""; }
64 virtual truth
CanBeTalkedTo () const { return true; }
65 virtual truth
IsUnconsciousness () const { return false; }
73 template <class type
, class base
> class actionsysbase
: public base
{
75 typedef actionsysbase mybase
;
76 static type
*Spawn (character
*Actor
) {
81 virtual const actionprototype
*GetProtoType () const { return &ProtoType
; }
82 static const actionprototype ProtoType
;
86 #ifdef __FILE_OF_STATIC_ACTION_PROTOTYPE_DEFINITIONS__
87 #define ACTION_PROTO(name)\
88 template<> const actionprototype\
89 name##sysbase::ProtoType((actionspawner)(&name##sysbase::Spawn), #name);
91 #define ACTION_PROTO(name)
94 #define ACTION(name, base)\
96 typedef actionsysbase<name, base> name##sysbase;\
98 class name : public name##sysbase