Phasor  01.00.10.059
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Objects.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "../../../Common/Types.h"
4 #include "../../../Common/vect3d.h"
5 #include "../Halo.h"
6 
7 namespace halo {
8  struct s_player;
9  namespace objects
10 {
11  #pragma pack(push, 1)
12 
13  // Some structure issues were clarified thanks to the code at:
14  // http://code.google.com/p/halo-devkit/source/browse/trunk/halo_sdk/Engine/objects.h
15  //
16 
17  struct s_halo_object // generic object header
18  {
19  ident map_id; // 0x0000
20  UNKNOWN(12);
22  bool ignoreGravity : 1;
24  bool stationary : 1;
26  bool noCollision : 1; // has no collision box, projectiles etc pass right through
27  UNKNOWN(3);
28  unsigned long timer; // 0x0014
29  UNKNOWN(0x44);// empty;
30  vect3d location; // 0x005c
31  vect3d velocity; // 0x0068
32  vect3d rotation; // 0x0074
34  UNKNOWN(sizeof(vect3d)); // some vector
35  UNKNOWN(0x28);
36  ident ownerPlayer; // 0x00c0 (index of owner (if has one))
37  ident ownerObject; // 0x00c4 (object id of owner, if projectile is player id)
38  UNKNOWN(0x18);
39  float health; // 0x00e0
40  float shield; // 0x00e4
41  UNKNOWN(0x10);
42  vect3d location1; // 0x00f8 set when in a vehicle unlike other one. best not to use tho (isnt always set)
43  UNKNOWN(0x10);
44  ident veh_weaponId; // 0x0114
46  ident vehicleId; // 0x011C
47  BYTE bGunner; // 0x0120
48  short unkShort; // 0x0121
49  BYTE bFlashlight; // 0x0123
50  UNKNOWN(4);
51  float shield1; // 0x0128 (same as other shield)
52  float flashlightCharge; // 0x012C (1.0 when on)
53  UNKNOWN(4);
54  float flashlightCharge1; // 0x0134
55  UNKNOWN(0xBC);
56 
57  //immune to backtap: 0xB4 (boolean)
58  // 0x107 | 8 == immune to all damage
59  };
60  static_assert (sizeof(s_halo_object) == 0x1f4, "bad");
61 
62  struct s_halo_biped
63  {
65  UNKNOWN(0x10); // 0x1f4
66  long invisible; // 0x204 (0x41 inactive, 0x51 active. probably bitfield but never seen anything else referenced)
67 
68  struct // 0x208
69  {
70  // these are action flags, basically client button presses
71  // these don't actually control whether or not an event occurs
72 
73  bool crouching : 1; // 0
74  bool jumping : 1; // 1
76  bool flashlight : 1; // 4
78  bool actionPress : 1; // 6 think this is just when they initially press the action button
79  bool melee : 1; // 7
81  bool reload : 1; // 10
82  bool primaryWeaponFire : 1; // 11 right mouse
83  bool secondaryWeaponFire : 1; // 12 left mouse
84  bool secondaryWeaponFire1 : 1; // 13
85  bool actionHold : 1; // 14 holding action button
87  } actionFlags;
88  UNKNOWN(0x26); // 0x020A
90  UNKNOWN(0x68); // 0x23c
91  BYTE bodyState; // 0x2A4 (2 = standing, 3 = crouching, 0xff = invalid, like in vehicle)
92  UNKNOWN(0x53); // 0x2A5
97  UNKNOWN(0x16); // 0x308
98  BYTE frag_nade_count; // 0x31e
99  BYTE plasma_nade_count; //0x31f
100  BYTE zoomLevel; // 0x320 (0xff - no zoom, 0 - 1 zoom, 1 - 2 zoom etc)
101  BYTE zoomLevel1; // 0x321
102  UNKNOWN(0x1AA); // 0x322
103  BYTE isAirbourne; // 0x4CC (from jumping/falling, not when flying in vehicle)
104  UNKNOWN(0x33); // 0x4cd - 0x500
105  UNKNOWN(0x0c);
107 
108  // The rest of bipd is composed of other tags, such as
109  // mod2\characters\cyborg\cyborg
110  // with these tags its size is 0xDEC
111  };
112  static_assert(sizeof(s_halo_biped) == 0x510, "bad");
113 
115  {
117  UNKNOWN(0xC2); // 1f4
118  WORD ammo_pack; // 2b6 reserve ammo
119  WORD ammo_clip; // 2b8
120  UNKNOWN(0x96);
121 
122  void SetAmmo(WORD pack, WORD clip);
123  static void SyncAmmo(ident weaponId);
124 
125  // rest of weap is composed on other tags, with these tags
126  // its size is 0x684
127  };
128  static_assert(sizeof(s_halo_weapon) == 0x350, "bad");
129 
131  {
133  UNKNOWN(0x3b8);
135  UNKNOWN(0x010);
136  // rest of vehi is composed of other tags, with these tags
137  // its size is 0xE00
138  };
139  static_assert(sizeof(s_halo_vehicle) == 0x5c0, "bad");
140 
142  {
144  UNKNOWN(4);
147  UNKNOWN(8);
149  // rest unknown..
150  };
151  #pragma pack(pop)
152 
153  struct view_vector
154  {
157  };
158 
159  void* GetObjectAddress(ident objectId);
160  bool DestroyObject(ident objid);
161 
162  void ClearManagedObjects();
163 
164  bool CreateObject(ident mapid, ident parentId, int respawnTime, bool bRecycle,
165  const vect3d* location, ident& out_objid);
166 
167  bool AssignPlayerWeapon(s_player& player, ident weaponid);
168 
169  // Forces a player into a vehicle
170  // Seat numbers: 0 (driver) 1 (passenger) 2 (gunner)
171  bool EnterVehicle(s_player& player, ident m_vehicleId, DWORD seat);
172 
173  // Forces a player to exit a vehicle
174  bool ExitVehicle(s_player& player);
175 
176  void MoveObject(s_halo_object& object, const vect3d& pos);
177 
178  // Finds an intersection between view and the environment.
179  // Returns true if object intersected, false otherwise.
180  bool FindIntersection(const view_vector& view, const halo::ident& ignore_obj,
181  vect3d& hit_pos, ident& hit_obj);
182 
183  // --------------------------------------------------------------------
184  // Events
185 
186  // Called when an object is being checked to see if it should respawn
187  int __stdcall VehicleRespawnCheck(ident m_objId, s_halo_vehicle* obj);
188 
189  // This is called when weapons/equipment are going to be destroyed.
190  // todo: check ticks should be signed
191  bool __stdcall EquipmentDestroyCheck(int checkTicks, ident m_objId, s_halo_object* obj);
192 
193  // Called when an object is being destroyed
194  void __stdcall OnObjectDestroy(ident m_objid);
195 }}