Example #1
0
// create observer object locally, and additionally, setup some other information
// ( client-side equivalent of multi_obs_create_observer() )
void multi_obs_create_observer_client()
{
	int pobj_num;

	Assert(!(Net_player->flags & NETINFO_FLAG_OBS_PLAYER));

	// make me an observer object
	multi_obs_create_observer(Net_player);

	// set my object to be the observer object	
	Player_obj = &Objects[Net_player->m_player->objnum];

	// create the default player ship object and use that as my default virtual "ship", and make it "invisible"
	pobj_num = parse_create_object(&Player_start_pobject);
	Assert(pobj_num != -1);
	obj_set_flags(&Objects[pobj_num], OF_PLAYER_SHIP);
	Player_ship = &Ships[Objects[pobj_num].instance];

	// make ship hidden from sensors so that this observer cannot target it.  Observers really have two ships
	// one observer, and one "Player_ship".  Observer needs to ignore the Player_ship.
	Player_ship->flags |= SF_HIDDEN_FROM_SENSORS;
	strcpy_s(Player_ship->ship_name, XSTR("Observer Ship", 688));
	Player_ai = &Ai_info[Ships[Objects[pobj_num].instance].ai_index];

	// configure the hud to be in "observer" mode
	hud_config_as_observer(Player_ship, Player_ai);

	// set some flags for myself
	Net_player->flags |= NETINFO_FLAG_OBSERVER;

	// reset the control info structure
	memset(&Player->ci, 0, sizeof(control_info));
}
Example #2
0
// respawn myself as an observer
void multi_respawn_as_observer()
{
	// configure the hud to be in "observer" mode
	hud_config_as_observer(Player_ship,Player_ai);	

	// blow away my old player object
	Player_obj->flags |= OF_SHOULD_BE_DEAD;
	obj_delete(OBJ_INDEX(Player_obj));

	// create a new shiny observer object for me
	multi_obs_create_observer(Net_player);
	
	// set my object to be the observer object
	Player_obj = &Objects[Net_player->player->objnum];
	Player_ship = &Hud_obs_ship;	
	Player_ai = &Hud_obs_ai;	
	
	// set some flags for myself
	Net_player->flags |= NETINFO_FLAG_OBSERVER;
	Net_player->flags |= NETINFO_FLAG_OBS_PLAYER;
	Net_player->flags &= ~(NETINFO_FLAG_LIMBO);

	// clear my auto-match speed flag
	Net_player->player->flags &= ~(PLAYER_FLAGS_AUTO_MATCH_SPEED | PLAYER_FLAGS_MATCH_TARGET);
	
	// reset the control info structure
	memset(&Player->ci,0,sizeof(control_info));	
}