I add Player Tool04 to the PC skin OnEnter/OnLevelUp, and then give it this functionality:
#include "x3_inc_horse"
#include "x2_inc_itemprop"
#include "nw_i0_plot"
float TimeUntilNextHiPSUse(object oPC);
void main()
{
object oPC = OBJECT_SELF;
//Give the player HiPS just long enough to let them to hide
object oSkin = SKIN_SupportGetSkin(oPC);
IPSafeAddItemProperty(oSkin,ItemPropertyBonusFeat(IP_CONST_FEAT_HIDE_IN_PLAIN_SIGHT),0.2,X2_IP_ADDPROP_POLICY_IGNORE_EXISTING);
DelayCommand(0.1, SetActionMode(oPC,ACTION_MODE_STEALTH,TRUE));
//DecrementRemainingFeatUses(oPC, FEAT_PLAYER_TOOL_04);
DelayCommand(TimeUntilNextHiPSUse(oPC), IncrementRemainingFeatUses(oPC, FEAT_PLAYER_TOOL_04));
}
//non-SDs can use HiPS sooner if they have more ranger/rogue/assassin levels
//maximum usage rate is 2 rounds for these classes
float TimeUntilNextHiPSUse(object oPC)
{
int nRang = GetLevelByclass(class_TYPE_RANGER,oPC);
int nRogue = GetLevelByclass(class_TYPE_ROGUE,oPC);
int nAss = GetLevelByclass(class_TYPE_ASSASSIN,oPC);
float fTime = 52.0 - nRang - nRogue - nAss;
return fTime;
}
I am having a couple problems:
1. When I add HiPS to the player skin with IPSafeAddItemProperty() using a 0.2 duration, it takes anywhere from 4-11 seconds for the feat to actually disappear from the player in-game. So a player could spam HiPS the entire time, which completely ruins what I want to do. Is that a coding mistake on my part, server lag, or what? Any ideas?
2. In feats.2da I set the player tool USESPERDAY to 1. I figured it would become unusable until my function increments the feat uses back up, but this isn't working. It stays usable all the time. I even tried, with the line I commented out, to manually decrement the feat uses in the script. That did not help either. Any thoughts?
I can limit the feat use by setting a local int when it is used, and setting it back to its original state when it can be re-used, but I'd prefer to use incrementremainingfeatuses() if I can.