# Sarven Brawl and electrocute

**URL:** <https://discourse.codecombat.com/t/sarven-brawl-and-electrocute/3989>\
**Category:** Uncategorized\
**Created:** [May 21, 2015, 5:27am UTC](https://discourse.codecombat.com/t/sarven-brawl-and-electrocute/3989 "2015-05-21T05:27:35Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![ChronistGilver](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/chronistgilver/32/3778_2.png) [@ChronistGilver](https://discourse.codecombat.com/u/ChronistGilver)\
**Post date:** [May 21, 2015, 5:27am UTC](https://discourse.codecombat.com/t/sarven-brawl-and-electrocute/3989/1 "2015-05-21T05:27:35Z")

</div>

When I use `electrocute` in Sarven Brawl, it seems to stop my loop entirely for a bit, before before casting Chain Lightning and continuing. What is going on? Is it my code?

```python
loop:
    yak = self.findNearest(self.findByType("sand-yak"))    
    enemy = self.findNearest(removeByType(self.findEnemies(), "sand-yak"))
    [...]
        elif self.canCast("chain-lightning"):
            if yak:
                if self.distanceTo(yak) < 10:
                    continue
                else:
                    self.cast("chain-lightning", enemy)
        elif self.isReady("bash"):
        [...]    

```

---

<div class="post-metadata">

**Author:** ![Vlevo](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/vlevo/32/2074_2.png) [@Vlevo](https://discourse.codecombat.com/u/Vlevo)\
**Post date:** [May 21, 2015, 8:19am UTC](https://discourse.codecombat.com/t/sarven-brawl-and-electrocute/3989/2 "2015-05-21T08:19:22Z")

</div>

Are you talking about Electrocute (steel ring) or Chain-lightning? Because your comment mentions both in a confusing way…

---

<div class="post-metadata">

**Author:** ![ChronistGilver](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/chronistgilver/32/3778_2.png) [@ChronistGilver](https://discourse.codecombat.com/u/ChronistGilver)\
**Post date:** [May 21, 2015, 4:36pm UTC](https://discourse.codecombat.com/t/sarven-brawl-and-electrocute/3989/3 "2015-05-21T16:36:57Z")

</div>

I mean that when I cast `electrocute` with the Steel Ring, my hero casts it, then stands there for a bit and does nothing, besides building archers when I have enough gold, then casts `chain-lightning` and jumps back into action.

---

<div class="post-metadata">

**Author:** ![Vlevo](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/vlevo/32/2074_2.png) [@Vlevo](https://discourse.codecombat.com/u/Vlevo)\
**Post date:** [May 22, 2015, 7:22pm UTC](https://discourse.codecombat.com/t/sarven-brawl-and-electrocute/3989/4 "2015-05-22T19:22:30Z")

</div>

Is there a yak nearby when this happens? (because if you can do chain lightning and there is a yak near by you will never bash or attack.)

As a side question what is the point of “shield + attack/bash/cleave” at best this would be shield for a tiny amount of time . . . time which would allow the opponent to hit you instead of you killing them first.

---

<div class="post-metadata">

**Author:** ![ChronistGilver](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/chronistgilver/32/3778_2.png) [@ChronistGilver](https://discourse.codecombat.com/u/ChronistGilver)\
**Post date:** [May 22, 2015, 7:57pm UTC](https://discourse.codecombat.com/t/sarven-brawl-and-electrocute/3989/5 "2015-05-22T19:57:22Z")

</div>

No, I am in the center canyon when this happens, and no yaks ever spawn there.

Would they really? I find that without the shield, we hit each other at the same time at best.

---

<div class="post-metadata">

**Author:** ![Vlevo](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/vlevo/32/2074_2.png) [@Vlevo](https://discourse.codecombat.com/u/Vlevo)\
**Post date:** [May 22, 2015, 8:01pm UTC](https://discourse.codecombat.com/t/sarven-brawl-and-electrocute/3989/6 "2015-05-22T20:01:28Z")

</div>

I’ll go run your code and see what I can see. 😄

(that could depend on your weapon)  
Hmm, so then the question becomes do they actually do less damage if you do a “single” shield action.

---

<div class="post-metadata">

**Author:** ![Vlevo](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/vlevo/32/2074_2.png) [@Vlevo](https://discourse.codecombat.com/u/Vlevo)\
**Post date:** [May 22, 2015, 9:16pm UTC](https://discourse.codecombat.com/t/sarven-brawl-and-electrocute/3989/7 "2015-05-22T21:16:16Z")

</div>

Sorry, I partially misspoke earlier: if you canCast chain-lightning you will never do bash/attack.

The canCast is actually the problem in your code.

You never cast chain lightning unless there is a distant yak. No yak == no chain-lightning . . . Good thing you are probably wearing the silly twilight glasses…

I had a hard time getting pauses that I couldn’t blame on other things. Mainly, the “canCast” since I can’t see yaks from the center, my hero does nothing except summon, cleave, and zap until I get around a corner and can see yaks, then I get to chain and can start attacking. Once I fixed the canCast logic the only pauses I got were because I couldn’t see any enemies.

You should probably have have a canElectrocute(enemy) on your if isReady-electrocute (though this shouldn’t really matter on this level).

(shield: if _melee_ enemy far away shield does nothing for you. Just so we are clear, I believe shield is a waste if not used “continuously”, but then I usually write my code in clojure where shield is somehow totally worthless **period**. So maybe I’m biased…) 😄

Question - why do you care about yaks if you are using chain-lightning but not if you are cleaving?

---

<div class="post-metadata">

**Author:** ![ChronistGilver](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/chronistgilver/32/3778_2.png) [@ChronistGilver](https://discourse.codecombat.com/u/ChronistGilver)\
**Post date:** [May 22, 2015, 10:43pm UTC](https://discourse.codecombat.com/t/sarven-brawl-and-electrocute/3989/8 "2015-05-22T22:43:52Z")

</div>

The `cleave` was just there because I haven’t gotten around to editing it out yet. I’m using a non-cleaving weapon, anyhow. Plus, Chain Lightning has a range of twenty-five, so I’m in more danger of hitting a Sand Yak by accident with it than with cleave.

EDIT: Oh, that’s my problem! I just realized I was wearing Kithgard Worker’s Glasses, and therefore couldn’t see through walls. Fail on my part.
