Jump to content

Recommended Posts

Posted

I was trying to make a script for my own, that updates lesser powers to BellaGail's vampire races. The script editor however refuses to save the script, claiming there are end expected at the player.addspell/removespell lines where it shouldn't (according to cswiki).

 

 

 

scn VampireLesserPowerUpdater


short level
short Novice
short Apprentice
short Journeyman
short Expert
short Master
short GrandMaster
short doonce


Begin GameMode


set level to player.getlevel


;checks if the player is the right race and level, so other races won't get these lesser powers 
     if ( player.getisrace BellaGailVampireDaywalker01 == 1 || player.getisrace BellaGailVampireDaywalker02 == 1 || player.getisrace BellaGailVampireFeralVampire01 == 1 || player.getisrace BellaGailVampirePureBlood01 == 1 || player.getisrace BellaGailVampirePureBlood02 == 1 || player.getisrace BellaGailVampirePureBlood03 == 1)
          if ( level < 10)
               set Novice to 1
          elseif ( level >= 10 && < 20 )
               set Apprentice to 1
          elseif ( level >= 20 && < 30 )
               set Journeyman to 1
          elseif ( level >= 30 && < 40 )
               set Expert to 1
          elseif ( level >= 40 && < 50 )
               set Master to 1
          elseif ( level >= 50 )
               set GrandMaster to 1
          endif
;makes the starting character a vampire, lifting the need to edit the console every new game
          if ( Novice == 1 && doonce == 0 )
               set PCVampire to 1
               set doonce to 1
          endif
;levels up the lesser powers according to new player levels
          if ( Apprentice == 1 )
               player.removespellNS VampireBiteNovice 1
               player.removespellNS VampireShotNovice 1
               player.removespellNS VampireShieldNovice 1
               player.addspellNS VampireBiteApprentice 1
               player.addspellNS VampireShotApprentice 1
               player.addspellNS VampireShieldApprentice 1
          elseif ( Journeyman == 1 ) 
               player.removespellNS VampireBiteApprentice 1
               player.removespellNS VampireShotApprentice 1
               player.removespellNS VampireShieldApprentice 1
               player.addspellNS VampireBiteJourneyman 1
               player.addspellNS VampireShotJourneyman 1
               player.addspellNS VampireShieldJourneyman 1
          elseif ( Expert == 1 ) 
               player.removespellNS VampireBiteJourneyman 1
               player.removespellNS VampireShotJourneyman 1
               player.removespellNS VampireShieldJourneyman 1
               player.addspellNS VampireBiteExpert 1
               player.addspellNS VampireShotExpert 1
               player.addspellNS VampireShieldExpert 1
          elseif ( Master == 1 )
               player.removespellNS VampireBiteExpert 1
               player.removespellNS VampireShotExpert 1
               player.removespellNS VampireShieldExpert 1
               player.addspellNS VampireBiteMaster 1
               player.addspellNS VampireShotMaster 1
               player.addspellNS VampireShieldMaster 1
          elseif ( GrandMaster == 1 )
               player.removespellNS VampireBiteMaster 1
               player.removespellNS VampireShotMaster 1
               player.removespellNS VampireShieldMaster 1
               player.addspellNS VampireBiteGrandMaster 1
               player.addspellNS VampireShotGrandMaster 1
               player.addspellNS VampireShieldGrandMaster 1
          endif
;makes possible for the vampire races only, to become a vampire again after the cure quest
          if ( PCVampire == -1 )
               set vampire.hasdisease to 0
               set vampire.vamphour to 0
               set vampire.daycount to 0
               set PCVampire to 0
          endif
     endif 
end

screenshot

The rest of the script looks fine for the script editor.

However, I don't know if I really need that lengthy IF line where checking for the vampire races, as the script will run as a quest and there I can set quest target conditions to these races.. (first time making such updater script..)

Posted

what spell flags? :ermm:

The "1"s at the end. Don't know where it comes from in the addSpellNS docs, but there is no 'count' for those spell functions addSpell and removeSpell. You can't have a spell more than once either, so... yeah, bogus documentation. Get rid of the "1"s.

Posted (edited)
Ok, I mended that one and even shortened the script slightly, but it doesn't seem to work..
It does gives the novice spells to a new character of the specific race, but won't update them upon leveling up (not sure how related, but I use ObXP).
scn VampirePowerUpdaterScript

Begin GameMode

if ( player.getisrace BellaGailVampireDaywalker01 == 1 || player.getisrace BellaGailVampireDaywalker02 == 1 || player.getisrace BellaGailVampireFeralVampire01 == 1 || player.getisrace BellaGailVampirePureBlood01 == 1 || player.getisrace BellaGailVampirePureBlood02 == 1 || player.getisrace BellaGailVampirePureBlood03 == 1)

     if ( player.getlevel < 10 )
          player.addspellNS VampireBiteNovice
          player.addspellNS VampireShotNovice
          player.addspellNS VampireShieldNovice
     elseif ( player.getlevel >= 10 && < 20 )
          player.removespellNS VampireBiteNovice
          player.removespellNS VampireShotNovice
          player.removespellNS VampireShieldNovice
          player.addspellNS VampireBiteApprentice
          player.addspellNS VampireShotApprentice
          player.addspellNS VampireShieldApprentice
     elseif ( player.getlevel >= 20 && < 30 )
          player.removespellNS VampireBiteApprentice
          player.removespellNS VampireShotApprentice
          player.removespellNS VampireShieldApprentice
          player.addspellNS VampireBiteJourneyman
          player.addspellNS VampireShotJourneyman
          player.addspellNS VampireShieldJourneyman
     elseif ( player.getlevel >= 30 && < 40 )
          player.removespellNS VampireBiteJourneyman
          player.removespellNS VampireShotJourneyman
          player.removespellNS VampireShieldJourneyman
          player.addspellNS VampireBiteExpert
          player.addspellNS VampireShotExpert
          player.addspellNS VampireShieldExpert
     elseif ( player.getlevel >= 40 && < 50 )
          player.removespellNS VampireBiteExpert
          player.removespellNS VampireShotExpert
          player.removespellNS VampireShieldExpert
          player.addspellNS VampireBiteMaster
          player.addspellNS VampireShotMaster
          player.addspellNS VampireShieldMaster
     elseif ( player.getlevel >= 50 )
          player.removespellNS VampireBiteMaster
          player.removespellNS VampireShotMaster
          player.removespellNS VampireShieldMaster
          player.addspellNS VampireBiteGrandmaster
          player.addspellNS VampireShotGrandmaster
          player.addspellNS VampireShieldGrandmaster
     endif

endif

end

 

Edited by Morghean
Posted

I'm actually a little surprised this did even compile. The Script Editor must be blind or something.

I've never seen a condition like "elseif ( player.getlevel >= 40 && < 50 )" ever before and am very doubtful it'll work.

You need to have a comparison on each side of the "&&", so make all of these lines read: "elseif ( player.getlevel >= 40 && player.getlevel < 50 )" instead.

 

Coming to think of it, conditions are picky with function calls and parameters, plus many repeated function calls can cause an FPS hit and are unneccessary.

You can store the return of "player.getlevel" into a variable once at the top of your script instead, like

 

long myPCLevel

...

set myPCLevel to player.getlevel

 

And then all your comparisons read like "elseif ( myPCLevel >= 30 && myPCLevel < 40 )". But that's just code-cleanup and performance enhancement.

Though it could be using function calls directly within comparisons might put the compiler off sometimes. I've seen it happen before with some functions.

Posted

I'm actually a little surprised this did even compile. The Script Editor must be blind or something.

I've never seen a condition like "elseif ( player.getlevel >= 40 && < 50 )" ever before and am very doubtful it'll work.

 

It's perfectly valid from a logic viewpoint (which is all the editor/compiler understands). It's the same as saying:

 

If ( ( Player.GetLevel >= 40 ) && False )

 

The script won't work (as planned) of course, but it's valid(?) logic.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...