Is IsHasPerk a thing?

GenEngineer

Prince
Joined
Aug 24, 2014
Messages
456
Hey everyone,

I was wondering if it was possible to use perks as triggers in LUA. I think I have the code correctly written to do what I want it to do, but it's all based on whether or not the if statement regarding whether player has a perk works - I was wondering if anyone knows any command that checks whether Player A has perk B, true or false?
 
Yes, it exists, but it's not IsHasPerk, it's simply HasPerk. An example from CovertOperationsSystem.lua (Base-Game Version):

Code:
	-- Perks
	local player = Players[playerID];
	if (player:HasPerk(GameInfo.PlayerPerks["PLAYERPERK_NATIONAL_SECURITY_PROJECT_OPS_RECON"].ID)) then
		for info in GameInfo.PlayerPerks_NationalSecurityProjectEffects{PlayerPerkType = "PLAYERPERK_NATIONAL_SECURITY_PROJECT_OPS_RECON"} do
			difficulty = difficulty - info.OperationSuccessPercent * player:GetNumUnassignedCovertAgents();
		end
	end
 
I was wondering if it was possible to use perks as triggers in LUA.
It is possible to test to see if a player has a specific perk. It is also possible to add or remove a perk from a player. However, if you are asking if it is possible to detect when a player gains a perk, the answer is not really. There are some sub-categories where it is feasible and there is a clunky way to fake it in the general case but I'll spare the details unless that really is what you're looking for.
 
That should actually do it - I don't necessarily need it to be a constant check when a perk is gained, since I'm instead using it as a check of whether or not buildings should be swapped out for an expanded version with more specialist slots at the start of each players turn. Nearest I can tell, it's working perfectly.

Thank you for the assistance
 
Back
Top Bottom