New Trait Effect

UnresearchedTechBonusFromKills is a percentage from 1-100 (if 0 has no effect).

If you kill a unit who's prereq technology you have not yet researched, you receive a percentage of that technology's cost in beakers, which goes toward that prereq technology, defined by UnresearchedTechBonusFromKills.

So if UnresearchedTechBonusFromKills is 10, and you kill a unit, then you research 10% of it's prereq technology if you have no yet researched it.

Code:
//	--------------------------------------------------------------------------------
/// Apply and show a bonus towards unresearched tech when we defeat a unit of that tech
/// If a bonus is applied, iNumBonuses must be incremented to stagger the UI text with other bonuses
void CvPlayer::DoUnresearchedTechBonusFromKill(UnitTypes eKilledUnitType, int iX, int iY, int &iNumBonuses)
{
	CvAssertMsg(eKilledUnitType != NO_UNIT, "Killed unit's type is NO_TYPE. Please send Anton your save file and version.");
	if (eKilledUnitType == NO_UNIT) return;

	int iPercent = GetPlayerTraits()->GetUnresearchedTechBonusFromKills();

	if (iPercent > 0)
	{
		int iValue = 0;

		CvUnitEntry* pkUnitInfo = GC.getUnitInfo(eKilledUnitType);
		if(pkUnitInfo)
		{
			TechTypes ePrereq = (TechTypes) pkUnitInfo->GetPrereqAndTech();
			if (ePrereq != NO_TECH)
			{
				CvTechEntry* pkTechInfo = GC.getTechInfo(ePrereq);
				if (pkTechInfo && !GET_TEAM(getTeam()).GetTeamTechs()->HasTech(ePrereq))
				{
					int iCombatStrength = max(pkUnitInfo->GetCombat(), pkUnitInfo->GetRangedCombat());
					if (iCombatStrength > 0)
					{
						int iTechCost = GetPlayerTechs()->GetResearchCost(ePrereq);
						iValue = (iTechCost * iPercent) / 100;

						// Cannot be greater than the tech's cost
						int iRemainingCost = iTechCost - GetPlayerTechs()->GetResearchProgress(ePrereq);
						if (iValue > iRemainingCost)
						{
							iValue = iRemainingCost;
						}

						if (iValue > 0)
						{
							GET_TEAM(getTeam()).GetTeamTechs()->ChangeResearchProgress(ePrereq, iValue, GetID());
							iNumBonuses++;
							ReportYieldFromKill(YIELD_SCIENCE, iValue, iX, iY, iNumBonuses);
						}
					}
				}
			}
		}
	}
}
 
Never heard of it, but since it's the closest thing to a science yield from kills apparently, definitely going to use it. Although unfortunately, as it seems, it's only an ability for BNW, not G&K. :( So I can only use it for BNW versions, I guess.

And also, since this is a trait, that would mean that all units receive the bonus, so is there anything remotely close to this that can be applied to a promotion or unit?
 
Never heard of it, but since it's the closest thing to a science yield from kills apparently, definitely going to use it. Although unfortunately, as it seems, it's only an ability for BNW, not G&K. :( So I can only use it for BNW versions, I guess.

And also, since this is a trait, that would mean that all units receive the bonus, so is there anything remotely close to this that can be applied to a promotion or unit?

You can have units yield Science from kills in the same way they might yield other national yields, such as culture, gold or faith.
 
If it's promotion based, you can have an invisible building give the promotion (like the zulu building) and use lua to install it as a trait or attach the promotion to the UB of the civilization (again like the zulu). Both can be attached to specific techs.


ps Sorry, on rereading... you meant the other unit's tech, right?
 
Yest! The trait neatly built by Putmalk works empire-wide, but AgressiveWimp rose the possibility of making it exclusive for an unit/promotion.

But your solution sounds good, doesn't it? If the invisible building gives an specific unit this Science-gain promotion (that only works when killing an unit which prereq tech you haven't researched yet), it could work, right?
 
You can have units yield Science from kills in the same way they might yield other national yields, such as culture, gold or faith.
Are you sure? Since science doesn't function like gold, culture or faith, as it isn't something you can "spend", but rather like tourism it just builds up every turn.

I believe there was a thread similar to this one about science from kills a while back...

EDIT: And then I looked up the alien community on the steam workshop but nothing in the UA says anything about science from kills (and it has no UU)
 
Are you sure? Since science doesn't function like gold, culture or faith, as it isn't something you can "spend", but rather like tourism it just builds up every turn.

I believe there was a thread similar to this one about science from kills a while back...

EDIT: And then I looked up the alien community on the steam workshop but nothing in the UA says anything about science from kills (and it has no UU)

Unless they changed it since BNW, I'm fairly sure, as I used to have it in my German Empire mod as an effect for the UU. Science is still a yield in the same way as gold or culture, regardless of its function. Tourism, on the other hand, is not (like Culture was in Vanilla); as in it wasn't implemented in the same way as other yields. So it should work.
 
Yest! The trait neatly built by Putmalk works empire-wide,

I didn't build it, I merely posted it from the source code. :)
 
But doesn't that give you Science for EVERY kill, instead only against units whose prereq techs you haven't researched yet?

Yes, but I was addressing AggressiveWimp's impression that Science from kills against more advanced units was the only way to get science from kills, which is not the case, in case it was more pertinent to him.
 
Yes, but I was addressing AggressiveWimp's impression that Science from kills against more advanced units was the only way to get science from kills, which is not the case, in case it was more pertinent to him.
Uh... that actually wasn't my impression... I was just wondering how to make a certain unit generate science from kills; it was putmalk who was saying you only get science from killing units of a more advanced civilization...
 
Never heard of it, but since it's the closest thing to a science yield from kills apparently, definitely going to use it. Although unfortunately, as it seems, it's only an ability for BNW, not G&K. :( So I can only use it for BNW versions, I guess.

I took the above out of context then.
 
Top Bottom