Small Script That I Want To Learn (noobish)

Post » Thu Nov 12, 2009 6:10 am

So I am Trying to make a small mod for learning purposes that works like this : When you read a book you get an extra 150 magicka to your magicka pool.

This is small and simple for many probably but I am just starting to learn so I would like some help with this. Here's what I came up with. (P.s. I can guess that this script is completely wrong.)

ScriptName BookofMagika

Short Doonce

Begin OnEquip
If Doonce == 0
Cast AyrtonsMagickaFortify Player
Set Doonce to 1
EndIf
End

Any help on this would be greatly appreciated, Thanks!
User avatar
Ross Zombie
 
Posts: 3328
Joined: Wed Jul 11, 2007 5:40 pm

Post » Thu Nov 12, 2009 5:54 pm

does it run ?
what 's the spell script ?

check http://cs.elderscrolls.com/constwiki/index.php/Cast. It has some gotchas - not sure it works on a book. Why not put the spell in the doonce block - like :
if doOnce == 0
player.http://cs.elderscrolls.com/constwiki/index.php/ModActorValue magicka 150
...
modav is not the best way to do it - I leave it as an exercise :D
(hint : ability)
User avatar
A Lo RIkIton'ton
 
Posts: 3404
Joined: Tue Aug 21, 2007 7:22 pm

Post » Thu Nov 12, 2009 6:48 am

I'm not sure the OnEquip logic works for books. You may want to try with OnActivate. If you want the player to gain a permanent increase of magicka points the best way is to add an ability to the player with the addspell command, not cast a spell on the player. (the "cast" command tends to be pretty iffy most of the time anyways). You can also use ModAV, but that value can mess up stats if it's used incorrectly. Although I doubt your script would cause any real issues with stats since it has a DoOnce flag attached to it. Anyways, it's better to be safe than sorry.

ScriptName BookofMagikashort DoOnceBegin OnEquip	if ( DoOnce == 0 )		player.addspell BookofMagikaAbility		set DoOnce to 1	endifend


If for some reason that won't work, you could try using an OnActivate block instead, but I assume that will only work if the book is not placed in a container.

ScriptName BookofMagikashort DoOnceBegin OnActivate	if ( DoOnce == 0 )		player.addspell BookofMagikaAbility		set DoOnce to 1	endifend


Hope this helps...
User avatar
James Wilson
 
Posts: 3457
Joined: Mon Nov 12, 2007 12:51 pm

Post » Thu Nov 12, 2009 4:07 pm

I'm not sure the OnEquip logic works for books. You may want to try with OnActivate.

It does - runs when book in inventory. Onactivate runs when book is in the open - check DLC spell tomes for examples.
Both are needed to have a book behave as usual.
User avatar
+++CAZZY
 
Posts: 3403
Joined: Wed Sep 13, 2006 1:04 pm

Post » Thu Nov 12, 2009 2:05 pm

It does - runs when book in inventory. Onactivate runs when book is in the open - check DLC spell tomes for examples.
Both are needed to have a book behave as usual.

Thanks for clearing that up ;)
User avatar
Elle H
 
Posts: 3407
Joined: Sun Aug 06, 2006 3:15 am

Post » Thu Nov 12, 2009 10:34 am

Thanks for clearing that up ;)

Welcome :)
User avatar
quinnnn
 
Posts: 3503
Joined: Sat Mar 03, 2007 1:11 pm

Post » Thu Nov 12, 2009 7:09 am

Thanks everyone for the help! I got it working perfectly so that you read the book, gain the effect and it only happens once. Here's the script I used for those who want to see it.

ScriptName BookofMagika

Short Doonce

Begin OnActivate
If ( Doonce == 0 )
Player.addspell AyrtonsMagikaFortify
Activate
Set Doonce to 1
EndIf
Activate
End

AyrtonsMagikaFortify (I know I spelled Magicka wrong) is an Ability that give +150 Magicka Fortify. I did not think that player.addspell would work because I thought it would give me a fortify magicka spell. I now know that it wont and why. Thanks again for the Help everyone!
User avatar
MARLON JOHNSON
 
Posts: 3377
Joined: Sun May 20, 2007 7:12 pm

Post » Thu Nov 12, 2009 1:43 pm

Welcome :) - you don't need double activation btw
ScriptName BookofMagikaShort DoonceBegin onactivateActivateIf ( Doonce == 0 )Player.addspell AyrtonsMagikaFortifySet Doonce to 1EndIfEnd
Does this work from the inventory ? that would prove me wrong
User avatar
KU Fint
 
Posts: 3402
Joined: Mon Dec 04, 2006 4:00 pm

Post » Thu Nov 12, 2009 3:12 pm

Thanks very much guys, and that script you offered Utumno it works like a charm :)
User avatar
Miss Hayley
 
Posts: 3414
Joined: Tue Jun 27, 2006 2:31 am


Return to IV - Oblivion