summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenpachi Developer <Kenpachi.Developer@gmx.de>2020-02-13 08:29:47 +0100
committerHaru <haru@dotalux.com>2020-04-05 21:20:35 +0200
commit09e291009156002e83566afe7a10b6509f5463f5 (patch)
treefd1d323198764c61892f9da7962e1442e2a86a1b
parent554e54afebf3eed9d6293a7891c66320af2586a0 (diff)
downloadhercules-09e291009156002e83566afe7a10b6509f5463f5.tar.gz
hercules-09e291009156002e83566afe7a10b6509f5463f5.tar.bz2
hercules-09e291009156002e83566afe7a10b6509f5463f5.tar.xz
hercules-09e291009156002e83566afe7a10b6509f5463f5.zip
Add enum for pet intimacy levels and use its constants
-rw-r--r--src/char/int_pet.c11
-rw-r--r--src/common/mmo.h11
-rw-r--r--src/map/atcommand.c2
-rw-r--r--src/map/clif.c4
-rw-r--r--src/map/pc.c6
-rw-r--r--src/map/pet.c26
-rw-r--r--src/map/script.c9
-rw-r--r--src/map/status.c2
-rw-r--r--src/map/unit.c6
9 files changed, 46 insertions, 31 deletions
diff --git a/src/char/int_pet.c b/src/char/int_pet.c
index e7be4d762..1c3ca16d6 100644
--- a/src/char/int_pet.c
+++ b/src/char/int_pet.c
@@ -61,7 +61,7 @@ static int inter_pet_tosql(const struct s_pet *p)
SQL->EscapeStringLen(inter->sql_handle, esc_name, p->name, strnlen(p->name, NAME_LENGTH));
hungry = cap_value(p->hungry, PET_HUNGER_STARVING, PET_HUNGER_STUFFED);
- intimate = cap_value(p->intimate, 0, 1000);
+ intimate = cap_value(p->intimate, PET_INTIMACY_NONE, PET_INTIMACY_MAX);
if (p->pet_id == 0) {
// New pet.
@@ -129,7 +129,7 @@ static int inter_pet_fromsql(int pet_id, struct s_pet *p)
SQL->FreeResult(inter->sql_handle);
p->hungry = cap_value(p->hungry, PET_HUNGER_STARVING, PET_HUNGER_STUFFED);
- p->intimate = cap_value(p->intimate, 0, 1000);
+ p->intimate = cap_value(p->intimate, PET_INTIMACY_NONE, PET_INTIMACY_MAX);
if (chr->show_save_log)
ShowInfo("Pet loaded (%d - %s).\n", pet_id, p->name);
@@ -176,16 +176,11 @@ static struct s_pet *inter_pet_create(int account_id, int char_id, int pet_class
inter_pet->pt->level = pet_lv;
inter_pet->pt->egg_id = pet_egg_id;
inter_pet->pt->equip = pet_equip;
- inter_pet->pt->intimate = intimate;
+ inter_pet->pt->intimate = cap_value(intimate, PET_INTIMACY_NONE, PET_INTIMACY_MAX);
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->intimate < 0)
- inter_pet->pt->intimate = 0;
- else if(inter_pet->pt->intimate > 1000)
- inter_pet->pt->intimate = 1000;
-
inter_pet->pt->pet_id = 0; //Signal NEW pet.
if ((inter_pet->pt->pet_id = inter_pet->tosql(inter_pet->pt)) != 0)
return inter_pet->pt;
diff --git a/src/common/mmo.h b/src/common/mmo.h
index 4886ca04b..9421f6e35 100644
--- a/src/common/mmo.h
+++ b/src/common/mmo.h
@@ -1388,6 +1388,17 @@ enum e_pet_hunger_level {
PET_HUNGER_STUFFED = 100
};
+/** Pet intimacy level **/
+enum e_pet_intimacy_level {
+ PET_INTIMACY_NONE = 0,
+ PET_INTIMACY_AWKWARD = 1,
+ PET_INTIMACY_SHY = 100,
+ PET_INTIMACY_NEUTRAL = 250,
+ PET_INTIMACY_CORDIAL = 750,
+ PET_INTIMACY_LOYAL = 900,
+ PET_INTIMACY_MAX = 1000
+};
+
/* 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 9fc552f5f..96093ffec 100644
--- a/src/map/atcommand.c
+++ b/src/map/atcommand.c
@@ -2817,7 +2817,7 @@ ACMD(petfriendly)
return false;
}
- if (friendly < 0 || friendly > 1000)
+ if (friendly < PET_INTIMACY_NONE || friendly > PET_INTIMACY_MAX)
{
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 14f5557eb..162308516 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -10804,7 +10804,7 @@ static void clif_parse_LoadEndAck(int fd, struct map_session_data *sd)
}
}
- if(sd->pd && sd->pd->pet.intimate > 900)
+ if (sd->pd && sd->pd->pet.intimate > PET_INTIMACY_LOYAL)
clif->pet_emotion(sd->pd,(sd->pd->pet.class_ - 100)*100 + 50 + pet->hungry_val(sd->pd));
if(homun_alive(sd->hd))
@@ -15232,7 +15232,7 @@ static void clif_parse_pet_evolution(int fd, struct map_session_data *sd)
}
// Not Loyal Yet
- if (sd->pd == NULL || sd->pd->pet.intimate < 900) {
+ if (sd->pd == NULL || sd->pd->pet.intimate < PET_INTIMACY_LOYAL) {
clif->petEvolutionResult(fd, PET_EVOL_RG_FAMILIAR);
return;
}
diff --git a/src/map/pc.c b/src/map/pc.c
index 6dba997ef..33deb780b 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -5920,7 +5920,7 @@ static int pc_setpos(struct map_session_data *sd, unsigned short map_index, int
sd->regen.state.gc = 1;
}
- if( sd->status.pet_id > 0 && sd->pd && sd->pd->pet.intimate > 0 ) {
+ if (sd->status.pet_id > 0 && sd->pd && sd->pd->pet.intimate > PET_INTIMACY_NONE) {
sd->pd->bl.m = m;
sd->pd->bl.x = sd->pd->ud.to_x = x;
sd->pd->bl.y = sd->pd->ud.to_y = y;
@@ -8046,8 +8046,8 @@ static int pc_dead(struct map_session_data *sd, struct block_list *src)
struct pet_data *pd = sd->pd;
if( !map->list[sd->bl.m].flag.noexppenalty ) {
pet->set_intimate(pd, pd->pet.intimate - pd->petDB->die);
- if( pd->pet.intimate < 0 )
- pd->pet.intimate = 0;
+ if (pd->pet.intimate < PET_INTIMACY_NONE)
+ pd->pet.intimate = PET_INTIMACY_NONE;
clif->send_petdata(sd,sd->pd,1,pd->pet.intimate);
}
if( sd->pd->target_id ) // Unlock all targets...
diff --git a/src/map/pet.c b/src/map/pet.c
index 39a502d0f..592a25d3e 100644
--- a/src/map/pet.c
+++ b/src/map/pet.c
@@ -91,7 +91,7 @@ static void pet_set_intimate(struct pet_data *pd, int value)
status_calc_pc(sd,SCO_NONE);
/* Pet is lost, delete the egg */
- if (value <= 0) {
+ if (value <= PET_INTIMACY_NONE) {
int i;
ARR_FIND(0, sd->status.inventorySize, i, sd->status.inventory[i].card[0] == CARD0_PET &&
@@ -246,7 +246,7 @@ static int pet_hungry(int tid, int64 tick, int id, intptr_t data)
}
pd->pet_hungry_timer = INVALID_TIMER;
- if (pd->pet.intimate <= 0)
+ if (pd->pet.intimate <= PET_INTIMACY_NONE)
return 1; //You lost the pet already, the rest is irrelevant.
pd->pet.hungry--;
@@ -262,9 +262,9 @@ static int pet_hungry(int tid, int64 tick, int id, intptr_t data)
pet_stop_attack(pd);
pd->pet.hungry = PET_HUNGER_STARVING;
pet->set_intimate(pd, pd->pet.intimate - battle_config.pet_hungry_friendly_decrease);
- if( pd->pet.intimate <= 0 )
+ if (pd->pet.intimate <= PET_INTIMACY_NONE)
{
- pd->pet.intimate = 0;
+ pd->pet.intimate = PET_INTIMACY_NONE;
pd->status.speed = pd->db->status.speed;
}
status_calc_pet(pd, SCO_NONE);
@@ -320,9 +320,9 @@ static int pet_performance(struct map_session_data *sd, struct pet_data *pd)
int val;
nullpo_retr(1, pd);
- if (pd->pet.intimate > 900)
+ if (pd->pet.intimate > PET_INTIMACY_LOYAL)
val = (pd->petDB->s_perfor > 0)? 4:3;
- else if(pd->pet.intimate > 750) //TODO: this is way too high
+ else if (pd->pet.intimate > PET_INTIMACY_CORDIAL) //TODO: this is way too high
val = 2;
else
val = 1;
@@ -678,7 +678,7 @@ static int pet_menu(struct map_session_data *sd, int menunum)
return 1;
//You lost the pet already.
- if(!sd->status.pet_id || sd->pd->pet.intimate <= 0 || sd->pd->pet.incubate)
+ if (!sd->status.pet_id || sd->pd->pet.intimate <= PET_INTIMACY_NONE || sd->pd->pet.incubate)
return 1;
egg_id = itemdb->exists(sd->pd->petDB->EggID);
@@ -858,12 +858,12 @@ static int pet_food(struct map_session_data *sd, struct pet_data *pd)
}
pet->set_intimate(pd, pd->pet.intimate + add_intimate);
}
- if (pd->pet.intimate <= 0) {
- pd->pet.intimate = 0;
+ if (pd->pet.intimate <= PET_INTIMACY_NONE) {
+ pd->pet.intimate = PET_INTIMACY_NONE;
pet_stop_attack(pd);
pd->status.speed = pd->db->status.speed;
- } else if (pd->pet.intimate > 1000) {
- pd->pet.intimate = 1000;
+ } else if (pd->pet.intimate > PET_INTIMACY_MAX) {
+ pd->pet.intimate = PET_INTIMACY_MAX;
}
status_calc_pet(pd, SCO_NONE);
pd->pet.hungry += pd->petDB->fullness;
@@ -937,7 +937,7 @@ static int pet_ai_sub_hard(struct pet_data *pd, struct map_session_data *sd, int
if(pd->ud.walktimer != INVALID_TIMER && pd->ud.walkpath.path_pos <= 2)
return 0; //No thinking when you just started to walk.
- if(pd->pet.intimate <= 0) {
+ if (pd->pet.intimate <= PET_INTIMACY_NONE) {
//Pet should just... well, random walk.
pet->randomwalk(pd,tick);
return 0;
@@ -1168,7 +1168,7 @@ static int pet_skill_bonus_timer(int tid, int64 tick, int id, intptr_t data)
if (pd->state.skillbonus && pd->bonus->delay > 0) {
bonus = 0;
duration = pd->bonus->delay*1000; // the duration until pet bonuses will be reactivated again
- } else if (pd->pet.intimate) {
+ } else if (pd->pet.intimate > PET_INTIMACY_NONE) {
bonus = 1;
duration = pd->bonus->duration*1000; // the duration for pet bonuses to be in effect
} else { //Lost pet...
diff --git a/src/map/script.c b/src/map/script.c
index 11ee56180..b6e3b8198 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -27721,6 +27721,15 @@ static void script_hardcoded_constants(void)
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("Pet intimacy levels");
+ script->set_constant("PET_INTIMACY_NONE", PET_INTIMACY_NONE, false, false);
+ script->set_constant("PET_INTIMACY_AWKWARD", PET_INTIMACY_AWKWARD, false, false);
+ script->set_constant("PET_INTIMACY_SHY", PET_INTIMACY_SHY, false, false);
+ script->set_constant("PET_INTIMACY_NEUTRAL", PET_INTIMACY_NEUTRAL, false, false);
+ script->set_constant("PET_INTIMACY_CORDIAL", PET_INTIMACY_CORDIAL, false, false);
+ script->set_constant("PET_INTIMACY_LOYAL", PET_INTIMACY_LOYAL, false, false);
+ script->set_constant("PET_INTIMACY_MAX", PET_INTIMACY_MAX, 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);
diff --git a/src/map/status.c b/src/map/status.c
index 4e7094569..bee5645ad 100644
--- a/src/map/status.c
+++ b/src/map/status.c
@@ -2583,7 +2583,7 @@ static int status_calc_pc_(struct map_session_data *sd, enum e_status_calc_opt o
struct pet_data *pd = sd->pd;
if( pd && pd->petDB && pd->petDB->equip_script && pd->pet.intimate >= battle_config.pet_equip_min_friendly )
script->run(pd->petDB->equip_script,0,sd->bl.id,0);
- if( pd && pd->pet.intimate > 0 && (!battle_config.pet_equip_required || pd->pet.equip > 0) && pd->state.skillbonus == 1 && pd->bonus )
+ if (pd && pd->pet.intimate > PET_INTIMACY_NONE && (!battle_config.pet_equip_required || pd->pet.equip > 0) && pd->state.skillbonus == 1 && pd->bonus)
pc->bonus(sd,pd->bonus->type, pd->bonus->val);
}
diff --git a/src/map/unit.c b/src/map/unit.c
index 56ddb5917..015f755bb 100644
--- a/src/map/unit.c
+++ b/src/map/unit.c
@@ -898,7 +898,7 @@ static int unit_movepos(struct block_list *bl, short dst_x, short dst_y, int eas
} else
npc->untouch_areanpc(sd, bl->m, bl->x, bl->y);
- if( sd->status.pet_id > 0 && sd->pd && sd->pd->pet.intimate > 0 )
+ if (sd->status.pet_id > 0 && sd->pd && sd->pd->pet.intimate > PET_INTIMACY_NONE)
{ // Check if pet needs to be teleported. [Skotlex]
int flag = 0;
struct block_list* pbl = &sd->pd->bl;
@@ -2722,7 +2722,7 @@ static int unit_remove_map(struct block_list *bl, enum clr_type clrtype, const c
case BL_PET:
{
struct pet_data *pd = BL_UCAST(BL_PET, bl);
- if( pd->pet.intimate <= 0 && !(pd->msd && !pd->msd->state.active) ) {
+ if (pd->pet.intimate <= PET_INTIMACY_NONE && !(pd->msd && !pd->msd->state.active)) {
//If logging out, this is deleted on unit->free
clif->clearunit_area(bl,clrtype);
map->delblock(bl);
@@ -2936,7 +2936,7 @@ static int unit_free(struct block_list *bl, enum clr_type clrtype)
aFree (pd->loot);
pd->loot = NULL;
}
- if (pd->pet.intimate > 0) {
+ if (pd->pet.intimate > PET_INTIMACY_NONE) {
intif->save_petdata(pd->pet.account_id,&pd->pet);
} else {
//Remove pet.