1. We have added a Gift Upgrades feature that allows you to gift an account upgrade to another member, just in time for the holiday season. You can see the gift option when going to the Account Upgrades screen, or on any user profile screen.
    Dismiss Notice

Is IsHasPerk a thing?

Discussion in 'CivBE - Modding Help & Mod Creation' started by GenEngineer, Mar 1, 2016.

  1. GenEngineer

    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?
     
  2. Ryika

    Ryika Lazy Wannabe Artista

    Joined:
    Aug 30, 2013
    Messages:
    9,395
    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
     
  3. Machiavelli24

    Machiavelli24 Mod creator

    Joined:
    May 9, 2012
    Messages:
    818
    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.
     
  4. GenEngineer

    GenEngineer Prince

    Joined:
    Aug 24, 2014
    Messages:
    456
    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
     

Share This Page