Returns the new child's handle
| 72 | |
| 73 | // Returns the new child's handle |
| 74 | int CreateAndAttach(int me, const char *child_name, uint8_t child_type, char parent_ap, char child_ap, bool f_aligned, |
| 75 | bool f_set_parent) { |
| 76 | int child_handle = OBJECT_HANDLE_NONE; |
| 77 | int child_id = Obj_FindID(child_name); |
| 78 | msafe_struct m; |
| 79 | m.objhandle = me; |
| 80 | MSafe_GetValue(MSAFE_OBJECT_POS, &m); |
| 81 | MSafe_GetValue(MSAFE_OBJECT_ROOMNUM, &m); |
| 82 | |
| 83 | if (child_id >= 0) { |
| 84 | int parent; |
| 85 | if (f_set_parent) |
| 86 | parent = me; |
| 87 | else |
| 88 | parent = OBJECT_HANDLE_NONE; |
| 89 | |
| 90 | child_handle = Obj_Create(child_type, child_id, m.roomnum, &m.pos, NULL, parent); |
| 91 | if (child_handle != OBJECT_HANDLE_NONE) { |
| 92 | if (!Obj_AttachObjectAP(me, parent_ap, child_handle, child_ap, f_aligned)) { |
| 93 | // chrishack (we need a way to instantly kill scripted objects) |
| 94 | } |
| 95 | } |
| 96 | } |
| 97 | |
| 98 | return child_handle; |
| 99 | } |
| 100 | |
| 101 | // ========================== |
| 102 | // Script class definitions// |
no test coverage detected