Play Home Contribute GitHub Join Us Discourse Staff Members GitHub Contribution Guides Team

Simpler is better? (Sacred Statue)


Fun level, btw. Not sure if this is interesting, but I was shocked to find that some really simple code worked way better than what I would have thought was better and more sophisticated code. I’ll play around with this tomorrow and try to figure it out but thought I’d do a quick post in case this is interesting to others.

This is Sacred Statue 2 and this code is at the end of the level (staying near the statue) I use it for both the ogre invasion and cyclops. I’m using Tharin and start out with 782 in health.

# this stupidly simple code works great
    enemy = self.findNearest(self.findEnemies())
    if enemy: 

# i thought i would spruce it up a little, but now it works much worse!     
    enemy = self.findNearest(self.findEnemies())
    if enemy and self.distanceTo(enemy) < 3: 
        while > 0:
            if self.isReady("bash"):
            elif self.isReady("power-up"):


Hmm… I think it might be the distance < 3 part. I changed that to 5 and it works about the same as the simpler code. The sword attack range is only 3, but I guess the 5 is better because with enemies moving towards you you need to start attacking before they are in range.


The first few difficulties are pretty easy and intended to be. Wait til you start getting the harder enemies…


You probably don’t want to always attack after bashing in your while loop, and you might want to only bash if the enemy you’re attacking has more health than your attack damage, and you could also save the power-up for when the enemy has so much health that the powerup will be high DPS (or do the powerup when the enemies aren’t around).


OK, thanks Nick. Good tip about the power-up, I hadn’t thought about that. It takes a full second so need to be careful about doing that while surrounded by a swarm of enemies.