1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  *
21  * Should really be called "moving actors.h"
22  */
23 
24 #ifndef TINSEL_RINCE_H	// prevent multiple includes
25 #define TINSEL_RINCE_H
26 
27 #include "tinsel/anim.h"	// for ANIM
28 #include "tinsel/scene.h"	// for TFTYPE
29 #include "tinsel/tinsel.h"
30 
31 namespace Tinsel {
32 
33 struct OBJECT;
34 
35 enum NPS {NOT_IN, GOING_UP, GOING_DOWN, LEAVING, ENTERING};
36 
37 enum IND {NO_PROB, TRY_CENTER, TRY_CORNER, TRY_NEXTCORNER};
38 
39 enum DIRECTION { LEFTREEL, RIGHTREEL, FORWARD, AWAY };
40 
41 #define NUM_MAINSCALES	(TinselV2 ? 10 : 5)
42 #define NUM_AUXSCALES	5
43 #define TOTAL_SCALES	(NUM_MAINSCALES + NUM_AUXSCALES)
44 #define REQ_MAIN_SCALES		10
45 #define REQ_TOTAL_SCALES	15
46 
47 #define BOGUS_BRIGHTNESS -1
48 
49 struct MOVER {
50 
51 	int		objX, objY;           /* Co-ordinates object  */
52 
53 	int     targetX, targetY;
54 	int     ItargetX, ItargetY;     /* Intermediate destination */
55 	int     UtargetX, UtargetY;     /* Ultimate destination */
56 
57 	HPOLYGON hIpath;
58 	HPOLYGON hUpath;
59 	HPOLYGON hCpath;
60 
61 	bool over;
62 	int	walkNumber;
63 
64 	IND	InDifficulty;
65 
66 	/* For use in 'follow nodes' polygons   */
67 	HPOLYGON hFnpath;
68 	NPS	npstatus;
69 	int     line;
70 
71 	int     Tline;                   // NEW
72 
73 	// TODO: TagReelRunning may be the same as bSpecReel
74 	bool		bSpecReel;
75 
76 	/* Used internally */
77 	DIRECTION	direction;		// Current reel
78 	int			scale;		// Current scale
79 
80 	int			stepCount;		// Step count for walking reel synchronisation
81 
82 	int			walkedFromX, walkedFromY;
83 
84 	bool		bMoving;		// Set this to TRUE during a walk
85 
86 	bool		bNoPath;
87 	bool		bIgPath;
88 	bool		bWalkReel;
89 
90 	OBJECT		*actorObj;	// Actor's object
91 	ANIM		actorAnim;	// Actor's animation script
92 
93 	SCNHANDLE	hLastFilm;	// } Used by AlterMover()
94 	SCNHANDLE	hPushedFilm;	// }
95 
96 	int			actorID;
97 	int			actorToken;
98 
99 	SCNHANDLE	walkReels[REQ_TOTAL_SCALES][4];
100 	SCNHANDLE	standReels[REQ_TOTAL_SCALES][4];
101 	SCNHANDLE	talkReels[REQ_TOTAL_SCALES][4];
102 
103 	bool		bActive;
104 
105 	int			SlowFactor;	// Slow down movement while hidden
106 
107 	bool		bStop;
108 
109 	/* NOTE: If effect polys can overlap, this needs improving */
110 	bool		bInEffect;
111 
112 	Common::PROCESS		*pProc;
113 
114 	// Discworld 2 specific fields
115 	int32		zOverride;
116 	bool		bHidden;
117 	int			brightness;	// Current brightness
118 	int			startColor;
119 	int			paletteLength;
120 	HPOLYGON	hRpath;		// Recent path
121 };
122 typedef MOVER *PMOVER;
123 
124 struct MAINIT {
125 	int	X;
126 	int	Y;
127 	PMOVER	pMover;
128 };
129 typedef MAINIT *PMAINIT;
130 
131 //---------------------------------------------------------------------------
132 
133 
134 void MoverProcessCreate(int X, int Y, int id, PMOVER pMover);
135 
136 
137 enum AR_FUNCTION { AR_NORMAL, AR_PUSHREEL, AR_POPREEL, AR_WALKREEL };
138 
139 void StoreMoverPalette(PMOVER pMover, int startColor, int length);
140 
141 void MoverBrightness(PMOVER pMover, int brightness);
142 
143 MOVER *GetMover(int ano);
144 MOVER *RegisterMover(int ano);
145 void KillMover(PMOVER pMover);
146 MOVER *GetLiveMover(int index);
147 
148 bool getMActorState(MOVER *psActor);
149 int GetMoverId(PMOVER pMover);
150 void SetMoverZ(PMOVER pMover, int y, uint32 zFactor);
151 void SetMoverZoverride(PMOVER pMover, uint32 zFactor);
152 
153 void HideMover(PMOVER pMover, int sf = 0);
154 bool MoverHidden(PMOVER pMover);
155 bool MoverIs(PMOVER pMover);
156 bool MoverIsSWalking(PMOVER pMover);
157 bool MoverMoving(PMOVER pMover);
158 int GetWalkNumber(PMOVER pMover);
159 void UnHideMover(PMOVER pMover);
160 void DropMovers();
161 void PositionMover(PMOVER pMover, int x, int y);
162 
163 void GetMoverPosition(PMOVER pMover, int *aniX, int *aniY);
164 void GetMoverMidTop(PMOVER pMover, int *aniX, int *aniY);
165 int GetMoverLeft(PMOVER pMover);
166 int GetMoverRight(PMOVER pMover);
167 int GetMoverTop(PMOVER pMover);
168 int GetMoverBottom(PMOVER pMover);
169 
170 bool MoverIsInPolygon(PMOVER pMover, HPOLYGON hPoly);
171 void AlterMover(PMOVER pMover, SCNHANDLE film, AR_FUNCTION fn);
172 DIRECTION GetMoverDirection(PMOVER pMover);
173 int GetMoverScale(PMOVER pMover);
174 void SetMoverDirection(PMOVER pMover, DIRECTION dirn);
175 void SetMoverStanding(PMOVER pMover);
176 void SetMoverWalkReel(PMOVER pMover, DIRECTION reel, int scale, bool force);
177 
178 PMOVER InMoverBlock(PMOVER pMover, int x, int y);
179 
180 void RebootMovers();
181 
182 bool IsMAinEffectPoly(int index);
183 void SetMoverInEffect(int index, bool tf);
184 
185 void StopMover(PMOVER pMover);
186 
187 /*----------------------------------------------------------------------*/
188 
189 struct SAVED_MOVER {
190 
191 	int		actorID;
192 	int		objX;
193 	int		objY;
194 	SCNHANDLE hLastfilm;
195 
196 	SCNHANDLE	walkReels[REQ_TOTAL_SCALES][4];
197 	SCNHANDLE	standReels[REQ_TOTAL_SCALES][4];
198 	SCNHANDLE	talkReels[REQ_TOTAL_SCALES][4];
199 
200 	bool	bActive;
201 	bool	bHidden;
202 	int		brightness;
203 	int		startColor;
204 	int		paletteLength;
205 };
206 
207 void SaveMovers(SAVED_MOVER *sMoverInfo);
208 void RestoreAuxScales(SAVED_MOVER *sMoverInfo);
209 
210 PMOVER NextMover(PMOVER pMover);
211 
212 /*----------------------------------------------------------------------*/
213 
214 enum {
215 	MAGICX	= -101,
216 	MAGICY	= -102
217 };
218 
219 /*----------------------------------------------------------------------*/
220 
221 } // End of namespace Tinsel
222 
223 #endif /* TINSEL_RINCE_H */
224