Jump to content

Need help with a simple code, please :)


Recommended Posts

I'm trying to add a "comedown effect" to skooma. I went through the Hello World tutorials on the Wiki and the Lokir's dungeon tutorial (the scripting part) and I thought I had enough figured out to be able to do simple things. But no. haha

 

I've attached a picture of my script and the warnings/failure compiling message for reference.

 

Basically, whenever the health effect from the skooma ends, I want the script to run and cast the "comedown" spell on the player. I tried to write a script for that but whenever I try to compile it, I get errors.

 

Let me know what you think because I'm so clueless. This is literally my first day of scripting and my second week or so of modding in general, so any tutorials or advice or anything would be awesome.

 

Also, for people that can't see the attached picture for whatever reason:

 

My script:

 

Scriptname GSDComedownEffectsScript Extends ActiveMagicEffect

Spell property comedownspell Auto
Event OnEffectFinish(Actor akTarget, Actor akCaster)
comedownspell.Cast(Self, Self)
EndEvent
The warnings I get are:
type mismatch on parameter1 (did you forget a cast?)
type mismatch on parameter2 (did you forget a cast?)

 

Link to comment
Share on other sites

Your problem is the usage of "self" intending it to be some object reference when it is in the context of a magic effect. In this case Self refers to the instance of the script on the magic effect not an object reference. Depending on the stage of the effect shutdown it could even have a None value. Using Self in OnEffectFinish has race condition concerns. See this page notes about that https://www.creationkit.com/index.php?title=OnEffectFinish_-_ActiveMagicEffect

 

In the scenario you're using it you wouldn't want to use self to refer to an actor anyway. You'd want that function call to use the passed parameters akTarget and akCaster. Try this:

 

comedownspell.cast(akCaster, akTarget)
Link to comment
Share on other sites

 

Your problem is the usage of "self" intending it to be some object reference when it is in the context of a magic effect. In this case Self refers to the instance of the script on the magic effect not an object reference. Depending on the stage of the effect shutdown it could even have a None value. Using Self in OnEffectFinish has race condition concerns. See this page notes about that https://www.creationkit.com/index.php?title=OnEffectFinish_-_ActiveMagicEffect

 

In the scenario you're using it you wouldn't want to use self to refer to an actor anyway. You'd want that function call to use the passed parameters akTarget and akCaster. Try this:

comedownspell.cast(akCaster, akTarget)

 

It compiled!!! =D Thank you SO MUCH!! You're awesome! I definitely have so much to learn about scripting...

 

Edit: I just checked it in the game and it's working perfectly! =) Thanks again!

Edited by stacymichelle084
Link to comment
Share on other sites

  • Recently Browsing   0 members

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