Example #1
0
// Wrapper for cInventory SaveToFile function
void SaveInvToFile(cInventory & inv, const char * filename)
{
	ofstream file(filename);
	if (file.is_open())
	{
		inv.SaveToFile(file);
		file.close();
	}
	else
		cout << "Error: Unable to open " << filename << endl;
}
Example #2
0
// Wrapper for cInventory LoadFromFile function
void LoadInvFromFile(cInventory & inv, const char * filename)
{
	ifstream file(filename);
	if (file.is_open())
	{
		inv.LoadFromFile(file);
		file.close();
	}
	else
		cout << "Error: Unable to open " << filename << endl;
}
Example #3
0
bool LoadInventoryXML(TiXmlHandle hInventory, sInventoryItem* items[], int& numItems, unsigned char isEquipped[], int quantities[])
{
	numItems = 0;
	TiXmlElement* pInventory = hInventory.ToElement();
	if (pInventory == 0)	return false;

	TiXmlElement* pItems = pInventory->FirstChildElement("Items");
	if (pItems)
	{
		for (TiXmlElement* pItem = pItems->FirstChildElement("Item"); pItem != 0; pItem = pItem->NextSiblingElement("Item"))
		{
			if (pItem->Attribute("Name"))
			{
				sInventoryItem* tempItem = g_InvManager.GetItem(pItem->Attribute("Name"));
				if (tempItem)
				{
					items[numItems] = tempItem;

					if (isEquipped)
					{
						int tempInt = 0;
						if (pItem->Attribute("isEquipped"))	pItem->QueryIntAttribute("isEquipped", &tempInt);
						isEquipped[numItems] = tempInt;
					}

					if (quantities)
					{
						int tempInt = 1;
						if (pItem->Attribute("quantity"))	pItem->QueryIntAttribute("quantity", &tempInt);
						quantities[numItems] = tempInt;
					}
					++numItems;
				}
			}
		}
	}
	return true;
}
Example #4
0
// `J` Job Farm - Laborers
bool cJobManager::WorkGardener(sGirl* girl, sBrothel* brothel, bool Day0Night1, string& summary)
{
#pragma region //	Job setup				//
	int actiontype = ACTION_WORKFARM;
	stringstream ss; string girlName = girl->m_Realname; ss << girlName;
	int roll_a = g_Dice.d100(), roll_b = g_Dice.d100(), roll_c = g_Dice.d100();
	if (g_Girls.DisobeyCheck(girl, actiontype, brothel))			// they refuse to work 
	{
		ss << " refused to work during the " << (Day0Night1 ? "night" : "day") << " shift.";
		girl->m_Events.AddMessage(ss.str(), IMGTYPE_PROFILE, EVENT_NOWORK);
		return true;
	}
	ss << " worked as a gardener on the farm.\n\n";

	g_Girls.UnequipCombat(girl);	// put that shit away, you'll scare off the customers!

	double wages = 20, tips = 0;
	int enjoy = 0;
	int imagetype = IMGTYPE_FARM;
	int msgtype = Day0Night1;

#pragma endregion
#pragma region //	Job Performance			//


	double jobperformance = JP_Gardener(girl, false);
	if (jobperformance >= 245)
	{
		ss << " She must be the perfect at this.";
		wages += 155;
	}
	else if (jobperformance >= 185)
	{
		ss << " She's unbelievable at this.";
		wages += 95;
	}
	else if (jobperformance >= 145)
	{
		ss << " She's good at this job.";
		wages += 55;
	}
	else if (jobperformance >= 100)
	{
		ss << " She made a few mistakes but overall she is okay at this.";
		wages += 15;
	}
	else if (jobperformance >= 70)
	{
		ss << " She was nervous and made a few mistakes. She isn't that good at this.";
		wages -= 5;
	}
	else
	{
		ss << " She was nervous and constantly making mistakes. She really isn't very good at this job.";
		wages -= 15;
	}
	ss << "\n\n";

#pragma endregion
#pragma region	//	Enjoyment and Tiredness		//


	int roll = g_Dice.d100();

	//enjoyed the work or not
	if (roll <= 5)
	{
		ss << "Some of the patrons abused her during the shift.";
		enjoy -= 1;
	}
	else if (roll <= 25)
	{
		ss << "She had a pleasant time working.";
		enjoy += 3;
	}
	else
	{
		ss << "Otherwise, the shift passed uneventfully.";
		enjoy += 1;
	}


#pragma endregion
#pragma region	//	Create Items				//


	// `J` Farm Bookmark - adding in items that can be gathered in the farm


	int flowerpower = g_Dice % 3;
	/* */if (jobperformance < 70)	flowerpower -= 1;
	else if (jobperformance < 100)	flowerpower += 0;
	else if (jobperformance < 145)	flowerpower += 1;
	else if (jobperformance < 185)	flowerpower += 2;
	else if (jobperformance < 245)	flowerpower += 3;
	else /*                     */	flowerpower += 4;

	string additems[8] = { "", "", "", "", "", "", "", "" };
	int additemnum = 0;
	while (flowerpower > 0 && additemnum < 8)
	{
		string additem = "";
		switch (g_Dice % 14)
		{
		case 0:		if (flowerpower >= 5) { flowerpower -= 5;	additem = "Bouquet of Enchanted Roses"; } break;
		case 1:		if (flowerpower >= 5) { flowerpower -= 5;	additem = "Chatty Flowers"; }			  break;
		case 2:		if (flowerpower >= 4) { flowerpower -= 4;	additem = "Watermelon of Knowledge"; }	  break;
		case 3:		if (flowerpower >= 3) { flowerpower -= 3;	additem = "Mango of Knowledge"; }		  break;
		case 4:		if (flowerpower >= 3) { flowerpower -= 3;	additem = "Red Rose Extravaganza"; }	  break;
		case 5:		if (flowerpower >= 3) { flowerpower -= 3;	additem = "Vira Blood"; }				  break;
		case 6:		if (flowerpower >= 3) { flowerpower -= 3;	additem = "Whitewillow Sap"; }			  break;
		case 7:		if (flowerpower >= 2) { flowerpower -= 2;	additem = "Rose of Enchantment"; }		  break;
		case 8:		if (flowerpower >= 2) { flowerpower -= 2;	additem = "Sinspice"; }					  break;
		case 9:		if (flowerpower >= 2) { flowerpower -= 2;	additem = "Nut of Knowledge"; }			  break;
		case 10:	if (flowerpower >= 2) { flowerpower -= 2;	additem = "Willbreaker Spice"; }		  break;
		case 11:	if (flowerpower >= 1) { flowerpower -= 1;	additem = "Shroud Mushroom"; }			  break;
		case 12:	if (flowerpower >= 1) { flowerpower -= 1;	additem = "Wild Flowers"; }				  break;
		default:	flowerpower -= 1; break;
		}
		if (additem != "")
		{
			additems[additemnum] = additem;
			additemnum++;
		}
	}
	if (additemnum > 0)
	{
		msgtype = EVENT_GOODNEWS;
		ss << "\n\n" << girlName << " was able to harvest ";
		if (additemnum == 1)
		{
			ss << "one " << additems[0] << ".";
		}
		else
		{
			ss << additemnum << " items: ";
			for (int i = 0; i < additemnum; i++)
			{
				ss << additems[i];
				if (i == additemnum - 1) ss << ".";
				else ss << ", ";
			}
		}
		for (int i = 0; i < additemnum; i++)
		{
			sInventoryItem* item = g_InvManager.GetItem(additems[i]);
			if (item) g_Brothels.AddItemToInventory(item);
		}
	}





#pragma endregion
#pragma region	//	Money					//

	if (girl->is_slave() && !cfg.initial.slave_pay_outofpocket()) wages = 0;    // You own her so you don't have to pay her.
	else
	{
		int roll_max = (g_Girls.GetStat(girl, STAT_INTELLIGENCE)
			+ g_Girls.GetStat(girl, SKILL_HERBALISM)
			+ g_Girls.GetSkill(girl, SKILL_FARMING));
		roll_max /= 6;
		wages += 10 + g_Dice%roll_max;
	}



#pragma endregion
#pragma region	//	Finish the shift			//




	g_Girls.UpdateEnjoyment(girl, actiontype, enjoy);
	girl->m_Events.AddMessage(ss.str(), IMGTYPE_PROFILE, msgtype);

	// Money
	if (wages < 0)	wages = 0;	girl->m_Pay = (int)wages;
	if (tips < 0)	tips = 0;	girl->m_Tips = (int)tips;

	// Improve stats
	int xp = 5, libido = 1, skill = 3;

	if (g_Girls.HasTrait(girl, "Quick Learner"))		{ skill += 1; xp += 3; }
	else if (g_Girls.HasTrait(girl, "Slow Learner"))	{ skill -= 1; xp -= 3; }
	if (g_Girls.HasTrait(girl, "Nymphomaniac"))			{ libido += 2; }

	g_Girls.UpdateStat(girl, STAT_EXP, (g_Dice % xp) + 1);
	g_Girls.UpdateStatTemp(girl, STAT_LIBIDO, libido);

	// primary (+2 for single or +1 for multiple)
	g_Girls.UpdateSkill(girl, SKILL_HERBALISM, (g_Dice%skill) + 2);
	// secondary (-1 for one then -2 for others)
	g_Girls.UpdateSkill(girl, SKILL_FARMING, max(0, (g_Dice % skill) - 1));
	g_Girls.UpdateStat(girl, STAT_INTELLIGENCE, max(0, (g_Dice % skill) - 2));
	g_Girls.UpdateStat(girl, STAT_CONSTITUTION, max(0, (g_Dice % skill) - 2));

#pragma endregion
	return false;
}
Example #5
0
// `J` Job Farm - Laborers
bool cJobManager::WorkMilker(sGirl* girl, sBrothel* brothel, bool Day0Night1, string& summary)
{
#pragma region //	Job setup				//
	int actiontype = ACTION_WORKFARM;
	stringstream ss; string girlName = girl->m_Realname; ss << girlName;
	int roll_a = g_Dice.d100(), roll_b = g_Dice.d100(), roll_c = g_Dice.d100();
	if (g_Girls.DisobeyCheck(girl, actiontype, brothel))			// they refuse to work 
	{
		ss << " refused to work during the " << (Day0Night1 ? "night" : "day") << " shift.";
		girl->m_Events.AddMessage(ss.str(), IMGTYPE_PROFILE, EVENT_NOWORK);
		return true;
	}
	ss << " worked as a milker on the farm.\n\n";

	g_Girls.UnequipCombat(girl);	// put that shit away, you'll scare off the customers!

	double wages = 20, tips = 0;
	int enjoy = 0;
	int imagetype = IMGTYPE_FARM;
	int msgtype = Day0Night1;

#pragma endregion
#pragma region //	Job Performance			//

	double jobperformance = JP_Milker(girl, false);
	double drinks = jobperformance / 2;

	if (jobperformance >= 245)
	{
		ss << "Her milk bucket practically fills itself as she walks down the rows of cows.";
		drinks *= 5; roll_a += 10; roll_b += 25;
	}
	else if (jobperformance >= 185)
	{
		ss << "Her hands moved like lightning as she gracefully milks the cows teats.";
		drinks *= 4; roll_a += 5; roll_b += 18;
	}
	else if (jobperformance >= 145)
	{
		ss << "She knows exactly when the cows are ready to be milked and how to best milk them.";
		drinks *= 3; roll_a += 2; roll_b += 10;
	}
	else if (jobperformance >= 100)
	{
		ss << "She can milk the cows without spilling much.";
		drinks *= 2;
	}
	else if (jobperformance >= 70)
	{
		ss << "She isn't very good at aiming the teats into the bucket.";
		roll_a -= 2; roll_b -= 5;
	}
	else
	{
		ss << "She can't seem to get the hang of this.";
		wages -= 10; drinks *= 0.8; roll_a -= 5; roll_b -= 10;
	}
	ss << "\n\n";

#pragma endregion
#pragma region	//	Enjoyment and Tiredness		//

	// Complications
	if (roll_a <= 10)
	{
		enjoy -= g_Dice % 3 + 1;
		ss << "The animals were uncooperative and some didn't even let her get near them.\n";
		drinks *= 0.8;
		if (g_Dice.percent(20))
		{
			enjoy--;
			ss << "Several animals kicked over the milking buckets and soaked " << girlName << ".\n";
			girl->happiness(-(1 + g_Dice % 5));
			drinks -= (5 + g_Dice % 6);
		}
		if (g_Dice.percent(20))
		{
			enjoy--;
			ss << "One of the animals urinated on " << girlName << " and contaminated the milk she had collected.\n";
			girl->happiness(-(1 + g_Dice % 3));
			drinks -= (5 + g_Dice % 6);
		}
		if (g_Dice.percent(20))
		{
			enjoy--;
			int healthmod = g_Dice % 10 + 1;
			girl->health(-healthmod);
			girl->happiness(-(healthmod + g_Dice % healthmod));
			ss << "One of the animals kicked " << girlName << " and ";
			if (girl->health() < 1)
			{
				ss << "killed her.\n";
				g_MessageQue.AddToQue(girlName + " was killed when an animal she was milking kicked her in the head.", COLOR_RED);
				return false;	// not refusing, she is dead
			}
			else ss << (healthmod > 5 ? "" : "nearly ") << "broke her arm.\n";
			drinks -= (5 + g_Dice % 6);
		}
	}
	else if (roll_a >= 90)
	{
		enjoy += g_Dice % 3 + 1;
		ss << "The animals were pleasant and cooperative today.\n";
		drinks *= 1.2;
	}
	else
	{
		enjoy += g_Dice % 2;
		ss << "She had an uneventful day milking.\n";
	}

#pragma endregion
#pragma region	//	Money					//

	// slave girls not being paid for a job that normally you would pay directly for do less work
	if ((girl->is_slave() && !cfg.initial.slave_pay_outofpocket()))
	{
		drinks *= 0.9;
		wages = 0;
	}
	else
	{
		wages += drinks / 100; // `J` Pay her based on how much she brought in
	}

#pragma endregion
#pragma region	//	Create Items				//

	int milk = int(drinks / 10);	// plain milk is made here, breast milk from girls is made in WorkMilk
	if (milk > 0)
	{
		int milkmade[5] = { 0, 0, 0, 0, 0 };	// (total,gallon,quart,pint,shots}
		// check if the milk items exist and only do the checks if at least one of them does
		sInventoryItem* milkitems[4] = { g_InvManager.GetItem("Milk"), g_InvManager.GetItem("Milk (pt)"), g_InvManager.GetItem("Milk (qt)"), g_InvManager.GetItem("Milk (g)") };
		if (milkitems[0] != 0 || milkitems[1] != 0 || milkitems[2] != 0 || milkitems[3] != 0)
		{
			while (milk > 0)	// add milk
			{
				sInventoryItem* item = NULL;
				string itemname = "";
				/* */if (milkitems[3] && milk > 3 && g_Dice.percent(30))
				{
					milk -= 4;
					milkmade[0]++;
					milkmade[4]++;
					g_Brothels.AddItemToInventory(milkitems[3]);
				}
				else if (milkitems[2] && milk > 2 && g_Dice.percent(50))
				{
					milk -= 3;
					milkmade[0]++;
					milkmade[3]++;
					g_Brothels.AddItemToInventory(milkitems[2]);
				}
				else if (milkitems[1] && milk > 1 && g_Dice.percent(70))
				{
					milk -= 2;
					milkmade[0]++;
					milkmade[2]++;
					g_Brothels.AddItemToInventory(milkitems[1]);
				}
				else if (milkitems[0])
				{
					milk -= 1;
					milkmade[0]++;
					milkmade[1]++;
					g_Brothels.AddItemToInventory(milkitems[0]);
				}
				else milk--;	// add a reducer just in case.
			}
		}
		if (milkmade[0] > 0)
		{
			ss << girlName << " produced " << milkmade[0] << " bottles of milk for you, \n";
			if (milkmade[4] > 0) ss << milkmade[4] << " gallons\n";
			if (milkmade[3] > 0) ss << milkmade[3] << " quarts\n";
			if (milkmade[2] > 0) ss << milkmade[2] << " pints\n";
			if (milkmade[1] > 0) ss << milkmade[1] << " shots\n";
		}
	}

	// `J` zzzzzz - need to add the girl milking herself - can be done easier after WorkMilk is done



	
#pragma endregion
#pragma region	//	Finish the shift			//

	ss << "\n" << girlName;
	if ((int)drinks > 0)
	{
		g_Brothels.add_to_drinks((int)drinks);
		ss << " brought in " << (int)drinks << " units of milk.";
	}
	else { ss << " was unable to collect any milk."; }

	girl->m_Events.AddMessage(ss.str(), imagetype, msgtype);

	// Money
	if (wages < 0)	wages = 0;	girl->m_Pay = (int)wages;
	if (tips < 0)	tips = 0;	girl->m_Tips = (int)tips;

	// Improve stats
	int xp = 5, libido = 1, skill = 3;

	if (g_Girls.HasTrait(girl, "Quick Learner"))		{ skill += 1; xp += 3; }
	else if (g_Girls.HasTrait(girl, "Slow Learner"))	{ skill -= 1; xp -= 3; }
	if (g_Girls.HasTrait(girl, "Nymphomaniac"))			{ libido += 2; }

	g_Girls.UpdateStat(girl, STAT_EXP, (g_Dice % xp) + 1);
	g_Girls.UpdateStatTemp(girl, STAT_LIBIDO, libido);

	// primary (+2 for single or +1 for multiple)
	g_Girls.UpdateSkill(girl, SKILL_ANIMALHANDLING, (g_Dice % skill) + 2);
	// secondary (-1 for one then -2 for others)
	g_Girls.UpdateSkill(girl, SKILL_HANDJOB, max(0, (g_Dice % skill) - 1));
	g_Girls.UpdateSkill(girl, SKILL_FARMING, max(0, (g_Dice % skill) - 2));
	g_Girls.UpdateStat(girl, STAT_INTELLIGENCE, max(0, (g_Dice % skill) - 2));

	g_Girls.UpdateEnjoyment(girl, actiontype, enjoy);


#pragma endregion
	return false;
}
Example #6
0
// `J` Job Farm - Laborers
bool cJobManager::WorkFarmer(sGirl* girl, sBrothel* brothel, bool Day0Night1, string& summary)
{
#pragma region //	Job setup				//
	int actiontype = ACTION_WORKFARM;
	stringstream ss; string girlName = girl->m_Realname; ss << girlName;
	int roll_a = g_Dice.d100(), roll_b = g_Dice.d100(), roll_c = g_Dice.d100();
	if (g_Girls.DisobeyCheck(girl, actiontype, brothel))			// they refuse to work 
	{
		ss << " refused to work during the " << (Day0Night1 ? "night" : "day") << " shift.";
		girl->m_Events.AddMessage(ss.str(), IMGTYPE_PROFILE, EVENT_NOWORK);
		return true;
	}
	ss << " worked tending crops on the farm.\n\n";

	g_Girls.UnequipCombat(girl);	// put that shit away, you'll scare off the customers!

	double wages = 20, tips = 0;
	int enjoy = 0;
	int imagetype = IMGTYPE_FARM;
	int msgtype = Day0Night1;

#pragma endregion
#pragma region //	Job Performance			//

	double jobperformance = (int)JP_Farmer(girl, false);
	double foodproduced = jobperformance;
	int alchemyproduced = 0;
	int goodsproduced = 0;

	if (jobperformance >= 245)
	{
		ss << "Her basket practically fills itself as she walks down the rows of crops.";
		foodproduced *= 5; roll_a += 10; roll_b += 25;
	}
	else if (jobperformance >= 185)
	{
		ss << "Her hands moved like lightning as she picked only the best crops.";
		foodproduced *= 4; roll_a += 5; roll_b += 18;
	}
	else if (jobperformance >= 145)
	{
		ss << "She knows exactly when the crops are ready to be picked and how to best collect them.";
		foodproduced *= 3; roll_a += 2; roll_b += 10;
	}
	else if (jobperformance >= 100)
	{
		ss << "She can pick the crops fairly well without too many culls.";
		foodproduced *= 2;
	}
	else if (jobperformance >= 70)
	{
		ss << "She isn't very good at knowing which plants are ripe and which should have been left a little longer.";
		roll_a -= 2; roll_b -= 5;
	}
	else
	{
		ss << "She seems to take more of the unuseable parts of the plants than she takes the edible parts.";
		wages -= 10; foodproduced *= 0.8; roll_a -= 5; roll_b -= 10;
	}
	ss << "\n\n";

#pragma endregion
#pragma region	//	Enjoyment and Tiredness		//

	int tired = (300 - (int)jobperformance);	// this gets divided in roll_a by (8, 10 or 12) so it will end up around 0-40 tired
	if (roll_a <= 10)
	{
		tired /= 8;
		enjoy -= g_Dice % 3;
		if (roll_b < 20)	// injury
		{
			girl->health(-(1 + g_Dice % 5));
			foodproduced *= 0.8;
			if (g_Dice.percent(girl->magic() / 2))
			{
				girl->mana(-10 - (g_Dice % 10));
				ss << "While trying to use magic to do her work for her, the magic rebounded on her";
			}
			else ss << "She cut herself while working";
			if (girl->health() <= 0)
			{
				ss << " killing her.";
				g_MessageQue.AddToQue(girlName + " was killed in an accident at the Farm.", COLOR_RED);
				return false;	// not refusing, she is dead
			}
			else ss << ".";
		}
		else	// unhappy
		{
			foodproduced *= 0.9;
			ss << "She did not like working in the fields today.";
			girl->happiness(-(g_Dice % 11));
		}
	}
	else if (roll_a >= 90)
	{
		tired /= 12;
		foodproduced *= 1.1;
		enjoy += g_Dice % 3;
		/* */if (roll_b < 50)	ss << "She kept a steady pace by humming a pleasant tune.";
		else /*            */	ss << "She had a great time working today.";
	}
	else
	{
		tired /= 10;
		enjoy += g_Dice % 2;
		ss << "The shift passed uneventfully.";
	}
	ss << "\n\n";

#pragma endregion
#pragma region	//	Create Items				//

	if (g_Dice.percent((girl->farming() + girl->magic()) / 10) && g_Dice.percent(jobperformance / 10))
	{
		string itemname = ""; int itemnumber = 1;
		/* */if (roll_c > 30)	{ itemname = "Nut of Knowledge";		itemnumber = (roll_c > 90 ? g_Dice % 3 + 2 : 1); }
		else if (roll_c > 10)	{ itemname = "Mango of Knowledge";		itemnumber = (roll_c > 28 ? 2 : 1); }
		else/*            */	{ itemname = "Watermelon of Knowledge"; itemnumber = (roll_c == 9 ? 2 : 1); }

		sInventoryItem* item = g_InvManager.GetItem(itemname);
		if (item)
		{
			for (int i = 0; i < itemnumber; i++) g_Brothels.AddItemToInventory(item);
			ss << "While picking crops, " << girlName << " sensed a magical aura and found ";
			if (itemnumber == 1) ss << "a"; else ss << itemnumber;
			ss << " " << itemname << ".\n";
			foodproduced -= itemnumber;
		}
	}
	if (g_Dice.percent(girl->herbalism() / 2) && g_Dice.percent(jobperformance / 10))
	{
		alchemyproduced = 1 + g_Dice % (girl->herbalism() / 10);
		ss << "While sorting the day's haul, " << girlName << " came across ";
		if (alchemyproduced == 1) ss << "a specimen";
		else ss << alchemyproduced << " specimens";
		ss << " that would work well in potions.\n";
		foodproduced -= alchemyproduced;
	}
	if (g_Dice.percent(girl->crafting() / 2) && g_Dice.percent(jobperformance / 10))
	{
		goodsproduced = 1 + g_Dice % (girl->crafting() / 10);
		ss << girlName << " created ";
		if (goodsproduced == 1) ss << "a little toy";
		else ss << goodsproduced << " little toys";
		ss << " from the unuseable parts of her crops.\n";
	}
	if (foodproduced <= 0) foodproduced = 0;

#pragma endregion
#pragma region	//	Money					//

	// slave girls not being paid for a job that normally you would pay directly for do less work
	if ((girl->is_slave() && !cfg.initial.slave_pay_outofpocket()))
	{
		foodproduced *= 0.9;
		wages = 0;
	}
	else
	{
		wages += foodproduced / 100; // `J` Pay her based on how much she brought in
	}

#pragma endregion
#pragma region	//	Finish the shift			//

	if (foodproduced > 0)
	{
		g_Brothels.add_to_food((int)foodproduced);
		ss << "\n" << girlName << " brought in " << (int)foodproduced << " units of food.";
	}
	if (alchemyproduced > 0)	g_Brothels.add_to_alchemy((int)alchemyproduced);
	if (goodsproduced > 0)		g_Brothels.add_to_goods((int)goodsproduced);

	// Money
	if (wages < 0)	wages = 0;	girl->m_Pay = (int)wages;
	if (tips < 0)	tips = 0;	girl->m_Tips = (int)tips;

	// Base Improvement and trait modifiers
	int xp = 5, libido = 1, skill = 3;
	/* */if (girl->has_trait("Quick Learner"))	{ skill += 1; xp += 3; }
	else if (girl->has_trait("Slow Learner"))	{ skill -= 1; xp -= 3; }
	/* */if (girl->has_trait("Nymphomaniac"))	{ libido += 2; }
	// EXP and Libido
	int I_xp = (g_Dice % xp) + 1;							g_Girls.UpdateStat(girl, STAT_EXP, I_xp);
	int I_libido = (g_Dice % libido) + 1;					g_Girls.UpdateStatTemp(girl, STAT_LIBIDO, I_libido);
	if (tired > 0) girl->tiredness(tired);

	// primary improvement (+2 for single or +1 for multiple)
	int I_farming = (g_Dice % skill) + 2;					g_Girls.UpdateSkill(girl, SKILL_FARMING, I_farming);
	// secondary improvement (-1 for one then -2 for others)
	int I_strength = max(0, (g_Dice % skill) - 1);			g_Girls.UpdateStat(girl, STAT_STRENGTH, I_strength);
	int I_constitution = max(0, (g_Dice % skill) - 2);		g_Girls.UpdateStat(girl, STAT_CONSTITUTION, I_constitution);
	int I_intelligence = max(0, (g_Dice % skill) - 2);		g_Girls.UpdateStat(girl, STAT_INTELLIGENCE, I_intelligence);

	// Update Enjoyment
	if (jobperformance < 50) enjoy -= 1; if (jobperformance < 0) enjoy -= 1;	// if she doesn't do well at the job, she enjoys it less
	if (jobperformance > 200) enjoy *= 2;		// if she is really good at the job, her enjoyment (positive or negative) is doubled
	g_Girls.UpdateEnjoyment(girl, actiontype, enjoy);

	// Gain Traits
	g_Girls.PossiblyGainNewTrait(girl, "Tough", 50, actiontype, "Working in the heat of the sun has made " + girlName + " rather Tough.", Day0Night1);

	if (cfg.debug.log_show_numbers())
	{
		ss << "\n\nNumbers:"
			<< "\n Job Performance = " << (int)jobperformance
			<< "\n Wages = " << (int)wages
			<< "\n Tips = " << (int)tips
			<< "\n Xp = " << I_xp
			<< "\n Libido = " << I_libido
			<< "\n Farming = " << I_farming
			<< "\n Strength = " << I_strength
			<< "\n Constitution = " << I_constitution
			<< "\n Intelligence = " << I_intelligence
			<< "\n Tiredness = " << tired
			<< "\n Enjoy " << girl->enjoy_jobs[actiontype] << " = " << enjoy
			;
	}

	// Push out the turn report
	girl->m_Events.AddMessage(ss.str(), imagetype, msgtype);

#pragma endregion
	return false;
}
// `J` Job Farm - Staff - Learning_Job
bool cJobManager::WorkFarmResearch(sGirl* girl, sBrothel* brothel, bool Day0Night1, string& summary)
{
#pragma region //	Job setup				//
	int actiontype = ACTION_WORKTRAINING;
	stringstream ss; string girlName = girl->m_Realname; ss << girlName;
	int roll_a = g_Dice.d100(), roll_b = g_Dice.d100(), roll_c = g_Dice.d100();
	if (g_Girls.DisobeyCheck(girl, actiontype, brothel))			// they refuse to work 
	{
		ss << " refused to work during the " << (Day0Night1 ? "night" : "day") << " shift.";
		girl->m_Events.AddMessage(ss.str(), IMGTYPE_PROFILE, EVENT_NOWORK);
		return true;
	}
	ss << " worked as a reseacher on the farm.";

	g_Girls.UnequipCombat(girl);	// put that shit away
	
	double wages = 20, tips = 0;
	int enjoy = 0;
	int imagetype = IMGTYPE_PROFILE;
	int msgtype = Day0Night1;

#pragma endregion
#pragma region //	Job Performance			//

	int train = 0;												// main skill trained
	int tanm = girl->m_Skills[SKILL_ANIMALHANDLING];			// Starting level - train = 1
	int tfar = girl->m_Skills[SKILL_FARMING];					// Starting level - train = 2
	int tmag = girl->m_Skills[SKILL_MAGIC];						// Starting level - train = 3
	int ther = girl->m_Skills[SKILL_HERBALISM];					// Starting level - train = 4
	int tint = girl->m_Stats[STAT_INTELLIGENCE];				// Starting level - train = 5
	bool gaintrait = false;										// posibility of gaining a trait
	int skill = 0;												// gian for main skill trained
	int dirtyloss = brothel->m_Filthiness / 100;				// training time wasted with bad equipment
	int sgAnm = 0, sgFar = 0, sgMag = 0, sgHer = 0, sgInt = 0;	// gains per skill


	/* */if (roll_a <= 5)	skill = 7;
	else if (roll_a <= 15)	skill = 6;
	else if (roll_a <= 30)	skill = 5;
	else if (roll_a <= 60)	skill = 4;
	else /*             */	skill = 3;
	/* */if (g_Girls.HasTrait(girl, "Quick Learner"))	{ skill += 1; }
	else if (g_Girls.HasTrait(girl, "Slow Learner"))	{ skill -= 1; }
	skill -= dirtyloss;
	ss << "The Farm Lab is ";
	if (dirtyloss <= 0) ss << "clean and tidy";
	if (dirtyloss == 1) ss << "dirty and the equipment has not been put back in its place";
	if (dirtyloss == 2) ss << "messy. The equipment is damaged and strewn about the building";
	if (dirtyloss == 3) ss << "filthy and some of the equipment is broken";
	if (dirtyloss >= 4) ss << "in complete disarray and the equipment barely usable";
	ss << ".\n\n";
	if (skill < 1) skill = 1;	// always at least 1 

	do{		// `J` New method of selecting what job to do
		/* */if (roll_b < 20  && tanm < 100)	train = 1;	// animalhandling
		else if (roll_b < 40  && tfar < 100)	train = 2;	// farming
		else if (roll_b < 60  && tmag < 100)	train = 3;	// magic
		else if (roll_b < 80  && ther < 100)	train = 4;	// herbalism
		else if (roll_b < 100 && tint < 100)	train = 5;	// intelligence
		roll_b -= 10;
	} while (train == 0 && roll_b > 0);
	if (train == 0 || g_Dice.percent(5)) gaintrait = true;

	if (train == 1) { sgAnm = skill; ss << "She researches animals.\n"; }				else sgAnm = g_Dice % 2;
	if (train == 2) { sgFar = skill; ss << "She researches farming techniques.\n"; }	else sgFar = g_Dice % 2;
	if (train == 3) { sgMag = skill; ss << "She researches magical techniques.\n"; }	else sgMag = g_Dice % 2;
	if (train == 4) { sgHer = skill; ss << "She researches plants and their uses.\n"; }	else sgHer = g_Dice % 2;
	if (train == 5) { sgInt = skill; ss << "She researches general topics.\n"; }		else sgInt = g_Dice % 2;

	if (sgAnm + sgFar + sgMag + sgHer + sgInt > 0)
	{
		ss << "She managed to gain:\n";
		if (sgAnm > 0) { ss << sgAnm << " Animal Handling\n";	g_Girls.UpdateSkill(girl, SKILL_ANIMALHANDLING, sgAnm); }
		if (sgFar > 0) { ss << sgFar << " Farming\n";			g_Girls.UpdateSkill(girl, SKILL_FARMING, sgFar); }
		if (sgMag > 0) { ss << sgMag << " Magic\n";				g_Girls.UpdateSkill(girl, SKILL_MAGIC, sgMag); }
		if (sgHer > 0) { ss << sgHer << " Herbalism\n";			g_Girls.UpdateSkill(girl, SKILL_HERBALISM, sgHer); }
		if (sgInt > 0) { ss << sgInt << " Intelligence\n";		g_Girls.UpdateStat(girl, STAT_INTELLIGENCE, sgInt); }
	}
	
	int trycount = skill;
	while (gaintrait && trycount > 0)	// `J` Try to add a trait 
	{
		trycount--;
		switch (g_Dice % 10)
		{
		case 0:
			break;
		case 1:
			break;
		case 2:
			if (g_Girls.HasTrait(girl, "Dependant"))
			{
				g_Girls.RemoveTrait(girl, "Dependant");
				ss << "She seems to be getting over her Dependancy with her training.";
				gaintrait = false;
			}
			break;
		case 3:
			break;
		case 4:
			break;
		case 5:

			break;
		case 6:

			break;

		default:	break;	// no trait gained
		}
	}
	ss << "\n\n";

#pragma endregion
#pragma region	//	Enjoyment and Tiredness		//


	//enjoyed the work or not
	/* */if (roll_c <= 10)	{ enjoy -= g_Dice % 3 + 1;	ss << "She did not enjoy her time training."; }
	else if (roll_c >= 90)	{ enjoy += g_Dice % 3 + 1;	ss << "She had a pleasant time training."; }
	else /*             */	{ enjoy += g_Dice % 2;		ss << "Otherwise, the shift passed uneventfully."; }
	
	ss << "\n\n";

#pragma endregion
#pragma region	//	Create Items				//



	// `J` Farm Bookmark - adding in items that can be created in the farm
	if (girl->intelligence() + girl->crafting() > 100 && g_Dice.percent(girl->intelligence() + girl->crafting() / 10))	// 10-20%
	{
		sInventoryItem* item = NULL;
		string itemname = "";
		int tries = skill;
		while (itemname == "" && tries > 0)
		{
			switch (g_Dice % 20)
			{
				/*	For each item available, the girl making it must have:
				Skills:
				*	If an item gives less than 40 skill points, the girl must have 40 more than the amount given in that skill
				*	If it gives more than 40 points, there will need to be some magic included.
				*	If there are multiple skills, add 40 to each bonus and if skills (a+b+c) > bonus total
				Stats:
				*	Stats will need more variation in how high they are needed because it is less knowledge than conditioning
				Traits:
				*	Most traits will require some magic
				Randomness:
				*	There also should be a g_Dice.percent() with the main Skills averaged and divided by 10
				*		If there are 3 skills, then g_Dice.percent((a+b+c)/30)
				*/
			case 0:
				if (girl->farming() > 50 && girl->animalhandling() > 50
					&& g_Dice.percent(girl->farming() + girl->animalhandling() / 20))
					itemname = "Farmer's Guide";		// +10 Farming, +10 AnimalHandling
				break;
			case 1:
				if (girl->constitution() > 60 && g_Dice.percent(girl->constitution() / 10))
					itemname = "Manual of Health";		// (+15 Beast/Group, +10 Cons/Str, +5 BDSM/Comb)
				break;
			case 2:
				if (girl->magic() > 60 && g_Dice.percent(girl->magic() / 10))
					itemname = "Manual of Magic";		// +20 magic
				break;
			case 3:
				if (girl->magic() > 80 && g_Dice.percent(girl->magic() / 10))
					itemname = "Codex of the Arcane";	// +40 magic
				break;
			case 4:
				if (girl->lesbian() > 40 && g_Dice.percent(girl->lesbian() / 10))
					itemname = "Manual of Two Roses";	// +20 Lesbian
				break;
			case 5:
			{
				if (girl->lesbian() > 80 && g_Dice.percent(girl->lesbian() / 10))
					itemname = "Codex of Sappho";		// +40 Lesbian
			}break;
			case 6:
				if (girl->bdsm() > 60 && g_Dice.percent(girl->bdsm() / 10))
					itemname = "Manual of Bondage";		// (+20 BDSM, +5 Cons)
				break;
			case 7:
				if (girl->combat() > 60 && g_Dice.percent(girl->combat() / 10))
					itemname = "Manual of Arms";		// (+20 Com)
				break;
			case 8:
				if (girl->performance() + girl->strip() > 100 && g_Dice.percent((girl->performance() + girl->strip()) / 20))
					itemname = "Manual of the Dancer";	// (+15 Serv/Strip/Perf, +5 Norm/Agi)
				break;
			case 9:
				if (girl->normalsex() + girl->oralsex() + girl->anal() > 150 && g_Dice.percent((girl->normalsex() + girl->oralsex() + girl->anal()) / 30))
					itemname = "Manual of Sex";			// (+15 Norm, +10 Oral, +5 Anal)
				break;
			case 10:
			{
				if (girl->magic() < 80 && girl->mana() < 20) break;
				int manacost = 60;
				/* */if (girl->has_trait("Sterile"))		manacost = 80;
				else if (girl->has_trait("Fertile"))		manacost = 40;
				else if (girl->has_trait("Broodmother"))	manacost = 20;
				if (girl->mana() >= manacost && g_Dice.percent(girl->magic() - manacost))
				{
					girl->mana(-manacost);
					itemname = "Fertility Tome";				// (-Sterile, +Fertile, +50 Normal Sex, +100 Libido)
				}
			}break;
			case 11:
			{
				// Noble, Princess and Queen needs 40, everyone else needs 60 to make this
				if (girl->has_trait("Noble") || girl->has_trait("Princess") || girl->has_trait("Queen"))
					if (girl->refinement() < 40 || girl->service() < 40 || girl->intelligence() < 40)		break;
				else if (girl->refinement() < 60 && girl->service() < 60 && girl->intelligence() < 60)		break;
				// she can make it, now does she?
				if (g_Dice.percent((girl->refinement() + girl->service() + girl->intelligence()) / 30))
					itemname = "Codex of the Courtesan";		// (+20 Serv/Strip/Refin, +10 Mor/Dig/Cha/Int/Lib/Conf/Oral)
			}break;
			case 12:
			{
				int manacost = 70;
				// Dominatrix, M*******t and Sadistic needs 50, everyone else needs 70 to make this
				if (girl->has_trait("Dominatrix") || girl->has_trait("M*******t") || girl->has_trait("Sadistic"))
				{
					if (girl->bdsm() < 50 || girl->magic() < 50 || girl->mana() < 50)		break;
					manacost = 50;
				}
				else if (girl->bdsm() < 70 && girl->magic() < 70 && girl->mana() < 70)		break;
				// she can make it, now does she?
				if (g_Dice.percent((girl->bdsm() + girl->magic()) / 20))
				{
					girl->mana(-manacost);
					itemname = "Codex of Submission";		// (+30 Obed, -30 Spi/Dig, +20 BDSM, +10 Anal/Group/Oral/Hand/Foot)
				}
			}break;
			case 13:
			{
				if (girl->combat() > 80 && g_Dice.percent(girl->combat() / 10))
					itemname = "Codex of Mars";			// (+40 Com, Adds Brawler)
			}break;
			case 14:
			{
				if (girl->normalsex() + girl->oralsex() + girl->anal() > 170 && g_Dice.percent((girl->normalsex() + girl->oralsex() + girl->anal()) / 30))
					itemname = "Codex of Eros";			// (+30 Norm, +10 Anal/Oral)
			}break;
			case 15:
			{
				if (girl->medicine() + girl->intelligence() > 110 && g_Dice.percent((girl->medicine() + girl->intelligence()) / 20))
					itemname = "Codex of Asclepius";	// (+20 Med, +10 Int)
			}break;
			case 16:
			{
				/*

				*/
			}break;
			case 17:
			{
				/*

				*/
			}break;
			case 18:
			{
				/*

				*/
			}break;

			default:
				break;
			}
		}
		
		item = g_InvManager.GetItem(itemname);
		if (item)
		{
			g_Brothels.AddItemToInventory(item);
			ss << girlName << " managed to create a " << itemname << " by compiling her notes together.\n";
		}
	}



#pragma endregion
#pragma region	//	Money					//

	if ((girl->is_slave() && !cfg.initial.slave_pay_outofpocket())) { wages = 0; }
	else { wages = 25 + (skill * 5); } // `J` Pay her more if she learns more


#pragma endregion
#pragma region	//	Finish the shift			//


	
	g_Girls.UpdateEnjoyment(girl, actiontype, enjoy);

	girl->m_Events.AddMessage(ss.str(), IMGTYPE_PROFILE, Day0Night1);

	// Money
	if (wages < 0)	wages = 0;	girl->m_Pay = (int)wages;
	if (tips < 0)	tips = 0;	girl->m_Tips = (int)tips;

	// Improve stats
	int xp = 5 + skill, libido = int(1 + skill / 2);

	if (g_Girls.HasTrait(girl, "Quick Learner"))		{ xp += 2; }
	else if (g_Girls.HasTrait(girl, "Slow Learner"))	{ xp -= 2; }
	if (g_Girls.HasTrait(girl, "Nymphomaniac"))			{ libido += 2; }

	g_Girls.UpdateStat(girl, STAT_EXP, (g_Dice % xp) + 1);
	g_Girls.UpdateStatTemp(girl, STAT_LIBIDO, libido);

#pragma endregion
	return false;
}
Example #8
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;
	}
}
Example #9
0
// `J` Job Farm - Producers
bool cJobManager::WorkBrewer(sGirl* girl, sBrothel* brothel, bool Day0Night1, string& summary)
{
#pragma region //	Job setup				//
	int actiontype = ACTION_WORKCOOKING;
	stringstream ss; string girlName = girl->m_Realname; ss << girlName;
	int roll_a = g_Dice.d100(), roll_b = g_Dice.d100(), roll_c = g_Dice.d100();
	if (g_Girls.DisobeyCheck(girl, actiontype, brothel))			// they refuse to work 
	{
		ss << " refused to work during the " << (Day0Night1 ? "night" : "day") << " shift.";
		girl->m_Events.AddMessage(ss.str(), IMGTYPE_PROFILE, EVENT_NOWORK);
		return true;
	}
	ss << " worked as a brewer on the farm.\n\n";

	g_Girls.UnequipCombat(girl);	// put that shit away, you'll scare off the customers!

	double wages = 20, tips = 0;
	int enjoy = 0;
	int imagetype = IMGTYPE_COOK;
	int msgtype = Day0Night1;

#pragma endregion
#pragma region //	Job Performance			//


	double jobperformance = JP_Brewer(girl, false);
	double drinksproduced = jobperformance;

	if (jobperformance >= 245)
	{
		ss << " She must be the perfect at this.";
		wages += 155;
	}
	else if (jobperformance >= 185)
	{
		ss << " She's unbelievable at this.";
		wages += 95;
	}
	else if (jobperformance >= 145)
	{
		ss << " She's good at this job.";
		wages += 55;
	}
	else if (jobperformance >= 100)
	{
		ss << " She made a few mistakes but overall she is okay at this.";
		wages += 15;
	}
	else if (jobperformance >= 70)
	{
		ss << " She was nervous and made a few mistakes. She isn't that good at this.";
		wages -= 5;
	}
	else
	{
		ss << " She was nervous and constantly making mistakes. She really isn't very good at this job.";
		wages -= 15;
	}
	ss << "\n\n";



#pragma endregion
#pragma region	//	Enjoyment and Tiredness		//



	if (wages < 0) wages = 0;
#if 1
	//enjoyed the work or not
	if (roll_a <= 5)
	{
		ss << "\nSome of the patrons abused her during the shift.";
		enjoy -= 1;
	}
	else if (roll_a <= 25)
	{
		ss << "\nShe had a pleasant time working.";
		enjoy += 3;
	}
	else
	{
		ss << "\nOtherwise, the shift passed uneventfully.";
		enjoy += 1;
	}
#else
	if (roll_a <= 10)
	{
		enjoyC -= g_Dice % 3; enjoyF -= g_Dice % 3;
		CleanAmt = int(CleanAmt * 0.8);
		/* */if (roll_b < 30)	ss << "She spilled a bucket of something unpleasant all over herself.";
		else if (roll_b < 60)	ss << "She stepped in something unpleasant.";
		else /*            */	ss << "She did not like working on the farm today.";
	}
	else if (roll_a >= 90)
	{
		enjoyC += g_Dice % 3; enjoyF += g_Dice % 3;
		CleanAmt = int(CleanAmt * 1.1);
		/* */if (roll_b < 50)	ss << "She cleaned the building while humming a pleasant tune.";
		else /*            */	ss << "She had a great time working today.";
	}
	else
	{
		enjoyC += g_Dice % 2; enjoyF += g_Dice % 2;
		ss << "The shift passed uneventfully.";
	}
	ss << "\n\n";
#endif


#pragma endregion
#pragma region	//	Create Items				//


	// `J` Farm Bookmark - adding in items that can be created in the farm
	string itemmade = "";
	string itemtext = "";
	int numbermade = 0;
	sInventoryItem* item = NULL;

	if (g_Dice.percent(min(90.0, jobperformance / 2)))
	{
		int chooseitem = g_Dice % (girl->magic() < 80 ? 80 : 100);	// limit some of the more magical items

		/* */if (chooseitem < 25) { itemmade = "Alcohol";					numbermade = (g_Dice % 5) + 2;	itemtext = " bottles of Alcohol "; }
		else if (chooseitem < 50) { itemmade = "Alcohol ";					numbermade = (g_Dice % 5) + 2;	itemtext = " bottles of Alcohol "; }
		else if (chooseitem < 55) { itemmade = "RigJuice";					numbermade = (g_Dice % 5) + 2;	itemtext = " bottles of RigJuice "; }
		else if (chooseitem < 60) { itemmade = "Radicola";					numbermade = (g_Dice % 5) + 2;	itemtext = " bottles of Radicola "; }
		else if (chooseitem < 65) { itemmade = "Black Cat Beer";			numbermade = 1;	itemtext = " bottle of Black Cat Beer "; }
		else if (chooseitem < 70) { itemmade = "Crossgate Egg Nog";			numbermade = 1;	itemtext = " bottle of Crossgate Egg Nog "; }
		else if (chooseitem < 75) { itemmade = "Nightmare Fuel";			numbermade = 1;	itemtext = " bottle of Nightmare Fuel "; }
		else if (chooseitem < 80) { itemmade = "Nightmare Fuel X";			numbermade = 1;	itemtext = " bottle of Nightmare Fuel "; }
		else if (chooseitem < 83) { itemmade = "Nightmare Fuel XY";			numbermade = 1;	itemtext = " bottle of Nightmare Fuel "; }
		else if (chooseitem < 84) { itemmade = "Nightmare Fuel XYZ";		numbermade = 1;	itemtext = " bottle of Nightmare Fuel "; }
		else if (chooseitem < 85) { itemmade = "Bimbo Liqueur";				numbermade = 1;	itemtext = " bottle of Bimbo Liqueur "; }
		else if (chooseitem < 86) { itemmade = "Mississippi Queen (Ch)";	numbermade = 1;	itemtext = " Mississippi Queen "; }
		else if (chooseitem < 87) { itemmade = "Mississippi Queen (De)";	numbermade = 1;	itemtext = " Mississippi Queen "; }
		else if (chooseitem < 88) { itemmade = "Mississippi Queen (FF)";	numbermade = 1;	itemtext = " Mississippi Queen "; }
		else if (chooseitem < 89) { itemmade = "Mississippi Queen (Fg)";	numbermade = 1;	itemtext = " Mississippi Queen "; }
		else if (chooseitem < 90) { itemmade = "Mississippi Queen (Fl)";	numbermade = 1;	itemtext = " Mississippi Queen "; }
		else if (chooseitem < 91) { itemmade = "Mississippi Queen (IW)";	numbermade = 1;	itemtext = " Mississippi Queen "; }
		else if (chooseitem < 92) { itemmade = "Mississippi Queen (MF)";	numbermade = 1;	itemtext = " Mississippi Queen "; }
		else if (chooseitem < 93) { itemmade = "Mississippi Queen (Mk)";	numbermade = 1;	itemtext = " Mississippi Queen "; }
		else if (chooseitem < 94) { itemmade = "Mississippi Queen (Ml)";	numbermade = 1;	itemtext = " Mississippi Queen "; }
		else if (chooseitem < 95) { itemmade = "Mississippi Queen (Op)";	numbermade = 1;	itemtext = " Mississippi Queen "; }
		else if (chooseitem < 96) { itemmade = "Mississippi Queen (Ps)";	numbermade = 1;	itemtext = " Mississippi Queen "; }
		else if (chooseitem < 97) { itemmade = "Mississippi Queen (Rt)";	numbermade = 1;	itemtext = " Mississippi Queen "; }
		else if (chooseitem < 98) { itemmade = "Mississippi Queen (St)";	numbermade = 1;	itemtext = " Mississippi Queen "; }
		else if (chooseitem < 99) { itemmade = "Mississippi Queen (To)";	numbermade = 1;	itemtext = " Mississippi Queen "; }
		else /*                */ { itemmade = "Mississippi Queen (Tw)";	numbermade = 1;	itemtext = " Mississippi Queen "; }

		item = g_InvManager.GetItem(itemmade);

	}
	if (item)
	{
		msgtype = EVENT_GOODNEWS;
		ss << "\n\n" << girlName << " made ";
		if (numbermade == 1) ss << "one ";
		else ss << numbermade << " ";
		ss << itemmade << " for you.";
		for (int i = 0; i < numbermade; i++)
			g_Brothels.AddItemToInventory(item);
	}





#pragma endregion
#pragma region	//	Money					//



#pragma endregion
#pragma region	//	Finish the shift			//


	g_Girls.UpdateEnjoyment(girl, actiontype, enjoy);
	girl->m_Events.AddMessage(ss.str(), imagetype, msgtype);

	// Money
	if (wages < 0)	wages = 0;	girl->m_Pay = (int)wages;
	if (tips < 0)	tips = 0;	girl->m_Tips = (int)tips;

	// Improve stats
	int xp = 5, libido = 1, skill = 3;

	if (g_Girls.HasTrait(girl, "Quick Learner"))		{ skill += 1; xp += 3; }
	else if (g_Girls.HasTrait(girl, "Slow Learner"))	{ skill -= 1; xp -= 3; }
	if (g_Girls.HasTrait(girl, "Nymphomaniac"))			{ libido += 2; }

	g_Girls.UpdateStat(girl, STAT_EXP, (g_Dice % xp) + 1);
	g_Girls.UpdateStatTemp(girl, STAT_LIBIDO, libido);

	// primary (+2 for single or +1 for multiple)
	g_Girls.UpdateSkill(girl, SKILL_BREWING, (g_Dice % skill) + 2);
	// secondary (-1 for one then -2 for others)
	g_Girls.UpdateSkill(girl, SKILL_HERBALISM, max(0, (g_Dice % skill) - 1));
	g_Girls.UpdateStat(girl, STAT_INTELLIGENCE, max(0, (g_Dice % skill) - 2));
	g_Girls.UpdateSkill(girl, SKILL_COOKING, max(0, (g_Dice % skill) - 2));

#pragma endregion
	return false;
}
Example #10
0
void cProtocol125::SendWholeInventory(const cInventory & a_Inventory)
{
	SendWholeInventory(*(a_Inventory.GetOwner().GetWindow()));
}
// `J` Job Farm - Laborers - Combat_Job
bool cJobManager::WorkBeastCapture(sGirl* girl, sBrothel* brothel, bool Day0Night1, string& summary)
{
#pragma region //	Job setup				//
	int actiontype = ACTION_COMBAT;
	stringstream ss; string girlName = girl->m_Realname; ss << girlName;
	int roll_a = g_Dice.d100(), roll_b = g_Dice.d100(), roll_c = g_Dice.d100();
	if (g_Girls.DisobeyCheck(girl, actiontype, brothel))			// they refuse to work
	{
		ss << " refused to capture beasts during the " << (Day0Night1 ? "night" : "day") << " shift.";
		girl->m_Events.AddMessage(ss.str(), IMGTYPE_PROFILE, EVENT_NOWORK);
		return true;
	}
	ss << " equipped herself and went out to hunt for exotic beasts and animals.\n\n";

	g_Girls.EquipCombat(girl);	// ready armor and weapons!

	int wages = 40, tips = 0;
	int enjoy = 0;
	int imagetype = IMGTYPE_COMBAT;
	int msgtype = Day0Night1;

#pragma endregion
#pragma region //	The Fight to get the Beasts		//

	int tired = 0;
	int gainmax = (int)(JP_BeastCapture(girl, false) / 30) + 1;
	int gain = g_Dice % gainmax + 1;
	sGirl* tempgirl = g_Girls.CreateRandomGirl(18, false, false, false, true, false);
	Uint8 fight_outcome = 0;
	if (tempgirl)		// `J` reworked incase there are no Non-Human Random Girls
	{
		fight_outcome = g_Girls.girl_fights_girl(girl, tempgirl);
	}
	else
	{
		g_LogFile.write("Error: You have no Non-Human Random Girls for your girls to fight\n");
		g_LogFile.write("Error: You need a Non-Human Random Girl to allow WorkBeastCapture randomness");
		fight_outcome = 7;
	}
	if (tempgirl) delete tempgirl; tempgirl = 0;	// Cleanup
	if (fight_outcome == 7)
	{
		ss << "She came back with just one animal today.\n\n";
		ss << "(Error: You need a Non-Human Random Girl to allow WorkBeastCapture randomness)";
		gain = 1;
		msgtype = EVENT_WARNING;
		tired = 15;
	}
	else if (fight_outcome == 1)	// she won
	{
		if (gain <= 2)	gain = 2;
		if (gain >= gainmax)	gain = gainmax;
		ss << "She had fun hunting today and came back with " << gain << " new beasts.";;
		imagetype = IMGTYPE_COMBAT;
		tired = g_Dice % (3 * gain);
		enjoy += g_Dice % 4 + 2;
	}
	else		// she lost or it was a draw
	{
		gain = g_Dice.bell(-gainmax / 3, gainmax / 2);
		ss << " The animals were difficult to track today. " << girlName << " eventually returned worn out and frustrated, ";
		if (gain <= 0)
		{
			gain = 0;
			ss << "empty handed.";
		}
		else
		{
			ss << "dragging ";
			if (gain == 1)	ss << "one";
			if (gain > 1)	ss << gain;
			ss << " captured beast" << (gain > 1 ? "s" : "") << " behind her.";
		}
		imagetype = IMGTYPE_COMBAT;
		enjoy -= g_Dice % 3 + 1;
		tired = g_Dice % (10 * gain) + 20;
	}
	ss << "\n\n";

#pragma endregion
#pragma region	//	A Little Randomness			//

	//SIN: A little randomness
	if (((g_Girls.GetSkill(girl, SKILL_ANIMALHANDLING) + g_Girls.GetStat(girl, STAT_CHARISMA)) > 125) && g_Dice.percent(30))
	{
		ss << girlName << " has a way with animals, a" << (gain > 1 ? "nother" : "") << " beast freely follows her back.\n";
		gain++;
	}
	//SIN: most the rest rely on more than one cap so might as well skip the lot if less than this...
	if (gain > 1)
	{
		// `J` added a switch with a use next if check fails and changed percents to (gain * 5)
		switch (g_Dice % 10)
		{
		case 0:
			if (girl->has_trait( "Twisted") && girl->has_trait( "Nymphomaniac") && (g_Girls.GetStat(girl, STAT_LIBIDO) >= 80))
			{
				ss << "Being a horny, twisted nymphomaniac, " << girlName << " had some fun with the beasts before she handed them over.\n";
				g_Girls.UpdateSkill(girl, SKILL_BEASTIALITY, g_Dice % gain);
				g_Girls.UpdateStat(girl, STAT_LIBIDO, -(g_Dice % gain));
				tired += gain;
				break;
			}
		case 1:
			if (girl->has_trait( "Psychic") && (g_Girls.GetStat(girl, STAT_LIBIDO) >= 90) && g_Dice.percent(gain * 5))
			{
				ss << girlName << "'s Psychic sensitivity caused her mind be overwhelmed by the creatures' lusts";
				if (g_Girls.CheckVirginity(girl))
				{
					ss << " but, things were moving too fast and she regained control before they could take her virginity.\n";
					g_Girls.UpdateSkill(girl, SKILL_BEASTIALITY, 1);
					g_Girls.UpdateStat(girl, STAT_LIBIDO, 2); // no satisfaction!
				}
				else
				{
					ss << ". Many hours later she staggered in to present the creatures to you.\n";
					g_Girls.UpdateSkill(girl, SKILL_BEASTIALITY, g_Dice % gain);
					g_Girls.UpdateStat(girl, STAT_LIBIDO, -2 * (g_Dice % gain));
					g_Girls.UpdateStat(girl, STAT_TIREDNESS, gain);
					girl->calc_insemination(g_Girls.GetBeast(), 1);
				}
				tired += gain;
				break;
			}
		case 2:
			if (girl->has_trait( "Assassin") && g_Dice.percent(gain * 5))
			{
				ss << " One of the captured creatures tried to escape on the way back. Trained assassin, " << girlName << ", instantly killed it as an example to the others.\n";
				g_Girls.UpdateSkill(girl, SKILL_COMBAT, 1);
				gain--;
				break;
			}
		case 3:
			if (g_Girls.GetStat(girl, STAT_TIREDNESS) > 50 && g_Dice.percent(gain * 5))
			{
				ss << girlName << " was so exhausted she couldn't concentrate. One of the creatures escaped.\n";
				gain--;
				break;
			}
		default: break;

		}
	}

#pragma endregion
#pragma region	//	Collect Pets				//

	// `J` Farm Bookmark - adding in items that can be gathered in the farm
	if (g_Dice.percent(5))
	{
		string itemfound = ""; string itemfoundtext = "";
		int chooseitem = g_Dice.d100();

		if (chooseitem < 25)
		{
			itemfound = (g_Dice % 2) ? "Black Cat" : "Cat";
			itemfoundtext = "a stray cat and brought it back with her.";
		}
		else if (chooseitem < 50)
		{
			itemfound = "Guard Dog";
			itemfoundtext = "a tough looking stray dog and brought it back with her.";
		}
		else if (chooseitem < 60)
		{
			itemfound = "A Bunch of Baby Ducks";
			itemfoundtext = "a bunch of baby ducks without a mother, so she gathered them up in her shirt and brought them home.";
		}
		else if (chooseitem < 65)
		{
			itemfound = "Death Bear";
			itemfoundtext = "a large bear that seems to have had some training, so she brought it home.";
		}
		else if (chooseitem < 80)
		{
			itemfound = "Pet Spider";
			itemfoundtext = "a strange looking spider so she collected it in a bottle and brought it back with her.";
		}
		else if (chooseitem < 95)
		{
			itemfound = (g_Dice % 4 == 1) ? "Fox Stole" : "Fur Stole";
			itemfoundtext = "a dead animal that was not too badly damaged. She brought it home, skinned it, cleaned it up and made a lovely stole from it.";
		}
		else if (chooseitem < 96)
		{
			itemfound = "Echidna's Snake";
			itemfoundtext = "a rather obedient and psychic snake. It wrapped itself around her crotch and let her take it home.";
		}
		else
		{
			itemfound = "Tiger Shark Tooth";
			itemfoundtext = "a rather large shark tooth and brought it home.";
		}

		sInventoryItem* item = g_InvManager.GetItem(itemfound);
		if (item)
		{
			ss << girlName << " found " << itemfoundtext;
			g_Brothels.AddItemToInventory(item);
		}
	}

#pragma endregion
#pragma region	//	Money					//

	// slave girls not being paid for a job that normally you would pay directly for do less work
	if ((girl->is_slave() && !cfg.initial.slave_pay_outofpocket()))
	{
		wages = 0;
	}
	else
	{
		wages += gain * 10; // `J` Pay her based on how much she brings back
	}

#pragma endregion
#pragma region	//	Finish the shift			//

	g_Brothels.add_to_beasts(gain);

	// Money
	girl->m_Tips = max(0, tips);
	girl->m_Pay = max(0, wages);

	// Improve girl
	// Base Improvement and trait modifiers
	int xp = 10, libido = 1, skill = 3;
	/* */if (girl->has_trait("Quick Learner"))	{ skill += 1; xp += 3; }
	else if (girl->has_trait("Slow Learner"))	{ skill -= 1; xp -= 3; }
	/* */if (girl->has_trait("Nymphomaniac"))	{ libido += 2; }
	// EXP and Libido
	int I_xp = (g_Dice % xp) + 1;							g_Girls.UpdateStat(girl, STAT_EXP, I_xp);
	int I_libido = (g_Dice % libido) + 1;					g_Girls.UpdateStatTemp(girl, STAT_LIBIDO, I_libido);
	if (tired > 0) girl->tiredness(tired);

	// primary improvement (+2 for single or +1 for multiple)
	int I_combat		= (g_Dice % skill) + 1;				g_Girls.UpdateSkill(girl, SKILL_COMBAT, I_combat);
	int I_animalh		= (g_Dice % skill) + 1;				g_Girls.UpdateSkill(girl, SKILL_ANIMALHANDLING, I_animalh);
	int I_strength		= (g_Dice % skill) + 1;				g_Girls.UpdateStat(girl, STAT_STRENGTH, I_strength);
	// secondary improvement (-1 for one then -2 for others)
	int I_constitution	= max(0, (g_Dice % skill) - 1);		g_Girls.UpdateStat(girl, STAT_CONSTITUTION, I_constitution);
	int I_beastiality	= max(0, (g_Dice % skill) - 2);		g_Girls.UpdateSkill(girl, SKILL_BEASTIALITY, I_beastiality);
	int I_agility		= max(0, (g_Dice % skill) - 2);		g_Girls.UpdateStat(girl, STAT_AGILITY, I_agility);
	int I_magic			= max(0, (g_Dice % skill) - 2);		g_Girls.UpdateSkill(girl, SKILL_MAGIC, I_magic);

	// Update Enjoyment
	g_Girls.UpdateEnjoyment(girl, actiontype, enjoy);

	// Gain Traits
	g_Girls.PossiblyGainNewTrait(girl, "Tough", 30, actiontype, "She has become pretty Tough from all of the fights she's been in.", Day0Night1);
	g_Girls.PossiblyGainNewTrait(girl, "Adventurer", 40, actiontype, "She has been in enough tough spots to consider herself Adventurer.", Day0Night1);
	g_Girls.PossiblyGainNewTrait(girl, "Aggressive", 60, actiontype, "She is getting rather Aggressive from her enjoyment of combat.", Day0Night1);
	if (g_Dice.percent(25) && g_Girls.GetStat(girl, STAT_STRENGTH) >= 60 && g_Girls.GetSkill(girl, SKILL_COMBAT) > g_Girls.GetSkill(girl, SKILL_MAGIC))
	{
		g_Girls.PossiblyGainNewTrait(girl, "Strong", 60, ACTION_COMBAT, girlName + " has become pretty Strong from all of the fights she's been in.", Day0Night1);
	}

	//lose traits
	g_Girls.PossiblyLoseExistingTrait(girl, "Fragile", 15, actiontype, girl->m_Realname + " has had to heal from so many injuries you can't say she is fragile anymore.", Day0Night1);

	if (cfg.debug.log_show_numbers())
	{
		ss << "\n\nNumbers:"
			<< "\n Wages = " << (int)wages
			<< "\n Tips = " << (int)tips
			<< "\n Xp = " << I_xp
			<< "\n Libido = " << I_libido
			<< "\n combat = " << I_combat
			<< "\n animalh = " << I_animalh
			<< "\n strength = " << I_strength
			<< "\n constitution = " << I_constitution
			<< "\n beastiality = " << I_beastiality
			<< "\n agility = " << I_agility
			<< "\n magic = " << I_magic
			<< "\n Tiredness = " << tired
			<< "\n Enjoy " << girl->enjoy_jobs[actiontype] << " = " << enjoy
			;

	}

	girl->m_Events.AddMessage(ss.str(), imagetype, msgtype);

#pragma endregion
	return false;
}