SDK Community enhancement project

I'm not sure how much has been put into developing this, but I have an idea for what could be added to this project.

When loading XML files, order is important. For example, the CIV4BonusInfos.xml file is loaded first, then the CIV4ImprovementsInfos.xml file. Thus, anything in the BonusInfos file can not use anything defined in the ImprovementsInfos file, since the function used to search infos (CvXMLLoadUtility::FindInInfoClass) will only be able to successfully find items that have already been read in.

The problem I've run into a few times is wanting to include something in one file of a file that is loaded later. So, unless I'm seriously mistaken and there's an easy way to fix this, I see it as a problem. My idea is this:

Perhaps a mechanism can be devised so that any variables that are set by calling CvXMLLoadUtility::FindInInfoClass are delayed in being set until after everything's been loaded. The actual implementation shouldn't be as hard as making that implementation friendly to users who wish to add new XML infos.

I'd be willing to help out in the coding if there's another interest from others.
 
How often do you plan to release new versions? If it's once a month or so, I don't think backward compatibility is that important for Civ 4. Personally, I don't have multiple games running, thus I can install any update between to games without bothering about backward compatibility.
 
I think once a month is probably about what we are going to achieve.

@ Gerikes
I have not come up against that problem myself yet. Surely you could put the value into CIV4ImprovementsInfos.xml instead?
 
The Great Apple said:
I have not come up against that problem myself yet. Surely you could put the value into CIV4ImprovementsInfos.xml instead?

I could, but it would require me going through all the improvements to find which one is specific to my bonus. On the flip side, I may be able to add a BuildType to the Bonus XML, and then reference that BuildType's Improvement.

But, if I were someone who weren't going to work on the SDK and rather use this package, I could have just done it the way I originally wanted, so that I could do a quick...

gc.getBonusInfo(mineralsID).getImprovementType().
 
Ok, here's an idea I came up with that I think could be useful. Not sure if it's already been mentioned, but thought why not. Basically, I'm able to pretty easily go into the C++ code and add small variables to units (if I wanted each unit to have a variable for magic mana, I could do that). But, people who only know python would have to find another way. I think that allowing an interface similar to CyVariableSystem but allowing for instance-specific variables.

So, for example, if I wanted to add to a unit an integer that allows me to keep track of the number of times a unit moves to an improvement, I could use a list of numbers, one for each unit, in a data structure I create using the unit id as the index. I could also see if someone else could make a mod that does this for me, once again using the unit as an index.

But if this project had something in the SDK, it would be easier if I could just go:

Code:
def onUnitMove(self, argsList):
	'unit move'
	pPlot,pUnit = argsList
	player = PyPlayer(pUnit.getOwner())
	unitInfo = PyInfo.UnitInfo(pUnit.getUnitType())
	
	pUnit.[b]incrCustomIntVar[/b]("STEPPED_ON_CRACK_COUNTER") # Adds one
	if (pUnit.[b]getCustomIntVar[/b]("STEPPED_ON_CRACK_COUNTER") == 5):
		brokeMommasBack(pUnit)
		if (pUnit.[b]getCustomStringVar[/b]("MOMMAS_NAME") == "Hulk" and
		   pUnit.[b]getCustomBoolVar[/b]("BROKE_MOMMAS_BACK_BEFORE")):
			pUnit.kill()
		else:
			pUnit.[b]setCustomIntVar[/b]("STEPPED_ON_CRACK_COUNTER", 0)
			pUnit.[b]setCustomBoolVar[/b]("BROKE_MOMMAS_BACK_BEFORE", True)

The variables can just be maps of various types with the string argument being the key.
 
Gerikes said:
gc.getBonusInfo(mineralsID).getImprovementType().
Aaah - didn't quite see what you meant by this. This might indeed be useful.
Gerikes said:
Ok, here's an idea I came up with that I think could be useful. Not sure if it's already been mentioned, but thought why not. Basically, I'm able to pretty easily go into the C++ code and add small variables to units (if I wanted each unit to have a variable for magic mana, I could do that). But, people who only know python would have to find another way. I think that allowing an interface similar to CyVariableSystem but allowing for instance-specific variables.
The method most commonly used to do this sort of thing in Civ 4 python at the moment is to use an object's script data to store a dictionary of custom data values.

Check out this thread, and this post for an improved version.
 
Just a heads up that we should have a first version out some time next week. We're aiming for Saturday, but it might not happen. I'll probably post more details in a few days.

If anybody wants to sumbit something for the first release then nowish would be a good time.
 
Minor suggestion for a future SDK Enhancement: Expose Feat Types to XML, somehow.
 
Padmewan said:
Minor suggestion for a future SDK Enhancement: Expose Feat Types to XML, somehow.

Feats are used in CvAdvisorUtils.py to perform popups wen certain criteria are met (you make your first archer, your population reaches a certain amount, etc).

What sort of thing would you like to use it for? I suspect that in most cases it may just be better to key the popup off of the specific event, or on a doTurn check than running it through the SDK. But I may be missing the intent.
 
Kael said:
Feats are used in CvAdvisorUtils.py to perform popups wen certain criteria are met (you make your first archer, your population reaches a certain amount, etc).

What sort of thing would you like to use it for? I suspect that in most cases it may just be better to key the popup off of the specific event, or on a doTurn check than running it through the SDK. But I may be missing the intent.
This is where it gets tricky. The ideal implementation would expose the conditions to XML somewhat like this:

bConditionUnitBuilt
bConditionPop
bConditionBonus

UnitType
iPopulation
BonusType

PopupMessage = TXT_KEY_FEAT_ARCHER


Is it worth the hassle of coding into XML? Based on the fact that Firaxis didn't do it, maybe not.

It would also be helpful to have Feats trigger a Python event. Or is that in the code already...

Along similar lines, and I don't think this is an SDK project, I'd like to see the Quests deconstructed and explained. I believe the Tutorial makes use of them (and IIRC is the only one that does so).
 
The only thing that the FeatType enumeration does, aside from offer a good variable name, is keep track for each player whether they've accomplished it. What happens when a feat has been accomplished is is in python. CvAdvisorUtils.py has a python function called endTurnFeats that tests each one. It checks off if a player has a feat accomplished by using CvPlayer::setFeatAccomplished, and then the number of the feat found in the FeatType.

However, without modding the SDK, I don't think that you can use this method. But it shoudn't be too hard for a just-python implementation for new feats, you would have to find another way to keep track of if the feat has been accomplished.
 
I think we're just about ready for some testing, if anybody wants to help.

First release has some bugfixes, some new gameplay optoins, and quite alot of enhanced modding features.
 
If (GridWidth = 200) && (isWrapX), and you call CyMap.plot(201,0), does it return the plot at (0,0) ? If not, should it?
 
No. It returns (-1,-1).

If GridWidth is 200 it means that (199,0) is the last tile BTW. It also should be CyMap().plot(x,y) ;)

IMO it should auto-wrap for both x and y co-ords as you say. It's on my to-do list, but won't be done until I get home. If you want to fix it then be my guest.
 
The Great Apple said:
IMO it should auto-wrap for both x and y co-ords. It's on my to-do list, but won't be done until I get home. If you want to fix it then be my guest.
'Scuse my mistakes. I was asking to see if this was something we want to insert into the community project, or whether it would incourage rampant laziness (or break functions that rely on returning -1, -1 -- don't see how that would be the case, but who knows).
 
If you're still accepting testers, please count me in. I'de like to see what you guys have done so far and see how everything works now :)
 
Padmewan said:
'Scuse my mistakes. I was asking to see if this was something we want to insert into the community project, or whether it would incourage rampant laziness (or break functions that rely on returning -1, -1 -- don't see how that would be the case, but who knows).
I wasn't getting at you - just stating facts :) I don't think it would encourage rampant laziness personally. Most of the times you get it you're scanning plots arount an area - it's very easy to forget X-Y wrapping.

EDIT: Just realised it might not have been clear that I was completely agreeing with the point you made.
 
Back
Top Bottom