Jump to content

add two spells with one script


Recommended Posts

I'm having problems doing this, I know it can be done as I've done it. The issue is one particular spell that refuses to be added by script, even though I can add it fine in the console, to either NPC or the player.

This is the offending spell effect script:

 

 

Scriptname dz_outfits_meta_ability_effect_script Extends ActiveMagicEffect
dz_auto_outfit_mcm_menu Property dz_mcm Auto       ;need access to mcm menu variables
Spell Property dz_outfits_meta_ability_spell Auto      ;need to reference the spell this effect is attached to
Spell Property dz_outfits_ability_spell Auto


Int npc_index               ;this will be the mcm page index for this NPC
Event OnEffectStart(Actor Target, Actor Caster)
;;;if auto-changing status has changed to off;;;

;/ If dz_mcm.activate_toggle[dz_mcm.index] == False     ;check to see if mcm menu toggle for ability has been deactivated

  self.dispel()             ;dispel the ability

  Return               ;and return, no more to be done

EndIf /;
;;;get the mcm menu page index for the npc that this instance of the effect is attached to;;;

Int i

i = 0

While i < dz_mcm.Pages.Length

  If dz_mcm.teammate_ref_slot[i] == Target      ;compare this NPC with the MCM menu pages

  npc_index = i             ;we have found the page index

  EndIf

  i = i + 1

EndWhile
EndEvent


Event OnEffectFinish(Actor Target, Actor Caster)
;;;do we need to re-apply this ability or allow the effect to finish?;;;

;/ If dz_mcm.activate_toggle[npc_index] == False      ;check if this NPC has auto-changing ativated in the MCM menu

  Return               ;and return, no more to do

EndIf /;
utility.wait(2)              ;if auto-changing is activated then wait a little



target.addspell(dz_outfits_meta_ability_spell)      ;re-apply theis ability and any other abilities/spells

;target.addspell(dz_outfits_ability_spell)

EndEvent

 

 

 

and this is the script that tries to add it:

 

 

Scriptname dz_grant_outfits_ability_effect_script Extends ActiveMagicEffectSpell  Property  dz_outfits_ability_spell  Auto

Spell Property dz_outfits_meta_ability_spell Auto

 Event OnEffectStart(Actor Target, Actor Caster)

Actor ActorRef = Target

  ActorRef.AddSpell(dz_outfits_ability_spell)
 
  ActorRef.AddSpell(dz_outfits_meta_ability_spell)

EndEvent

 

 

 

both magiceffects are script,constant effect, target actor, each has the right script and the properties set, the only difference (apart from name and script) is the the dz_outfits_meta_ability_effect has a blue persistent hit effect art and shader

 

as I said, in the console:

player.addspell SPELLID

 

and clicking on Serana:

addspell SPELLID

 

gives both player and Serana the blue aura and checking in the console with hassspell shows that they both have the spell that won't get added by script

 

The REALLY annoying thing is that this spell was working fine about five hours ago, so what have I missed, I must have changed something, but what?

 

Any suggestions

 

 

diziet

Link to comment
Share on other sites

The first script has a semi-colon in front of the second AddSpell line. This turns it into a comment and does not get compiled. This may be a possible cause.

The second script appears to be fine aside from a possible copy / paste error where the first spell property ended up on the ScriptName line.

 

Unsure to be honest. Do you have any errors in your papyrus log related to this?

Link to comment
Share on other sites

The first script has a semi-colon in front of the second AddSpell line. This turns it into a comment and does not get compiled. This may be a possible cause.

The second script appears to be fine aside from a possible copy / paste error where the first spell property ended up on the ScriptName line.

 

Unsure to be honest. Do you have any errors in your papyrus log related to this?

The first script is not the one granting the abilities - i.e. adding the spells; the commented out addspell is a possible future feature,

And yes a copy paste error:)

 

Never thought of the log, and indeed there are some lines about one of the spells (effects)

[08/22/2020 - 01:15:18AM] warning: Property dz_outfits_ability_effect on script dz_grant_outfits_ability_effect_script attached to Active effect 4 on (00000014) cannot be initialized because the script no longer contains that property

[08/22/2020 - 01:15:18AM] Error: Cannot add a None spell to the actor

stack:

[ (00000014)].Actor.AddSpell() - "<native>" Line ?

[None].dz_grant_outfits_ability_effect_script.OnEffectStart() - "dz_grant_outfits_ability_effect_script.psc" Line 19

 

the warning I'm not sure about since the spell with that effect is the spell that _does_ get added;

line 19 of dz_grant_outfits_ability_effect_script.psc is the line that tries to add the spell that doesn't get added, note: the scripts posted above have lots of comments stripped out for easier reading so I shall repeat line 19 here:

ActorRef.AddSpell(dz_outfits_meta_ability_spell)

Link to comment
Share on other sites

[08/22/2020 - 01:15:18AM] warning: Property dz_outfits_ability_effect on script dz_grant_outfits_ability_effect_script attached to Active effect 4 on  (00000014) cannot be initialized because the script no longer contains that property

Pretty straightforward here. The property dz_outfits_ability_effect has been removed from the script but not the record holding the script. Reopen the record in the Creation Kit and access the properties window for the script (without doing anything else). Once you close the properties window you should notice the CK put an * by the file name at the top left indicating that a record has changed and the plugin has not yet been saved. Even tho you yourself did nothing the CK updates the record's list of properties to match those on the current version of the script.

[08/22/2020 - 01:15:18AM] Error: Cannot add a None spell to the actor
stack:
[ (00000014)].Actor.AddSpell() - "<native>" Line ?
[None].dz_grant_outfits_ability_effect_script.OnEffectStart() - "dz_grant_outfits_ability_effect_script.psc" Line 19

Another straightforward error. The script tries to add a spell but there is no data indicating what spell to add. Double check your properties are correctly assigned and test on a new game.

 

 

Link to comment
Share on other sites

Well I found the answer, it's not the script or the esp in the CK. It's me, I'm an idiot! A few days ago I was experimenting with a test esp, and somehow, I managed to forward some records form this current esp into the test esp, and then forget that I had left it enabled in Vortex. Of course there weren't supposed to be any forwared records so I never thought about it.

But as soon as I disabled the test esp, bingo! My current script to add two spells worked.

 

To all those who responded, thankyou. I'm well aware that I post quite a lot in this forum and so far. no one has got annoyed with me, told me to let someone else have a go!, or otherwise encourage me to slow the post rate:) Thankyou all, including those who just read posts that don't actually need an answer!

 

I've been doing the internet for some decades now, and this place is incredibly chilled compared to some forums I've read.

 

Again, thankyou:)

 

 

diziet

Link to comment
Share on other sites

  • Recently Browsing   0 members

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