class Game:
summonTypes = ['soldier']
excludeType = ['door', 'decoy']
priorityType = []
tacticks = {'skeleton': 'attack', 'paladin': 'defend'}
def __init__(self):
self.team = hero.team
if self.team == 'humans':
self.position = 'left'
else:
self.position = 'right'
hero.debug("self.position", self.position)
self.best_target = None
self.best_target_distance = 9999
hero._earthskin = -10
def findTarget(self): # exclude decoy
best = 0
enemies = hero.findEnemies()
self.best_target = None
self.best_target_distance = 9999
self.enemy_hero = [e for e in hero.findEnemies() if e.id in ["Hero Placeholder", "Hero Placeholder 1"]][0]
for enemy in enemies:
if enemy.type in self.excludeType:
continue
distance = hero.distanceTo(enemy)
current = enemy.maxHealth / distance
# hero.debug(enemy.id,enemy.type, current)
if (best > current and (
(self.position == 'left' and current.pos.x < 70) or (self.position != 'left' and current.pos.x > 90))):
best = current
self.best_target = enemy
self.best_target_distance = distance
if (not (self.best_target)):
self.best_target = hero.findNearestEnemy()
if self.best_target and ((self.position == 'left' and self.best_target.pos.x < 70) or (
self.position != 'left' and self.best_target.pos.x > 90)):
self.best_target_distance = hero.distanceTo(self.best_target)
else:
self.best_target = None
if (self.enemy_hero and ((hero.distanceTo(self.enemy_hero) < 50 or hero.now() > 120) or (
(self.position == 'left' and self.enemy_hero.pos.x < 70) or (
self.position != 'left' and self.enemy_hero.pos.x > 90)))):
self.best_target = self.enemy_hero
self.best_target_distance = hero.distanceTo(self.best_target)
hero.debug("best target", self.best_target)
def moveTo(self, position):
if (hero.isReady("jump")):
hero.jumpTo(position)
else:
hero.move(position)
def summonTroops(self):
type = self.summonTypes[len(hero.built) % len(self.summonTypes)]
if hero.gold > hero.costOf(type):
hero.summon(type)
def commandTroops(self):
for friend in hero.findFriends():
if friend.type == 'paladin':
self._commandPaladin(friend)
elif friend.type == 'soldier' or friend.type == 'archer' or friend.type == 'griffin-rider' or friend.type == 'skeleton':
self._commandSoldier(friend)
elif friend.type == 'peasant':
self._commandPeasant(friend)
def _commandSoldier(self, soldier):
if self.best_target and soldier.distanceTo(self.best_target) < 30:
hero.command(soldier, "attack", self.best_target)
else:
hero.command(soldier, "defend", hero)
def _commandPeasant(self, soldier):
item = soldier.findNearestItem()
if item:
hero.command(soldier, "move", item.pos)
def _commandPaladin(self, paladin):
if (paladin.canCast("heal") and hero.health < hero.maxHealth * 2 / 3):
hero.command(paladin, "cast", "heal", hero)
else:
if self.best_target and paladin.distanceTo(self.best_target) < 30:
hero.command(paladin, "attack", self.best_target)
else:
hero.command(paladin, "defend", hero)
def pickUpNearestItem(self, items):
nearestItem = hero.findNearest(items)
if nearestItem:
moveTo(nearestItem.pos)
def attack(self):
# todo: mass targets
if self.best_target is not None:
if (hero.canCast('fear', self.best_target) and self.best_target_distance < 25 and self.best_target.id in [
"Hero Placeholder", "Hero Placeholder 1"]):
hero.cast('fear', self.best_target)
elif (hero.canCast('drain-life', self.best_target) and self.best_target_distance < 15):
hero.cast('drain-life', self.best_target)
elif (hero.canCast('poison-cloud',
self.best_target) and self.best_target_distance < 30 and self.best_target_distance > 10 and self.best_target.id in [
"Hero Placeholder", "Hero Placeholder 1"]):
hero.cast('poison-cloud', self.best_target)
elif (hero.canCast('chain-lightning', self.best_target) and self.best_target_distance < 30):
hero.cast('chain-lightning', self.best_target)
elif (self.best_target_distance < hero.attackRange):
hero.attack(self.best_target)
else:
if self.position == 'left':
game.moveTo(Vector(50, 70))
else:
game.moveTo(Vector(110, 70))
else:
if self.position == 'left':
game.moveTo(Vector(50, 70))
else:
game.moveTo(Vector(110, 70))
def _canDevour(self):
if not (hero.isReady('devour')):
return None
best_enemy = None
best_enemy_distance = 9999
enemies = hero.findEnemies()
for friend in hero.findFriends():
if (friend.health < 200 and hero.distanceTo(friend) < best_enemy_distance):
best_enemy = friend
best_enemy_distance = hero.distanceTo(friend)
for enemy in enemies:
if (enemy.health < 200 and hero.distanceTo(enemy) < best_enemy_distance):
best_enemy = enemy
best_enemy_distance = hero.distanceTo(enemy)
if (best_enemy and best_enemy_distance > 10):
self.moveTo(best_enemy.pos)
return best_enemy
def _choseSacrifice(self):
for friend in hero.findFriends():
if friend.type == 'burl':
return friend
for friend in hero.findFriends():
if hero.distanceTo(friend) < 50:
return friend
return None
def _action(self):
devourTarget = self._canDevour()
if (devourTarget):
hero.devour(devourTarget)
return
if (hero.health < hero.maxHealth * 1 / 2):
saticfire = self._choseSacrifice()
if (saticfire):
hero.cast("sacrifice", saticfire, hero)
if (hero.canCast('summon-burl', hero)):
hero.cast('summon-burl')
return
if (hero.canCast('earthskin', hero) and hero.now() > 3):
hero.cast('earthskin', hero)
self._earthskin = hero.now()
return
if (hero.canCast('raise-dead')):
courpses = hero.findCorpses()
closest = 0
for courpse in courpses:
if (hero.distanceTo(courpse) <= 20):
closest += 1
if (closest > 5):
hero.cast('raise-dead')
return
if (hero.canCast('summon-undead')): # todo: check for bodies
hero.cast('summon-undead')
return
self.attack()
def run(self):
self.findTarget()
self.summonTroops()
self.commandTroops()
self._action()
def onSpawn(e):
while True:
enemy = hero.findNearestEnemy() # todo: list of closest
if enemy and pet.isReady("chase") and enemy.maxHealth < enemy.maxHealth / 1:
pet.chase(enemy)
# Find and fetch a "potion":
potion = pet.findNearestByType("potion")
if potion:
pet.fetch(potion)
pet.on('spawn', onSpawn)
game = Game()
while True:
game.run()
没有合适的资源?快使用搜索试试~ 我知道了~
资源详情
资源评论
资源推荐
收起资源包目录
CodeCombat:Codecombat (1788个子文件)
.gitignore 54B
Quizlet.html 7KB
Wanted.html 2KB
SiblingRivalry.html 2KB
TransformativeProperties.html 2KB
Animania.html 2KB
MarginalUtility.html 2KB
WantedPoster.html 1KB
EventfulSelectors.html 1KB
BorderPatrol.html 1KB
Clickthrough.html 1KB
Appendix.html 1KB
PrecisionColoring.html 1KB
AttrItude.html 1KB
Tabloid.html 1018B
DisappearingAct.html 990B
Toggulation.html 905B
IdentificationPlease.html 873B
Classy.html 854B
QueryConfirmed.html 791B
ListingIiaison.html 762B
ParagraphParagon.html 757B
BigAndTall.html 716B
OrdersWanted.html 690B
DangerousDivide.html 677B
HoverAndUnder.html 657B
Headliner.html 548B
StylishIntent.html 542B
IllustriousImagery.html 528B
BreakingNews.html 519B
HumbleBeginnings.html 284B
ZeroSum.js 30KB
AceOfCodersWinningStrategy.js 27KB
CaptureTheirFlagOgres.js 3KB
CaptureTheirFlagHumans.js 3KB
BinaryDeployment.js 2KB
BrokenCircles.js 2KB
GreedHuman.js 2KB
GreedOgres.js 2KB
CrossBonesHuman.js 1KB
JavascriptStillnessInMotion.js 1KB
DungeonArenaH.js 1KB
GoldRushO.js 1KB
threes-company.js 1KB
GoldRushH.js 1KB
CrossBonesOgres.js 1KB
StandardOperatingProcedure.js 1KB
GameDev2FinalProject.js 953B
Palimpsest.js 938B
JavascriptAFineMint.js 925B
ArmyTraining2.js 888B
GuardDuty.js 806B
ForestIncursion.js 723B
JavascriptReturnToThornbushFarm.js 687B
ArmyTraining.js 653B
JavascriptLostInTheStacks.js 491B
DungeonArenaO.js 466B
JavascriptMasterOfNames.js 446B
JavascriptFireDancing.js 426B
JavascriptBackToBack.js 426B
JavascriptManiacMunchkins.js 344B
JavascriptPatrolBuster.js 342B
OgresOfHanoi.js 313B
JavascriptTrueNames.js 214B
КiddlingKithmaze.js 176B
SignsAndPortents.js 174B
TrueNames.js 147B
TheRaisedSword.js 122B
ForgetfulGemsmith.js 103B
ShadowGuard.js 85B
GemsInTheDepth.js 82B
KithgardLibrarian.js 53B
BinaryDeployment.lua 714B
Readme.md 1KB
Readme.md 739B
Readme.md 705B
Readme.md 388B
Readme.md 347B
Readme.md 309B
Readme.md 308B
Readme.md 303B
Readme.md 277B
Readme.md 270B
Readme.md 261B
Readme.md 253B
Readme.md 252B
Readme.md 251B
Readme.md 250B
Readme.md 248B
Readme.md 247B
Readme.md 247B
Readme.md 246B
Readme.md 244B
Readme.md 244B
Readme.md 242B
Readme.md 242B
Readme.md 242B
Readme.md 241B
Readme.md 241B
Readme.md 240B
共 1788 条
- 1
- 2
- 3
- 4
- 5
- 6
- 18
君倾策
- 粉丝: 21
- 资源: 4635
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 基于STM32F103C8T6单片机蓄电池在线监测系统主板硬件(原理图+PCB)工程文件.zip
- mysql大纲资料.txt
- c++大纲资料.txt
- 效率工具bat脚本实现日志提取
- MyBatis 中动态 SQL 的示例
- STM8L101F3P6单片机+CC1100模块433M遥控器设计硬件(原理图+PCB)工程文件.zip
- 上传下载铁人下载系统 Liuxing 1.0-liuxing1.0.rar
- 南京邮电大学数学实验实力雄厚,凭借其优秀的师资力量、丰富的实践教学资源和卓越的科研成果,成为国内一流的数学实验教学和科研基地
- 【火爆朋友圈的今天吃什么源码 v1.0】随机的为用户带来每一天的用餐选择和推荐.rar
- MPU6050中文版数据手册
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0