Aller au contenu

Photo

firing scripts on rest


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

#1
Laugh out loud

Laugh out loud
  • Members
  • 109 messages

I have some custom feat scripts (passive feats) that fire for the Player "on rest" but not for any companions in his party that also happen to have the same feat.  Can I get an example of a script that would first fire the script for the Player and then for the companions in his party?

 

Thank you.



#2
Laugh out loud

Laugh out loud
  • Members
  • 109 messages

OK, I now have a script that fires for both the player and the companions but for some reason the script is not firing when they get the feat through a bonus-feat magic item.  Are there any steps that need to happen to a skill-aiding passive script that need to applied other than the normal feat attaining process?



#3
kevL

kevL
  • Members
  • 4 056 messages
i guess that a bonus-feat on an item doesn't register when examining a character with GetHasFeat() ?

- then loop through the char's equipment and examine each item for its properties, looking for the required itemproperty ( ITEM_PROPERTY_BONUS_FEAT w/ subType IP_CONST_FEAT_* ). There's a tiny snag, though, in that I don't think there's a function that checks if an item has to be equipped/unequipped, for its magical properties to be active. In this case, however, it sounds like you'll know that in advance ....

#4
Laugh out loud

Laugh out loud
  • Members
  • 109 messages

I have an item bonus feat script that seems to be working just fine on a heartbeat script using GetHasFeat().  Does this only not register with passive feats on resting scripts?



#5
kevL

kevL
  • Members
  • 4 056 messages
it worked fine for me.

using a ring that had bonus feat Power Attack, all these module events said yep, has power attack
// on HB
    // test
    if (GetHasFeat(FEAT_POWER_ATTACK, GetFirstPC(), TRUE))
        SendMessageToPC(GetFirstPC(FALSE), ". [hb] has Feat PowerAttack");
    // test_end.

// on rest
    object oPC = GetLastPCRested();

    // test
    if (GetHasFeat(FEAT_POWER_ATTACK, oPC, TRUE))
        SendMessageToPC(GetFirstPC(FALSE), ". [rest] has Feat PowerAttack");
    // test_end.

            // test
            if (GetHasFeat(FEAT_POWER_ATTACK, oPC, TRUE))
                SendMessageToPC(GetFirstPC(FALSE), ". [rest_started] has Feat PowerAttack");
            // test_end.

            // test
            if (GetHasFeat(FEAT_POWER_ATTACK, oPC, TRUE))
                SendMessageToPC(GetFirstPC(FALSE), ". [rest_cancelled] has Feat PowerAttack");
            // test_end.

            // test
            if (GetHasFeat(FEAT_POWER_ATTACK, oPC, TRUE))
                SendMessageToPC(GetFirstPC(FALSE), ". [rest_finished] has Feat PowerAttack");
            // test_end.


#6
kevL

kevL
  • Members
  • 4 056 messages
nb. Also worked with passive feat, Alertness, on the ring.

the feats showed up on my Feats page, which kinda surprised me.

#7
Laugh out loud

Laugh out loud
  • Members
  • 109 messages

Yea, the feat showed up in my feats as well, it just did not work when I attained it from an item.  Only when I purchased it through normal level progression.  Here is a copy of the script.

 

const int FEAT_ELOQUENCE = 2843;
void main()
{
   object oPC = GetLastPCRested();
   object oTarget = OBJECT_SELF;
   if(GetHasFeat(2843, oTarget) && (GetLocalInt(oPC,"FEAT_ELOQUENCE") <1))
      SetLocalInt(oPC,"FEAT_ELOQUENCE",1);
   
   int oWis = GetAbilityModifier(ABILITY_WISDOM, oTarget);
   effect eEffect = EffectLinkEffects(
         EffectSkillIncrease(SKILL_DIPLOMACY, oWis),
         EffectSkillIncrease(SKILL_TAUNT, oWis));
   eEffect = SupernaturalEffect(eEffect);
   ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eEffect, oTarget, HoursToSeconds(72));
   SendMessageToPC(GetFirstPC(), "Using eloquence.");
}
 
 
Of course I also have the OnRest() script reset the FEAT_ELOQUENCE int back to 0. The strange part it it works for the Player's character and his companions when the feat is attained through normal level-progression.  The feat does not work when it is attained via a bonus-feat magic item.


#8
kevL

kevL
  • Members
  • 4 056 messages
where is that script called from?

#9
Laugh out loud

Laugh out loud
  • Members
  • 109 messages

It is a passive custom feat called eloquence.



#10
kevL

kevL
  • Members
  • 4 056 messages
so it's a spellscript, in Spells.2da ?

#11
Laugh out loud

Laugh out loud
  • Members
  • 109 messages

Yes



#12
kevL

kevL
  • Members
  • 4 056 messages
and the item that has a bonus-feat for Eloquence

what IP_CONST_FEAT_* value do you use ( iprp_feats.2da )

#13
Laugh out loud

Laugh out loud
  • Members
  • 109 messages

There does not seem to be a place for a IP_CONST_FEAT_* value in the iprp_feats.2da file. There is only a field named label and a feat# that match the feats that they are refering to in the feats.2da file.  Should I be refering to a IP_CONST_FEAT value in the script itself?  I do not see why since it already has a GetHasFeat() command.



#14
kevL

kevL
  • Members
  • 4 056 messages
well the way i understand what you have going ... some of it anyway ... is that there's an Item in your game that should have a bonus feat, that refers to the custom Eloquence feat.

if that's so, the way to ascribe the Eloquence feat to the item is by giving the item a bonus-feat itemproperty -- and the ip constant has to be referenced *through* iprp_feats.2da, *to* Feat.2da

in iprp_feats, the row# becomes the value that goes into ItemPropertyBonusFeat(IP_CONST_FEAT_ELOQUENCE), on said item, and the FeatIndex should refer to your value in Feats.2da for FEAT_ELOQUENCE

The two constants, one for the ip (subtype), the other for the Feat, are different ...


[ edit ] so, what is this item you have and how did you give it bonus-feat Eloquence

#15
Laugh out loud

Laugh out loud
  • Members
  • 109 messages

OK, I have done some testing.  The I have tried both passive and active custom feats, all of them show up on the items that I place them upon and they all display within the character's feat screen but none of them work properly.  The passive feats never give the host character their respected bonuses and the active feats can be used unlimited numbers of times per day.  There has to be some way they can be added to items and work properly?  I already have the bonus feats upon the items and characters themselves,  This is not the problem.  The problem is getting them to fire, reset and act properly during game play.

 

The item is a belt.  I added the feat information to the feats.2da, spells.2da and iprp_feats.2da files so the feat would show in the bonus feats for items.  I used a OnRest() vustom script to fire the feat every time the character rested.  It does show as a feat in the character's feat screen but during game play I never see the phrease "Using eliquence", nor do I ever see the bonuses granted to the character.



#16
kevL

kevL
  • Members
  • 4 056 messages
yeh i'm getting the same thing, a custom feat i jazzed up using your Eloquence script works properly when granted directly to the PC, but as an item's bonus feat ... the spellability-script never runs (tested onEquip & onRested).

I suggest thinking about Tag-based scripting for the belt, or if you need something more generic try inserting some appropriate code into the module's equip/unequip scripts


if not a bug, it's definitely an oversight in the hardcode, imo.

#17
Laugh out loud

Laugh out loud
  • Members
  • 109 messages

Thanks for trying.



#18
kevL

kevL
  • Members
  • 4 056 messages
the wiki says that "IsPersistent" feats fire at the following times

- loaded
- rests
- finishes leveling up
- respawns
- or module transitions.

They also fire when they're granted. I've got some issues that needa be addressed too. I may end up placing calls from each of those events to a master-like ExecuteScript() that checks & refreshes specific things

(another option is to make a "fake feat" that mirrors the "real feat" but hence can be safely granted and removed when an item is equipped or unequipped)


good luck,

#19
Laugh out loud

Laugh out loud
  • Members
  • 109 messages

Well the feat is intended to ba added to a specific character (NPC) during the course of the game.  I will simply change the scene to add the feat ditrectly to the NPC/companion who is intended to receive it.  I simply couldnot find a way to get a custom feat effect to work.