Author Topic: Randomizing floating text  (Read 2144 times)

Offline Qwinn

  • Planewalker
  • *****
  • Posts: 111
Randomizing floating text
« on: May 14, 2008, 10:26:18 AM »
Okay, in a script, I've got a character who's got floating text that's supposed to be called randomly.  Here's the scripting bit:

Quote
IF
  LOS([PC],10)
  Allegiance(Myself,NEUTRAL)
THEN
  RESPONSE #100
    FaceObject([PC])
    FloatMessage(Myself,9497) // "Welcome to the Smoldering Corpse!"
    Wait(5)
  RESPONSE #100
    FaceObject([PC])
    FloatMessage(Myself,9504) // "Buy a gal a drink, scarred man?"
    Wait(5)
  RESPONSE #100
    FaceObject([PC])
    FloatMessage(Myself,9505) // "If you can get over the smell, this ain't a bad place to call kip."
    Wait(5)
  RESPONSE #100
    FaceObject([PC])
    FloatMessage(Myself,9506) // "You clueless?"
    Wait(5)
  RESPONSE #100
    FaceObject([PC])
    FloatMessage(Myself,9507) // "Did you come to watch him burn?"
    Wait(5)
  RESPONSE #100
    FaceObject([PC])
    FloatMessage(Myself,9508) // "It's a little dead here tonight... not as dead as the Mortuary, though."
    Wait(5)
END

In theory, those 6 should have an equal chance of playing.  In reality, I've sat there for 15 minutes and seen only the first 3 come up... in fact, I've -yet- to see the 5th and 6th ones come up even once.   Sim's scripting guide mentions a "bias" towards the first ones but that seems like a lot more than a bias to me.  It links to a thread that supposedly has a discussion about it but that link is dead.

Anyways, my question is, will this truly randomize it?

Quote
IF
  LOS([PC],10)
  Allegiance(Myself,NEUTRAL)
  RandomNum(6,1)
THEN
  RESPONSE #100
    FaceObject([PC])
    FloatMessage(Myself,9497) // "Welcome to the Smoldering Corpse!"
    Wait(5)
END

IF
  LOS([PC],10)
  Allegiance(Myself,NEUTRAL)
  RandomNum(6,2)
THEN
  RESPONSE #100
    FaceObject([PC])
    FloatMessage(Myself,9504) // "Buy a gal a drink, scarred man?"
    Wait(5)
END

IF
  LOS([PC],10)
  Allegiance(Myself,NEUTRAL)
  RandomNum(6,3)
THEN
  RESPONSE #100
    FaceObject([PC])
    FloatMessage(Myself,9505) // "If you can get over the smell, this ain't a bad place to call kip."
    Wait(5)
END

IF
  LOS([PC],10)
  Allegiance(Myself,NEUTRAL)
  RandomNum(6,4)
THEN
  RESPONSE #100
    FaceObject([PC])
    FloatMessage(Myself,9506) // "You clueless?"
    Wait(5)
END

IF
  LOS([PC],10)
  Allegiance(Myself,NEUTRAL)
  RandomNum(6,5)
THEN
  RESPONSE #100
    FaceObject([PC])
    FloatMessage(Myself,9507) // "Did you come to watch him burn?"
    Wait(5)
END

IF
  LOS([PC],10)
  Allegiance(Myself,NEUTRAL)
  RandomNum(6,6)
THEN
  RESPONSE #100
    FaceObject([PC])
    FloatMessage(Myself,9508) // "It's a little dead here tonight... not as dead as the Mortuary, though."
    Wait(5)
END

Will that work?  Or does it reroll the random num each time so that I'll again have a bias towards the first selections?  And is there an easier way to accomplish this?

Qwinn
« Last Edit: May 14, 2008, 10:41:11 AM by Qwinn »

Offline Qwinn

  • Planewalker
  • *****
  • Posts: 111
Re: Randomizing floating text
« Reply #1 on: May 14, 2008, 10:48:22 AM »
Well, I tried it, and I -am- seeing all the messages now, but much more rapid fire.  It does seem like the random number is being rerolled each block... and it doesn't seem like the Wait(5)'s are executing, at least not consistently, they're coming up like every 2 seconds.

I know I've seen script pieces where multiple randomnum trigger checks are supposed to share a single die-roll, so to speak, but I can't find any examples now.  Any help?

I would think that after a block triggered as true and executed, the script would restart (since I didn't put in Continue()s) but it seems like it rolls right on down, ignoring Wait(5)'s.  What's going on?

Qwinn
« Last Edit: May 14, 2008, 10:52:10 AM by Qwinn »

Offline Qwinn

  • Planewalker
  • *****
  • Posts: 111
Re: Randomizing floating text
« Reply #2 on: May 14, 2008, 11:33:55 AM »
Well, I tried weighing the responses.  I seemed to get a fairly random occurrence of the first five responses with this:

Quote
IF
  LOS([PC],10)
  Allegiance(Myself,NEUTRAL)
THEN
  RESPONSE #50
    FaceObject([PC])
    FloatMessage(Myself,9497) // "Welcome to the Smoldering Corpse!"
    Wait(2)
  RESPONSE #60
    FaceObject([PC])
    FloatMessage(Myself,9504) // "Buy a gal a drink, scarred man?"
    Wait(2)
  RESPONSE #70
    FaceObject([PC])
    FloatMessage(Myself,9505) // "If you can get over the smell, this ain't a bad place to call kip."
    Wait(2)
  RESPONSE #80
    FaceObject([PC])
    FloatMessage(Myself,9506) // "You clueless?"
    Wait(2)
  RESPONSE #90
    FaceObject([PC])
    FloatMessage(Myself,9507) // "Did you come to watch him burn?"
    Wait(2)
  RESPONSE #300
    FaceObject([PC])
    FloatMessage(Myself,9508) // "It's a little dead here tonight... not as dead as the Mortuary, though."
    Wait(2)
END

Note that, despite giving that sixth response a weight of #300, over six times that of the first response, it still -never- came up.  The engine doesn't appear to consider the sixth response at all.  Was this common knowledge, and I just missed any mention of it?

Anyways, if I do want to do more than five possibilities ever, looks like I will have to learn how to make that RandomNum thing I tried work.  Any hints on how to get it to use a single roll of the die to determine which block runs?

Qwinn

Offline Grim Squeaker

  • Fallen
  • Planewalker
  • *****
  • Posts: 1019
  • Gender: Male
Re: Randomizing floating text
« Reply #3 on: May 14, 2008, 11:54:17 AM »
God I love WeiNGINE...
"You alone can make my song take flight..."

Offline Qwinn

  • Planewalker
  • *****
  • Posts: 111
Re: Randomizing floating text
« Reply #4 on: May 14, 2008, 12:24:19 PM »
I can't use it for what I'm doing, unfortunately :(

For anyone who's interested, this was my outcome when testing five RESPONSE blocks which were equally weighted.  I sat through 100 of them, and out of that 100:

1) 95 times, I got one of the first three response blocks (though fairly evenly distributed between those 3, I think, actually).
2) 5 times, I got the fourth response block.
3) 0 times, I got the fifth response block.

I can tell you that in several 100 more times I observed it (where I wasn't actually counting) I still never saw the 5th response block.

I tried giving the first 3 response blocks a weight of 70, the fourth response block a weight of 85, and the fifth response block a weight of 100.  This seemed to give me my best results.  It may not be perfectly random but none of the responses are rare or simply never happen, with that setup. 

In the above example I think I'll just make it two IF blocks of 3 responses each, so I can get that sixth response in there, and also make them alternate so it'll never repeat itself.

This issue means quite a few floating text messages in PS:T simply were never coming up.  I'll be fixing those, redistributing the weights, and in some cases where it was around 10 blocks within a single IF, splitting them up into two IFs that will alternate.  In a case like that, that should mean something like 5 new floating text messages no one ever saw before, heh.  Someone might want to see if that's been an issue in other games?  Or is this something everyone knew about and has been fixed?

Qwinn

Offline Qwinn

  • Planewalker
  • *****
  • Posts: 111
Re: Randomizing floating text
« Reply #5 on: May 14, 2008, 03:58:45 PM »
Okay, I think I've figured out what's going on.

Every thread I've seen regarding this issue claims that you'd get the same behavior if you had all of your response weights add up to 1000 or 100, that it makes no difference.  At least with the PS:T engine, this is NOT correct.  The total does very much matter.  If I assign the 6 responses a weight of 20 each, they seem quite random, and I get all 6 responses.  If you assign them 100 each, you'll almost never see the 4th, and you will never ever see the 5th or 6th. 

From that behavior, it seems like it'll work up to a total of about 350-400 or so.  If your accumulated weight of your first handful of responses goes beyond that total, further responses won't run.

Qwinn
« Last Edit: May 14, 2008, 04:03:32 PM by Qwinn »

Offline Avenger_teambg

  • Planewalker
  • *****
  • Posts: 399
Re: Randomizing floating text
« Reply #6 on: July 02, 2008, 07:33:56 AM »
My theory, which could be tested: the weights (and their sums) are stored on a single byte (0-255).
So, a weight of 256 will never happen.
You better make them add up to 255 (or 100).
Anything larger will get a skewed (hard to explain) result.
I'm also curious what happens if the weights add up exactly 256 (or a multiplication of that).

Offline Lu

  • Planewalker
  • *****
  • Posts: 750
  • Gender: Female
Re: Randomizing floating text
« Reply #7 on: July 30, 2008, 09:44:07 PM »
Quote
IF
  LOS([PC],10)
  Allegiance(Myself,NEUTRAL)
  RandomNum(6,1)
THEN
  RESPONSE #100
    FaceObject([PC])
    FloatMessage(Myself,9497) // "Welcome to the Smoldering Corpse!"
    Wait(5)
END

IF
  LOS([PC],10)
  Allegiance(Myself,NEUTRAL)
  RandomNum(6,2)
THEN
  RESPONSE #100
    FaceObject([PC])
    FloatMessage(Myself,9504) // "Buy a gal a drink, scarred man?"
    Wait(5)
END

IF
  LOS([PC],10)
  Allegiance(Myself,NEUTRAL)
  RandomNum(6,3)
THEN
  RESPONSE #100
    FaceObject([PC])
    FloatMessage(Myself,9505) // "If you can get over the smell, this ain't a bad place to call kip."
    Wait(5)
END
 [...]

Quote
I know I've seen script pieces where multiple randomnum trigger checks are supposed to share a single die-roll, so to speak, but I can't find any examples now.  Any help?

 I doubt I've ever seen such scripts among written by Bioware, BUT
  there are many dialogs in which the branch is chosen randomly, in the same manner as in the piece of code above, eg PROST1.DLG
 It has 8 branches, for which the only trigger is RandomNum(8,1) to RandomNum(8,8). So if this (Bioware's) dialog is OK (which means that all these values 1 to 8 are realizations of the same random) then I think it's quite reasonable to assume that in the piece of script above in each block the value is obtained by the same roll, too
  As for the  PROST1.DLG, I'm pretty sure that it works. Never had the message 'The whore has nothing to say to you'
  Though I don't often talk to those ladies in Athkatla, being straight, you know. So if anyone has experienced the opposite, please post here. I think the issue is very important




 

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)?: