summaryrefslogtreecommitdiff
path: root/src/map/homunculus.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/map/homunculus.c')
-rw-r--r--src/map/homunculus.c55
1 files changed, 26 insertions, 29 deletions
diff --git a/src/map/homunculus.c b/src/map/homunculus.c
index 31cb5b012..d7f1c5f0c 100644
--- a/src/map/homunculus.c
+++ b/src/map/homunculus.c
@@ -7,6 +7,7 @@
#include "../common/timer.h"
#include "../common/nullpo.h"
#include "../common/mmo.h"
+#include "../common/random.h"
#include "../common/showmsg.h"
#include "../common/strlib.h"
#include "../common/utils.h"
@@ -38,10 +39,6 @@
#include <string.h>
#include <math.h>
-
-//Better equiprobability than rand()% [orn]
-#define rand(a, b) (a+(int) ((float)(b-a+1)*rand()/(RAND_MAX+1.0)))
-
struct s_homunculus_db homunculus_db[MAX_HOMUNCULUS_CLASS]; //[orn]
struct skill_tree_entry hskill_tree[MAX_HOMUNCULUS_CLASS][MAX_SKILL_TREE];
@@ -233,14 +230,14 @@ int merc_hom_levelup(struct homun_data *hd)
max = &hd->homunculusDB->gmax;
min = &hd->homunculusDB->gmin;
- growth_max_hp = rand(min->HP, max->HP);
- growth_max_sp = rand(min->SP, max->SP);
- growth_str = rand(min->str, max->str);
- growth_agi = rand(min->agi, max->agi);
- growth_vit = rand(min->vit, max->vit);
- growth_dex = rand(min->dex, max->dex);
- growth_int = rand(min->int_,max->int_);
- growth_luk = rand(min->luk, max->luk);
+ growth_max_hp = rnd_value(min->HP, max->HP);
+ growth_max_sp = rnd_value(min->SP, max->SP);
+ growth_str = rnd_value(min->str, max->str);
+ growth_agi = rnd_value(min->agi, max->agi);
+ growth_vit = rnd_value(min->vit, max->vit);
+ growth_dex = rnd_value(min->dex, max->dex);
+ growth_int = rnd_value(min->int_,max->int_);
+ growth_luk = rnd_value(min->luk, max->luk);
//Aegis discards the decimals in the stat growth values!
growth_str-=growth_str%10;
@@ -308,14 +305,14 @@ int merc_hom_evolution(struct homun_data *hd)
hom = &hd->homunculus;
max = &hd->homunculusDB->emax;
min = &hd->homunculusDB->emin;
- hom->max_hp += rand(min->HP, max->HP);
- hom->max_sp += rand(min->SP, max->SP);
- hom->str += 10*rand(min->str, max->str);
- hom->agi += 10*rand(min->agi, max->agi);
- hom->vit += 10*rand(min->vit, max->vit);
- hom->int_+= 10*rand(min->int_,max->int_);
- hom->dex += 10*rand(min->dex, max->dex);
- hom->luk += 10*rand(min->luk, max->luk);
+ hom->max_hp += rnd_value(min->HP, max->HP);
+ hom->max_sp += rnd_value(min->SP, max->SP);
+ hom->str += 10*rnd_value(min->str, max->str);
+ hom->agi += 10*rnd_value(min->agi, max->agi);
+ hom->vit += 10*rnd_value(min->vit, max->vit);
+ hom->int_+= 10*rnd_value(min->int_,max->int_);
+ hom->dex += 10*rnd_value(min->dex, max->dex);
+ hom->luk += 10*rnd_value(min->luk, max->luk);
hom->intimacy = 500;
unit_remove_map(&hd->bl, CLR_OUTSIGHT);
@@ -651,7 +648,7 @@ int merc_call_homunculus(struct map_session_data *sd)
struct homun_data *hd;
if (!sd->status.hom_id) //Create a new homun.
- return merc_create_homunculus_request(sd, HM_CLASS_BASE + rand(0, 7)) ;
+ return merc_create_homunculus_request(sd, HM_CLASS_BASE + rnd_value(0, 7)) ;
// If homunc not yet loaded, load it
if (!sd->hd)
@@ -859,14 +856,14 @@ int merc_hom_shuffle(struct homun_data *hd)
//Evolved bonuses
struct s_homunculus *hom = &hd->homunculus;
struct h_stats *max = &hd->homunculusDB->emax, *min = &hd->homunculusDB->emin;
- hom->max_hp += rand(min->HP, max->HP);
- hom->max_sp += rand(min->SP, max->SP);
- hom->str += 10*rand(min->str, max->str);
- hom->agi += 10*rand(min->agi, max->agi);
- hom->vit += 10*rand(min->vit, max->vit);
- hom->int_+= 10*rand(min->int_,max->int_);
- hom->dex += 10*rand(min->dex, max->dex);
- hom->luk += 10*rand(min->luk, max->luk);
+ hom->max_hp += rnd_value(min->HP, max->HP);
+ hom->max_sp += rnd_value(min->SP, max->SP);
+ hom->str += 10*rnd_value(min->str, max->str);
+ hom->agi += 10*rnd_value(min->agi, max->agi);
+ hom->vit += 10*rnd_value(min->vit, max->vit);
+ hom->int_+= 10*rnd_value(min->int_,max->int_);
+ hom->dex += 10*rnd_value(min->dex, max->dex);
+ hom->luk += 10*rnd_value(min->luk, max->luk);
}
hd->homunculus.exp = exp;