Jump to content

[LE] Script Troubleshoot: Message & Refund Potion if player doesn't meet requirements


Garruski

Recommended Posts

I've made a potion that adds a perk point in exchange for 3 dragon souls - this part works, it also correctly fails to fire if the player doesn't have 3 dragon souls - but it still removes the potion and I wanted to either stop this or refund the potion with a messagebox.
So to sum it up, everything works up til the "elseIf". Can you see any issues here or do you have a workaround?
I'm on CK 64-bit and using SSE. This script is on the magic effect (MGEF)
Scriptname PerkTransferScript37G extends activemagiceffect 

magiceffect property player auto
potion property itemtoadd auto

event oneffectstart(actor akTarget, actor akActor)
 if akActor.getav("DragonSouls") >= 3
  game.getplayer().modav("DragonSouls",-3)
  game.addperkpoints(1)
  debug.notification("3 dragon souls removed")
  debug.notification("Perk point added")
 elseif akActor.getav("DragonSouls") < 3
  debug.messagebox("You need 3 dragon souls to use this")
  game.getplayer().additem(itemtoadd, 1, abSilent = true)


endif
endevent

 

Link to comment
Share on other sites

Looks like it should be working. Make sure you fill the itemtoadd property in the creation kit. Alternatively, you can change the itemtoadd name to the name of your potion and hit auto fill all under properties and it will automatically fill the property.

Link to comment
Share on other sites

Looks like it should be working. Make sure you fill the itemtoadd property in the creation kit. Alternatively, you can change the itemtoadd name to the name of your potion and hit auto fill all under properties and it will automatically fill the property.

 

Thanks, tried this and it's the same as before unfortunately. Everything compiles etc but it seems to not recognize the second half. It's either not recognizing that there are instructions for < 3 dragon souls or it's hanging up at the messagebox, or it doesn't recognize the potion as an item... No idea!

Link to comment
Share on other sites

Actually I just noticed there's a problem with your script. AkActor should be AkCaster, and you should be using akTarget instead. Try this:

 

magiceffect property player auto
potion property itemtoadd auto

event oneffectstart(actor akTarget, actor akCaster)
 if akTarget.getav("DragonSouls") >= 3
  game.getplayer().modav("DragonSouls",-3)
  game.addperkpoints(1)
  debug.notification("3 dragon souls removed")
  debug.notification("Perk point added")
 elseif akTarget.getav("DragonSouls") < 3
  debug.messagebox("You need 3 dragon souls to use this")
  game.getplayer().additem(itemtoadd, 1, abSilent = true)

endif
endevent
Link to comment
Share on other sites

Same result with this I'm afraid, which I guess is strange if akActor was wrong-

 

Someone also mentioned the "magiceffect property player auto" was unnecessary, is this true? I just inherited that from another script a while ago but it does the same thing either way

Link to comment
Share on other sites

Yes that's true, the magic effect property player is unnecessary as it's not used in the script. They probably meant to do Actor property PlayerRef auto, and use that instead of game.GetPlayer(). I'm not sure why that wouldn't be working, it should.

Link to comment
Share on other sites

Try this:

 

 

Import Game
potion property itemtoadd auto
 
event oneffectstart(actor akTarget, actor akCaster)
 if GetPlayer().getav("DragonSouls") >= 3
    getplayer().modav("DragonSouls",-3)
    addperkpoints(1)
 else
    getplayer().additem(itemtoadd, 1, True)
endif
endevent

 

 

 

Beware that, "Debug.Notifications" use and take processing time, the more of them you have in a script the more likely is for the script to malfunction on a 'MagicEffect' script, cause too much proseccing time lands when the 'MagicEffect' finishes.

 

Although this seems not to be the problem here, but it's better to use 'Messages' instead of 'Debug.Notifications'.

Edited by maxarturo
Link to comment
Share on other sites

Try this:

 

 

That's a good point, I tried yours and got the same results though. The magic effect is performing perfectly, just not the item.

 

I would say it must be something in the potion item form, but I tried a separate script with just one debug box on magic effect start and it didn't recognize that either

 

Or, it could be that the 'else' part is cancelling the effect from starting somehow, but I'm not well-versed on those issues

 

Link to comment
Share on other sites

If this is not working, then you are not doing something right or your potion is not recognized cause of something done wrong with it.


The "Else" cuts down the processing from your script, you have already check for the player's dragonsouls:

GetPlayer().getav("DragonSouls") >= 3

so, if this is not 'True' the script will automaticaly do the:

else

getplayer().additem(itemtoadd, 1, True)


By using the 'ElseIf' statement you are adding more stuff to processes.

Edited by maxarturo
Link to comment
Share on other sites

  • Recently Browsing   0 members

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