From 09e291009156002e83566afe7a10b6509f5463f5 Mon Sep 17 00:00:00 2001 From: Kenpachi Developer Date: Thu, 13 Feb 2020 08:29:47 +0100 Subject: Add enum for pet intimacy levels and use its constants --- src/map/atcommand.c | 2 +- src/map/clif.c | 4 ++-- src/map/pc.c | 6 +++--- src/map/pet.c | 26 +++++++++++++------------- src/map/script.c | 9 +++++++++ src/map/status.c | 2 +- src/map/unit.c | 6 +++--- 7 files changed, 32 insertions(+), 23 deletions(-) (limited to 'src/map') 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. -- cgit v1.2.3-70-g09d2