ScummVM API documentation
actionzone.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  */
21 
22 #ifndef NANCY_ACTION_ACTIONZONE_H
23 #define NANCY_ACTION_ACTIONZONE_H
24 
25 #include "common/array.h"
26 #include "common/rect.h"
27 #include "common/str.h"
28 
29 #include "engines/nancy/commontypes.h"
30 
31 namespace Common {
32 class SeekableReadStream;
33 }
34 
35 namespace Nancy {
36 namespace Action {
37 
38 // The zone's subtype, stored in the low byte of its leading int32. It selects both
39 // what the zone does at runtime and how much trailing data follows the shared base.
40 // Subtypes whose meaning has not been worked out yet are named after their value;
41 // those still read (or skip) the right number of bytes.
42 enum ActionZoneType : byte {
43  kZoneSpecialEffect = 0x00, // carries a scene id plus an optional fade
44  kZoneBaseOnly = 0x01, // base fields only, no behavior of its own
45  kZoneTeleport = 0x02, // pipe: swallows the ball and re-emits it elsewhere
46  kZoneTerrain = 0x03, // sand trap / mud puddle: slows whatever is inside
47  kZoneSlope = 0x04, // hill: a velocity kick while crossing the zone
48  kZoneUnknown05 = 0x05, // base fields only
49  kZoneEventFlag = 0x0b, // checkpoint / sewing seam: sets an event flag
50  kZoneSceneChange = 0x0c, // finish line / golf cup: fade + target scene + flag
51  kZoneOverlay = 0x0d, // cosmetic overlay sprite
52  kZoneUnknown0E = 0x0e,
53  kZoneUnknown0F = 0x0f,
54  kZoneUnknown10 = 0x10, // base fields only
55  kZoneDestination = 0x11, // driving: a location entrance the car can park in
56  kZoneUnknown12 = 0x12, // another special-effect variant
57  kZoneUnknown13 = 0x13, // another special-effect variant
58  kZoneBoundary = 0x14, // play-area wall
59  kZoneUnknown15 = 0x15, // special effect + int32; a damage range in Nancy13
60  kZoneBumper = 0x16, // Nancy12: an overlay variant; Nancy13: a pachinko hole
61  kZoneFlatTire = 0x17 // pothole: damages the car driving over it
62 };
63 
64 // A polymorphic "ActionZone" record, embedded as a count-prefixed array inside
65 // every Nancy12 PuzzleBase puzzle (Driving/Minigolf/MirrorLight/BoardGame/Mind/
66 // Chase). Each subtype reads a different amount of trailing data; readData()
67 // consumes exactly the right number of bytes so the surrounding chunk stays in sync.
68 struct ActionZone {
69  ActionZoneType type = kZoneSpecialEffect;
70  int32 typeField = 0; // full leading int32; low byte == type
71 
72  Common::Rect rect;
73  Common::String ovlName; // OVL sprite name ("" / sentinel == none)
74 
75  int32 pointA = 0; // 8 bytes (a point) at base+0x39
76  int32 pointB = 0;
77  int32 valC = 0; // 8 bytes at base+0x41
78  int32 valD = 0;
79  int16 val49 = 0;
80  byte val4b = 0;
81 
82  RandomSoundBlock _sound;
83 
84  // Special Effect (an embedded 21-byte SpecialEffect record, present on the
85  // special-effect subtypes when the effect byte is not the terminator).
86  uint16 specialEffectId = 0;
87  bool hasSpecialEffect = false;
88  byte seType = 0; // 1 = blackout, 2 = cross-dissolve, 3 = through-black
89  uint16 seTotalTime = 0;
90  uint16 seFadeToBlackTime = 0;
91  Common::Rect seRect;
92 
93  // int16 + byte trailer carried by kZoneEventFlag and kZoneSceneChange. For the
94  // former it is an event-flag id + on/off; for the latter a target scene id + a
95  // flag. Left at their defaults for the other subtypes.
96  int16 tailId = 0;
97  byte tailFlag = 0;
98 
99  // kZoneTeleport: the ball entering this zone is held for teleportDelay ms, then
100  // re-emerges at exitRect travelling at exitSpeed along exitAngle (degrees).
101  Common::Rect exitRect;
102  int32 teleportDelay = 0;
103  int16 exitAngle = 0;
104  int16 exitSpeed = 0;
105 
106  // kZoneTerrain: extra deceleration added to the moving object's friction while
107  // it is inside this zone.
108  double terrainDecel = 0.0;
109 
110  // kZoneFlatTire: entering the zone adds a random amount of damage in
111  // [flatTireMin, flatTireMax].
112  int32 flatTireMin = 0;
113  int32 flatTireMax = 0;
114 
115  // kZoneSlope: a velocity kick of slopeForce along slopeAngle (degrees), applied
116  // on entering the zone and removed on leaving.
117  double slopeForce = 0.0;
118  int16 slopeAngle = 0;
119 
120  // kZoneOverlay (and kZoneBumper in Nancy12)
121  Common::String overlayName;
122  Common::Array<Common::Rect> overlaySrcRects;
123  Common::Rect overlayDestRect;
124  int32 overlayLayer = 0; // draw pass: 0 renders under the car, 1 over it
125 
126  // The Nancy13 pinball layout (AR 175) differs from the Nancy12 one: the base carries an
127  // extra int32 before the sound block, and the overlay/unknown-0x15/bumper subtypes have
128  // different trailers. Pass isNancy13 = true to parse it; the default keeps Nancy12.
129  void readData(Common::SeekableReadStream &stream, bool isNancy13 = false);
130 
131 private:
132  void readSpecialEffect(Common::SeekableReadStream &stream);
133  void readOverlayZone(Common::SeekableReadStream &stream, bool isNancy13);
134  void readSubtype(Common::SeekableReadStream &stream, bool isNancy13);
135 };
136 
137 // Reads an int16 count, then that many ActionZones.
138 void readActionZoneArray(Common::SeekableReadStream &stream, Common::Array<ActionZone> &out, bool isNancy13 = false);
139 
140 } // End of namespace Action
141 } // End of namespace Nancy
142 
143 #endif // NANCY_ACTION_ACTIONZONE_H
Definition: str.h:59
Definition: rect.h:536
Definition: stream.h:745
Definition: commontypes.h:300
Definition: algorithm.h:29
Definition: actionzone.h:68
Definition: actionmanager.h:32