Jump to content

My script fires twice...


Salk

Recommended Posts

Hello!

The biggest problem I am facing at the moment is that I have a script that often fires twice and I have no idea why. Perhaps someone here might suggest some way to make it always work as it should?

 

The .d file begins with this:

 

IF ~Global("INBACKPACK","GLOBAL",1)~ THEN BEGIN 39 // from:
   SAY @12
   IF ~~ THEN DO ~IncrementGlobal("INBACKPACK","GLOBAL",1)SetGlobalTimer("WTPFAMWANTSOUT","GLOBAL",120)SetGlobalTimer("ISTAYOUT","GLOBAL",1200)DestroySelf()~ EXIT
END


IF ~Global("INBACKPACK","GLOBAL",3)~ THEN BEGIN 40 // from:
   SAY @13
   IF ~~ THEN DO ~IncrementGlobal("INBACKPACK","GLOBAL",1)SetGlobalTimer("WTPFAMWANTSOUT","GLOBAL",120)SetGlobalTimer("ISTAYOUT","GLOBAL",1200)DestroySelf()~ EXIT
END


IF ~Global("INBACKPACK","GLOBAL",5)~ THEN BEGIN 41 // from:
   SAY @14
   IF ~~ THEN DO ~SetGlobalTimer("WTPFAMWANTSOUT","GLOBAL",60)SetGlobalTimer("ISTAYOUT","GLOBAL",1200)DestroySelf()~ EXIT
END

 

This part is appended to baldur.bcs and it's duplicated for each familiar (I have the Quasit in the example here):

 

IF
PartyHasItem("wtpfmqua")
Global("WTPINBACK", "GLOBAL", 1)
Global("INBACKPACK", "GLOBAL", 0) 
!TriggerOverride(Player1,See([ENEMY]))
    !ActuallyInCombat() 
GlobalTimerExpired("WTPFAMWANTSOUT","GLOBAL")
THEN
    RESPONSE #100
IncrementGlobal("INBACKPACK","GLOBAL",1)
ActionOverride(Player1,MoveViewObject(Myself,INSTANT))
CreateCreatureObject("wtpnag9",Player1,0,0,0)
ActionOverride(Player1,VerbalConstant("WTPNAG9",BORED))
END


IF
PartyHasItem("wtpfmqua")
Global("INBACKPACK", "GLOBAL", 2) 
!TriggerOverride(Player1,See([ENEMY]))
    !ActuallyInCombat() 
GlobalTimerExpired("WTPFAMWANTSOUT","GLOBAL")
THEN
    RESPONSE #100
IncrementGlobal("INBACKPACK","GLOBAL",1)
ActionOverride(Player1,MoveViewObject(Myself,INSTANT))
CreateCreatureObject("wtpnag9",Player1,0,0,0) 
ActionOverride(Player1,VerbalConstant("WTPNAG9",BORED))
END


IF
PartyHasItem("wtpfmqua")
        OR(2)
 Global("INBACKPACK", "GLOBAL", 4)
 Global("INBACKPACK", "GLOBAL", 5) 
!TriggerOverride(Player1,See([ENEMY]))
    !ActuallyInCombat() 
GlobalTimerExpired("WTPFAMWANTSOUT","GLOBAL")
THEN
    RESPONSE #100
SetGlobal("INBACKPACK", "GLOBAL", 5)
ActionOverride(Player1,MoveViewObject(Myself,INSTANT))
CreateCreatureObject("wtpnag9",Player1,0,0,0)
ActionOverride(Player1,VerbalConstant("WTPNAG9",BORED))
END

Any help in individuating the problem? Or suggestions about how to make it better?

 

Thanks!

 

Link to comment

I don't see any logic that puts the creature into the player's backpack. Or is it present constantly in the inventory? If yes then the third code block would fire constantly once the global variable reaches a value of 5 and timer runs out.

Link to comment

I don't see any logic that puts the creature into the player's backpack. Or is it present constantly in the inventory? If yes then the third code block would fire constantly once the global variable reaches a value of 5 and timer runs out.

 

Hello!

 

The creature is put in the backpack via dialogue. It's not always present in the inventory:

 

IF ~~ THEN BEGIN 26 // from: 
  SAY #72667 /* ~It rolls its eyes.  "Oh, sure.  Stick me in your smelly pack.  Ever thought of sticking some mint in there?  Baaah..." It reluctantly crawls in.~ */
  IF ~~ THEN DO ~SetGlobal("WTPINBACK","GLOBAL",1)GivePartyAllEquipment()GiveItemCreate("wtpfmqua",Player1,0,0,0)SetGlobalTimer("WTPFAMWANTSOUT","GLOBAL",300)SetGlobalTimer("ISTAYOUT","GLOBAL",1200)DestroySelf()~ EXIT
END
Link to comment

You might need to consider that you should set the timer in the script block, as you might not be able to set in the dialog before it's rechecked... as the second dialog might be a consequence of a second run through of the script that was already started before the first one finished...

Link to comment

Thank you for your suggestions, guys.

 

First a small correction, it's not just two times... It can happen I rest at the inn and the script fired up even four times.

 

Jarno, I will try your suggestion and see if it helps.

 

Kulyok, I hoped the Timer would stop the perpetual loop. In fact, in ordinary cases, the script only fires once.

Link to comment

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...