Jump to content
⚠ Known Issue: Media on User Profiles ×

Multiple MessageBox Activator Script Help


Recommended Posts

Ok, basically I'm writing a script to open a MessageBox that opens up more MessageBox's, each with their own summon. I've got the multiple boxes working, the problem is, regardless of which MessageBox I'm in, the selection always acts like it's from Box one. I can provide a quick video if needed to show what I mean.

 

Meanwhile, here's the script. I think, maybe I have to have all the dialogue boxes pre-written in stages, then have all the answers in stages afterwards? I'm not sure.

 

||||||||||||||||||||||||||||||||||||||||///////////////\\\\\\\\\\\\|||||||||||||||||||||||||||||||||||

 

Begin _trainingactivator

Short ScriptState

Short Button

If ( MenuMode == 1 )

Return

EndIf

If ( OnActivate == 1 )

If ( ScriptState == 0 )

MessageBox "What would you like to summon?" "Scrib - Level 1 | 20 Gold" "Rat - Level 2 | 35 Gold" "Kwama Warrior - Level 3 | 45 Gold" "Bonewalker - Level 4 | 70 Gold" "Scamp - Level 5 | 75 Gold" "Next"

Set ScriptState to 0

EndIf

EndIf

If ( ScriptState == 0 )

Set Button to GetButtonPressed

If ( Button == 0 )

If ( Player->GetItemCount Gold_001 < 20 )

MessageBox "You don't have enough gold"

Else

Player->RemoveItem "Gold_001" 20

MessageBox "You summon a level 1 Scrib."

PlaceAtPC "scrib", 1, 128, 3

Set ScriptState to 1

EndIf

EndIf

If ( Button == 1 )

If ( Player->GetItemCount Gold_001 < 35 )

MessageBox"You don't have enough gold."

Else

Player->RemoveItem "Gold_001" 35

MessageBox "You summon a level 2 Rat."

PlaceAtPC "Rat", 1, 128, 3

Set ScriptState to 1

EndIf

EndIf

If ( Button == 2 )

If ( Player->GetItemCount Gold_001 < 45 )

MessageBox "You don't have enough gold."

Else

Player->RemoveItem "Gold_001" 45

MessageBox "You summon a level 3 Kwama Warrior"

PlaceAtPC "kwama warrior", 1, 128, 3

Set ScriptState to 1

EndIf

EndIf

If ( Button == 3 )

If ( Player->GetItemCount Gold_001 < 70 )

MessageBox "You don't have enough gold."

Else

Player->RemoveItem "Gold_001" 70

MessageBox "You summon a level 4 Bonewalker."

PlaceAtPC "bonewalker", 1, 128, 3

Set ScriptState to 1

EndIf

EndIf

If ( Button == 4 )

If ( Player->GetItemCount Gold_001 < 75 )

MessageBox "You don't have enough gold."

Else

Player->RemoveItem "Gold_001" 75

MessageBox "You summon a level 5 Scamp."

PlaceAtPC "scamp", 1, 128, 3

Set ScriptState to 1

EndIf

EndIf

If ( Button == 5 )

Set ScriptState to 3

EndIf

EndIf

If ( ScriptState == 3 )

Set Button to GetButtonPressed

MessageBox "Levels Six through Ten" "Shalk - Level 6 | 60 Gold" "Skeleton Warrior - Level 7 | 110 Gold"

If ( Button == 6 )

If (Player->GetItemCount Gold_001 < 60 )

MessageBox "You don't have enough gold."

Else

Player->RemoveItem "Gold_001" 60

MessageBox "You summon a level 6 Shalk."

PlaceAtPc "shalk", 1, 128, 3

Set ScriptState to 3

EndIf

EndIf

If ( Button == 7 )

If ( Player->GetItemCount Gold_001 < 110 )

MessageBox "You don't have enough gold."

Else

Player->RemoveItem "Gold_001" 110

MessageBox "You summon a level 7 Skeleton Warrior"

PlaceAtPC "skeleton warrior", 1, 128, 3

Set ScriptState to 3

EndIf

EndIf

EndIf

If ( ScriptState == 1 )

Set ScriptState to 0

EndIf

If ( ScriptState == 3 )

Set ScriptState to 0

EndIf

End _trainingactivator

 

 

Please Note, it's not complete. No point completing it yet if I can't get it working.

Link to comment
Share on other sites

Okay now I came across something strange. Any time I use Button 1, regardless of the activator, it summons a Scrib. I broke the game apparently.

 

I am doing this in OpenMW with the OpenMW Editor, if that makes any difference.

Edited by Rizalgar
Link to comment
Share on other sites

Please indent your code to make your script easier to read and understand.

 

I suspect if you select a skeleton warrior it will summon a rat. This is because after each cycle your script runs (and it runs to the end each cycle) you will set the script state to 0 if it is 1 or 3. After the second menu displays and the player makes a choice that choice is applied to the first menu block. You need an early return while the script waits for the player to make a choice. Such returns will improve the efficience of your code as well. After activation you want to set 'ScriptState' to 1 (not 0 as it already is) to prevent the player from activating it a second time before the choice is completed. As a personal choice, there is no need for the message informing the player that creature is summoned, and specifying the level of the summon is immersion-breaking. Rather than try to explain where changes should be made I offer the following untested code:

Begin TrainingActivator
 
; Underscores as the first character of names can be a dangerous practice
 
short scriptState
short button
 
if ( menumode == 1 )
   return
endIf
 
if ( OnActivate == 1 )
   if ( scriptState == 0 )
      messagebox "What would you like to summon?" "Scrib (20 gold)" "Rat (35 gold)" "Kwama Warrior (45 gold)" "Bonewalker (70 gold)" "Scamp (75 gold)" "Next"
      set scriptState to 1
   endIf
endIf
 
if ( scriptState == 1 )
   set button to GetButtonPressed
   if ( button == -1 ) ; the player has not made a choice yet
      return
   elseif ( button == 0 ) ; scrib
      if ( ( player->GetItemCount "Gold_001" ) < 20 )
         messagebox "You don't have enough gold."
      else
         player->RemoveItem "Gold_001" 20
         PlaceAtPC "scrib" 1 128 3
      endIf
   elseif ( button == 1 ) ; rat
      if ( ( player->GetItemCount "Gold_001" ) < 35 )
         messagebox "You don't have enough gold."
      else
         player->RemoveItem "Gold_001" 35
         PlaceAtPC "rat" 1 128 3
      endIf
   elseif ( button == 2 ) ; kwama warrior - perhaps you meant kwama forager?
      if ( ( player->GetItemCount "Gold_001" ) < 45 )
         messagebox "You don't have enough gold."
      else
         player->RemoveItem "Gold_001" 45
         PlaceAtPC "kwama warrior" 1 128 3
      endIf
   elseif ( button == 3 ) ; bonewalker - another comparatively high level challenge
      if ( ( player->GetItemCount "Gold_001" ) < 70 )
         messagebox "You don't have enough gold."
      else
         player->RemoveItem "Gold_001" 70
         PlaceAtPC "bonewalker" 1 128 3
      endIf
   elseif ( button == 4 ) ; scamp - more like it
      if ( ( player->GetItemCount "Gold_001" ) < 75 )
         messagebox "You don't have enough gold."
      else
         player->RemoveItem "Gold_001" 75
         PlaceAtPC "scamp" 1 128 3
      endIf
   elseif ( button == 5 ) ; next menu branch
      set scriptState to 2
   endif
endif
 
if ( scriptState == 2 ) ; second menu branch
   messagebox "Shalk (60 gold)" "Skeleton Warrior (110 Gold)" "Next"
   set scriptState to 3
endif

if ( scriptState == 3 )
   set button to GetButtonPressed
   if ( button == -1 ) ; the player has not made a choice yet
      return
   elseif ( button == 0 ) ; this is first choice on new menu branch - shalk
      if ( ( player->GetItemCount "Gold_001" ) < 60 )
         messagebox "You don't have enough gold."
      else
         player->RemoveItem "Gold_001" 60
         PlaceAtPC "shalk" 1 128 3
      endIf
   elseif ( button == 1 ) ; skeleton warrior
      if ( ( player->GetItemCount "Gold_001" ) < 110 )
         messagebox "You don't have enough gold."
      else
         player->RemoveItem "Gold_001" 110
         PlaceAtPC "skeleton warrior" 1 128 3
      endif
   elseif ( button == 2 ) ; next menu branch - just for illustration
      set scriptState to 4
   endif
endif
 
if ( scriptState == 4 ) ; third menu branch
    messagebox "Fargoth (1000 gold)"
   set scriptState to 5
endif

if ( scriptState == 5 )
   set button to GetButtonPressed
   if ( button == -1 ) ; the player has not made a choice yet
      return
   elseif ( button == 0 ) ; you get the idea
   endIf
endIf
 
set scriptState to 0 ; the script does not reach this point until the player makes a choice
 
End TrainingActivator

Tightening up the first message (choice menu) makes it possible to include more creatures per menu branch. This is expensive training. While it may not be necessary, I uncoupled each menu branch into separate logical blocks. There is an 'instruction limit' for an if-block. Depending on how many choices you plan to offer it is possible the code would have exceeded it.

Edited by cyran0
Link to comment
Share on other sites

Okay, I'll remember that next time. Thanks for the help. However, now the script will indeed spawn from the proper message box, but it will not go away, until you make a second selection, which defaults back to the first box. So say you choose Skeleton from box Two, the menu will remain and if you press Two again, it will summon a rat. I have tried moving around the If ( Button == -1 ) to see if it would remedy it, but to no avail. Any ideas?

 

Edit -- Is it maybe because the script is defaulting back to a certain ScriptState? I will tinker around with the variables a little bit and see what happens.

Edited by Rizalgar
Link to comment
Share on other sites

I tested the script myself in-game. I did make an error in the second and third branches of the message tree - I forgot the prompt "What would you like to summon?" so the first choice became the prompt. Other than that, the script worked as expected for me. I do suggest that you add an option for the player to cancel the training on each branch. I cannot account for why the original messagebox is not clearing for you after you make your first choice.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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