Places an object in the world Parameters: obj_type,obj_id - specify the object to be placed Returns: true if object placed, false if there was some problem
| 277 | // Parameters: obj_type,obj_id - specify the object to be placed |
| 278 | // Returns: true if object placed, false if there was some problem |
| 279 | bool HObjectPlace(int obj_type, int obj_id) { |
| 280 | int objnum; |
| 281 | object *objp; |
| 282 | poly_model *pm; |
| 283 | matrix orient = IDENTITY_MATRIX; |
| 284 | |
| 285 | // Special stuff for player ship |
| 286 | if (obj_type == OBJ_PLAYER) { |
| 287 | |
| 288 | if (!Num_ships) { |
| 289 | OutrageMessageBox("Cannot a player: There are no player ships."); |
| 290 | return 0; |
| 291 | } |
| 292 | |
| 293 | // Store ship num in player array |
| 294 | int ship_num = D3EditState.current_ship; |
| 295 | |
| 296 | if (ship_num == -1) { |
| 297 | OutrageMessageBox("You must have a current player ship selected for this operation."); |
| 298 | return 0; |
| 299 | } |
| 300 | |
| 301 | Players[obj_id].ship_index = ship_num; |
| 302 | } |
| 303 | |
| 304 | if (obj_type != OBJ_POWERUP) { |
| 305 | orient = Viewer_object->orient; |
| 306 | } |
| 307 | |
| 308 | // Create the object at the viewer for now |
| 309 | objnum = ObjCreate(obj_type, obj_id, Viewer_object->roomnum, &Viewer_object->pos, &orient); |
| 310 | if (objnum == -1) |
| 311 | return 0; |
| 312 | |
| 313 | objp = &Objects[objnum]; |
| 314 | |
| 315 | // If we have a ground plane, use current cell or face for position & place normal for orientation |
| 316 | if ((objp->render_type == RT_POLYOBJ) && ((pm = GetPolymodelPointer(objp->rtype.pobj_info.model_num))->n_ground)) { |
| 317 | vector *surface_norm; |
| 318 | vector pos; |
| 319 | int roomnum; |
| 320 | |
| 321 | // If terrain, use current cell |
| 322 | if (Editor_view_mode == VM_TERRAIN) { |
| 323 | |
| 324 | int cellnum = GetSelectedTerrainCell(); |
| 325 | |
| 326 | if (cellnum == -1) { |
| 327 | OutrageMessageBox("You must have a terrain cell selected to place an object."); |
| 328 | ObjDelete(objnum); |
| 329 | return 0; |
| 330 | } |
| 331 | if (cellnum == -2) { |
| 332 | OutrageMessageBox("You must have only have one cell selected to place an object."); |
| 333 | ObjDelete(objnum); |
| 334 | return 0; |
| 335 | } |
| 336 |
no test coverage detected