internal unit SellHero(HabProperties hps) { if (hps == null) { return(null); } string ID = hps.GetStringValue("Name"); unit hero = Heroes.GetByUnit("ID", ID) as unit; if (hero != null && hero.IsDisposed) { if (Current.unit != null && Current.unit != hero && Current.unit.codeID == hero.codeID && !Current.unit.IsDisposed) { Heroes.Remove(hero); Heroes.Add(Current.unit); hero = Current.unit; } else { Heroes.Remove(hero); hero = null; } } if (hero == null) { unit sellingTavern = null; // find the tavern that sold this hero string tavernID = DHLOOKUP.dcHeroesTaverns[hps.name]; foreach (unit tavern in DHLOOKUP.taverns) { if (tavern.ID == tavernID) { sellingTavern = tavern; } } // create new hero hero = new unit(hps.name); hero.DoSummon = true; hero.set_owningPlayer(Current.player, sellingTavern.x, sellingTavern.y); Heroes.Add(hero); // only new heroes process onsell event sellingTavern.OnSell(hero); // pay the gold for this hero Current.player.Gold = Current.player.Gold - hero.goldCost; } return(hero); }
private void killHeroB_Click(object sender, EventArgs e) { int streak = streakCmbB.SelectedIndex; if (streak > 0) { streak += 2; } player enemyPlayer = player.players[7]; player alliedPlayer = player.players[2]; for (int i = 0; i < (int)heroesNumUD.Value; i++) { unit enemyHero = new unit(); enemyHero.codeID = "Hero"; // so triggers could work with id enemyHero.ID.Value = "[Enemy Hero to be killed]"; enemyHero.primary = PrimAttrType.Str; // only heroes have primary attributes enemyHero.Level = (int)heroLevelNumUD.Value; enemyHero.set_owningPlayer(enemyPlayer); // generate killing streak for enemy hero // by killing allied heroes for (int j = 0; j < streak; j++) { unit victim = new unit(); victim.codeID = "Prey"; victim.ID.Value = "[Allied Victim]"; victim.primary = PrimAttrType.Str; victim.set_owningPlayer(alliedPlayer); victim.OnDeath(enemyHero); victim.destroy(); } // now our hero kills this enemy hero enemyHero.OnDeath(Current.unit); enemyHero.destroy(); } }
private void killHeroB_Click(object sender, EventArgs e) { int streak = streakCmbB.SelectedIndex; if (streak > 0) streak += 2; player enemyPlayer = player.players[7]; player alliedPlayer = player.players[2]; for (int i = 0; i < (int)heroesNumUD.Value; i++) { unit enemyHero = new unit(); enemyHero.codeID = "Hero"; // so triggers could work with id enemyHero.ID.Value = "[Enemy Hero to be killed]"; enemyHero.primary = PrimAttrType.Str; // only heroes have primary attributes enemyHero.Level = (int)heroLevelNumUD.Value; enemyHero.set_owningPlayer(enemyPlayer); // generate killing streak for enemy hero // by killing allied heroes for (int j = 0; j < streak; j++) { unit victim = new unit(); victim.codeID = "Prey"; victim.ID.Value = "[Allied Victim]"; victim.primary = PrimAttrType.Str; victim.set_owningPlayer(alliedPlayer); victim.OnDeath(enemyHero); victim.destroy(); } // now our hero kills this enemy hero enemyHero.OnDeath(Current.unit); enemyHero.destroy(); } }
private void dieB_Click(object sender, EventArgs e) { if (suicideRB.Checked) { Current.unit.OnDeath(Current.unit); Current.unit.playSound(AnimSounds.Death); } else switch (deathsCmbB.SelectedIndex) { case 0: // enemy hero int streak = streakCmbB.SelectedIndex; if (streak > 0) streak += 2; player enemyPlayer = player.players[7]; player alliedPlayer = player.players[2]; unit enemyHero = new unit(); enemyHero.codeID = "Hero"; // so triggers could work with id enemyHero.ID.Value = "[Enemy Hero that will kill you]"; enemyHero.primary = PrimAttrType.Str; // only heroes have primary attributes enemyHero.Level = (int)heroLevelNumUD.Value; enemyHero.set_owningPlayer(enemyPlayer); // generate killing streak for enemy hero // by killing allied heroes for (int j = 0; j < streak; j++) { unit victim = new unit(); victim.codeID = "Prey"; victim.ID.Value = "[Allied Victim]"; victim.primary = PrimAttrType.Str; victim.set_owningPlayer(alliedPlayer); victim.OnDeath(enemyHero); victim.destroy(); } // enemy hero kills our hero Current.unit.OnDeath(enemyHero); enemyHero.destroy(); break; case 1: // allied hero alliedPlayer = player.players[2]; unit ally = new unit(); ally.codeID = "Ally"; ally.ID.Value = "[Allied Killer]"; ally.primary = PrimAttrType.Str; ally.set_owningPlayer(alliedPlayer); // allied hero kills our hero Current.unit.OnDeath(ally); ally.destroy(); break; case 2: // enemy creep HabProperties hpsProfile = creepsCmbB.SelectedItem as HabProperties; player enemyCreepPlayer = player.players[6]; unit creep = enemyCreepPlayer.add_unit(hpsProfile.name); // creep kills our hero Current.unit.OnDeath(creep); creep.destroy(); break; case 3: // neutral creep hpsProfile = creepsCmbB.SelectedItem as HabProperties; player neutralPlayer = player.players[12]; creep = neutralPlayer.add_unit(hpsProfile.name); // creep kills our hero Current.unit.OnDeath(creep); creep.destroy(); break; case 4: // unknown source Current.unit.OnDeath(null); break; } }
private void dieB_Click(object sender, EventArgs e) { if (suicideRB.Checked) { Current.unit.OnDeath(Current.unit); Current.unit.playSound(AnimSounds.Death); } else { switch (deathsCmbB.SelectedIndex) { case 0: // enemy hero int streak = streakCmbB.SelectedIndex; if (streak > 0) { streak += 2; } player enemyPlayer = player.players[7]; player alliedPlayer = player.players[2]; unit enemyHero = new unit(); enemyHero.codeID = "Hero"; // so triggers could work with id enemyHero.ID.Value = "[Enemy Hero that will kill you]"; enemyHero.primary = PrimAttrType.Str; // only heroes have primary attributes enemyHero.Level = (int)heroLevelNumUD.Value; enemyHero.set_owningPlayer(enemyPlayer); // generate killing streak for enemy hero // by killing allied heroes for (int j = 0; j < streak; j++) { unit victim = new unit(); victim.codeID = "Prey"; victim.ID.Value = "[Allied Victim]"; victim.primary = PrimAttrType.Str; victim.set_owningPlayer(alliedPlayer); victim.OnDeath(enemyHero); victim.destroy(); } // enemy hero kills our hero Current.unit.OnDeath(enemyHero); enemyHero.destroy(); break; case 1: // allied hero alliedPlayer = player.players[2]; unit ally = new unit(); ally.codeID = "Ally"; ally.ID.Value = "[Allied Killer]"; ally.primary = PrimAttrType.Str; ally.set_owningPlayer(alliedPlayer); // allied hero kills our hero Current.unit.OnDeath(ally); ally.destroy(); break; case 2: // enemy creep HabProperties hpsProfile = creepsCmbB.SelectedItem as HabProperties; player enemyCreepPlayer = player.players[6]; unit creep = enemyCreepPlayer.add_unit(hpsProfile.name); // creep kills our hero Current.unit.OnDeath(creep); creep.destroy(); break; case 3: // neutral creep hpsProfile = creepsCmbB.SelectedItem as HabProperties; player neutralPlayer = player.players[12]; creep = neutralPlayer.add_unit(hpsProfile.name); // creep kills our hero Current.unit.OnDeath(creep); creep.destroy(); break; case 4: // unknown source Current.unit.OnDeath(null); break; } } }
public void CollectItemCombiningData() { if (MorphingItems != null) { return; } sameLookingComplexItems = null; Current.player.AcceptMessages = false; Dictionary <string, widget> dcItems = new Dictionary <string, widget>(); foreach (unit shop in DHLOOKUP.shops) { if (DHHELPER.IsNewVersionItemShop(shop)) { foreach (string unitID in shop.sellunits) { if (!dcItems.ContainsKey(unitID)) { unit u = new unit(unitID); u.DoSummon = true; u.set_owningPlayer(Current.player); dcItems.Add(unitID, u); } } } else { foreach (string itemID in shop.sellitems) { if (!dcItems.ContainsKey(itemID)) { dcItems.Add(itemID, new item(itemID)); } } } } unit test_unit = new unit(); test_unit.codeID = "test"; test_unit.Inventory.init(0, 10); test_unit.set_owningPlayer(Current.player); DHJassExecutor.CaughtReferences.Clear(); DHJassExecutor.CatchArrayReference = true; DBINVENTORY inventory = test_unit.Inventory; List <widget> itemList = new List <widget>(dcItems.Values); MorphingItems = new Dictionary <string, string>(itemList.Count); SplashScreen splashScreen = new SplashScreen(); splashScreen.Show(); splashScreen.ShowText("Collecting item combining data..."); for (int i = 0; i < itemList.Count; i++) { widget item = itemList[i]; if (DHHELPER.IsNewVersionItem(item.codeID)) { test_unit.OnSell(item as unit); Thread.Sleep(2); // to pass control to item handling script thread } else { test_unit.OnSellItem(item as item, test_unit); inventory.put_item(item as item); } item result = inventory[0].Item; if (result != null) { if (result.codeID != item.codeID) { MorphingItems.Add(result.codeID, item.codeID); } inventory[0].drop_item(); } splashScreen.ShowProgress((double)i, (double)itemList.Count); } Current.player.remove_unit(test_unit); test_unit.destroy(); List <string> arrays = DHJassExecutor.CaughtReferences; if (arrays.Count == 6) { Dictionary <int, DHJassValue> dcA = (DHJassExecutor.Globals[arrays[0]] as DHJassArray).Array; Dictionary <int, DHJassValue> dcB = (DHJassExecutor.Globals[arrays[1]] as DHJassArray).Array; Dictionary <int, DHJassValue> dcC = (DHJassExecutor.Globals[arrays[2]] as DHJassArray).Array; Dictionary <int, DHJassValue> dcD = (DHJassExecutor.Globals[arrays[3]] as DHJassArray).Array; Dictionary <int, DHJassValue> dcCombined = (DHJassExecutor.Globals[arrays[4]] as DHJassArray).Array; ComplexItems = new Dictionary <string, List <List <string> > >(dcA.Count); int value; foreach (int key in dcA.Keys) { List <string> components = new List <string>(4); value = dcA[key].IntValue; if (value != 0) { components.Add(DHJassInt.int2id(value)); } value = dcB[key].IntValue; if (value != 0) { components.Add(DHJassInt.int2id(value)); } value = dcC[key].IntValue; if (value != 0) { components.Add(DHJassInt.int2id(value)); } value = dcD[key].IntValue; if (value != 0) { components.Add(DHJassInt.int2id(value)); } value = dcCombined[key].IntValue; if (value != 0) { string strValue = DHJassInt.int2id(value); List <List <string> > componentsList; if (!ComplexItems.TryGetValue(strValue, out componentsList)) { componentsList = new List <List <string> >(1); ComplexItems.Add(strValue, componentsList); } componentsList.Add(components); } } } splashScreen.Close(); Current.player.AcceptMessages = true; }