Event Cleanup

@Vokarya the issue is the advanced Cargo mod changed units so they can have more than 1 special unit type. You need to pass an index parameter to getSpecialUnitType. So you need to have a for loop over the number of special unit types on a unit.

However to make matters more complicated, Thomas SG (or the people who merged his code) failed to include the getNumSpecialUnitTypes for python, so in fact, it's impossible to implement code now correctly...

I'll add the missing python method that was not exposed from C++.

So roughly the code should look like this:

Code:
	iFighter = gc.getInfoTypeForString("SPECIALUNIT_FIGHTER")
	iNumFighters = 9
	iNumPlayerFighters = 0
	(loopUnit, iter) = player.firstUnit(False)
	while (loopUnit):
		for i in range(0, loopUnit.getNumSpecialUnitTypes()):
			if loopUnit.getSpecialUnitType(i) == iFighter:
				iNumPlayerFighters += 1
		(loopUnit, iter) = player.nextUnit(iter, False)

	if iNumPlayerFighters < iNumFighters:
		return False

Edit: getNumSpecialUnitTypes was added for you in 948, so update and the above code should work.

I thought it would be something like that.

Also, is there an exposed Python function for getting a count of all units of a combat class? I would like the Nuclear Protest event to count all Doomsday units, not just Tactical Nukes and ICBMs. Something like getUnitClassCount, but applied to UNITCOMBATs, not UNITCLASSes. If there isn't, you don't need to make one, but if there is, I would like to know what it is.

I suppose I could also use getNumNukeUnits in this case. I don't know the Python in-depth, but it looks to me like that would work.
 
So you can get the number of all Doomsday units with the existing python API. It's similar to counting all fighters above. You have to loop over all the units a player has, and check if the unit combat type == the Doomsday unit combat. Basically this:

Code:
iDoomsDay = gc.getInfoTypeForString(...)
iCount = 0
(loopUnit, iter) = player.firstUnit(False)
	while (loopUnit):
		if (loopUnit.getUnitCombatType() == iDoomsday):
			iCount += 1
		(loopUnit, iter) = player.nextUnit(iter, False)

And it's pretty easy to figure out what is in the python API. Just do a control-f in the CyXXX.h files. For example, CyUnit.h for units. It will list all the return types, function parameters, etc. If it's in a Cy file, it's in the Python API. That's why those files exist.
 
A humble suggestion about the Holy Mountain Quest:
It has a great randomness for failure. If a barbarian city is spawned next to the Holy Mountain, you fail it. (It happened to me before)
I suggest quest completion to be the first to build a Temple (or a Cathedral?) next to the spot if it is feasible.
 
A humble suggestion about the Holy Mountain Quest:
It has a great randomness for failure. If a barbarian city is spawned next to the Holy Mountain, you fail it. (It happened to me before)
I suggest quest completion to be the first to build a Temple (or a Cathedral?) next to the spot if it is feasible.

Fun quest but it's so easy to fail heh. I've had it show up on the opposite end of the world many times, and a few times it's been right on the border of an enemy civilization. I clearly recall failing the quest the turn after being given it too due to an AI planting a settler beside it :lol:


The Blessings of the Ocean one is just awful. Requirements are absurd on any mapsize, and it's suicide to even bother attempting if you're playing with Revolutions. The reward is hardly worth it as well.
 
I got that quest whilst on an archipelago map and I still pointed and laughed. :) Maybe coastal cities and island cities would be a better choice.
 
A humble suggestion about the Holy Mountain Quest:
It has a great randomness for failure. If a barbarian city is spawned next to the Holy Mountain, you fail it. (It happened to me before)
I suggest quest completion to be the first to build a Temple (or a Cathedral?) next to the spot if it is feasible.

I think we can exclude barbarians from causing the quest to fail.

This is the Python line to check for if another player owns the plot:
Code:
if (plot.getOwner() != kTriggeredData.ePlayer and plot.getOwner() != -1):

I'm pretty sure -1 is the assignment for "no ownership". I don't know if player #0 is the barbarians or the first human player. I think player #0 is always the first human player. But there is an isBarbarian test that can be used.

I am absolutely NOT going to dictate forcing the placement of a city right next to the Mountain. I think it is enough to own the Mountain plot before another (non-barbarian) civilization can claim it.
 
You can also look up the Barbarian player id with gc.getBARBARIAN_PLAYER()
 
I just got this 'Preparing for War' event, it's referring to Hereditary Rule (Monarchy) still, and I can't even train Swordsmen yet (Requires Smithing which isn't even viewable on my "Can Research" list yet)
 

Attachments

  • Civ4ScreenShot0206.JPG
    Civ4ScreenShot0206.JPG
    174.5 KB · Views: 46
I just got this 'Preparing for War' event, it's referring to Hereditary Rule (Monarchy) still, and I can't even train Swordsmen yet (Requires Smithing which isn't even viewable on my "Can Research" list yet)

I forgot to update the text. The event actually counts both Light Swordsmen and Swordsmen. And I will change it to refer to Monarchy as well.
 
I forgot to update the text. The event actually counts both Light Swordsmen and Swordsmen. And I will change it to refer to Monarchy as well.

Alright awesome - I can still get this quest done with my Praetorians then :king:
 
Alright awesome - I can still get this quest done with my Praetorians then :king:

That was the point. There are several Quests that I updated by allowing two or three unit types to fill the quest requirement. Otherwise the completion window was just too narrow.
 
Rev 958, I got this event about inflation.
 

Attachments

  • Civ4ScreenShot0192.JPG
    Civ4ScreenShot0192.JPG
    261 KB · Views: 77
Jumped up to rev696 and started a new game, and have been noticing some oddities with the "Brothers at War" event. It's triggered twice, and both times so far it's refused to allow me selection of the 'We can't spare any aid' option. I've got Elephants, and Iron, multiple units of both in face, but the only option it will let me pick is Horses.

So that's the first thing. Second, and stranger still, is that the second time it came up? Was with a nation that wasn't at war with anyone. He wasn't even experiencing revolutions or unrest! Being unable to select the 'We can't help' option again, the game ended up forcing me to give away my last spare Horse. I canceled the other one on the following turn, but still...
Civ4ScreenShot0226.JPG


The other thing I've been noticing and have been for the past few revisions is the abundance of the event that gives +10 or so food stores to ever one of your cities. Soldiers Returning from War or something?
It seems to happen quite frequently, and I had one trigger earlier while I was at war.
 
Jumped up to rev696 and started a new game, and have been noticing some oddities with the "Brothers at War" event. It's triggered twice, and both times so far it's refused to allow me selection of the 'We can't spare any aid' option. I've got Elephants, and Iron, multiple units of both in face, but the only option it will let me pick is Horses.

So that's the first thing. Second, and stranger still, is that the second time it came up? Was with a nation that wasn't at war with anyone. He wasn't even experiencing revolutions or unrest! Being unable to select the 'We can't help' option again, the game ended up forcing me to give away my last spare Horse. I canceled the other one on the following turn, but still...
View attachment 393655


The other thing I've been noticing and have been for the past few revisions is the abundance of the event that gives +10 or so food stores to ever one of your cities. Soldiers Returning from War or something?
It seems to happen quite frequently, and I had one trigger earlier while I was at war.
I've seen the brothers at war event problem too. It happened some revisions ago to me, probably one month ago.
 
For Baby Boom: Could something have been wrong with the AtWarCount and AtPeaceCounter? I just did some testing and I found that the event triggers exactly when you are at peace with everyone and your last war just ended. I set up a three-player game (Tiny, Pangaea) and set the iWeight to -1 so the event was sure to trigger. When I made peace with the first rival, he got the Baby Boom and I didn't; I am fairly sure he had not yet made contact with the third civ. When I made peace with the second rival, then Baby Boom triggered for me.

The only check on Baby Boom is a Python routine.
Code:
def canTriggerBabyBoom(argsList):
	kTriggeredData = argsList[0]
	player = gc.getPlayer(kTriggeredData.ePlayer)
	team = gc.getTeam(player.getTeam())

	if team.getAtWarCount(True) > 0:
		return False

	for iLoopTeam in range(gc.getMAX_CIV_TEAMS()):
		if iLoopTeam != player.getTeam():
			if team.AI_getAtPeaceCounter(iLoopTeam) == 1:
				return True

	return False

The event has a very high iWeight of 500 so it is very likely to trigger if the conditions are met. If you are at war with anyone, it won't trigger. If you have been at peace with someone for one turn, then it will trigger.
 
45°38'N-13°47'E;13814618 said:
I've seen the brothers at war event problem too. It happened some revisions ago to me, probably one month ago.

Brothers at War has a PythonCanDo that seems unnecessary. Here's the code for the Python routine (BrothersInNeed1 is the "don't give anything" option):

Code:
def canDoBrothersInNeed1(argsList):
	kTriggeredData = argsList[1]
	newArgs = (kTriggeredData, )

	return canTriggerBrothersInNeed(newArgs)

I don't even know what this is supposed to do. It is the same code as the Brothers in Need in vanilla BTS. Do you have any idea what is supposed to result from this?
 
Brothers at War has a PythonCanDo that seems unnecessary. Here's the code for the Python routine (BrothersInNeed1 is the "don't give anything" option):

Code:
def canDoBrothersInNeed1(argsList):
kTriggeredData = argsList[1]
newArgs = (kTriggeredData, )

return canTriggerBrothersInNeed(newArgs)

I don't even know what this is supposed to do. It is the same code as the Brothers in Need in vanilla BTS. Do you have any idea what is supposed to result from this?

No, I don't but I'll look into it.

Edit: I had a look... but I must tell that I have no idea. And if it's the same as in Vanilla BTS, I really don't know why it causes this problem, which by the way only started recently. Only thing that comes to mind is that it might be connected to some changes in the trading code but I don't remember any change of this kind recently.
 
Top Bottom