DLL - Lua API requests

Agreed- I will note that the function is designed around a base of 0-10 for the flavors, so 10 = highest value and 0 = lowest (like leader personality flavors). Going over 10 will make the AI value items quite a bit (as in, a lot), and they may over-pay :)

With that in mind, I think we should also consider variable flavors for the existing resources, as some are intrinsically more valuable than others).

G
 
Could a "Building_GlobalResourceAnds" and "Building_GlobalResouceORs" table be added, akin to the "Building_LocalResource..." tables. I'm giving an associated building to all resources, and restricting their being built based upon having a global source of the prereq resource via city.CanConstruct has a considerable impact upon performance when opening the city view, and I'm hoping that adding that functionality to the DLL would eliminate that issue. Thanks. Unless there are recommendations as to how to improve performance here. I am including a custom cityview.lua file, so maybe some things can be steamlined in there.

EDIT: Hm, this might not help with the issue anyway. What I'm looking for is something like Building_QuantityRequirements, but that doesn't work very accurately with resources that give happiness (and I don't necessarily want the building to consume the resource). It also doesn't hide the building from the production queue - though that can be fixed with an edit to the cityview. The necessary thing might be to make my own UI for what I want - but any ideas are appreciated, as that means the poor human player will only be able to purchase these buildings and not produce them (unlike the AI).
 
I could make a new row for buildings that is similar to the <PolicyType> or <BeliefType> rows in Buildings, in that it looks for the presence of said resource in a player's empire, and if it finds it, it makes the building available. I've considered making such a row anyways, as I might do something fun with Elephant units at some point.

Edit: here's what I've done:

Code:
#if defined(MOD_BALANCE_CORE_POLICIES)
	ResourceTypes eResource = (ResourceTypes)pBuildingInfo.GetResourceType();
	if (eResource != NO_RESOURCE)
	{
		if (getNumResourceTotal(eResource, true) <= 0)
		{
			return false;
		}
	}
#endif

That'll be tied to a new building row, ResourceType. Should work like PolicyBranchType or PolicyType (in the CP).

G
 
I could make a new row for buildings that is similar to the <PolicyType> or <BeliefType> rows in Buildings, in that it looks for the presence of said resource in a player's empire, and if it finds it, it makes the building available. I've considered making such a row anyways, as I might do something fun with Elephant units at some point.

Edit: here's what I've done:

Code:
#if defined(MOD_BALANCE_CORE_POLICIES)
	ResourceTypes eResource = (ResourceTypes)pBuildingInfo.GetResourceType();
	if (eResource != NO_RESOURCE)
	{
		if (getNumResourceTotal(eResource, true) <= 0)
		{
			return false;
		}
	}
#endif

That'll be tied to a new building row, ResourceType. Should work like PolicyBranchType or PolicyType (in the CP).

G

Thanks. This seems to help a lot.
 
I notice player:SetCapitalCity() is already in the DLL, so could you expose this function to lua when you get a chance. Also, if a SetOriginalCapital() is possible, too (though I don't think I saw that in the source code to begin with). Thanks.
 
I notice player:SetCapitalCity() is already in the DLL, so could you expose this function to lua when you get a chance. Also, if a SetOriginalCapital() is possible, too (though I don't think I saw that in the source code to begin with). Thanks.

Just in case it was missed. No rush; just want to know that it's (some part of it) possible. And it would go a long way in preventing my assassination by Sukritact :p
 
Hm, I did some testing with TrainedFreePromotion in the Buildings table and it doesn't seem to work for civilian units (when they're in the correct UnitPromotion_CivilianUnitType table). This seems like it could be an oversight (probably intentional) on Firaxis' part. I'd be interested to know whether you can look into the source code and see what's up, Gazebo.

This isn't much of an API request, but I didn't know where else to put it, and if it turns out that the DLL skips civilian units or something, I suppose a request - provided it's easy enough - to have the TrainedFreePromotion column include civilians wouldn't be remiss.
 
Hm, I did some testing with TrainedFreePromotion in the Buildings table and it doesn't seem to work for civilian units (when they're in the correct UnitPromotion_CivilianUnitType table). This seems like it could be an oversight (probably intentional) on Firaxis' part. I'd be interested to know whether you can look into the source code and see what's up, Gazebo.

This isn't much of an API request, but I didn't know where else to put it, and if it turns out that the DLL skips civilian units or something, I suppose a request - provided it's easy enough - to have the TrainedFreePromotion column include civilians wouldn't be remiss.

Here's the DLL for that specific function:

Code:
for(int iI = 0; iI < GC.getNumPromotionInfos(); iI++)
	{
		const PromotionTypes ePromotion = static_cast<PromotionTypes>(iI);
		CvPromotionEntry* pkPromotionInfo = GC.getPromotionInfo(ePromotion);
		if(pkPromotionInfo)
		{
			if(isFreePromotion(ePromotion))
			{
				if((pUnit->getUnitCombatType() != NO_UNITCOMBAT) && pkPromotionInfo->GetUnitCombatClass(pUnit->getUnitCombatType()))
				{
					pUnit->setHasPromotion(ePromotion, true);
				}
			}
		}
	}

Seems that without a unitcombat class, they'll be messed up.

G
 
It's just to support my Exploration Continued Expanded mod, which adds - indirectly - secondary effects to resources. A few grant promotions, such as Banana which grants double movement in Jungle for Workers and Settlers (though that's only without my Attrition add-on) to civilian units, and some of those should be extended to diplomatic civilians. So I've created three combat classes for civilians - CIVILIAN (for Workers and Settlers), GREAT PERSON (for Great People), and RELIGIOUS (for religious units) to which, in addition to DIPLOMATIC, these promotions will be granted, which is much easier than doing it through Lua.
 
It's just to support my Exploration Continued Expanded mod, which adds - indirectly - secondary effects to resources. A few grant promotions, such as Banana which grants double movement in Jungle for Workers and Settlers (though that's only without my Attrition add-on) to civilian units, and some of those should be extended to diplomatic civilians. So I've created three combat classes for civilians - CIVILIAN (for Workers and Settlers), GREAT PERSON (for Great People), and RELIGIOUS (for religious units) to which, in addition to DIPLOMATIC, these promotions will be granted, which is much easier than doing it through Lua.

Sounds great- if you can, try to make it compatible with the CBP, as that sounds like something the community here would like. :)

G
 
Top Bottom