A quick script question about FeatAdd

I made a simple script with the function FeatAdd. Everything works except for one little thing.

///////////////////////////////////////////////////////////////////////////////
// FeatAdd
///////////////////////////////////////////////////////////////////////////////
// Created By:  Brock Heinz - OEI
// Created On:  01/19/06
// Description: Adds a feat to the target creature. with an option to check or
//              bypass the feat's requirements
// Edited 09/30/2008 JWR-OEI
// Arguments:
//  oCreature           - The creature to which you want to add a feat
//  iFeatId             - The Feat ID which you want to add, from Feats.2DA
//  bCheckRequirements  - Whether or not the game should check to see if the
//                      creature meets the feat's prerequisites before adding
// bFeedback            - Whether or not to display feedback in chatlog
// bFeedback            - Whether or not to display "notice" text in center of
//                        the screen
// Returns: TRUE if the feat was added to the creature, otherwise, FALSE
///////////////////////////////////////////////////////////////////////////////

I was to apply this to the PC and the companions, using the bFeedback, but in the chat window it only says that the PC has received the new feat even though the companions got it too. I would have liked it if the game said the companions name and that they got it too. Like if I used the function like this:

object oEdgar = GetNearestObjectByTag("edgar",oPC);
FeatAdd(oEdgar ,23,FALSE,TRUE,TRUE);

it would have been nice that the game would notify the player that Edgar got the feat. I hope you’re understanding what I’m getting at.

Are those feats gain happening in quick succession?
Or did you test them separately?

For example, does this happen if you give it only to the companion? (get no message or wrong message)

2 Likes

Try something like this:


void main()
{
	object oPC = GetFirstPC(FALSE);
	object oFM = GetFirstFactionMember(oPC, FALSE);

	SetNoticeText(oPC, "The party has recieved the Knockdown feat!");	
	
	while(GetIsObjectValid(oFM))
	{
		if (!GetAssociateType(oFM))	// no associates will get the feat
		{
			FeatAdd(oFM, FEAT_KNOCKDOWN, FALSE);
			SendMessageToPC(oPC, GetName(oFM) + " got the Knockdown feat!");
	 	}
			
		oFM = GetNextFactionMember(oPC, FALSE);
	}
}
2 Likes

Thanks for the replies you guys!

@Clangeddin Yes, they are happening directly after one another in the script. I haven’t tested them separately.

@travus That was a neat variation of the script. I think I’ll go with that one.