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.
23 #include "GameScript/GameScript.h"
25 #include "defsounds.h"
29 #include "Interface.h"
32 #define ID_REFERENCE 1
34 #define ID_VARIABLES 4
36 #define ID_TRIGGERS 16
38 extern Holder
<SymbolMgr
> triggersTable
;
39 extern Holder
<SymbolMgr
> actionsTable
;
40 extern Holder
<SymbolMgr
> overrideActionsTable
;
41 extern Holder
<SymbolMgr
> objectsTable
;
42 extern TriggerFunction triggers
[MAX_TRIGGERS
];
43 extern ActionFunction actions
[MAX_ACTIONS
];
44 extern short actionflags
[MAX_ACTIONS
];
45 extern short triggerflags
[MAX_TRIGGERS
];
46 extern ObjectFunction objects
[MAX_OBJECTS
];
47 extern IDSFunction idtargets
[MAX_OBJECT_FIELDS
];
48 extern Cache SrcCache
; //cache for string resources (pst)
49 extern Cache BcsCache
; //cache for scripts
50 extern int ObjectIDSCount
;
51 extern int MaxObjectNesting
;
52 extern bool HasAdditionalRect
;
53 extern bool HasTriggerPoint
;
54 extern ieResRef
*ObjectIDSTableNames
;
55 extern int ObjectFieldsCount
;
56 extern int ExtraParametersCount
;
58 extern int *SkillStats
;
59 extern int SkillCount
;
60 extern Gem_Polygon
**polygons
;
62 #define MIC_INVALID -2
67 GEM_EXPORT
int GetReaction(Actor
*target
, Scriptable
*Sender
);
68 int GetHappiness(Scriptable
*Sender
, int reputation
);
69 int GetHPPercent(Scriptable
*Sender
);
70 bool StoreHasItemCore(const ieResRef storename
, const ieResRef itemname
);
71 bool HasItemCore(Inventory
*inventory
, const ieResRef itemname
, ieDword flags
);
72 void ClickCore(Scriptable
*Sender
, Point point
, int type
, int speed
);
73 void TransformItemCore(Actor
*actor
, Action
*parameters
, bool onlyone
);
74 void CreateVisualEffectCore(Actor
*target
, const char *effect
, int iterations
);
75 void CreateVisualEffectCore(Scriptable
*Sender
, const Point
&position
, const char *effect
, int iterations
);
76 void GetPositionFromScriptable(Scriptable
* scr
, Point
&position
, bool trap
);
77 void BeginDialog(Scriptable
* Sender
, Action
* parameters
, int flags
);
78 void ChangeAnimationCore(Actor
*src
, const char *resref
, bool effect
);
79 void PolymorphCopyCore(Actor
*src
, Actor
*tar
, bool base
);
80 void CreateCreatureCore(Scriptable
* Sender
, Action
* parameters
, int flags
);
81 int MoveItemCore(Scriptable
*Sender
, Scriptable
*target
, const char *resref
, int flags
, int setflag
);
82 void MoveToObjectCore(Scriptable
*Sender
, Action
*parameters
, ieDword flags
, bool untilsee
);
83 void CreateItemCore(CREItem
*item
, const char *resref
, int a
, int b
, int c
);
84 void AttackCore(Scriptable
*Sender
, Scriptable
*target
, int flags
);
85 void InitScriptTables();
86 void HandleBitMod(ieDword
&value1
, ieDword value2
, int opcode
);
87 bool ResolveSpellName(ieResRef spellres
, Action
*parameter
);
88 GEM_EXPORT
void ResolveSpellName(ieResRef spellres
, ieDword number
);
89 GEM_EXPORT ieDword
ResolveSpellNumber(const ieResRef spellres
);
90 bool ResolveItemName(ieResRef itemres
, Actor
*act
, ieDword Slot
);
91 void EscapeAreaCore(Scriptable
*Sender
, const Point
&p
, const char *area
, const Point
&enter
, int flags
, int wait
);
92 void GoNear(Scriptable
*Sender
, const Point
&p
);
93 void MoveNearerTo(Scriptable
*Sender
, Scriptable
*target
, int distance
);
94 int MoveNearerTo(Scriptable
*Sender
, const Point
&p
, int distance
, int no_release
);
95 void GoNearAndRetry(Scriptable
*Sender
, Scriptable
*target
, bool destination
, int distance
);
96 void GoNearAndRetry(Scriptable
*Sender
, const Point
&p
, int distance
);
98 #define NO_OPERATION -1
99 #define LESS_OR_EQUALS 0
100 //iwd2 diffmode with gemrb enhancements
103 #define GREATER_THAN 3
104 #define GREATER_OR_EQUALS 4
106 #define BINARY_LESS_OR_EQUALS 6 //(left has only bits in right)
107 #define BINARY_MORE_OR_EQUALS 7 //(left has equal or more bits than right)
108 #define BINARY_INTERSECT 8 //(left and right has at least one common bit)
109 #define BINARY_NOT_INTERSECT 9 //(no common bits)
110 #define BINARY_MORE 10 //left has more bits than right
111 #define BINARY_LESS 11 //left has less bits than right
113 GEM_EXPORT
int GetGroup(Actor
*actor
);
115 void FreeSrc(SrcVector
*poi
, const ieResRef key
);
116 SrcVector
*LoadSrc(const ieResRef resname
);
117 Action
*ParamCopy(Action
*parameters
);
118 Action
*ParamCopyNoOverride(Action
*parameters
);
119 void SetVariable(Scriptable
* Sender
, const char* VarName
, ieDword value
);
120 Point
GetEntryPoint(const char *areaname
, const char *entryname
);
121 //these are used from other plugins
122 GEM_EXPORT
int CanSee(Scriptable
* Sender
, Scriptable
* target
, bool range
, int nodead
);
123 GEM_EXPORT
int SeeCore(Scriptable
* Sender
, Trigger
* parameters
, int justlos
);
124 GEM_EXPORT
int DiffCore(ieDword a
, ieDword b
, int diffmode
);
125 GEM_EXPORT
void DisplayStringCore(Scriptable
* Sender
, int Strref
, int flags
);
126 GEM_EXPORT
void SetVariable(Scriptable
* Sender
, const char* VarName
, const char* Context
, ieDword value
);
127 GEM_EXPORT
void MoveBetweenAreasCore(Actor
* actor
, const char *area
, const Point
&position
, int face
, bool adjust
);
128 GEM_EXPORT ieDword
CheckVariable(Scriptable
* Sender
, const char* VarName
, bool *valid
= NULL
);
129 GEM_EXPORT ieDword
CheckVariable(Scriptable
* Sender
, const char* VarName
, const char* Context
, bool *valid
= NULL
);
130 Action
* GenerateActionCore(const char *src
, const char *str
, unsigned short actionID
);
131 Trigger
*GenerateTriggerCore(const char *src
, const char *str
, int trIndex
, int negate
);
132 unsigned int GetSpellDistance(const ieResRef spellres
, Scriptable
*Sender
);
133 unsigned int GetItemDistance(const ieResRef itemres
, int header
);
134 void SetupWishCore(Scriptable
*Sender
, int column
, int picks
);
135 Gem_Polygon
*GetPolygon2DA(ieDword index
);
137 inline int Bones(ieDword value
)
139 return core
->Roll((value
&0xf000)>>12, (value
&0xff0)>>8, value
&15);