Aller au contenu

Photo

Script that checks level


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

#1
Laugh out loud

Laugh out loud
  • Members
  • 109 messages

Hello I need a feat script that adds 2 points to an attribute when attained, will improve to 3 points at 8th level and max out to 4points at 16th level.  I have this thus far:

 

const int SPIRIT_BEAUTY = 2810;
void main()
{
   object oPC = GetLastPCRested();
   object oTarget = OBJECT_SELF;
   int nLevel = GetCasterLevel(oTarget);
   int nScore;
   
    if (nLevel > 16)
    {
        nLevel = 16;
    }
 
nScore = (nLevel/8)+2;
 
   if(GetHasFeat(2810, oTarget) && (GetLocalInt(oPC,"SPIRIT_BEAUTY") <1))
      SetLocalInt(oPC,"SPIRIT_BEAUTY",1);
   
         effect eFF = SupernaturalEffect(EffectAbilityIncrease(ABILITY_CHARISMA, nScore));
         ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eFF, oTarget, HoursToSeconds(72));
  
}


#2
Psionic-Entity

Psionic-Entity
  • Members
  • 195 messages

If you're sure you want to use an effect rather than a permanent ability increase then you should assign the effect a spell ID (use the feat ID) and work with that instead of a local int.



#3
rjshae

rjshae
  • Members
  • 4 491 messages

In the future you'll want to post to the Scripting forum.



#4
Laugh out loud

Laugh out loud
  • Members
  • 109 messages

If you're sure you want to use an effect rather than a permanent ability increase then you should assign the effect a spell ID (use the feat ID) and work with that instead of a local int.

but there seems to be something wrong with the formula. Despite the character leveling up, it never increases past a +2 bonus.

#5
kamal_

kamal_
  • Members
  • 5 250 messages

You're not checking the character level, you're calling GetCasterLevel, that function doesn't do what you think it does.

 

GetCasterLevel // Get the level at which this creature cast it's last spell (or spell-like ability)

 * Return value on error, or if oCreature has not yet cast a spell: 0;

 

If you're purely checking the total level, you probably want GetHitDice. If you're checking level of a specific class, you probably want GetLevelByClass.



#6
Laugh out loud

Laugh out loud
  • Members
  • 109 messages

You're not checking the character level, you're calling GetCasterLevel, that function doesn't do what you think it does.

 

GetCasterLevel // Get the level at which this creature cast it's last spell (or spell-like ability)

 * Return value on error, or if oCreature has not yet cast a spell: 0;

 

If you're purely checking the total level, you probably want GetHitDice. If you're checking level of a specific class, you probably want GetLevelByClass.

Thanks, that is what I did not know and this will help me with so many other scripts for this custom class I am building.



#7
andysks

andysks
  • Members
  • 1 650 messages

but there seems to be something wrong with the formula. Despite the character leveling up, it never increases past a +2 bonus.

If you want it permanent, and you have no problem for characters becoming illegal (or how it's called for PW, I don't know), the this function works pretty good. I use it in conversations.

void main(int iAbility)
{
object oPC = GetPCSpeaker();

int iMyCurrentAbilityScore = GetAbilityScore(oPC, iAbility, TRUE);
int iNewAbilityScore = iMyCurrentAbilityScore - 1;
SetBaseAbilityScore(oPC, iAbility, iNewAbilityScore);
}