Is it possible to create specialists who give a % bonus instead of a numberical one?

Can you tell us more ? What have you done in the sdk ? We can tell you what is the error, but we need somthing, like a code, or something else.
 
OK, I am very new to the whole concept of modding so I may be missing something silly, but this is what I have in mind. Take, for example, the default XML code for the Citizen:


<SpecialistInfos>
<SpecialistInfo>
<Type>SPECIALIST_CITIZEN</Type>
<Description>TXT_KEY_SPECIALIST_CITIZEN</Description>
<Civilopedia>TXT_KEY_CONCEPT_SPECIALISTS_PEDIA</Civilopedia>
<Strategy>TXT_KEY_SPECIALIST_CITIZEN_STRATEGY</Strategy>
<Help/>
<Texture>Art/Interface/MainScreen/CityScreen/Citizen.dds</Texture>
<bVisible>1</bVisible>
<GreatPeopleUnitClass>NONE</GreatPeopleUnitClass>
<iGreatPeopleRateChange>0</iGreatPeopleRateChange>
<Yields>
<iYield>0</iYield>
<iYield>1</iYield>
<iYield>0</iYield>
</Yields>
<Commerces/>
<iExperience>0</iExperience>
<Flavors/>
<HotKey/>
<bAltDown>0</bAltDown>
<bShiftDown>0</bShiftDown>
<bCtrlDown>0</bCtrlDown>
<iHotKeyPriority>0</iHotKeyPriority>
<Button>Art/Interface/MainScreen/CityScreen/Citizen.dds</Button>
</SpecialistInfo>

I cannot seem to get the game to work if I substiture a modifier for the yield bonus (say, to give the citizen a 5% production bonus instead of a flat rate of 1 shield:


<SpecialistInfo>
<Type>SPECIALIST_CITIZEN</Type>
<Description>TXT_KEY_SPECIALIST_CITIZEN</Description>
<Civilopedia>TXT_KEY_CONCEPT_SPECIALISTS_PEDIA</Civilopedia>
<Strategy>TXT_KEY_SPECIALIST_CITIZEN_STRATEGY</Strategy>
<Help/>
<Texture>Art/Interface/MainScreen/CityScreen/Citizen.dds</Texture>
<bVisible>1</bVisible>
<GreatPeopleUnitClass>NONE</GreatPeopleUnitClass>
<iGreatPeopleRateChange>0</iGreatPeopleRateChange>
<YieldModifiers>
<iYield>0</iYield>
<iYield>5</iYield>
<iYield>0</iYield>
</YieldModifiers>
<Commerces/>
<iExperience>0</iExperience>
<Flavors/>
<HotKey/>
<bAltDown>0</bAltDown>
<bShiftDown>0</bShiftDown>
<bCtrlDown>0</bCtrlDown>
<iHotKeyPriority>0</iHotKeyPriority>
<Button>Art/Interface/MainScreen/CityScreen/Citizen.dds</Button>
</SpecialistInfo>

The idea I have in mind is to create workers that would "work" improvements such as factories, instead of the factories themselves providing the bonus.

Is there any way to make that work?
 
You cant arbitrarily use new XML tags, it violates the Schema (look at the top of each XML file to see what its schema is, its usaly in the same folder).

Even IF you modify the Schema to allow your new tag the game will simply pass over it when loading as the SDK specificaly loads each tag by name. SDK moding is required to make a new tag load into the game, additional code is needed to make it show up in the Pedia and yet more code to make it actualy have some kind of effect.
 
If you would like, I am happy to try and get you started.

First, you want to add <YieldModifier/> and <CommerceModifier/> as new XML tags but-as Impaler said, this won't do anything by itself!
Next, go into CvInfos.cpp and CvInfos.h, and find the section headed CvSpecialists in the .cpp file.
Next, find this section of the code:

Code:
CvSpecialistInfo::CvSpecialistInfo() :
m_iGreatPeopleUnitClass(NO_UNITCLASS),
m_iGreatPeopleRateChange(0),
m_iMissionType(NO_MISSION),
m_bVisible(false),
[B]m_piYieldChange(NULL),
m_piCommerceChange(NULL),[/B]
m_piFlavorValue(NULL)

Now, just after the bolded section, add the next 2 lines of code:
Code:
m_piYieldModifier(NULL),
m_piCommerceModifier(NULL),

Right below this section, you will find THIS code:
Code:
SAFE_DELETE_ARRAY(m_piYieldChange);
	SAFE_DELETE_ARRAY(m_piCommerceChange);
	SAFE_DELETE_ARRAY(m_piFlavorValue);
Now after piCommerceChange, add:

Code:
SAFE_DELETE_ARRAY(m_piYieldModifier);
SAFE_DELETE_ARRAY(m_piCommerceModifier);

Now, under the section headed //Arrays, add in the following code:

Code:
int CvSpecialistInfo::getYieldModifier(int i) const
{
	FAssertMsg(i < NUM_YIELD_TYPES, "Index out of bounds");
	FAssertMsg(i > -1, "Index out of bounds");
	return m_piYieldChange ? m_piYieldModifier[i] : -1;
}

const int* CvSpecialistInfo::getYieldModifierArray() const
{
	return m_piYieldModifier;
}

Next, do exactly the same thing with Commerce.

The next place you want to add code is under the // read from XML heading, where you want to add this:

Code:
if (gDLL->getXMLIFace()->SetToChildByTagName(pXML->GetXML(),"YieldModifier"))
	{
		pXML->SetYields(&m_piYieldModifier);
		gDLL->getXMLIFace()->SetToParent(pXML->GetXML());
	}
	else
	{
		pXML->InitList(&m_piYieldModifier, NUM_YIELD_TYPES);
	}

Again, do the exact same thing for commerce.
At this point, you are finished with the .cpp file (I hope ;) ).

You then go into CvInfos.h file. Again, under CvSpecialistInfo, you want to add the following code, under //Arrays:

Code:
	DllExport int getYieldModifier(int i) const;		
	DllExport const int* getYieldModifierArray() const;
	DllExport int getCommerceModifier(int i) const;		
	DllExport const int* getCommerceModifierArray() const;

Then, under the second //Arrays heading, add:

Code:
int* m_piYieldModifier;
	int* m_piCommerceModifier;

Lastly, compile these 2 files and let us know-then either myself, or one of the other much more talented modders here ;), will let you know how to procede.

Definitely lastly, if this is all too much for you, then I sugges you visit THIS thread:

http://forums.civfanatics.com/showthread.php?t=166935

I found it a huge help, and this guy SERIOUSLY knows what he is talking about :)! Hope this has all been helpful to you.

Aussie_Lurker.
 
This suddenly makes me think... are the bonuses the specialists give added on top of the current stats for the city after the buildings and such are factored in? Or are they added to the baseline output and then the buildings are factored?
 
Thanks for the tips to both Impaler and Lurker... it's been awhile since I've taken a computer programming course so I have a bit of homework to do but I think it will be worth it.
 
Back
Top Bottom