Improved randomness (part 1) (#7882)

Faster and with no module bias

Removed rnd_init, rnd_uint32 and rnd_uniform
From now on we will only use rnd_value(min, max) for values in range [min, max] and rnd_chance(chance, base) for chances

Fixes #7881
Fixes #7883
Fixes #7884
Fixes #7885

Co-authored-by: Lemongrass3110 <lemongrass@kstp.at>
This commit is contained in:
Lemon
2023-12-20 00:12:15 +01:00
committed by GitHub
parent ad3a2e99eb
commit 7c153416bc
20 changed files with 83 additions and 107 deletions

View File

@@ -1927,7 +1927,7 @@ int skill_additional_effect( struct block_list* src, struct block_list *bl, uint
break;
case LG_HESPERUSLIT:
if( pc_checkskill(sd,LG_PINPOINTATTACK) > 0 && sc && sc->getSCE(SC_BANDING) && sc->getSCE(SC_BANDING)->val2 > 5 )
skill_castend_damage_id(src,bl,LG_PINPOINTATTACK,rnd_value(1, pc_checkskill(sd,LG_PINPOINTATTACK)),tick,0);
skill_castend_damage_id(src,bl,LG_PINPOINTATTACK, rnd_value<uint16>(1, pc_checkskill(sd,LG_PINPOINTATTACK)),tick,0);
break;
case SR_DRAGONCOMBO:
sc_start(src,bl, SC_STUN, 1 + skill_lv, skill_lv, skill_get_time(skill_id, skill_lv));
@@ -2332,7 +2332,7 @@ int skill_additional_effect( struct block_list* src, struct block_list *bl, uint
uint16 autospl_skill_lv = it.lv ? it.lv : 1;
if (it.flag & AUTOSPELL_FORCE_RANDOM_LEVEL)
autospl_skill_lv = rnd_value( 1, autospl_skill_lv );
autospl_skill_lv = rnd_value<uint16>( 1, autospl_skill_lv );
int rate = (!sd->state.arrow_atk) ? it.rate : it.rate / 2;
@@ -2479,7 +2479,7 @@ int skill_onskillusage(map_session_data *sd, struct block_list *bl, uint16 skill
uint16 skill_lv = it.lv ? it.lv : 1;
if (it.flag & AUTOSPELL_FORCE_RANDOM_LEVEL)
skill_lv = rnd_value( 1, skill_lv ); //random skill_lv
skill_lv = rnd_value<uint16>( 1, skill_lv ); //random skill_lv
e_cast_type type = skill_get_casttype(skill);
@@ -2699,7 +2699,7 @@ int skill_counter_additional_effect (struct block_list* src, struct block_list *
uint16 autospl_skill_id = it.id, autospl_skill_lv = it.lv ? it.lv : 1;
if (it.flag & AUTOSPELL_FORCE_RANDOM_LEVEL)
autospl_skill_lv = rnd_value( 1, autospl_skill_lv );
autospl_skill_lv = rnd_value<uint16>( 1, autospl_skill_lv );
int autospl_rate = it.rate;