MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / ai_fire

Function ai_fire

Descent3/AImain.cpp:5196–5534  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5194#define DEFAULT_FIRE_DOT .93f
5195
5196void ai_fire(object *obj) {
5197 if (!Object_info[obj->id].static_wb) {
5198 // something is hosed due to 'Mac memory savings' (c)
5199 Int3();
5200 return; // object can't fire anything...
5201 }
5202
5203 ai_frame *ai_info = obj->ai_info;
5204 int i;
5205 int j;
5206 poly_model *pm = &Poly_models[obj->rtype.pobj_info.model_num];
5207 object_info *obj_info = &Object_info[obj->id];
5208 bool f_turret_next_move_still;
5209
5210 //. mprintf(0, "Aiming\n");
5211 if (!(ai_info->flags & AIF_FIRE)) {
5212 if (ai_info->status_reg & AISR_RANGED_ATTACK) {
5213 for (i = 0; i < pm->num_wbs; i++) {
5214 if (!(obj->dynamic_wb[i].flags & DWBF_ENABLED))
5215 continue;
5216
5217 if (WBIsBatteryReady(obj, &obj_info->static_wb[i], i) &&
5218 !(Cinematic_inuse && !(ai_info->status_reg & AISR_OK_TO_FIRE_DURING_CINEMATICS))) {
5219 int anim_type = obj_info->static_wb[i].flags & WBF_ANIM_MASKS;
5220
5221 if (anim_type == WBF_ANIM_LOCAL) {
5222 WBSetupFireAnim(obj, &obj_info->static_wb[i], i);
5223 } else if (anim_type == WBF_ANIM_FULL) {
5224 gi_fire attack_info;
5225
5226 attack_info.cur_wb = i;
5227 attack_info.cur_mask = obj->dynamic_wb[i].cur_firing_mask;
5228
5229 GoalAddGoal(obj, AIG_FIRE_AT_OBJ, (void *)&attack_info, ACTIVATION_BLEND_LEVEL);
5230 } else {
5231 WBFireBattery(obj, &obj_info->static_wb[i], i);
5232 ai_info->status_reg &= ~AISR_RANGED_ATTACK;
5233 }
5234 }
5235 }
5236 }
5237
5238 return;
5239 }
5240
5241 if (((Gametime - ai_info->last_see_target_time) > 4.0 && (Gametime - ai_info->last_hear_target_time) > 4.0) ||
5242 ai_info->awareness <= AWARE_BARELY) {
5243 ai_info->status_reg &= ~AISR_RANGED_ATTACK;
5244 return;
5245 }
5246
5247 for (i = 0; i < pm->num_wbs; i++) {
5248 vector target_dir[3];
5249 float dot[3];
5250 vector gun_point[3];
5251 vector gun_normal[3];
5252 float ta[3];
5253 int best_dot = WB_MOVE_STILL;

Callers 1

AIDoFrameFunction · 0.85

Calls 15

WBIsBatteryReadyFunction · 0.85
WBSetupFireAnimFunction · 0.85
GoalAddGoalFunction · 0.85
WBFireBatteryFunction · 0.85
WeaponCalcGunFunction · 0.85
vm_NormalizeVectorFunction · 0.85
MultiPlay3dSoundFunction · 0.85
DemoWrite3DSoundFunction · 0.85
DemoWriteTurretChangedFunction · 0.85
MultiAddObjTurretUpdateFunction · 0.85
ObjGetFunction · 0.85
fvi_FindIntersectionFunction · 0.85

Tested by

no test coverage detected