# Dueling Grounds - not a fair fight

**URL:** <https://discourse.codecombat.com/t/dueling-grounds-not-a-fair-fight/18062>\
**Category:** Level Help\
**Created:** [April 5, 2019, 2:38am UTC](https://discourse.codecombat.com/t/dueling-grounds-not-a-fair-fight/18062 "2019-04-05T02:38:46Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![brooksy125](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/brooksy125/32/9966_2.png) [@brooksy125](https://discourse.codecombat.com/u/brooksy125)\
**Post date:** [April 5, 2019, 2:38am UTC](https://discourse.codecombat.com/t/dueling-grounds-not-a-fair-fight/18062/1 "2019-04-05T02:38:46Z")

</div>

After the enemy goes invisible, my hero can’t ever find him/her again. I cut out everything except these lines of code, and nothing happens except he walks towards the enemy. Also, I have not lost but a few matches, but can’t seem to improve my score. I get a lot of Ties that seem linked to the fights not actually happening. Why can’t my hero (ogre side) find the human enemy reliably?

```python
while True:
    enemy = hero.findNearestEnemy()
    if enemy:
        hero.attack(enemy)
    else:
        hero.shield()

```

 ![Missing%20Enemy](https://us1.discourse-cdn.com/flex016/uploads/codecombat/original/2X/0/036a39ab3c210d72d329d92d567027d1bf890c61.jpeg)

---

<div class="post-metadata">

**Author:** ![Chaboi\_3000](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/chaboi_3000/32/48486_2.png) [@Chaboi\_3000](https://discourse.codecombat.com/u/Chaboi_3000)\
**Post date:** [April 5, 2019, 5:48am UTC](https://discourse.codecombat.com/t/dueling-grounds-not-a-fair-fight/18062/2 "2019-04-05T05:48:29Z")

</div>

I don’t see this problem. Naria’s hide will wear off after the invisibility, so heroes should be able to attack.

---

<div class="post-metadata">

**Author:** ![Deadpool198](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/deadpool198/32/16753_2.png) [@Deadpool198](https://discourse.codecombat.com/u/Deadpool198)\
**Post date:** [April 5, 2019, 7:51am UTC](https://discourse.codecombat.com/t/dueling-grounds-not-a-fair-fight/18062/4 "2019-04-05T07:51:22Z")

</div>

I get this a lot. It’s caused by you seeing the enemy, deciding to attack, then the enemy goes invisible and you’re still moving towards them. You can try a variety of strategies to prevent this:

```python
#this is one combining wait and checking for invis. Not sure whether this will work in your particular situation
#so try experimenting with wait and checking for effect("hide"). It's worked for me.
if enemy:
     hero.wait(0.01)
     if not enemy.hasEffect("hide"):
         hero.attack(enemy)
     else:
         hero.shield()
else:
    hero.shield()

```

🦁 🦁 🦁

---

<div class="post-metadata">

**Author:** ![Chaboi\_3000](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/chaboi_3000/32/48486_2.png) [@Chaboi\_3000](https://discourse.codecombat.com/u/Chaboi_3000)\
**Post date:** [April 5, 2019, 9:11am UTC](https://discourse.codecombat.com/t/dueling-grounds-not-a-fair-fight/18062/5 "2019-04-05T09:11:14Z")

</div>

A solution to this issue could be something like. Adding a check to the attack() component:

```python
checkIfHidden: ->
    if target.alpha=1
        # Do something here to find a new target.

```

I forgot how they did the “Invisible” part, but I think it was something like target.alpha or something. Anyway, the `attack()` method should “check” before performing the attacking.

---

<div class="post-metadata">

**Author:** ![brooksy125](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/brooksy125/32/9966_2.png) [@brooksy125](https://discourse.codecombat.com/u/brooksy125)\
**Post date:** [April 5, 2019, 11:27am UTC](https://discourse.codecombat.com/t/dueling-grounds-not-a-fair-fight/18062/6 "2019-04-05T11:27:35Z")

</div>

Thanks for the tips!! I didn’t realize you could check the enemy for invisibility. I was thinking you could only use .hasEffect(“hide”) when your hero cast the invisibility spell. Looking forward to adding this check in all my fights.

Just know @Deadpool198, I’m gunning for you!! 🤠 So don’t be too eager to give me all of your tricks.

---

<div class="post-metadata">

**Author:** ![Deadpool198](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/deadpool198/32/16753_2.png) [@Deadpool198](https://discourse.codecombat.com/u/Deadpool198)\
**Post date:** [April 5, 2019, 3:55pm UTC](https://discourse.codecombat.com/t/dueling-grounds-not-a-fair-fight/18062/7 "2019-04-05T15:55:39Z")

</div>

😄_heh_. I’ll let you know when I can find you on the leaderboard. (jokinnggg…)  
🦁 🦁 🦁

---

<div class="post-metadata">

**Author:** ![brooksy125](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/brooksy125/32/9966_2.png) [@brooksy125](https://discourse.codecombat.com/u/brooksy125)\
**Post date:** [April 5, 2019, 4:46pm UTC](https://discourse.codecombat.com/t/dueling-grounds-not-a-fair-fight/18062/8 "2019-04-05T16:46:28Z")

</div>

I’m 15th in Harrowland without Boss star 4:  
23rd in Zero Sum red side. I can’t find you on that one.  
60th on Treasure Grove red side

I’m circling back to the other multiplayer levels to upgrade their code now that I understand the combat approach and simulations. I still need to finish Cloudrip Mtn and Kelvintaph Glacier. By that time I hope to have enough gems for Ritic, [which I hear you don’t have](https://discourse.codecombat.com/t/post-picures-of-funny-things-that-have-happened-in-your-game/14338/6?u=brooksy125). Ritic may be your end!!

---

<div class="post-metadata">

**Author:** ![JuIcEbOx\_KiNg](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/juicebox_king/32/10193_2.png) [@JuIcEbOx\_KiNg](https://discourse.codecombat.com/u/JuIcEbOx_KiNg)\
**Post date:** [April 5, 2019, 6:29pm UTC](https://discourse.codecombat.com/t/dueling-grounds-not-a-fair-fight/18062/9 "2019-04-05T18:29:34Z")

</div>

Why do my Harrowland matches become messed up when I try to challenge someone on the ladder? I will do the AI challange, then try to do another fight with a medium level person, and then my weapons will degrade. I had a samurai sword, and the defensive infantry shield. After the AI match, my weapons changed to the rough edge and the basic round shield. Why does this happen? 🤔

---

<div class="post-metadata">

**Author:** ![xython](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/xython/32/7269_2.png) [@xython](https://discourse.codecombat.com/u/xython)\
**Post date:** [April 5, 2019, 8:34pm UTC](https://discourse.codecombat.com/t/dueling-grounds-not-a-fair-fight/18062/10 "2019-04-05T20:34:46Z")

</div>

Did you debug your code?

```python
if enemy: # I always check enemy and enemy.health > 0
     hero.wait(0.01) # how do you to test this line?
     if not enemy.hasEffect("hide"):
         hero.attack(enemy)
     else: # you mean if enemy.hasEffect("hide")?
         hero.shield() 
           # to see if this else is ever reached put
         console.log( 'hide') # Do you have an output
                               # in the browser console? I'm not sure
else:
    hero.shield() # why do you shield when there is no enemy?
                   # I think it's better to move to another place or stay still

```

@brooksy125 you freeze and lose against a simple invisibility cast.  
Why do you use flags? They cannot compete with code.

 ![multy](https://us1.discourse-cdn.com/flex016/uploads/codecombat/original/2X/0/0a13dd18031ca95b40fdb07b8380b793970debf1.jpeg)

---

<div class="post-metadata">

**Author:** ![JuIcEbOx\_KiNg](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/juicebox_king/32/10193_2.png) [@JuIcEbOx\_KiNg](https://discourse.codecombat.com/u/JuIcEbOx_KiNg)\
**Post date:** [April 5, 2019, 10:28pm UTC](https://discourse.codecombat.com/t/dueling-grounds-not-a-fair-fight/18062/11 "2019-04-05T22:28:33Z")

</div>

What do you mean @xython? I change my code almost every time I fight. It’s my weapons/items that change.

---

<div class="post-metadata">

**Author:** ![ducky](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/ducky/32/9364_2.png) [@ducky](https://discourse.codecombat.com/u/ducky)\
**Post date:** [April 5, 2019, 11:02pm UTC](https://discourse.codecombat.com/t/dueling-grounds-not-a-fair-fight/18062/12 "2019-04-05T23:02:36Z")

</div>

Do you not see that xython is not responding to you, but to Deadpool198?

---

<div class="post-metadata">

**Author:** ![JuIcEbOx\_KiNg](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/juicebox_king/32/10193_2.png) [@JuIcEbOx\_KiNg](https://discourse.codecombat.com/u/JuIcEbOx_KiNg)\
**Post date:** [April 5, 2019, 11:03pm UTC](https://discourse.codecombat.com/t/dueling-grounds-not-a-fair-fight/18062/13 "2019-04-05T23:03:20Z")

</div>

Yes, I saw. I apologize. Whoops

---

<div class="post-metadata">

**Author:** ![brooksy125](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/brooksy125/32/9966_2.png) [@brooksy125](https://discourse.codecombat.com/u/brooksy125)\
**Post date:** [April 5, 2019, 11:36pm UTC](https://discourse.codecombat.com/t/dueling-grounds-not-a-fair-fight/18062/14 "2019-04-05T23:36:05Z")

</div>

@xython I realized that I lose against a simple invisibility cast. That’s why I started this post. My current code does not have flags, not sure why you are seeing them. I don’t see any when I watch one of my matches. It took me a minute to realize you had a screen shot of Treasure Grove and not Dueling Grounds.

---

<div class="post-metadata">

**Author:** ![xython](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/xython/32/7269_2.png) [@xython](https://discourse.codecombat.com/u/xython)\
**Post date:** [April 5, 2019, 11:49pm UTC](https://discourse.codecombat.com/t/dueling-grounds-not-a-fair-fight/18062/15 "2019-04-05T23:49:49Z")

</div>

Did you try the Deadpool code? If you are using the commented code:  
 ![bits](https://us1.discourse-cdn.com/flex016/uploads/codecombat/original/2X/5/591f4d8d08a03561f3f6aefc68b5d7b260ce2275.jpeg)  
you can freeze yourself without the enemy help:

```python
if ready lightnig -> ligthnig and you kill an enemy minion
if ready throw -> you try to throw a dead enemy and you freeze

```

so I think it’s better to use if/elif/elif/else .

---

<div class="post-metadata">

**Author:** ![brooksy125](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/brooksy125/32/9966_2.png) [@brooksy125](https://discourse.codecombat.com/u/brooksy125)\
**Post date:** [April 6, 2019, 12:07am UTC](https://discourse.codecombat.com/t/dueling-grounds-not-a-fair-fight/18062/16 "2019-04-06T00:07:21Z")

</div>

I had other checks that were removed when I started focusing on the invisibility problem, but I understand what you mean. I have run into that problem.

---

<div class="post-metadata">

**Author:** ![Deadpool198](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/deadpool198/32/16753_2.png) [@Deadpool198](https://discourse.codecombat.com/u/Deadpool198)\
**Post date:** [April 6, 2019, 8:19am UTC](https://discourse.codecombat.com/t/dueling-grounds-not-a-fair-fight/18062/17 "2019-04-06T08:19:30Z")

</div>

> [@brooksy125](#):
>
> I’m 15th in Harrowland without Boss star 4:  
> 23rd in Zero Sum red side. I can’t find you on that one.  
> 60th on Treasure Grove red side

I was just a joking.

> [@brooksy125](#):
>
> Ritic may be your end!!

Do you have Gift of the Trees? If you don’t there’s no point getting Ritic. He’s really good, but I can beat all the best of them (Archion, DaBeast45, Titus the Titan) with Senick, who I think’s the best hero for dueling grounds even though he only cost 2500 or something.  
🦁 🦁 🦁

---

<div class="post-metadata">

**Author:** ![Deadpool198](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/deadpool198/32/16753_2.png) [@Deadpool198](https://discourse.codecombat.com/u/Deadpool198)\
**Post date:** [April 6, 2019, 11:29am UTC](https://discourse.codecombat.com/t/dueling-grounds-not-a-fair-fight/18062/18 "2019-04-06T11:29:53Z")

</div>

> [@xython](#):
>
> Did you debug your code?
> 
> ```python
> if enemy: # I always check enemy and enemy.health > 0
> hero.wait(0.01) # how do you to test this line? -- I think the main  
> # reason you (not *you* specifically, "one") get 
> # errors from this is that you're trying
> # to do something at the same time that they're
> # (your enemy) casting invis. Therefore if you wait
> # for them to go invisible, then your hero realises 
> # that the enemy's not there and waits for them to
> # come back. (this is tried and tested in the way
> # when I have it, it works, and when I don't, it
> # doesn't.)
> if not enemy.hasEffect("hide"):
> hero.attack(enemy)
> else: # you mean if enemy.hasEffect("hide")? -- Yes, thanks.
> hero.shield() 
> # to see if this else is ever reached put
> console.log( 'hide') # Do you have an output
> # in the browser console? I'm not sure -- I can use
> # hero.say() and I can see that it never reaches it.
> else:
> hero.shield() # why do you shield when there is no enemy? -- Are you
> # talking to Brooksy or me? I only adapted it, I didn't
> # write it.
> # I think it's better to move to another place or stay still
> 
> ```

I have realised this didn’t really work, let me try again:

```python
if enemy:
    hero.wait(0.01)
    if enemy and enemy.health > 0:
        hero.attack(enemy)
# I can't say this will 100% work, and if it doesn't then that's that. In my blue 
# Pender code on Multiplayer treasure grove, Janderfuhren makes me stop doing 
# anything for ages (15 seconds). And then I start again once I can cast the spell
# I originally wanted to cast on the enemy.

```

🦁 🦁 🦁

---

<div class="post-metadata">

**Author:** ![brooksy125](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/brooksy125/32/9966_2.png) [@brooksy125](https://discourse.codecombat.com/u/brooksy125)\
**Post date:** [April 6, 2019, 6:26pm UTC](https://discourse.codecombat.com/t/dueling-grounds-not-a-fair-fight/18062/19 "2019-04-06T18:26:08Z")

</div>

Sorry, didn’t mean to sound so aggressive. Just letting you know that I’m not as far behind as you might think. I definitely have a lot to learn before I can come close to beating your code. I simulated a few matches between us and it was quite entertaining. With your healing ability and the Paladin helping out, I think you still had full health when I was crushed.

I haven’t worked with Rangers yet, but it sounds like I should start particularly for the multiplayer battles. I’m willing to test your theory out about Senick being the best for dueling. 🤓

---

<div class="post-metadata">

**Author:** ![Deadpool198](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/deadpool198/32/16753_2.png) [@Deadpool198](https://discourse.codecombat.com/u/Deadpool198)\
**Post date:** [April 7, 2019, 7:49am UTC](https://discourse.codecombat.com/t/dueling-grounds-not-a-fair-fight/18062/20 "2019-04-07T07:49:04Z")

</div>

It’s fine, when I wrote my first post I was like…should I post this?..It’s a bit… hmm… _but_ I did.  
I also recommend Silver-fire bomb over boom ball and if you’re using Ritic I think either silver-fire bomb or dragon tooth which is really good because ritic has so many ways of going invisible.  
🦁
