Author Topic: BG2/ToB PC scripting: Hide() and SetGlobal()  (Read 2082 times)

Offline gimble

  • Planewalker
  • *****
  • Posts: 1
BG2/ToB PC scripting: Hide() and SetGlobal()
« on: August 18, 2011, 01:47:20 PM »
Based on recent experimentation, SetGlobal(), IncrementGlobal(), and SetGlobalTimer() all force the character out of stealth.

Perhaps it's old news, but it surprised me.  Sample script code was as follows:
Quote
IF
  ActionListEmpty()
  !GlobalTimerNotExpired("TEST","LOCALS")
THEN
  RESPONSE #100
    SetGlobalTimer("TEST","LOCALS",THREE_ROUNDS)
END
Run that as your script, and then click on the stealth button until the character hides.  He will un-hide as soon as the timer expires.  Similar tests can be done with SetGlobal() and IncrementGlobal().

I was running a "try to hide" counter for the character, so that he could initially try frequently, and then try less frequently as he continued failing.

However, once the PC succeeded and hid, resetting the counter to zero forced the character out of hiding.  Experimentation revealed the cause as listed above.

My ultimate workaround was to have non-hidden PC characters reset the "try to hide" global variable per PC as appropriate if hidden.  Works OK.

 

With Quick-Reply you can write a post when viewing a topic without loading a new page. You can still use bulletin board code and smileys as you would in a normal post.

Warning: this topic has not been posted in for at least 120 days.
Unless you're sure you want to reply, please consider starting a new topic.

Name: Email:
Verification:
Type the letters shown in the picture
Listen to the letters / Request another image
Type the letters shown in the picture:
What color is grass?:
What is the seventh word in this sentence?:
What is five minus two (use the full word)?: