Weird script behaviour: Message Box doesn't show up in simil

Post » Fri Nov 16, 2012 11:22 pm

Hi all,

I am currently working on a spell which should create a necromantic artefact that, as final result, should allow the character to gain skill advances by absorbing knowledge directly from the spirits of the dead. However, the spell requires to define the object reference of the specific skull and link the dead creature's attributes to it, but my current problem is that the custom activation message box which I made didn't show up...and I am using the same workaround used in another of my creations (Daedric Mystery Box)...now I'll post both scripts and I'd ask you the kindness to look at them and, if you have any idea of what could have gone wrong, please tell me... :(

Daedric Mystery Box (works like a charm...)

Scriptname VAoNActivateDaedricMysteryBox extends ObjectReference  import GlobalVariableEvent OnInit()    Self.BlockActivation()EndEventEvent OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer)        Self.BlockActivation()EndEventEvent OnActivate(ObjectReference akActionRef)    acActivator = akActionRef as Actor     intActivatorSpeechcraft = (acActivator.GetActorValue("speechcraft") as int)    iCurrentSoulEnergy =  (glSoulEnergy.GetValue() as int)    intHeartSacrificed = (glHumanHeartSacrifice.GetValue() as int)    intDaedricCoinsSacrificed = (glDaedricCoinSacrifice.GetValue() as int)    intActivatorKilledPersons = Game.QueryStat("People Killed")    intActivatorMurders = Game.QueryStat("Murders")	  GotoState("ActivationMenu")	  ReturnEndEventState ActivationMenuEvent OnBeginState()    int iPushedButton    iPushedButton = msgDaedricBoxMenu[0].Show()    if iPushedButton == 0       GotoState("BoxActivated")       Return    elseif iPushedButton == 1       acActivator.AddItem(Self, 1)       GotoState("BoxClosed")       Return    elseif iPushedButton == 2       GotoState("ChargeBox")       Return      elseif iPushedButton == 3       GotoState("OfferSacrifice")       Return         elseif iPushedButton == 4       acActivator.AddItem(bkInstructions, 1)       GotoState("BoxClosed")       Return    elseif iPushedButton == 5       GotoState("Configure")       Return         EndifEndEventEndStateState BoxActivatedEvent OnBeginState()    int iPushedButton    int iCharacterLevel = acActivator.GetLevel()    intHeartSacrificed = (glHumanHeartSacrifice.GetValue() as int)    intDaedricCoinsSacrificed = (glDaedricCoinSacrifice.GetValue() as int)	   intOblivionFavor = ((intDaedricCoinsSacrificed * 100) + (intHeartSacrificed * 1000) + (intActivatorKilledPersons * 5) + (intActivatorMurders * 10))/iCharacterLevel as int    int intWealth	   If  iWealthFactor == 0		   iWealthFactor = 100	  endif    If iCurrentSoulEnergy == 0      Debug.Notification("The box has no soul energy.")      Debug.Notification("Recharge it with soul gems.")		 GotoState("ActivationMenu")       Return	  else           Debug.Notification("Your current Oblivion Favor is " + intOblivionFavor )           iPushedButton = msgDaedricBoxMenu[3].Show()    		 if iPushedButton == 0		    if ((acActivator.GetItemCount(moMiscellaneousObject[0])== 0) && (intDaedricCoinsSacrificed == 0))          Debug.Notification("This service require at least 1 daedric coin as payment.")   		    else          Debug.Notification("The Daedra Princes fill your soul with dragon spirit...")             intWealth = ((intOblivionFavor/(iWealthFactor*10)) as int)          acActivator.ModActorValue("DragonSouls", intWealth)          iCurrentSoulEnergy-=1			    glSoulEnergy.SetValue(iCurrentSoulEnergy)          if     (intDaedricCoinsSacrificed == 0)                   acActivator.RemoveItem(moMiscellaneousObject[0], 1)          endif   		 glHumanHeartSacrifice.SetValue(0)    			   glDaedricCoinSacrifice.SetValue(0)   		  GotoState("BoxClosed")           Return        endif          elseif iPushedButton == 1		    if ((acActivator.GetItemCount(moMiscellaneousObject[0])== 0) && (intDaedricCoinsSacrificed == 0))          Debug.Notification("This service require at least 1 daedric coin as payment.")   		    else          intWealth =  ((intOblivionFavor * intActivatorSpeechcraft)/(iWealthFactor*100)) as int          Debug.Notification("The Daedra Princes grants you powerful artifacts...")      		  acActivator.AddItem(ptOblivionTear,  intWealth)          iCurrentSoulEnergy-=1			   glSoulEnergy.SetValue(iCurrentSoulEnergy)          if     (intDaedricCoinsSacrificed == 0)                   acActivator.RemoveItem(moMiscellaneousObject[0], 1)          endif   		 glHumanHeartSacrifice.SetValue(0)    			   glDaedricCoinSacrifice.SetValue(0)   		  GotoState("BoxClosed")           Return        endif      elseif iPushedButton == 2		    if ((acActivator.GetItemCount(moMiscellaneousObject[0])== 0) && (intDaedricCoinsSacrificed == 0))          Debug.Notification("This service require at least 1 daedric coin as payment.")   		    else          intWealth =  ((intOblivionFavor * intActivatorSpeechcraft * 10)/iWealthFactor) as int          Debug.Notification("The Daedra Princes fill your pockets with gold...")      		  acActivator.AddItem(moMiscellaneousObject[1],  intWealth)          iCurrentSoulEnergy-=1			   glSoulEnergy.SetValue(iCurrentSoulEnergy)          if     (intDaedricCoinsSacrificed == 0)                   acActivator.RemoveItem(moMiscellaneousObject[0], 1)          endif   		 glHumanHeartSacrifice.SetValue(0)    			   glDaedricCoinSacrifice.SetValue(0)   		  GotoState("BoxClosed")           Return                endif		 elseif iPushedButton == 3		 GotoState("ActivationMenu")       Return      endif	  endif	   EndEventEndStateState ChargeBoxEvent OnBeginState()    Debug.Notification("The soul energy of the box is of " + iCurrentSoulEnergy + " units.")    int iPushedButton	   iPushedButton = msgDaedricBoxMenu[1].Show()        if (iPushedButton == 6)		 GotoState("ActivationMenu")       Return	  else        if (acActivator.GetItemCount(sgSoulGems[iPushedButton]) == 0)           Debug.Notification("You don't have a filled soul gem of that size.")              Debug.Notification("Retry...")   		  GotoState("ChargeBox")           Return   	    else           iCurrentSoulEnergy+= intSoulEnergyContent[iPushedButton]           acActivator.RemoveItem(sgSoulGems[iPushedButton], 1)           glSoulEnergy.SetValue(iCurrentSoulEnergy)   		   Debug.Notification("The soul energy of the box is of " + iCurrentSoulEnergy + " units.")           GotoState("ActivationMenu")           Return           endif    endifEndEventEndStateState OfferSacrificeEvent OnBeginState()    int iPushedButton    int iOffer    Debug.Notification("You have sacrificed " +  intHeartSacrificed + " human hearts and " +intDaedricCoinsSacrificed + " daedric coins." )	   iPushedButton = msgDaedricBoxMenu[2].Show()        if iPushedButton == 0   	   iOffer = acActivator.GetItemCount(ingHeart)        if (iOffer == 0)           Debug.Notification("You don't have human hearts to sacrifice...")           Debug.Notification("Retry...")	         GotoState("OfferSacrifice")           Return	       else           Debug.Notification("You have sacrificed " + iOffer + " human hearts.")           acActivator.RemoveItem(ingHeart, iOffer)           intHeartSacrificed += iOffer           iOffer = 0   		   glHumanHeartSacrifice.SetValue(intHeartSacrificed)                endif	    elseif  iPushedButton == 1   	   iOffer = acActivator.GetItemCount(moMiscellaneousObject[0])        if (iOffer == 0)           Debug.Notification("You don't have daedric coins to sacrifice...")           Debug.Notification("Retry...")	         GotoState("OfferSacrifice")           Return	       else           Debug.Notification("You have sacrificed " + iOffer + " daedric coins.")           acActivator.RemoveItem(moMiscellaneousObject[0], iOffer)           intDaedricCoinsSacrificed += iOffer           iOffer = 0   		   glDaedricCoinSacrifice.SetValue(intDaedricCoinsSacrificed)                endif	    elseif  iPushedButton == 2       GotoState("ActivationMenu")       Return       endifEndEventEndStateState ConfigureEvent OnBeginState()    int iPushedButton    Debug.Notification("The current wealth factor is " + iWealthFactor)	   iPushedButton = msgDaedricBoxMenu[4].Show()         iWealthFactor = iWealthOptions[iPushedButton]        Debug.Notification("The wealth factor changed to " + iWealthFactor)    	   GotoState("ActivationMenu")    Return   EndEventEndStateState BoxClosedEndStateSoulGem[] Property sgSoulGems  Auto  GlobalVariable Property glSoulEnergy  Auto  GlobalVariable Property glDaedricCoinSacrifice  Auto  GlobalVariable Property glHumanHeartSacrifice  Auto  Int Property iCurrentSoulEnergy  Auto   Message[] Property msgDaedricBoxMenu  Auto  Book Property bkInstructions  Auto  Int Property intActivatorSpeechcraft  Auto  Int Property intActivatorKilledPersons  Auto  Int Property intActivatorMurders  Auto  Int Property intOblivionFavor  Auto  Int Property intHeartSacrificed  Auto  Int Property intDaedricCoinsSacrificed  Auto  Actor Property acActivator  Auto  MiscObject[] Property moMiscellaneousObject  Auto  Potion Property ptOblivionTear  Auto  Int[] Property intSoulEnergyContent  Auto  Ingredient Property ingHeart  Auto  Int Property iWealthFactor  Auto  Int[] Property iWealthOptions  Auto   


Skull of the Enslaved Soul (doesn't work!!)

Scriptname VAoNInteractWithEnslavedSoul extends ObjectReference  Import ActorImport ActorBaseimport globalvariableImport Mathimport messageEvent OnInit()    Self.BlockActivation()EndEventEvent OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer)  Self.BlockActivation()If ((akOldContainer!= Game.GetPlayer()) && (akNewContainer == None) && (blSoulImprisoned != True))       int iCount = 0    obSpecificSkull = self       actor acActor = akOldContainer as Actor    actorbase abActor = acActor.GetLeveledActorBase()    strSoulClass = (abActor.GetClass()).GetName() as string    strSoulRace = (abActor.GetRace()).GetName() as string    strSoulName = abActor.GetName() as string    iSoulLevel = acActor.GetLevel()    While (iCount < flSoulStatisticValue.Length)         flSoulStatisticValue[iCount] = acActor.GetBaseActorValue(strSoulStatisticLabel[iCount]) as float	 EndWhile	 iCount = 0    blSoulImprisoned = Trueendif  endEventEvent OnActivate(ObjectReference akActionRef)acActivator = akActionRef as actorstring strVariant = "th"If (iSoulLevel == 1)    strVariant = "st"elseif (iSoulLevel == 2)    strVariant = "nd"elseif (iSoulLevel == 3)    strVariant = "rd"EndifDebug.Notification("This skull holds the spirit of " +  strSoulName + " ( " + iSoulLevel + strVariant +" level " + strSoulRace + " " + strSoulClass + " )")int iCount = 0iActivatorLevel = acActivator.GetLevel()While (iCount < flSoulStatisticValue.Length)       glSoulGlobalStatistic[iCount].SetValue(flSoulStatisticValue[iCount])		 flActivatorStatisticValue[iCount] = acActivator.GetBaseActorValue(strSoulStatisticLabel[iCount]) as floatEndWhileDebug.Notification("The spirit has been fully retrieved...")iCount = 0iMenuLevel = 0iBranchSector = 0flMemoryAbsorptionRatio = flActivatorStatisticValue[7] * (iSoulLevel/iActivatorLevel) as floatif (flMemoryAbsorptionRatio > 1)    flMemoryAbsorptionRatio = 1endifDebug.Notification("You absorb statistics from the soul at a 1:" + floor ((1/flMemoryAbsorptionRatio)) + " ratio.")int iButtonPushed = msgSkullMenuOptions[0].Show()If (iButtonPushed == 0)    GoToState("ActivateSkull")    Returnelseif (iButtonPushed == 1)acActivator.AddItem(Self, 1)    GoToState("DeactivateSkull")    ReturnEndifendEventstate ActivateSkullEvent OnBeginState()iMenuLevel = 1iBranchSector = 0int iButtonPushed = msgSkullMenuOptions[1].Show()If (iButtonPushed == 0)    GoToState("ImproveAttribute")    Returnelseif (iButtonPushed == 1)    GoToState("SelectSkillGroup")    Returnelseif (iButtonPushed == 2)    GoToState("DeactivateSkull")    ReturnEndifendEventendStatestate ImproveAttributeEvent OnBeginState()iMenuLevel = 2iBranchSector = 0int iButtonPushed = msgSkullMenuOptions[2].Show()If (iButtonPushed < 3)   flSkillBoost = (floor((flSoulStatisticValue[iButtonPushed] -  flActivatorStatisticValue[iButtonPushed])* flMemoryAbsorptionRatio)) as float   if flSkillBoost > flAttributeCapPerUse	   flSkillBoost = flAttributeCapPerUse   endif   strStatisticToChange = strSoulStatisticLabel[iButtonPushed]    Debug.Notification("The soul has " + strSoulStatisticLabel[iButtonPushed] + " : " + (flSoulStatisticValue[iButtonPushed]  as int))    Debug.Notification("You can increase this trait by + " + (flSkillBoost as int))    GoToState("ConfirmChange")    Returnelseif (iButtonPushed == 3)    GoToState("ActivateSkull")    ReturnEndifEndEventendStatestate SelectSkillGroupEvent OnBeginState()iMenuLevel = 2iBranchSector = 1int iButtonPushed = msgSkullMenuOptions[3].Show()If (iButtonPushed == 0)    GoToState("ImproveCombatSkill")    Returnelseif (iButtonPushed == 1)    GoToState("ImproveMagicSkill")    Returnelseif (iButtonPushed == 2)    GoToState("ImproveStealthSkill")    Returnelseif (iButtonPushed == 3)    GoToState("ActivateSkull")    ReturnEndifEndEventendStatestate ImproveCombatSkillEvent OnBeginState()iMenuLevel = 3iBranchSector = 0int iButtonPushed = msgSkullMenuOptions[4].Show()int iSelectionCode = iButtonPushed +  iCombatMenuAdj[iButtonPushed]If (iButtonPushed < 6)   flSkillBoost = (floor((flSoulStatisticValue[iSelectionCode] -  flActivatorStatisticValue[iSelectionCode])* flMemoryAbsorptionRatio)) as float   if flSkillBoost > flSkillCapPerUse	   flSkillBoost = flSkillCapPerUse   endif   strStatisticToChange = strSoulStatisticLabel[iSelectionCode]    Debug.Notification("The soul has " + strSoulStatisticLabel[iSelectionCode] + " : " + (flSoulStatisticValue[iSelectionCode]  as int))    Debug.Notification("You can increase this trait by + " + (flSkillBoost as int))    GoToState("ConfirmChange")    Returnelseif (iButtonPushed == 6)    GoToState("SelectSkillGroup")    ReturnEndifEndEventendStatestate ImproveMagicSkillEvent OnBeginState()iMenuLevel = 3iBranchSector = 1int iButtonPushed = msgSkullMenuOptions[5].Show()int iSelectionCode = iButtonPushed +  iMagicMenuAdj[iButtonPushed]If (iButtonPushed < 6)   flSkillBoost = (floor((flSoulStatisticValue[iSelectionCode] -  flActivatorStatisticValue[iSelectionCode])* flMemoryAbsorptionRatio)) as float   if flSkillBoost > flSkillCapPerUse	   flSkillBoost = flSkillCapPerUse   endif   strStatisticToChange = strSoulStatisticLabel[iSelectionCode]    Debug.Notification("The soul has " + strSoulStatisticLabel[iSelectionCode] + " : " + (flSoulStatisticValue[iSelectionCode]  as int))    Debug.Notification("You can increase this trait by + " + (flSkillBoost as int))    GoToState("ConfirmChange")    Returnelseif (iButtonPushed == 6)    GoToState("SelectSkillGroup")    ReturnEndifEndEventendStatestate ImproveStealthSkillEvent OnBeginState()iMenuLevel = 3iBranchSector = 2int iButtonPushed = msgSkullMenuOptions[6].Show()int iSelectionCode = iButtonPushed +  iStealthMenuAdj[iButtonPushed]If (iButtonPushed < 6)   flSkillBoost = (floor((flSoulStatisticValue[iSelectionCode] -  flActivatorStatisticValue[iSelectionCode])* flMemoryAbsorptionRatio)) as float   if flSkillBoost > flSkillCapPerUse	   flSkillBoost = flSkillCapPerUse   endif   strStatisticToChange = strSoulStatisticLabel[iSelectionCode]    Debug.Notification("The soul has " + strSoulStatisticLabel[iSelectionCode] + " : " + (flSoulStatisticValue[iSelectionCode]  as int))    Debug.Notification("You can increase this trait by + " + (flSkillBoost as int))    GoToState("ConfirmChange")    Returnelseif (iButtonPushed == 6)    GoToState("SelectSkillGroup")    ReturnEndifEndEventendStatestate ConfirmChangeEvent OnBeginState()int iButtonPushed = msgSkullMenuOptions[7].Show()int iSourceMenu = (iMenuLevel * 10) + iBranchSectorIf (iButtonPushed == 0)GoToState("ChangeStatistic")Return   elseif (iButtonPushed == 1)    if (iMenuLevel == 20)   	 GoToState("ImproveAttribute")       	 Return       elseif (iMenuLevel == 30)   	 GoToState("ImproveCombatSkill")       	 Return       elseif (iMenuLevel == 31)   	 GoToState("ImproveMagicSkill")       	 Return        elseif (iMenuLevel == 32)   	 GoToState("ImproveStealthSkill")       	 Return       else       Debug.Notification("Original menu couldn't be found...")   	 GoToState("ActivateSkull")       	 Return       endifEndIfEndEventendStatestate ChangeStatisticEvent OnBeginState()Game.AdvanceSkill(strStatisticToChange, flSkillBoost )int iNewValue = http://forums.bethsoft.com/topic/1393797-weird-script-behaviour-message-box-doesnt-show-up-in-similar-scriptswhy/(acActivator.GetBaseActorValue(strStatisticToChange)) as intDebug.Notification("Your new value for " + strStatisticToChange + " is " +   iNewValue + ".)")GoToState("DeactivateSkull")ReturnEndEventendStatestate DeactivateSkullEvent OnBeginState()EndEventendStateObjectReference Property obSpecificSkull  Auto  Float[] Property flSoulStatisticValue  Auto  String[] Property strSoulStatisticLabel  Auto  String Property strSoulName  Auto  String Property strSoulClass  Auto  Bool Property blSoulImprisoned  Auto  String Property strSoulRace  Auto  Actor Property acActivator  Auto  Message[] Property msgSkullMenuOptions  Auto  GlobalVariable[] Property glSoulGlobalStatistic  Auto  Float[] Property flActivatorStatisticValue  Auto  Float Property flMemoryAbsorptionRatio  Auto  Int Property iSoulLevel  Auto  Int Property iActivatorLevel  Auto  Int Property iMenuLevel  Auto  String Property strStatisticToChange  Auto  Float Property flSkillBoost  Auto  Int Property iBranchSector  Auto  Int[] Property iCombatMenuAdj  Auto  Int[] Property iMagicMenuAdj  Auto  Int[] Property iStealthMenuAdj  Auto  Float Property flAttributeCapPerUse  Auto  Float Property flSkillCapPerUse  Auto  


Honestly...I had a little experience in scripting, but the way in which the above said scripts works seem to me exactly the same!

Please help...

Thanks,
Jashkar
User avatar
Pete Schmitzer
 
Posts: 3387
Joined: Fri Sep 14, 2007 8:20 am

Post » Fri Nov 16, 2012 6:44 pm

You don't seem to have actually initialized the Message[] array or assigned the indicies values. You would need something like the following in a place that would run once (perhaps your OnInit event):

Message[] msgSkullMenuOptions = new Message[8]

Or did you do this in the CK by creating the array property manually there and assigning values to it?
User avatar
Isabell Hoffmann
 
Posts: 3463
Joined: Wed Apr 18, 2007 11:34 pm

Post » Sat Nov 17, 2012 9:28 am

You don't seem to have actually initialized the Message[] array or assigned the indicies values. You would need something like the following in a place that would run once (perhaps your OnInit event):

Message[] msgSkullMenuOptions = new Message[8]

Or did you do this in the CK by creating the array property manually there and assigning values to it?

Yes...I create them manually as array property in the CK. :)

Jashkar
User avatar
Ron
 
Posts: 3408
Joined: Tue Jan 16, 2007 4:34 am

Post » Sat Nov 17, 2012 9:18 am

Ok...I found it! :P

I forgot to add the increase of counter (iCount) into the loop above...so an endless loop was generated and the script never reached the point to add the new menu.

It was a really silly reason, but honestly...well...took a really long time to find out...

Anyway, thank you a lot, Cesko... :)

Jashkar
User avatar
sam smith
 
Posts: 3386
Joined: Sun Aug 05, 2007 3:55 am


Return to V - Skyrim