Returns the new child's handle
| 207 | |
| 208 | // Returns the new child's handle |
| 209 | int CreateAndAttach(int me, const char *child_name, uint8_t child_type, char parent_ap, char child_ap, bool f_aligned, |
| 210 | bool f_set_parent) { |
| 211 | int child_handle = OBJECT_HANDLE_NONE; |
| 212 | int child_id = Obj_FindID(child_name); |
| 213 | msafe_struct m; |
| 214 | m.objhandle = me; |
| 215 | MSafe_GetValue(MSAFE_OBJECT_POS, &m); |
| 216 | MSafe_GetValue(MSAFE_OBJECT_ROOMNUM, &m); |
| 217 | |
| 218 | if (child_id >= 0) { |
| 219 | int parent; |
| 220 | if (f_set_parent) |
| 221 | parent = me; |
| 222 | else |
| 223 | parent = OBJECT_HANDLE_NONE; |
| 224 | |
| 225 | child_handle = Obj_Create(child_type, child_id, m.roomnum, &m.pos, NULL, parent); |
| 226 | if (child_handle != OBJECT_HANDLE_NONE) { |
| 227 | if (!Obj_AttachObjectAP(me, parent_ap, child_handle, child_ap, f_aligned)) { |
| 228 | // chrishack (we need a way to instantly kill scripted objects) |
| 229 | } |
| 230 | } |
| 231 | } |
| 232 | |
| 233 | return child_handle; |
| 234 | } |
| 235 | |
| 236 | // ========================== |
| 237 | // Script class definitions// |
no test coverage detected