Scripting Help - Souls Summoning Overhaul Menu

Post » Fri May 24, 2013 10:54 pm

Alright so as a programmer myself I understand how hard it is to read another person's code and help them out so I will do my best to make it easier for everybody here to understand.

Here is the code

Spoiler

Whats the point of the program?

The point of the program is to open the soul summoning menu when a summon spell is cast. What it will do is check the player's inventory for soul gems filled soul gems. If any are available the menu will open up before casting the creature. However, if no soul gems or no filled soul gems are availabe the spell will be interrupted (not cast). I know for a fact that the menu works, I tested it with an activator.

Whats the problem?

For some reason when I cast the summon spell "Conjure Familiar" which I attached the script to its magic effect, the summon will still be cast with or without the soul gems but the notification will still appear when the player has no soul gems. Also when the player does have soul gems the menu does not pop up.

My thoughs on this.

Well honestly I cannot find any flaws with the code, so it might be a logic error. However, I may have wrongly attached the script or it has something to do with the soulsMenu function.

Any help you give will be greatly appreciated and when the mod goes up you will have your username on the credits for your support and advice.

P.S I am new to this forum so if I have posted incorrectly please let me know as well.

User avatar
Tessa Mullins
 
Posts: 3354
Joined: Mon Oct 22, 2007 5:17 am

Post » Sat May 25, 2013 12:20 pm

Make these changes:
Replace all Game.GetPlayer() functions with "player", this is a performance wise change.
Write "Else" instead of "ElseIf(akTarget.GetItemCount...)"
Oh, and vendoritemsoulgem refers to the empty gems too, I think.
User avatar
Teghan Harris
 
Posts: 3370
Joined: Mon Mar 05, 2007 1:31 pm

Post » Fri May 24, 2013 10:10 pm

In the OnEffectStart Event, the spell has already been cast so InterruptCast does nothing. Also, for your soulsmenu, it looks like you get stuck in a while loop unless the player chooses to quit? I can't see any reason why you need the while menuActive and if button != -1, since those conditions will always be true at the start of your function.

User avatar
Liv Staff
 
Posts: 3473
Joined: Wed Oct 25, 2006 10:51 pm

Post » Sat May 25, 2013 1:26 pm

Wow First off, thank you for the quick replies I will start applying both of your fixes straight away!

@Templar - Edit didn't realize you used a variable to hold the player value. Ok that's a lot to fix but by player you mean Game.player rather than game.getPlayer() right?

- I guess I will create my own keyword then and add it to the filled gems

@mojo22 - The while loop is to keep the player from selecting one option and then getting kicked out of the menu. So it is set up like that so that a quit button needs to be selected in order to quit. Though I will take a look at it and see if I can code it better.

Also is there an event that will check the spell before it is cast?

User avatar
ChloƩ
 
Posts: 3351
Joined: Sun Apr 08, 2007 8:15 am

Post » Sat May 25, 2013 9:48 am

Is there an event that checks before the spell is cast? Because I cannot seem to find it.

User avatar
naana
 
Posts: 3362
Joined: Fri Dec 08, 2006 2:00 pm

Post » Sat May 25, 2013 11:59 am

You don't need to check before, but just finish the spell.
User avatar
jessica sonny
 
Posts: 3531
Joined: Thu Nov 02, 2006 6:27 pm

Post » Sat May 25, 2013 8:36 am

Thanks

User avatar
TIhIsmc L Griot
 
Posts: 3405
Joined: Fri Aug 03, 2007 6:59 pm

Post » Fri May 24, 2013 9:45 pm

RegisterForAnimationEvent may be a way to detect something before a spell cast. However... you could try something like this...

Scriptname _test_testscript extends ActiveMagicEffectActor Property PlayerRef  Auto  Message Property soulsMessage1  Auto  FormList Property SoulsEmpty Auto ;0 = petty, 1 = lesser, 2 = common, etcFormList Property SoulsFilled Auto ;0 = petty, etcEvent onEffectStart(Actor akTarget, Actor akCaster);Check for Soul Gems, if none in inventory interrupt spell    If(akTarget == PlayerRef)        If(akTarget.GetItemCount(SoulsEmpty) < 1)            Debug.Notification("I need soul gems in order to summon my creatures . . .")            ;SomeMessage.Show() ???            Dispel() ;will kill your summon automatically        Else ;If(akTarget.GetItemCount(VendorItemSoulGem) >= 1)            Game.DisablePlayerControls(False, False, False, False, False, True)            Game.EnablePlayerControls(False, False, False, False, False, True)            int button = soulsMessage1.Show()            if button == 6 ;is option 6 to cancel the cast?                Dispel()            else                PlayerRef.RemoveItem(SoulsEmpty.GetAt(button))                PlayerRef.AddItem(SoulsFilled.GetAt(button))             endIf        endIf    endIfendEvent

I think this is what you're trying to accomplish. See if you can add conditions to your souls menu, so the buttons only appear if the item count of the empty soul gem is greater than 0.

You could also try the Cast function instead. Have the spell you cast only run a script, and then cast the spell if the right conditions are met. That could get a bit messy though.

User avatar
James Baldwin
 
Posts: 3366
Joined: Tue Jun 05, 2007 11:11 am

Post » Sat May 25, 2013 6:23 am

Thank you guys so much for all of the help you both have given me, I will apply your advice to my code and will see what happens. When this mod is completed conscider yourselves on the credits for support.

User avatar
Yonah
 
Posts: 3462
Joined: Thu Aug 02, 2007 4:42 am


Return to V - Skyrim