Please Help with my Mod

MarzipanStan

Chieftain
Joined
Jul 30, 2016
Messages
9
Hey all, this was at one time a comment on a different thread, because I didn't understand how to make a new thread and assumed that you had to have a certain number of posts to do that. I'm trying to make a mod to add Tarzan (leading the Mangani), and I'm struggling. Everybody gets a lil cred for helping! Because I really couldn't do this alone just yet.

Things that need work:

UA: "Lord of the Jungle"
- Gain a percentage of the other civ's Science during a Declaration of Friendship
- Farms and Plantations don't remove Jungle
 
Aha! I have learned how to post a new thread. Here is my spiel:

I'm new to modding, new to coding, and have overstuffed myself and burned my eyes on tutorials and guides. I've been troubleshooting this thing for the whole time that I've been working on it. At first the text strings came through, but the icon didn't, and then the icon did, but the text strings didn't. Then, when I got both the icon and text strings working, I tried to add a leader icon, and it stopped appearing entirely in any game setup screen. I backtracked on that, but it seems it's too late now.

I've tried to plug in dummy unique buildings, I've tried adding functioning unique buildings, I've checked the txt keys, I've plugged in a dummy trait, I've added a functioning trait, I've done all the VFS and UpdateDatabase things, and at this point I am at a loss. Would some gentle folk be willing to check my code for whatever catastrophic errors there seem to be?

Moderator Action: Moved this to the main C&C forum as that is where questions belong. Please use this thread and do not spam your request around the C&C forum. Thanks.
 

Attachments

  1. See whoward69's enable error logging tutorial
    You have fatal syntax errors in at least one file. These errors in xml files will be reported in the Database.log file.
  2. You have no <Row>--</Row>:
    Code:
    	<Building_FreeSpecialistCounts>
    		<BuildingType>BUILDING_EXPEDITION_CAMP</BuildingType>
    		<SpecialistType>SPECIALIST_SCIENTIST</SpecialistType>
    		<Count>1</Count>
    	</Building_FreeSpecialistCounts>
    This error is fatal to the entire contents of the xml-file where it occurs.
  3. All these files are just extra deadwieght files in the mod, especially if you intend to upload to Steam or elsewhere:
    Code:
        <File md5="25E149991B94B7A24157268EF64FD9BB" import="0">Reference Files/CIV5Buildings.xml</File>
        <File md5="67AEAD5A199E6DDA67E62AF9B26143AA" import="0">Reference Files/CIV5Buildings_Expansion2.xml</File>
        <File md5="FABC9E2E744F02EBB9E6AEDFD3F7801D" import="0">Reference Files/CIV5Buildings_Inherited_Expansion2.xml</File>
        <File md5="B82BCAA382DA2453B962530046F1EA92" import="0">Reference Files/CIV5Leader_Alexander.xml</File>
        <File md5="978FC28349E714579970DCB922A45D5A" import="0">Reference Files/CIV5Leader_Alexander_Expansion2.xml</File>
        <File md5="BE7FD46DDDDC49D1E148A89C778B9F30" import="0">Reference Files/CIV5Traits.xml</File>
        <File md5="22C17D588C3FE0D8D15A04781F7E3BFC" import="0">Reference Files/CIV5Traits_Expansion2.xml</File>
        <File md5="7DF759CCBFFCD591F1A793DA5596C637" import="0">Reference Files/CIV5Traits_Inherited_Expansion2.xml</File>
        <File md5="3853C577E526E1EDCB78F877781151D4" import="0">Reference Files/Civilizations.sql</File>
        <File md5="727D3A3B3F23A42D5D2AA4CD89AAADBC" import="0">Reference Files/DummyBuildings.xml</File>
        <File md5="ED8ABF76B721E0AD74A031F731A5A3AA" import="0">Reference Files/Leaderhead.sql</File>
        <File md5="C65AAA0C7131A002CA12AEEED9441AA0" import="0">Reference Files/Traits.sql</File>
    Copy these files into a folder somewhere directly in your computer's "Documents" folder, and then delete these files from the mod.
  4. Eliminate the <ID> line entirely from here:
    Code:
    	<Leaders>
    		<Row>
    			[color="red"]<ID>0</ID>[/color]
    			<Type>LEADER_TARZAN</Type>
    • As a general rule you never want to state an <ID> within a mod except if the mod is a total conversion mod and you are first deleting the entire contents of a game-table before rebuilding said entire contents.
    • The Game already has a leader whose ID # is '0', so will not allow you to attempt to state that some other leader will now have ID # '0'. The game discards the entire contents of the xml-file where this attempt occurs.
  5. This
    Code:
    <GameData>
    	<Traits>
    		<Row>
    			<Type>[color="red"]TRAIT_LORD_OF_THE_JUNGLE[/color]</Type>
    			<Description>TXT_KEY_TRAIT_LORD_OF_THE_JUNGLE_DESC</Description>
    			<ShortDescription>TXT_KEY_TRAIT_LORD_OF_THE_JUNGLE_SHORT</ShortDescription>
    		</Row>
    	</Traits>
    </GameData>
    does not match to this
    Code:
    	<Leader_Traits>
    		<Row>
    			<LeaderType>LEADER_TARZAN</LeaderType>
    			<TraitType>[color="red"]LORD_OF_THE_JUNGLE[/color]</TraitType>
    		</Row>
    	</Leader_Traits>
  6. Neither does the trait as defined here actually do anything:
    Code:
    <GameData>
    	<Traits>
    		<Row>
    			<Type>TRAIT_LORD_OF_THE_JUNGLE</Type>
    			<Description>TXT_KEY_TRAIT_LORD_OF_THE_JUNGLE_DESC</Description>
    			<ShortDescription>TXT_KEY_TRAIT_LORD_OF_THE_JUNGLE_SHORT</ShortDescription>
    		</Row>
    	</Traits>
    </GameData>
 
Whoa! That was awesome! Thanks for taking a look LeeS; I'll test those changes right away
 
Following up - how would one go about giving a civ a science boost for the duration of a DoF? At the moment we have a dummy building that yields 1 science (BUILDING_FRIENDLY_SCIENCE), and the following Lua written:
Code:
GameEvents.PlayerDoTurn.Add(
function(iPlayer)
	local fPercentage = 0.1;
	local pPlayer = Players[iPlayer];
	if (pPlayer:IsEverAlive()) then
		if (pPlayer:GetCivilizationType() == GameInfoTypes.CIVILIZATION_MANGANI) then
			local iTotalNewScience = 0;
			local pCapital = pPlayer:GetCapitalCity();
			for otherPlayerID, otherPlayer in pairs(Players) do	
				if otherPlayer:IsEverAlive() and otherPlayer ~= player and not otherPlayer:IsMinorCiv() then
					if pPlayer:IsDoF(otherPlayer) then
						local iNewScience = otherPlayer:GetScience() * fPercentage;
						iTotalNewScience += iNewScience;
					end
				end
			end
			pCapital:SetNumRealBuilding(GameInfoTypes.BUILDING_FRIENDLY_SCIENCE, iTotalNewScience);
		end
	end
)

But it doesn't seem to do anything. It's not a matter of scale; I've tested it with local fPercentage = 1000
 
If you sprinkle some print()'s into your code you'll see that the calculation of the percentage of science never executes, this is because IsDoF() takes a player ID, not a player object, so it should be

if pPlayer:IsDoF(otherPlayerID) then
 
Erm... no dice. Could it be that "local iTotalNewScience = 0" is sabotaging "local iNewScience = otherPlayer:GetScience() * fPercentage" if "pCapital:SetNumRealBuilding(GameInfoTypes.BUILDING_FRIENDLY_SCIENCE, iTotalNewScience)" happens after the chunk that "local iNewScience = otherPlayer:GetScience() * fPercentage" is in ends?
 
Code:
iTotalNewScience += iNewScience;
Is an lua syntax error. You want:
Code:
iTotalNewScience = iTotalNewScience + iNewScience
And you don't even need "iNewScience" as you have written the rest of the code. You could do the calculation directly as:
Code:
iTotalNewScience = iTotalNewScience + (otherPlayer:GetScience() * fPercentage)
But you really ought to also either "floor" or "ceiling" the end result for "iTotalNewScience" before using it as the integer value for how many copies of the building to add to the capital city.
 
What do you mean by floor or ceiling? I barely understand Lua and my partner in this is away for a bit
 
Is this at all what everyone's trying to get at?

Code:
GameEvents.PlayerDoTurn.Add(
function(iPlayer)
	local fPercentage = 100; --just to make sure I notice if it works
	local pPlayer = Players[iPlayer];
	if (pPlayer:IsEverAlive()) then
		if (pPlayer:GetCivilizationType() == GameInfoTypes.CIVILIZATION_MANGANI) then
			local iTotalNewScience = 0;
			local pCapital = pPlayer:GetCapitalCity();
			for otherPlayerID, otherPlayer in pairs(Players) do	
				if otherPlayer:IsEverAlive() and otherPlayer ~= player and not otherPlayer:IsMinorCiv() then
					if pPlayer:IsDoF(otherPlayerID) then
						--local iNewScience = otherPlayer:GetScience() * fPercentage;
						iTotalNewScience = math.floor(iTotalNewScience + (otherPlayer:GetScience() * fPercentage));
					end
				end
				pCapital:SetNumRealBuilding(GameInfoTypes.BUILDING_FRIENDLY_SCIENCE, iTotalNewScience);						
			end			
		end
	end
)

I'm afraid it's sill not working, so either I'm taking your advice in the wrong directions or we haven't cracked this yet
 
Back
Top Bottom