C++/Lua Request Thread

A key shortcoming seems to be the lack of ability to intercept important events before they complete in order to alter their outcome:
- city conquest
- unit attacks
- unit kills
- AI unit move / pathfinding
Another one is the lack of ability to know which tiles belong to which city (and map which resources are tied to which city), since this makes it impossible for a script to determine which cities are most worth conquering.
 
I'd like to see religious victories added as an official option...defined as the majority of cities/city-states following the player's religion. Exactly how big that majority should be, would depend on difficulty level (say, 55% at Settler and 95% at Deity, with the levels in-between set by the coder).
 
I don't know whether DLL modding falls under this topic, but...I've been trying to figure out how to base a promotion (usable by just one unit) based on a hard-coded trait bonus (the "FightWellDamaged" ability associated with Japan in the core game). I've got zero knowledge of C++ and no way to open/examine the game files directly. Could one of the experienced DLL modders give me some starting pointers, please?
 
One thing that I would really, really like is the implementation of advanced diplomacy for multiplayer games (and while we'll wait for a proper Multiplayer Mod, I'm sure I could survive the advanced settings one, especially since it could be upgraded as well). These requests are primarily ones that would enhance my Hotseat experience with myself, and for those, who enjoy not only playing to win, but also role-playing as their individual nations.

Anyways, here's a list of things I wanna see
- Ability to Denounce and Declare Friendship in the same way as you can do it onto other AI players (so far, this is nothing more than trading option with only DoF working).
- Ability to set attitudes toward other nations (Guarded, Afraid, Friendly etc.)
-- Ability to set custom and default diplomatic modifiers.

If the above would be implemented, additional features would be even coller
- Ability to send messages via leaderscreens (which would include the loading of screens, as well as choosing messages and writing it down, which would include the ability to taunt other players, or thank them for various deeds, as AI can, from complementing them on adopting specific policies, to taunting them on their barbarians ways of poor culture.
-- Like above, the overall idea that Leaderscreens be activated during primarily Hotseat games, but LAN/Internet can also have those options.

- Bug fixes : Enabling certain pop-ups from not appearing, these include the entrance to eras, the founding of religions and pantheons, notifications of Decleration of Friendships, and the changes in alliances between players and City States

THE OVERALL REQUEST is this
- Enhance the Diplomatic Experience/Features between Human players in Hotseat and Internet/LAN games (Multiplayer games).
 
You can post request for Lua/C++ component here.
 
Civilians can violate 1upt (with each other) and can pass through other civ's units rather than having to route around them.
 
Civilizations choose a random Religion to found, instead of their default.

Removing defaults does not work, because they just choose in alpha-order.

You're compiling your own DLL, right?

In CvReligionClasses.cpp, change CvGameReligions::GetReligionToFound to the following:
Spoiler :
Code:
ReligionTypes CvGameReligions::GetReligionToFound(PlayerTypes ePlayer)
{
	ReligionTypes eCivReligion;
/*	eCivReligion = GET_PLAYER(ePlayer).getCivilizationInfo().GetReligion();
	if(!HasBeenFounded(eCivReligion))
	{
		CvReligionEntry* pEntry = GC.getReligionInfo(eCivReligion);
		if(pEntry)
		{
			return eCivReligion;
		}
	}*/

	// Need to "borrow" from another civ.  Loop through all religions looking for one that is eligible
	for(int iI = 0; iI < GC.getNumReligionInfos(); iI++)
	{
		ReligionTypes eReligion = (ReligionTypes)iI;
		CvReligionEntry* pEntry = GC.getReligionInfo(eReligion);
		if(!pEntry)
		{
			continue;
		}

		if(pEntry->GetID() == RELIGION_PANTHEON)
		{
			continue;
		}

		if(HasBeenFounded((ReligionTypes)pEntry->GetID()))
		{
			continue;
		}

		if(IsPreferredByCivInGame(eReligion))
		{
			continue;
		}

		return (eReligion);
	}

	// Will have to use a religion that someone else prefers
	for(int iI = 0; iI < GC.getNumReligionInfos(); iI++)
	{
		ReligionTypes eReligion = (ReligionTypes)iI;
		CvReligionEntry* pEntry = GC.getReligionInfo(eReligion);
		if(!pEntry)
		{
			continue;
		}

		if(pEntry->GetID() == RELIGION_PANTHEON)
		{
			continue;
		}

		if(HasBeenFounded((ReligionTypes)pEntry->GetID()))
		{
			continue;
		}

		return (eReligion);
	}

	return NO_RELIGION;
}

I haven't tested it, but that's the spot where the game does that particular magic. A more robust solution would probably be to allow you to enter NO_RELIGION into the field, but that'd be more complicated and I'd feel obligated to test a solution before I sent it over to you >.>
 
That will just remove the preferred religion check in C++ (which will have the same effect as removing the default religion from the XML) - ie you'll get the first alphabetical religion

To get a random choice you need to do that and also build a list of all possible religions and then pick one randomly.
 
That will just remove the preferred religion check in C++ (which will have the same effect as removing the default religion from the XML) - ie you'll get the first alphabetical religion

To get a random choice you need to do that and also build a list of all possible religions and then pick one randomly.

Oh damn. You're right. How embarrassing.

I'll build something in a little while.
 
Untested ... coming to a DLL mod soon (ie when someone has tested it!)

Code:
// Removes religion preference
#define MOD_RELIGION_NO_PREFERRENCES        (true)
// Randomises religion choice (if preferred religion unavailable)
#define MOD_RELIGION_RANDOMISE              (true)

Code:
/// Get the appropriate religion for this player to found next
ReligionTypes CvGameReligions::GetReligionToFound(PlayerTypes ePlayer)
{
#if defined(MOD_RELIGION_NO_PREFERRENCES)
	if (!MOD_RELIGION_NO_PREFERRENCES) {
		// Choose the civs preferred religion if not disabled and available
#endif
		ReligionTypes eCivReligion;
		eCivReligion = GET_PLAYER(ePlayer).getCivilizationInfo().GetReligion();
		if(!HasBeenFounded(eCivReligion))
		{
			CvReligionEntry* pEntry = GC.getReligionInfo(eCivReligion);
			if(pEntry)
			{
				return eCivReligion;
			}
		}
#if defined(MOD_RELIGION_NO_PREFERRENCES)
	}
#endif

#if defined(MOD_RELIGION_RANDOMISE)
	// No preferred religion, so find all the possible religions
	std::vector<ReligionTypes> availableReligions;
#endif
	
	// Need to "borrow" from another civ.  Loop through all religions looking for one that is eligible
	for(int iI = 0; iI < GC.getNumReligionInfos(); iI++)
	{
		ReligionTypes eReligion = (ReligionTypes)iI;
		CvReligionEntry* pEntry = GC.getReligionInfo(eReligion);
		if(!pEntry)
		{
			continue;
		}

		if(pEntry->GetID() == RELIGION_PANTHEON)
		{
			continue;
		}

		if(HasBeenFounded((ReligionTypes)pEntry->GetID()))
		{
			continue;
		}

#if defined(MOD_RELIGION_NO_PREFERRENCES)
		// Only excluded religions preferred by other civs if not disabled
		if (!MOD_RELIGION_NO_PREFERRENCES) {
#endif
			if(IsPreferredByCivInGame(eReligion))
			{
				continue;
			}
#if defined(MOD_RELIGION_NO_PREFERRENCES)
		}
#endif

#if defined(MOD_RELIGION_RANDOMISE)
		if (MOD_RELIGION_RANDOMISE) {
			// If we want a random religion, remember this as a possible candidate ...
			availableReligions.push_back(eReligion);
		} else {
			// ... otherwise just return it
#endif
			return (eReligion);
#if defined(MOD_RELIGION_RANDOMISE)
		}
#endif
	}

#if defined(MOD_RELIGION_RANDOMISE)
	if (availableReligions.empty()) {
#endif

		// Will have to use a religion that someone else prefers
		for(int iI = 0; iI < GC.getNumReligionInfos(); iI++)
		{
			ReligionTypes eReligion = (ReligionTypes)iI;
			CvReligionEntry* pEntry = GC.getReligionInfo(eReligion);
			if(!pEntry)
			{
				continue;
			}

			if(pEntry->GetID() == RELIGION_PANTHEON)
			{
				continue;
			}

			if(HasBeenFounded((ReligionTypes)pEntry->GetID()))
			{
				continue;
			}

#if defined(MOD_RELIGION_RANDOMISE)
			if (MOD_RELIGION_RANDOMISE) {
				// If we want a random religion, remember this as a possible candidate ...
				availableReligions.push_back(eReligion);
			} else {
				// ... otherwise just return it
#endif
			return (eReligion);
#if defined(MOD_RELIGION_RANDOMISE)
			}
#endif
		}

#if defined(MOD_RELIGION_RANDOMISE)
	}
#endif

#if defined(MOD_RELIGION_RANDOMISE)
	// Pick a random religion
	if (!availableReligions.empty()) {
		int index = 0;
		
		// Pick a random one if required
		if (MOD_RELIGION_RANDOMISE) {
			index = GC.getGame().getJonRandNum(availableReligions.size(), "Random Religion To Found");
		}
		
		return availableReligions[index];
	}
#endif

	return NO_RELIGION;
}
 
Civilizations choose a random Religion to found, instead of their default.

Removing defaults does not work, because they just choose in alpha-order.

No need for dll. Just randomize preferred religion in SQL. PowelS has an example of random table order for city names here.
 
No need for dll. Just randomize preferred religion in SQL. PowelS has an example of random table order for city names here.

Won't work. (Unless there is now some way to update the database after the game has started.)

Including DLC there are 34 possible civilizations, but only 11 religions, and as you don't know which civs are in play until after the game database is effectively read-only, each religion will have 3 candidate civs (one will have 4), which, statistically, will lead to a "random" religion already being in play, so that civ will then get the next alphabetical religion ... which may be good enough, but is not truely random.

EDIT: It may work, but you'll need to delete all the preferred religion entries (Civilization_Religions table) and then randomize the religions in their table (while leaving Pantheon as number 0)

EDIT 2: Try

Code:
-- Create a temp religions table from the standard Pantheon entry
CREATE TABLE Religions_Temp AS
  SELECT *
  FROM Religions
  WHERE Type = 'RELIGION_PANTHEON';

-- Copy the remaining religions to the temp table in a random order  
INSERT INTO Religions_Temp
  SELECT *
  FROM Religions
  WHERE Type != 'RELIGION_PANTHEON'
  ORDER BY RANDOM();

-- Renumber the religions  
UPDATE Religions_Temp
  SET ID = (rowid-1);

-- Copy everything back from the temp table, keeping the same order, and then tidy up after ourselves
DELETE FROM Religions;
INSERT INTO Religions SELECT * FROM Religions_Temp ORDER BY rowid ASC;
DROP TABLE Religions_Temp;

-- Finally delete all the preferred religions
DELETE FROM Civilization_Religions;

EDIT 3: The above SQL doesn't work as it randomises the religions differently every time the game starts - so after a save/load cycle the religions founded by civs will all have changed names!
 
I know that many people were quite annoyed about a missing queue to give to orders to their units, especially workers.
Does anybody know if it is possible by now to implement such thing?

We would need an event trigger, like pressing shift + giving an order, then record the given orders and store them in an array.
If that is possible, the rest is just a question of UI.

I tried to get into lua programming the last 2 days, but I still don't feel qualified to answer my question.
 
I know that many people were quite annoyed about a missing queue to give to orders to their units, especially workers.
Does anybody know if it is possible by now to implement such thing?

We would need an event trigger, like pressing shift + giving an order, then record the given orders and store them in an array.
If that is possible, the rest is just a question of UI.

I tried to get into lua programming the last 2 days, but I still don't feel qualified to answer my question.

I'd say almost definitely possible but potentially a large amount of work in the C++, unless there's a clever Lua way to do it that I haven't thought of.
 
I honestly don't know if this is the right place to request this, but... It would be great if there was a way to assign already existant (or custom too) game music to a completelly custom leader and civ, just so we don't have to replace an existing one to have music ingame...
 
I honestly don't know if this is the right place to request this, but... It would be great if there was a way to assign already existant (or custom too) game music to a completelly custom leader and civ, just so we don't have to replace an existing one to have music ingame...

You aren't the first person that has wanted this. Think about it.

But yeah, no idea why we can't add music to the game. Aliens? Government conspiracy? Zionist plot?
 
I want to add to civilopedia for Great People, like...
Great Artist
Homer
thespis
...
Great scientist
Merit ptah
Xi ling shi
...
 
Top Bottom