hello i need help to change Goblin Blastmage so it only uses it if i have an mech on the table. because countless times it just uses it without mech -.- i have found a code but dont know if it is right one to edit but i show anyway. Code: using System; using System.Collections.Generic; using System.Text; namespace HREngine.Bots { class Sim_GVG_004 : SimTemplate //Goblin Blastmage { // Battlecry: If you have a Mech, deal 4 damage randomly split among all enemies. public override void getBattlecryEffect(Playfield p, Minion own, Minion target, int choice) { // optimistic bool ownplay = own.own; List<Minion> temp1 = (ownplay) ? p.ownMinions : p.enemyMinions; bool haveAMech = true; foreach (Minion m in temp1) { if ((TAG_RACE)m.handcard.card.race == TAG_RACE.MECHANICAL) haveAMech = false; } if (!haveAMech) return; int i = 0; List<Minion> temp = (ownplay) ? p.enemyMinions : p.ownMinions; int times = (ownplay) ? p.getSpellDamageDamage(4) : p.getEnemySpellDamageDamage(4); if ((ownplay && p.enemyHero.Hp <= times) || (!ownplay && p.ownHero.Hp <= times)) { if (ownplay) p.minionGetDamageOrHeal(p.enemyHero, p.enemyHero.Hp - 1); else p.minionGetDamageOrHeal(p.ownHero, p.ownHero.Hp - 1); } else { while (i < times) { if (temp.Count >= 1) { //search Minion with lowest hp Minion enemy = temp[0]; int minhp = 10000; bool found = false; foreach (Minion m in temp) { if (m.name == CardDB.cardName.nerubianegg && enemy.Hp >= 2) continue; //dont attack nerubianegg! if (m.Hp >= 2 && minhp > m.Hp) { enemy = m; minhp = m.Hp; found = true; } } if (found) { p.minionGetDamageOrHeal(enemy, 1); } else { p.minionGetDamageOrHeal(ownplay ? p.enemyHero : p.ownHero, 1); } } else { p.minionGetDamageOrHeal(ownplay ? p.enemyHero : p.ownHero, 1); } i++; } } } } } i may have fixed it. test for yourself here are the files for Goblin Blastmage and Tinkertown Technician. View attachment Sim_GvG_102.cs View attachment Sim_GvG_004.cs put the files in Routines\DefaultRoutine\Silverfish\cards nvm dont work......
bump please someone that are decent with codes just do a simple fix for this. only use if mech on board.
You contradicted and reversed the mech check boolean. (I also took the liberty of optimizing and further cleaning the code) Try: Code: using System; using System.Collections.Generic; using System.Text; namespace HREngine.Bots { class Sim_GVG_004 : SimTemplate //Goblin Blastmage { public override void getBattlecryEffect(Playfield p, Minion own, Minion target, int choice) { bool myTurn = own.own, hasMech = false; List<Minion> minions = (myTurn ? p.ownMinions : p.enemyMinions); foreach (Minion m in minions) if ((TAG_RACE)m.handcard.card.race == TAG_RACE.MECHANICAL) { hasMech = true; break; } if (!hasMech) return; minions = (myTurn ? p.enemyMinions : p.ownMinions); int times = (myTurn ? p.getSpellDamageDamage(4) : p.getEnemySpellDamageDamage(4)); if ((myTurn && (p.enemyHero.Hp <= times)) || (!myTurn && (p.ownHero.Hp <= times))) { if (myTurn) p.minionGetDamageOrHeal(p.enemyHero, (p.enemyHero.Hp - 1)); else p.minionGetDamageOrHeal(p.ownHero, (p.ownHero.Hp - 1)); } else for (int i = 0; i < times; i++) if (minions.Count >= 1) { Minion enemy = minions[0]; byte minHP = byte.MaxValue; foreach (Minion m in minions) if ((m.name == CardDB.cardName.nerubianegg) && (enemy.Hp >= 2)) continue; else if ((m.Hp >= 2) && (minHP > m.Hp)) { enemy = m; minHP = (byte)m.Hp; } if (minHP < byte.MaxValue) p.minionGetDamageOrHeal(enemy, 1); else p.minionGetDamageOrHeal((myTurn ? p.enemyHero : p.ownHero), 1); } else p.minionGetDamageOrHeal((myTurn ? p.enemyHero : p.ownHero), 1); } } }
Could you retry with the latest code? Sorry I just keep noticing my own errors in the code. Edit: Thank you
could you please do the same with tinkertown tech? Code: using System; using System.Collections.Generic; using System.Text; namespace HREngine.Bots { class Sim_GVG_102 : SimTemplate //Tinkertown Technician { // Battlecry: If you have a Mech, gain +1/+1 and add a Spare Part to your hand. public override void getBattlecryEffect(Playfield p, Minion own, Minion target, int choice) { List<Minion> temp = (own.own) ? p.ownMinions : p.enemyMinions; foreach (Minion m in temp) { if ((TAG_RACE)m.handcard.card.race == TAG_RACE.MECHANICAL) { p.minionGetBuffed(own, 1, 1); p.drawACard(CardDB.cardName.armorplating, own.own, true); return; } } } } }
I actually don't see anything wrong with that one, but I updated it with my code: Code: using System; using System.Collections.Generic; using System.Text; namespace HREngine.Bots { class Sim_GVG_102 : SimTemplate //Tinkertown Technician { public override void getBattlecryEffect(Playfield p, Minion own, Minion target, int choice) { bool myTurn = own.own, hasMech = false; List<Minion> minions = (myTurn ? p.ownMinions : p.enemyMinions); foreach (Minion m in minions) if ((TAG_RACE)m.handcard.card.race == TAG_RACE.MECHANICAL) { hasMech = true; break; } if (hasMech) { p.minionGetBuffed(own, 1, 1); p.drawACard(CardDB.cardName.armorplating, myTurn, true); } } } }
Let me know the problem with blastmage exactly, and what you want the tinkertown to do. Sorry, I haven't played Hearthstone that long so I'm new to everything.
Tinkertown Technician - Hearthstone Cards Goblin Blastmage - Hearthstone Cards these two card should 99% of all time only be played if a mech is on the board. filename is "Sim_GvG_004" for goblin blastmage and "Sim_GvG_102" for tinkertown technician
I believe my code should be working then, though I didn't write the AI, though I have looked through all of the AI code, and no disrespect intended to the developer(s) but it is terribly coded, optimized and cleaned.