Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- pub unsafe fn get_std_attack_target_proc_hook(
- target: *mut bw::Unit,
- unit: *mut bw::Unit,
- orig: &dyn Fn(*mut bw::Unit, *mut bw::Unit,)->u32,)->u32 {
- let unit = match Unit::from_ptr(unit) {
- Some(s) => s,
- None => {
- return orig(target, unit);
- },
- };
- let target = match Unit::from_ptr(target) {
- Some(s) => s,
- None => {
- return orig(target, unit.0);
- },
- };
- let spriteTgt = (*target.0).sprite;
- if unit.0 != target.0 {
- if (((1 << (*unit.0).player) as u8) & (*spriteTgt).visibility_mask) == 1 {
- let mut canAttack: u32 = 0;
- canAttack = bw::can_attack_target(target.0, unit.0, 1);
- if canAttack != null_mut() {
- if bw::are_enemies(unit.0 as u32, target.0 as u32) {
- 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) {
- let mut sub = (*unit.0).subunit;
- if bw::issubunit((*unit.0).subunit) == 0 {
- sub = unit.0;
- }
- if (*sub.0).flags & 0x10000 == 0 { // Full auto attack
- if bw::check_firing_angle((*spriteTgt).position + 2, (*spriteTgt).position, sub, bw::units_dat_ground_weapon[(*sub.0).unit_id as u16]) == 0 {
- return 0;
- }
- }
- if bw::is_unk_target(unit.0, target.0) == 0 {
- let mut threatLevel = bw::get_threat_level(unit.0, target.0);
- bw::add_unit_to_possible_targets(threatLevel, target.0);
- }
- }
- }
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement