ScummVM API documentation
movers.h
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 modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (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, see <http://www.gnu.org/licenses/>.
19  *
20  * Should really be called "moving actors.h"
21  */
22 
23 #ifndef TINSEL_MOVERS_H // prevent multiple includes
24 #define TINSEL_MOVERS_H
25 
26 #include "tinsel/anim.h" // for ANIM
27 #include "tinsel/scene.h" // for TFTYPE
28 #include "tinsel/tinsel.h"
29 
30 namespace Tinsel {
31 
32 struct OBJECT;
33 
34 enum NPS {NOT_IN, GOING_UP, GOING_DOWN, LEAVING, ENTERING};
35 
36 enum IND {NO_PROB, TRY_CENTER, TRY_CORNER, TRY_NEXTCORNER};
37 
38 enum DIRECTION { LEFTREEL, RIGHTREEL, FORWARD, AWAY };
39 
40 #define NUM_MAINSCALES ((TinselVersion >= 2) ? 10 : 5)
41 #define NUM_AUXSCALES 5
42 #define TOTAL_SCALES (NUM_MAINSCALES + NUM_AUXSCALES)
43 #define REQ_MAIN_SCALES 10
44 #define REQ_TOTAL_SCALES 15
45 
46 #define BOGUS_BRIGHTNESS -1
47 
48 enum MOVER_TYPE { MOVER_2D, MOVER_3D };
49 
50 struct MOVER {
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; /* Intermediate path */
58  HPOLYGON hUpath; /* Ultimate path */
59  HPOLYGON hCpath; /* Current path */
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  // Noir specific fields
123  MOVER_TYPE type;
124  SCNHANDLE hModelName;
125  SCNHANDLE hTextureName;
126 
127  int posX, posY, posZ;
128  int animSpeed;
129  uint nextIdleAnim;
130 };
131 
132 struct MAINIT {
133  int X;
134  int Y;
135  MOVER *pMover;
136 };
137 
138 //---------------------------------------------------------------------------
139 
140 
141 void MoverProcessCreate(int X, int Y, int id, MOVER *pMover);
142 
143 
144 enum AR_FUNCTION { AR_NORMAL, AR_PUSHREEL, AR_POPREEL, AR_WALKREEL };
145 
146 void StoreMoverPalette(MOVER *pMover, int startColor, int length);
147 
148 void MoverBrightness(MOVER *pMover, int brightness);
149 
150 MOVER *GetMover(int ano);
151 MOVER *RegisterMover(int ano);
152 void KillMover(MOVER *pMover);
153 MOVER *GetLiveMover(int index);
154 
155 bool getMActorState(MOVER *psActor);
156 int GetMoverId(MOVER *pMover);
157 void SetMoverZ(MOVER *pMover, int y, uint32 zFactor);
158 void SetMoverZoverride(MOVER *pMover, uint32 zFactor);
159 
160 void HideMover(MOVER *pMover, int sf = 0);
161 bool MoverHidden(MOVER *pMover);
162 bool MoverIs(MOVER *pMover);
163 bool MoverIsSWalking(MOVER *pMover);
164 bool MoverMoving(MOVER *pMover);
165 int GetWalkNumber(MOVER *pMover);
166 void UnHideMover(MOVER *pMover);
167 void DropMovers();
168 void PositionMover(MOVER *pMover, int x, int y);
169 
170 void GetMoverPosition(MOVER *pMover, int *aniX, int *aniY);
171 void GetMoverMidTop(MOVER *pMover, int *aniX, int *aniY);
172 int GetMoverLeft(MOVER *pMover);
173 int GetMoverRight(MOVER *pMover);
174 int GetMoverTop(MOVER *pMover);
175 int GetMoverBottom(MOVER *pMover);
176 
177 bool MoverIsInPolygon(MOVER *pMover, HPOLYGON hPoly);
178 void AlterMover(MOVER *pMover, SCNHANDLE film, AR_FUNCTION fn);
179 DIRECTION GetMoverDirection(MOVER *pMover);
180 int GetMoverScale(MOVER *pMover);
181 void SetMoverDirection(MOVER *pMover, DIRECTION dirn);
182 void SetMoverStanding(MOVER *pMover);
183 void SetMoverWalkReel(MOVER *pMover, DIRECTION reel, int scale, bool force);
184 
185 MOVER *InMoverBlock(MOVER *pMover, int x, int y);
186 
187 void RebootMovers();
188 
189 bool IsMAinEffectPoly(int index);
190 void SetMoverInEffect(int index, bool tf);
191 
192 void StopMover(MOVER *pMover);
193 
194 /*----------------------------------------------------------------------*/
195 
196 struct SAVED_MOVER {
197 
198  int actorID;
199  int objX;
200  int objY;
201  SCNHANDLE hLastfilm;
202 
203  SCNHANDLE walkReels[REQ_TOTAL_SCALES][4];
204  SCNHANDLE standReels[REQ_TOTAL_SCALES][4];
205  SCNHANDLE talkReels[REQ_TOTAL_SCALES][4];
206 
207  bool bActive;
208  bool bHidden;
209  int brightness;
210  int startColor;
211  int paletteLength;
212 };
213 
214 void SaveMovers(SAVED_MOVER *sMoverInfo);
215 void RestoreAuxScales(SAVED_MOVER *sMoverInfo);
216 
217 MOVER *NextMover(MOVER *pMover);
218 
219 /*----------------------------------------------------------------------*/
220 
221 enum {
222  MAGICX = -101,
223  MAGICY = -102
224 };
225 
226 /*----------------------------------------------------------------------*/
227 
228 } // End of namespace Tinsel
229 
230 #endif /* TINSEL_MOVERS_H */
uint32 SCNHANDLE
Definition: dw.h:31
Definition: movers.h:196
Definition: anim.h:33
Definition: movers.h:132
Definition: movers.h:50
Definition: object.h:74
Definition: coroutines.h:300
Definition: actors.h:36
int HPOLYGON
Definition: dw.h:34