new girl on the block

Lady Wandbender

Chieftain
Joined
May 4, 2008
Messages
51
Location
atlanta ga
Hi everybody, a friend had me play this mod during a get together at his house, three days later I went home with my first huge-map win. It is the best I've played since civ2, including the commercial releases.

I am a tweaker and ussualy just pay people to do the code work for me, but this time the guy who said he could do it, couldn't. The things he couldn't fix I either found work arounds for or put on my wish list for later. The below code though is bugging me since it's something I really want but can't find a work around for it, just poor choice comprimises. So I thought I'd come here and hope someone could tell me what to do to fix it, or tell me how else it can be done.

It's supposed to let the presence of an unit add to the city's production without joing the city as a citizen.

if city.isHasunit(gc.getInfoTypeForString('Unit_Builder')):
if city.getNumRealBuilding(gc.getInfoTypeForString('BUILDING_MANA_FACTORY')) > 0:
city.changeProduction(1)


in the orignal code there is no space in the Unit_Builder, I don't know why it listed it as such here. and both the Unit and building are accuately (and working) in the game
 
Try this...

Code:
if pCity.getNumRealBuilding(gc.getInfoTypeForString('BUILDING_MANA_FACTORY')) > 0:	# if we have a Mana Factory
	for iI in pCity.getPlot().getNumUnits() 					# count how many units we have in the city and iterate
		pUnit = getUnit(iI)							# get a CyUnit so we can check the type
		if pUnit.getType() == gc.getInfoTypeForString('UNIT_BUILDER')		# if it's the right type
			 pCity.changeProduction(1)					# add one to the production total

The problem is with city.isHasUnit() - there's no such animal. You need to get the city plot, get the number of units on that plot and then check them one by one to see if you've got a UNIT_BUILDER.

I've assumed that you want production increased by one for *each* UNIT_BUILDER - not just if there's one there at all.
 
Wow ur first post :)

Welcome to the FfH forums. The best mod in town lol :D

Wish I could help you with the code, but my programming experience doesn't involve python, C++ or anything used in civ.

You've picked the right mod to play! Congrats on ur first "huge" win... time to up the difficulty ;)

Al
 
thank you so much vehem for taking the time to even try, but it didn't work, I'll go and check just to make sure there are no typo's in my xml. I really do appriciate the effort, just I think I'm going to have to live without my idea.

rats.

And the game was on Monarch setting with normal speed. I got whipped back down to one city on my first day, then learned enough about the magic system to start taking people apart.

Oh, and thank you for the welcome Alzrara.
 
Hehe no problem. Always happy to welcome people to the fold ;)

I tend to play prince nowadays (upped my difficulty from noble). I always play epic speed though :)

Depending on how powerful your machine is, I would reccommend Planet Generator 0.68. It's an awesome map script :)

Enjoy FfH :D

Al
 
You could add a spell to that unit that adds a building to the city as long as the caster is in the city that adds one hammer.
 
Thank you Farmer, I'm about to test it now. It's not exactly what I wanted to do, which was to have a "flying (mobile)" company of crafters as national units to help out in those cities which are too small, too fertile or too barren to ever really amount to much and at least get them where they can contribute something. I thought 1 hammer per was on par with citizens, but with the advantage they could be moved from town to town.

And your idea will do exactly the same thing without the added headache of multiple units in a city taking up space, so it might turn out I like how it works much better.
 
Little offtopic while we are by mod-moding:

In a previous civilisations[cant remember with one] there was an upgrade of the settlers. Why haven't anyone implemented it here? A unit that would replace a settler, probably late in the game [guilds? tech that grands republic?], same cost and functionality[move +1] but the city it spawns gets a free granary, herbalist and a palisade [+lighthouse if coastal].
 
thank you so much vehem for taking the time to even try, but it didn't work, I'll go and check just to make sure there are no typo's in my xml. I really do appriciate the effort, just I think I'm going to have to live without my idea.

What was the problem? Admittedly Farmer's idea will probably be easier in the end, but as far as I can tell the code probably should have done what was needed (and I do hate it when code is misbehaving :D)

EDIT: Just noticed that I used "pCity" whilst you used "city" - different naming conventions, which if you hadn't changed pCity to match the rest of your code, it would probably stop it working.
 
Maybe these tweaks on Vehem's code would work better:

Code:
if pCity.getNumBuilding(gc.getInfoTypeForString('BUILDING_MANA_FACTORY')) > 0:
	iBuilder = gc.getInfoTypeForString('UNIT_BUILDER')
	for iI in range (pPlot.getNumUnits()):
		pUnit = pPlot.getUnit(iI)
		if pUnit.getUnitType() == iBuilder:
			 pCity.changeProduction(1)

Im assuming this code is going in onCityDoTurn in CvEventManager.py, in which case you don't need to define either pCity or pPlot.
 
Maybe these tweaks on Vehem's code would work better:

Code:
if city.getNumBuilding(gc.getInfoTypeForString('BUILDING_MANA_FACTORY')) > 0:
	pPlot = city.getPlot()
	iBuilder = gc.getInfoTypeForString('UNIT_BUILDER')
	for iI in range (pPlot.getNumUnits()):
		pUnit = pPlot.getUnit(iI)
		if pUnit.getUnitType() == iBuilder:
			 city.changeProduction(1)


Thanks - I missed "range" (D'oh!). Been doing too many iterate-over-lists lately methinks...
 
This is why I date plumbers and engineers, not professionals.

Give a problem to an engineer and he'll fix it, he might take three or four stabs at it, but he will get the dang thing to work. Doctors and lawyers will just look at you and shrug then say "oops". OOPS?!?!? I have half a legion out in the world hanging by a thread and they give me OOPS!!!!!

Thank you so much guys, I figured it was something like that but computer programming is something that happens to other people as far as I'm concerned, (though I am learning and teaching myself, I "fixed" several of the things I paid for that weren't working by looking at how else it was done elsewhere)

And yes I know that engineers are professionals too, I um, forgot, the sun was in my eyes, the dog ate my breifs, there was a flood..a terrible hurricane, locusts!!!!!!!!!!!!!!!! I have to so never watch the Blues Brothers ever again.
 
This is why I date plumbers and engineers, not professionals.

Give a problem to an engineer and he'll fix it, he might take three or four stabs at it, but he will get the dang thing to work. Doctors and lawyers will just look at you and shrug then say "oops". OOPS?!?!? I have half a legion out in the world hanging by a thread and they give me OOPS!!!!!

Thank you so much guys, I figured it was something like that but computer programming is something that happens to other people as far as I'm concerned, (though I am learning and teaching myself, I "fixed" several of the things I paid for that weren't working by looking at how else it was done elsewhere)

And yes I know that engineers are professionals too, I um, forgot, the sun was in my eyes, the dog ate my breifs, there was a flood..a terrible hurricane, locusts!!!!!!!!!!!!!!!! I have to so never watch the Blues Brothers ever again.

What a peculiar dating criteria :rolleyes:

Al
 
IT'S A TRAP! THE SKUM TRIED TO KNIFE ME! KILL HIM! (sorry in joke... bit of a waste of a post :p)

Al
 
It is common knowledge that there are no women on the internet.

oh don't be stupid, of course there are women on the internet, old fat chicks playing WoW mostly, as allaince. And in chat rooms telling everybody how to behave. I was going to put up a <semi> hot pic but the only avatars you can use are from the civ games.

and the code didn't work, oh well, Farmer's work around is just as good and I really thank everybody who gave tips and advice and took the time to rehash the code over and over.
*this is not me complaining or begging for more help, this is me warning others so they don't use the code and spending the game time to learn it was blizzardcraft and 'working as intended' (which is not at all) :) :) :)
 
Back
Top Bottom