Jump to content

more pseudocode happiness


Avenger

Recommended Posts

Well, i would like more actions detailed in this depth, so i started to write down what i found.

I hope Taimon can confirm (fill in the gaps).

 

-- hide action --

 

rand = rand(1,100)-stat[32] ;; luck

 

if (rand>=100) hide_failed()

 

if (???) hide_failed()

 

if (disabled button) hide_failed()

 

if (seen by enemy) hide_failed()

 

stat = (stat[27]+stat[135] )/2 ;;move silently and hide in shadows

 

diff = (100-area_light)*stat/100

 

if (rand>diff) hide_failed()

 

set_modal(hide)

display hide success

apply invis effect(300 ticks)

 

hide_failed():

set_modal(none)

display hide failed text

disable hiding(90 ticks)

Link to comment
rand = rand(1,100)-stat[32] ;; luck

if (rand>=100) hide_failed()

This uses the rand_mod function that I talked about a while ago. [rand_mod(range, modifier)]

It calculates a random value in 0..range-1 adds the modifier and makes sure the result is still in [0;range-1].

(And I don't think it checks >=100.)

rand = rand_mod(100,-luck) + 1
if (rand == 100) hide_failed()

 

if (???) hide_failed()

This checks some selection and targeting related things. It's done in all modal state actions.

Link to comment

Your rand mod, would cap the value at 100, so if it is >100 it becomes 100.

I used simple rand in the pseudo code, that's why i wrote >= 100.

 

Basically, it causes 1% failure with 0 luck, no failure with any luck, and 1+misfortune (if your luck is negative).

 

I'm more curious about the ???. But i guess, gemrb can live without it, until the missing feature is obvious.

Link to comment

Looks like the posts from yesterday are missing.

 

I mentioned that there is a check for dual-classed thiefs with disabled thief class and Avenger was requesting details on the light check.

 

Here is python script that has most of the details:

(  5,   0) ->   6%
(  5,  90) ->   2%
( 10,   0) ->  13%
( 10,  45) ->   9%
( 10,  90) ->   5%
( 20,   0) ->  27%
( 20,  21) ->  23%
( 20,  45) ->  19%
( 20,  67) ->  15%
( 20,  90) ->  11%
( 50,   0) ->  69%
( 50,   8) ->  65%
( 50,  17) ->  61%
( 50,  26) ->  57%
( 50,  35) ->  53%
( 50,  45) ->  49%
( 50,  54) ->  45%
( 50,  63) ->  41%
( 50,  72) ->  37%
( 50,  81) ->  33%
( 50,  90) ->  29%
( 50,  99) ->  25%
( 75,   4) -> 100%
( 75,  10) ->  96%
( 75,  17) ->  92%
( 75,  22) ->  88%
( 75,  28) ->  84%
( 75,  35) ->  80%
( 75,  41) ->  76%
( 75,  47) ->  72%
( 75,  54) ->  68%
( 75,  59) ->  64%
( 75,  65) ->  60%
( 75,  72) ->  56%
( 75,  78) ->  52%
( 75,  83) ->  48%
( 75,  90) ->  44%
( 75,  96) ->  40%
(100,  43) -> 100%
(100,  48) ->  96%
(100,  53) ->  92%
(100,  57) ->  88%
(100,  62) ->  84%
(100,  66) ->  80%
(100,  71) ->  76%
(100,  75) ->  72%
(100,  80) ->  68%
(100,  85) ->  64%
(100,  89) ->  60%
(100,  94) ->  56%
(100,  98) ->  52%
(150,  81) -> 100%
(150,  85) ->  96%
(150,  88) ->  91%
(150,  91) ->  87%
(150,  95) ->  82%
(150,  98) ->  78%
(200, 100) -> 100%

 

Some explanations:

Lightness is a mapping from a rgb color to a value between 0 and 100.

[rgb(255,255,255) -> 100]

 

The color for the reference lightness seems to be the color overlay at midnight, but I'm not really sure. It's also used when deciding whether to draw the infravision overlay or not.

 

There is some interpolation going on to determine the lightmap color of the location, since the lightmap is much smaller than the area.

At night/dusk/dawn the lightmap color is adjusted by the color overlay. (Only get's darker.)

 

The rest should be pretty self-explanatory.

Remember that there is always a 1% chance of failure due to a previous check.

Link to comment

Well, you should at least give it a try. ???

 

Four step summary:

1. Get lightmap color of the creature location. (Uses some interpolation.)

2. Apply daytime overlay color. (Can only make the color "darker".)

3. Calculate "lightness" of that color and compare it to a reference lightness.

4. Calculate chance of successful hiding depending on that lightness difference and the thief skills.

Link to comment

I guess, iesdp doesn't need that specific details, but it is very helpful for GemRB.

 

I think one sentence is enough for IESDP: the perceptive light level of the hiding spot actually gives a bonus or penalty.

 

And at infravision: the light level of the spot (where the affected party member is) determines if the infravision visual effect is turned on.

Link to comment

By the way, this line in the script output

(100,  43) -> 100%

indicates, that if both thief skills are at 100, it is night and you are in a non-shadowed spot your chance of successful hiding is 100%. (Actually 99%, since there is always a 1% chance of failure due to the first check in the hide action.)

Link to comment

Archived

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

×
×
  • Create New...