sets the position of an object. This should be called to move an object
| 3160 | |
| 3161 | // sets the position of an object. This should be called to move an object |
| 3162 | void 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 | } |
no test coverage detected