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.
22 #include "Interface.h"
23 #include "GameScript.h"
26 #include "defsounds.h"
28 #define ID_REFERENCE 1
30 #define ID_VARIABLES 4
32 #define ID_TRIGGERS 16
34 extern int initialized
;
35 extern bool charactersubtitles
;
36 extern SymbolMgr
* triggersTable
;
37 extern SymbolMgr
* actionsTable
;
38 extern SymbolMgr
* objectsTable
;
39 extern TriggerFunction triggers
[MAX_TRIGGERS
];
40 extern ActionFunction actions
[MAX_ACTIONS
];
41 extern short actionflags
[MAX_ACTIONS
];
42 extern short triggerflags
[MAX_TRIGGERS
];
43 extern ObjectFunction objects
[MAX_OBJECTS
];
44 extern IDSFunction idtargets
[MAX_OBJECT_FIELDS
];
45 extern Cache SrcCache
; //cache for string resources (pst)
46 extern Cache BcsCache
; //cache for scripts
47 extern int ObjectIDSCount
;
48 extern int MaxObjectNesting
;
49 extern bool HasAdditionalRect
;
50 extern bool HasTriggerPoint
;
51 extern ieResRef
*ObjectIDSTableNames
;
52 extern int ObjectFieldsCount
;
53 extern int ExtraParametersCount
;
55 extern int *SkillStats
;
56 extern int SkillCount
;
58 #define MIC_INVALID -2
63 int GetReaction(Scriptable
*Sender
);
64 int GetHappiness(Scriptable
*Sender
, int reputation
);
65 int GetHPPercent(Scriptable
*Sender
);
66 bool StoreHasItemCore(const ieResRef storename
, const ieResRef itemname
);
67 bool HasItemCore(Inventory
*inventory
, const ieResRef itemname
, ieDword flags
);
68 void ClickCore(Scriptable
*Sender
, Point point
, int type
, int speed
);
69 void TransformItemCore(Actor
*actor
, Action
*parameters
, bool onlyone
);
70 void CreateVisualEffectCore(Actor
*target
, const char *effect
, int iterations
);
71 void CreateVisualEffectCore(Scriptable
*Sender
, Point
&position
, const char *effect
, int iterations
);
72 void GetPositionFromScriptable(Scriptable
* scr
, Point
&position
, bool trap
);
73 void BeginDialog(Scriptable
* Sender
, Action
* parameters
, int flags
);
74 void ChangeAnimationCore(Actor
*src
, const char *resref
, bool effect
);
75 void PolymorphCopyCore(Actor
*src
, Actor
*tar
, bool base
);
76 void CreateCreatureCore(Scriptable
* Sender
, Action
* parameters
, int flags
);
77 Targets
* GetAllObjects(Map
*map
, Scriptable
* Sender
, Object
* oC
, int ga_flags
);
78 Targets
* GetAllActors(Scriptable
* Sender
, int ga_flags
);
79 Scriptable
* GetActorFromObject(Scriptable
* Sender
, Object
* oC
, int ga_flags
= 0);
80 Scriptable
* GetStoredActorFromObject(Scriptable
* Sender
, Object
* oC
, int ga_flags
= 0);
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 ieDword
ResolveSpellNumber(const ieResRef spellres
);
90 bool ResolveItemName(ieResRef itemres
, Actor
*act
, ieDword Slot
);
91 void EscapeAreaCore(Scriptable
*Sender
, Point
&p
, const char *area
, Point
&enter
, int flags
, int wait
);
92 void GoNear(Scriptable
*Sender
, Point
&p
);
93 void MoveNearerTo(Scriptable
*Sender
, Scriptable
*target
, int distance
);
94 int MoveNearerTo(Scriptable
*Sender
, Point
&p
, int distance
, int no_release
);
95 void GoNearAndRetry(Scriptable
*Sender
, Scriptable
*target
, bool destination
, int distance
);
96 void GoNearAndRetry(Scriptable
*Sender
, 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
);
114 Targets
*GetMyTarget(Scriptable
*Sender
, Actor
*actor
, Targets
*parameters
, int ga_flags
);
115 Targets
*XthNearestOf(Targets
*parameters
, int count
, int ga_flags
);
116 Targets
*XthNearestDoor(Targets
*parameters
, unsigned int count
);
117 Targets
*XthNearestEnemyOf(Targets
*parameters
, int count
, int ga_flags
);
118 Targets
*ClosestEnemySummoned(Scriptable
*origin
, Targets
*parameters
, int ga_flags
);
119 Targets
*XthNearestEnemyOfType(Scriptable
*origin
, Targets
*parameters
, unsigned int count
, int ga_flags
);
120 Targets
*XthNearestMyGroupOfType(Scriptable
*origin
, Targets
*parameters
, unsigned int count
, int ga_flags
);
122 void FreeSrc(SrcVector
*poi
, const ieResRef key
);
123 SrcVector
*LoadSrc(const ieResRef resname
);
124 Action
*ParamCopy(Action
*parameters
);
125 Action
*ParamCopyNoOverride(Action
*parameters
);
126 /* returns true if actor matches the object specs. */
127 bool MatchActor(Scriptable
*Sender
, ieDword ID
, Object
* oC
);
128 /* returns the number of actors matching the IDS targeting */
129 int GetObjectCount(Scriptable
* Sender
, Object
* oC
);
130 int GetObjectLevelCount(Scriptable
* Sender
, Object
* oC
);
131 void SetVariable(Scriptable
* Sender
, const char* VarName
, ieDword value
);
132 Point
GetEntryPoint(const char *areaname
, const char *entryname
);
133 //these are used from other plugins
134 GEM_EXPORT
int CanSee(Scriptable
* Sender
, Scriptable
* target
, bool range
, int nodead
);
135 GEM_EXPORT
int SeeCore(Scriptable
* Sender
, Trigger
* parameters
, int justlos
);
136 GEM_EXPORT
int DiffCore(ieDword a
, ieDword b
, int diffmode
);
137 GEM_EXPORT
void DisplayStringCore(Scriptable
* Sender
, int Strref
, int flags
);
138 GEM_EXPORT
void SetVariable(Scriptable
* Sender
, const char* VarName
, const char* Context
, ieDword value
);
139 GEM_EXPORT
void MoveBetweenAreasCore(Actor
* actor
, const char *area
, Point
&position
, int face
, bool adjust
);
140 GEM_EXPORT ieDword
CheckVariable(Scriptable
* Sender
, const char* VarName
, bool *valid
= NULL
);
141 GEM_EXPORT ieDword
CheckVariable(Scriptable
* Sender
, const char* VarName
, const char* Context
, bool *valid
= NULL
);
142 Action
* GenerateActionCore(const char *src
, const char *str
, int acIndex
);
143 Trigger
*GenerateTriggerCore(const char *src
, const char *str
, int trIndex
, int negate
);
144 unsigned int GetSpellDistance(ieResRef spellres
, Actor
*actor
);
145 unsigned int GetItemDistance(ieResRef itemres
, int header
);
146 void SetupWishCore(Scriptable
*Sender
, int column
, int picks
);
148 inline int Bones(ieDword value
)
150 return core
->Roll((value
&0xf000)>>12, (value
&0xff0)>>8, value
&15);