Move EventMgr to GUI.
[gemrb.git] / gemrb / core / GSUtils.h
blob5cab3a2383379e51a280910163a7eb5293d9840f
1 /* GemRB - Infinity Engine Emulator
2 * Copyright (C) 2003 The GemRB Project
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 #ifndef GSUTILS_H
21 #define GSUTILS_H
22 #include "defsounds.h"
23 #include "exports.h"
24 #include "strrefs.h"
26 #include "GameScript.h"
27 #include "Interface.h"
28 //indebug flags
29 #define ID_REFERENCE 1
30 #define ID_CUTSCENE 2
31 #define ID_VARIABLES 4
32 #define ID_ACTIONS 8
33 #define ID_TRIGGERS 16
35 extern Holder<SymbolMgr> triggersTable;
36 extern Holder<SymbolMgr> actionsTable;
37 extern Holder<SymbolMgr> objectsTable;
38 extern TriggerFunction triggers[MAX_TRIGGERS];
39 extern ActionFunction actions[MAX_ACTIONS];
40 extern short actionflags[MAX_ACTIONS];
41 extern short triggerflags[MAX_TRIGGERS];
42 extern ObjectFunction objects[MAX_OBJECTS];
43 extern IDSFunction idtargets[MAX_OBJECT_FIELDS];
44 extern Cache SrcCache; //cache for string resources (pst)
45 extern Cache BcsCache; //cache for scripts
46 extern int ObjectIDSCount;
47 extern int MaxObjectNesting;
48 extern bool HasAdditionalRect;
49 extern bool HasTriggerPoint;
50 extern ieResRef *ObjectIDSTableNames;
51 extern int ObjectFieldsCount;
52 extern int ExtraParametersCount;
53 extern int InDebug;
54 extern int *SkillStats;
55 extern int SkillCount;
57 #define MIC_INVALID -2
58 #define MIC_FULL -1
59 #define MIC_NOITEM 0
60 #define MIC_GOTITEM 1
62 GEM_EXPORT int GetReaction(Actor *target, Scriptable *Sender);
63 int GetHappiness(Scriptable *Sender, int reputation);
64 int GetHPPercent(Scriptable *Sender);
65 bool StoreHasItemCore(const ieResRef storename, const ieResRef itemname);
66 bool HasItemCore(Inventory *inventory, const ieResRef itemname, ieDword flags);
67 void ClickCore(Scriptable *Sender, Point point, int type, int speed);
68 void TransformItemCore(Actor *actor, Action *parameters, bool onlyone);
69 void CreateVisualEffectCore(Actor *target, const char *effect, int iterations);
70 void CreateVisualEffectCore(Scriptable *Sender, const Point &position, const char *effect, int iterations);
71 void GetPositionFromScriptable(Scriptable* scr, Point &position, bool trap);
72 void BeginDialog(Scriptable* Sender, Action* parameters, int flags);
73 void ChangeAnimationCore(Actor *src, const char *resref, bool effect);
74 void PolymorphCopyCore(Actor *src, Actor *tar, bool base);
75 void CreateCreatureCore(Scriptable* Sender, Action* parameters, int flags);
76 Targets* GetAllObjects(Map *map, Scriptable* Sender, Object* oC, int ga_flags);
77 Targets* GetAllActors(Scriptable* Sender, int ga_flags);
78 Scriptable* GetActorFromObject(Scriptable* Sender, Object* oC, int ga_flags = 0);
79 Scriptable* GetStoredActorFromObject(Scriptable* Sender, Object* oC, int ga_flags = 0);
80 int MoveItemCore(Scriptable *Sender, Scriptable *target, const char *resref, int flags, int setflag);
81 void MoveToObjectCore(Scriptable *Sender, Action *parameters, ieDword flags, bool untilsee);
82 void CreateItemCore(CREItem *item, const char *resref, int a, int b, int c);
83 void AttackCore(Scriptable *Sender, Scriptable *target, int flags);
84 void InitScriptTables();
85 void HandleBitMod(ieDword &value1, ieDword value2, int opcode);
86 bool ResolveSpellName(ieResRef spellres, Action *parameter);
87 GEM_EXPORT void ResolveSpellName(ieResRef spellres, ieDword number);
88 ieDword ResolveSpellNumber(const ieResRef spellres);
89 bool ResolveItemName(ieResRef itemres, Actor *act, ieDword Slot);
90 void EscapeAreaCore(Scriptable *Sender, const Point &p, const char *area, const Point &enter, int flags, int wait);
91 void GoNear(Scriptable *Sender, const Point &p);
92 void MoveNearerTo(Scriptable *Sender, Scriptable *target, int distance);
93 int MoveNearerTo(Scriptable *Sender, const Point &p, int distance, int no_release);
94 void GoNearAndRetry(Scriptable *Sender, Scriptable *target, bool destination, int distance);
95 void GoNearAndRetry(Scriptable *Sender, const Point &p, int distance);
97 #define NO_OPERATION -1
98 #define LESS_OR_EQUALS 0
99 //iwd2 diffmode with gemrb enhancements
100 #define EQUALS 1
101 #define LESS_THAN 2
102 #define GREATER_THAN 3
103 #define GREATER_OR_EQUALS 4
104 #define NOT_EQUALS 5
105 #define BINARY_LESS_OR_EQUALS 6 //(left has only bits in right)
106 #define BINARY_MORE_OR_EQUALS 7 //(left has equal or more bits than right)
107 #define BINARY_INTERSECT 8 //(left and right has at least one common bit)
108 #define BINARY_NOT_INTERSECT 9 //(no common bits)
109 #define BINARY_MORE 10 //left has more bits than right
110 #define BINARY_LESS 11 //left has less bits than right
112 GEM_EXPORT int GetGroup(Actor *actor);
113 Targets *GetMyTarget(Scriptable *Sender, Actor *actor, Targets *parameters, int ga_flags);
114 Targets *XthNearestOf(Targets *parameters, int count, int ga_flags);
115 Targets *XthNearestDoor(Targets *parameters, unsigned int count);
116 Targets *XthNearestEnemyOf(Targets *parameters, int count, int ga_flags);
117 Targets *ClosestEnemySummoned(Scriptable *origin, Targets *parameters, int ga_flags);
118 Targets *XthNearestEnemyOfType(Scriptable *origin, Targets *parameters, unsigned int count, int ga_flags);
119 Targets *XthNearestMyGroupOfType(Scriptable *origin, Targets *parameters, unsigned int count, int ga_flags);
121 void FreeSrc(SrcVector *poi, const ieResRef key);
122 SrcVector *LoadSrc(const ieResRef resname);
123 Action *ParamCopy(Action *parameters);
124 Action *ParamCopyNoOverride(Action *parameters);
125 /* returns true if actor matches the object specs. */
126 bool MatchActor(Scriptable *Sender, ieDword ID, Object* oC);
127 /* returns the number of actors matching the IDS targeting */
128 int GetObjectCount(Scriptable* Sender, Object* oC);
129 int GetObjectLevelCount(Scriptable* Sender, Object* oC);
130 void SetVariable(Scriptable* Sender, const char* VarName, ieDword value);
131 Point GetEntryPoint(const char *areaname, const char *entryname);
132 //these are used from other plugins
133 GEM_EXPORT int CanSee(Scriptable* Sender, Scriptable* target, bool range, int nodead);
134 GEM_EXPORT int SeeCore(Scriptable* Sender, Trigger* parameters, int justlos);
135 GEM_EXPORT int DiffCore(ieDword a, ieDword b, int diffmode);
136 GEM_EXPORT void DisplayStringCore(Scriptable* Sender, int Strref, int flags);
137 GEM_EXPORT void SetVariable(Scriptable* Sender, const char* VarName, const char* Context, ieDword value);
138 GEM_EXPORT void MoveBetweenAreasCore(Actor* actor, const char *area, const Point &position, int face, bool adjust);
139 GEM_EXPORT ieDword CheckVariable(Scriptable* Sender, const char* VarName, bool *valid = NULL);
140 GEM_EXPORT ieDword CheckVariable(Scriptable* Sender, const char* VarName, const char* Context, bool *valid = NULL);
141 Action* GenerateActionCore(const char *src, const char *str, int acIndex);
142 Trigger *GenerateTriggerCore(const char *src, const char *str, int trIndex, int negate);
143 unsigned int GetSpellDistance(ieResRef spellres, Actor *actor);
144 unsigned int GetItemDistance(ieResRef itemres, int header);
145 void SetupWishCore(Scriptable *Sender, int column, int picks);
147 inline int Bones(ieDword value)
149 return core->Roll((value&0xf000)>>12, (value&0xff0)>>8, value&15);
152 #endif