Makes the player into an AI controlled physics object
| 2604 | |
| 2605 | // Makes the player into an AI controlled physics object |
| 2606 | void PlayerSetControlToAI(int slot, float velocity) { |
| 2607 | ASSERT(slot >= 0 && slot < MAX_PLAYERS); |
| 2608 | if (slot < 0 || slot >= MAX_PLAYERS) |
| 2609 | return; |
| 2610 | |
| 2611 | object *pobj = &Objects[Players[slot].objnum]; |
| 2612 | |
| 2613 | // Turn off some player physics stuff |
| 2614 | pobj->mtype.phys_info.flags &= ~PF_USES_THRUST; |
| 2615 | pobj->mtype.phys_info.drag = .1f; |
| 2616 | pobj->mtype.phys_info.flags &= ~PF_LEVELING; |
| 2617 | |
| 2618 | // pobj->flags &= ~OF_DESTROYABLE; |
| 2619 | vm_MakeZero(&pobj->mtype.phys_info.thrust); |
| 2620 | vm_MakeZero(&pobj->mtype.phys_info.rotthrust); |
| 2621 | vm_MakeZero(&pobj->mtype.phys_info.rotvel); |
| 2622 | vm_MakeZero(&pobj->mtype.phys_info.velocity); |
| 2623 | |
| 2624 | // Put the player in AI mode |
| 2625 | SetObjectControlType(pobj, CT_AI); |
| 2626 | |
| 2627 | memset(pobj->ai_info, 0, sizeof(ai_frame)); |
| 2628 | |
| 2629 | pobj->ai_info->ai_class = AIC_STATIC; |
| 2630 | pobj->ai_info->ai_type = AIT_AIS; |
| 2631 | |
| 2632 | GoalInitTypeGoals(pobj, AIT_AIS); |
| 2633 | |
| 2634 | pobj->ai_info->flags = AIF_PERSISTANT | AIF_DISABLE_FIRING | AIF_DISABLE_MELEE | AIF_ORIENT_TO_VEL; |
| 2635 | pobj->ai_info->max_velocity = velocity; |
| 2636 | pobj->ai_info->max_delta_velocity = 40.0f; |
| 2637 | pobj->ai_info->max_turn_rate = 14000; |
| 2638 | pobj->ai_info->awareness = AWARE_MOSTLY; |
| 2639 | pobj->ai_info->movement_type = MC_FLYING; |
| 2640 | pobj->ai_info->next_movement = AI_INVALID_INDEX; |
| 2641 | pobj->ai_info->anim_sound_handle = 0; |
| 2642 | pobj->ai_info->status_reg = 0; |
| 2643 | pobj->ai_info->last_played_sound_index = -1; |
| 2644 | pobj->ai_info->weapon_speed = 0.0f; |
| 2645 | pobj->ai_info->animation_type = AS_ALERT; |
| 2646 | pobj->ai_info->next_melee_time = Gametime; |
| 2647 | pobj->ai_info->next_flinch_time = Gametime; |
| 2648 | pobj->ai_info->target_handle = OBJECT_HANDLE_NONE; |
| 2649 | pobj->ai_info->next_check_see_target_time = Gametime; |
| 2650 | pobj->ai_info->last_see_target_time = Gametime; |
| 2651 | pobj->ai_info->last_render_time = -1.0f; |
| 2652 | pobj->ai_info->next_target_update_time = Gametime; |
| 2653 | pobj->ai_info->notify_flags |= AI_NOTIFIES_ALWAYS_ON; |
| 2654 | pobj->ai_info->last_see_target_pos = Zero_vector; |
| 2655 | pobj->ai_info->dodge_vel_percent = 1.0f; |
| 2656 | pobj->ai_info->attack_vel_percent = 1.0f; |
| 2657 | pobj->ai_info->fight_same = 0.0f; |
| 2658 | pobj->ai_info->agression = 0.0f; |
| 2659 | pobj->ai_info->avoid_friends_distance = 0.0f; |
| 2660 | pobj->ai_info->biased_flight_importance = 0.0f; |
| 2661 | pobj->ai_info->circle_distance = 10.0f; |
| 2662 | pobj->ai_info->dodge_percent = 0.0f; |
| 2663 | pobj->ai_info->fight_team = 0.0f; |
no test coverage detected