Jump to content

Kay, I'm stumped


Khet

Recommended Posts

Basically, there are three statues. Each statue has the exact same script save for the Statue##.Disable command. What should happen is when the player touches (activates) a statue, there a chance that they're either sent back to the start, or moved to a marker. If the fail twice the third one is guaranteed to send the player to the marker, but... I have two problems.

 

First off, the statues don't disable, nor does the failure message box pop up (but they player IS moved back to the start)

 

Secondly, on a success, the player isn't moved either but this time the message box DOES appear.

 

Can't figure out what's going wrong here... though knowing me (and my habitual lack of sleep) I missed probably ONE variable or something somewhere.

 

I know that the Player.MoveTo KTMLoc1 is commented out, it's because I haven't set it up yet, but even Player.MoveTo KTMLoc2 isn't working.

 

scn KTMStatueActivate01

Short Rand
Short Button
Short ButtonPressed

Begin OnActivate

Set Rand to 1 + GetRandomPercent * (2) / 99

If BCRef.Random == 0
If Rand == 1 
	;Fail
	Set BCRef.Random to BCRef.Random + 1
	Player.MoveTo BRS
	Statue01.Disable
	MessageBox "The statue shatters at your touch and you find yourself back at the beginning."
ElseIf Rand == 2
	;Fail
	Set BCRef.Random to BCRef.Random + 1
	Player.MoveTo BRS
	Statue01.Disable
	MessageBox "The statue shatters at your touch and you find yourself back at the beginning."
ElseIf Rand < 2
	;Win
	Set BCRef.Random to BCRef.Random + 1
	messagebox "Where to?", "Test one", "Test two"
  		 set ButtonPressed to 1
EndIf
EndIf

If BCRef.Random == 1
If Rand == 1 || Rand == 2
	;Fail
	Set BCRef.Random to BCRef.Random + 1
	Player.MoveTo BRS
	Statue01.Disable
	MessageBox "The statue shatters at your touch and you find yourself back at the beginning."
ElseIf Rand < 2
	;Win
	Set BCRef.Random to BCRef.Random + 1
	messagebox "Where to?", "Test one", "Test two"
  		 set ButtonPressed to 1
EndIf
EndIf

If BCRef.Random == 2
	;Win
	Set BCRef.Random to BCRef.Random + 1
	messagebox "Where to?", "Test one", "Test two"
  		 set ButtonPressed to 1
EndIf
EndIf

End

Begin GameMode

If ButtonPressed == 1
Set Button to GetButtonPressed
	If button > -1
		If button == 0
			;Death Location
			;Player.MoveTo KTMLoc1
			Set ButtonPressed to 0
		ElseIf button == 1
			;Safe Location
			Player.MoveTo KTMLoc2
			Set ButtonPressed to 0
     EndIf
   EndIf
 EndIf

End

Link to comment
Share on other sites

player.moveto acts as a return in whatever script is called by it, essentially stopping the script where it was. You should probably only initiate the move after the script has done everything it needs to, even if you need to isolate it with a condition in a gamemode block.

 

begin onactivate

if <stuff> == 1

messagebox "more stuff happens"

set domove to 1

endif

end

 

begin gamemode

if domove == 1

set domove to 0 ;; has to be done before the move or you end up trapping the player in a loop until the game crashes.

player.movetomarker <marker>

endif

end

Link to comment
Share on other sites

Well, that explains a few things then! Never knew MoveTo acted as a return, thanks!

 

Edit: Forgot to ask... is there a way to completely prevent NightSight, even if it's added by a mod as a toggle?

Edited by Khet
Link to comment
Share on other sites

Am I running the GetRandomPercent right? It should pull up a number between 1 and 3, yet every time (just tested about six or seven times) the success variable runs when activating the statues (doesn't matter which one)
Link to comment
Share on other sites

Well, that explains a few things then! Never knew MoveTo acted as a return, thanks!

 

Edit: Forgot to ask... is there a way to completely prevent NightSight, even if it's added by a mod as a toggle?

Not really. You might be able to force it off with player.setactorvalue nighteyebonus 0 but it might screw up whatever script or ability gave it. If you're trying to force darkness, you might be able to emulate it to some degree with black fog in that cell.

 

As for the random stuff. math is not my strong suit. but I believe the problem here is that you are mixing a function with math processes. Try doing something like

set rand to getrandompercent
set rand2 to ((rand + 1) 2) / 99

or as I would probably do it.

[/code]

set rand to getrandompercent

set rand2 to rand / 10 ;; which gives you a straight 0-9 value

set rand3 to {rand2 + 1} ;; which gives you a number 1-10

if rand3 >= 7

<stuff>

return

elseif rand3 >= 4

<stuff>

return

elseif rand3 >= 1

<stuff>

return

endif

[/code]

Although this gives a slight bias toward the first group of stuff and requires a few more steps, it does allow for quite a bit more flexibility depending on what the randompercent function returns. You should always keep in mind that this particular functions does not always return a truly random value, so trying to make it work with an absolute condition == does not always work well. Instead use the way that the script is run to handle the logic. It checks from top to bottom.

Link to comment
Share on other sites

Ah, just tested out a thought with made things much simpler, and working this time.

 

Set Rand to GetRandomPercent/25

 

And simply have a 75% chance of failure on the first statue, 50% chance on the second statue, then 0% chance on the third statue... or make it go 75/50/25/0 if I add a fourth statue, wouldn't be too hard.

 

But thanks though, you've cleared up the function a bit more for future use though.

Link to comment
Share on other sites

Okay I've no idea wtf is going on now. The script just... stopped working. I can't think of anything that I've changed since getting the GetRandomPercent to work, and I've looked at this thing for an hour and a half now. Activate the statue and.... nothing. Absolutely nothing. I just don't get it... it was working perfectly fine before, then suddenly it just... stopped.

 

 

scn KTMStatueActivate02

Short RandNum
Short Button
Short ButtonPressed
Short DoMove

Begin OnActivate

Set RandNum to GetRandomPercent/25

If BCRef.Random == 0
If RandNum == 1
	;Fail
	Set BCRef.Random to BCRef.Random + 1
	Set DoMove to 1
	Statue02.Disable
	MessageBox "The statue shatters at your touch and you find yourself back at the beginning."
ElseIf RandNum == 2 
	;Fail
	Set BCRef.Random to BCRef.Random + 1
	Set DoMove to 1
	Statue02.Disable
	MessageBox "The statue shatters at your touch and you find yourself back at the beginning."
ElseIf RandNum == 3
	;Fail
	Set BCRef.Random to BCRef.Random + 1
	Set DoMove to 1
	Statue02.Disable
	MessageBox "The statue shatters at your touch and you find yourself back at the beginning."
ElseIf RandNum == 4
	;Win
	Set BCRef.Random to BCRef.Random + 1
	messagebox "Where to?", "Test Loc 1", "Test Loc 2"
  		 set ButtonPressed to 1
EndIf
EndIf

If BCRef.Random == 1
If RandNum == 1 || RandNum == 2
	;Fail
	Set BCRef.Random to BCRef.Random + 1
	Set DoMove to 1
	Statue02.Disable
	MessageBox "The statue shatters at your touch and you find yourself back at the beginning."
ElseIf RandNum < 2
	;Win
	Set BCRef.Random to BCRef.Random + 1
	messagebox "Where to?", "Test Loc 1", "Test Loc 2"
  		 set ButtonPressed to 1
EndIf
EndIf

If BCRef.Random == 2
	;Win
	Set BCRef.Random to BCRef.Random + 1
	messagebox "Where to?", "Test Loc 1", "Test Loc 2"
  		 set ButtonPressed to 1
EndIf
EndIf

End

Begin GameMode

If ButtonPressed == 1
Set Button to GetButtonPressed
	If button > -1
		If button == 0
			;Death Location
			Set DoMove to 2
			Set ButtonPressed to 0
		ElseIf button == 1
			;Safe Location
			Set DoMove to 3
			Set ButtonPressed to 0
     EndIf
   EndIf
 EndIf

If DoMove == 1
Set DoMove to 0
Player.MoveToMarker BRS
ElseIf DoMove == 2
Set DoMove to 0
;Player.MoveToMarker KTMRezLoc1
ElseIf DoMove == 3
Set DoMove to 0
Player.MoveToMarker KTMRezLoc2
ElseIf DoMove == 4 && KTMDeathQuest.SE == 1
Set DoMove to 0
;Player.MoveToMarker KTMRezLoc3
EndIf
End

 

Link to comment
Share on other sites

  • Recently Browsing   0 members

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