Jump to content

DOWNLOAD MODS

Are you looking for something shiny for your load order? We have many exclusive mods and resources you won't find anywhere else. Start your search now...

LEARN MODDING

Ready to try your hand at making your own mod creations? Visit the Enclave, the original ES/FO modding school, and learn the tricks of the trade from veteran modders...

JOIN THE ALLIANCE

Membership is free and registering unlocks image galleries, project hosting, live chat, unlimited downloads, & more...

Script is partially not working.


ThomasKaira
 Share

Recommended Posts

I have tried absolutely everything I can to get this particular piece of the script to trigger:


			ELSEIF(!bMage && Guardian == "Mage")

				debug.MessageBox("The Stone does not respond to your touch")

				utility.wait(2)				

				doOnce = TRUE

			ELSEIF(!bThief && Guardian == "Thief")

				debug.MessageBox("The Stone does not respond to your touch")

				utility.wait(2)				

				doOnce = TRUE

			ELSEIF(!bWarrior && Guardian == "Warrior")

				debug.MessageBox("The Stone does not respond to your touch")

				utility.wait(2)				

				doOnce = TRUE
But no matter what I try, it keeps getting skipped. The String I'm checking for is being set properly and the If statements above these three work just fine, so why do these ones never fire at all?
scriptName doomTKGuardianShrineScript extends ObjectReference


import game

import utility


String property graphVariable auto


; //which stone are we

BOOL PROPERTY bMage AUTO

BOOL PROPERTY bThief AUTO

BOOL PROPERTY bWarrior AUTO


; //list of the effects

SPELL PROPERTY pDoomMageAbility AUTO

SPELL PROPERTY pDoomThiefAbility AUTO

SPELL PROPERTY pDoomWarriorAbility AUTO

SPELL PROPERTY pDoomMageAbility2 AUTO

SPELL PROPERTY pDoomThiefAbility2 AUTO

SPELL PROPERTY pDoomWarriorAbility2 AUTO

SPELL PROPERTY pDoomMageAbility3 AUTO

SPELL PROPERTY pDoomThiefAbility3 AUTO

SPELL PROPERTY pDoomWarriorAbility3 AUTO


; //list of the messages

MESSAGE PROPERTY pDoomMageMSG AUTO

MESSAGE PROPERTY pDoomThiefMSG AUTO

MESSAGE PROPERTY pDoomWarriorMSG AUTO



; //the already have message

MESSAGE PROPERTY pDoomAlreadyHaveMSG AUTO


STRING PROPERTY Guardian AUTO




;************************************


BOOL DOONCE=TRUE

Int Response = -1


Auto State base


	EVENT onACTIVATE(OBJECTREFERENCE obj)


		; //check to see if the player is the activator and we havent already activated

		IF(doOnce && obj AS ACTOR == game.getPlayer())


			doOnce = FALSE


			; //if we already have the power and this is the stone then kick the player out

			; //if the player's stone selection is not a Charge of their guardian, kick him out

			; //if the player has already selected a Guardian and tries to take another, kick him out

			; //finally, disallow player interaction altogether if he has taken the Serpent

			IF(bMage && Guardian == "Mage")

				pDoomAlreadyHaveMSG.show()

				utility.wait(2)				

				doOnce = TRUE

			ELSEIF(bThief && Guardian == "Thief")

				pDoomAlreadyHaveMSG.show()

				utility.wait(2)				

				doOnce = TRUE

			ELSEIF(bWarrior && Guardian == "Warrior")

				pDoomAlreadyHaveMSG.show()

				utility.wait(2)				

				doOnce = TRUE

			ELSEIF(!bMage && Guardian == "Mage")

				debug.MessageBox("The Stone does not respond to your touch")

				utility.wait(2)				

				doOnce = TRUE

			ELSEIF(!bThief && Guardian == "Thief")

				debug.MessageBox("The Stone does not respond to your touch")

				utility.wait(2)				

				doOnce = TRUE

			ELSEIF(!bWarrior && Guardian == "Warrior")

				debug.MessageBox("The Stone does not respond to your touch")

				utility.wait(2)				

				doOnce = TRUE



			ELSE


				; // present them with the choice

				; // Items 1, 2, 3 == Accept, Item 4 == Decline

				IF(bMage) 


					Response = pDoomMageMSG.Show()


					IF Response == 0

						addSign1()


						SELF.playAnimation("playanim01")


						utility.wait(15)


						doOnce = TRUE


					ELSEIF Response == 1

						addSign2()


						SELF.playAnimation("playanim01")


						utility.wait(15)


						DoOnce = TRUE


					ELSEIF Response == 2

						addSign3()


						SELF.playAnimation("playanim01")


						utility.wait(15)


						doOnce = TRUE


					ELSE

						utility.wait(2)

						doOnce = TRUE

					ENDIF


				ELSEIF(bThief) 


					Response = pDoomThiefMSG.Show()


					IF Response == 0

						addSign1()


						SELF.playAnimation("playanim01")


						utility.wait(15)


						doOnce = TRUE


					ELSEIF Response == 1

						addSign2()


						SELF.playAnimation("playanim01")


						utility.wait(15)


						DoOnce = TRUE


					ELSEIF Response == 2

						addSign3()


						SELF.playAnimation("playanim01")


						utility.wait(15)


						doOnce = TRUE


					ELSE

						utility.wait(2)

						doOnce = TRUE

					ENDIF


				ELSEIF(bWarrior) 


					Response = pDoomWarriorMSG.Show()


					IF Response == 0

						addSign1()


						SELF.playAnimation("playanim01")


						utility.wait(15)


						doOnce = TRUE


					ELSEIF Response == 1

						addSign2()


						SELF.playAnimation("playanim01")


						utility.wait(15)


						DoOnce = TRUE


					ELSEIF Response == 2

						addSign3()


						SELF.playAnimation("playanim01")


						utility.wait(15)


						doOnce = TRUE


					ELSE

						utility.wait(2)

						doOnce = TRUE

					ENDIF


				ENDIF


			ENDIF


		ENDIF

	endEVENT


endState


; //FUNCTION: addSign

; //

; // adds the sign of the stone to the player

FUNCTION addSign1()

	game.AddAchievement(29)

	; // Standard signs

	IF(bMage)

		game.getPlayer().addSpell(pDoomMageAbility)

		Guardian = "Mage"

		Debug.Notification("You have taken " + Guardian)

	ELSEIF(bThief)

		game.getPlayer().addSpell(pDoomThiefAbility)

		Guardian = "Thief"

		Debug.Notification("You have taken " + Guardian)

	ELSEIF(bWarrior)

		game.getPlayer().addSpell(pDoomWarriorAbility)

		Debug.Notification("You have taken " + Guardian)

	ENDIF


	endFUNCTION


FUNCTION addSign2()

	game.AddAchievement(29)

	; // Standard signs

	IF(bMage)

		game.getPlayer().addSpell(pDoomMageAbility2)

		Guardian = "Mage"

		Debug.Notification("You have taken " + Guardian)

	ELSEIF(bThief)

		game.getPlayer().addSpell(pDoomThiefAbility2)

		Guardian = "Thief"

		Debug.Notification("You have taken " + Guardian)

	ELSEIF(bWarrior)

		game.getPlayer().addSpell(pDoomWarriorAbility2)

		Guardian = "Warrior"

		Debug.Notification("You have taken " + Guardian)

	ENDIF


	endFUNCTION


FUNCTION addSign3()

	game.AddAchievement(29)

	; // Standard signs

	IF(bMage)

		game.getPlayer().addSpell(pDoomMageAbility3)

		Guardian = "Mage"

		Debug.Notification("You have taken " + Guardian)

	ELSEIF(bThief)

		game.getPlayer().addSpell(pDoomThiefAbility3)

		Guardian = "Thief"

		Debug.Notification("You have taken " + Guardian)

	ELSEIF(bWarrior)

		game.getPlayer().addSpell(pDoomWarriorAbility3)

		Guardian = "Warrior"

		Debug.Notification("You have taken " + Guardian)

	ENDIF


	endFUNCTION



;************************************


State waiting

	;do nothing

endState


;************************************

Link to comment
Share on other sites

Hmm, total newbie at Papyrus and just a stab here, but I would guess it has something to do with the doOnce variable.

doOnce is initalized as true. If it enters the first wrapping IF statement but then never triggers any of the nested IFs it will stay false, so the next time it's called it never passes the first condition.

Is it possible it got called earlier and flipped doOnce to false?

Link to comment
Share on other sites

Also maybe structuring it like this would help make it clearer? At work and just did this in textpad real quick, but just to get the general idea:





EVENT onACTIVATE(OBJECTREFERENCE obj)


   ; //check to see if the player is the activator and we havent already activated

   IF(doOnce && obj AS ACTOR == game.getPlayer())


      doOnce = FALSE


      IF (isValidForStone())

	pDoomAlreadyHaveMSG.show()

        utility.wait(2)   	     

        doOnce = TRUE

      ELSE

        debug.MessageBox("The Stone does not respond to your touch")

        utility.wait(2)                         

        doOnce = TRUE

     ENDIF


     IF (!doOnce)

	handleStoneTouch()   

        doOnce = TRUE

     ENDIF


endEVENT


FUNCTION isValidForStone()


  IF(bMage && Guardian == "Mage")

	return true

  ELSEIF(bThief && Guardian == "Thief")

	return true

  ELSEIF(bWarrior && Guardian == "Warrior")

	return true

  ELSE

	return false

 ENDIF


EndFunction



FUNCTION handleStoneTouch()


  IF(bMage)

     Response = pDoomMageMSG.Show()

  ELSEIF(bThief)

     Response = pDoomThiefMSG.Show()

  ELSEIF(bWarrior)

     Response = pDoomWarriorMSG.Show()

  ENDIF


  IF Response == 0

    addSign1()                                        

    SELF.playAnimation("playanim01")

    utility.wait(15)

  ELSEIF Response == 1

    addSign2()

    SELF.playAnimation("playanim01")

    utility.wait(15)

  ELSEIF Response == 2

   addSign3()

   SELF.playAnimation("playanim01")

   utility.wait(15) 

  ELSE

    utility.wait(2)

  ENDIF


EndFunction


Edited by Leecarter
Link to comment
Share on other sites

Also, I noticed you forgot to set Guardian = "Warrior" in addSign1.

Another possible refactor might look something like this:



EVENT onACTIVATE(OBJECTREFERENCE obj)


   ; //check to see if the player is the activator and we havent already activated

   IF(doOnce && obj AS ACTOR == game.getPlayer())


      doOnce = FALSE


      IF (isValidForStone())

        pDoomAlreadyHaveMSG.show()

        utility.wait(2)              

        doOnce = TRUE

      ELSE

        debug.MessageBox("The Stone does not respond to your touch")

        utility.wait(2)                         

        doOnce = TRUE

     ENDIF


     IF (!doOnce)

        handleStoneTouch()   

        doOnce = TRUE

     ENDIF

  ENDIF


endEVENT


FUNCTION isValidForStone()


  IF(bMage && Guardian == "Mage")

        return true

  ELSEIF(bThief && Guardian == "Thief")

        return true

  ELSEIF(bWarrior && Guardian == "Warrior")

        return true

  ELSE

        return false

 ENDIF


EndFunction



FUNCTION handleStoneTouch()


  IF(bMage)

      Guardian = "Mage"

     Response = pDoomMageMSG.Show()

  ELSEIF(bThief)

      Guardian = "Thief"

     Response = pDoomThiefMSG.Show()

  ELSEIF(bWarrior)

     Guardian = "Warrior"

     Response = pDoomWarriorMSG.Show()

  ENDIF


  addSign(Response)

  SELF.playAnimation("playanim01")

  utility.wait(15) 

  Debug.Notification("You have taken " + Guardian)


EndFunction


FUNCTION addSign(int numSign)

   game.AddAchievement(29)


   IF (numSign == 1)

	addFirstDoomAbility()

   ELSEIF (numSign == 2)

	addSecondDoomAbility()

   ELSEIF (numSign == 3)

	addThirdDoomAbility()

   ENDIF  


ENDFUNCTION


FUNCTION addFirstDoomAbility()


   IF(bMage)

      game.getPlayer().addSpell(pDoomMageAbility)

   ELSEIF(bThief)

     game.getPlayer().addSpell(pDoomThiefAbility)

   ELSEIF(bWarrior)

     game.getPlayer().addSpell(pDoomWarriorAbility)

   ENDIF


EndFunction



FUNCTION addSecondDoomAbility()


   IF(bMage)

      game.getPlayer().addSpell(pDoomMageAbility2)

   ELSEIF(bThief)

     game.getPlayer().addSpell(pDoomThiefAbility2)

   ELSEIF(bWarrior)

     game.getPlayer().addSpell(pDoomWarriorAbility2)

   ENDIF


EndFunction



FUNCTION addThirdDoomAbility()


   IF(bMage)

      game.getPlayer().addSpell(pDoomMageAbility3)

   ELSEIF(bThief)

     game.getPlayer().addSpell(pDoomThiefAbility3)

   ELSEIF(bWarrior)

     game.getPlayer().addSpell(pDoomWarriorAbility3)

   ENDIF


EndFunction



Edited by Leecarter
Link to comment
Share on other sites

Hmm, total newbie at Papyrus and just a stab here, but I would guess it has something to do with the doOnce variable.

doOnce is initalized as true. If it enters the first wrapping IF statement but then never triggers any of the nested IFs it will stay false, so the next time it's called it never passes the first condition.

Is it possible it got called earlier and flipped doOnce to false?

Actually, no. I tried checking for different parameters and then the script worked correctly. It just wasn't reading the variables correctly for some reason.

I've transferred the Guardian identification to a Global variable now, too, because I have other scripts that need it passed to them to function properly.

Thanks for the help, though. :)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...