# Library Tactitian

**URL:** <https://discourse.codecombat.com/t/library-tactitian/21947>\
**Category:** Level Help\
**Created:** [June 1, 2020, 11:10am UTC](https://discourse.codecombat.com/t/library-tactitian/21947 "2020-06-01T11:10:03Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![anon66968315](https://avatars.discourse-cdn.com/v4/letter/a/a3d4f5/32.png) [@anon66968315](https://discourse.codecombat.com/u/anon66968315)\
**Post date:** [June 1, 2020, 11:10am UTC](https://discourse.codecombat.com/t/library-tactitian/21947/1 "2020-06-01T11:10:03Z")

</div>

![CC LT](https://us1.discourse-cdn.com/flex016/uploads/codecombat/original/2X/f/fb25e79298dcd25c227c742fbdbd0b93d1aac781.jpeg)  
I do not understand why the yellow duck is warning me not to do it. The code is part of the given code…

---

<div class="post-metadata">

**Author:** ![Alexbrand](https://avatars.discourse-cdn.com/v4/letter/a/e9bcb4/32.png) [@Alexbrand](https://discourse.codecombat.com/u/Alexbrand)\
**Post date:** [June 1, 2020, 12:59pm UTC](https://discourse.codecombat.com/t/library-tactitian/21947/2 "2020-06-01T12:59:34Z")

</div>

Hi. Maybe archer is not defined or he’s dead alright?

---

<div class="post-metadata">

**Author:** ![Jeremy\_Yu](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/jeremy_yu/32/12445_2.png) [@Jeremy\_Yu](https://discourse.codecombat.com/u/Jeremy_Yu)\
**Post date:** [June 1, 2020, 9:25pm UTC](https://discourse.codecombat.com/t/library-tactitian/21947/3 "2020-06-01T21:25:23Z")

</div>

Your character is hero not Archer and if you’re aiming for Archer as ally then define archer

---

<div class="post-metadata">

**Author:** ![dedreous](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/dedreous/32/13849_2.png) [@dedreous](https://discourse.codecombat.com/u/dedreous)\
**Post date:** [June 4, 2020, 10:31pm UTC](https://discourse.codecombat.com/t/library-tactitian/21947/4 "2020-06-04T22:31:41Z")

</div>

@anon66968315 are you still having issues with this one? If so, please share all of your code…might need to take a closer look at it.

---

<div class="post-metadata">

**Author:** ![anon66968315](https://avatars.discourse-cdn.com/v4/letter/a/a3d4f5/32.png) [@anon66968315](https://discourse.codecombat.com/u/anon66968315)\
**Post date:** [June 6, 2020, 5:14am UTC](https://discourse.codecombat.com/t/library-tactitian/21947/5 "2020-06-06T05:14:18Z")

</div>

```python
# Hushbaum has been ambushed by ogres!
# She is busy healing her soldiers, you should command them to fight!
# The ogres will send more troops if they think they can get to Hushbaum or your archers, so keep them inside the circle!

# Soldiers spread out in a circle and defend.
def commandSoldier(soldier, soldierIndex, numSoldiers):
    angle = Math.PI * 2 * soldierIndex / numSoldiers
    defendPos = {"x": 41, "y": 40}
    defendPos.x += 10 * Math.cos(angle)
    defendPos.y += 10 * Math.sin(angle)
    hero.command(soldier, "defend", defendPos);

# Find the strongest target (most health)
# This function returns something! When you call the function, you will get some value back.
def findStrongestTarget():
    mostHealth = 0
    bestTarget = None
    enemies = hero.findEnemies()
    # Figure out which enemy has the most health, and set bestTarget to be that enemy.
    for enemy in enemies:
        if enemy.health > mostHealth:
            bestTarget = enemy
            mostHealth = enemy.health
        return weakest
    # Only focus archers' fire if there is a big ogre.
    if bestTarget and bestTarget.health > 15:
        return bestTarget
    else:
        return None

# If the strongestTarget has more than 15 health, attack that target. Otherwise, attack the nearest target.
def commandArcher(archer):
    archer = hero.findFriends("archer")
    nearest = archer.findNearestEnemy()
    if archerTarget:
        hero.command(archer, "attack", archerTarget)
    elif nearest:
        hero.command(archer, "attack", nearest)

archerTarget = None

while True:
    # If archerTarget is defeated or doesn't exist, find a new one.
    if not archerTarget or archerTarget.health <= 0:
        # Set archerTarget to be the target that is returned by findStrongestTarget()
        archerTarget = findStrongestTarget()
    
    friends = hero.findFriends()
    soldiers = hero.findByType("soldier")
    # Create a variable containing your archers.
    archers = hero.findByType("archer")
    for i in range(len(soldiers)):
        soldier = soldiers[i]
        commandSoldier(soldier, i, len(soldiers));
    # use commandArcher() to command your archers
    commandArcher()

```

The humans always die, idk why. I thought Hushbaum was supposed to heal them automatically?

---

<div class="post-metadata">

**Author:** ![anon66968315](https://avatars.discourse-cdn.com/v4/letter/a/a3d4f5/32.png) [@anon66968315](https://discourse.codecombat.com/u/anon66968315)\
**Post date:** [June 6, 2020, 5:15am UTC](https://discourse.codecombat.com/t/library-tactitian/21947/6 "2020-06-06T05:15:42Z")

</div>

![CC](https://us1.discourse-cdn.com/flex016/uploads/codecombat/original/2X/b/b0f5ad28399d56ee6927575a1d6e4d4e604c7431.jpeg)  
now it is doing this… idk why

---

<div class="post-metadata">

**Author:** ![anon66968315](https://avatars.discourse-cdn.com/v4/letter/a/a3d4f5/32.png) [@anon66968315](https://discourse.codecombat.com/u/anon66968315)\
**Post date:** [June 6, 2020, 5:39am UTC](https://discourse.codecombat.com/t/library-tactitian/21947/7 "2020-06-06T05:39:46Z")

</div>

Actually nvm. I solved it! 🙂
