Modifying Malfunctioning Playerperks

Ubik1994

Chieftain
Joined
Oct 14, 2015
Messages
13
I stumbled upon an error while creating a custom sponsor:

When using the playerperk GlobalEnergyIncomePercentCultureYield instead of being a % is actually an integer. I mean that if you set it at 5 instead of receiving 5% of your income as bonus culture you get FIVE TIMES the income as culture. You cannot insert an usable value since this perks accepts only integers.
GlobalEnergyIncomePercentScienceYield works fine.

Is there a way to make it work correctly?
Is there a way (and eventually a guide/tutorial) to create entirely new playerperks?
 
Well, you could use lua to emulate it. Other than that no, you can't fix stuff because that's handled in the part of the code that we don't have access to.

Not sure what you mean by a guide to make entirely new playerperks. You mean add possible perk-effects to the list? You can't. The workaround is once again using lua to emulate it yourself. (by creating an empty dummy-perk and making lua check for that one + do stuff if it finds it).

To learn the basics of lua you can use about any lua guide out there and then look at the lua that is available in the game + that is used in mods to learn the specifics for BE. But if you haven't got any experience with programming at all and are new to modding that may be overkill for now.
 
Thank you Ryika, I actually started modding after having seen your terrific work. I love your mods, Can't wait for your overhaul of ruins/pods/artifacts. I am always stealing/looking at the code you use. Though there are plenty of them it's kind of sad that you cannot create playerperks. Is there a way to add stuff to the Virtue column? For instance adding a Player Perk bonus to a virtue like artifactacquisitionrate.
 
I have some code that implements Energy from culture. Use the following lua:

Code:
function AppliedAesthetics(playerID)
	local player = Players[playerID];
	local perk = GameInfo.PlayerPerks["PLAYERPERK_NH_ENERGY_FROM_CULTURE"].ID;

	if(player:HasPerk(perk)) then
		local bonus = math.floor(player:GetTotalCulturePerTurn() / 2);

		if(bonus > 0) then
			player:ChangeEnergy(bonus);

			-- Send a notification to the player
			local text = Locale.ConvertTextKey("TXT_KEY_NH_APPLIED_AESTHETICS_NOTIFICATION", tostring(bonus));
			player:AddNotification(NotificationTypes.NOTIFICATION_GENERIC, text, text);
		end
	end
end
GameEvents.PlayerDoTurn.Add(AppliedAesthetics);

And the following text:
Code:
		<Row Tag="TXT_KEY_NH_APPLIED_AESTHETICS_HELP">
			<Text>Earn extra [ICON_ENERGY] Energy equal to 50% of the [ICON_CULTURE] Culture you generate</Text>
		</Row>
		<Row Tag="TXT_KEY_NH_APPLIED_AESTHETICS_NOTIFICATION">
			<Text>+{@1_num}[ICON_ENERGY] from Applied Aesthetics.</Text>
		</Row>

You'll also need to add a perk for PLAYERPERK_NH_ENERGY_FROM_CULTURE. If you want it to come from a Virtue use My Policies grant buildings & perks snippet Ryika linked to.
 
Top Bottom