Piracy Promotion

Joined
Jun 7, 2008
Messages
6,123
Location
Just wonder...
Well, I've worked a bit on this promotion. I've been able to add that promotion, to add some new needed tags in PromotionInfos.xml (bPirate and PrereqOrCivics/PrereqAndCivics, which I've more or less copied from Afforess' ZoC code and Civics Buildings code, which I've used as a template to write new code for Piracy promotion). I've also been able to solve a lovely problem Afforess solved a long ago.
Yet, I'm having strange issues with missing inteface and CTD. I still have things to try before I give up, I think I can do it. Until now, I've been able to introduce that new piracy promotion, which can be selected as intended under certain civics. So that PrereqOrCivics/PrereqAndCivics is working. Now I'm trying to make the promotion to work as intended, i.e. granting HiddenNationality and AlwaysHostile. What I've done (and it doesnt' work for now) is scanning where HiddenNationality and AlwaysHostile are being used in the code and trying to apply that part of the code even when Piracy Promotion comes into play.
For example in CvPlayerAI.cpp, I've added that part in red:

Code:
		case UNITAI_PIRATE_SEA:
		
[COLOR="Red"]			for (int iI = 0; iI < GC.getNumPromotionInfos(); iI++)
			{
				if (GC.getUnitInfo(eUnit).isHasPromotion((PromotionTypes)iI))
				{
					if (GC.getPromotionInfo((PromotionTypes)iI).isPirate())
					{
						bValid = true;
					}
					break;									
				}
			}	[/COLOR]	
			if (GC.getUnitInfo(eUnit).isAlwaysHostile() && GC.getUnitInfo(eUnit).isHiddenNationality())
			{
				bValid = true;
			}
			break;

Of course in order to do this, I had to add isHasPromotion to CvUnitInfo.cpp

Code:
bool CvUnitInfo::isHasPromotion(PromotionTypes eIndex) const
{
	FAssertMsg(eIndex >= 0 || eIndex == NO_PROMOTION, "eIndex is expected to be non-negative (invalid Index)");
	FAssertMsg(eIndex < GC.getNumPromotionInfos(), "eIndex is expected to be within maximum bounds (invalid Index)");
	return eIndex == NO_PROMOTION ? false : m_pabHasPromotion[eIndex];
}

and of course this means I have to add it to CvInfo.h too:
bool isHasPromotion(PromotionTypes eIndex) const;
and
bool* m_pabHasPromotion;

This because I had to use UnitInfo files and not Unit files in order to write that part of the code in red above. If I can use a workaround to check that promotion in Unit instead of in UnitInfo, I might be able to solve the CTD but I'm not sure.
Afforess or anyone else, do you have any suggestion? :)

Thank you.
 
I just want to note that I saw this thread, but right now I have no access to my development computer and can't offer much assistance.
 
Well, I think I've fixed it but I've had no time to try. I've simply chosen a bad template for my code, now I'm looking at first strike code because it's both a unit property and a property granted by promotions, like I'd like piracy to be (hiddennationality and alwayshostile are already unit's property)
 
If I can ask - what's the difference between Hidden Nationality and Always Hostile? We have two Hidden Nationality units, the Privateer and the SR71, and the Privateer is Always Hostile while the SR71 is not. I thought HN would be enough to allow a unit to attack freely, but maybe that's what AH is for?
 
If I can ask - what's the difference between Hidden Nationality and Always Hostile? We have two Hidden Nationality units, the Privateer and the SR71, and the Privateer is Always Hostile while the SR71 is not. I thought HN would be enough to allow a unit to attack freely, but maybe that's what AH is for?

I'm not sure, I'll run some test but I suspect that HN gives you free hand at attacking while AH makes your ship always a target for anyone else. Even one of them is enough to let you enter another civ's territory freely (I've tried this one).

I'm almost finished with the Piracy Promotion I think, just a couple of more tests hopefully
 
If I can ask - what's the difference between Hidden Nationality and Always Hostile? We have two Hidden Nationality units, the Privateer and the SR71, and the Privateer is Always Hostile while the SR71 is not. I thought HN would be enough to allow a unit to attack freely, but maybe that's what AH is for?

Perhaps HN applies for SR71 only in case of interception during recon missions because is the only mission it can perform but has anybody ever had his aircraft intercepted during a recon mission?
 
Hidden Nationality means that no one (except the owner of course) can know who owns that unit, and it displays the barbarian flag. Hidden Nationality alone, however, does not allow that unit to attack or be attacked indiscriminately, that's what Always Hostile does: such a unit can attack units of any other civilization, no matter the diplomatic relations, and without repercussions, as if it were a barbarian. And that's how the AI treats those units as well, attacking them on sight.

Basically, the barbarians are an entire faction of Hidden Nationality and Always Hostile units.
 
Perhaps we could have a land version of it too? Marauder, maybe?
I don't think it's a good idea. There was something like that in C2C and I remember it was a total mess (although it was a long time ago); I've just finished coding Piracy promotion and I've also redone the icon to look better. I'll upload everything in the next hours.
 
I would like the piracy promotion begin with Carousels because the promotion at Mercantilism is redundant. pirates are an ancient breed, Mobile outlaws if you will.

would it be possible to code an option related to era?
 
I would like the piracy promotion begin with Carousels because the promotion at Mercantilism is redundant. pirates are an ancient breed, Mobile outlaws if you will.

would it be possible to code an option related to era?

I don't think it's worth it coding something related to an era, if I understand what you mean; making it available at Caravels would mean Optics so a bit earlier than Mercantilism and it could be fine. But I'll leave that to Vokarya to decide, he's the master of the tech tree. :)
 
Well my point is that caravels land spies ( I always play archipelago with lots of islands). and even war canoes carry spies. so I feel the need to counter these spies effectively and the easiest way that II can think of is through some sort of pirate action that would allow interceptions early as possible when vessels from other civs are sighted. especially when other civs are nearby.
 
My 2 :gold:: Piracy promotion should be available from the start, or very early in the game (maybe one of the Ancient era ship techs), but keep the civic limitations.
 
You might be both right. My concern is that I don't want this promotion to be abused. But since it needs Navigation III and you don't have many XP granting buildings at the start, it might be ok anyway to grant it from earlier. If Vokarya has other suggestions, we'll change that. But we'll also have to change Navigation III prereq for Piracy because Navigation III becomes available at Navigation. Making only Navigation II prereq for Piracy is a bit weak for me.
 
I agree that it should be available earlier.
A way to weaken it could be to have some diplomatic penalty for it. After all they rightly say: "Why don't you purge those pirates from your seas?!"
-1 diplomatic penalty with everyone / X number of units with piracy promotion, where X is scaled by map size. Is that possible?
 
I agree that it should be available earlier.
A way to weaken it could be to have some diplomatic penalty for it. After all they rightly say: "Why don't you purge those pirates from your seas?!"
-1 diplomatic penalty with everyone / X number of units with piracy promotion, where X is scaled by map size. Is that possible?

Definetely too complicated and not worth it.
 
How about available at game start as a bug option

any vessel, limit 1 or 2, receives only 1/2 normal exp., no other restrictions or requirements.
 
How about available at game start as a bug option

any vessel, limit 1 or 2, receives only 1/2 normal exp., no other restrictions or requirements.

What about making it available at Naval Warfare (Ancient Era), requiring Navigation II AND Coastal Assault I? Pirates usually don't operate in deep blue waters. Moreover, that would encourage using Coastal Assault (and Coastal Defense, to compensate), which IMO is rarely used.
 
Top Bottom