Checks to see if tractor beam pulling can commence/continue
| 6334 | |
| 6335 | // Checks to see if tractor beam pulling can commence/continue |
| 6336 | bool AlienBoss::DoStingAttack(int me) { |
| 6337 | matrix orient; |
| 6338 | vector vec_to_target; |
| 6339 | int target_handle; |
| 6340 | float fov_angle; |
| 6341 | |
| 6342 | // Make sure we still have a target |
| 6343 | AI_Value(me, VF_GET, AIV_I_TARGET_HANDLE, &target_handle); |
| 6344 | if (target_handle == OBJECT_HANDLE_NONE) |
| 6345 | return false; |
| 6346 | |
| 6347 | // check distance to target |
| 6348 | float dist; |
| 6349 | AI_Value(me, VF_GET, AIV_F_DIST_TO_TARGET, &dist); |
| 6350 | if (dist > AB_MAX_STING_DIST) |
| 6351 | return false; |
| 6352 | |
| 6353 | // check FOV position of target (greater than 45 degrees is too much) |
| 6354 | Obj_Value(me, VF_GET, OBJV_M_ORIENT, &orient); |
| 6355 | |
| 6356 | // NOTE: do my own vec to target here! (chris' doesn't update quick enough) |
| 6357 | AI_Value(me, VF_GET, AIV_V_VEC_TO_TARGET, &vec_to_target); |
| 6358 | vm_VectorNormalize(&vec_to_target); |
| 6359 | fov_angle = orient.fvec * vec_to_target; |
| 6360 | if (fov_angle < 0.7f) |
| 6361 | return false; |
| 6362 | |
| 6363 | // see if anything is in the way |
| 6364 | ray_info ray; |
| 6365 | int flags, fate; |
| 6366 | vector start_pos, end_pos, landing_pos; |
| 6367 | int start_room, landing_room; |
| 6368 | float target_size; |
| 6369 | |
| 6370 | Obj_Value(me, VF_GET, OBJV_V_POS, &start_pos); |
| 6371 | Obj_Value(me, VF_GET, OBJV_I_ROOMNUM, &start_room); |
| 6372 | Obj_Value(target_handle, VF_GET, OBJV_V_POS, &end_pos); |
| 6373 | Obj_Value(target_handle, VF_GET, OBJV_F_SIZE, &target_size); |
| 6374 | |
| 6375 | flags = FQ_CHECK_OBJS | FQ_IGNORE_POWERUPS | FQ_IGNORE_WEAPONS | FQ_IGNORE_MOVING_OBJECTS | |
| 6376 | FQ_IGNORE_NON_LIGHTMAP_OBJECTS; |
| 6377 | fate = FVI_RayCast(me, &start_pos, &end_pos, start_room, target_size, flags, &ray); |
| 6378 | if (fate != HIT_NONE) |
| 6379 | return false; |
| 6380 | |
| 6381 | // Create the lightning effect for the sting attack |
| 6382 | aLightningCreate(target_handle, memory->tail_pos_handle, 0.4f, 1.0f, 3, transfer_effect_id, 0.4f, 1, 255, 255, 255, |
| 6383 | false); |
| 6384 | |
| 6385 | // Damage the target |
| 6386 | aObjApplyDamage(target_handle, AB_STING_DAMAGE); |
| 6387 | |
| 6388 | // Play damaged sound for target |
| 6389 | |
| 6390 | mprintf(0, "Did sting attack.\n"); |
| 6391 | |
| 6392 | return true; |
| 6393 | } |
nothing calls this directly
no test coverage detected