Esempio n. 1
0
static void destroy_local (entity *en)
{
	regen
		*raw;

	////////////////////////////////////////
	//
	// PRE-AMBLE
	//
	////////////////////////////////////////

	#if DEBUG_MODULE

	debug_log_entity_args (ENTITY_DEBUG_LOCAL, ENTITY_DEBUG_DESTROY, en);

	#endif

	raw = (regen *) get_local_entity_data (en);

	////////////////////////////////////////
	//
	// VALIDATE
	//
	////////////////////////////////////////

	ASSERT (!raw->member_root.first_child);

	////////////////////////////////////////
	//
	// DESTROY COMPONENTS
	//
	////////////////////////////////////////

	////////////////////////////////////////
	//
	// UNLINK FROM SYSTEM
	//
	////////////////////////////////////////

	delete_local_entity_from_parents_child_list (en, LIST_TYPE_CURRENT_WAYPOINT);

	delete_local_entity_from_parents_child_list (en, LIST_TYPE_REGEN);

	delete_local_entity_from_parents_child_list (en, LIST_TYPE_UPDATE);

	////////////////////////////////////////
	//
	// FREE ENTITY DATA
	//
	////////////////////////////////////////

	free_mem (raw);

	set_free_entity (en);
}
Esempio n. 2
0
static void destroy_local (entity *en)
{
	sprite
		*raw;

	////////////////////////////////////////
	//
	// PRE-AMBLE
	//
	////////////////////////////////////////

	#if DEBUG_MODULE

	debug_log_entity_args (ENTITY_DEBUG_LOCAL, ENTITY_DEBUG_DESTROY, en);

	#endif

	raw = (sprite *) get_local_entity_data (en);

	////////////////////////////////////////
	//
	// VALIDATE
	//
	////////////////////////////////////////

	////////////////////////////////////////
	//
	// DESTROY COMPONENTS
	//
	////////////////////////////////////////

	////////////////////////////////////////
	//
	// UNLINK FROM SYSTEM
	//
	////////////////////////////////////////

	delete_local_entity_from_parents_child_list (en, LIST_TYPE_SECTOR);

	delete_local_entity_from_parents_child_list (en, LIST_TYPE_UPDATE);

	delete_local_entity_from_parents_child_list (en, LIST_TYPE_SPECIAL_EFFECT);

	////////////////////////////////////////
	//
	// FREE ENTITY DATA
	//
	////////////////////////////////////////

	free_mem (raw);

	set_free_entity (en);
}
Esempio n. 3
0
static void destroy_local (entity *en)
{
	division
		*raw;

	////////////////////////////////////////
	//
	// PRE-AMBLE
	//
	////////////////////////////////////////

	#if DEBUG_MODULE

	debug_log_entity_args (ENTITY_DEBUG_LOCAL, ENTITY_DEBUG_DESTROY, en);

	#endif

	raw = (division *) get_local_entity_data (en);

	////////////////////////////////////////
	//
	// VALIDATE
	//
	////////////////////////////////////////

	////////////////////////////////////////
	//
	// DESTROY COMPONENTS
	//
	////////////////////////////////////////

	////////////////////////////////////////
	//
	// UNLINK FROM SYSTEM
	//
	////////////////////////////////////////

	unlink_local_entity_children (en, LIST_TYPE_DIVISION);

	delete_local_entity_from_parents_child_list (en, LIST_TYPE_DIVISION);

	delete_local_entity_from_parents_child_list (en, LIST_TYPE_DIVISION_HEADQUARTERS);

	////////////////////////////////////////
	//
	// FREE ENTITY DATA
	//
	////////////////////////////////////////

	free_mem (raw);

	set_free_entity (en);
}
Esempio n. 4
0
static void set_local_ptr_value (entity *en, ptr_types type, void *ptr)
{
	group
		*raw;

	#if DEBUG_MODULE

	debug_log_entity_args (ENTITY_DEBUG_LOCAL, ENTITY_DEBUG_PTR_VALUE, en, type, ptr);

	#endif

	raw = (group *) get_local_entity_data (en);

	switch (type)
	{
		////////////////////////////////////////
		case PTR_TYPE_GROUP_LEADER:
		////////////////////////////////////////
		{
			entity
				*member;
				
			//
			// make an entity group leader by removing it from the member list, and inserting it at the front
			//

			member = (entity *) ptr;

			ASSERT (member);

			ASSERT (get_local_entity_parent (member, LIST_TYPE_MEMBER) == en);
	
			delete_local_entity_from_parents_child_list (member, LIST_TYPE_MEMBER);

			insert_local_entity_into_parents_child_list (member, LIST_TYPE_MEMBER, en, NULL);

			break;
		}
		////////////////////////////////////////
		default:
		////////////////////////////////////////
		{
			debug_fatal_invalid_ptr_type (en, type);

			break;
		}
	}
}
Esempio n. 5
0
void kill_local_restored_anti_aircraft_entity (entity *en)
{

	anti_aircraft
		*raw;

	entity
		*group;

	raw = (anti_aircraft *) get_local_entity_data (en);

	// must be done before alive flag set to FALSE
	remove_mobile_values_from_sector (get_local_entity_parent (en, LIST_TYPE_SECTOR), en);

	set_local_entity_int_value (en, INT_TYPE_ALIVE, FALSE);

	damage_anti_aircraft_3d_object (en);

	set_local_entity_int_value (en, INT_TYPE_OPERATIONAL_STATE, OPERATIONAL_STATE_DEAD);

	////////////////////////////////////////
	//
	// DESTROY COMPONENTS
	//
	////////////////////////////////////////

	group = get_local_entity_parent (en, LIST_TYPE_MEMBER);

	////////////////////////////////////////
	//
	// UNLINK FROM SYSTEM
	//
	////////////////////////////////////////

	unlink_local_entity_children (en, LIST_TYPE_TASK_DEPENDENT);

	unlink_local_entity_children (en, LIST_TYPE_LAUNCHED_WEAPON);

	delete_local_entity_from_parents_child_list (en, LIST_TYPE_MEMBER);

	delete_local_entity_from_parents_child_list (en, LIST_TYPE_FOLLOWER);

	// gunship_target_link

	// member_link

	// view_link

	unlink_local_entity_children (en, LIST_TYPE_TARGET);

	delete_local_entity_from_parents_child_list (en, LIST_TYPE_PADLOCK);

	// sector_link

	delete_local_entity_from_parents_child_list (en, LIST_TYPE_TARGET);

	delete_local_entity_from_parents_child_list (en, LIST_TYPE_UPDATE);

	//
	// kill weapon sound effects
	//

	kill_local_entity_sound_type (en, ENTITY_SUB_TYPE_EFFECT_SOUND_CHAIN_GUN);

	//
	// Notify the GROUP that the mobile has been killed  (N.B. must be done AFTER mobile is unlinked from member list)
	//

	if (get_comms_model () == COMMS_MODEL_SERVER)
	{
		notify_local_entity (ENTITY_MESSAGE_MOBILE_KILLED, group, en);
	}
	else
	{
		//
		// Client - Kill local group if empty
		//

		if (get_local_entity_int_value (group, INT_TYPE_MEMBER_COUNT) == 0)
		{
			kill_local_entity (group);
		}
	}
}
Esempio n. 6
0
static void set_local_vec3d (entity *en, vec3d_types type, vec3d *v)
{
	keysite
		*raw;

	ASSERT (v);

	#if DEBUG_MODULE

	debug_log_entity_args (ENTITY_DEBUG_LOCAL, ENTITY_DEBUG_VEC3D, en, type, v);

	#endif

	raw = (keysite *) get_local_entity_data (en);

	switch (type)
	{
		////////////////////////////////////////
		case VEC3D_TYPE_POSITION:
		////////////////////////////////////////
		{
			int
				old_x_sec,
				old_z_sec,
				new_x_sec,
				new_z_sec;

			entity
				*parent;

			get_x_sector (old_x_sec, raw->position.x);
			get_z_sector (old_z_sec, raw->position.z);

			get_x_sector (new_x_sec, v->x);
			get_z_sector (new_z_sec, v->z);

			if ((old_x_sec != new_x_sec) || (old_z_sec != new_z_sec))
			{
				delete_local_entity_from_parents_child_list (en, LIST_TYPE_SECTOR);

				raw->position = *v;

				parent = get_local_raw_sector_entity (new_x_sec, new_z_sec);

				insert_local_entity_into_parents_child_list (en, LIST_TYPE_SECTOR, parent, NULL);
			}
			else
			{
				raw->position = *v;
			}

			break;
		}
		////////////////////////////////////////
		default:
		////////////////////////////////////////
		{
			debug_fatal_invalid_vec3d_type (en, type);

			break;
		}
	}
}
Esempio n. 7
0
static void kill_local (entity *en)
{

    person
    *raw;

    int
    losses;

    entity
    *task,
    *destroy_task,
    *group;

    ////////////////////////////////////////
    //
    // PRE-AMBLE
    //
    ////////////////////////////////////////

#if DEBUG_MODULE >= 2

    debug_log_entity_args (ENTITY_DEBUG_LOCAL, ENTITY_DEBUG_KILL, en);

#endif

    if (!get_local_entity_int_value (en, INT_TYPE_ALIVE))
    {
        return;
    }

    raw = get_local_entity_data (en);

    ////////////////////////////////////////
    //
    // VALIDATE
    //
    ////////////////////////////////////////

    ////////////////////////////////////////
    //
    // KILL
    //
    ////////////////////////////////////////

    // must be done before alive flag set to FALSE
    remove_mobile_values_from_sector (get_local_entity_parent (en, LIST_TYPE_SECTOR), en);

    set_local_entity_int_value (en, INT_TYPE_ALIVE, FALSE);

    // update person object
    damage_person_3d_object (en);

    group = get_local_entity_parent (en, LIST_TYPE_MEMBER);

    ASSERT (group);

    //
    // group losses
    //

    losses = get_local_entity_int_value (group, INT_TYPE_LOSSES);

    losses ++;

    set_local_entity_int_value (group, INT_TYPE_LOSSES, losses);

    ////////////////////////////////////////
    //
    // DESTROY COMPONENTS
    //
    ////////////////////////////////////////

    if (get_comms_model () == COMMS_MODEL_SERVER)
    {
        ////////////////////////////////////////
        //
        // SEND NOTIFY MESSAGES
        //
        ////////////////////////////////////////

        //
        //
        //

        task = get_local_entity_first_child (en, LIST_TYPE_TASK_DEPENDENT);

        while (task)
        {

            destroy_task = task;

            task = get_local_entity_child_succ (task, LIST_TYPE_TASK_DEPENDENT);

            if (get_local_entity_type (destroy_task) == ENTITY_TYPE_TASK)
            {

#if DEBUG_MODULE

                debug_log ("PS_DSTRY: killing person, notifying task %s complete", entity_sub_type_task_names [get_local_entity_int_value (destroy_task, INT_TYPE_ENTITY_SUB_TYPE)]);

#endif

                notify_local_entity (ENTITY_MESSAGE_TASK_COMPLETED, destroy_task, en);
            }
        }

        //
        // Release landing lock (if any)
        //

        //release_mobile_entity_landing_locks (en);
    }

    ////////////////////////////////////////
    //
    // UNLINK FROM SYSTEM
    //
    ////////////////////////////////////////

    //
    // person
    //

    //
    // vehicle
    //

    unlink_local_entity_children (en, LIST_TYPE_TASK_DEPENDENT);

    unlink_local_entity_children (en, LIST_TYPE_LAUNCHED_WEAPON);

    delete_local_entity_from_parents_child_list (en, LIST_TYPE_MEMBER);

    delete_local_entity_from_parents_child_list (en, LIST_TYPE_FOLLOWER);

    // gunship_target_link

    // member_link

    // view_link

    delete_local_entity_from_parents_child_list (en, LIST_TYPE_TAKEOFF_QUEUE);

    //
    // mobile
    //

    //
    // kill weapon sound effects
    //

    kill_local_entity_sound_type (en, ENTITY_SUB_TYPE_EFFECT_SOUND_CHAIN_GUN);

    //unlink_local_entity_children (en, LIST_TYPE_SPECIAL_EFFECT);

    unlink_local_entity_children (en, LIST_TYPE_TARGET);

    delete_local_entity_from_parents_child_list (en, LIST_TYPE_PADLOCK);

    // sector_link

    delete_local_entity_from_parents_child_list (en, LIST_TYPE_TARGET);

    set_local_entity_int_value (en, INT_TYPE_OPERATIONAL_STATE, OPERATIONAL_STATE_DEAD);

    //
    // Notify Campaign Screen
    //

    notify_campaign_screen (CAMPAIGN_SCREEN_GROUP_REMOVE_MEMBER, group);

    //
    // Notify the GROUP that the mobile has been killed  (N.B. must be done AFTER mobile is unlinked from member list)
    //

    if (get_comms_model () == COMMS_MODEL_SERVER)
    {
        notify_local_entity (ENTITY_MESSAGE_MOBILE_KILLED, group, en);
    }

    ////////////////////////////////////////
    //
    // SPECIAL EFFECTS
    //
    ////////////////////////////////////////

    set_local_entity_float_value (en, FLOAT_TYPE_DEATH_TIMER, calculate_mobile_death_timer_value (en));

    if (get_comms_model () == COMMS_MODEL_SERVER)
    {
        create_client_server_object_killed_explosion_effect (en);
    }
}
Esempio n. 8
0
static void destroy_local (entity *en)
{

	helicopter
		*raw;

	////////////////////////////////////////
	//
	// PRE-AMBLE
	//
	////////////////////////////////////////

	#if DEBUG_MODULE >= 2

	debug_log_entity_args (ENTITY_DEBUG_LOCAL, ENTITY_DEBUG_DESTROY, en);

	#endif

	raw = get_local_entity_data (en);

	set_local_entity_int_value (en, INT_TYPE_ALIVE, FALSE);

	////////////////////////////////////////
	//
	// VALIDATE
	//
	////////////////////////////////////////

	////////////////////////////////////////
	//
	// DESTROY COMPONENTS
	//
	////////////////////////////////////////

	destruct_3d_object (raw->ac.inst3d);

	free_mem (raw->ac.weapon_package_status_array);

	if (raw->ac.sound_effect_data)
	{

		destroy_system_sound_effect (raw->ac.sound_effect_data);
	}

	////////////////////////////////////////
	//
	// UNLINK FROM SYSTEM
	//
	////////////////////////////////////////

	//
	// helicopter
	//

	unlink_local_entity_children (en, LIST_TYPE_GUNSHIP_TARGET);

	unlink_local_entity_children (en, LIST_TYPE_PADLOCK);

	//
	// aircraft
	//

	unlink_local_entity_children (en, LIST_TYPE_AIRCREW);

	unlink_local_entity_children (en, LIST_TYPE_TASK_DEPENDENT);

	unlink_local_entity_children (en, LIST_TYPE_LAUNCHED_WEAPON);

	delete_local_entity_from_parents_child_list (en, LIST_TYPE_FOLLOWER);

	delete_local_entity_from_parents_child_list (en, LIST_TYPE_GUNSHIP_TARGET);

	delete_local_entity_from_parents_child_list (en, LIST_TYPE_MEMBER);

	delete_local_entity_from_parents_child_list (en, LIST_TYPE_MOVEMENT_DEPENDENT);

	delete_local_entity_from_parents_child_list (en, LIST_TYPE_VIEW);

	delete_local_entity_from_parents_child_list (en, LIST_TYPE_TAKEOFF_QUEUE);

	//
	// mobile
	//

	unlink_local_entity_children (en, LIST_TYPE_SPECIAL_EFFECT);

	unlink_local_entity_children (en, LIST_TYPE_TARGET);

	delete_local_entity_from_parents_child_list (en, LIST_TYPE_PADLOCK);

	delete_local_entity_from_parents_child_list (en, LIST_TYPE_SECTOR);

	delete_local_entity_from_parents_child_list (en, LIST_TYPE_TARGET);

	delete_local_entity_from_parents_child_list (en, LIST_TYPE_UPDATE);

	//
	//
	//

	if (en == get_gunship_entity ())
	{
		set_raw_gunship_entity (NULL);
	}

	#if LANDING_ROUTE_CHECK

	destroy_debug_entity_landing_route_check (en);

	#endif

	////////////////////////////////////////
	//
	// FREE ENTITY DATA
	//
	////////////////////////////////////////

	free_mem (raw);

	set_free_entity (en);
}
Esempio n. 9
0
static void destroy_local (entity *en)
{
	force
		*raw;

	////////////////////////////////////////
	//
	// PRE-AMBLE
	//
	////////////////////////////////////////

	#if DEBUG_MODULE

	debug_log_entity_args (ENTITY_DEBUG_LOCAL, ENTITY_DEBUG_DESTROY, en);

	#endif

	raw = get_local_entity_data (en);

	////////////////////////////////////////
	//
	// VALIDATE
	//
	////////////////////////////////////////

	ASSERT (!raw->keysite_force_root.first_child);

	ASSERT (!raw->pilot_root.first_child);

	////////////////////////////////////////
	//
	// DEBUG
	//
	////////////////////////////////////////

	#ifdef DEBUG

	display_task_generation_stats (en);

	#endif

	////////////////////////////////////////
	//
	// DESTROY COMPONENTS
	//
	////////////////////////////////////////

	if (raw->campaign_criteria)
	{

		campaign_criteria_type
			*destroy_campaign_criteria;

		while (raw->campaign_criteria)
		{
	
			destroy_campaign_criteria = raw->campaign_criteria;
	
			raw->campaign_criteria = raw->campaign_criteria->next;

			free_mem (destroy_campaign_criteria);
		}
	}

	////////////////////////////////////////
	//
	// UNLINK FROM SYSTEM
	//
	////////////////////////////////////////

	unlink_local_entity_children (en, LIST_TYPE_DIVISION);

	unlink_local_entity_children (en, LIST_TYPE_INDEPENDENT_GROUP);

	delete_local_entity_from_parents_child_list (en, LIST_TYPE_FORCE);

	delete_local_entity_from_parents_child_list (en, LIST_TYPE_UPDATE);

	////////////////////////////////////////
	//
	// FREE ENTITY DATA
	//
	////////////////////////////////////////

	free_mem (raw);

	set_free_entity (en);
}
Esempio n. 10
0
static void destroy_local (entity *en)
{

	ship_vehicle
		*raw;

	////////////////////////////////////////
	//
	// PRE-AMBLE
	//
	////////////////////////////////////////

	#if DEBUG_MODULE >= 2

	debug_log_entity_args (ENTITY_DEBUG_LOCAL, ENTITY_DEBUG_DESTROY, en);

	#endif

	raw = (ship_vehicle *) get_local_entity_data (en);

	set_local_entity_int_value (en, INT_TYPE_ALIVE, FALSE);

	////////////////////////////////////////
	//
	// VALIDATE
	//
	////////////////////////////////////////

	////////////////////////////////////////
	//
	// DESTROY COMPONENTS
	//
	////////////////////////////////////////

	destruct_3d_object (raw->vh.inst3d);

	free_mem (raw->vh.weapon_package_status_array);

	if (raw->vh.sound_effect_data)
	{

		destroy_system_sound_effect (raw->vh.sound_effect_data);
	}

	////////////////////////////////////////
	//
	// UNLINK FROM SYSTEM
	//
	////////////////////////////////////////

	//
	// ship_vehicle
	//

	//
	// vehicle
	//

	unlink_local_entity_children (en, LIST_TYPE_TASK_DEPENDENT);

	unlink_local_entity_children (en, LIST_TYPE_LAUNCHED_WEAPON);

	unlink_local_entity_children (en, LIST_TYPE_MOVEMENT_DEPENDENT);

	delete_local_entity_from_parents_child_list (en, LIST_TYPE_MOVEMENT_DEPENDENT);

	delete_local_entity_from_parents_child_list (en, LIST_TYPE_FOLLOWER);

	delete_local_entity_from_parents_child_list (en, LIST_TYPE_DESIGNATED_TARGET); // Jabberwock 031107 Designated targets

	delete_local_entity_from_parents_child_list (en, LIST_TYPE_GUNSHIP_TARGET);

	delete_local_entity_from_parents_child_list (en, LIST_TYPE_MEMBER);

	delete_local_entity_from_parents_child_list (en, LIST_TYPE_VIEW);

	delete_local_entity_from_parents_child_list (en, LIST_TYPE_TAKEOFF_QUEUE);

	//
	// mobile
	//

	unlink_local_entity_children (en, LIST_TYPE_SPECIAL_EFFECT);

	unlink_local_entity_children (en, LIST_TYPE_TARGET);

	delete_local_entity_from_parents_child_list (en, LIST_TYPE_PADLOCK);

	delete_local_entity_from_parents_child_list (en, LIST_TYPE_SECTOR);

	delete_local_entity_from_parents_child_list (en, LIST_TYPE_TARGET);

	delete_local_entity_from_parents_child_list (en, LIST_TYPE_UPDATE);

	#if LANDING_ROUTE_CHECK

	destroy_debug_entity_landing_route_check (en);

	#endif

	////////////////////////////////////////
	//
	// FREE ENTITY DATA
	//
	////////////////////////////////////////

	free_mem (raw);

	set_free_entity (en);
}
Esempio n. 11
0
static void destroy_local (entity *en)
{
	segment
		*raw;

	////////////////////////////////////////
	//
	// PRE-AMBLE
	//
	////////////////////////////////////////

	#if DEBUG_MODULE

	debug_log_entity_args (ENTITY_DEBUG_LOCAL, ENTITY_DEBUG_DESTROY, en);

	debug_log ("SG_DSTRY: destroying segment %d", get_local_entity_index (en));

	#endif

	raw = (segment *) get_local_entity_data (en);

	////////////////////////////////////////
	//
	// VALIDATE
	//
	////////////////////////////////////////

	////////////////////////////////////////
	//
	// DESTROY COMPONENTS
	//
	////////////////////////////////////////

	////////////////////////////////////////
	//
	// UNLINK FROM SYSTEM
	//
	////////////////////////////////////////

	//
	// fixed
	//

	unlink_local_entity_children (en, LIST_TYPE_TASK_DEPENDENT);

	unlink_local_entity_children (en, LIST_TYPE_TARGET);

	delete_local_entity_from_parents_child_list (en, LIST_TYPE_DESIGNATED_TARGET);

	delete_local_entity_from_parents_child_list (en, LIST_TYPE_GUNSHIP_TARGET);

	delete_local_entity_from_parents_child_list (en, LIST_TYPE_SECTOR);

	//
	// segment
	//

	delete_local_entity_from_parents_child_list (en, LIST_TYPE_SEGMENT);

	delete_local_entity_from_parents_child_list (en, LIST_TYPE_UPDATE);

	////////////////////////////////////////
	//
	// FREE ENTITY DATA
	//
	////////////////////////////////////////

	free_mem (raw);

	set_free_entity (en);
}
Esempio n. 12
0
static void set_local_vec3d (entity *en, vec3d_types type, vec3d *v)
{
	weapon
		*raw;

	ASSERT (v);

	#if DEBUG_MODULE

	debug_log_entity_args (ENTITY_DEBUG_LOCAL, ENTITY_DEBUG_VEC3D, en, type, v);

	#endif

	raw = get_local_entity_data (en);

	switch (type)
	{
		////////////////////////////////////////
		case VEC3D_TYPE_POSITION:
		////////////////////////////////////////
		{
			entity
				*special_effect,
				*old_sector,
				*new_sector;

			raw->mob.position = *v;

			old_sector = get_local_entity_parent (en, LIST_TYPE_SECTOR);

			new_sector = get_local_sector_entity (v);

			if (old_sector != new_sector)
			{
				delete_local_entity_from_parents_child_list (en, LIST_TYPE_SECTOR);

				insert_local_entity_into_parents_child_list (en, LIST_TYPE_SECTOR, new_sector, NULL);
			}

			//
			// notify special effects of move
			//

			special_effect = get_local_entity_first_child (en, LIST_TYPE_SPECIAL_EFFECT);

			while (special_effect)
			{
				#if DEBUG_MODULE

				debug_log ("WEAPON VEC3D: sending set entity position %f, %f, %f", raw->mob.position.x, raw->mob.position.y, raw->mob.position.z);

				#endif

				notify_local_entity (ENTITY_MESSAGE_SET_ENTITY_POSITION, special_effect, en, &raw->mob.position, 0.0, 0.0);

				special_effect = get_local_entity_child_succ (special_effect, LIST_TYPE_SPECIAL_EFFECT);
			}

			break;
		}
		////////////////////////////////////////
		default:
		////////////////////////////////////////
		{
			debug_fatal_invalid_vec3d_type (en, type);

			break;
		}
	}
}
Esempio n. 13
0
static void set_local_vec3d (entity *en, vec3d_types type, vec3d *v)
{
   aircraft
      *raw;

   ASSERT (v);

   #if DEBUG_MODULE

   debug_log_entity_args (ENTITY_DEBUG_LOCAL, ENTITY_DEBUG_VEC3D, en, type, v);

   #endif

   raw = (aircraft *) get_local_entity_data (en);

   switch (type)
   {
      ////////////////////////////////////////
      case VEC3D_TYPE_MOTION_VECTOR:
      ////////////////////////////////////////
      {
         raw->mob.motion_vector = *v;

         break;
      }
      ////////////////////////////////////////
      case VEC3D_TYPE_POSITION:
      ////////////////////////////////////////
      {

         float
            heading;

         entity
				*dependent,
				*special_effect,
				*old_sector,
				*new_sector;

			//
			// notify dependents of move, must be done before set_vec3d so children can work out delta positions
			//

         heading = 0.0;

			//if (get_local_entity_type (en) == ENTITY_TYPE_HELICOPTER)
			{

				heading = get_heading_from_attitude_matrix (raw->mob.attitude);
	
				dependent = get_local_entity_first_child (en, LIST_TYPE_MOVEMENT_DEPENDENT);
	
				while (dependent)
				{
					#if DEBUG_MODULE_AIRCRAFT_POSITION_MESSAGE
	
					debug_log ("AIRCRAFT VEC3D: sending set entity position %f, %f, %f", raw->mob.position.x, raw->mob.position.y, raw->mob.position.z);
	
					#endif
	
					notify_local_entity (ENTITY_MESSAGE_SET_ENTITY_POSITION, dependent, en, v, (double) heading, (double) raw->mob.velocity);
	
					dependent = get_local_entity_child_succ (dependent, LIST_TYPE_MOVEMENT_DEPENDENT);
				}
			}

			//
			// Actual set_vec3d
			//

         raw->mob.position = *v;

			//
			// check if entered new sector
			//

			old_sector = get_local_entity_parent (en, LIST_TYPE_SECTOR);

			new_sector = get_local_sector_entity (v);

         if (old_sector != new_sector)
         {
            delete_local_entity_from_parents_child_list (en, LIST_TYPE_SECTOR);

            insert_local_entity_into_parents_child_list (en, LIST_TYPE_SECTOR, new_sector, NULL);

				//
				// play speech for flown across "front-line"
				//

				if (get_comms_model () == COMMS_MODEL_SERVER)
				{
					if (get_local_entity_int_value (new_sector, INT_TYPE_SIDE) != get_local_entity_int_value (old_sector, INT_TYPE_SIDE))
					{
						play_aircraft_flown_into_new_sector_speech (en, old_sector, new_sector);
					}
				}
         }

			//
			// notify special effects of move
			//

			special_effect = get_local_entity_first_child (en, LIST_TYPE_SPECIAL_EFFECT);

			while (special_effect)
			{
				#if DEBUG_MODULE_AIRCRAFT_POSITION_MESSAGE

				debug_log ("AIRCRAFT VEC3D: sending set entity position %f, %f, %f", raw->mob.position.x, raw->mob.position.y, raw->mob.position.z);

				#endif

				notify_local_entity (ENTITY_MESSAGE_SET_ENTITY_POSITION, special_effect, en, &raw->mob.position, (double) heading, (double) raw->mob.velocity);

				special_effect = get_local_entity_child_succ (special_effect, LIST_TYPE_SPECIAL_EFFECT);
			}

         break;
      }
      ////////////////////////////////////////
      case VEC3D_TYPE_WEAPON_TO_TARGET_VECTOR:
      ////////////////////////////////////////
      {
         raw->weapon_to_target_vector = *v;

         break;
      }
      ////////////////////////////////////////
      case VEC3D_TYPE_WEAPON_VECTOR:
      ////////////////////////////////////////
      {
         raw->weapon_vector = *v;

         break;
      }
      ////////////////////////////////////////
      default:
      ////////////////////////////////////////
      {
         debug_fatal_invalid_vec3d_type (en, type);

         break;
      }
   }
}
Esempio n. 14
0
static void kill_local (entity *en)
{

	int
		losses;

	routed_vehicle
		*raw;

	entity
		*task,
		*destroy_task,
		*group;

	////////////////////////////////////////
	//
	// PRE-AMBLE
	//
	////////////////////////////////////////

	#if DEBUG_MODULE >= 2

	debug_log_entity_args (ENTITY_DEBUG_LOCAL, ENTITY_DEBUG_KILL, en);

	#endif

	if (!get_local_entity_int_value (en, INT_TYPE_ALIVE))
	{
		return;
	}

	raw = get_local_entity_data (en);

	group = get_local_entity_parent (en, LIST_TYPE_MEMBER);

	ASSERT (group);

	//
	// update force info
	//

	remove_from_force_info (get_local_force_entity (raw->vh.mob.side), en);

	////////////////////////////////////////
	//
	// VALIDATE
	//
	////////////////////////////////////////

	////////////////////////////////////////
	//
	// DESTROY COMPONENTS
	//
	////////////////////////////////////////

	if (get_comms_model () == COMMS_MODEL_SERVER)
	{
		////////////////////////////////////////
		//
		// SEND NOTIFY MESSAGES
		//
		////////////////////////////////////////

		// notify regen of kill

		add_entity_to_regen_queue
		(
			get_local_entity_int_value(en, INT_TYPE_SIDE),
			get_local_entity_type(en),
			get_local_entity_int_value (en, INT_TYPE_ENTITY_SUB_TYPE),
			get_local_entity_int_value (group, INT_TYPE_ENTITY_SUB_TYPE)
		);

		//
		//
		//

		task = get_local_entity_first_child (en, LIST_TYPE_TASK_DEPENDENT);

		while (task)
		{

			destroy_task = task;

			task = get_local_entity_child_succ (task, LIST_TYPE_TASK_DEPENDENT);

			if (get_local_entity_type (destroy_task) == ENTITY_TYPE_TASK)
			{

				#if DEBUG_MODULE

				debug_log ("RV_DSTRY: killing routed vehicle, notifying task %s complete", entity_sub_type_task_names [get_local_entity_int_value (destroy_task, INT_TYPE_ENTITY_SUB_TYPE)]);

				#endif

				notify_local_entity (ENTITY_MESSAGE_TASK_COMPLETED, destroy_task, en, TASK_TERMINATED_OBJECTIVE_MESSAGE);
			}
		}

		//
		// Release landing lock (if any)
		//

		release_mobile_entity_landing_locks (en);
	}

	////////////////////////////////////////
	//
	// UNLINK FROM SYSTEM
	//
	////////////////////////////////////////

	//
	// routed_vehicle
	//

	//
	// vehicle
	//

	unlink_local_entity_children (en, LIST_TYPE_TASK_DEPENDENT);

	unlink_local_entity_children (en, LIST_TYPE_MOVEMENT_DEPENDENT);

	#if DEBUG_MODULE

	debug_log ("RV_DSTRY: removing member %d from group %d", get_local_entity_index (en), get_local_entity_index (raw->vh.member_link.parent));

	#endif

	delete_local_entity_from_parents_child_list (en, LIST_TYPE_MEMBER);

	delete_local_entity_from_parents_child_list (en, LIST_TYPE_MOVEMENT_DEPENDENT);

	delete_local_entity_from_parents_child_list (en, LIST_TYPE_FOLLOWER);

	// gunship_target_link

	// member_link

	// view_link

	delete_local_entity_from_parents_child_list (en, LIST_TYPE_TAKEOFF_QUEUE);

	//
	// mobile
	//

	//
	// kill weapon sound effects
	//

	kill_local_entity_sound_type (en, ENTITY_SUB_TYPE_EFFECT_SOUND_CHAIN_GUN);

	//
	// kill engine sound effects
	//

	kill_local_entity_sound_type (en, ENTITY_SUB_TYPE_EFFECT_SOUND_ENGINE_LOOPING1);
	kill_local_entity_sound_type (en, ENTITY_SUB_TYPE_EFFECT_SOUND_ENGINE_LOOPING2);

	unlink_local_entity_children (en, LIST_TYPE_TARGET);

	delete_local_entity_from_parents_child_list (en, LIST_TYPE_PADLOCK);

	// sector_link

	delete_local_entity_from_parents_child_list (en, LIST_TYPE_TARGET);

	// update_link

	set_local_entity_int_value (en, INT_TYPE_OPERATIONAL_STATE, OPERATIONAL_STATE_DYING);

	////////////////////////////////////////
	//
	// KILL
	//
	////////////////////////////////////////

	// must be done before alive flag set to FALSE
	remove_mobile_values_from_sector (get_local_entity_parent (en, LIST_TYPE_SECTOR), en);

	set_local_entity_int_value (en, INT_TYPE_ALIVE, FALSE);

	damage_routed_vehicle_3d_object (en);

	//
	// group losses
	//

	losses = get_local_entity_int_value (group, INT_TYPE_LOSSES);

	losses ++;

	set_local_entity_int_value (group, INT_TYPE_LOSSES, losses);

	//
	// task losses
	//

	task = get_local_group_primary_task (group);

	if (task)
	{
		losses = get_local_entity_int_value (task, INT_TYPE_LOSSES);

		losses ++;

		set_local_entity_int_value (task, INT_TYPE_LOSSES, losses);
	}

	//
	// Notify Campaign Screen
	//

	notify_campaign_screen (CAMPAIGN_SCREEN_GROUP_REMOVE_MEMBER, group);

	//
	// Notify the GROUP that the mobile has been killed  (N.B. must be done AFTER mobile is unlinked from member list)
	//

	if (get_comms_model () == COMMS_MODEL_SERVER)
	{
		notify_local_entity (ENTITY_MESSAGE_MOBILE_KILLED, group, en);
	}

	////////////////////////////////////////
	//
	// SPECIAL EFFECTS
	//
	////////////////////////////////////////

	set_local_entity_float_value (en, FLOAT_TYPE_DEATH_TIMER, calculate_mobile_death_timer_value (en));

	routed_vehicle_impact_movement (en);

	if (get_comms_model () == COMMS_MODEL_SERVER)
	{
		create_client_server_object_killed_explosion_effect (en);
	}

	#if LANDING_ROUTE_CHECK

	destroy_debug_entity_landing_route_check (en);

	#endif

	/////////////////////////////////////////////////////////////////
	//
	// SPECIAL_EFFECT_HOOK FOR BEING_DESTROYED
	//
	////////////////////////////////////////////////////////////////

	/////////////////////////////////////////////////////////////////
	//
	//
	/////////////////////////////////////////////////////////////////
}
Esempio n. 15
0
entity *push_task_onto_group_task_stack (entity *group, entity *task, unsigned int valid_members)
{
	entity
		*task_parent,
		*guide;

	list_types
		list_type;

	#ifdef DEBUG
	
	unsigned int
		total_members,
		member_number;

	#endif

	ASSERT (get_comms_model () == COMMS_MODEL_SERVER);

	ASSERT (group);

	#ifdef DEBUG

	total_members = 0;

	//
	// Check not already on stack
	//

	guide = get_local_entity_first_child (task, LIST_TYPE_GUIDE);

	while (guide)
	{
		if (get_local_entity_parent (guide, LIST_TYPE_GUIDE_STACK) == group)
		{
			member_number = get_local_entity_int_value (guide, INT_TYPE_VALID_GUIDE_MEMBERS);

			total_members |= member_number;
		}

		guide = get_local_entity_child_succ (guide, LIST_TYPE_GUIDE);
	}

	//
	// A TASK may be on the stack many times, but any one member should not have the same task duplicated
	// e.g. ENGAGE tasks may be duplicated many times, but their guide "valid_members" should all be exclusive
	//

	if (valid_members & total_members)
	{
		debug_filtered_log ("Trying to assign task %s (%d) to group %s - members %d",
										get_local_entity_string (task, STRING_TYPE_FULL_NAME),
										get_local_entity_index (task),
										get_local_entity_string (group, STRING_TYPE_FULL_NAME),
										valid_members);

		debug_filtered_log ("");

		dump_guide_stack (group);

		debug_fatal ("ASSIGN: Task %s already on Group %s guide stack",
								get_local_entity_string (task, STRING_TYPE_FULL_NAME),
								get_local_entity_string (group, STRING_TYPE_FULL_NAME));
	}

	#endif

	//
	// create guide entity for task
	//

	guide = create_client_server_guide_entity (task, NULL, valid_members);

	attach_group_to_guide_entity (group, guide);

	//
	// remove task and group from lists (must be done AFTER guide is created and attached)
	//

	list_type = get_local_task_list_type (task);

	if (list_type == LIST_TYPE_UNASSIGNED_TASK)
	{
		task_parent = get_local_entity_parent (task, list_type);

		if (task_parent)
		{
			delete_local_entity_from_parents_child_list (task, list_type);

			//
			// add task to assigned task list, if not already on it.
			//

			insert_local_entity_into_parents_child_list (task, LIST_TYPE_ASSIGNED_TASK, task_parent, NULL);

			transmit_entity_comms_message (ENTITY_COMMS_SWITCH_LIST, task, LIST_TYPE_UNASSIGNED_TASK, task_parent, LIST_TYPE_ASSIGNED_TASK);
		}
	}

	return guide;
}
Esempio n. 16
0
static void kill_local (entity *en)
{

	int
		losses;

	entity
		*task,
		*group,
		*destroy_task;

	fixed_wing
		*raw;

	////////////////////////////////////////
	//
	// PRE-AMBLE
	//
	////////////////////////////////////////

	#if DEBUG_MODULE >= 2

	debug_log_entity_args (ENTITY_DEBUG_LOCAL, ENTITY_DEBUG_KILL, en);

	#endif

	if (!get_local_entity_int_value (en, INT_TYPE_ALIVE))
	{
		return;
	}

	raw = (fixed_wing *) get_local_entity_data (en);

	group = get_local_entity_parent (en, LIST_TYPE_MEMBER);

	ASSERT (group);

	//
	// update force info
	//

	remove_from_force_info (get_local_force_entity ((entity_sides) raw->ac.mob.side), en);

	if (tacview_is_logging())
		write_tacview_unit_event(en, TACVIEW_UNIT_DESTROYED, NULL);

	////////////////////////////////////////
	//
	// VALIDATE
	//
	////////////////////////////////////////

	////////////////////////////////////////
	//
	// SEND NOTIFY MESSAGES
	//
	////////////////////////////////////////

	if (get_comms_model () == COMMS_MODEL_SERVER)
	{
		// notify regen of kill

		add_entity_to_regen_queue
		(
			(entity_sides) get_local_entity_int_value(en, INT_TYPE_SIDE),
			get_local_entity_type(en),
			get_local_entity_int_value (en, INT_TYPE_ENTITY_SUB_TYPE),
			get_local_entity_int_value (group, INT_TYPE_ENTITY_SUB_TYPE)
		);

		task = get_local_entity_first_child (en, LIST_TYPE_TASK_DEPENDENT);

		while (task)
		{

			destroy_task = task;

			task = get_local_entity_child_succ (task, LIST_TYPE_TASK_DEPENDENT);

			if (destroy_task->type == ENTITY_TYPE_TASK)
			{

				#if DEBUG_MODULE

				debug_log ("FW_DSTRY: killing fixed wing, notifying task %s complete", entity_sub_type_task_names [get_local_entity_int_value (destroy_task, INT_TYPE_ENTITY_SUB_TYPE)]);

				#endif

				notify_local_entity (ENTITY_MESSAGE_TASK_COMPLETED, destroy_task, en, TASK_TERMINATED_OBJECTIVE_MESSAGE);
			}
		}

		//
		// Release landing lock (if any)
		//

		release_mobile_entity_landing_locks (en);
	}

	////////////////////////////////////////
	//
	// UNLINK FROM SYSTEM
	//
	////////////////////////////////////////

	//
	// fixed_wing
	//

	//
	// aircraft
	//

	// aircrew_root

	unlink_local_entity_children (en, LIST_TYPE_TASK_DEPENDENT);

	// unlink_local_entity_children (en, LIST_TYPE_LAUNCHED_WEAPON);

	delete_local_entity_from_parents_child_list (en, LIST_TYPE_FOLLOWER);

	delete_local_entity_from_parents_child_list (en, LIST_TYPE_MEMBER);

	// gunship_target_link

	// member_link

	// view_link

	delete_local_entity_from_parents_child_list (en, LIST_TYPE_TAKEOFF_QUEUE);

	//
	// mobile
	//

	//
	// kill weapon sound effects
	//

	kill_local_entity_sound_type (en, ENTITY_SUB_TYPE_EFFECT_SOUND_CHAIN_GUN);

	//
	// kill engine sound effects
	//

	kill_local_entity_sound_type (en, ENTITY_SUB_TYPE_EFFECT_SOUND_ENGINE_LOOPING1);
	kill_local_entity_sound_type (en, ENTITY_SUB_TYPE_EFFECT_SOUND_ENGINE_LOOPING2);

	//
	// Kill speech
	//

	notify_speech_buffers_entity_killed (en);

	// special_effect root

	unlink_local_entity_children (en, LIST_TYPE_TARGET);

	delete_local_entity_from_parents_child_list (en, LIST_TYPE_PADLOCK);

	// sector_link

	delete_local_entity_from_parents_child_list (en, LIST_TYPE_TARGET);

	// update_link

	set_local_entity_int_value (en, INT_TYPE_OPERATIONAL_STATE, OPERATIONAL_STATE_DYING);

	//
	// death timer (set time after which entity is totally destroyed)
	//

	set_local_entity_float_value (en, FLOAT_TYPE_DEATH_TIMER, calculate_mobile_death_timer_value (en));

	////////////////////////////////////////
	//
	// KILL
	//
	////////////////////////////////////////

	damage_fixed_wing_3d_object (en);

	// must be done before alive flag set to FALSE
	remove_mobile_values_from_sector (get_local_entity_parent (en, LIST_TYPE_SECTOR), en);

	set_local_entity_int_value (en, INT_TYPE_ALIVE, FALSE);

	//
	// group losses
	//

	losses = get_local_entity_int_value (group, INT_TYPE_LOSSES);

	losses ++;

	set_local_entity_int_value (group, INT_TYPE_LOSSES, losses);

	//
	// task losses
	//

	task = get_local_group_primary_task (group);

	if (task)
	{
		losses = get_local_entity_int_value (task, INT_TYPE_LOSSES);

		losses ++;

		set_local_entity_int_value (task, INT_TYPE_LOSSES, losses);
	}

	//
	// Notify Campaign Screen
	//

	notify_campaign_screen (CAMPAIGN_SCREEN_GROUP_REMOVE_MEMBER, group);

	//
	// Notify the GROUP that the mobile has been killed  (N.B. must be done AFTER mobile is unlinked from member list)
	//

	if (get_comms_model () == COMMS_MODEL_SERVER)
	{
		notify_local_entity (ENTITY_MESSAGE_MOBILE_KILLED, group, en);
	}

	////////////////////////////////////////
	//
	// SPECIAL EFFECTS
	//
	////////////////////////////////////////

	set_local_fixed_wing_afterburner_state (en, OFF);

	fixed_wing_impact_movement (en);

	if (get_comms_model () == COMMS_MODEL_SERVER)
	{
		vec3d
			*position;

		sound_sample_indices
			sound_sample_index;

		create_client_server_object_killed_explosion_effect (en);

		position = get_local_entity_vec3d_ptr (en, VEC3D_TYPE_POSITION);

		sound_sample_index = SOUND_SAMPLE_INDEX_SHOT_DOWN_AIRCRAFT;

		create_client_server_sound_effect_entity
		(
			en,
			ENTITY_SIDE_NEUTRAL,
			ENTITY_SUB_TYPE_EFFECT_SOUND_ENGINE_LOOPING1,
			SOUND_CHANNEL_SOUND_EFFECT,
			SOUND_LOCALITY_ALL,
			NULL,												// position
			1.0,												// amplification
			1.0,												// Werewolf pitch
			TRUE,												// valid sound effect
			TRUE,												// looping
			1,													// sample count
			&sound_sample_index							// sample index list
		);
	}

	#if LANDING_ROUTE_CHECK

	destroy_debug_entity_landing_route_check (en);

	#endif

	/////////////////////////////////////////////////////////////////
	//
	// SPECIAL_EFFECT_HOOK FOR BEING_DESTROYED
	//
	/////////////////////////////////////////////////////////////////

	/////////////////////////////////////////////////////////////////
	//
	//
	/////////////////////////////////////////////////////////////////
}
Esempio n. 17
0
static void kill_local (entity *en)
{
	site_updatable
		*raw;

	vec3d
		pos;

	entity
		*task,
		*destroy_task;

	////////////////////////////////////////
	//
	// PRE-AMBLE
	//
	////////////////////////////////////////

	#if DEBUG_MODULE

	debug_log_entity_args (ENTITY_DEBUG_LOCAL, ENTITY_DEBUG_KILL, en);

	#endif

	raw = (site_updatable *) get_local_entity_data (en);

	////////////////////////////////////////
	//
	// UNLINK FROM SYSTEM
	//
	////////////////////////////////////////

	if (get_comms_model () == COMMS_MODEL_SERVER)
	{
		task = get_local_entity_first_child (en, LIST_TYPE_TASK_DEPENDENT);

		while (task)
		{

			destroy_task = task;

			task = get_local_entity_child_succ (task, LIST_TYPE_TASK_DEPENDENT);

			if (destroy_task->type == ENTITY_TYPE_TASK)
			{

				#if DEBUG_MODULE

				debug_log ("SU_DSTRY: killing siteupdt, notifying task %s complete", entity_sub_type_task_names [get_local_entity_int_value (destroy_task, INT_TYPE_ENTITY_SUB_TYPE)]);

				#endif

				notify_local_entity (ENTITY_MESSAGE_TASK_COMPLETED, destroy_task, en, TASK_TERMINATED_OBJECTIVE_MESSAGE);
			}
		}
	}

	//
	// fixed
	//

	unlink_local_entity_children (en, LIST_TYPE_TASK_DEPENDENT);

	unlink_local_entity_children (en, LIST_TYPE_TARGET);

	// gunship_target_link

	// sector_link

	//
	// site
	//

	delete_local_entity_from_parents_child_list (en, LIST_TYPE_UPDATE);

	////////////////////////////////////////
	//
 	// KILL
	//
	////////////////////////////////////////

	// must be done BEFORE alive flag set
	subtract_local_entity_importance_from_keysite (en);

	set_local_entity_int_value (en, INT_TYPE_ALIVE, FALSE);

	////////////////////////////////////////
	//
	// SPECIAL EFFECTS
	//
	////////////////////////////////////////

	if (get_comms_model () == COMMS_MODEL_SERVER)
	{
		create_client_server_object_killed_explosion_effect (en);

		get_local_entity_vec3d (en, VEC3D_TYPE_POSITION, &pos);

		pos.y = get_3d_terrain_elevation (pos.x, pos.z);

		create_client_server_crater (CRATER_TYPE_LARGE_EXPLOSION, &pos);
	}

	//
	// must be done AFTER object explosion
	//

	raw->fix.object_3d_shape = get_3d_object_destroyed_object_index (raw->fix.object_3d_shape);
}
Esempio n. 18
0
void update_vector_altitude_dynamics (void)
{

	static float
		last_ground_height = 0;

	matrix3x3
		attitude;

	float
		heading,
		pitch,
		roll,
		ground_height,
		centre_of_gravity_to_ground_distance;

	vec3d
		position,
		*face_normal;

	centre_of_gravity_to_ground_distance = get_local_entity_float_value (get_gunship_entity (), FLOAT_TYPE_CENTRE_OF_GRAVITY_TO_GROUND_DISTANCE);

	get_local_entity_attitude_matrix (get_gunship_entity (), attitude);

	ground_height = get_local_entity_float_value (get_gunship_entity (), FLOAT_TYPE_TERRAIN_ELEVATION);

	//
	// debug
	//

	if ((ground_height < -1000) || (ground_height > 32000))
	{

		debug_log ("!!!!!!!!!!!!!! GROUND HEIGHT %f", ground_height);

		ground_height = last_ground_height;
	}

	//
	// end
	//

	last_ground_height = ground_height;

	current_flight_dynamics->altitude.value = current_flight_dynamics->position.y;

	current_flight_dynamics->altitude.min = ground_height;

	switch (get_local_entity_int_value (get_gunship_entity (), INT_TYPE_OPERATIONAL_STATE))
	{

		case OPERATIONAL_STATE_LANDED:
		{

			if (current_flight_dynamics->world_velocity_y.value > 0.0)
			{
		
				#if DEBUG_DYNAMICS
		
				debug_log ("VECTOR DYN: takeoff !");
		
				#endif
		
				set_local_entity_int_value (get_gunship_entity (), INT_TYPE_OPERATIONAL_STATE, OPERATIONAL_STATE_NAVIGATING);
		
				delete_local_entity_from_parents_child_list (get_gunship_entity (), LIST_TYPE_CURRENT_WAYPOINT);
		
				transmit_entity_comms_message (ENTITY_COMMS_MOBILE_TAKEOFF, get_gunship_entity ());
			}
			else
			{

				entity
					*wp;

				vec3d
					wp_pos;

				wp = get_local_entity_parent (get_gunship_entity (), LIST_TYPE_CURRENT_WAYPOINT);

				if (wp)
				{

					get_local_waypoint_formation_position (get_local_entity_int_value (get_gunship_entity (), INT_TYPE_FORMATION_POSITION), wp, &wp_pos);

					ground_height = wp_pos.y;
				}
	
				current_flight_dynamics->world_velocity_y.value = max (current_flight_dynamics->world_velocity_y.value, 0.0);

				current_flight_dynamics->velocity_y.value = max (current_flight_dynamics->velocity_y.value, 0.0);
				
				memset (&current_flight_dynamics->world_motion_vector, 0, sizeof (vec3d));
			
				current_flight_dynamics->velocity_x.value = bound (current_flight_dynamics->velocity_x.value, knots_to_metres_per_second (-10), knots_to_metres_per_second (50));
				current_flight_dynamics->velocity_y.value = 0;
				current_flight_dynamics->velocity_z.value = bound (current_flight_dynamics->velocity_z.value, knots_to_metres_per_second (-10), knots_to_metres_per_second (50));
			
				current_flight_dynamics->position.y = ground_height + centre_of_gravity_to_ground_distance;
			
				current_flight_dynamics->altitude.value = ground_height + centre_of_gravity_to_ground_distance;
				
				heading = get_heading_from_attitude_matrix (attitude);
			
				//get_3d_terrain_face_normal (&n, current_flight_dynamics->position.x, current_flight_dynamics->position.z);
				face_normal = get_local_entity_ptr_value (get_gunship_entity (), PTR_TYPE_TERRAIN_FACE_NORMAL);
			
				get_3d_transformation_matrix_from_face_normal_and_heading (attitude, face_normal, heading);
				
				pitch = get_pitch_from_attitude_matrix (attitude);
			
				pitch += rad (aircraft_database [ENTITY_SUB_TYPE_AIRCRAFT_AH64D_APACHE_LONGBOW].fuselage_angle);
			
				roll = get_roll_from_attitude_matrix (attitude);
			
				get_3d_transformation_matrix (attitude, heading, pitch, roll);

				position.x = current_flight_dynamics->position.x;
				position.y = current_flight_dynamics->position.y;
				position.z = current_flight_dynamics->position.z;
			
				set_local_entity_vec3d (get_gunship_entity (), VEC3D_TYPE_POSITION, &position);
			
				set_local_entity_attitude_matrix (get_gunship_entity (), attitude);
			}

			break;
		}

		default:
		{
	
			if (current_flight_dynamics->world_velocity_y.value < 0.0)
			{
	
				if (current_flight_dynamics->altitude.value < current_flight_dynamics->altitude.min + centre_of_gravity_to_ground_distance)
				{
			
					if (get_local_entity_int_value (get_gunship_entity (), INT_TYPE_OPERATIONAL_STATE) != OPERATIONAL_STATE_LANDED)
					{
			
						//
						// need to find what wp the user is trying to land on ....
						//
			
						//entity
							//*wp;
				
						#if DEBUG_DYNAMICS
				
						debug_log ("VECTOR DYN: landed !");
				
						#endif
				
						set_local_entity_int_value (get_gunship_entity (), INT_TYPE_OPERATIONAL_STATE, OPERATIONAL_STATE_LANDED);
			
						//transmit_entity_comms_message (ENTITY_COMMS_MOBILE_LAND, get_gunship_entity (), wp);
					}
				}
			}
		
			break;
		}
	}

	current_flight_dynamics->altitude.value = bound (
														current_flight_dynamics->altitude.value,
														current_flight_dynamics->altitude.min,
														current_flight_dynamics->altitude.max);
}
Esempio n. 19
0
void unpack_local_keysite_data (pack_modes mode)
{
   entity
      *en,
		*landing_en;

	landing
		*landing_raw;

   keysite
      *raw;

	int
		side,
		landing_lock,
		landed_lock,
		takeoff_lock,
		in_use,
		index;

   ASSERT (mode != PACK_MODE_UPDATE_ENTITY);

   if (mode == PACK_MODE_BROWSE_SESSION)
   {
      return;
   }

	en = get_local_entity_list ();

	while (en)
	{

		if (get_local_entity_type (en) == ENTITY_TYPE_KEYSITE)
		{

			//
			// unpack keysite
			//

			index = unpack_entity_safe_index ();

			raw = (keysite *) get_local_entity_data (en);

			raw->supplies.ammo_supply_level = unpack_float_value (en, FLOAT_TYPE_AMMO_SUPPLY_LEVEL);

			raw->supplies.fuel_supply_level = unpack_float_value (en, FLOAT_TYPE_FUEL_SUPPLY_LEVEL);

			raw->keysite_strength = unpack_float_value (en, FLOAT_TYPE_KEYSITE_STRENGTH);

			raw->keysite_maximum_strength = unpack_float_value (en, FLOAT_TYPE_KEYSITE_MAXIMUM_STRENGTH);

			raw->alive = unpack_int_value (en, INT_TYPE_ALIVE);

			side = unpack_int_value (en, INT_TYPE_SIDE);

			if (side != raw->side)
			{
				//
				// update I-Maps (remove old side)
				//

				if (raw->in_use)
				{
					update_imap_sector_side (en, FALSE);

					if (mode == PACK_MODE_SERVER_SESSION)
					{
						update_imap_importance_level (en, FALSE);
					}
				}

				//
				// change side of keysite buildings
				//

				change_local_keysite_building_sides (en, (entity_sides) side);

				//
				// place into other sides force
				//

				delete_local_entity_from_parents_child_list (en, LIST_TYPE_KEYSITE_FORCE);

				insert_local_entity_into_parents_child_list (en, LIST_TYPE_KEYSITE_FORCE, get_local_force_entity ((entity_sides) side), NULL);

				if (mode == PACK_MODE_SERVER_SESSION)
				{
					// Must be done after removed from force
					update_imap_distance_to_friendly_base ((entity_sides) raw->side);
				}

				//
				// switch sides
				//

				raw->side = side;

				//
				// update I-Maps (add new side)
				//

				if (raw->in_use)
				{
					update_imap_sector_side (en, TRUE);

					if (mode == PACK_MODE_SERVER_SESSION)
					{
						update_imap_importance_level (en, TRUE);

						update_keysite_distance_to_friendly_base (en, (entity_sides) side);
					}
				}
			}

			in_use = unpack_int_value (en, INT_TYPE_IN_USE);

			raw->keysite_id = unpack_int_value (en, INT_TYPE_KEYSITE_ID);

			raw->keysite_usable_state = unpack_int_value (en, INT_TYPE_KEYSITE_USABLE_STATE);

			if (raw->in_use != in_use)
			{
				//
				// Update I-Maps (in use flag changed)
				//

				raw->in_use = in_use;

				update_imap_sector_side (en, in_use);

				if (mode == PACK_MODE_SERVER_SESSION)
				{
					update_imap_importance_level (en, in_use);

					if (in_use)
					{
						update_keysite_distance_to_friendly_base (en, (entity_sides) side);
					}
					else
					{
						update_imap_distance_to_friendly_base ((entity_sides) side);
					}
				}
			}

			unpack_list_root (en, LIST_TYPE_UNASSIGNED_TASK, &raw->unassigned_task_root);
			unpack_list_root (en, LIST_TYPE_ASSIGNED_TASK, &raw->assigned_task_root);
			unpack_list_root (en, LIST_TYPE_COMPLETED_TASK, &raw->completed_task_root);

//			unpack_list_root (en, LIST_TYPE_KEYSITE_GROUP, &raw->keysite_group_root);

			unpack_list_root (en, LIST_TYPE_DIVISION_HEADQUARTERS, &raw->division_headquarters_root);

			if (unpack_int_value (en, INT_TYPE_VALID))
			{
				unpack_list_link (en, LIST_TYPE_CAMPAIGN_OBJECTIVE, &raw->campaign_objective_link);
			}

			#if DEBUG_MODULE

			debug_log ("KS_PACK: unpacking keysite %s", raw->keysite_name);

			#endif

			if (mode == PACK_MODE_SERVER_SESSION)
			{
				raw->repair_timer = unpack_float_value (en, FLOAT_TYPE_REPAIR_TIMER);

				raw->sleep = unpack_float_value (en, FLOAT_TYPE_SLEEP);

				raw->assist_timer = unpack_float_value (en, FLOAT_TYPE_ASSIST_TIMER);

				raw->assign_timer = unpack_float_value (en, FLOAT_TYPE_ASSIGN_TIMER);

				//
				// unpack landing data
				//

				landing_en = get_local_entity_first_child (en, LIST_TYPE_LANDING_SITE);
	
				while (landing_en)
				{
	
					landing_raw = (landing *) get_local_entity_data (landing_en);
	
					landing_raw->reserved_landing_sites = unpack_int_value (landing_en, INT_TYPE_RESERVED_LANDING_SITES);
	
					//landing_raw->free_landing_sites = unpack_int_value (en, INT_TYPE_FREE_LANDING_SITES);
					landing_raw->free_landing_sites = landing_raw->total_landing_sites;
	
					landing_lock = unpack_int_value (landing_en, INT_TYPE_LANDING_LOCK);
	
					landed_lock = unpack_int_value (landing_en, INT_TYPE_LANDED_LOCK);
	
					takeoff_lock = unpack_int_value (landing_en, INT_TYPE_TAKEOFF_LOCK);
	
					#if DEBUG_MODULE

					debug_log ("KS_PACK: %s (%d) unpacking %s landing entity, reserved %d, free %d, locks (saved :landing %d, landed %d, takeoff %d, calc landing %d, landed %d, takeoff %d)",
									raw->keysite_name,
									get_local_entity_index (en),
									entity_sub_type_landing_names [landing_raw->sub_type],
									landing_raw->reserved_landing_sites, landing_raw->free_landing_sites,
									landing_lock, landed_lock, takeoff_lock,
									landing_raw->landing_lock, landing_raw->landed_lock, landing_raw->takeoff_lock);

					if (landing_raw->landing_lock != landing_lock)
					{

						debug_log ("KS_PACK: %s %s landing entity needs landing_lock repairing", raw->keysite_name, entity_sub_type_landing_names [landing_raw->sub_type]);
					}
					if (landing_raw->landed_lock != landed_lock)
					{

						debug_log ("KS_PACK: %s %s landing entity needs landed_lock repairing", raw->keysite_name, entity_sub_type_landing_names [landing_raw->sub_type]);
					}
					if (landing_raw->takeoff_lock != takeoff_lock)
					{

						debug_log ("KS_PACK: %s %s landing entity needs takeoff_lock repairing", raw->keysite_name, entity_sub_type_landing_names [landing_raw->sub_type]);
					}

					#endif
	
					unpack_list_root (landing_en, LIST_TYPE_TAKEOFF_QUEUE, &landing_raw->takeoff_queue_root);

					landing_en = get_local_entity_child_succ (landing_en, LIST_TYPE_LANDING_SITE);
				}
			}
		}

		en = get_local_entity_succ (en);
	}
}
Esempio n. 20
0
static void destroy_local (entity *en)
{
	particle
		*raw;

	int
		loop;

	////////////////////////////////////////
	//
	// PRE-AMBLE
	//
	////////////////////////////////////////

	#if DEBUG_MODULE

	debug_log_entity_args (ENTITY_DEBUG_LOCAL, ENTITY_DEBUG_DESTROY, en);

	#endif

	raw = get_local_entity_data (en);

	////////////////////////////////////////
	//
	// VALIDATE
	//
	////////////////////////////////////////

	////////////////////////////////////////
	//
	// DESTROY COMPONENTS
	//
	////////////////////////////////////////

	free_mem (raw->position);

	free_mem (raw->motion_vector);

	free_mem (raw->valid);

	for (loop = 0; loop < raw->particle_count; loop ++)
	{
		if (raw->inst3d [loop])
		{
			destruct_3d_object (raw->inst3d [loop]);
		}
	}

	free_mem (raw->inst3d);

	////////////////////////////////////////
	//
	// UNLINK FROM SYSTEM
	//
	////////////////////////////////////////

	unlink_local_entity_children (en, LIST_TYPE_SPECIAL_EFFECT);

	delete_local_entity_from_parents_child_list (en, LIST_TYPE_SECTOR);

	delete_local_entity_from_parents_child_list (en, LIST_TYPE_UPDATE);

	////////////////////////////////////////
	//
	// FREE ENTITY DATA
	//
	////////////////////////////////////////

	free_mem (raw);

	set_free_entity (en);
}
Esempio n. 21
0
void unpack_local_site_updatable_data (pack_modes mode)
{

	site_updatable
		*raw;

	entity
		*en;

	int
		count,
		alive;

	if ((mode != PACK_MODE_SERVER_SESSION) && (mode != PACK_MODE_CLIENT_SESSION))
	{

		return;
	}

	//
	// RLE encoded
	//

	debug_log ("RLE SITE UPDATEABLE");

	en = get_local_entity_list ();

	count = unpack_int_value (NULL, INT_TYPE_LENGTH);

	alive = unpack_int_value (NULL, INT_TYPE_ALIVE);

	#if DEBUG_MODULE

	debug_log ("SU_PACK: unpacking count %d, alive %d", count, alive);

	#endif

	while (en)
	{

		if (get_local_entity_type (en) == ENTITY_TYPE_SITE_UPDATABLE)
		{

			if (count == 0)
			{

				count = unpack_int_value (NULL, INT_TYPE_LENGTH);

				alive = unpack_int_value (NULL, INT_TYPE_ALIVE);

				#if DEBUG_MODULE

				debug_log ("SU_PACK: unpacking count %d, alive %d", count, alive);

				#endif
			}

			count --;

			raw = get_local_entity_data (en);

			if (!alive)
			{
				delete_local_entity_from_parents_child_list (en, LIST_TYPE_UPDATE);

				// must be done BEFORE alive flag set, and BEFORE shape changed
//				subtract_local_entity_importance_from_keysite (en);

				raw->fix.object_3d_shape = get_3d_object_destroyed_object_index (raw->fix.object_3d_shape);
			}

			raw->fix.alive = alive;
		}

		en = get_local_entity_succ (en);
	}
}
Esempio n. 22
0
static void kill_local (entity *en)
{

	int
		losses;

	entity
		*task,
		*group,
		*keysite,
		*destroy_task;

	ship_vehicle
		*raw;

	////////////////////////////////////////
	//
	// PRE-AMBLE
	//
	////////////////////////////////////////

	#if DEBUG_MODULE >= 2

	debug_log_entity_args (ENTITY_DEBUG_LOCAL, ENTITY_DEBUG_KILL, en);

	#endif

	if (!get_local_entity_int_value (en, INT_TYPE_ALIVE))
	{
		return;
	}

	raw = (ship_vehicle *) get_local_entity_data (en);

	group = get_local_entity_parent (en, LIST_TYPE_MEMBER);

	ASSERT (group);

	keysite = NULL;

	if (tacview_is_logging())
		write_tacview_unit_event(en, TACVIEW_UNIT_DESTROYED, NULL);

	//
	// update force info
	//

	remove_from_force_info (get_local_force_entity ((entity_sides) raw->vh.mob.side), en);

	////////////////////////////////////////
	//
	// VALIDATE
	//
	////////////////////////////////////////

	////////////////////////////////////////
	//
	// DESTROY COMPONENTS
	//
	////////////////////////////////////////

	if (get_comms_model () == COMMS_MODEL_SERVER)
	{
		task = get_local_entity_first_child (en, LIST_TYPE_TASK_DEPENDENT);

		while (task)
		{
			destroy_task = task;

			task = get_local_entity_child_succ (task, LIST_TYPE_TASK_DEPENDENT);

			if (destroy_task->type == ENTITY_TYPE_TASK)
			{
				#if DEBUG_MODULE

				debug_log ("SH_DSTRY: killing ship, notifying task %s complete", entity_sub_type_task_names [get_local_entity_int_value (destroy_task, INT_TYPE_ENTITY_SUB_TYPE)]);

				#endif

				notify_local_entity (ENTITY_MESSAGE_TASK_COMPLETED, destroy_task, en, TASK_TERMINATED_OBJECTIVE_MESSAGE);
			}
		}

		//
		// Release landing lock (if any)
		//

		release_mobile_entity_landing_locks (en);

		////////////////////////////////////////
		//
		// UNLINK FROM SYSTEM
		//
		////////////////////////////////////////

		//
		// Destroy keysite entity if ship is carrier
		//

		keysite = get_local_entity_first_child (en, LIST_TYPE_MOVEMENT_DEPENDENT);

		while (keysite)
		{
			if (get_local_entity_type (keysite) == ENTITY_TYPE_KEYSITE)
			{
				break;
			}

			keysite = get_local_entity_child_succ (keysite, LIST_TYPE_MOVEMENT_DEPENDENT);
		}
	}

	//
	// ship_vehicle
	//

	//
	// vehicle
	//

	unlink_local_entity_children (en, LIST_TYPE_TASK_DEPENDENT);

	unlink_local_entity_children (en, LIST_TYPE_MOVEMENT_DEPENDENT);

	delete_local_entity_from_parents_child_list (en, LIST_TYPE_MEMBER);

	delete_local_entity_from_parents_child_list (en, LIST_TYPE_MOVEMENT_DEPENDENT);

	delete_local_entity_from_parents_child_list (en, LIST_TYPE_FOLLOWER);

	// gunship_target_link

	// member_link

	// view_link

	delete_local_entity_from_parents_child_list (en, LIST_TYPE_TAKEOFF_QUEUE);

	//
	// mobile
	//

	//
	// kill weapon sound effects
	//

	kill_local_entity_sound_type (en, ENTITY_SUB_TYPE_EFFECT_SOUND_CHAIN_GUN);

	//
	// kill engine sound effects
	//

	kill_local_entity_sound_type (en, ENTITY_SUB_TYPE_EFFECT_SOUND_ENGINE_LOOPING1);
	kill_local_entity_sound_type (en, ENTITY_SUB_TYPE_EFFECT_SOUND_ENGINE_LOOPING2);

	unlink_local_entity_children (en, LIST_TYPE_TARGET);

	delete_local_entity_from_parents_child_list (en, LIST_TYPE_PADLOCK);

	// sector_link

	delete_local_entity_from_parents_child_list (en, LIST_TYPE_TARGET);

	// update_link

	set_local_entity_int_value (en, INT_TYPE_OPERATIONAL_STATE, OPERATIONAL_STATE_STOPPED);

	////////////////////////////////////////
	//
	// KILL
	//
	////////////////////////////////////////

	// must be done before alive flag set
	remove_mobile_values_from_sector (get_local_entity_parent (en, LIST_TYPE_SECTOR), en);

	set_local_entity_int_value (en, INT_TYPE_ALIVE, FALSE);

	damage_ship_3d_object (en);

	//
	// group losses
	//

	losses = get_local_entity_int_value (group, INT_TYPE_LOSSES);

	losses ++;

	set_local_entity_int_value (group, INT_TYPE_LOSSES, losses);

	//
	// task losses
	//

	task = get_local_group_primary_task (group);

	if (task)
	{
		losses = get_local_entity_int_value (task, INT_TYPE_LOSSES);

		losses ++;

		set_local_entity_int_value (task, INT_TYPE_LOSSES, losses);
	}

	//
	// Notify Campaign Screen
	//

	notify_campaign_screen (CAMPAIGN_SCREEN_GROUP_REMOVE_MEMBER, group);

	if (get_comms_model () == COMMS_MODEL_SERVER)
	{
		//
		// Notify the GROUP that the mobile has been killed  (N.B. must be done AFTER mobile is unlinked from member list)
		//

		notify_local_entity (ENTITY_MESSAGE_MOBILE_KILLED, group, en);

		//
		// Kill the keysite if ship is the carrier (N.B. must be done AFTER ships alive flag cleared)
		//

		if (keysite)
		{
			kill_client_server_entity (keysite);
		}
	}

	////////////////////////////////////////
	//
	// SPECIAL EFFECTS
	//
	////////////////////////////////////////

	if (get_comms_model () == COMMS_MODEL_SERVER)
	{
		create_client_server_object_killed_explosion_effect (en);
	}

	#if LANDING_ROUTE_CHECK

	destroy_debug_entity_landing_route_check (en);

	#endif

	/////////////////////////////////////////////////////////////////
	//
	// SPECIAL_EFFECT_HOOK FOR BEING_DESTROYED
	//
	/////////////////////////////////////////////////////////////////

	/////////////////////////////////////////////////////////////////
	//
	//
	/////////////////////////////////////////////////////////////////
}
Esempio n. 23
0
static void kill_local (entity *en)
{

	entity
		*task,
		*destroy_task;

	cargo
		*raw;

	////////////////////////////////////////
	//
	// PRE-AMBLE
	//
	////////////////////////////////////////

	#if DEBUG_MODULE >= 2

	debug_log_entity_args (ENTITY_DEBUG_LOCAL, ENTITY_DEBUG_KILL, en);

	#endif

	raw = (cargo *) get_local_entity_data (en);

	////////////////////////////////////////
	//
	// VALIDATE
	//
	////////////////////////////////////////

	////////////////////////////////////////
	//
	// KILL
	//
	////////////////////////////////////////

	set_local_entity_int_value (en, INT_TYPE_ALIVE, FALSE);

	////////////////////////////////////////
	//
	// SEND NOTIFY MESSAGES
	//
	////////////////////////////////////////

	if (get_comms_model () == COMMS_MODEL_SERVER)
	{

		task = get_local_entity_first_child (en, LIST_TYPE_TASK_DEPENDENT);

		while (task)
		{

			destroy_task = task;

			task = get_local_entity_child_succ (task, LIST_TYPE_TASK_DEPENDENT);

			if (destroy_task->type == ENTITY_TYPE_TASK)
			{

				#if DEBUG_MODULE

				debug_log ("FW_DSTRY: killing cargo, notifying task %s complete", entity_sub_type_task_names [get_local_entity_int_value (destroy_task, INT_TYPE_ENTITY_SUB_TYPE)]);

				#endif

				notify_local_entity (ENTITY_MESSAGE_TASK_COMPLETED, destroy_task, en, TASK_TERMINATED_OBJECTIVE_MESSAGE);
			}
		}

		////////////////////////////////////////
		//
		// SEND NOTIFY MESSAGES
		//
		////////////////////////////////////////
	}

	////////////////////////////////////////
	//
	// UNLINK FROM SYSTEM
	//
	////////////////////////////////////////

	//
	// cargo
	//

	unlink_local_entity_children (en, LIST_TYPE_TASK_DEPENDENT);

	delete_local_entity_from_parents_child_list (en, LIST_TYPE_CARGO);

	delete_local_entity_from_parents_child_list (en, LIST_TYPE_MOVEMENT_DEPENDENT);

	// view_link

	//
	// mobile
	//

	unlink_local_entity_children (en, LIST_TYPE_SPECIAL_EFFECT);

	unlink_local_entity_children (en, LIST_TYPE_TARGET);

	delete_local_entity_from_parents_child_list (en, LIST_TYPE_PADLOCK);

	// sector_link

	delete_local_entity_from_parents_child_list (en, LIST_TYPE_TARGET);

	// update_link

	////////////////////////////////////////
	//
	// SPECIAL EFFECTS
	//
	////////////////////////////////////////
}
Esempio n. 24
0
static void update_server (entity *en)
{
	entity
		*parent,
		*next_segment,
		*prev_segment;

	entity_sub_types
		sub_type;

	vec3d
		*pos;

	float
		terrain_height;

	terrain_3d_point_data
		terrain_info;

	//
	// notify the segments neighbours as applicable
	//

	parent = get_local_entity_parent (en, LIST_TYPE_SEGMENT);

	ASSERT (parent);

	next_segment = get_local_entity_child_succ (en, LIST_TYPE_SEGMENT);

	if (next_segment)
	{
		notify_local_entity (ENTITY_MESSAGE_COLLISION, parent, next_segment);
	}

	prev_segment = get_local_entity_child_pred (en, LIST_TYPE_SEGMENT);

	if (prev_segment)
	{
		notify_local_entity (ENTITY_MESSAGE_COLLISION, parent, prev_segment);
	}

	sub_type = get_local_entity_int_value (en, INT_TYPE_ENTITY_SUB_TYPE);

	if (sub_type == ENTITY_SUB_TYPE_FIXED_BRIDGE_UNSUPPORTED_MID_SECTION)
	{
		//
		// make the segment drop to the floor ( removing it from the update list when it hits )
		//
	
		pos = get_local_entity_vec3d_ptr (en, VEC3D_TYPE_POSITION);
	
		pos->y -= ( 10.0 * get_delta_time() );
	
		memset (&terrain_info, 0, sizeof (terrain_3d_point_data));
	
		terrain_height = get_3d_terrain_point_data (pos->x, pos->z, &terrain_info);

		if (get_terrain_type_class (terrain_info.terrain_type) == TERRAIN_CLASS_WATER)
		{
			terrain_height -= 1.0;
		}
	
		if ( pos->y <= terrain_height )
		{
			pos->y = terrain_height;
	
			delete_local_entity_from_parents_child_list (en, LIST_TYPE_UPDATE);
	
			if (get_comms_model () == COMMS_MODEL_SERVER)
			{
				create_client_server_object_hit_ground_explosion_effect (en, terrain_info.terrain_type);
			}
		}
	}
	else
	{
		//
		// segment is supported, and so should be instantly removed from the update list
		// ( only put there in the first place so that neighbours would be notified )
		//

		delete_local_entity_from_parents_child_list (en, LIST_TYPE_UPDATE);
	}
}
Esempio n. 25
0
static void destroy_local (entity *en)
{

	cargo
		*raw;

	////////////////////////////////////////
	//
	// PRE-AMBLE
	//
	////////////////////////////////////////

	#if DEBUG_MODULE >= 2

	debug_log_entity_args (ENTITY_DEBUG_LOCAL, ENTITY_DEBUG_DESTROY, en);

	#endif

	raw = (cargo *) get_local_entity_data (en);

	////////////////////////////////////////
	//
	// VALIDATE
	//
	////////////////////////////////////////

	////////////////////////////////////////
	//
	// DESTROY COMPONENTS
	//
	////////////////////////////////////////

	////////////////////////////////////////
	//
	// UNLINK FROM SYSTEM
	//
	////////////////////////////////////////

	//
	// cargo
	//

	unlink_local_entity_children (en, LIST_TYPE_TASK_DEPENDENT);

	delete_local_entity_from_parents_child_list (en, LIST_TYPE_CARGO);

	delete_local_entity_from_parents_child_list (en, LIST_TYPE_MOVEMENT_DEPENDENT);

	//
	// mobile
	//

	unlink_local_entity_children (en, LIST_TYPE_SPECIAL_EFFECT);

	unlink_local_entity_children (en, LIST_TYPE_TARGET);

	delete_local_entity_from_parents_child_list (en, LIST_TYPE_PADLOCK);

	delete_local_entity_from_parents_child_list (en, LIST_TYPE_SECTOR);

	delete_local_entity_from_parents_child_list (en, LIST_TYPE_UPDATE);

	////////////////////////////////////////
	//
	// FREE ENTITY DATA
	//
	////////////////////////////////////////

	free_mem (raw);

	set_free_entity (en);
}
Esempio n. 26
0
static void destroy_local (entity *en)
{
	site
		*raw;

	////////////////////////////////////////
	//
	// PRE-AMBLE
	//
	////////////////////////////////////////

	#if DEBUG_MODULE

	debug_log_entity_args (ENTITY_DEBUG_LOCAL, ENTITY_DEBUG_DESTROY, en);

	#endif

	raw = get_local_entity_data (en);

	////////////////////////////////////////
	//
	// VALIDATE
	//
	////////////////////////////////////////

	////////////////////////////////////////
	//
	// DESTROY COMPONENTS
	//
	////////////////////////////////////////

	////////////////////////////////////////
	//
	// UNLINK FROM SYSTEM
	//
	////////////////////////////////////////

	//
	// fixed
	//

	unlink_local_entity_children (en, LIST_TYPE_TASK_DEPENDENT);

	unlink_local_entity_children (en, LIST_TYPE_TARGET);

	delete_local_entity_from_parents_child_list (en, LIST_TYPE_GUNSHIP_TARGET);

	delete_local_entity_from_parents_child_list (en, LIST_TYPE_SECTOR);

	//
	// site
	//

	delete_local_entity_from_parents_child_list (en, LIST_TYPE_MEMBER);

	////////////////////////////////////////
	//
	// FREE ENTITY DATA
	//
	////////////////////////////////////////

	free_mem (raw);

	set_free_entity (en);
}
Esempio n. 27
0
static void kill_local (entity *en)
{

	int
		losses;

	helicopter
		*raw;

	entity
		*task,
		*group,
		*member,
		*destroy_task;

	////////////////////////////////////////
	//
	// PRE-AMBLE
	//
	////////////////////////////////////////

	#if DEBUG_MODULE >= 2

	debug_log_entity_args (ENTITY_DEBUG_LOCAL, ENTITY_DEBUG_KILL, en);

	#endif

	if (!get_local_entity_int_value (en, INT_TYPE_ALIVE))
	{
		return;
	}

	raw = get_local_entity_data (en);

	group = get_local_entity_parent (en, LIST_TYPE_MEMBER);

	ASSERT (group);

	//
	// update force info
	//

	remove_from_force_info (get_local_force_entity (raw->ac.mob.side), en);

	if (en == get_gunship_entity ())
	{
		//
		// Award Points for mission
		//

		task = get_local_entity_primary_task (en);

		if (task)
		{
			if (get_local_entity_int_value (task, INT_TYPE_TASK_STATE) == TASK_STATE_COMPLETED)
			{
				//
				// Only award points for COMPLETE missions (also means player can't rejoin that mission and get points again)
				//

				notify_gunship_entity_mission_terminated (en, task);
			}
		}
	}

	////////////////////////////////////////
	//
	// VALIDATE
	//
	////////////////////////////////////////

	////////////////////////////////////////
	//
	// DESTROY COMPONENTS
	//
	////////////////////////////////////////

	#if DEBUG_MODULE

	debug_log ("HC_DSTRY: killing helicopter %s", entity_sub_type_aircraft_names [raw->ac.mob.sub_type]);

	#endif

	if (get_comms_model () == COMMS_MODEL_SERVER)
	{
		// notify regen of kill

		add_entity_to_regen_queue
		(
			get_local_entity_int_value(en, INT_TYPE_SIDE),
			get_local_entity_type(en),
			get_local_entity_int_value (en, INT_TYPE_ENTITY_SUB_TYPE),
			get_local_entity_int_value (group, INT_TYPE_ENTITY_SUB_TYPE)
		);

		//
		// notify task dependents
		//

		task = get_local_entity_first_child (en, LIST_TYPE_TASK_DEPENDENT);

		while (task)
		{

			destroy_task = task;

			task = get_local_entity_child_succ (task, LIST_TYPE_TASK_DEPENDENT);

			if (destroy_task->type == ENTITY_TYPE_TASK)
			{

				#if DEBUG_MODULE

				debug_log ("HC_DSTRY: killing helicopter, notifying task %s complete", entity_sub_type_task_names [get_local_entity_int_value (destroy_task, INT_TYPE_ENTITY_SUB_TYPE)]);

				#endif

				notify_local_entity (ENTITY_MESSAGE_TASK_COMPLETED, destroy_task, en, TASK_TERMINATED_OBJECTIVE_MESSAGE);
			}
		}

		//
		// Release landing lock (if any)
		//

		release_mobile_entity_landing_locks (en);

		//
		// if group contains player, set all helicopters in group to "weapons free", and clear "hold position" flag
		//

		if (get_local_entity_int_value (en, INT_TYPE_PLAYER) != ENTITY_PLAYER_AI)
		{
			member = get_local_entity_first_child (group, LIST_TYPE_MEMBER);

			while (member)
			{
				set_client_server_entity_int_value (member, INT_TYPE_WEAPONS_HOLD, FALSE);

				set_client_server_entity_int_value (member, INT_TYPE_POSITION_HOLD, FALSE);

				member = get_local_entity_child_succ (member, LIST_TYPE_MEMBER);
			}
		}
	}

	////////////////////////////////////////
	//
	// UNLINK FROM SYSTEM
	//
	////////////////////////////////////////

	//
	// helicopter
	//

	unlink_local_entity_children (en, LIST_TYPE_GUNSHIP_TARGET);

	unlink_local_entity_children (en, LIST_TYPE_PADLOCK);

	//
	// aircraft
	//

	// aircrew_root

	unlink_local_entity_children (en, LIST_TYPE_TASK_DEPENDENT);

	////////////////////////////////////////
	//
	// the eject sequence relies on launched weapons NOT being unlinked
	//

	// unlink_local_entity_children (en, LIST_TYPE_LAUNCHED_WEAPON);

	//
	////////////////////////////////////////

	delete_local_entity_from_parents_child_list (en, LIST_TYPE_FOLLOWER);

	delete_local_entity_from_parents_child_list (en, LIST_TYPE_MEMBER);

	// gunship_target_link

	// member_link

	delete_local_entity_from_parents_child_list (en, LIST_TYPE_MOVEMENT_DEPENDENT);

	// view_link

	delete_local_entity_from_parents_child_list (en, LIST_TYPE_TAKEOFF_QUEUE);

	//
	// mobile
	//

	//
	// kill weapon sound effects
	//

	kill_local_entity_sound_type (en, ENTITY_SUB_TYPE_EFFECT_SOUND_CHAIN_GUN);

	//
	// kill engine sound effects
	//

	kill_local_entity_sound_type (en, ENTITY_SUB_TYPE_EFFECT_SOUND_ROTOR_LOOPING);
	kill_local_entity_sound_type (en, ENTITY_SUB_TYPE_EFFECT_SOUND_ROTOR_WIND_UP);
	kill_local_entity_sound_type (en, ENTITY_SUB_TYPE_EFFECT_SOUND_ROTOR_WIND_DOWN);

	//
	// kill radio / warning effects
	//

	kill_local_entity_sound_type (en, ENTITY_SUB_TYPE_EFFECT_SOUND_INCOMING_MISSILE_WARNING);
	kill_local_entity_sound_type (en, ENTITY_SUB_TYPE_EFFECT_SOUND_LOCK_ON_TONE);
	kill_local_entity_sound_type (en, ENTITY_SUB_TYPE_EFFECT_SOUND_MCA);
	kill_local_entity_sound_type (en, ENTITY_SUB_TYPE_EFFECT_SOUND_RADAR_LOCKED);
	kill_local_entity_sound_type (en, ENTITY_SUB_TYPE_EFFECT_SOUND_RADAR_TRACKED);
	kill_local_entity_sound_type (en, ENTITY_SUB_TYPE_EFFECT_SOUND_CPG_MESSAGE);
	kill_local_entity_sound_type (en, ENTITY_SUB_TYPE_EFFECT_SOUND_RADIO_MESSAGE);
	kill_local_entity_sound_type (en, ENTITY_SUB_TYPE_EFFECT_SOUND_WARNING_MESSAGE);

	notify_speech_buffers_entity_killed (en);

	unlink_local_entity_children (en, LIST_TYPE_TARGET);

	delete_local_entity_from_parents_child_list (en, LIST_TYPE_PADLOCK);

	// sector_link

	delete_local_entity_from_parents_child_list (en, LIST_TYPE_TARGET);

	// update_link

	//
	// death timer (set time after which entity is totally destroyed)
	//

	set_local_entity_float_value (en, FLOAT_TYPE_DEATH_TIMER, calculate_mobile_death_timer_value (en));

	////////////////////////////////////////
	//
	// KILL
	//
	////////////////////////////////////////

	damage_helicopter_3d_object (en);

	// must be done before alive flag set to FALSE
	remove_mobile_values_from_sector (get_local_entity_parent (en, LIST_TYPE_SECTOR), en);

	set_local_entity_int_value (en, INT_TYPE_ALIVE, FALSE);

	//
	// group losses
	//

	losses = get_local_entity_int_value (group, INT_TYPE_LOSSES);

	losses ++;

	set_local_entity_int_value (group, INT_TYPE_LOSSES, losses);

	//
	// task losses
	//

	task = get_local_group_primary_task (group);

	if (task)
	{
		losses = get_local_entity_int_value (task, INT_TYPE_LOSSES);

		losses ++;

		set_local_entity_int_value (task, INT_TYPE_LOSSES, losses);
	}

	//
	// Notify Campaign Screen
	//

	notify_campaign_screen (CAMPAIGN_SCREEN_GROUP_REMOVE_MEMBER, group);

	//
	// Notify the GROUP that the mobile has been killed  (N.B. must be done AFTER mobile is unlinked from member list)
	//

	if (get_comms_model () == COMMS_MODEL_SERVER)
	{
		notify_local_entity (ENTITY_MESSAGE_MOBILE_KILLED, group, en);
	}

	//
	// Notify force to check campaign criteria
	//

	if (get_comms_model () == COMMS_MODEL_SERVER)
	{
		entity
			*force;

		force = get_local_entity_first_child (get_session_entity (), LIST_TYPE_FORCE);

		while (force)
		{
			notify_local_entity (ENTITY_MESSAGE_CHECK_CAMPAIGN_OBJECTIVES, force, en);

			force = get_local_entity_child_succ (force, LIST_TYPE_FORCE);
		}
	}

	////////////////////////////////////////
	//
	// SPECIAL EFFECTS
	//
	////////////////////////////////////////

	helicopter_impact_movement (en);

	if (get_comms_model () == COMMS_MODEL_SERVER)
	{
		vec3d
			*position;

		sound_sample_indices
			sound_sample_index;

		set_client_server_entity_int_value (en, INT_TYPE_MAIN_ROTOR_DAMAGED, TRUE);

		set_client_server_entity_int_value (en, INT_TYPE_TAIL_ROTOR_DAMAGED, TRUE);

		create_client_server_object_killed_explosion_effect (en);

		position = get_local_entity_vec3d_ptr (en, VEC3D_TYPE_POSITION);

		sound_sample_index = SOUND_SAMPLE_INDEX_SHOT_DOWN_HELICOPTER;

		create_client_server_sound_effect_entity
		(
			en,
			ENTITY_SIDE_NEUTRAL,
			ENTITY_SUB_TYPE_EFFECT_SOUND_ROTOR_LOOPING,
			SOUND_CHANNEL_SOUND_EFFECT,
			SOUND_LOCALITY_ALL,
			NULL,												// position
			1.0,												// amplification
			TRUE,												// valid sound effect
			TRUE,												// looping
			1,													// sample count
			&sound_sample_index							// sample index list
		);
	}

	set_local_entity_int_value (en, INT_TYPE_OPERATIONAL_STATE, OPERATIONAL_STATE_DYING);

	////////////////////////////////////////
	//
	// VIEWS
	//
	////////////////////////////////////////

	if ((en == get_gunship_entity ()) && (!get_local_entity_int_value (en, INT_TYPE_EJECTED)))
	{
		set_gunship_entity (NULL);
	}

	#if LANDING_ROUTE_CHECK

	destroy_debug_entity_landing_route_check (en);

	#endif

	/////////////////////////////////////////////////////////////////
	//
	// SPECIAL_EFFECT_HOOK FOR BEING_DESTROYED
	//
	/////////////////////////////////////////////////////////////////

	/////////////////////////////////////////////////////////////////
	//
	//
	/////////////////////////////////////////////////////////////////
}