Returns the new child's handle
| 284 | |
| 285 | // Returns the new child's handle |
| 286 | int CreateAndAttach(int me, const char *child_name, uint8_t child_type, char parent_ap, char child_ap, bool f_aligned, |
| 287 | bool f_set_parent) { |
| 288 | int child_handle = OBJECT_HANDLE_NONE; |
| 289 | int child_id = Obj_FindID(child_name); |
| 290 | msafe_struct m; |
| 291 | m.objhandle = me; |
| 292 | MSafe_GetValue(MSAFE_OBJECT_POS, &m); |
| 293 | MSafe_GetValue(MSAFE_OBJECT_ROOMNUM, &m); |
| 294 | |
| 295 | if (child_id >= 0) { |
| 296 | int parent; |
| 297 | if (f_set_parent) |
| 298 | parent = me; |
| 299 | else |
| 300 | parent = OBJECT_HANDLE_NONE; |
| 301 | |
| 302 | child_handle = Obj_Create(child_type, child_id, m.roomnum, &m.pos, NULL, parent); |
| 303 | if (child_handle != OBJECT_HANDLE_NONE) { |
| 304 | if (!Obj_AttachObjectAP(me, parent_ap, child_handle, child_ap, f_aligned)) { |
| 305 | // chrishack (we need a way to instantly kill scripted objects) |
| 306 | } |
| 307 | } |
| 308 | } |
| 309 | |
| 310 | return child_handle; |
| 311 | } |
| 312 | |
| 313 | int FindClosestPlayer(int objhandle) { |
| 314 | vector objpos, playerpos; |