1. We have added a Gift Upgrades feature that allows you to gift an account upgrade to another member, just in time for the holiday season. You can see the gift option when going to the Account Upgrades screen, or on any user profile screen.
    Dismiss Notice

C++/Lua Request Thread

Discussion in 'Civ5 - SDK / LUA' started by Nefliqus, Jun 11, 2012.

  1. Nefliqus

    Nefliqus Chieftain

    Joined:
    Sep 16, 2010
    Messages:
    400
    Location:
    Poland
    - Capability to add new CityState player after game start, like Game.AddPlayer()
     
  2. bc1

    bc1

    Joined:
    Jan 12, 2004
    Messages:
    1,209
    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.
     
  3. isnorden

    isnorden Amnesiac Modder

    Joined:
    Jul 6, 2012
    Messages:
    608
    Location:
    Madison, Wisconsin, USA
    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).
     
  4. isnorden

    isnorden Amnesiac Modder

    Joined:
    Jul 6, 2012
    Messages:
    608
    Location:
    Madison, Wisconsin, USA
    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?
     
  5. TheMarshmallowBear

    TheMarshmallowBear Benelovent Chieftain of the BearKingdom

    Joined:
    Dec 27, 2006
    Messages:
    7,264
    Location:
    Inside an Ikanda.
    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).
     
  6. Gedemon

    Gedemon Modder Moderator

    Joined:
    Oct 4, 2004
    Messages:
    8,643
    Location:
    France
    You can post request for Lua/C++ component here.
     
  7. Pazyryk

    Pazyryk Chieftain

    Joined:
    Jun 13, 2008
    Messages:
    3,584
    Civilians can violate 1upt (with each other) and can pass through other civ's units rather than having to route around them.
     
  8. trystero49

    trystero49 Chieftain

    Joined:
    Apr 30, 2012
    Messages:
    515
    Civilizations choose a random Religion to found, instead of their default.

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

    Drawmeus Chieftain

    Joined:
    Jul 25, 2007
    Messages:
    1,213
    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 >.>
     
  10. whoward69

    whoward69 DLL Minion

    Joined:
    May 30, 2011
    Messages:
    8,342
    Location:
    Near Portsmouth, UK
    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.
     
  11. Drawmeus

    Drawmeus Chieftain

    Joined:
    Jul 25, 2007
    Messages:
    1,213
    Oh damn. You're right. How embarrassing.

    I'll build something in a little while.
     
  12. whoward69

    whoward69 DLL Minion

    Joined:
    May 30, 2011
    Messages:
    8,342
    Location:
    Near Portsmouth, UK
    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;
    }
    
     
  13. Pazyryk

    Pazyryk Chieftain

    Joined:
    Jun 13, 2008
    Messages:
    3,584
    No need for dll. Just randomize preferred religion in SQL. PowelS has an example of random table order for city names here.
     
  14. whoward69

    whoward69 DLL Minion

    Joined:
    May 30, 2011
    Messages:
    8,342
    Location:
    Near Portsmouth, UK
    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!
     
  15. Airny

    Airny Chieftain

    Joined:
    Aug 6, 2006
    Messages:
    297
    Location:
    Germany
    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.
     
  16. Drawmeus

    Drawmeus Chieftain

    Joined:
    Jul 25, 2007
    Messages:
    1,213
    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.
     
  17. trystero49

    trystero49 Chieftain

    Joined:
    Apr 30, 2012
    Messages:
    515
    Thanks for help with randomized religion!
     
  18. Leugi

    Leugi Supreme Libertador

    Joined:
    Jan 25, 2013
    Messages:
    1,673
    Location:
    Bolivia
    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...
     
  19. Irkalla

    Irkalla ENTP POWWWEEEEEER

    Joined:
    Sep 25, 2012
    Messages:
    1,009
    Location:
    Way down around Vicksburg
    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?
     
  20. MDAgent

    MDAgent Chieftain

    Joined:
    Feb 6, 2013
    Messages:
    1
    I want to add to civilopedia for Great People, like...
    Great Artist
    Homer
    thespis
    ...
    Great scientist
    Merit ptah
    Xi ling shi
    ...
     

Share This Page