// 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)); }
// given a newly created weapon, turn it into a flak weapon void flak_create(weapon *wp) { int idx; int found; // make sure this is a valid flak weapon object Assert(wp->objnum >= 0); Assert(Objects[wp->objnum].type == OBJ_WEAPON); Assert(wp->weapon_info_index >= 0); Assert(Weapon_info[wp->weapon_info_index].wi_flags & WIF_FLAK); // switch off rendering for the object obj_set_flags(&Objects[wp->objnum], Objects[wp->objnum].flags & ~(OF_RENDERS)); // try and find a free flak index found = 0; for(idx=0; idx<MAX_FLAK_INFO; idx++){ if(Flak[idx].range < 0.0f){ found = 1; break; } } // if we found a free slot if(found){ Flak[idx].range = 0.0f; wp->flak_index = (short)idx; } else { nprintf(("General", "Out of FLAK slots!\n")); } }
// respawns an AI ship. void multi_respawn_ai( p_object *pobjp ) { int objnum; object *objp; // create the object and change the ship type objnum = multi_respawn_common_stuff( pobjp ); objp = &Objects[objnum]; // be sure the the OF_PLAYER_SHIP flag is unset, and the could be player flag is set obj_set_flags( objp, objp->flags | OF_COULD_BE_PLAYER ); objp->flags &= ~OF_PLAYER_SHIP; }
// respawns an AI ship. void multi_respawn_ai( p_object *pobjp ) { int objnum; object *objp; // create the object and change the ship type objnum = multi_respawn_common_stuff( pobjp ); objp = &Objects[objnum]; // be sure the the OF_PLAYER_SHIP flag is unset, and the could be player flag is set obj_set_flags(objp, objp->flags + Object::Object_Flags::Could_be_player); objp->flags.remove(Object::Object_Flags::Player_ship); }
// server should check to see if any respawned players have run out of their invulnerability void multi_respawn_handle_invul_players() { int idx; object *objp; for(idx=0;idx<MAX_PLAYERS;idx++){ if(MULTI_CONNECTED(Net_players[idx]) && (Objects[Net_players[idx].player->objnum].flags & OF_INVULNERABLE)){ // make him normal (_non_ invulnerable) on either of 2 conditions : // 1.) More than 5 seconds have passed // 2.) He's fired either a primary or a secondary weapon if( ((Net_players[idx].s_info.invul_timestamp != -1) && (timestamp_elapsed(Net_players[idx].s_info.invul_timestamp))) || ((Net_players[idx].player->ci.fire_primary_count > 0) || (Net_players[idx].player->ci.fire_secondary_count > 0)) ) { objp = &Objects[Net_players[idx].player->objnum]; obj_set_flags(objp,objp->flags & ~(OF_INVULNERABLE)); } } } }