Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function stunBot(self,others,storage){
- let turnsLeft=999-turn()
- let lowestHpBots=others.sort((a,b)=>a.hp-b.hp)
- const shieldTurns=2;
- const farmTurns=3;
- if(!storage.teammateUid){
- if(turn()<=shieldTurns){
- return shield()
- }else if(turn()<=farmTurns+shieldTurns){
- return farm()
- }else if(turn()===farmTurns+shieldTurns+1){
- try{
- teammate=others.find(bot=>bot.hp===self.hp+self.shield)
- storage.teammateUid=teammate.uid
- return shield()
- }catch(e){//failed to id teammate
- return shield()
- }
- }else{
- return farm()
- }
- }else if(self.hp<=(95-self.levels.heal)){
- return heal()
- }else if(self.shield<=100||self.shield<=5500/others.length&&self.shield<=1200&&turn()>=20||lowestHpBots[1]&&lowestHpBots[1].hp>self.hp+self.shield){
- return shield()
- }else if(self.gold>=cost(self.levels.shield)&&self.levels.shield<=4&&turnsLeft>20){
- return upgrade("shield")
- }else{
- enemies=others.filter(bot=>bot.uid!==storage.teammateUid)
- if(enemies.length>0){
- return stun(enemies.sort((a,b)=>b.worth-a.worth)[0].uid)
- }else{
- if((others[0].attack*1.25+7)*(turnsLeft-1)<=self.hp+self.shield+15){//suicide so its teammate gets more gold
- return farm()
- }else if(self.hp<=(20-self.levels.heal)){
- return heal()
- }else if(self.gold>=cost(self.levels.farm)&&turnsLeft>100){
- return upgrade("farm")
- }else{
- return farm()
- }
- }
- }
- }
- function attackBot(self,others,storage){
- let turnsLeft=999-turn()
- let lowestHpBots=others.sort((a,b)=>a.hp-b.hp)
- let maxDamage=others.map(c=>c.attack).reduce((a, b) => Math.max(a, b))*1.25+5
- const shieldTurns=2;
- const farmTurns=3;
- if(!storage.worth){
- storage.worth=5
- storage.prevGold=self.gold
- }else if(self.gold>storage.prevGold){
- storage.worth+=self.gold-storage.prevGold
- }
- if(!storage.teammateUid){
- if(turn()<=shieldTurns){
- return shield()
- }else if(turn()<=farmTurns+shieldTurns){
- return farm()
- }else if(turn()===farmTurns+shieldTurns+1){
- try{
- teammate=others.find(bot=>bot.hp===self.hp+self.shield)
- storage.teammateUid=teammate.uid
- return shield()
- }catch(e){//failed to id teammate
- //console.log("Failed")
- return shield()
- }
- }else{//failed to id teammate
- if(others.length===1&&storage.worth>others[0].worth){
- //stun lock the other bot if there are only 2 left and I can win
- return stun(others[0].uid)
- }else if(self.hp<=(95-self.levels.heal)){
- return heal()
- }else if(lowestHpBots[0]&&lowestHpBots[0].hp<20&&lowestHpBots[0].worth/2>2*self.levels.farm+5&&self.hp+self.shield>=110){
- //kill assist
- return attack(lowestHpBots[0].uid)
- } else if(self.shield<=100||self.shield<=5500/others.length&&self.shield<=1200&&turn()>=20||lowestHpBots[1]&&lowestHpBots[1].hp>self.hp+self.shield){
- return shield()
- }else if(self.gold>=cost(self.levels.shield)&&self.levels.shield<=8){
- return upgrade("shield")
- } else if(self.gold>=cost(self.levels.farm)&&(turnsLeft+1)*(2*(self.levels.farm)+5)<turnsLeft*(2*(self.levels.farm+1)+5)){
- return upgrade("farm")
- } else if(self.gold>=cost(self.levels.heal)&&(turnsLeft+1)/(self.levels.heal+5)*(2*self.levels.farm+5)<turnsLeft/(self.levels.heal+6)*(2*self.levels.farm+5)&&self.levels.heal<=2){
- return upgrade("heal")
- }else{
- return farm()
- }
- }
- }else if(self.hp<=(95-self.levels.heal)){
- return heal()
- }else if(lowestHpBots[0]&&lowestHpBots[0].hp<=maxDamage+self.levels.attack*1.25+5&&lowestHpBots[0].worth/2>2*self.levels.farm+5&&self.hp+self.shield>=110){
- //kill assist
- return attack(lowestHpBots[0].uid)
- }else if(self.shield<=100||self.shield<=5500/others.length&&self.shield<=1200&&turn()>=20||lowestHpBots[1]&&lowestHpBots[1].hp>self.hp+self.shield){
- return shield()
- } else if(self.gold>=cost(self.levels.attack)&&turnsLeft>20){
- return upgrade("attack")
- }else if(self.gold>=cost(self.levels.shield)&&self.levels.shield<=4&&turnsLeft>20){
- return upgrade("shield")
- }else{
- enemies=others.filter(bot=>bot.uid!==storage.teammateUid)
- if(enemies.length>0){
- return attack(enemies.sort((a,b)=>b.worth-a.worth)[0].uid)
- }else{
- if((self.attack*1.25+7)*(turnsLeft-1)<=others[0].hp+15&&(2*self.levels.farm+5)*turnsLeft<others[0].worth/2){//kill its teammate for more gold at the end of the game
- return attack(storage.teammateUid)
- }else if(self.hp<=(95-self.levels.heal)){
- return heal()
- }else if(self.gold>=cost(self.levels.farm)&&turnsLeft>100){
- return upgrade("farm")
- }else{
- return farm()
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment