string cRivalManager::rivals_plunder_pc_gold(cRival* rival) { if (g_Gold.ival() <= 0) return ""; // no gold to sieze? nothing to do. long pc_gold = g_Gold.ival(); // work out how much they take. make a note of how much we have long gold = g_Dice.random(min((long)2000, pc_gold)); if (gold < 45) gold = 45; // make sure there's at least 45 gold taken if (pc_gold < gold) gold = pc_gold; // unless the pc has less than that, in which case take the lot g_Gold.rival_raids(gold); // deduct the losses against rival raid losses rival->m_Gold += gold; // add the aount to rival coffers stringstream ss; ss << gettext("\nThey get away with ") << gold << gettext(" gold."); // format a message and store it in the string that was passed to us return ss.str(); }
void cScreenTown::check_farm(int FarmNum) { // player clicked on one of the brothels if (g_Farm.GetNumBrothels() == FarmNum) { // player doesn't own this Studio... can he buy it? static_brothel_data *bck = farm_data + FarmNum; locale syslocale(""); stringstream ss; ss.imbue(syslocale); if (!g_Gold.afford(bck->price) || g_Gangs.GetNumBusinessExtorted() < bck->business) { // can't buy it ss << gettext("This building costs ") << bck->price << gettext(" gold and you need to control at least ") << bck->business << gettext(" businesses."); if (!g_Gold.afford(bck->price)) ss << "\n" << gettext("You need ") << (bck->price - g_Gold.ival()) << gettext(" more gold to afford it."); if (g_Gangs.GetNumBusinessExtorted() < bck->business) ss << "\n" << gettext("You need to control ") << (bck->business - g_Gangs.GetNumBusinessExtorted()) << gettext(" more businesses."); g_MessageQue.AddToQue(ss.str(), 0); } else { // can buy it ss << gettext("Do you wish to purchase this building for ") << bck->price << gettext(" gold? It has ") << bck->rooms << gettext(" rooms."); g_MessageQue.AddToQue(ss.str(), 2); g_ChoiceManager.CreateChoiceBox(224, 112, 352, 384, 0, 2, 32, 8); g_ChoiceManager.AddChoice(0, gettext("Buy It"), 0); g_ChoiceManager.AddChoice(0, gettext("Don't Buy It"), 1); g_ChoiceManager.SetActive(0); BuyFarm = FarmNum; } } else { // player owns this brothel... go to it g_Building = BUILDING_FARM; g_CurrFarm = FarmNum; g_WinManager.push("Farm Screen"); } }
void cScreenGangs::check_events() { if (g_InterfaceEvents.GetNumEvents() == 0) return; // no events means we can go home if (g_InterfaceEvents.CheckButton(back_id)) // if it's the back button, pop the window off the stack and we're done { g_InitWin = true; g_WinManager.Pop(); return; } if (g_InterfaceEvents.CheckButton(ganghire_id)) { hire_recruitable(); return; } if (g_InterfaceEvents.CheckButton(weaponup_id)) { int cost = 0; int *wlev = g_Gangs.GetWeaponLevel(); cost = tariff.goon_weapon_upgrade(*wlev); if (g_Gold.item_cost(cost) == true) { *wlev += 1; g_InitWin = true; } wlev = 0; return; } int buynets = 0; if (g_InterfaceEvents.CheckButton(netbuy_id)) buynets = 1; if (g_InterfaceEvents.CheckButton(netbuy10_id)) buynets = 10; if (g_InterfaceEvents.CheckButton(netbuy20_id)) buynets = 20; if (buynets > 0) { int cost = 0; int amount = buynets; int *nets = g_Gangs.GetNets(); if (((*nets) + buynets) > 60) amount = 60 - (*nets); cost = tariff.nets_price(amount); if (g_Gold.item_cost(cost) == true) { *nets += amount; if (IsCheckboxOn(netautobuy_id)) g_Gangs.KeepNetStocked(*nets); g_InitWin = true; } nets = 0; buynets = 0; return; } int buypots = 0; if (g_InterfaceEvents.CheckButton(healbuy_id)) buypots = 1; if (g_InterfaceEvents.CheckButton(healbuy10_id)) buypots = 10; if (g_InterfaceEvents.CheckButton(healbuy20_id)) buypots = 20; if (buypots > 0) { int cost = 0; int amount = buypots; int *potions = g_Gangs.GetHealingPotions(); if (((*potions) + buypots) > 200) amount = 200 - (*potions); cost = tariff.healing_price(amount); if (g_Gold.item_cost(cost) == true) { *potions += amount; if (IsCheckboxOn(healautobuy_id)) g_Gangs.KeepHealStocked(*potions); g_InitWin = true; } potions = 0; buypots = 0; return; } if (g_InterfaceEvents.CheckCheckbox(netautobuy_id)) { int *nets = g_Gangs.GetNets(); g_Gangs.KeepNetStocked(IsCheckboxOn(netautobuy_id) ? *nets : 0); } if (g_InterfaceEvents.CheckCheckbox(healautobuy_id)) { int *potions = g_Gangs.GetHealingPotions(); g_Gangs.KeepHealStocked(IsCheckboxOn(healautobuy_id) ? *potions : 0); } if (g_InterfaceEvents.CheckButton(gangfire_id)) { selection = GetLastSelectedItemFromList(ganglist_id); if (selection != -1) { g_Gangs.FireGang(selection); g_InitWin = true; } return; } if (g_InterfaceEvents.CheckListbox(recruitlist_id)) { string ClickedHeader = HeaderClicked(recruitlist_id); if (ClickedHeader != "") { g_LogFile.ss() << "User clicked \"" << ClickedHeader << "\" column header on Recruit listbox" << endl; g_LogFile.ssend(); return; } g_LogFile.ss() << "selected recruitable gang changed" << endl; g_LogFile.ssend(); sel_recruit = GetLastSelectedItemFromList(recruitlist_id); if (ListDoubleClicked(recruitlist_id)) { g_LogFile.ss() << "User double-clicked recruitable gang! Hiring if possible." << endl; g_LogFile.ssend(); hire_recruitable(); return; } // g_InitWin = true; } // this is what gets called it you change the selected gang if (g_InterfaceEvents.CheckListbox(ganglist_id)) { string ClickedHeader = HeaderClicked(ganglist_id); if (ClickedHeader != "") { g_LogFile.ss() << "User clicked \"" << ClickedHeader << "\" column header on Gangs listbox" << endl; g_LogFile.ssend(); return; } g_LogFile.write("selected gang changed"); selection = GetLastSelectedItemFromList(ganglist_id); if (selection != -1) { sGang* gang = g_Gangs.GetGang(selection); ss.str(""); ss << "Name: " << gang->m_Name << "\n" << "Number: " << gang->m_Num << "\n" << "Combat: " << gang->m_Skills[SKILL_COMBAT] << "%\n" << "Magic: " << gang->m_Skills[SKILL_MAGIC] << "%\n" << "Intelligence: " << gang->m_Stats[STAT_INTELLIGENCE] << "%\n"; EditTextItem(ss.str(), gangdesc_id); SetSelectedItemInList(missionlist_id, gang->m_MissionID, false); set_mission_desc(gang->m_MissionID); // set the long description for the mission } } if (g_InterfaceEvents.CheckListbox(missionlist_id)) { // get the index into the missions list int mission_id = GetLastSelectedItemFromList(missionlist_id); g_LogFile.ss() << "selchange: mid = " << mission_id << endl; g_LogFile.ssend(); set_mission_desc(mission_id); // set the textfield with the long description and price for this mission g_LogFile.ss() << "selection change: rebuilding gang list box" << endl; g_LogFile.ssend(); for (int selection = multi_first(); selection != -1; selection = multi_next()) { sGang* gang = g_Gangs.GetGang(selection); /* * make sure we found the gang - pretty catastrophic * if not, so log it if we do */ if (gang == 0) { g_LogFile.ss() << "Error: No gang for index " << selection; g_LogFile.ssend(); continue; } /* * if the mission id is -1, nothing else to do * (moving this to before the recruitment check * since -1 most likely means nothing selected in * the missions list) */ if (mission_id == -1) { continue; } /* * if the gang is already doing <whatever> * then let them get on with it */ if (gang->m_MissionID == u_int(mission_id)) { continue; } /* * if they were recruiting, turn off the * auto-recruit flag */ if (gang->m_MissionID == MISS_RECRUIT && gang->m_AutoRecruit) { gang->m_AutoRecruit = false; gang->m_LastMissID = -1; } gang->m_MissionID = mission_id; /* * format the display line */ g_InitWin = true; } int cost = 0; if (g_Gangs.GetNumGangs() > 0) { for (int i = 0; i < g_Gangs.GetNumGangs(); i++) { sGang* g = g_Gangs.GetGang(i); cost += tariff.goon_mission_cost(g->m_MissionID); } } ss.str(""); ss << "Weekly Cost: " << cost; EditTextItem(ss.str(), totalcost_id); if (gold_id >= 0) { ss.str(""); ss << "Gold: " << g_Gold.ival(); EditTextItem(ss.str(), gold_id); } } if (g_InterfaceEvents.CheckCheckbox(controlcatacombs_id)) { g_Gangs.Control_Gangs(IsCheckboxOn(controlcatacombs_id)); } bool dosliders = false; if (g_InterfaceEvents.CheckSlider(girlspercslider_id)) { int s1 = SliderValue(girlspercslider_id); int s2 = SliderValue(itemspercslider_id); if (s2 < s1) { s2 = s1; SliderRange(itemspercslider_id, 0, 100, s2, 1); } dosliders = true; } if (g_InterfaceEvents.CheckSlider(itemspercslider_id)) { int s1 = SliderValue(itemspercslider_id); int s2 = SliderValue(girlspercslider_id); if (s1 < s2) { s2 = s1; SliderRange(girlspercslider_id, 0, 100, s2, 1); } dosliders = true; } if (dosliders) { int s1 = SliderValue(girlspercslider_id); int s2 = SliderValue(itemspercslider_id); g_Gangs.Gang_Gets_Girls(s1); g_Gangs.Gang_Gets_Items(s2 - s1); g_Gangs.Gang_Gets_Beast(100 - s2); ss.str(""); ss << "Girls : " << g_Gangs.Gang_Gets_Girls() << "%"; EditTextItem(ss.str(), ganggetsgirls_id); ss.str(""); ss << "Items : " << g_Gangs.Gang_Gets_Items() << "%"; EditTextItem(ss.str(), ganggetsitems_id); ss.str(""); ss << "Beasts : " << g_Gangs.Gang_Gets_Beast() << "%"; EditTextItem(ss.str(), ganggetsbeast_id); return; } }
void cScreenGangs::init() { g_CurrentScreen = SCREEN_GANGMANAGEMENT; if (!g_InitWin) return; Focused(); g_InitWin = false; selection = GetLastSelectedItemFromList(ganglist_id); sel_recruit = GetLastSelectedItemFromList(recruitlist_id); ClearListBox(missionlist_id); AddToListBox(missionlist_id, 0, "GUARDING"); AddToListBox(missionlist_id, 1, "SABOTAGE"); AddToListBox(missionlist_id, 2, "SPY ON GIRLS"); AddToListBox(missionlist_id, 3, "RECAPTURE"); AddToListBox(missionlist_id, 4, "ACQUIRE TERRITORY"); AddToListBox(missionlist_id, 5, "PETTY THEFT"); AddToListBox(missionlist_id, 6, "GRAND THEFT"); AddToListBox(missionlist_id, 7, "KIDNAPPING"); AddToListBox(missionlist_id, 8, "CATACOMBS"); AddToListBox(missionlist_id, 9, "TRAINING"); AddToListBox(missionlist_id, 10, "RECRUITING"); AddToListBox(missionlist_id, 11, "SERVICE"); SetCheckBox(controlcatacombs_id, (g_Gangs.Control_Gangs())); SliderRange(girlspercslider_id, 0, 100, g_Gangs.Gang_Gets_Girls(), 1); SliderRange(itemspercslider_id, 0, 100, g_Gangs.Gang_Gets_Girls() + g_Gangs.Gang_Gets_Items(), 1); ss.str(""); ss << "Girls : " << g_Gangs.Gang_Gets_Girls() << "%"; EditTextItem(ss.str(), ganggetsgirls_id); ss.str(""); ss << "Items : " << g_Gangs.Gang_Gets_Items() << "%"; EditTextItem(ss.str(), ganggetsitems_id); ss.str(""); ss << "Beasts : " << g_Gangs.Gang_Gets_Beast() << "%"; EditTextItem(ss.str(), ganggetsbeast_id); SetCheckBox(netautobuy_id, (g_Gangs.GetNetRestock() > 0)); SetCheckBox(healautobuy_id, (g_Gangs.GetHealingRestock() > 0)); // weapon upgrades int *wlev = g_Gangs.GetWeaponLevel(); ss.str(""); ss << "Weapon Level: " << *wlev; if ((*wlev) < 4) { EnableButton(weaponup_id); ss << " Next: " << tariff.goon_weapon_upgrade(*wlev) << "g"; } else DisableButton(weaponup_id); g_LogFile.ss() << "weapon text = '" << ss.str() << "'" << endl; g_LogFile.ssend(); EditTextItem(ss.str(), weaponlevel_id); int *nets = g_Gangs.GetNets(); ss.str(""); ss << "Nets (" << tariff.nets_price(1) << "g each): " << *nets; EditTextItem(ss.str(), netdesc_id); DisableButton(netbuy_id, *nets >= 60); DisableButton(netbuy10_id, *nets >= 60); DisableButton(netbuy20_id, *nets >= 60); DisableCheckBox(netautobuy_id, *nets < 1); int *potions = g_Gangs.GetHealingPotions(); ss.str(""); ss << "Heal Potions (" << tariff.healing_price(1) << "g each): " << *potions; EditTextItem(ss.str(), healdesc_id); DisableButton(healbuy_id, *potions >= 200); DisableButton(healbuy10_id, *potions >= 200); DisableButton(healbuy20_id, *potions >= 200); DisableCheckBox(healautobuy_id, *potions < 1); int cost = 0; if (g_Gangs.GetNumGangs() > 0) { for (int i = 0; i < g_Gangs.GetNumGangs(); i++) { sGang* g = g_Gangs.GetGang(i); if (g == 0) g = g_Gangs.GetGang(i - 1); cost += tariff.goon_mission_cost(g->m_MissionID); } } ss.str(""); ss << "Weekly Cost: " << cost; EditTextItem(ss.str(), totalcost_id); if (gold_id >= 0) { ss.str(""); ss << "Gold: " << g_Gold.ival(); EditTextItem(ss.str(), gold_id); } ClearListBox(ganglist_id); int num = 0; sGang* current = g_Gangs.GetGang(0); // loop through the gangs, populating the list box g_LogFile.write("Setting gang mission descriptions\n"); for (current = g_Gangs.GetGang(0); current; current = current->m_Next) { // format the string with the gang name, mission and number of men string Data[11]; ss.str(""); ss << current->m_Name; Data[0] = ss.str(); ss.str(""); ss << current->m_Num; Data[1] = ss.str(); ss.str(""); ss << short_mission_desc(current->m_MissionID); Data[2] = ss.str(); ss.str(""); ss << current->m_Skills[SKILL_COMBAT] << "%"; Data[3] = ss.str(); ss.str(""); ss << current->m_Skills[SKILL_MAGIC] << "%"; Data[4] = ss.str(); ss.str(""); ss << current->m_Stats[STAT_INTELLIGENCE] << "%"; Data[5] = ss.str(); ss.str(""); ss << current->m_Stats[STAT_AGILITY] << "%"; Data[6] = ss.str(); ss.str(""); ss << current->m_Stats[STAT_CONSTITUTION] << "%"; Data[7] = ss.str(); ss.str(""); ss << current->m_Stats[STAT_CHARISMA] << "%"; Data[8] = ss.str(); ss.str(""); ss << current->m_Stats[STAT_STRENGTH] << "%"; Data[9] = ss.str(); ss.str(""); ss << current->m_Skills[SKILL_SERVICE] << "%"; Data[10] = ss.str(); // cerr << "Gang:\t" << Data[0] << "\t" << Data[1] << "\t" << Data[2] // << "\t" << Data[3] << "\t" << Data[4] << "\t" << Data[5] << "\t" << Data[6] << endl; /* * add the box to the list; red highlight gangs that are low on numbers */ int color = (current->m_Num < 6 ? COLOR_RED : COLOR_BLUE); if (current->m_Num < 6 && (current->m_MissionID == MISS_SERVICE || current->m_MissionID == MISS_TRAINING)) color = COLOR_YELLOW; AddToListBox(ganglist_id, num++, Data, 11, color); } ClearListBox(recruitlist_id); num = 0; current = g_Gangs.GetHireableGang(0); // loop through the gangs, populating the list box g_LogFile.write("Setting recruitable gang info\n"); for (current = g_Gangs.GetHireableGang(0); current; current = current->m_Next) { // format the string with the gang name, mission and number of men string Data[10]; ss.str(""); ss << current->m_Name; Data[0] = ss.str(); ss.str(""); ss << current->m_Num; Data[1] = ss.str(); ss.str(""); ss << current->m_Skills[SKILL_COMBAT] << "%"; Data[2] = ss.str(); ss.str(""); ss << current->m_Skills[SKILL_MAGIC] << "%"; Data[3] = ss.str(); ss.str(""); ss << current->m_Stats[STAT_INTELLIGENCE] << "%"; Data[4] = ss.str(); ss.str(""); ss << current->m_Stats[STAT_AGILITY] << "%"; Data[5] = ss.str(); ss.str(""); ss << current->m_Stats[STAT_CONSTITUTION] << "%"; Data[6] = ss.str(); ss.str(""); ss << current->m_Stats[STAT_CHARISMA] << "%"; Data[7] = ss.str(); ss.str(""); ss << current->m_Stats[STAT_STRENGTH] << "%"; Data[8] = ss.str(); ss.str(""); ss << current->m_Skills[SKILL_SERVICE] << "%"; Data[9] = ss.str(); // cerr << "Recruitable\t" << Data[0] << "\t" << Data[1] << "\t" << Data[2] // << "\t" << Data[3] << "\t" << Data[4] << "\t" << Data[5] << endl; /* * add the box to the list */ int color = (current->m_Num < 6 ? COLOR_RED : COLOR_BLUE); AddToListBox(recruitlist_id, num++, Data, 10, color); } if (selection == -1 && GetListBoxSize(ganglist_id) >= 1) selection = 0; if (selection >= 0) { while (selection > GetListBoxSize(ganglist_id) && selection != -1) selection--; } if (selection >= 0) SetSelectedItemInList(ganglist_id, selection); if (sel_recruit == -1 && GetListBoxSize(recruitlist_id) >= 1) sel_recruit = 0; if (sel_recruit >= 0) SetSelectedItemInList(recruitlist_id, sel_recruit); DisableButton(ganghire_id, (g_Gangs.GetNumHireableGangs() <= 0) || (g_Gangs.GetNumGangs() >= g_Gangs.GetMaxNumGangs()) || (sel_recruit == -1)); DisableButton(gangfire_id, (g_Gangs.GetNumGangs() <= 0) || (selection == -1)); potions = wlev = nets = 0; }
void cRivalManager::Update(int& NumPlayerBussiness) { cRival* curr = m_Rivals; cConfig cfg; if (g_Year >= 1209 && g_Month > 3) m_PlayerSafe = false; while (curr) { // check if rival is killed if (curr->m_Gold <= 0 && curr->m_NumBrothels <= 0 && curr->m_NumGangs <= 0 && curr->m_NumGirls <= 0 && curr->m_NumGamblingHalls <= 0 && curr->m_NumBars <= 0 && curr->m_NumInventory <= 0) { cRival* tmp = curr->m_Next; RemoveRival(curr); curr = tmp; SetGameFlag(FLAG_RIVALLOSE); continue; } int income = 0; int upkeep = 0; int profit = 0; int totalincome = 0; int totalupkeep = 0; int startinggold = curr->m_Gold; // `J` added - rival power // `J` reworked to reduce the rival's power curr->m_Power = max(0, curr->m_NumBrothels * 5) + max(0, curr->m_NumGamblingHalls * 2) + max(0, curr->m_NumBars * 1); // check if a rival is in danger if (curr->m_Gold <= 0 || curr->m_NumBrothels <= 0 || curr->m_NumGirls <= 0 || curr->m_NumGamblingHalls <= 0 || curr->m_NumBars <= 0) { // The AI is in danger so will stop extra spending curr->m_BribeRate = 0; curr->m_Influence = 0; // first try to sell any items if (curr->m_NumInventory > 0) { for (int i = 0; i < MAXNUM_RIVAL_INVENTORY && curr->m_Gold + income + upkeep < 1000; i++) { sInventoryItem* temp = curr->m_Inventory[i]; if (temp) { income += (temp->m_Cost / 2); RemoveRivalInvByNumber(curr, i); } } } // try to buy at least one of each to make up for losses if (curr->m_NumBrothels <= 0 && curr->m_Gold + income + upkeep - 20000 >= 0) { upkeep -= 20000; curr->m_NumBrothels++; } if (curr->m_NumGirls <= 0 && curr->m_Gold + income + upkeep - 550 >= 0) { upkeep -= 550; curr->m_NumGirls++; } if (curr->m_NumGamblingHalls <= 0 && curr->m_Gold + income + upkeep - 10000 >= 0) { curr->m_NumGamblingHalls++; upkeep -= 10000; } if (curr->m_NumBars <= 0 && curr->m_Gold + income + upkeep - 2500 >= 0) { curr->m_NumBars++; upkeep -= 2500; } // buy more girls if there is enough money left (save at least 1000 in reserve) if (curr->m_Gold + income + upkeep >= 1550 && (curr->m_NumGirls < 5 || curr->m_NumGirls < curr->m_NumBrothels * 20)) { int i = 0; while (curr->m_Gold + income + upkeep >= 1550 && i < (g_Dice % 5) + 1) // buy up to 5 girls if they can afford it. { upkeep -= 550; curr->m_NumGirls++; i++; } } } // process money totalincome += income; totalupkeep += upkeep; curr->m_Gold += income; curr->m_Gold += upkeep; profit = totalincome + totalupkeep; income = upkeep = 0; for (int i = 0; i < curr->m_NumGirls; i++) // from girls { // If a rival has more girls than their brothels can handle, the rest work on the streets double rapechance = (i > curr->m_NumBrothels * 20 ? cfg.prostitution.rape_brothel() : cfg.prostitution.rape_streets()); int Customers = g_Dice % 6; // 0-5 cust per girl for (int i = 0; i < Customers;i++) { if (g_Dice.percent(rapechance)) { upkeep -= 50; // pay off the girl and the officials after killing the rapist } else { income += g_Dice % 38 + 2; // 2-40 gold per cust } } } // from halls for (int i = 0; i < curr->m_NumGamblingHalls; i++) { int Customers = ((g_Dice%curr->m_NumGirls) + curr->m_NumGirls / 5); if (g_Dice.percent(5)) { upkeep -= ((g_Dice % 101) + 200); // Big Winner Customers += g_Dice % 10; // attracts more customers } if (g_Dice.percent(5)) { income += ((g_Dice % 601) + 400); // Big Loser Customers -= g_Dice % (Customers / 5); // scares off some customers } // they will kick a customer out if they win too much so they can win up to 100 but only lose 50 for (int j = 0; j < Customers; j++) { int winloss = (g_Dice % 151 - 50); if (winloss > 0) income += winloss; else /* */ upkeep += winloss; } } // from bars for (int i = 0; i < curr->m_NumBars; i++) { int Customers = ((g_Dice%curr->m_NumGirls) + curr->m_NumGirls/5); if (g_Dice.percent(5)) { upkeep -= ((g_Dice % 250) + 1); // bar fight - cost to repair Customers -= g_Dice % (Customers / 5); // scare off some customers } if (g_Dice.percent(5)) { income += ((g_Dice % 250) + 1); // Big Spender Customers += g_Dice % 5; // attracts more customers } for (int j = 0; j < Customers; j++) { income += (g_Dice % 9) + 1; // customers spend 1-10 per visit } } // from businesses if (curr->m_BusinessesExtort > 0) income += (curr->m_BusinessesExtort * INCOME_BUSINESS); // Calc their upkeep upkeep -= curr->m_BribeRate; upkeep -= curr->m_NumGirls * 5; upkeep -= curr->m_NumBars * 20; upkeep -= curr->m_NumGamblingHalls * 80; upkeep -= (curr->m_NumBars)*((g_Dice % 50) + 30); // upkeep for buying barrels of booze upkeep -= (curr->m_NumGangs * 90); float taxRate = 0.06f; // normal tax rate is 6% if (curr->m_Influence > 0) // can you influence it lower { int lowerBy = curr->m_Influence / 20; float amount = (float)(lowerBy / 100); taxRate -= amount; if (taxRate <= 0.01f) taxRate = 0.01f; } if (income > 0) { int tmp = income - (g_Dice % (int)(income*0.25f)); // launder up to 25% of gold int tax = (int)(tmp*taxRate); upkeep -= tax; } // process money totalincome += income; totalupkeep += upkeep; curr->m_Gold += income; curr->m_Gold += upkeep; profit = totalincome + totalupkeep; income = upkeep = 0; // Work out gang missions int cGangs = curr->m_NumGangs; for (int i = 0; i < cGangs; i++) { sGang* cG1 = g_Gangs.GetTempGang(curr->m_Power); // create a random gang for this rival int missionid = -1; int tries = 0; while (missionid == -1 && tries < 10) // choose a mission { switch (g_Dice % 9) // `J` zzzzzz - need to add checks into this { case 0: missionid = MISS_EXTORTION; // gain territory break; case 1: missionid = MISS_PETYTHEFT; // small money but safer break; case 2: missionid = MISS_GRANDTHEFT; // large money but difficult break; case 3: missionid = MISS_SABOTAGE; // attack rivals break; case 4: break; // not ready missionid = MISS_CAPTUREGIRL; // take girls from rivals break; case 5: missionid = MISS_KIDNAPP; // get new girls break; case 6: missionid = MISS_CATACOMBS; // random but dangerous break; default: missionid = MISS_GUARDING; // don't do anything but guard break; } tries++; } switch (missionid) { case MISS_EXTORTION: // gain territory { int numB = GetNumBusinesses() + NumPlayerBussiness; if (numB < TOWN_NUMBUSINESSES) // if there are uncontrolled businesses { int n = g_Dice % 5 - 2; if (n > 0) // try to take some { if (numB + n > TOWN_NUMBUSINESSES) n = TOWN_NUMBUSINESSES - numB; curr->m_BusinessesExtort += n; income += n * 20; } } else // if there are no uncontrolled businesses { stringstream ss; int who = (g_Dice % (m_NumRivals + 1)); // who to attack if (who == m_NumRivals) // try to attack you { if (!player_safe() && NumPlayerBussiness > 0) // but only if you are a valid target { sGang* miss1 = g_Gangs.GetGangOnMission(MISS_GUARDING); if (miss1) // if you have a gang guarding { ss << gettext("Your guards encounter ") << curr->m_Name << gettext(" going after some of your territory."); sGang* rGang = g_Gangs.GetTempGang(curr->m_Power); if (g_Gangs.GangBrawl(miss1, rGang)) // if you win { if (rGang->m_Num == 0) curr->m_NumGangs--; ss << gettext("\nBut you maintain control of the territory."); miss1->m_Events.AddMessage(ss.str(), IMGTYPE_PROFILE, EVENT_GANG); } else // if you lose { if (miss1->m_Num == 0) g_Gangs.RemoveGang(miss1); ss << gettext("\nYou lose the territory."); NumPlayerBussiness--; curr->m_BusinessesExtort++; g_MessageQue.AddToQue(ss.str(), COLOR_RED); } delete rGang; rGang = 0; // cleanup } else // if you do not have a gang guarding { ss << gettext("Your rival ") << curr->m_Name << gettext(" has taken one of the undefended territories you control."); g_MessageQue.AddToQue(ss.str(), COLOR_RED); NumPlayerBussiness--; curr->m_BusinessesExtort++; } } } else // attack another rival { ss << gettext("The ") << curr->m_Name << gettext(" attacked the territories of "); cRival* rival = GetRival(who); if (rival != curr && rival->m_BusinessesExtort > 0) { ss << rival->m_Name; if (rival->m_NumGangs > 0) { sGang* rG1 = g_Gangs.GetTempGang(rival->m_Power); if (g_Gangs.GangBrawl(cG1, rG1, true)) { rival->m_NumGangs--; rival->m_BusinessesExtort--; curr->m_BusinessesExtort++; ss << gettext(" and won."); } else { curr->m_NumGangs--; ss << gettext(" and lost."); } delete rG1; rG1 = 0; // cleanup } else { ss << " and took an unguarded territory."; rival->m_BusinessesExtort--; curr->m_BusinessesExtort++; } g_MessageQue.AddToQue(ss.str(), COLOR_BLUE); } } } }break; case MISS_PETYTHEFT: // small money but safer { if (g_Dice.percent(70)) { income += g_Dice % 400 + 1; } else if (g_Dice.percent(10)) // they may lose the gang { curr->m_NumGangs--; } }break; case MISS_GRANDTHEFT: // large money but difficult { if (g_Dice.percent(30)) { income += (g_Dice % 20 + 1) * 100; } else if (g_Dice.percent(30)) // they may lose the gang { curr->m_NumGangs--; } }break; case MISS_SABOTAGE: // attack rivals { if (g_Dice.percent(min(90, cG1->intelligence()))) // chance they find a target { stringstream ss; int who = (g_Dice % (m_NumRivals + 1)); if (who == m_NumRivals && !player_safe()) // if it is you and you are a valid target { int num = 0; bool damage = false; sGang* miss1 = g_Gangs.GetGangOnMission(MISS_GUARDING); if (miss1) { ss << gettext("Your rival the ") << curr->m_Name << gettext(" attack your assets."); if (!g_Gangs.GangBrawl(miss1, cG1)) { if (miss1->m_Num == 0) g_Gangs.RemoveGang(miss1); ss << gettext("\nYour men are defeated."); int num = (g_Dice % 2) + 1; damage = true; } else { if (cG1->m_Num == 0) curr->m_NumGangs--; ss << gettext(" But they fail."); miss1->m_Events.AddMessage(ss.str(), IMGTYPE_PROFILE, EVENT_GANG); } } else { ss << gettext("You have no guards so your rival ") << curr->m_Name << gettext(" attacks."); if (NumPlayerBussiness > 0 || g_Gold.ival() > 0) { num = (g_Dice % 3) + 1; damage = true; } } if (damage) { if (NumPlayerBussiness > 0) { ss << "\nThey destroy "; NumPlayerBussiness -= num; if (NumPlayerBussiness < 0) { ss << "all"; NumPlayerBussiness = 0; } else if (num == 1) ss << "one"; else if (num == 2) ss << "two"; else /* */ ss << num; ss << " of your territories."; } else ss << "."; ss << rivals_plunder_pc_gold(curr); g_MessageQue.AddToQue(ss.str(), COLOR_RED); } } else { ss << gettext("The ") << curr->m_Name << gettext(" launched an assault on "); cRival* rival = GetRival(who); if (rival && rival != curr) { int num = 0; ss << rival->m_Name; if (rival->m_NumGangs > 0) { sGang* rG1 = g_Gangs.GetTempGang(rival->m_Power); if (g_Gangs.GangBrawl(cG1, rG1, true)) { rival->m_NumGangs--; ss << gettext(" and won."); num = (g_Dice % 2) + 1; } else { ss << gettext(" and lost."); curr->m_NumGangs--; } delete rG1; rG1 = 0; // cleanup } else { num = (g_Dice % 4) + 1; // can do more damage if not fighting another gang } if (num > 0) { if (rival->m_BusinessesExtort > 0) { rival->m_BusinessesExtort -= num; if (rival->m_BusinessesExtort < 0) rival->m_BusinessesExtort = 0; } if (rival->m_Gold > 0) { long gold = (g_Dice % 2000) + 45; // get a random ammount if ((rival->m_Gold - gold) > 0) // and if they have more than that { rival->m_Gold -= gold; // take it } else // but if not { gold = rival->m_Gold; // take all they have rival->m_Gold = 0; } income += gold; } int buildinghit = g_Dice.d100() - num; if (rival->m_NumBrothels > 0 && buildinghit < 10 + (rival->m_NumBrothels * 2)) { // 10% base + 2% per brothel rival->m_NumBrothels--; rival->m_Power--; ss << "\nThey destroyed one of their Brothels."; } else if (rival->m_NumGamblingHalls > 0 && buildinghit < 30 + (rival->m_NumGamblingHalls * 2)) { // 20% base + 2% per hall rival->m_NumGamblingHalls--; ss << "\nThey destroyed one of their Gambling Halls."; } else if (rival->m_NumBars > 0 && buildinghit < 60 + (rival->m_NumBars * 2)) { // 60% base + 2% per bar rival->m_NumBars--; ss << "\nThey destroyed one of their Bars."; } } g_MessageQue.AddToQue(ss.str(), 0); } } } }break; case MISS_CAPTUREGIRL: // take girls from rivals { }break; case MISS_KIDNAPP: // get new girls { if (g_Dice.percent(cG1->intelligence())) // chance to find a girl { bool addgirl = false; sGirl* girl = g_Girls.GetRandomGirl(); g_Girls.SetStat(girl, STAT_HEALTH, 100); // make sure she is at full health if (girl) { if (g_Dice.percent(cG1->m_Stats[STAT_CHARISMA])) // convince her { addgirl = true; } else if (g_Brothels.FightsBack(girl)) // try to kidnap her { if (!g_Gangs.GirlVsEnemyGang(girl, cG1)) addgirl = true; else if (cG1->m_Num <= 0) curr->m_NumGangs--; } else { addgirl = true; } // she goes willingly } if (addgirl) curr->m_NumGirls++; } }break; case MISS_CATACOMBS: // random but dangerous { int num = cG1->m_Num; for (int i = 0; i < num; i++) { if (!g_Dice.percent(cG1->combat())) cG1->m_Num--; } if (cG1->m_Num > 0) { // determine loot int gold = cG1->m_Num; gold += g_Dice % (cG1->m_Num * 100); income += gold; int items = 0; while (g_Dice.percent(60) && items <= (cG1->m_Num / 3) && curr->m_NumInventory < MAXNUM_RIVAL_INVENTORY) { bool quit = false; bool add = false; sInventoryItem* temp; do { temp = g_InvManager.GetRandomItem(); } while (!temp || temp->m_Rarity < RARITYSHOP25 || temp->m_Rarity > RARITYCATACOMB01); switch (temp->m_Rarity) { case RARITYSHOP25: add = true; break; case RARITYSHOP05: if (g_Dice.percent(25)) add = true; break; case RARITYCATACOMB15: if (g_Dice.percent(15)) add = true; break; case RARITYCATACOMB05: if (g_Dice.percent(5)) add = true; break; case RARITYCATACOMB01: if (g_Dice.percent(1)) add = true; break; // adding these cases to shut the compiler up case RARITYCOMMON: case RARITYSHOP50: case RARITYSCRIPTONLY: case RARITYSCRIPTORREWARD: default: break; } if (add) { AddRivalInv(curr, temp); } } int girls = 0; while (g_Dice.percent(40) && girls <= 4) // up to 4 girls { girls++; curr->m_NumGirls++; } } }break; default: break; // No mission } // end mission switch delete cG1; cG1 = 0; // cleanup } // end Gang Missions // process money totalincome += income; totalupkeep += upkeep; curr->m_Gold += income; curr->m_Gold += upkeep; profit = totalincome + totalupkeep; income = upkeep = 0; bool danger = false; bool sellfail = false; // if they are loosing money and they will be bankrupt in 2 turns or less if (profit <= 0 && curr->m_Gold - (profit * 2) < 0) // sell off some stuff { danger = true; // this will make sure AI doesn't replace them this turn while (curr->m_Gold + income + upkeep - (profit * 2) < 0 && !sellfail) { // first try to sell any items if (curr->m_NumInventory > 0) { for (int i = 0; i < MAXNUM_RIVAL_INVENTORY && curr->m_Gold + income + upkeep - (profit * 2) < 0; i++) { sInventoryItem* temp = curr->m_Inventory[i]; if (temp) { income += (temp->m_Cost / 2); RemoveRivalInvByNumber(curr, i); } } } // sell extra stuff - hall or bar if (curr->m_NumGamblingHalls > curr->m_NumBrothels) { curr->m_NumGamblingHalls--; income += 5000; } else if (curr->m_NumBars > curr->m_NumBrothels) { curr->m_NumBars--; income += 1250; } // if they have an empty brothel, sell it else if (curr->m_NumBrothels > 1 && (curr->m_NumBrothels - 1) * 20 > curr->m_NumGirls + 1) { curr->m_NumBrothels--; income += 10000; } // sell extra girls else if (curr->m_NumGirls > curr->m_NumBrothels * 20) { curr->m_NumGirls--; income += g_Dice % 401 + 300; // variable price 300-700 } // sell a hall or bar keeping at least 1 of each else if (curr->m_NumGamblingHalls > 1 && curr->m_NumBars <= curr->m_NumGamblingHalls) { curr->m_NumGamblingHalls--; income += 5000; } else if (curr->m_NumBars > 1) { curr->m_NumBars--; income += 1250; } // Finally - sell a girl else if (curr->m_NumGirls > 1) { curr->m_NumGirls--; income += g_Dice % 401 + 300; // variable price 300-700 } else { sellfail = true; // could not sell anything so break out of the while loop } } } // process money totalincome += income; totalupkeep += upkeep; curr->m_Gold += income; curr->m_Gold += upkeep; profit = totalincome + totalupkeep; income = upkeep = 0; if (!danger) { // use or sell items if (curr->m_NumInventory > 0) { for (int i = 0; i < MAXNUM_RIVAL_INVENTORY; i++) { sInventoryItem* temp = curr->m_Inventory[i]; if (temp && g_Dice.percent(50)) { if (g_Dice.percent(50)) income += (temp->m_Cost / 2); RemoveRivalInvByNumber(curr, i); } } } // buy a new brothel if they have enough money if (curr->m_Gold + income + upkeep - 20000 > 0 && curr->m_NumGirls + 2 >= curr->m_NumBrothels * 20 && curr->m_NumBrothels < 6) { curr->m_NumBrothels++; upkeep -= 20000; } // buy new girls int girlsavailable = (g_Dice % 6) + 1; while (curr->m_Gold + income + upkeep - 550 >= 0 && girlsavailable > 0 && curr->m_NumGirls < curr->m_NumBrothels * 20) { curr->m_NumGirls++; girlsavailable--; upkeep -= 550; } // hire gangs int gangsavailable = (max(0, (g_Dice % 5) - 2)); while (curr->m_Gold + income + upkeep - 90 >= 0 && gangsavailable > 0 && curr->m_NumGangs < 8) { curr->m_NumGangs++; upkeep -= 90; } // buy a gambling hall if (g_Dice.percent(30) && curr->m_Gold + income + upkeep - 10000 >= 0 && curr->m_NumGamblingHalls < curr->m_NumBrothels) { curr->m_NumGamblingHalls++; upkeep -= 10000; } // buy a new bar if (g_Dice.percent(60) && curr->m_Gold + income + upkeep - 2500 >= 0 && curr->m_NumBars < curr->m_NumBrothels) { curr->m_NumBars++; upkeep -= 2500; } // buy items int rper[7] = { 90, 70, 50, 30, 10, 5, 1 }; int i = 0; while (i < 6) { sInventoryItem* item = g_InvManager.GetRandomItem(); if (item && item->m_Rarity <= RARITYCATACOMB01 && g_Dice.percent(rper[item->m_Rarity]) && curr->m_Gold + income + upkeep > item->m_Cost) { if (g_Dice.percent(50)) { AddRivalInv(curr, item); // buy 50%, use 50% } upkeep -= item->m_Cost; } i++; } } // process money totalincome += income; totalupkeep += upkeep; curr->m_Gold += income; curr->m_Gold += upkeep; profit = totalincome + totalupkeep; income = upkeep = 0; // adjust their bribe rate if (profit > 1000) curr->m_BribeRate += (long)(50); // if doing well financially then increase else if (profit < 0) curr->m_BribeRate -= (long)(50); // if loosing money decrease if (curr->m_BribeRate < 0) curr->m_BribeRate = 0; // check 0 g_Brothels.UpdateBribeInfluence(); // update influence // `J` bookmark - rival money at the end of their turn if (cfg.debug.log_debug()) g_LogFile.os() << "Processing Rival: " << curr->m_Name << " | Starting Gold: " << startinggold << " | Income: " << totalincome << " | Upkeep: " << totalupkeep << " | Profit: " << totalincome + totalupkeep << " | Ending Gold: " << curr->m_Gold <<"\n"; curr = curr->m_Next; } }
void cScreenHouse::init() { g_CurrentScreen = SCREEN_HOUSE; if (!g_InitWin) { return; } Focused(); g_InitWin = false; locale syslocale(""); stringstream ss; ss.imbue(syslocale); ss << gettext("CURRENT OBJECTIVE: "); sObjective* obj = g_Brothels.GetObjective(); if (obj) { switch (obj->m_Objective) { case OBJECTIVE_REACHGOLDTARGET: ss << gettext("Gather ") << obj->m_Target << gettext(" gold"); if (obj->m_Limit != -1) { ss << gettext(" in ") << obj->m_Limit << gettext(" weeks"); } ss << gettext(", ") << g_Gold.ival() << gettext(" gathered so far."); break; case OBJECTIVE_GETNEXTBROTHEL: fmt_objective(ss, gettext("Purchase the next brothel"), obj->m_Limit); break; /*---- case OBJECTIVE_PURCHASENEWGAMBLINGHALL: fmt_objective(ss, "Purchase a gambling hall", obj->m_Limit); break; case OBJECTIVE_PURCHASENEWBAR: fmt_objective(ss, "Purchase a bar", obj->m_Limit); break; ----*/ case OBJECTIVE_LAUNCHSUCCESSFULATTACK: fmt_objective(ss, gettext("Launch a successful attack"), obj->m_Limit); break; case OBJECTIVE_HAVEXGOONS: ss << gettext("Have ") << obj->m_Target << gettext(" gangs"); fmt_objective(ss, "", obj->m_Limit); break; case OBJECTIVE_STEALXAMOUNTOFGOLD: ss << gettext("Steal ") << obj->m_Target << gettext(" gold"); fmt_objective(ss, "", obj->m_Limit, obj->m_SoFar); break; case OBJECTIVE_CAPTUREXCATACOMBGIRLS: ss << gettext("Capture ") << obj->m_Target << gettext(" girls from the catacombs"); fmt_objective(ss, "", obj->m_Limit, obj->m_SoFar); break; case OBJECTIVE_HAVEXMONSTERGIRLS: ss << gettext("Have a total of ") << obj->m_Target << gettext(" monster (non-human) girls"); fmt_objective(ss, "", obj->m_Limit, g_Brothels.GetTotalNumGirls(true)); break; case OBJECTIVE_KIDNAPXGIRLS: ss << gettext("Kidnap ") << obj->m_Target << gettext(" girls from the streets"); fmt_objective(ss, "", obj->m_Limit, obj->m_SoFar); break; case OBJECTIVE_EXTORTXNEWBUSINESS: ss << gettext("Control ") << obj->m_Target << gettext(" city business"); fmt_objective(ss, "", obj->m_Limit, obj->m_SoFar); break; case OBJECTIVE_HAVEXAMOUNTOFGIRLS: ss << gettext("Have a total of ") << obj->m_Target << gettext(" girls"); fmt_objective(ss, "", obj->m_Limit, g_Brothels.GetTotalNumGirls(false)); break; } } else ss << gettext("NONE\n"); ss << gettext("\n") << gettext("Current gold: ") << g_Gold.ival() << gettext("\n") << gettext("Bank account: ") << g_Brothels.GetBankMoney() << gettext("\n") << gettext("Businesses controlled: ") << g_Gangs.GetNumBusinessExtorted() << gettext("\n") ; ss << gettext("\nCurrent number of runaways: ") << g_Brothels.GetNumRunaways() << gettext("\n"); // `J` added while loop to add runaway's names to the list if (g_Brothels.GetNumRunaways() > 0) { sGirl* rgirl = g_Brothels.m_Runaways; while (rgirl) { ss << rgirl->m_Realname << gettext(" (") << rgirl->m_RunAway << gettext(")"); rgirl = rgirl->m_Next; if (rgirl) ss << gettext(" , "); } } EditTextItem(ss.str(), details_id); obj = 0; }