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
15 #include "ivancommon.h"
26 typedef action
*(*actionspawner
) (character
*);
29 class actionprototype
{
31 actionprototype (actionspawner
, cchar
*);
32 action
*SpawnAndLoad (inputfile
&) const;
33 cchar
*GetClassID () const { return ClassID
; }
34 int GetIndex () const { return Index
; }
38 actionspawner Spawner
;
45 typedef actionprototype prototype
;
48 action () : Actor(0), Flags(0) {}
51 virtual void Handle () = 0;
52 virtual void Terminate (truth
);
53 character
*GetActor () const { return Actor
; }
54 void SetActor (character
*What
) { Actor
= What
; }
55 virtual truth
IsVoluntary () const { return true; }
56 virtual truth
AllowUnconsciousness () const { return true; }
57 virtual truth
AllowFoodConsumption () const { return true; }
58 virtual truth
TryDisplace () { return true; }
59 virtual void Save (outputfile
&) const;
60 virtual void Load (inputfile
&);
61 virtual truth
IsRest () const { return false; }
62 virtual const prototype
*GetProtoType () const = 0;
63 int GetType () const { return GetProtoType()->GetIndex(); }
64 virtual cchar
*GetDescription () const = 0;
65 truth
InDNDMode () const { return Flags
& IN_DND_MODE
; }
66 void ActivateInDNDMode () { Flags
|= IN_DND_MODE
; }
67 virtual truth
ShowEnvironment () const { return true; }
68 virtual cchar
*GetDeathExplanation () const { return ""; }
69 virtual truth
CanBeTalkedTo () const { return true; }
70 virtual truth
IsUnconsciousness () const { return false; }
78 template <class type
, class base
> class actionsysbase
: public base
{
80 typedef actionsysbase mybase
;
81 static type
*Spawn (character
*Actor
) {
86 virtual const actionprototype
*GetProtoType () const { return &ProtoType
; }
87 static const actionprototype ProtoType
;
91 #ifdef __FILE_OF_STATIC_ACTION_PROTOTYPE_DEFINITIONS__
92 #define ACTION_PROTO(name)\
93 template<> const actionprototype\
94 name##sysbase::ProtoType((actionspawner)(&name##sysbase::Spawn), #name);
96 #define ACTION_PROTO(name)
99 #define ACTION(name, base)\
101 typedef actionsysbase<name, base> name##sysbase;\
103 class name : public name##sysbase