Skip to content

Enhanced Scripts...

KerozevokKerozevok Member Posts: 695
edited August 2012 in Archive (Feature Requests)
If
condition
Then
Response #100
action
End
No problem.
If
condition
Then
Response #50
action A
Response #50
action B
End
Despite the 50/50, most of the time, the game always choose the 1st possibility, is it possible to improve this ?...
Post edited by Kerozevok on

Comments

  • WardWard Member Posts: 1,305
    edited August 2012
    Change the first one to #49. ;)

    image

    No to be honest I'm no help and would be interested to know more.
  • KerozevokKerozevok Member Posts: 695
    We can write #10 in 1st and #90 in 2nd, the problem is the same, most of the time, the game choose the 1st possibility.
  • lansounetlansounet Member Posts: 1,182
    edited August 2012
    How about
    IF
    RandomNum(2,1)
    Trigger A
    THEN
    RESPONSE #100
    Action A
    END

    IF
    RandomNum(2,2)
    Trigger A
    THEN
    RESPONSE #100
    Action B
    END
    ?

    You can split the probabilities unevenly too with RandomNumGT() / RandomNumLT() (Instead of a lot of OR() RandomNum()), for example
    IF
    RandomNumLT(10,2)
    Trigger A
    THEN
    RESPONSE #100
    Action A
    END

    IF
    RandomNumGT(10,1)
    RandomNumLT(10,5)
    Trigger A
    THEN
    RESPONSE #100
    Action B
    END

    IF
    RandomNumGT(10,4)
    Trigger A
    THEN
    RESPONSE #100
    Action C
    END
  • KerozevokKerozevok Member Posts: 695
    edited August 2012
    @lansounet I agree, but that increases the number of lines because the % are not respected by the engine.
  • lansounetlansounet Member Posts: 1,182
    Well I've never seen people complain about BG2 Tweaks @CamDawg 's slow drow disintegration component.

    It goes like this (pretty much):
    IF
    GlobalTimerExpired()
    Triggers
    THEN
    RESPONSE #5
    TakeItemReplace()
    Continue()
    RESPONSE #95
    Continue()
    END


    and that seems to work fine for a 5% probability to break items everytime the timer is expired.
  • KerozevokKerozevok Member Posts: 695
    edited August 2012
    However it's an old problem...

    Scripting Guide by SimDing0 (writing in 2004)
    You are not limited to simply using a single RESPONSE #100 in scripts. (...)
    So, you could have, for example:

    IF
    // Triggers
    THEN
    RESPONSE #100
    // Action 1
    RESPONSE #100
    // Action 2
    END

    This will theoretically execute either action 1 or action 2 with equal chance of each when the block is executed. However, in practice, there is a bias towards the first response (see this post). Truly random responses, if essential, can be achieved using the RandomNum trigger.


    Moreover, I am not sure the game makes a difference between 5% or 300%.
  • lansounetlansounet Member Posts: 1,182
    Yeh I knew about this when the values are equal or close. That's why I first mentionned RandomNum() as in that guide. However when a relatively low value is put first it appears to work somewhat fine.
Sign In or Register to comment.