# Bug in mattack::chickenbot, grenade launcher used only when range is exacly 38

**URL:** https://discourse.cataclysmdda.org/t/bug-in-mattack-chickenbot-grenade-launcher-used-only-when-range-is-exacly-38/13571
**Category:** The Garage
**Created:** [April 4, 2017, 8:44pm UTC](https://discourse.cataclysmdda.org/t/bug-in-mattack-chickenbot-grenade-launcher-used-only-when-range-is-exacly-38/13571 "2017-04-04T20:44:27Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![latogato](https://avatars.discourse-cdn.com/v4/letter/l/b9bd4f/32.png) [@latogato](https://discourse.cataclysmdda.org/u/latogato)
#### Post date: [April 4, 2017, 8:44pm UTC](https://discourse.cataclysmdda.org/t/bug-in-mattack-chickenbot-grenade-launcher-used-only-when-range-is-exacly-38/13571/1 "2017-04-04T20:44:27Z")

</div>

I think there is a bug in the mattack::chickenbot, the grenade launcher used only when range is exacly 38.

```auto
bool mattack::chickenbot(monster *z)
{ 
{...}
    case 2:
        if( dist <= 20 ) {
            rifle( z, target );
        }
        break;
    case 3:
        if( dist == 38 ) {
            frag( z, target );
        }
        break;
    default:
        return false; // Weak stuff, shouldn't bother with
    }

    return true;
} 
```

---

<div class="post-metadata">

### Author: ![kevin.granade](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/kevin.granade/32/1316_2.png) [@kevin.granade](https://discourse.cataclysmdda.org/u/kevin.granade)
#### Post date: [April 8, 2017, 10:16pm UTC](https://discourse.cataclysmdda.org/t/bug-in-mattack-chickenbot-grenade-launcher-used-only-when-range-is-exacly-38/13571/2 "2017-04-08T22:16:54Z")

</div>

It’s actually kind of hosed all around, it degraded to the point where it can’t use anything except the tazer attack.

The problem is several combined bugs, one is it always decides to use the grenade launcher, another is an error in calculating sight range, and the final one is the bug you point out that causes it to fail to use the grenade launcher unless it’s at exactly 38 tiles away from the target.

I almost have the bugfixes for all three wrapped up, at which point they will return to full lethality.

---

<div class="post-metadata">

### Author: ![latogato](https://avatars.discourse-cdn.com/v4/letter/l/b9bd4f/32.png) [@latogato](https://discourse.cataclysmdda.org/u/latogato)
#### Post date: [April 13, 2017, 5:01pm UTC](https://discourse.cataclysmdda.org/t/bug-in-mattack-chickenbot-grenade-launcher-used-only-when-range-is-exacly-38/13571/3 "2017-04-13T17:01:00Z")

</div>

I see you fixed it. Thank you, i can’t wait to die by it next time. 😃
