ScummVM API documentation
object_structs.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  * Additional copyright for this file:
8  * Copyright (C) 1999-2000 Revolution Software Ltd.
9  * This code is based on source code created by Revolution Software,
10  * used with permission.
11  *
12  * This program is free software: you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation, either version 3 of the License, or
15  * (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program. If not, see <http://www.gnu.org/licenses/>.
24  *
25  */
26 
27 #ifndef ICB_OBSTRUCTS
28 #define ICB_OBSTRUCTS
29 
30 #include "engines/icb/common/px_common.h"
31 #include "engines/icb/common/px_game_object.h"
32 #include "engines/icb/common/px_route_barriers.h"
33 #include "engines/icb/common/px_array.h"
34 #include "engines/icb/common/px_string.h"
35 #include "engines/icb/animation_mega_set.h"
36 #include "engines/icb/p4_generic.h"
37 #include "engines/icb/string_vest.h"
38 #include "engines/icb/route_manager.h"
39 #include "engines/icb/breath.h"
40 #include "engines/icb/gfx/rlp_api.h"
41 #include "engines/icb/common/px_bones.h"
42 
43 // depth of script logic tree for game objects - 3 is same as Broken Sword games
44 #define TREE_SIZE 3
45 
46 namespace ICB {
47 
48 // high level walk or run mode for mega/player
49 // used by high level routing and interaction functionality
50 enum __motion { __MOTION_WALK, __MOTION_RUN };
51 
52 // high level armed state
53 // this will be used to construct the animation path name
54 enum __weapon {
55  __NOT_ARMED,
56  __GUN,
57  __CROUCH_NOT_ARMED,
58  __CROUCH_GUN,
59  __TOTAL_WEAPONS, // used for searches
60  __NOT_SET // default - will cause error in fn-set-voxel-path
61 };
62 
63 // Added this enum for object type field.
64 enum __object_type { __NO_TYPE_SET = 0, __BUTTON_OPERATED_DOOR, __RECHARGE_POINT, __ORGANIC_MEGA, __NON_ORGANIC_MEGA, __REMORA_CARRIER, __RECHARGE_POINT_WITH_EMP, __AUTO_DOOR };
65 
66 #define MAX_WEAPON_NAME_LENGTH 16
67 
68 extern char weapon_text[__TOTAL_WEAPONS][MAX_WEAPON_NAME_LENGTH];
69 extern bool8 armed_state_table[__TOTAL_WEAPONS];
70 extern bool8 crouch_state_table[__TOTAL_WEAPONS];
71 
72 #define MAX_CHAR_NAME_LENGTH 32
73 #define MAX_OUTFIT_NAME_LENGTH 16
74 #define MAX_CUSTOM_NAME_LENGTH 16
75 
76 #define IMAGE_PATH_STR_LEN 144
77 #define BASE_PATH_STR_LEN 144
78 #define ANIM_NAME_STR_LEN 144
79 #define PALETTE_STR_LEN ENGINE_STRING_LEN
80 
81 // game objects with voxel images need one of these
82 // assigned at session start when objects are initialised
83 class _vox_image { // this is badly named - frame info or something
84 
85 private:
86  int8 anim_table[__TOTAL_ANIMS];
87 
88 public:
89  void ___init(const char *chr, const char *set, __weapon weapon);
90 
91  // temprarily store these for swapping between voxel and polygons (so we can call ___init() again...
92  // when the voxels go these things can go
93  char palette[PALETTE_STR_LEN];
94  char temp_chr[128];
95  char temp_set[128];
96  __weapon temp_weapon;
97  char alternativeImagePath[128]; // this stores the pcp path for animations (for getting the raj files instead of rai files...
98  char alternativeBasePath[128]; // this is same as base path but is pcp (on voxels) - isn't required for polys and can go when we
99  // ditch
100  // setting functions
101  bool8 Init_custom_animation(const char *anim_name);
102  bool8 Find_anim_type(__mega_set_names *anim, const char *name);
103  bool8 Set_texture(const char *texture_name);
104  bool8 Set_palette(const char *palette_name);
105  bool8 Set_mesh(const char *mesh_name);
106  bool8 Set_override_pose(const char *override_pose_name);
107  bool8 Cancel_override_pose();
108  void Promote_non_generic();
109  int8 IsAnimTable(int32 i);
110  void MakeAnimEntry(int32 i);
111  int Preload_file(const char *file);
112 
113  // those hashs in full
114 
115  uint32 anim_name_hash[__TOTAL_ANIMS];
116  uint32 info_name_hash[__TOTAL_ANIMS];
117 
118  uint32 mesh_hash; // the name of the base mesh
119  uint32 shadow_mesh_hash; // the name of the base shadow mesh
120  uint32 palette_hash; // the name of the palette
121  uint32 texture_hash; // the name of the texture (which includes a default palette)
122  uint32 pose_hash; // the name of the ordinary pose/accessory mesh
123  uint32 override_pose_hash; // the name of the pose/accessory mesh overrides the default setting
124  uint32 custom_pose_hash; // the name of the "custom" pose/accessory mesh
125 
126  // base path
127 
128  char base_path[BASE_PATH_STR_LEN];
129  uint32 base_path_hash; // hash value of the base_path string
130 
131  // init'ed by _vox_image::_vox_image which is created by fn-set-voxel-image-path
132  // path primitives - require to build path+name to non generic custom specifics
133  char image_path[IMAGE_PATH_STR_LEN]; // i.e. karl\, karl_in_coat\, etc. Initially set by objects init script and then by
134  // interaction/logic
135 
136  bool8 has_custom_path_built; // says whether or not the current custom anim path has been built - done for preloader which builds
137  // filename early
138 
139  // bone deformations
140 
141  BoneDeformation neckBone;
142  BoneDeformation jawBone;
143  BoneDeformation lookBone;
144  SVECTOR
145  scriptedLookBoneTarget; // this is the one the scripts set - if this is not <0,0,0> then these values override the look targets
146 
147  uint8 padding2;
148  uint8 padding3;
149 
150  // on the pc we store these strings
151  char anim_name[__TOTAL_ANIMS][ANIM_NAME_STR_LEN];
152  char info_name[__TOTAL_ANIMS][ANIM_NAME_STR_LEN];
153  char mesh_name[ANIM_NAME_STR_LEN];
154  char shadow_mesh_name[ANIM_NAME_STR_LEN];
155  char texture_name[PALETTE_STR_LEN];
156  char palette_name[PALETTE_STR_LEN];
157  char pose_name[ANIM_NAME_STR_LEN];
158  char custom_pose_name[ANIM_NAME_STR_LEN];
159  char override_pose_name[ANIM_NAME_STR_LEN];
160 
161  // and so the access functions return the
162  // actual thing
163 
164  char *get_anim_name(int32 i) { return anim_name[i]; }
165  char *get_info_name(int32 i) { return info_name[i]; }
166  char *get_mesh_name() { return mesh_name; }
167  char *get_shadow_mesh_name() { return shadow_mesh_name; }
168  char *get_texture_name() { return texture_name; }
169  char *get_palette_name() { return palette_name; }
170  char *get_pose_name() { return pose_name; }
171  char *get_custom_pose_name() { return custom_pose_name; }
172  char *get_override_pose_name() { return override_pose_name; }
173 
174 };
175 
176 inline int8 _vox_image::IsAnimTable(int32 i) {
177  // If the table has not been set yet : make the anim entry which will set anim_table entry to correct value
178  if (anim_table[i] == (int8)-1)
179  MakeAnimEntry(i);
180  return anim_table[i];
181 }
182 
183 #define MAX_bars 96
184 
185 // Handy constants for accesing the viewState member variable
186 // <last_cycle_state>_<this_cycle_state>
187 // The <last_cycle_state> (1 or 0) is in bit 0
188 // The <this_cycle_state> (1 or 0) is in bit 1
189 enum CameraStateEnum { OFF_CAMERA = 0x0, ON_CAMERA = 0x1 };
190 
191 #define THIS_CYCLE_SHIFT 1
192 #define LAST_CYCLE_SHIFT 0
193 #define LAST_CYCLE_MASK ((1 << THIS_CYCLE_SHIFT) - 1)
194 
195 #define MAKE_VIEW_STATE(last, this) (last | (this << THIS_CYCLE_SHIFT))
196 
197 // off camera last cycle and this cycle : 0x0
198 #define OFF_OFF_CAMERA MAKE_VIEW_STATE(OFF_CAMERA, OFF_CAMERA)
199 
200 // on camera last cycle and off this cycle : 0x1
201 #define ON_OFF_CAMERA MAKE_VIEW_STATE(ON_CAMERA, OFF_CAMERA)
202 
203 // off camera last cycle and on this cycle : 0x2
204 #define OFF_ON_CAMERA MAKE_VIEW_STATE(OFF_CAMERA, ON_CAMERA)
205 
206 // on camera last cycle and on this cycle
207 #define ON_ON_CAMERA MAKE_VIEW_STATE(ON_CAMERA, ON_CAMERA)
208 
209 #define DEFAULT_HEIGHT 170
210 
211 class _mega { // mega logic specific
212 public:
213  ParentBox *cur_parent; // our owner parent box
214  uint32 par_number; // for players abar list update
215  uint32 cur_slice; // for speedups
216 
217  uint32 barrier_list[MAX_bars]; // including animating ones
218  uint32 nudge_list[MAX_bars]; // only player builds this - i can't be bothered with putting it in the player struct however
219 
220  uint32 number_of_barriers; // kept for safety
221  uint32 number_of_nudge; // kept for safety
222  uint32 number_of_animating; // kept for safety
223 
224  __mega_set_names next_anim_type; // queued anim to play after current link anim
225 
226  // turn on spot pan stuff
227  PXfloat target_pan; // actual relative distance to turn
228  PXfloat actual_target_pan; // actual target pan to clip to if necessary
229 
230  PXfloat auto_target_pan; // target pan for auto engine pans - i.e. when routing\bumping
231 
232  PXfloat looking_pan;
233 
234  uint32 target_id; // hurray! Its back again!! Id of target object
235  PXvector target_xyz; // target coordinate - used for position correcting, etc
236 
237  __weapon weapon; // what weapon the mega is carrying
238  __motion motion; // walking, running, used by high level anim functions
239 
240  // To maintain alignment, the sizes of these arrays must be a multiple of 4.
241  char chr_name[MAX_CHAR_NAME_LENGTH]; // i.e. cord
242  char anim_set[MAX_OUTFIT_NAME_LENGTH]; // i.e. casual_wear
243  char custom_set[MAX_CUSTOM_NAME_LENGTH]; // i.e. mine
244 
245  // this is the real game-world coordinate
246  PXvector actor_xyz;
247  PXvector pushed_actor_xyz;
248 
249  uint32 m_phase;
250  _route_description m_main_route;
251 
252  Breath breath;
253 
254  int32 height; // looking height (El Dorado only)
255 
256  // the dynamic lamp (with one state only) and a switch as to whether it is on or off (if >0 then it is on for dynLightOn cycles, if
257  // 0 then off, if -1 on until explicitly turned off)
258  PSXLamp dynLight; // the lamp, filled in partly by logic and partly by stagedraw (rotating with character)
259  int32 dynLightOn; // if 0-off, >0-on for n cycles (count down), -1 - constant until turned off
260  int16 dynLightX, dynLightY, dynLightZ; // cm from centre of character (hip) (hip hurray!)
261 
262  SVECTOR bulletPos;
263  int16 bulletDX;
264  int16 bulletDY;
265  int16 bulletInitialHeight;
266 
267  uint8 bulletBounced, bulletColour;
268 
269  bool8 bulletOn;
270 
271  // NOTE THAT THE FOLLOWING DATA MEMBERS HAVE BEEN ARRANGED TO MAKE 4-BYTE ALIGNMENT CLEAR.
272 
273  // A status flag containing info if the MEGA was in view last cycle,
274  // and is in view this cycle, a change in view state causes an event
275  // to be sent to the MEGA saying "oncamera" "offcamera"
276  bool8 pushed;
277  uint8 viewState;
278  bool8 interacting; // yes or no to avoid problems interacting with id=0 !!!!
279  bool8 turn_dir; // 0 right 1 left
280  bool8 custom;
281  bool8 has_exclusive_coords; // if yes then this object will not have coordinates saved to micro-session - player and chi
282 
283  bool8 is_evil; // true if guard or robot, or some other horrible creature, false if lovely chi or some sort of scientist or whatever.
284  bool8 make_remora_beep; // true for robots so the remora picks them up
285 
286  uint8 inShadePercentage; // how much light to be in shadow
287  bool8 in_shade; // Set to TRUE8 when mega is in shade, FALSE8 otherwise.
288  bool8 use_strike_script; // call a script instead of hitting object
289  bool8 use_fire_script; // call a script instead of shooting object
290 
291  bool8 on_players_floor;
292  uint8 speech_red;
293  uint8 speech_green;
294  uint8 speech_blue;
295 
296  uint8 anim_speed; // 1 is normal
297  bool8 reverse_route; // routing backwards
298  bool8 is_shooting; // are we firing the gun ?
299  bool8 drawShadow; // sometimes turned off
300 
301  // generic async
302  bool8 asyncing; // is loading a generic anim file
303  uint8 async_list_pos; // position in current file list/queue
304  __weapon async_weapon; // current set used by asyncer
305 
306  // footsteps
307  int8 footstep_status; // current foot left/right status...
308  uint8 footstep_weight; // weight of footstep (100 is Cord) 255 maximum...
309  bool8 footstep_special; // whether special or not...
310 
311  bool8 display_me; // high level character draw clip
312 
313  // generic stair-----------------------------------------------------------
314  // stuff for shadow correction on stairs
315  bool8 on_stairs;
316  PXreal bottom_x, bottom_z;
317  PXreal top_x, top_z;
318  PXfloat stair_pan;
319 
320  uint8 extrap_size; // route barrier extrapolation size
321  bool8 dead; // dead or not?
322  uint32 slice_hold_tolerance; // y distance to stray before slice hold kicks back in
323  uint8 idle_count; // how int32 just been stood
324 
325  bool8 inventoryActive; // used to toggle the inventory on and off from scripts (El Dorado only)
326 
327  // camera control
328  bool8 y_locked;
329  PXreal y_lock;
330 
331  void ___init();
332 
333  void InitCartridgeCase(SVECTOR *initPos, int16 initialHeight);
334 
335  bool8 Fetch_armed_status();
336  bool8 Fetch_custom();
337  __weapon Fetch_pose();
338  bool8 Is_crouched();
339 
340  // Move this cycle view state flag into last cycle view state
341  void ShiftViewState();
342  // Set the view state for this cycle
343  void SetThisViewState(enum CameraStateEnum status);
344 
345  void InitDynamicLight();
346 
347  // SetDynamicLight(cycles,r,g,b,x,y,z,falloff);
348  // where cycles is number of cycles to stay on (-1 for constant, 0 for off)
349  // falloff is maximum extent of light, falloff starts 10% of the way from it...
350  void SetDynamicLight(int32 in_cycles, int32 in_r, int32 in_g, int32 in_b, int32 in_x, int32 in_y, int32 in_z, int32 falloff);
351 
352  void RemoveDynamicLight() { dynLightOn = 0; }
353 };
354 
355 // Move this cycle view state flag into last cycle view state
356 inline void _mega::ShiftViewState() { viewState = (uint8)((viewState >> THIS_CYCLE_SHIFT) & (LAST_CYCLE_MASK)); }
357 
358 // Set the view state for this cycle
359 // status is ON_CAMERA or OFF_CAMERA
360 inline void _mega::SetThisViewState(enum CameraStateEnum status) { viewState = (uint8)((viewState & LAST_CYCLE_MASK) | ((int)status << THIS_CYCLE_SHIFT)); }
361 
362 enum _object_image_type { PROP, VOXEL };
363 
364 enum _prop_interact_type { __THREE_SIXTY = 1, __ICB, __RADIAL };
365 
366 enum _hold_mode {
367  prop_camera_hold = 1,
368  mega_player_floor_hold, // hold when not on player floor
369  mega_initial_floor_hold, // hold until on player floor then release forever
370  mega_slice_hold, // hold if not on plyer y then release after a set y distance
371  none
372 };
373 
374 enum _big_mode {
375  __SCRIPT,
376  __NO_LOGIC,
377  __MEGA_SLICE_HELD,
378  __MEGA_PLAYER_FLOOR_HELD,
379  __MEGA_INITIAL_FLOOR_HELD,
380  __CUSTOM_SIMPLE_ANIMATE,
381  __CUSTOM_BUTTON_OPERATED_DOOR,
382  __CUSTOM_AUTO_DOOR
383 };
384 
385 #define MAX_list 10
386 
387 #define THREE_SIXTY_INTERACT 2
388 #define PROP_CROUCH_INTERACT 1
389 
390 // game object logic structure
391 class _logic {
392 public:
393  uint32 ms_timer; // timer for this object DEBUGGING
394  uint32 looping;
395  uint32 old_looping; // logic controller for script functions - such as animators
396  uint32 pause; // logic pause value
397  uint32 anim_direction; // 0 forward, else backward
398  _object_status ob_status; // low level internal stuff - see enum _object_status //held/not held...
399  _big_mode big_mode;
400  uint32 owner_floor_rect; // current floor rect number
401  uint32 total_list; // number of items in list
402  uint32 list[MAX_list]; // a list available to script logic
403  uint32 list_result; // tempory holding place for the result of list checking functions - that must return true/false
404  uint32 sfxVars[3]; // up to 3 different sound effect modifiers per type of object (gunshot,ricochet,tinkle) (door open,door close)
405  uint32 logic_level; // what level? 0 is the context switch, 1 is the main logic, 2+ are gosubs from level 1
406  char *logic[TREE_SIZE]; // pointers to the raw compiled script data
407  char *logic_ref[TREE_SIZE]; // holds the initial pointers
408  _object_image_type image_type; // object is PROP or VOXEL based
409  __object_type object_type;
410  uint32 conversation_uid; // id of conversation we may be in
411  // type of current animation - use to index into voxel_image->anim_name;
412  __mega_set_names cur_anim_type;
413  uint32 anim_pc; // pc of current animation - i.e. position in track\voxel frame file
414  _vox_image *voxel_info; // extra graphic info
415  _mega *mega; // extra mega info
416  // prop xyz coord derived from nico
417  PXvector prop_xyz;
418  PXfloat prop_interact_pan;
419  PXreal interact_dist; //actual distance - can be changed by implementor
420  _prop_interact_type prop_interact_method; //user interaction method
421  int32 radial_interact_distance;
422 
423  PXfloat pan; // engine pan
424  PXfloat pan_adjust; // pan neutraliser for frames that include a pan from the grab - i.e. turn on spot
425  // this is a distance to look up when looking at the object, only useful:
426  int32 look_height; // -1 means not used so don't do...
427  // auto panning stuff
428  PXfloat auto_display_pan;
429  // timers
430  uint32 cycle_time;
431  uint32 slowest_cycle_time;
432  _hold_mode hold_mode;
433 
434  int16 sparkleX;
435  int16 sparkleY;
436 
437  int16 sparkleZ;
438  bool8 player_can_interact; // interactable true or false
439  bool8 context_request; // crude switch to force context script rerun
440 
441  bool8 prop_coords_set; // has a prop object been asigned coordinates - for development safety
442  uint8 three_sixty_interact; // true then overides the normal tight pan approach to interaction - like a mega in-fact
443  bool8 auto_panning;
444  bool8 do_not_disturb; // If true, object will not rerun logic context.
445 
446  bool8 camera_held;
447  bool8 prop_on_this_screen; // actually on this camera - used by closed doors
448  bool8 sparkleOn; // whether or not sparkle is on
449  bool8 padding; // Pad the structure
450 
451 private:
452  char ob_name[ENGINE_STRING_LEN];
453 
454 public:
455  void ___init(const char *name);
456  void ___destruct();
457 
458  const char *GetName() const { return ob_name; }
459 
460  void GetPosition(PXreal &x, PXreal &y, PXreal &z) const {
461  bool8 isActor = (bool8)(image_type == VOXEL);
462 
463  if (isActor) {
464  x = mega->actor_xyz.x;
465  y = mega->actor_xyz.y;
466  z = mega->actor_xyz.z;
467  } else {
468  x = prop_xyz.x;
469  y = prop_xyz.y;
470  z = prop_xyz.z;
471  }
472  }
473 };
474 
475 } // End of namespace ICB
476 
477 #endif
Definition: px_route_barriers.h:190
Definition: px_common.h:166
Definition: rlp_api.h:118
Definition: px_capri_maths.h:53
Definition: actor.h:32
Definition: object_structs.h:391
Definition: px_bones.h:43
Definition: route_manager.h:74
Definition: object_structs.h:83
Definition: breath.h:40
Definition: object_structs.h:211