Another question of my mod.How to add a spell automatically

Post » Mon Nov 19, 2012 9:04 pm

I create a new quest as a trigger.
I check the start Game Enabled and the Run once in the Quest Data Tab.
Set the pority to 80 and leave the type to none.


Then a create a script like this.

Scriptname MCSScript extends activemagiceffect  Spell Property MCSChangeCloth AutoEvent OnInit()Game.GetPlayer().AddSpell(MCSChangeCloth)EndEvent

The MCSChangeCloth is a spell id newly created and I've tested it in the game and quite sure it can be added to the player's magic list.


So,shall the quest begin automagically and add the spell like a console?
As the mod may only run once.I've unload and reload it for some times but still not works.No new magic has been added.


Thanks if anyone may help
User avatar
Sarah Unwin
 
Posts: 3413
Joined: Tue Aug 01, 2006 10:31 pm

Post » Mon Nov 19, 2012 10:34 pm

It should have worked, you did it correctly. Btw, quest priority does not matter here.

So...
* Ensure that your script is correctly attached to your quest and its properties are properly assigned. Maybe MCSCCHangeCloth is not assigned?
* Ensure that MCSCCHangeCloth is an ability and is correctly defined.
* Check the game's logs, there may be an error. You should always check them anyway, both for code quality and because repeated insignificant errors may not hurt your mod but may decrease performances significantly. it also offers a poor way to do debugging through debug.trace messages.
* Do you have dialogues in your quest? This may cause troubles because of a bug, search for "SEQ" in this forum (or the "quest/dialogue bug solution" thread, should be on pages 1 to 3)
User avatar
Amanda savory
 
Posts: 3332
Joined: Mon Nov 27, 2006 10:37 am

Post » Mon Nov 19, 2012 6:26 pm

Maybe MCSCCHangeCloth is not assigned?
What means assigned?

I create a new property like the code.
And do a step may unneccessary which I set the property 'Pick Object' to MCSChangeCloth in the quest property setting window;
After this,I found my spell MCSChangeCloth's used property becomes 1.
User avatar
Marina Leigh
 
Posts: 3339
Joined: Wed Jun 21, 2006 7:59 pm

Post » Mon Nov 19, 2012 11:02 pm

What means assigned?
I create a new property like the code.
And do a step may unneccessary which I set the property 'Pick Object' to MCSChangeCloth in the quest property setting window;
if you mean you did as shown in http://www.creationkit.com/images/1/1b/PropertyWindowFilled.png, then it is indeed properly assigned and the error is elsewhere.

After this,I found my spell MCSChangeCloth's used property becomes 1.
I do not understand this part however, but it probably does not matter.
You can check your property's value by adding the following line: debug.trace(MCSChangeCloth)
The value will be displayed in the logs.

EDIT: Nevermind, I figured it out that you were talking about the number of references to this item as displayed in the "used" column in the objects window.
User avatar
Horror- Puppe
 
Posts: 3376
Joined: Fri Apr 13, 2007 11:09 am

Post » Tue Nov 20, 2012 5:53 am

You're so kind but my property is spell.
Should assign the quest itself anywhere?Your screenshot shows the quest is a script property
User avatar
Irmacuba
 
Posts: 3531
Joined: Sat Mar 31, 2007 2:54 am

Post » Mon Nov 19, 2012 10:38 pm

Your script is extending an activemagiceffect. Is your script attached to a magic effect?
If it is, it might be worth changing your script to

Scriptname MCSScript extends activemagiceffectActor Property PlayerRef AutoSpell Property MCSChangeCloth AutoEvent OnEffectStart(Actor akCaster, Actor akTarget)PlayerRef.AddSpell(MCSChangeCloth)EndEvent

From discussions within this forum using it has been demonstrated that using PlayerRef is much more effecient than using Game.GetPlayer()
If your script is not attached to a magic effect, could this be your problem.

Another couple of points,
(1) Do you want the player to have the spell only when the quest is running? If so you could make the player an alias within the quest and add the spell to the Alias Spells box. However when the player is removed from the alias, the spell is also removed.

(2) If you want the spell to be permanent, even when the quest ends, you could add a papyrus fragment to any stage you choose. Preferably you would add the line to the start up stage.
To do this, make your player an alias. For the sake of this i will assume the alias name is player.
In the Papyrus Fragment box, you could then add the following

Alias_Player.GetActorRef().AddSpell(MCSChangeCloth)

This is important, you will need to put ; (semi-colon)in front of that line, then compile. You will then be able to create the property for your spell. Once the property is created, then remove the semi-colon.
User avatar
priscillaaa
 
Posts: 3309
Joined: Sat Dec 30, 2006 8:22 pm

Post » Tue Nov 20, 2012 2:33 am

You're so kind but my property is spell.
Should assign the quest itself anywhere?Your screenshot shows the quest is a script property
No, no, the fact that it was a quest on the screenshot is not relevant, it was just here to show how properties are assigned. Keep a spell for your mod, you do not need a quest property.
One suggestion: try to add Utility.Wait(5) before you add the spell.


From discussions within this forum using it has been demonstrated that using PlayerRef is much more effecient than using Game.GetPlayer()
For something that is only called once, we can safely ignore this imho and keep using Game.GetPlayer(). With all due respect I think he is already annoyed enough by the fact that his mod does not work and I that you're doing more harm than good to him.
What he did is fine, there is simply no performance problem.
User avatar
Isabell Hoffmann
 
Posts: 3463
Joined: Wed Apr 18, 2007 11:34 pm


Return to V - Skyrim