Aller au contenu

Photo

Custom Feat Script


  • Veuillez vous connecter pour répondre
3 réponses à ce sujet

#1
Laugh out loud

Laugh out loud
  • Members
  • 117 messages

I am trying once again to construct my Sharpshooter class but I need help with a custom feat.  This feat should first detect when the character has a bow equiped and then detect which score is stronger the character's strength modifier or the bow's mighty score.  Lastly the script should apply whichever score is higher as the bow's new mighty score.  I was getting some help but the person was talking way above my skill level.  Here is the script I have so far but I do not know how to get it to apply the greater score to the bow.

 

#include "x2_inc_itemprop"
const int FEAT_SSHOOT_BOW_MOD = 2839;
 
object oPC = GetFirstPC(FALSE);
 
int IsBowEquipped(object oPC)
{
    // get the type of item wielded in the left hand
    object oItem = GetItemInSlot(INVENTORY_SLOT_RIGHTHAND, OBJECT_SELF);
    int nType = GetBaseItemType(oItem);
         // check if (holding a bow and (having the right feat)
    if (((nType == BASE_ITEM_LONGBOW) || (nType == BASE_ITEM_SHORTBOW) && (GetHasFeat(FEAT_SSHOOT_BOW_MOD, oPC))))
    {
        return TRUE;
    }
    else
    {
        return FALSE;
    }
}
 
int AddMightToWeapon(object oMyWeapon)
{
    object oMyWeapon = IsBowEquipped();
    int iStr = GetAbilityModifier(ABILITY_STRENGTH, OBJECT_SELF);
    int iMight = GetItemParam1(ITEM_PROPERTY_MIGHTY, oMyWeapon);
 
    if (iMight < iStr)
    {
        return iStr;
}
else
    {
   return iMight;
}
}
 
void main()
{
     if (IsBowEquipped(OBJECT_SELF) && (GetLocalInt(oPC,"FEAT_SSHOOT_BOW_MOD") <1))
     {
     SetLocalInt(oPC,"FEAT_SSHOOT_BOW_MOD",1);
itemproperty ipMight = ItemPropertyMaxRangeStrengthMod(AddMightToWeapon);
IPSafeAddItemProperty(oMyWeapon, ipMight, DURATION_TYPE_TEMPORARY(HoursToSeconds(72)), X2_IP_ADDPROP_POLICY_REPLACE_EXISTING, FALSE, FALSE);
FloatingTextStringOnCreature("Sharpshooter's bow adjusted", OBJECT_SELF);
     }
     else
     {
     SetLocalInt(oPC,"FEAT_SSHOOT_BOW_MOD",0);
     }
}
 
Thank you in advance.
 


#2
_Guile

_Guile
  • Members
  • 685 messages
It would probably be easiest to use the Player Tools (See Lexicon)

#3
Laugh out loud

Laugh out loud
  • Members
  • 117 messages

It would probably be easiest to use the Player Tools (See Lexicon)

According to Google search, Lexicon is out of business.  However, perhaps you can look at my script and tell me why it is not adding the mighty property to the bow in the player's hand?

 

 

#include "x2_inc_itemprop"
const int FEAT_SSHOOT_BOW_MOD = 2839;
 
object oPC = GetFirstPC(FALSE);
 
int IsBowEquipped(object oPC)
{
    // get the type of item wielded in the left hand
    object oItem = GetItemInSlot((INVENTORY_SLOT_RIGHTHAND)||(INVENTORY_SLOT_LEFTHAND), OBJECT_SELF);
    int nType = GetBaseItemType(oItem);
         // check if (holding a bow and (having the right feat)
    if (((nType == BASE_ITEM_LONGBOW) || (nType == BASE_ITEM_SHORTBOW)))
    {
        return TRUE;
    }
    else
    {
        return FALSE;
    }
}
 
void main()
{
 
if (!GetIsPC(GetItemActivatedTarget()))
{
 
  SendMessageToPC(GetItemActivator(), "Bow already adjusted.");
  return;}
 
  oPC = GetItemActivator();
 
  object oTarget;
  object oItem;
  int iStr = GetAbilityModifier(ABILITY_STRENGTH, OBJECT_SELF);
  oTarget = OBJECT_SELF;
 
  oItem = GetItemInSlot((INVENTORY_SLOT_RIGHTHAND)||(INVENTORY_SLOT_LEFTHAND), oTarget);
 
  itemproperty ipAdd;
  ipAdd = ItemPropertyMaxRangeStrengthMod(iStr);
 
  IPSafeAddItemProperty(oItem, ipAdd);
  SendMessageToPC(GetItemActivator(),"Bow adjusted");
}


#4
henesua

henesua
  • Members
  • 3 882 messages

The claims of the NWN Lexicon's demise have been exaggerated.

Please head on over to the NWN Lexicon for all your coding knowledge needs.

 

Would you like fries with that?

[Yes]

[Yes]