Jump to content

[LE] Visual effect playing and keywords


Recommended Posts

Here's the script attached to an ability:

Scriptname AceScript extends ActiveMagicEffect ;tried actor too


Keyword Property MyKeyword Auto
VisualEffect Property MyEffect  Auto  

Event OnSpellCast(Form akSpell)

	Spell SpellCast = akSpell as Spell
	MyEffect.Play(Game.GetPlayer(), 3) ;doesn't fire, didn't expect it to

	If SpellCast.HasKeyword(MyKeyword)
		
		MyEffect.Play(Game.GetPlayer(), 3) ;doesn't fire
		Debug.Notification("If fired") ;doesn't fire

	EndIf

EndEvent

Not sure why nothing is firing. Properties are filled. I'm using a MagicDamageFire keyword and testing with the default spell, flames. I'm aware that concentration spells only call the event once. When I remove the keyword check, the notification fires so that's not the issue. I think it might be a syntax issue but I'm not sure since I had a similar script and the visual effect played on that.

 

Link to comment
Share on other sites

First, thanks for testing! I checked the properties, they're filled. MagicDamageFire and my custom visual effect which I tested separately before using.

I've tested on a save that has seen the mod but not the ability, and I've tested on a fresh COC character. My MGEF has No duration, no magnitude, no area checked. My ability is pretty much the defaults.

Link to comment
Share on other sites

I think failure to explain my recent suggestion of OnSpellCast is why its taken this long for you to get this working, for that I'm sorry.

 

This could still be not what you want though, and my above testing did not use an ability, but I tried that today and just as with you, I got no where with that.

 

You can make a quest, place the player in a referencealias, attach that script(extend it to ReferenceAlias) to the player's alias, and the Event will now fire as expected and consistently.

 

Other things making this a bit annoying is sheer lack of alternative ways for cast detection.

Edited by Rasikko
Link to comment
Share on other sites

It's taking me forever to do something I thought would be simple but it's not your fault. Why doesn't it work though? It fires the notification 100% of the time when I remove the keyword condition.

I'll try that way, I've never actually used a quest like that though. There is another method and that's detecting animations.

 

THANK YOU!!!

Just so I know I haven't messed anything up, I left everything as the default settings except I unchecked run once. Did I need to do anything else?

Also, what's the most efficient way of getting the script to fire only when I want it? I could just check if the actor has the ability from earlier but if there's a better way I'd like to know.

Edited by Elias555
Link to comment
Share on other sites

I don't know why it didn't work with the keyword check(for me it just didn't work at all), and without knowing what breaks it, it can't be known how to fix it.

 

Basically any logical thing of "If it has this, do that, otherwise do this instead". Checking if the actor has ability is just one of many ways to control the flow of a script - it's not an inefficient method either. If you want to know if an actor has a spell, this would be the go-to route.

 

It's easy to totally lock a script out too with states, or booleans. You could check if the actor is level 10, and then send the script to a state that has no event in it.

Link to comment
Share on other sites

Well, I thought about that a long time ago, but no one has reported it to be anything like its OnHit counterpart, where if several spells cast in short order will create stack dumps.

I don't know anything about this, could you go into more detail?

Link to comment
Share on other sites

https://www.creationkit.com/index.php?title=User:DavidJCobb/Stack_dumping

 

I actually think this isn't a problem for OnSpellCast, because the player has control over how often they cast spells actually, and spells need time to fire anyway.

 

And on that note, I have to say, don't worry too much about performance - I see a few folks doing that and I feel they end up limiting themselves due to not knowing the tolerable limits of papyrus. There are best practices you can make a habit of(like if you need a getxxxx() function several times in a script, and you know its value is not going to change, assign it to a variable. A personal preference of mine but I'd stay far away from "convenience" functions like GetActorRef,which is GetActorReference, which is GetReference as Actor.. just use the cast version).

 

Also if you know for sure a thing you want to do can be done entirely with a magic effect/quest(no script, lots of neat things can be done with aliases), condition function, prefer that over a script.

 

Generally avoid long running loops, and make sure the logic allows them to actually end.

 

One other thing, abilities check conditions every second.

 

And I think this might shed light on a few things: https://www.creationkit.com/index.php?title=Threading_Notes_(Papyrus)

 

All in all, continue with what you're doing.

Edited by Rasikko
Link to comment
Share on other sites

  • Recently Browsing   0 members

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