Jump to content

making spells unlock when skill requirements are meant script?


thelawfull

Recommended Posts

Selecting the skill level by hand when making spells in the CS (just below the effects list) makes them usable only after that skill level has been reached, not before. Also the auto-calculate thing works, but it calculates the level automatically. Like Expert level spells can only be cast if that magic skill is greater than or equal to 75. If that was what you were thinking.

 

Making a script... umm... how to make it depends on the amount of spells, I think. Just a few could be made by checking skill level and if player has that spell already. If the idea is to add a spell when skill level is high enough.

    ; Alteration adept spell, actor value codes are in OBSE command documentation
    If ( Player.GetActorValueC 20 >= 50 ) && ( Player.HasSpell SomeAdeptSpellID == 0 )
        Player.AddSpell SomeAdeptSpellID
        MessageBoxEX "You have unlocked %n!", SomeAdeptSpellID
    EndIf
Or something a bit like that? For a hundred spells, using an array might be better than writing that a hundred times. Just add all the spells to an array and then go through it. Maybe something like that could work (not tested, though):

Array_var aSpells
Array_var aTemp
ref       rTemp
int       iLevel
int       iSchool

...

    ; Initialise the array somewhere and add spells to it, you could probably
    ; do this somewhere else, as it only needs to be done once, if this is a quest script

    let aSpells := ar_Construct Array
    ar_Append aSpells SomeSpellID

    ; SetDebugMode 0 disables, SetDebugMode 1 enables the debug messages (PrintD) for the whole mod
    ; Also can be done just once per save load, for example.
    SetDebugMode 1

...

    let aTemp := ar_Construct Array

    PrintD "MyModPrefix: Check " + $( ar_Size aSpells ) + " spells..."

    ForEach aTemp <- aSpells
        let rTemp   := *aTemp
        let iLevel  := ( GetSpellMasteryLevel rTemp ) * 25
        let iSchool := ( GetSpellSchool rTemp ) + 20
        If ( Player.GetActorValueC iSchool >= iLevel ) && ( Player.HasSpell rTemp == 0 )
            Player.AddSpell rTemp
            PrintD "MyModPrefix: Added '" + $rTemp + "' to player (AV " + $iSchool + ", level " + $iLevel + ")"
            MessageEX "You have unlocked %n!", rTemp
        EndIf
    Loop

    PrintD "MyModPrefix: Check finished!"
    let aTemp := ar_Null
Maybe something like that could be useful for several spells. Easier than checking each one individually. :P

 

Hopefully that helps a little. :)

 

Edit: OBSE is required for those, forgot to mention it.

Edited by PhilippePetain
Link to comment
Share on other sites

the spells wont have a school requirement, But a skill one and yes having it after is what I am looking for thankyou. :smile:

theres only about 7 or 8 spells but i want them unlocked when you meet a certain sneak requirement endurance requirement stuff like that.

Edited by thelawfull
Link to comment
Share on other sites

so

 

stength adept spell, actor value codes are in OBSE command documentation
If ( Player.GetActorValueC 30 ) && ( Player.HasSpell SomeAdeptSpellID == 0 )
Player.AddSpell SomeAdeptSpellID
MessageBoxEX "through training you have learned %n!", SomeAdeptSpellID
EndIf

Link to comment
Share on other sites

There are actor value codes in OBSE command documentation I like to use. But there is also just the normal GetActorValue command from the base game, which works with names. Like

Player.GetActorValue Strength
Whereas the OBSE version requires the numbers presented in OBSE command documentation.

Player.GetActorValueC 0
If you want to check player's actor value, you can use either version. The 'comparison operator' thingy or whatever it is named checks the value returned against another value. Like

If ( 2 > 3 )   ; False, 2 is not greater than 3
If ( 2 < 3 )   ; True, 2 is less than 3
If ( 1 == 1 )  ; True, 1 is equal to 1
If ( 1 >= 1 )  ; True, 1 is greater than OR EQUAL TO 1
If ( 1 <= 1 )  ; True, 1 is smaller than OR EQUAL TO 1
If ( 1 <= 2 )  ; True, 1 is LESS THAN or equal to 2
If ( 1 != 2 )  ; True, 1 is something else than 2
and the HasSpell returns 1 if actor has that spell, 0 if the actor does not have the spell. If player does not have the spell,

If ( Player.HasSpell MySpellEditorID == 0 )
Will return true so long as player does not have the spell. If you want to check if player does not have a spell AND player has strength greater than or equal to 90, that would work:

If ( Player.GetActorValue Strength >= 90 ) && ( Player.HasSpell MySpellEditorID == 0 )
So that checking actor value the easy way (should be enough for your project, I just try to use OBSE whenever I can, even when not necessary :P ) would work this way:

If ( <actor ref>.GetActorValue <name of value> <comparison operator thingy> <value to compare to> )
And Player strength with 'greater than or equal to' with a comparison value of 33 would be

If ( Player.GetActorValue Strength >= 33 )
To print a message(box) with %n and such (to display names and such) will require OBSE. A piece like that:

ref rSpell

...

let rSpell := MySpellEditorID
MessageBoxEX "Through training, you have learned %n", rSpell
Should, if the spell would be named 'Fireball', show a messagebox:

Through training, you have learned Fireball
Maybe it also works with editor IDs like I showed you:

MessageBoxEX "Through training, you have unlocked %n", MySpellEditorID
But I have used it with reference variables (ref), so I am not sure.

 

This should, if player has strength greater than or equal to 33 and not the spell, add it to player and display a messagebox.

ref rSpell

...

    ; Set the ref variable to your spell, lines like this with ";" prefix
    ; are comments in the script editor and do not produce effects in game.
    let rSpell := MySpellEditorID
    If ( Player.GetActorValue Strength >= 33 ) && ( Player.HasSpell rSpell == 0 )
        Player.AddSpell rSpell
        MessageBoxEX "Through training, you have learned %n", rSpell
    EndIf
OBSE allows to use "let" instead of "set", which is handy if you end up doing more scripting. Here are some examples of how normal "set...to" is easier with "let":

set X to Y       --> let X := Y
set X to X - Y   --> let X -= Y
set X to X + Y   --> let X += Y
set X to X*Y     --> let X *= Y
set X to X/Y     --> let X /= Y
set X to X^Y     --> let X ^= Y
And more. The OBSE command documentation has everything listed. Does that help? I am extremely bad at explaining things. :P

 

Edit: Also no need to give any credit, as you could always read everything on the scripting portal of the Construction Set wiki. :)

Edited by PhilippePetain
Link to comment
Share on other sites

  • Recently Browsing   0 members

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