summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/char/int_pet.c10
-rw-r--r--src/common/mmo.h10
-rw-r--r--src/map/atcommand.c4
-rw-r--r--src/map/clif.c2
-rw-r--r--src/map/pet.c28
-rw-r--r--src/map/script.c10
6 files changed, 39 insertions, 25 deletions
diff --git a/src/char/int_pet.c b/src/char/int_pet.c
index 880de668d..e7be4d762 100644
--- a/src/char/int_pet.c
+++ b/src/char/int_pet.c
@@ -60,7 +60,7 @@ static int inter_pet_tosql(const struct s_pet *p)
nullpo_ret(p);
SQL->EscapeStringLen(inter->sql_handle, esc_name, p->name, strnlen(p->name, NAME_LENGTH));
- hungry = cap_value(p->hungry, 0, 100);
+ hungry = cap_value(p->hungry, PET_HUNGER_STARVING, PET_HUNGER_STUFFED);
intimate = cap_value(p->intimate, 0, 1000);
if (p->pet_id == 0) {
@@ -128,7 +128,7 @@ static int inter_pet_fromsql(int pet_id, struct s_pet *p)
SQL->FreeResult(inter->sql_handle);
- p->hungry = cap_value(p->hungry, 0, 100);
+ p->hungry = cap_value(p->hungry, PET_HUNGER_STARVING, PET_HUNGER_STUFFED);
p->intimate = cap_value(p->intimate, 0, 1000);
if (chr->show_save_log)
@@ -177,14 +177,10 @@ static struct s_pet *inter_pet_create(int account_id, int char_id, int pet_class
inter_pet->pt->egg_id = pet_egg_id;
inter_pet->pt->equip = pet_equip;
inter_pet->pt->intimate = intimate;
- inter_pet->pt->hungry = hungry;
+ inter_pet->pt->hungry = cap_value(hungry, PET_HUNGER_STARVING, PET_HUNGER_STUFFED);
inter_pet->pt->rename_flag = rename_flag;
inter_pet->pt->incubate = incubate;
- if(inter_pet->pt->hungry < 0)
- inter_pet->pt->hungry = 0;
- else if(inter_pet->pt->hungry > 100)
- inter_pet->pt->hungry = 100;
if(inter_pet->pt->intimate < 0)
inter_pet->pt->intimate = 0;
else if(inter_pet->pt->intimate > 1000)
diff --git a/src/common/mmo.h b/src/common/mmo.h
index 25ad350c0..4886ca04b 100644
--- a/src/common/mmo.h
+++ b/src/common/mmo.h
@@ -1378,6 +1378,16 @@ enum questinfo_type {
QINFO_MERCENARY_CLASS
};
+/** Pet hunger level **/
+enum e_pet_hunger_level {
+ PET_HUNGER_STARVING = 0,
+ PET_HUNGER_VERY_HUNGRY = 10,
+ PET_HUNGER_HUNGRY = 25,
+ PET_HUNGER_NEUTRAL = 75,
+ PET_HUNGER_SATISFIED = 90,
+ PET_HUNGER_STUFFED = 100
+};
+
/* packet size constant for itemlist */
#if MAX_INVENTORY > MAX_STORAGE && MAX_INVENTORY > MAX_CART
#define MAX_ITEMLIST MAX_INVENTORY
diff --git a/src/map/atcommand.c b/src/map/atcommand.c
index d3368c3b0..9fc552f5f 100644
--- a/src/map/atcommand.c
+++ b/src/map/atcommand.c
@@ -2774,7 +2774,7 @@ ACMD(makeegg)
sd->status.account_id, sd->status.char_id,
pet->db[pet_id].class_, mob->db(pet->db[pet_id].class_)->lv,
pet->db[pet_id].EggID, 0, (short)pet->db[pet_id].intimate,
- 100, 0, 1, pet->db[pet_id].jname);
+ PET_HUNGER_STUFFED, 0, 1, pet->db[pet_id].jname);
} else {
clif->message(fd, msg_fd(fd,180)); // The monster/egg name/id doesn't exist.
return false;
@@ -2852,7 +2852,7 @@ ACMD(pethungry)
clif->message(fd, msg_fd(fd,184)); // Sorry, but you have no pet.
return false;
}
- if (hungry < 0 || hungry > 100) {
+ if (hungry < PET_HUNGER_STARVING || hungry > PET_HUNGER_STUFFED) {
clif->message(fd, msg_fd(fd,37)); // An invalid number was specified.
return false;
}
diff --git a/src/map/clif.c b/src/map/clif.c
index 83f5751ba..14f5557eb 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -15292,7 +15292,7 @@ static void clif_parse_pet_evolution(int fd, struct map_session_data *sd)
sd->status.account_id, sd->status.char_id,
pet->db[pet_id].class_, mob->db(pet->db[pet_id].class_)->lv,
pet->db[pet_id].EggID, 0, (short)pet->db[pet_id].intimate,
- 100, 0, 1, pet->db[pet_id].jname);
+ PET_HUNGER_STUFFED, 0, 1, pet->db[pet_id].jname);
clif->petEvolutionResult(fd, PET_EVOL_SUCCESS);
} else {
clif->petEvolutionResult(fd, PET_EVOL_UNKNOWN);
diff --git a/src/map/pet.c b/src/map/pet.c
index aeb372c05..39a502d0f 100644
--- a/src/map/pet.c
+++ b/src/map/pet.c
@@ -64,13 +64,13 @@ static int pet_hungry_val(struct pet_data *pd)
{
nullpo_ret(pd);
- if(pd->pet.hungry > 90)
+ if(pd->pet.hungry > PET_HUNGER_SATISFIED)
return 4;
- else if(pd->pet.hungry > 75)
+ else if(pd->pet.hungry > PET_HUNGER_NEUTRAL)
return 3;
- else if(pd->pet.hungry > 25)
+ else if(pd->pet.hungry > PET_HUNGER_HUNGRY)
return 2;
- else if(pd->pet.hungry > 10)
+ else if(pd->pet.hungry > PET_HUNGER_VERY_HUNGRY)
return 1;
else
return 0;
@@ -115,7 +115,7 @@ static int pet_create_egg(struct map_session_data *sd, int item_id)
mob->db(pet->db[pet_id].class_)->lv,
pet->db[pet_id].EggID, 0,
(short)pet->db[pet_id].intimate,
- 100, 0, 1, pet->db[pet_id].jname);
+ PET_HUNGER_STUFFED, 0, 1, pet->db[pet_id].jname);
return 1;
}
@@ -174,7 +174,7 @@ static int pet_target_check(struct map_session_data *sd, struct block_list *bl,
if( bl == NULL || bl->type != BL_MOB || bl->prev == NULL
|| pd->pet.intimate < battle_config.pet_support_min_friendly
- || pd->pet.hungry < 1
+ || pd->pet.hungry <= PET_HUNGER_STARVING
|| pd->pet.class_ == status->get_class(bl))
return 0;
@@ -252,15 +252,15 @@ static int pet_hungry(int tid, int64 tick, int id, intptr_t data)
pd->pet.hungry--;
/* Pet Autofeed */
if (battle_config.feature_enable_pet_autofeed != 0) {
- if (pd->petDB->autofeed == 1 && pd->pet.autofeed == 1 && pd->pet.hungry <= 25) {
+ if (pd->petDB->autofeed == 1 && pd->pet.autofeed == 1 && pd->pet.hungry <= PET_HUNGER_HUNGRY) {
pet->food(sd, pd);
}
}
- if( pd->pet.hungry < 0 )
+ if (pd->pet.hungry < PET_HUNGER_STARVING)
{
pet_stop_attack(pd);
- pd->pet.hungry = 0;
+ pd->pet.hungry = PET_HUNGER_STARVING;
pet->set_intimate(pd, pd->pet.intimate - battle_config.pet_hungry_friendly_decrease);
if( pd->pet.intimate <= 0 )
{
@@ -607,7 +607,7 @@ static int pet_catch_process2(struct map_session_data *sd, int target_id)
status_kill(&md->bl);
clif->pet_roulette(sd,1);
intif->create_pet(sd->status.account_id,sd->status.char_id,pet->db[i].class_,mob->db(pet->db[i].class_)->lv,
- pet->db[i].EggID,0,pet->db[i].intimate,100,0,1,pet->db[i].jname);
+ pet->db[i].EggID, 0, pet->db[i].intimate, PET_HUNGER_STUFFED, 0, 1, pet->db[i].jname);
achievement->validate_taming(sd, pet->db[i].class_);
}
@@ -843,7 +843,7 @@ static int pet_food(struct map_session_data *sd, struct pet_data *pd)
}
pc->delitem(sd, i, 1, 0, DELITEM_NORMAL, LOG_TYPE_CONSUME);
- if (pd->pet.hungry > 90) {
+ if (pd->pet.hungry > PET_HUNGER_SATISFIED) {
pet->set_intimate(pd, pd->pet.intimate - pd->petDB->r_full);
} else {
int add_intimate = 0;
@@ -851,7 +851,7 @@ static int pet_food(struct map_session_data *sd, struct pet_data *pd)
add_intimate = (pd->petDB->r_hungry * battle_config.pet_friendly_rate)/100;
else
add_intimate = pd->petDB->r_hungry;
- if (pd->pet.hungry > 75) {
+ if (pd->pet.hungry > PET_HUNGER_NEUTRAL) {
add_intimate = add_intimate >> 1;
if (add_intimate <= 0)
add_intimate = 1;
@@ -867,8 +867,8 @@ static int pet_food(struct map_session_data *sd, struct pet_data *pd)
}
status_calc_pet(pd, SCO_NONE);
pd->pet.hungry += pd->petDB->fullness;
- if( pd->pet.hungry > 100 )
- pd->pet.hungry = 100;
+ if (pd->pet.hungry > PET_HUNGER_STUFFED)
+ pd->pet.hungry = PET_HUNGER_STUFFED;
clif->send_petdata(sd,pd,2,pd->pet.hungry);
clif->send_petdata(sd,pd,1,pd->pet.intimate);
diff --git a/src/map/script.c b/src/map/script.c
index d575c5925..11ee56180 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -19635,7 +19635,7 @@ static BUILDIN(setunitdata)
setunitdata_check_bounds(4, 0, SHRT_MAX);
break;
case UDT_HUNGER:
- setunitdata_check_bounds(4, 0, 99);
+ setunitdata_check_bounds(4, PET_HUNGER_STARVING, PET_HUNGER_STUFFED); // Pets and Homunculi have the same hunger value bounds.
break;
case UDT_RACE:
case UDT_ELETYPE:
@@ -27713,6 +27713,14 @@ static void script_hardcoded_constants(void)
script->set_constant("PETINFO_EVO_EGGID", PETINFO_EVO_EGGID, false, false);
script->set_constant("PETINFO_AUTOFEED", PETINFO_AUTOFEED, false, false);
+ script->constdb_comment("Pet hunger levels");
+ script->set_constant("PET_HUNGER_STARVING", PET_HUNGER_STARVING, false, false);
+ script->set_constant("PET_HUNGER_VERY_HUNGRY", PET_HUNGER_VERY_HUNGRY, false, false);
+ script->set_constant("PET_HUNGER_HUNGRY", PET_HUNGER_HUNGRY, false, false);
+ script->set_constant("PET_HUNGER_NEUTRAL", PET_HUNGER_NEUTRAL, false, false);
+ script->set_constant("PET_HUNGER_SATISFIED", PET_HUNGER_SATISFIED, false, false);
+ script->set_constant("PET_HUNGER_STUFFED", PET_HUNGER_STUFFED, false, false);
+
script->constdb_comment("monster skill states");
script->set_constant("MSS_ANY", MSS_ANY, false, false);
script->set_constant("MSS_IDLE", MSS_IDLE, false, false);