summaryrefslogtreecommitdiff
path: root/src/map/battle.c
diff options
context:
space:
mode:
authorgepard1984 <gepard1984@54d463be-8e91-2dee-dedb-b68131a5f0ec>2012-01-17 18:06:34 +0000
committergepard1984 <gepard1984@54d463be-8e91-2dee-dedb-b68131a5f0ec>2012-01-17 18:06:34 +0000
commit95548cb1caad95933e2b36df9a13af070b733b04 (patch)
treeb9ce67cc8b45c6956528e5bb2935900b6d8ad441 /src/map/battle.c
parenta09cc2371ac0a2534f514a35a5637614c11f6a37 (diff)
downloadhercules-95548cb1caad95933e2b36df9a13af070b733b04.tar.gz
hercules-95548cb1caad95933e2b36df9a13af070b733b04.tar.bz2
hercules-95548cb1caad95933e2b36df9a13af070b733b04.tar.xz
hercules-95548cb1caad95933e2b36df9a13af070b733b04.zip
Enabled Mersenne Twister MT19937 as random number generator instead of standard `rand()` function (follow-up to r14865, r14870).
- It fixes issues caused by RAND_MAX being only 32k in Windows system (bugreport:1927, bugreport:86). git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@15483 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/battle.c')
-rw-r--r--src/map/battle.c97
1 files changed, 49 insertions, 48 deletions
diff --git a/src/map/battle.c b/src/map/battle.c
index 6a1943e42..ed51c63fe 100644
--- a/src/map/battle.c
+++ b/src/map/battle.c
@@ -7,6 +7,7 @@
#include "../common/malloc.h"
#include "../common/showmsg.h"
#include "../common/ers.h"
+#include "../common/random.h"
#include "../common/strlib.h"
#include "../common/utils.h"
@@ -88,7 +89,7 @@ struct block_list* battle_gettargeted(struct block_list *target)
map_foreachinrange(battle_gettargeted_sub, target, AREA_SIZE, BL_CHAR, bl_list, &c, target->id);
if (c == 0 || c > 24)
return NULL;
- return bl_list[rand()%c];
+ return bl_list[rnd()%c];
}
@@ -140,7 +141,7 @@ struct block_list* battle_getenemy(struct block_list *target, int type, int rang
return NULL;
if( c >= 24 )
c = 23;
- return bl_list[rand()%c];
+ return bl_list[rnd()%c];
}
static int battle_getenemyarea_sub(struct block_list *bl, va_list ap)
{
@@ -177,7 +178,7 @@ struct block_list* battle_getenemyarea(struct block_list *src, int x, int y, int
return NULL;
if( c >= 24 )
c = 23;
- return bl_list[rand()%c];
+ return bl_list[rnd()%c];
}
// ƒ_??[ƒW‚Ì’x‰„
@@ -289,7 +290,7 @@ int battle_attr_fix(struct block_list *src, struct block_list *target, int damag
if (target) tsc = status_get_sc(target);
if (atk_elem < 0 || atk_elem >= ELE_MAX)
- atk_elem = rand()%ELE_MAX;
+ atk_elem = rnd()%ELE_MAX;
if (def_type < 0 || def_type > ELE_MAX ||
def_lv < 1 || def_lv > 4) {
@@ -398,14 +399,14 @@ int battle_calc_damage(struct block_list *src,struct block_list *bl,struct Damag
d->dmg_lv = ATK_BLOCK;
return 0;
}
- if( sc->data[SC_WEAPONBLOCKING] && flag&(BF_SHORT|BF_WEAPON) && rand()%100 < sc->data[SC_WEAPONBLOCKING]->val2 )
+ if( sc->data[SC_WEAPONBLOCKING] && flag&(BF_SHORT|BF_WEAPON) && rnd()%100 < sc->data[SC_WEAPONBLOCKING]->val2 )
{
clif_skill_nodamage(bl,src,GC_WEAPONBLOCKING,1,1);
d->dmg_lv = ATK_BLOCK;
sc_start2(bl,SC_COMBO,100,GC_WEAPONBLOCKING,src->id,2000);
return 0;
}
- if( (sce=sc->data[SC_AUTOGUARD]) && flag&BF_WEAPON && !(skill_get_nk(skill_num)&NK_NO_CARDFIX_ATK) && rand()%100 < sce->val2 )
+ if( (sce=sc->data[SC_AUTOGUARD]) && flag&BF_WEAPON && !(skill_get_nk(skill_num)&NK_NO_CARDFIX_ATK) && rnd()%100 < sce->val2 )
{
int delay;
clif_skill_nodamage(bl,bl,CR_AUTOGUARD,sce->val1,1);
@@ -418,12 +419,12 @@ int battle_calc_damage(struct block_list *src,struct block_list *bl,struct Damag
delay = 100;
unit_set_walkdelay(bl, gettick(), delay, 1);
- if(sc->data[SC_SHRINK] && rand()%100<5*sce->val1)
+ if(sc->data[SC_SHRINK] && rnd()%100<5*sce->val1)
skill_blown(bl,src,skill_get_blewcount(CR_SHRINK,1),-1,0);
return 0;
}
- if( (sce=sc->data[SC_PARRYING]) && flag&BF_WEAPON && skill_num != WS_CARTTERMINATION && rand()%100 < sce->val2 )
+ if( (sce=sc->data[SC_PARRYING]) && flag&BF_WEAPON && skill_num != WS_CARTTERMINATION && rnd()%100 < sce->val2 )
{ // attack blocked by Parrying
clif_skill_nodamage(bl, bl, LK_PARRYING, sce->val1,1);
return 0;
@@ -431,7 +432,7 @@ int battle_calc_damage(struct block_list *src,struct block_list *bl,struct Damag
if(sc->data[SC_DODGE] && ( !sc->opt1 || sc->opt1 == OPT1_BURNING ) &&
(flag&BF_LONG || sc->data[SC_SPURT])
- && rand()%100 < 20) {
+ && rnd()%100 < 20) {
if (sd && pc_issit(sd)) pc_setstand(sd); //Stand it to dodge.
clif_skill_nodamage(bl,bl,TK_DODGE,1,1);
if (!sc->data[SC_COMBO])
@@ -445,7 +446,7 @@ int battle_calc_damage(struct block_list *src,struct block_list *bl,struct Damag
if(sc->data[SC_TATAMIGAESHI] && (flag&(BF_MAGIC|BF_LONG)) == BF_LONG)
return 0;
- if((sce=sc->data[SC_KAUPE]) && rand()%100 < sce->val2)
+ if((sce=sc->data[SC_KAUPE]) && rnd()%100 < sce->val2)
{ //Kaupe blocks damage (skill or otherwise) from players, mobs, homuns, mercenaries.
clif_specialeffect(bl, 462, AREA);
//Shouldn't end until Breaker's non-weapon part connects.
@@ -455,7 +456,7 @@ int battle_calc_damage(struct block_list *src,struct block_list *bl,struct Damag
return 0;
}
- if( flag&BF_MAGIC && (sce=sc->data[SC_PRESTIGE]) && rand()%100 < sce->val2) {
+ if( flag&BF_MAGIC && (sce=sc->data[SC_PRESTIGE]) && rnd()%100 < sce->val2) {
clif_specialeffect(bl, 462, AREA); // Still need confirm it.
return 0;
}
@@ -553,7 +554,7 @@ int battle_calc_damage(struct block_list *src,struct block_list *bl,struct Damag
((TBL_PC *)src)->status.weapon == W_1HSWORD ||
((TBL_PC *)src)->status.weapon == W_2HSWORD
)) &&
- rand()%100 < sce->val2
+ rnd()%100 < sce->val2
){
damage = damage*50/100;
status_fix_damage(bl,src,damage,clif_damage(bl,src,gettick(),0,0,damage,0,0,0));
@@ -588,10 +589,10 @@ int battle_calc_damage(struct block_list *src,struct block_list *bl,struct Damag
//Probably not the most correct place, but it'll do here
//(since battle_drain is strictly for players currently)
if ((sce=sc->data[SC_BLOODLUST]) && flag&BF_WEAPON && damage > 0 &&
- rand()%100 < sce->val3)
+ rnd()%100 < sce->val3)
status_heal(src, damage*sce->val4/100, 0, 3);
- if( sd && (sce = sc->data[SC_FORCEOFVANGUARD]) && flag&BF_WEAPON && rand()%100 < sce->val2 )
+ if( sd && (sce = sc->data[SC_FORCEOFVANGUARD]) && flag&BF_WEAPON && rnd()%100 < sce->val2 )
pc_addspiritball(sd,skill_get_time(LG_FORCEOFVANGUARD,sce->val1),sce->val3);
}
@@ -625,7 +626,7 @@ int battle_calc_damage(struct block_list *src,struct block_list *bl,struct Damag
break;
}
}
- if( sc->data[SC_POISONINGWEAPON] && skill_num != GC_VENOMPRESSURE && (flag&BF_WEAPON) && damage > 0 && rand()%100 < sc->data[SC_POISONINGWEAPON]->val3 )
+ if( sc->data[SC_POISONINGWEAPON] && skill_num != GC_VENOMPRESSURE && (flag&BF_WEAPON) && damage > 0 && rnd()%100 < sc->data[SC_POISONINGWEAPON]->val3 )
sc_start(bl,sc->data[SC_POISONINGWEAPON]->val2,100,sc->data[SC_POISONINGWEAPON]->val1,skill_get_time2(GC_POISONINGWEAPON,sc->data[SC_POISONINGWEAPON]->val1));
}
@@ -783,7 +784,7 @@ static int battle_calc_drain(int damage, int rate, int per)
{
int diff = 0;
- if (per && rand()%1000 < rate) {
+ if (per && rnd()%1000 < rate) {
diff = (damage * per) / 100;
if (diff == 0) {
if (per > 0)
@@ -949,7 +950,7 @@ static int battle_calc_base_damage(struct status_data *status, struct weapon_atk
//Weapon Damage calculation
if (!(flag&1))
- damage = (atkmax>atkmin? rand()%(atkmax-atkmin):0)+atkmin;
+ damage = (atkmax>atkmin? rnd()%(atkmax-atkmin):0)+atkmin;
else
damage = atkmax;
@@ -957,7 +958,7 @@ static int battle_calc_base_damage(struct status_data *status, struct weapon_atk
{
//rodatazone says the range is 0~arrow_atk-1 for non crit
if (flag&2 && sd->arrow_atk)
- damage += ((flag&1)?sd->arrow_atk:rand()%sd->arrow_atk);
+ damage += ((flag&1)?sd->arrow_atk:rnd()%sd->arrow_atk);
//SizeFix only for players
if (!(sd->special_state.no_sizefix || (flag&8)))
@@ -977,12 +978,12 @@ static int battle_calc_base_damage(struct status_data *status, struct weapon_atk
if(sd) {
if (type == EQI_HAND_L) {
if(sd->left_weapon.overrefine)
- damage += rand()%sd->left_weapon.overrefine+1;
+ damage += rnd()%sd->left_weapon.overrefine+1;
if (sd->weapon_atk_rate[sd->weapontype2])
damage += damage*sd->weapon_atk_rate[sd->weapontype2]/100;;
} else { //Right hand
if(sd->right_weapon.overrefine)
- damage += rand()%sd->right_weapon.overrefine+1;
+ damage += rnd()%sd->right_weapon.overrefine+1;
if (sd->weapon_atk_rate[sd->weapontype1])
damage += damage*sd->weapon_atk_rate[sd->weapontype1]/100;;
}
@@ -1184,7 +1185,7 @@ static struct Damage battle_calc_weapon_attack(struct block_list *src,struct blo
} else //Range for normal attacks.
wd.flag |= flag.arrow?BF_LONG:BF_SHORT;
- if ( (!skill_num || skill_num == PA_SACRIFICE) && tstatus->flee2 && rand()%1000 < tstatus->flee2 )
+ if ( (!skill_num || skill_num == PA_SACRIFICE) && tstatus->flee2 && rnd()%1000 < tstatus->flee2 )
{ //Check for Lucky Dodge
wd.type=0x0b;
wd.dmg_lv=ATK_LUCKY;
@@ -1206,7 +1207,7 @@ static struct Damage battle_calc_weapon_attack(struct block_list *src,struct blo
else if( s_ele == -2 ) //Use enchantment's element
s_ele = s_ele_ = status_get_attack_sc_element(src,sc);
else if( s_ele == -3 ) //Use random element
- s_ele = s_ele_ = rand()%ELE_MAX;
+ s_ele = s_ele_ = rnd()%ELE_MAX;
switch( skill_num )
{
case GS_GROUNDDRIFT:
@@ -1233,13 +1234,13 @@ static struct Damage battle_calc_weapon_attack(struct block_list *src,struct blo
if( ( ( skill_lv = pc_checkskill(sd,TF_DOUBLE) ) > 0 && sd->weapontype1 == W_DAGGER )
|| ( sd->double_rate > 0 && sd->weapontype1 != W_FIST ) ) //Will fail bare-handed
{ //Success chance is not added, the higher one is used [Skotlex]
- if( rand()%100 < ( 5*skill_lv > sd->double_rate ? 5*skill_lv : sd->double_rate ) )
+ if( rnd()%100 < ( 5*skill_lv > sd->double_rate ? 5*skill_lv : sd->double_rate ) )
{
wd.div_ = skill_get_num(TF_DOUBLE,skill_lv?skill_lv:1);
wd.type = 0x08;
}
}
- else if( sd->weapontype1 == W_REVOLVER && (skill_lv = pc_checkskill(sd,GS_CHAINACTION)) > 0 && rand()%100 < 5*skill_lv )
+ else if( sd->weapontype1 == W_REVOLVER && (skill_lv = pc_checkskill(sd,GS_CHAINACTION)) > 0 && rnd()%100 < 5*skill_lv )
{
wd.div_ = skill_get_num(GS_CHAINACTION,skill_lv);
wd.type = 0x08;
@@ -1288,7 +1289,7 @@ static struct Damage battle_calc_weapon_attack(struct block_list *src,struct blo
}
if(tsd && tsd->critical_def)
cri = cri*(100-tsd->critical_def)/100;
- if (rand()%1000 < cri)
+ if (rnd()%1000 < cri)
flag.cri= 1;
}
if (flag.cri)
@@ -1296,7 +1297,7 @@ static struct Damage battle_calc_weapon_attack(struct block_list *src,struct blo
wd.type = 0x0a;
flag.idef = flag.idef2 = flag.hit = 1;
} else { //Check for Perfect Hit
- if(sd && sd->perfect_hit > 0 && rand()%100 < sd->perfect_hit)
+ if(sd && sd->perfect_hit > 0 && rnd()%100 < sd->perfect_hit)
flag.hit = 1;
if (sc && sc->data[SC_FUSION]) {
flag.hit = 1; //SG_FUSION always hit [Komurka]
@@ -1392,7 +1393,7 @@ static struct Damage battle_calc_weapon_attack(struct block_list *src,struct blo
hitrate = cap_value(hitrate, battle_config.min_hitrate, battle_config.max_hitrate);
- if(rand()%100 >= hitrate)
+ if(rnd()%100 >= hitrate)
wd.dmg_lv = ATK_FLEE;
else
flag.hit = 1;
@@ -1921,7 +1922,7 @@ static struct Damage battle_calc_weapon_attack(struct block_list *src,struct blo
skillratio += 400 + 50 * skill_lv;
if( status_get_lv(src) > 100 ) skillratio += skillratio * (status_get_lv(src) - 100) / 200; // Base level bonus.
if( tsc && (tsc->data[SC_BITE] || tsc->data[SC_ANKLE] || tsc->data[SC_ELECTRICSHOCKER]) )
- wd.div_ = tstatus->size + 2 + rand()%2;
+ wd.div_ = tstatus->size + 2 + rnd()%2;
break;
case RA_CLUSTERBOMB:
skillratio += 100 + 100 * skill_lv;
@@ -2069,7 +2070,7 @@ static struct Damage battle_calc_weapon_attack(struct block_list *src,struct blo
break;
case GS_MAGICALBULLET:
if(sstatus->matk_max>sstatus->matk_min) {
- ATK_ADD(sstatus->matk_min+rand()%(sstatus->matk_max-sstatus->matk_min));
+ ATK_ADD(sstatus->matk_min+rnd()%(sstatus->matk_max-sstatus->matk_min));
} else {
ATK_ADD(sstatus->matk_min);
}
@@ -2228,7 +2229,7 @@ static struct Damage battle_calc_weapon_attack(struct block_list *src,struct blo
if (tsd) //Sd vit-eq
{ //[VIT*0.5] + rnd([VIT*0.3], max([VIT*0.3],[VIT^2/150]-1))
vit_def = def2*(def2-15)/150;
- vit_def = def2/2 + (vit_def>0?rand()%vit_def:0);
+ vit_def = def2/2 + (vit_def>0?rnd()%vit_def:0);
if((battle_check_undead(sstatus->race,sstatus->def_ele) || sstatus->race==RC_DEMON) && //This bonus already doesnt work vs players
src->type == BL_MOB && (skill=pc_checkskill(tsd,AL_DP)) > 0)
@@ -2239,7 +2240,7 @@ static struct Damage battle_calc_weapon_attack(struct block_list *src,struct blo
} else { //Mob-Pet vit-eq
//VIT + rnd(0,[VIT/20]^2-1)
vit_def = (def2/20)*(def2/20);
- vit_def = def2 + (vit_def>0?rand()%vit_def:0);
+ vit_def = def2 + (vit_def>0?rnd()%vit_def:0);
}
if (battle_config.weapon_defense_type) {
@@ -2743,7 +2744,7 @@ struct Damage battle_calc_magic_attack(struct block_list *src,struct block_list
else if (s_ele == -2) //Use status element
s_ele = status_get_attack_sc_element(src,status_get_sc(src));
else if( s_ele == -3 ) //Use random element
- s_ele = rand()%ELE_MAX;
+ s_ele = rnd()%ELE_MAX;
//Set miscellaneous data that needs be filled
if(sd) {
@@ -2798,7 +2799,7 @@ struct Damage battle_calc_magic_attack(struct block_list *src,struct block_list
i = 20*skill_lv + sstatus->luk + sstatus->int_ + status_get_lv(src)
+ 200 - 200*tstatus->hp/tstatus->max_hp;
if(i > 700) i = 700;
- if(rand()%1000 < i && !(tstatus->mode&MD_BOSS))
+ if(rnd()%1000 < i && !(tstatus->mode&MD_BOSS))
ad.damage = tstatus->hp;
else
ad.damage = status_get_lv(src) + sstatus->int_ + skill_lv * 10;
@@ -2823,10 +2824,10 @@ struct Damage battle_calc_magic_attack(struct block_list *src,struct block_list
* -> statusMATK holds the %Matk modifier stuff from earlier and lastly:
* -> the mdef part is not applied at this point, but later.
**/ //1:bugreport:5101 //1:bugreport:5101
- MATK_ADD((1+sstatus->matk_max) * 2 + 15/10 * sstatus->matk_min + rand()% ( sstatus->matk_max + (1 + (sstatus->matk_max*sstatus->wlv) / 10 * 2 + 10/15 * sstatus->matk_min ) ));
+ MATK_ADD((1+sstatus->matk_max) * 2 + 15/10 * sstatus->matk_min + rnd()% ( sstatus->matk_max + (1 + (sstatus->matk_max*sstatus->wlv) / 10 * 2 + 10/15 * sstatus->matk_min ) ));
#else //Ancient MATK Appliance
if (sstatus->matk_max > sstatus->matk_min) {
- MATK_ADD(sstatus->matk_min+rand()%(1+sstatus->matk_max-sstatus->matk_min));
+ MATK_ADD(sstatus->matk_min+rnd()%(1+sstatus->matk_max-sstatus->matk_min));
} else {
MATK_ADD(sstatus->matk_min);
}
@@ -3314,7 +3315,7 @@ struct Damage battle_calc_misc_attack(struct block_list *src,struct block_list *
if (s_ele < 0 && s_ele != -3) //Attack that takes weapon's element for misc attacks? Make it neutral [Skotlex]
s_ele = ELE_NEUTRAL;
else if (s_ele == -3) //Use random element
- s_ele = rand()%ELE_MAX;
+ s_ele = rnd()%ELE_MAX;
//Skill Range Criteria
md.flag |= battle_range_type(src, target, skill_num, skill_lv);
@@ -3365,14 +3366,14 @@ struct Damage battle_calc_misc_attack(struct block_list *src,struct block_list *
md.damage=3;
break;
case NPC_DARKBREATH:
- md.damage = 500 + (skill_lv-1)*1000 + rand()%1000;
+ md.damage = 500 + (skill_lv-1)*1000 + rnd()%1000;
if(md.damage > 9999) md.damage = 9999;
break;
case PA_PRESSURE:
md.damage=500+300*skill_lv;
break;
case PA_GOSPEL:
- md.damage = 1+rand()%9999;
+ md.damage = 1+rnd()%9999;
break;
case CR_ACIDDEMONSTRATION: // updated the formula based on a Japanese formula found to be exact [Reddozen]
if(tstatus->vit+sstatus->int_) //crash fix
@@ -3388,7 +3389,7 @@ struct Damage battle_calc_misc_attack(struct block_list *src,struct block_list *
case NJ_ZENYNAGE:
md.damage = skill_get_zeny(skill_num ,skill_lv);
if (!md.damage) md.damage = 2;
- md.damage = md.damage + rand()%md.damage;
+ md.damage = md.damage + rnd()%md.damage;
if (is_boss(target))
md.damage=md.damage/3;
else if (tsd)
@@ -3401,7 +3402,7 @@ struct Damage battle_calc_misc_attack(struct block_list *src,struct block_list *
md.damage = sstatus->max_hp * (50 + 50 * skill_lv) / 100 ;
break ;
case ASC_BREAKER:
- md.damage = 500+rand()%500 + 5*skill_lv * sstatus->int_;
+ md.damage = 500+rnd()%500 + 5*skill_lv * sstatus->int_;
nk|=NK_IGNORE_FLEE|NK_NO_ELEFIX; //These two are not properties of the weapon based part.
break;
case HW_GRAVITATION:
@@ -3477,7 +3478,7 @@ struct Damage battle_calc_misc_attack(struct block_list *src,struct block_list *
hitrate+= sstatus->hit - flee;
hitrate = cap_value(hitrate, battle_config.min_hitrate, battle_config.max_hitrate);
- if(rand()%100 < hitrate)
+ if(rnd()%100 < hitrate)
i = 1;
}
if (!i) {
@@ -3670,7 +3671,7 @@ void battle_drain(TBL_PC *sd, struct block_list *tbl, int rdamage, int ldamage,
}
}
- if (sd->sp_vanish_rate && rand()%1000 < sd->sp_vanish_rate)
+ if (sd->sp_vanish_rate && rnd()%1000 < sd->sp_vanish_rate)
status_percent_damage(&sd->bl, tbl, 0, (unsigned char)sd->sp_vanish_per, false);
if (!thp && !tsp) return;
@@ -3821,7 +3822,7 @@ enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* t
triple_rate+= triple_rate*(sc->data[SC_SKILLRATE_UP]->val2)/100;
status_change_end(src, SC_SKILLRATE_UP, INVALID_TIMER);
}
- if (rand()%100 < triple_rate)
+ if (rnd()%100 < triple_rate)
//FIXME: invalid return type!
return (damage_lv)skill_attack(BF_WEAPON,src,src,target,MO_TRIPLEATTACK,skillv,tick,0);
}
@@ -3867,10 +3868,10 @@ enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* t
damage = wd.damage + wd.damage2;
if( damage > 0 && src != target )
{
- if( sc && sc->data[SC_DUPLELIGHT] && (wd.flag&BF_SHORT) && rand()%100 <= 10+2*sc->data[SC_DUPLELIGHT]->val1 )
+ if( sc && sc->data[SC_DUPLELIGHT] && (wd.flag&BF_SHORT) && rnd()%100 <= 10+2*sc->data[SC_DUPLELIGHT]->val1 )
{ // Activates it only from melee damage
int skillid;
- if( rand()%2 == 1 )
+ if( rnd()%2 == 1 )
skillid = AB_DUPLELIGHT_MELEE;
else
skillid = AB_DUPLELIGHT_MAGIC;
@@ -3916,11 +3917,11 @@ enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* t
status_change_end(target, SC_DEVOTION, INVALID_TIMER);
}
- if (sc && sc->data[SC_AUTOSPELL] && rand()%100 < sc->data[SC_AUTOSPELL]->val4) {
+ if (sc && sc->data[SC_AUTOSPELL] && rnd()%100 < sc->data[SC_AUTOSPELL]->val4) {
int sp = 0;
int skillid = sc->data[SC_AUTOSPELL]->val2;
int skilllv = sc->data[SC_AUTOSPELL]->val3;
- int i = rand()%100;
+ int i = rnd()%100;
if (sc->data[SC_SPIRIT] && sc->data[SC_SPIRIT]->val2 == SL_SAGE)
i = 0; //Max chance, no skilllv reduction. [Skotlex]
if (i >= 50) skilllv -= 2;
@@ -3958,7 +3959,7 @@ enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* t
if (tsc) {
if (tsc->data[SC_POISONREACT] &&
- (rand()%100 < tsc->data[SC_POISONREACT]->val3
+ (rnd()%100 < tsc->data[SC_POISONREACT]->val3
|| sstatus->def_ele == ELE_POISON) &&
// check_distance_bl(src, target, tstatus->rhw.range+1) && Doesn't checks range! o.O;
status_check_skilluse(target, src, TF_POISON, 0)