Advertisement
Pr0nogo

Untitled

Jul 4th, 2020
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. pub unsafe fn get_std_attack_target_proc_hook(
  2. target: *mut bw::Unit,
  3. unit: *mut bw::Unit,
  4. orig: &dyn Fn(*mut bw::Unit, *mut bw::Unit,)->u32,)->u32 {
  5. let unit = match Unit::from_ptr(unit) {
  6. Some(s) => s,
  7. None => {
  8. return orig(target, unit);
  9. },
  10. };
  11. let target = match Unit::from_ptr(target) {
  12. Some(s) => s,
  13. None => {
  14. return orig(target, unit.0);
  15. },
  16. };
  17. let spriteTgt = (*target.0).sprite;
  18. if unit.0 != target.0 {
  19. if (((1 << (*unit.0).player) as u8) & (*spriteTgt).visibility_mask) == 1 {
  20. let mut canAttack: u32 = 0;
  21. canAttack = bw::can_attack_target(target.0, unit.0, 1);
  22. if canAttack != null_mut() {
  23. if bw::are_enemies(unit.0 as u32, target.0 as u32) {
  24. if bw::unk_6955B8[9] == 0 || (bw::is_in_area(unit.0, bw::unk_6955B8[9], target.0) == 0 && bw::is_in_area(unit.0, bw::max_range_px, target.0) != 0) {
  25. let mut sub = (*unit.0).subunit;
  26. if bw::issubunit((*unit.0).subunit) == 0 {
  27. sub = unit.0;
  28. }
  29. if (*sub.0).flags & 0x10000 == 0 { // Full auto attack
  30. if bw::check_firing_angle((*spriteTgt).position + 2, (*spriteTgt).position, sub, bw::units_dat_ground_weapon[(*sub.0).unit_id as u16]) == 0 {
  31. return 0;
  32. }
  33. }
  34. if bw::is_unk_target(unit.0, target.0) == 0 {
  35. let mut threatLevel = bw::get_threat_level(unit.0, target.0);
  36. bw::add_unit_to_possible_targets(threatLevel, target.0);
  37. }
  38. }
  39. }
  40. }
  41. }
  42. }
  43. return 0;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement