فهرست منبع

Homunculus intimacy check
* Moved out intimacy required to evo the homun to conf/battle/homunc.conf: 'homunculus_evo_intimacy_need'
* Moved out intimacy reset after evo the homun to conf/battle/homunc.conf: 'homunculus_evo_intimacy_reset'
* Follow up eca4fa0e38c060c0f9918d11899ee00d099a16f7, missed the '/100' for intimacy info.
* Corrected intimacy set after using skill 'HVAN_EXPLOSION' to 1 (100, Hate with passion) instead of 2 (200, is for HFLI_SBR44)
* Init 'hardcoded' homunculus intimacy grade tables for some lookups

Signed-off-by: Cydh Ramdh <house.bad@gmail.com>

Cydh Ramdh 10 سال پیش
والد
کامیت
36be5aa5b9
7فایلهای تغییر یافته به همراه76 افزوده شده و 26 حذف شده
  1. 6 0
      conf/battle/homunc.conf
  2. 2 0
      src/map/battle.c
  3. 2 0
      src/map/battle.h
  4. 48 20
      src/map/homunculus.c
  5. 12 0
      src/map/homunculus.h
  6. 1 1
      src/map/script.c
  7. 5 5
      src/map/skill.c

+ 6 - 0
conf/battle/homunc.conf

@@ -27,6 +27,12 @@ homunculus_friendly_rate: 100
 // Can you name a homunculus more then once? (Note 1)
 hom_rename: no
 
+// Minimum intimacy to evo the homunculus
+homunculus_evo_intimacy_need: 91100
+
+// Reset intimacy after evolution to:
+homunculus_evo_intimacy_reset: 1000
+
 // Intimacy needed to use Evolved Vanilmirth's Bio Explosion
 hvan_explosion_intimate: 45000
 

+ 2 - 0
src/map/battle.c

@@ -7960,6 +7960,8 @@ static const struct _battle_data {
 	{ "default_fixed_castrate",             &battle_config.default_fixed_castrate,          20,     0,      100,            },
 	{ "default_bind_on_equip",              &battle_config.default_bind_on_equip,           BOUND_CHAR, BOUND_NONE, BOUND_MAX-1, },
 	{ "pet_ignore_infinite_def",            &battle_config.pet_ignore_infinite_def,         0,      0,      1,              },
+	{ "homunculus_evo_intimacy_need",       &battle_config.homunculus_evo_intimacy_need,    91100,  0,      INT_MAX,        },
+	{ "homunculus_evo_intimacy_reset",      &battle_config.homunculus_evo_intimacy_reset,   1000,   0,      INT_MAX,        },
 };
 
 #ifndef STATS_OPT_OUT

+ 2 - 0
src/map/battle.h

@@ -585,6 +585,8 @@ extern struct Battle_Config
 	int default_fixed_castrate;
 	int default_bind_on_equip;
 	int pet_ignore_infinite_def; // Makes fixed damage of petskillattack2 ignores infinite defense
+	int homunculus_evo_intimacy_need;
+	int homunculus_evo_intimacy_reset;
 } battle_config;
 
 void do_init_battle(void);

+ 48 - 20
src/map/homunculus.c

@@ -33,6 +33,22 @@ static unsigned int hexptbl[MAX_LEVEL];
 //For holding the view data of npc classes. [Skotlex]
 static struct view_data hom_viewdb[MAX_HOMUNCULUS_CLASS];
 
+struct s_homun_intimacy_grade {
+	//const char *grade;
+	uint32 min_value;
+};
+
+/// Intimacy grade, order based on enum e_homun_grade
+static struct s_homun_intimacy_grade intimacy_grades[] = {
+	{ /*"Hate with passion",*/   100 },
+	{ /*"Hate",             */   400 },
+	{ /*"Awkward",          */  1100 },
+	{ /*"Shy",              */ 10100 },
+	{ /*"Neutral",          */ 25100 },
+	{ /*"Cordial",          */ 75100 },
+	{ /*"Loyal",            */ 91100 },
+};
+
 /**
 * Check if the skill is a valid homunculus skill based skill range or availablity in skill db
 * @param skill_id
@@ -302,7 +318,7 @@ void hom_calc_skilltree(struct homun_data *hd, int flag_evolve)
 		if (hd->homunculus.hskill[idx].id)
 			continue; //Skill already known.
 		intimacy = (flag_evolve) ? 10 : hd->homunculus.intimacy;
-		if (intimacy < hskill_tree[c][i].intimacylv)
+		if (intimacy < hskill_tree[c][i].intimacylv * 100)
 			continue;
 		if (!battle_config.skillfree) {
 			int j;
@@ -538,7 +554,7 @@ int hom_evolution(struct homun_data *hd)
 	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;
+	hom->intimacy = battle_config.homunculus_evo_intimacy_reset;
 
 	unit_remove_map(&hd->bl, CLR_OUTSIGHT);
 	if (map_addblock(&hd->bl))
@@ -1289,28 +1305,40 @@ int hom_shuffle(struct homun_data *hd)
 	return 1;
 }
 
+/**
+ * Get minimum intimacy value of specified grade
+ * @param grade see enum e_homun_grade
+ * @return Intimacy value
+ **/
+uint32 hom_intimacy_grade2intimacy(enum e_homun_grade grade) {
+	if (grade < HOMGRADE_HATE_WITH_PASSION || grade > HOMGRADE_LOYAL)
+		return 0;
+	return intimacy_grades[grade].min_value;
+}
+
+/**
+ * Get grade of given intimacy value
+ * @param intimacy
+ * @return Grade, see enum e_homun_grade
+ **/
+enum e_homun_grade hom_intimacy_intimacy2grade(uint32 intimacy) {
+#define CHK_HOMINTIMACY(grade) { if (intimacy >= intimacy_grades[(grade)].min_value) return (grade); }
+	CHK_HOMINTIMACY(HOMGRADE_LOYAL)
+	CHK_HOMINTIMACY(HOMGRADE_CORDIAL)
+	CHK_HOMINTIMACY(HOMGRADE_NEUTRAL)
+	CHK_HOMINTIMACY(HOMGRADE_SHY)
+	CHK_HOMINTIMACY(HOMGRADE_AWKWARD)
+	CHK_HOMINTIMACY(HOMGRADE_HATE)
+#undef CHK_HOMINTIMACY
+	return HOMGRADE_HATE_WITH_PASSION;
+}
+
 /**
 * Get initmacy grade
 * @param hd
 */
-uint8 hom_get_intimacy_grade(struct homun_data *hd)
-{
-	unsigned int val = hd->homunculus.intimacy / 100;
-
-	if( val > 100 ) {
-		if( val > 250 ) {
-			if( val > 750 ) {
-				if ( val > 900 )
-					return 4;
-				else
-					return 3;
-			} else
-				return 2;
-		} else
-			return 1;
-	}
-
-	return 0;
+uint8 hom_get_intimacy_grade(struct homun_data *hd) {
+	return hom_intimacy_intimacy2grade(hd->homunculus.intimacy);
 }
 
 /**

+ 12 - 0
src/map/homunculus.h

@@ -125,6 +125,16 @@ enum homun_setting {
 	HOMSET_RESET_REUSESKILL_TELEPORTED	= 0x80, /// Skill re-use delay is reset when they are warped (by skill or item) with player.
 };
 
+enum e_homun_grade {
+	HOMGRADE_HATE_WITH_PASSION = 0,
+	HOMGRADE_HATE,
+	HOMGRADE_AWKWARD,
+	HOMGRADE_SHY,
+	HOMGRADE_NEUTRAL,
+	HOMGRADE_CORDIAL,
+	HOMGRADE_LOYAL,
+};
+
 /// Check Homunculus Class ID
 #define homdb_checkid(id) (id >=  HM_CLASS_BASE && id <= HM_CLASS_MAX)
 
@@ -171,6 +181,8 @@ void hom_addspiritball(TBL_HOM *hd, int max);
 void hom_delspiritball(TBL_HOM *hd, int count, int type);
 
 uint8 hom_get_intimacy_grade(struct homun_data *hd);
+uint32 hom_intimacy_grade2intimacy(enum e_homun_grade grade);
+enum e_homun_grade hom_intimacy_intimacy2grade(uint32 intimacy);
 
 void do_final_homunculus(void);
 void do_init_homunculus(void);

+ 1 - 1
src/map/script.c

@@ -10611,7 +10611,7 @@ BUILDIN_FUNC(homunculus_evolution)
 
 	if(hom_is_active(sd->hd))
 	{
-		if (sd->hd->homunculus.intimacy > 91000)
+		if (sd->hd->homunculus.intimacy >= battle_config.homunculus_evo_intimacy_need)
 			hom_evolution(sd->hd);
 		else
 			clif_emotion(&sd->hd->bl, E_SWT);

+ 5 - 5
src/map/skill.c

@@ -655,7 +655,7 @@ bool skill_isNotOk_hom(uint16 skill_id, struct homun_data *hd)
 
 	switch(skill_id) {
 		case MH_LIGHT_OF_REGENE: //must be cordial
-			if (hom_get_intimacy_grade(hd) != 4) {
+			if (hom_get_intimacy_grade(hd) < HOMGRADE_CORDIAL) {
 				if (hd->master)
 					clif_skill_fail(hd->master, skill_id, USESKILL_FAIL_RELATIONGRADE, 0);
 				return true;
@@ -2069,7 +2069,7 @@ int skill_counter_additional_effect (struct block_list* src, struct block_list *
 	case HVAN_EXPLOSION:
 		if(src->type == BL_HOM){
 			TBL_HOM *hd = (TBL_HOM*)src;
-			hd->homunculus.intimacy = 200;
+			hd->homunculus.intimacy = (skill_id == HFLI_SBR44) ? 200 : 100; // hom_intimacy_grade2intimacy(HOMGRADE_HATE_WITH_PASSION)
 			if (hd->master)
 				clif_send_homdata(hd->master,SP_INTIMATE,hd->homunculus.intimacy/100);
 		}
@@ -3570,7 +3570,7 @@ static int skill_check_condition_mercenary(struct block_list *bl, int skill, int
 		switch( skill )
 		{
 			case HFLI_SBR44:
-				if( hd->homunculus.intimacy <= 200 )
+				if( hd->homunculus.intimacy <= 200 ) // hom_intimacy_grade2intimacy(HOMGRADE_HATE_WITH_PASSION)
 					return 0;
 				break;
 			case HVAN_EXPLOSION:
@@ -10176,8 +10176,8 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
 			struct block_list *s_bl = battle_get_master(src);
 			if(s_bl) sc_start(src, s_bl, type, 100, skill_lv, skill_get_time(skill_id, skill_lv));
 			sc_start2(src, src, type, 100, skill_lv, hd->homunculus.level, skill_get_time(skill_id, skill_lv));
-			hd->homunculus.intimacy = 25100; //change to neutral (can't be cast if < 750)
-			if(sd) clif_send_homdata(sd, SP_INTIMATE, hd->homunculus.intimacy); //refresh intimacy info
+			hd->homunculus.intimacy = hom_intimacy_grade2intimacy(HOMGRADE_NEUTRAL); //change to neutral
+			if(sd) clif_send_homdata(sd, SP_INTIMATE, hd->homunculus.intimacy/100); //refresh intimacy info
 			skill_blockhomun_start(hd, skill_id, skill_get_cooldown(skill_id, skill_lv));
 		}
 		break;