| 6106 | } |
| 6107 | |
| 6108 | void AIDoFrame(object *obj) { |
| 6109 | |
| 6110 | bool f_attach_done = false; |
| 6111 | int multi_saved_weapon_flags; |
| 6112 | char multi_saved_wb_firing; |
| 6113 | |
| 6114 | // AI objects don't use thrust (in general) |
| 6115 | obj->mtype.phys_info.flags &= ~PF_USES_THRUST; |
| 6116 | obj->mtype.phys_info.rotthrust = Zero_vector; |
| 6117 | obj->mtype.phys_info.thrust = Zero_vector; |
| 6118 | |
| 6119 | if (obj->type == OBJ_DUMMY) |
| 6120 | return; |
| 6121 | |
| 6122 | if ((Game_mode & GM_MULTI) && (Netgame.local_role == LR_SERVER)) { |
| 6123 | multi_saved_wb_firing = obj->ai_info->last_special_wb_firing; |
| 6124 | multi_saved_weapon_flags = obj->weapon_fire_flags; |
| 6125 | } |
| 6126 | |
| 6127 | ai_frame *ai_info = obj->ai_info; |
| 6128 | ASSERT((obj->control_type == CT_AI) || (obj->control_type == CT_DYING_AND_AI)); |
| 6129 | |
| 6130 | if ((ai_info->flags & AIF_DISABLED) || (obj->type == OBJ_DUMMY)) { |
| 6131 | return; |
| 6132 | } |
| 6133 | |
| 6134 | // Animate the object |
| 6135 | ai_do_animation(obj, Frametime); |
| 6136 | if (ai_info->animation_type == AS_IDLE) { |
| 6137 | f_attach_done = true; |
| 6138 | } |
| 6139 | |
| 6140 | if (Demo_flags == DF_PLAYBACK) { |
| 6141 | // All we want is animation |
| 6142 | return; |
| 6143 | } |
| 6144 | // Handle On/off and spray weapons |
| 6145 | { |
| 6146 | if ((obj->weapon_fire_flags & WFF_SPRAY) && !(obj->flags & (OF_DESTROYED | OF_DYING))) { |
| 6147 | char wb_index = ai_info->last_special_wb_firing; |
| 6148 | DoSprayEffect(obj, &Object_info[obj->id].static_wb[wb_index], wb_index); |
| 6149 | if (!((Game_mode & GM_MULTI) && (Netgame.local_role == LR_CLIENT))) { |
| 6150 | if (WBIsBatteryReady(obj, &Object_info[obj->id].static_wb[wb_index], wb_index) && |
| 6151 | !(Cinematic_inuse && !(ai_info->status_reg & AISR_OK_TO_FIRE_DURING_CINEMATICS))) { |
| 6152 | WBFireBattery(obj, &Object_info[obj->id].static_wb[wb_index], wb_index); |
| 6153 | } |
| 6154 | } |
| 6155 | } |
| 6156 | |
| 6157 | if (obj->weapon_fire_flags & WFF_ON_OFF) { |
| 6158 | FireOnOffWeapon(obj); |
| 6159 | } |
| 6160 | } |
| 6161 | |
| 6162 | if ((Game_mode & GM_MULTI) && (Netgame.local_role == LR_CLIENT)) { |
| 6163 | if (!f_attach_done) { |
| 6164 | AttachUpdateSubObjects(obj); |
| 6165 | f_attach_done = true; |
no test coverage detected