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

Function ObjSetPos

Descent3/object.cpp:3162–3221  ·  view source on GitHub ↗

sets the position of an object. This should be called to move an object

Source from the content-addressed store, hash-verified

3160
3161// sets the position of an object. This should be called to move an object
3162void ObjSetPos(object *obj, vector *pos, int roomnum, matrix *orient, bool f_update_attached_children) {
3163 int oldroomnum = obj->roomnum;
3164 vector old_pos = obj->pos;
3165
3166 // Reset the position & recalculate the AABB
3167 obj->pos = *pos;
3168 ObjSetAABB(obj);
3169
3170 // Reset the orientation if changed
3171 if (orient != NULL)
3172 ObjSetOrient(obj, orient);
3173
3174 // Clear the outside-mine flag
3175 obj->flags &= ~OF_OUTSIDE_MINE;
3176
3177 // If changed rooms, do a bunch of stuff
3178 if (obj->roomnum != roomnum) {
3179
3180 // Let the script know
3181 tOSIRISEventInfo ei;
3182 ei.evt_changeseg.room_num = roomnum;
3183 Osiris_CallEvent(obj, EVT_CHANGESEG, &ei);
3184
3185 if (obj->type == OBJ_PLAYER && !ROOMNUM_OUTSIDE(roomnum) && (Rooms[roomnum].flags & RF_INFORM_RELINK_TO_LG)) {
3186 Level_goals.Inform(LIT_INTERNAL_ROOM, LGF_COMP_ENTER, roomnum);
3187 }
3188
3189 // Relink the object
3190 ObjRelink(OBJNUM(obj), roomnum);
3191
3192 // Call DLL function if the server player changed rooms
3193 if ((Game_mode & GM_MULTI) && (Netgame.local_role == LR_SERVER)) {
3194 DLLInfo.me_handle = obj->handle;
3195 DLLInfo.it_handle = obj->handle;
3196 DLLInfo.oldseg = oldroomnum;
3197 DLLInfo.newseg = obj->roomnum;
3198
3199 if (obj->type == OBJ_PLAYER) {
3200 CallGameDLL(EVT_GAMEPLAYERCHANGESEG, &DLLInfo);
3201 } else {
3202 CallGameDLL(EVT_GAMEOBJCHANGESEG, &DLLInfo);
3203 }
3204 }
3205
3206 // Slowly change volume lighting if going between rooms, if not in the editor
3207 if (GetFunctionMode() != EDITOR_MODE) {
3208 if ((obj->effect_info != NULL) && (obj->effect_info->type_flags & EF_VOLUME_LIT)) {
3209 if (!ROOMNUM_OUTSIDE(oldroomnum) && !ROOMNUM_OUTSIDE(roomnum)) {
3210 if (!(obj->effect_info->type_flags & EF_VOLUME_CHANGING)) {
3211 obj->effect_info->type_flags |= EF_VOLUME_CHANGING;
3212 obj->effect_info->volume_change_time = 1.0;
3213 obj->effect_info->volume_old_room = oldroomnum;
3214 obj->effect_info->volume_old_pos = old_pos;
3215 }
3216 } else // either old or new room was outside, so don't do volume changing
3217 obj->effect_info->type_flags &= ~EF_VOLUME_CHANGING;
3218 }
3219 }

Callers 15

DoPhysLinkedFrameFunction · 0.85
do_physics_simFunction · 0.85
do_walking_simFunction · 0.85
MoveViewerFunction · 0.85
HObjectPlaceFunction · 0.85
ResetGroundObjectFunction · 0.85
HObjectMoveToViewerFunction · 0.85
MoveObjectFunction · 0.85
OnGotoMethod · 0.85
OnLButtonDownMethod · 0.85
ResetObjectOntoTerrainFunction · 0.85

Calls 7

ObjSetAABBFunction · 0.85
ObjSetOrientFunction · 0.85
Osiris_CallEventFunction · 0.85
ObjRelinkFunction · 0.85
CallGameDLLFunction · 0.85
GetFunctionModeFunction · 0.85
InformMethod · 0.80

Tested by

no test coverage detected