Can you use Team:SetHasTech() without the tech popup appearing?

Vicevirtuoso

The Modetta Man
Joined
May 14, 2013
Messages
775
Location
The Wreckage, Brother
As title.

TeamTechs:SetHasTech() does not make the tech award popup appear, but granting techs this way doesn't seem to affect Traits which have a PrereqTech or ObsoleteTech for some reason. (I'm trying to use dummy technologies to turn a Civ's NoAnnexing Trait on or off based on various conditions.)
 
Using the technique to hi-jack popups (ie install your own listener for the pop-up and send a close action immediately it occurs) you could modify it by setting a flag (probably via a LuaEvent) before you grant the fake tech and only close the standard popup if the flag is set. Don't forget to always clear the flag in the hi-jack code.

Edit: Ninja'd! And of course the "flag" is the tech id!
 
Thanks for the responses!

I actually had already figured out how to hide the popup using DequeuePopup, but the issue with that is that the "tech discovered" sound still plays. The narration also plays, though that's not an issue with dummy techs lacking audio quotes. Considering how frequently this Civilization will be swapping out techs, that would nonetheless get annoying very quickly.

It turns out that after a good night's sleep, I came up with this method which does the following:

  • Turns the player's "No Rewards Popups" option on temporarily while remembering their previous setting
  • Sets the player to have whichever free tech is necessary
  • Destroy the notification as it appears
  • Set the player's No Rewards Popup setting back to off if it was off previously

Code:
local PUPPETING_ON = GameInfoTypes.TECH_VV_NEPTUNE_DUMMY_ON
local PUPPETING_OFF = GameInfoTypes.TECH_VV_NEPTUNE_DUMMY_OFF

function OnNotificationAdded( Id, nType, toolTip, strSummary, iGameValue, iExtraGameData, ePlayer )
	if nType == NotificationTypes.NOTIFICATION_TECH_AWARD and (iExtraGameData == PUPPETING_OFF or iExtraGameData == PUPPETING_ON) then
		UI.RemoveNotification( Id )
	end
end
Events.NotificationAdded.Add(OnNotificationAdded)

--if bSet is true, set the PUPPETING_OFF trait to true and PUPPETING_ON trait false.
function NeptuneDummyTechSet(pPlayer, bSet)
	local pTeam = Teams[pPlayer:GetTeam()]
	local bIsActivePlayer = (pPlayer:GetID() == Game:GetActivePlayer())

	--Temporarily disable reward popups if they are on.
	local bNoRewardPopups = OptionsManager.IsNoRewardPopups_Cached()
	if bIsActivePlayer and not bNoRewardPopups then
		OptionsManager.SetNoRewardPopups_Cached(true)
		OptionsManager.CommitGameOptions();	
	end

	pTeam:SetHasTech(PUPPETING_ON, not bSet)
	pTeam:SetHasTech(PUPPETING_OFF, bSet)
	
	if bIsActivePlayer and not bNoRewardPopups then
		OptionsManager.SetNoRewardPopups_Cached(false)
		OptionsManager.CommitGameOptions();
	end
end

You can still see the notification for a couple of frames if you're looking for it, but it's the best method I've found so far.
 
oh, shiney! I've been trying to figure out such a thing for my Era Buildings mod, where when the player advances to the next era they get an 'unlocker' tech that acts as prerequisite for building upgrades and so on. Course, I may decide to let the tech pop-up keep happening because it is a signal to the player they have more buildings to construct and/or upgrade. Plus, well, for my own giggles:
Spoiler :
Code:
<Row Tag="TXT_KEY_TECH_LRSDUMMY_CLASSICAL_QUOTE">
	<Text>Toga! Toga! Toga![NEWLINE]-- John Belushi</Text>
</Row>
<Row Tag="TXT_KEY_TECH_LRSDUMMY_MEDIEVAL_QUOTE">
	<Text>[COLOR_POSITIVE_TEXT]Messenger[ENDCOLOR]: Sire! The peasants are revolting![NEWLINE][COLOR_POSITIVE_TEXT]King[ENDCOLOR]: Yes they are.</Text>
</Row>
<Row Tag="TXT_KEY_TECH_LRSDUMMY_RENAISSANCE_QUOTE">
	<Text>Let us all now be Renaissance Men.</Text>
</Row>
<Row Tag="TXT_KEY_TECH_LRSDUMMY_INDUSTRIAL_QUOTE">
	<Text>Who needs Robber Barons? Much more fun and far easier to be an 'Industrialist'!</Text>
</Row>
<Row Tag="TXT_KEY_TECH_LRSDUMMY_MODERN_QUOTE">
	<Text>I am the very model of a Modern Major General. Really!</Text>
</Row>
<Row Tag="TXT_KEY_TECH_LRSDUMMY_POSTMODERN_QUOTE">
	<Text>Ghandi! Are you happy to see me again, or is that just a boatload of Nuclear Missiles you have hidden there under your Sarong?</Text>
</Row>
But it is nice to know I can shut off the pop-ups without having to rewrite the standard UI game-files, which I was starting to think I would have to do to eliminate the pop-up if players thought it was too annoying or confusing because it will always occur for my dummy techs in tandem with the Era Splashes.
 
Back
Top Bottom