Switches a player object to observer mode
| 3498 | |
| 3499 | // Switches a player object to observer mode |
| 3500 | void PlayerSwitchToObserver(int slot, int observer_mode, int piggy_objnum) { |
| 3501 | object *obj = &Objects[Players[slot].objnum]; |
| 3502 | |
| 3503 | // call the event to the multiplayer DLL's so they can do what they need |
| 3504 | if (Game_mode & GM_MULTI) { |
| 3505 | DLLInfo.me_handle = obj->handle; |
| 3506 | |
| 3507 | if (observer_mode == OBSERVER_MODE_PIGGYBACK) { |
| 3508 | DLLInfo.it_handle = Objects[piggy_objnum].handle; |
| 3509 | } else { |
| 3510 | DLLInfo.it_handle = OBJECT_HANDLE_NONE; |
| 3511 | } |
| 3512 | |
| 3513 | CallGameDLL(EVT_CLIENT_GAMEPLAYERENTERSOBSERVER, &DLLInfo); |
| 3514 | } |
| 3515 | |
| 3516 | // Stop sounds for this player |
| 3517 | PlayerStopSounds(slot); |
| 3518 | |
| 3519 | if (slot == Player_num) { |
| 3520 | AddHUDMessage(TXT_ENTEROBS); |
| 3521 | SetHUDMode(HUD_OBSERVER); |
| 3522 | Players[slot].movement_scalar = 2.0; |
| 3523 | } else |
| 3524 | AddHUDMessage(TXT_PLYRENTEROBS, Players[slot].callsign); |
| 3525 | |
| 3526 | CreateRandomSparks(30, &obj->pos, obj->roomnum, HOT_SPARK_INDEX, (ps_rand() % 3) + 2); |
| 3527 | |
| 3528 | if (Demo_flags != DF_PLAYBACK) { |
| 3529 | PlayerSpewInventory(obj, false); |
| 3530 | } |
| 3531 | |
| 3532 | obj->type = OBJ_OBSERVER; |
| 3533 | obj->render_type = RT_NONE; |
| 3534 | |
| 3535 | if (Demo_flags == DF_RECORDING) { |
| 3536 | DemoWritePlayerTypeChange(slot, false, observer_mode, piggy_objnum); |
| 3537 | } |
| 3538 | |
| 3539 | if (observer_mode == OBSERVER_MODE_ROAM) { |
| 3540 | SetObjectControlType(obj, CT_FLYING); |
| 3541 | Players[slot].piggy_objnum = -1; |
| 3542 | obj->movement_type = MT_PHYSICS; |
| 3543 | } else if (observer_mode == OBSERVER_MODE_PIGGYBACK) { |
| 3544 | SetObjectControlType(obj, CT_NONE); |
| 3545 | Players[slot].piggy_objnum = piggy_objnum; |
| 3546 | Players[slot].piggy_sig = Objects[piggy_objnum].handle & HANDLE_COUNT_MASK; |
| 3547 | mprintf(0, "Object %d is observing object %d!\n", obj - Objects, piggy_objnum); |
| 3548 | } |
| 3549 | } |
| 3550 | |
| 3551 | // Stops a player from observing |
| 3552 | void PlayerStopObserving(int slot) { |
no test coverage detected