Add a permanent spell to player via quest...

Post » Tue Jun 19, 2012 6:50 pm

OK, so this isn't working and I have no idea why. The following quest is set to StartGameEnabled and compiles correctly:

Scriptname phitestquestS extends QuestSpell Property phiTestSpell autoFunction AddTheSpell()	 ;won't compile if I don't register within arbitrary function	registerForSingleUpdate(5)EndFunctionEvent OnUpdate()		if (Game.GetPlayer().HasSpell(phiTestSpell)) != 1		Game.GetPlayer().AddSpell(phiTestSpell)	endifEndEvent

The quest does indeed start up, however the spell is never added in-game.

Could be a syntax thing. phiTestSpell is set as a spell, Concentration Aimed, with a drain stam effect and script effect attached, making it a destruction spell. Not able to add it through the console either...
User avatar
BEl J
 
Posts: 3397
Joined: Tue Feb 13, 2007 8:12 am

Post » Tue Jun 19, 2012 7:30 am

Tried just setting the spell to be a PC Start Spell, which didn't work either...
User avatar
Emily abigail Villarreal
 
Posts: 3433
Joined: Mon Aug 27, 2007 9:38 am

Post » Tue Jun 19, 2012 2:02 pm

OK, so this isn't working and I have no idea why. The following quest is set to StartGameEnabled and compiles correctly:

Scriptname phitestquestS extends QuestSpell Property phiTestSpell autoFunction AddTheSpell()	 ;won't compile if I don't register within arbitrary function	registerForSingleUpdate(5)EndFunctionEvent OnUpdate()		if (Game.GetPlayer().HasSpell(phiTestSpell)) != 1		Game.GetPlayer().AddSpell(phiTestSpell)	endifEndEvent

The quest does indeed start up, however the spell is never added in-game.

Could be a syntax thing. phiTestSpell is set as a spell, Concentration Aimed, with a drain stam effect and script effect attached, making it a destruction spell. Not able to add it through the console either...

What do you use the function AddTheSpell for?

Also, if what you want is just adding a spell on game start, you could just use the AddSpell() in the OnInit. Check the scripts in http://www.gamesas.com/topic/1344324-adding-spells-on-startup

EDIT: Once I couldn't add a spell through the console neither. It was because I copied the effect from another one and has a Hide from UI thing enabled. So what happened is that I already had it, but couldn't select it.

EDIT 2: I hadn't assigned a magic school back then neither... :S
User avatar
Heather M
 
Posts: 3487
Joined: Mon Aug 27, 2007 5:40 am

Post » Tue Jun 19, 2012 8:48 am

I have noticed a very disturbing behavior with scripts in this game. It is almost like there is a middle manager taking your requests to do this and that and then deciding when they will be executed. Could be many moments after you wanted it to.

And it seems it is posible to lose you place in line...so to speak...

So I would suggest making the script repeat over and over UNTIL the player has been confirmed to have spell.

If that does not work then there is an issue with your spell not the script I would guess.


OK, so this isn't working and I have no idea why. The following quest is set to StartGameEnabled and compiles correctly:

Scriptname phitestquestS extends QuestSpell Property phiTestSpell autoFunction AddTheSpell()	 ;won't compile if I don't register within arbitrary function	registerForSingleUpdate(5)EndFunctionEvent OnUpdate()		if (Game.GetPlayer().HasSpell(phiTestSpell)) != 1		Game.GetPlayer().AddSpell(phiTestSpell)	endifEndEvent

The quest does indeed start up, however the spell is never added in-game.

Could be a syntax thing. phiTestSpell is set as a spell, Concentration Aimed, with a drain stam effect and script effect attached, making it a destruction spell. Not able to add it through the console either...
User avatar
Nany Smith
 
Posts: 3419
Joined: Sat Mar 17, 2007 5:36 pm

Post » Tue Jun 19, 2012 6:01 pm

What do you use the function AddTheSpell for?
As per my comment line, the script wouldn't compile unless I put my RegisterForUpdates inside a function. Not sure if this is because it is a quest script of if that always holds.

Also, if what you want is just adding a spell on game start, you could just use the AddSpell() in the OnInit. Check the scripts in http://www.gamesas.com/topic/1344324-adding-spells-on-startup
It does seem much easier. I think it was because I was looking only at events for Quest objects, and tried OnReset() without success. But now I see Quest extends Form, so has more things you can use! ;)

EDIT: Once I couldn't add a spell through the console neither. It was because I copied the effect from another one and has a Hide from UI thing enabled. So what happened is that I already had it, but couldn't select it.

EDIT 2: I hadn't assigned a magic school back then neither... :S
Well, you were spot on! I had copied Alduin's Invulnerability effect I believe which had the "Hide in UI" thing checked. I corrected this, and basically made everything in my effect look EXACTLY like the Absorb Stam ConcAimed effect.

I also changed the spell from a Lesser Power to a regular old spell, and removed the default Absorb Stam effect so my custom spell effect which looks just like Absorb Stam but has a script was the only effect in the list for the spell I'm trying to add.

I changed the script to this:

Scriptname phitestquestS extends QuestSpell Property phiTestSpell autoEVENT OnInit()	Actor player = Game.GetPlayer()	if !player.HasSpell(phiTestSpell)		player.AddSpell(phiTestSpell)	endIfEndEvent

That compiles fine. However, after all that, and waiting 30sec on a save I never loaded with this mod (clean save), it still will not add the damn spell! The quest starts, which I can verify with GetStage. But no spell!
User avatar
Emilie M
 
Posts: 3419
Joined: Fri Mar 16, 2007 9:08 am

Post » Tue Jun 19, 2012 6:19 am

The condition specifies, IF you have that spell, it will add it.

Since you DONT have it, it's not going to add it.

Change your conditional, and then it should work.
User avatar
Nancy RIP
 
Posts: 3519
Joined: Mon Jan 29, 2007 5:42 am

Post » Tue Jun 19, 2012 2:27 pm

I was somewhat dubious as to that use of the "!" to specify "if not."

So "if !player.HasSpell(phiTestSpell)" won't work?

What would be correct? "if player.HasSpell(phiTestSpell) != 1" like I did above?

Testing...

EDIT: OK, tried it with "if player.HasSpell(phiTestSpell) != 1" and it compiles, but still will not add the spell. =(
User avatar
Breanna Van Dijk
 
Posts: 3384
Joined: Mon Mar 12, 2007 2:18 pm

Post » Tue Jun 19, 2012 5:26 pm

I would say that !HasSpell should work...but never bothered checking if the player had it since I set the quest to run once...I just use Addspell :tongue: ( Not saying that's a good practice lol )


I assume it works adding it through the console now, doesn't it?
User avatar
Benjamin Holz
 
Posts: 3408
Joined: Fri Oct 19, 2007 9:34 pm

Post » Tue Jun 19, 2012 2:42 pm

I saw that. I tested that operator in my own script and it doesn't work that way(spell is still added).

I don't know how to do this. But if you make a conditional where that spell adds according to the queststage, that should work.

Like if queststage.yourquestname == current stage
User avatar
Nikki Lawrence
 
Posts: 3317
Joined: Sat Jul 01, 2006 2:27 am

Post » Tue Jun 19, 2012 7:13 pm

I guess you could always "switch" the if condition then

if player.HasSpell(phiTestSpell) ; Nothing hereelse  player.AddSpell(phiTestSpell)endIf

I find it weird because I would swear I've seen it being used before...Time to double check and test my code I guess...
User avatar
ONLY ME!!!!
 
Posts: 3479
Joined: Tue Aug 28, 2007 12:16 pm

Post » Tue Jun 19, 2012 7:05 pm

Try this.

Scriptname phitestquestS extends QuestSpell Property phiTestSpell autoEvent OnInit()	if ( Game.GetPlayer().HasSpell( phiTestSpell ) == false )		Game.GetPlayer().AddSpell( phiTestSpell )		Debug.Notification( "Spell Added" )	endifEndEvent
User avatar
Maria Leon
 
Posts: 3413
Joined: Tue Aug 14, 2007 12:39 am

Post » Tue Jun 19, 2012 5:59 am

Well, I am really confused now. According to http://www.gamesas.com/topic/1344324-adding-spells-on-startup/ thread, which I followed to the letter, everything should work. Yet it doesn't. The only thing I can think now to do is post EVERYTHING with screenshots to see if someone can spot what I' m missing.

http://www.iparadigm.org/temp/spell.jpg

http://www.iparadigm.org/temp/effect.jpg

The script on that effect:
Spoiler
Scriptname phiTameBeastTriggerS extends ActiveMagicEffect  Spell Property phiTaming autoSpell Property phiTamed auto;currently not doing anything...

http://www.iparadigm.org/temp/quest.jpg

The script on that quest:
Spoiler
Scriptname phiTameBeastTracker1S extends QuestSpell Property phiTameBeastTrigger autoEVENT OnInit()        Actor player = Game.GetPlayer()        if player.HasSpell(phiTameBeastTrigger) != 1                player.AddSpell(phiTameBeastTrigger)        endIfEndEvent
User avatar
Bethany Short
 
Posts: 3450
Joined: Fri Jul 14, 2006 11:47 am

Post » Tue Jun 19, 2012 2:59 pm

Try this.

Scriptname phitestquestS extends QuestSpell Property phiTestSpell autoEvent OnInit()	if ( Game.GetPlayer().HasSpell( phiTestSpell ) == false )		Game.GetPlayer().AddSpell( phiTestSpell )		Debug.Notification( "Spell Added" )	endifEndEvent
Strange... I got the "Spell Added" message but the spell still isn't there. That leads me to believe there's something wrong with my spell and/or its effect. I posted the screenshots for these above.

EDIT: I realize I've been calling it "phiTestSpell" here and it is "phiTameBeastTrigger" in the screenshots. I assure you, I'm not THAT daft! I just edited the scripts I posted here for ease of reading. =P
User avatar
m Gardner
 
Posts: 3510
Joined: Sun Jun 03, 2007 8:08 pm

Post » Tue Jun 19, 2012 6:23 pm

Why does the magic effect in your spell window says Tame Beast : (null) ?

Does it work when added through the console?


As a side note, !HasSpell in an if works as expected for me :o
User avatar
JD FROM HELL
 
Posts: 3473
Joined: Thu Aug 24, 2006 1:54 am

Post » Tue Jun 19, 2012 10:44 am

Why does the magic effect in your spell window says Tame Beast : (null) ?

I guess maybe because I am using an Absorb archetype I need to put something here... Testing.

EDIT: Added the Stamina effect for the Absorb archetype. Now reads "Tame Beast: Stamina."

Still won't add via script OR console. /wrists
User avatar
Samantha Jane Adams
 
Posts: 3433
Joined: Mon Dec 04, 2006 4:00 pm

Post » Tue Jun 19, 2012 6:35 pm

You need to use an actor property for the player, not just copy the player into an actor variable.

The easiest way to do what you're trying to do though would be to set the player up as a quest alias, then add the spell to the alias within the alias window. No script required.

edit: whoops, didn't notice that your later version replaced the variable with just getting the player directly.

Also, make sure your script properties window has the spell property pointing to the right spell.
User avatar
Mel E
 
Posts: 3354
Joined: Mon Apr 09, 2007 11:23 pm

Post » Tue Jun 19, 2012 10:50 am

You need to use an actor property for the player, not just copy the player into an actor variable.

That's not the issue. I use Actor player = Game.GetPlayer() for that and it works.
User avatar
Poetic Vice
 
Posts: 3440
Joined: Wed Oct 31, 2007 8:19 pm

Post » Tue Jun 19, 2012 9:59 am

Change your effect archetype to script, save everything and try again.
User avatar
louise tagg
 
Posts: 3394
Joined: Sun Aug 06, 2006 8:32 am

Post » Tue Jun 19, 2012 11:30 am

Why does the magic effect in your spell window says Tame Beast : (null) ?

Does it work when added through the console?


As a side note, !HasSpell in an if works as expected for me :ohmy:

I think that's because it's set as an absorb but doesn't have an assoc item on it. Actually that could be part of the issue... Change that to Script archtype.
User avatar
Jimmie Allen
 
Posts: 3358
Joined: Sun Oct 14, 2007 6:39 am

Post » Tue Jun 19, 2012 11:23 am

The easiest way to do what you're trying to do though would be to set the player up as a quest alias, then add the spell to the alias within the alias window. No script required.

That was easy, and it worked! I created a new reference alias, selected "any" from the location, and then found the Player reference. I had to drag and drop the spell into the list since the add dialogue only shows shouts... Odd. But when I start up the game it works, the spell is there.

Incidentally, changing the effect to script made no difference. Not sure why it won't work that way, but it does using a quest alias. /cheer
User avatar
XPidgex Jefferson
 
Posts: 3398
Joined: Fri Sep 08, 2006 4:39 pm

Post » Tue Jun 19, 2012 10:54 am

That was easy, and it worked! I created a new reference alias, selected "any" from the location, and then found the Player reference. I had to drag and drop the spell into the list since the add dialogue only shows shouts... Odd. But when I start up the game it works, the spell is there.

Incidentally, changing the effect to script made no difference. Not sure why it won't work that way, but it does using a quest alias. /cheer

Lol...I don't get it. I use player.AddSpell everywhere...Anyway I'm glad you've worked it out :)
User avatar
Dina Boudreau
 
Posts: 3410
Joined: Thu Jan 04, 2007 10:59 pm


Return to V - Skyrim