Jump to content

Trying to Figure out How to End Script if in Combat


LordXayd

Recommended Posts

Hello,

 

I am working on a mod house that includes a teleporter. Everything works from menu choices, mark and recall, follower gate, etc. But, I'm trying to rig it so that the script will end prematurely if the player is in combat. Normally I wouldnt care and just gate out anyway, but the follower will not come with if combat is in session.

...
Event OnEffectStart(Actor akTarget, Actor akCaster)
   Menu()
EndEvent

Function Menu(Int aiButton = 0)
      If(game.getplayer().isincombat() == false)
      Else
         MyCombatMESG.Show()
         XXXXXXXXXXXXXXXXXX
      EndIf
   aiButton = MyMenuMESG.Show()
   If aiButton == 0; Set Recall Point
...

MyCombatMESG is just a MESG file with a body of text stating that you cant teleport while in combat.

MyMenuMESG is a MESG file with several button choices for various gates, sets and cancel.

 

The line of X's aside, the above script snippet compiles successfully.

If not in combat, MyCombatMESG is not displayed (as intended), and you get the aiButton list from MyMenuMESG, as expected.

If in combat, MyCombatMESG is displayed (as intended), but then you still get the aiButton list anyway and can teleport.

 

What I was thinking was that if I add a line at the X's that ends the script right there after the combat mesg, I'd be good. But I'm at a loss for discovering the right code.

 

I tried adding an EndFunction at the X's, but of course the compiler did not like that as there is more to that Function set.

I thought about possibly having two Functions, the first being the combat message, but I see no reason why it wouldn't just do the 2nd Function set anyway.

 

Thanks in advance for any help. My entire mod is done and ready for bugtesting, except for this little detail. I could just upload it as is, but I want to be professional. As it currently stands, if you gate out in combat with a follower, they will never come with. You have to go back for em and finish the combat. Which, in all professionalism, one should be doing anyway.

Link to comment
Share on other sites

It sounds like what you're saying is that I should have the combat check in one section, and everything else in an if/else Function set beneath it. I'm not sure I'm following you though. Do you mean I should have a combat function, then a menu function? I thought if I did it that way, it would do the menu function anyway because what's to stop the script from going from the top to the bottom?

 

I guess I need to see an example :)

Link to comment
Share on other sites

Using your code as a base....

Event OnEffectStart(Actor akTarget, Actor akCaster)
  If (game.getplayer().isincombat()) ;player in combat
    MyCombatMESG.Show()
  ElseIf !(game.getplayer().isincombat()) ;player not in combat
    Menu()
  EndIf
EndEvent

Function Menu(Int aiButton = 0)
  aiButton = MyMenuMESG.Show()
  If aiButton == 0; Set Recall Point
  ;rest of menu section with buttons
  ;...
EndFunction
Link to comment
Share on other sites

  • Recently Browsing   0 members

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