void kill_client_server_entity_sound_type (entity *en, entity_sub_types type) { entity *spec, *next; sound_effect *raw; spec = get_local_entity_first_child (en, LIST_TYPE_SPECIAL_EFFECT); while (spec) { next = get_local_entity_child_succ (spec, LIST_TYPE_SPECIAL_EFFECT); if (get_local_entity_type (spec) == ENTITY_TYPE_SOUND_EFFECT) { raw = get_local_entity_data (spec); if (raw->eff.sub_type == type) { // // "kill" sound // kill_client_server_entity (spec); } } spec = next; } }
static int response_to_collision (entity_messages message, entity *receiver, entity *sender, va_list pargs) { int total_damage_level; float damage_modifier; #if DEBUG_MODULE >= 2 debug_log_entity_message (message, receiver, sender, pargs); #endif damage_modifier = va_arg (pargs, double); damage_client_server_entity (receiver, sender, damage_modifier); total_damage_level = get_local_entity_int_value (receiver, INT_TYPE_DAMAGE_LEVEL); if (total_damage_level <= 0) { kill_client_server_entity (receiver); } return (TRUE); }
void kill_client_server_group_entity (entity *en) { entity *guide, *task, *next; ASSERT (en); ASSERT (get_comms_model () == COMMS_MODEL_SERVER); // // abort tasks (NOTE: Notifying each guide could indirectly destroy other guides on the stack) // do { guide = get_local_entity_first_child (en, LIST_TYPE_GUIDE_STACK); if (guide) { notify_local_entity (ENTITY_MESSAGE_GROUP_KILLED, guide, en); } } while (guide); // // notify task dependents // task = get_local_entity_first_child (en, LIST_TYPE_TASK_DEPENDENT); while (task) { next = get_local_entity_child_succ (task, LIST_TYPE_TASK_DEPENDENT); if (task->type == ENTITY_TYPE_TASK) { notify_local_entity (ENTITY_MESSAGE_TASK_COMPLETED, task, en, TASK_TERMINATED_OBJECTIVE_MESSAGE); } task = next; } kill_client_server_entity (en); }
void group_kill_all_members (entity *en) { entity *next, *member; ASSERT (get_comms_model () == COMMS_MODEL_SERVER); member = get_local_entity_first_child (en, LIST_TYPE_MEMBER); while (member) { next = get_local_entity_child_succ (member, LIST_TYPE_MEMBER); kill_client_server_entity (member); member = next; } }
static void notify_base_destroy_button (ui_object *obj, void *arg) { entity *en; entity_sides side, new_side; int sub_type; if (get_comms_model () != COMMS_MODEL_SERVER) { return; } en = get_local_entity_safe_ptr (get_ui_object_item_number (campaign_page [CAMPAIGN_PAGE_BASE])); ASSERT (en); sub_type = get_local_entity_int_value (en, INT_TYPE_ENTITY_SUB_TYPE); if (keysite_database [sub_type].troop_insertion_target) { side = get_local_entity_int_value (en, INT_TYPE_SIDE); new_side = get_enemy_side (side); // create_troop_insertion_task (new_side, en, NULL, TRUE, 10.0, NULL, NULL); capture_keysite (en, new_side); } else { kill_client_server_entity (en); } }
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 // ///////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////// // // ///////////////////////////////////////////////////////////////// }
void kill_routed_vehicles_on_segment (entity *en) { float range, damage_radius; int sx, sz; vec3d *segment_position, *object_position; entity *sect, *object; bridge_segment_types bridge_segment_type; // // get damage radius ( plus a little overlap ) // bridge_segment_type = (bridge_segment_types) get_local_entity_int_value (en, INT_TYPE_BRIDGE_SEGMENT_TYPE); damage_radius = bridge_segment_length (bridge_segment_type); if (damage_radius == 0.0) { return; } damage_radius *= ROOT2; // // get sector which the segment is in ( don't bother with adjacent sectors for now ) // segment_position = get_local_entity_vec3d_ptr (en, VEC3D_TYPE_POSITION); get_x_sector (sx, segment_position->x); get_z_sector (sz, segment_position->z); sect = get_local_raw_sector_entity (sx, sz); // // search for routed vehicles // object = get_local_entity_first_child (sect, LIST_TYPE_SECTOR); while (object) { if (object->type == ENTITY_TYPE_ROUTED_VEHICLE) { if (get_local_entity_int_value (object, INT_TYPE_ALIVE)) { object_position = get_local_entity_vec3d_ptr (object, VEC3D_TYPE_POSITION); if (object_position) { range = get_approx_3d_range (segment_position, object_position); if (range < damage_radius) { kill_client_server_entity (object); } } } } object = get_local_entity_child_succ (object, LIST_TYPE_SECTOR); } }