MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / CreateAndAttach

Function CreateAndAttach

scripts/AIGame.cpp:209–234  ·  view source on GitHub ↗

Returns the new child's handle

Source from the content-addressed store, hash-verified

207
208// Returns the new child's handle
209int 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//

Callers 2

DoInitMethod · 0.70
DoSubModeFrameMethod · 0.70

Calls 1

Obj_CreateFunction · 0.85

Tested by

no test coverage detected