Author Topic: Custom Feat Script  (Read 254 times)

Legacy_Laugh out loud

  • Newbie
  • *
  • Posts: 4
  • Karma: +0/-0
Custom Feat Script
« on: October 03, 2014, 07:55:12 pm »


               

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.

 


               
               

               
            

Legacy__Guile

  • Hero Member
  • *****
  • Posts: 1308
  • Karma: +0/-0
Custom Feat Script
« Reply #1 on: October 08, 2014, 06:27:18 pm »


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

               
            

Legacy_Laugh out loud

  • Newbie
  • *
  • Posts: 4
  • Karma: +0/-0
Custom Feat Script
« Reply #2 on: October 09, 2014, 04:52:09 am »


               


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");

}

               
               

               
            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
Custom Feat Script
« Reply #3 on: October 09, 2014, 05:02:53 am »


               

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]