Просмотр исходного кода

* Moved the homunculus shuffle code to mercenary.c, fixing the bug in the atcommand not using the bonus evolution stats for homunculus.
* Added a new script command "homshuffle" to reset the homunculus stats using NPC.

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@11350 54d463be-8e91-2dee-dedb-b68131a5f0ec

zephyrus 17 лет назад
Родитель
Сommit
383f017009
5 измененных файлов с 71 добавлено и 25 удалено
  1. 3 0
      Changelog-Trunk.txt
  2. 4 25
      src/map/atcommand.c
  3. 50 0
      src/map/mercenary.c
  4. 1 0
      src/map/mercenary.h
  5. 13 0
      src/map/script.c

+ 3 - 0
Changelog-Trunk.txt

@@ -10,6 +10,9 @@ IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
 	- renamed some skill-related data structs (had same name as variables)
 	- commented out custom Venom Splasher countdown messaging code
 	* Bosses now can use teleport on Land Protector [Playtester]
+	- Moved the homunculus shuffle code to mercenary.c, fixing the bug in the
+	  atcommand not using the bonus evolution stats for homunculus.
+	- Adding a new script command "homshuffle" to fix homunculus using NPCs.
 2007/10/01
 	* Fixed various trading/vending glitches [ultramage]
 	- fixed vending_tax not working at all (integer division in r10182)

+ 4 - 25
src/map/atcommand.c

@@ -8137,7 +8137,7 @@ static int atshowmobs_sub(struct block_list *bl,va_list ap)
 
     md = (struct mob_data *)bl;
 
-	 if(md->special_state.ai || md->master_id)
+	if(md->special_state.ai || md->master_id)
 		 return 0; //Hide slaves and player summoned mobs. [Skotlex]
 
     if(fd && (mob_id==-1 || (md->class_==mob_id))){
@@ -8466,9 +8466,6 @@ int atcommand_homstats(const int fd, struct map_session_data* sd, const char* co
 int atcommand_homshuffle(const int fd, struct map_session_data* sd, const char* command, const char* message)
 {
 	struct homun_data *hd;
-	int lv, i, skillpts;
-	unsigned int exp;
-	struct skill b_skill[MAX_HOMUNSKILL];
 	TBL_PC* tsd = sd;
 
 	nullpo_retr(-1, sd);
@@ -8492,28 +8489,10 @@ int atcommand_homshuffle(const int fd, struct map_session_data* sd, const char*
 	}
 
 	hd = tsd->hd;
-	if(!merc_is_hom_active(hd))
+
+	if(!merc_hom_shuffle(hd))
 		return -1;
-	
-	lv = hd->homunculus.level;
-	exp = hd->homunculus.exp;
-	memcpy(&b_skill, &hd->homunculus.hskill, sizeof(b_skill));
-	skillpts = hd->homunculus.skillpts;
-	//Reset values to level 1.
-	merc_reset_stats(hd);
-	//Level it back up
-	for (i = 1; i < lv && hd->exp_next; i++){
-		hd->homunculus.exp += hd->exp_next;
-		merc_hom_levelup(hd);
-	}
-	hd->homunculus.exp = exp;
-	memcpy(&hd->homunculus.hskill, &b_skill, sizeof(b_skill));
-	hd->homunculus.skillpts = skillpts;
-	clif_homskillinfoblock(hd->master);
-	status_calc_homunculus(hd,0);
-	status_percent_heal(&hd->bl, 100, 100);
-	clif_misceffect2(&hd->bl,568);
-	clif_displaymessage(fd, "Homunculus stats altered");
+
 	//Print out the new stats
 	//This will send the commands to the invoker since they all use this fd regardless of sd value.
 	atcommand_homstats(fd, tsd, command, message);

+ 50 - 0
src/map/mercenary.c

@@ -834,6 +834,56 @@ void merc_reset_stats(struct homun_data *hd)
 	hd->homunculus.skillpts = 0;
 }
 
+int merc_hom_shuffle(struct homun_data *hd)
+{
+	struct map_session_data *sd = hd->master;
+	int lv, i, skillpts;
+	unsigned int exp;
+	struct skill b_skill[MAX_HOMUNSKILL];
+
+	if (!merc_is_hom_active(hd))
+		return 0;
+
+	lv = hd->homunculus.level;
+	exp = hd->homunculus.exp;
+	memcpy(&b_skill, &hd->homunculus.hskill, sizeof(b_skill));
+	skillpts = hd->homunculus.skillpts;
+	//Reset values to level 1.
+	merc_reset_stats(hd);
+	//Level it back up
+	for (i = 1; i < lv && hd->exp_next; i++){
+		hd->homunculus.exp += hd->exp_next;
+		merc_hom_levelup(hd);
+	}
+
+	clif_displaymessage(sd->fd, "[Homunculus Stats Altered]");
+
+	if(!hd->homunculusDB->evo_class || hd->homunculus.class_ == hd->homunculusDB->evo_class) {
+		// Homunculus Evolucionado
+		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);
+		clif_displaymessage(sd->fd, "[Adding Bonus Stats for Evolved Homunculus]");
+	}
+
+	hd->homunculus.exp = exp;
+	memcpy(&hd->homunculus.hskill, &b_skill, sizeof(b_skill));
+	hd->homunculus.skillpts = skillpts;
+	clif_homskillinfoblock(sd);
+	status_calc_homunculus(hd,0);
+	status_percent_heal(&hd->bl, 100, 100);
+	clif_misceffect2(&hd->bl,568);
+
+	return 1;
+}
+
 int read_homunculusdb(void)
 {
 	FILE *fp;

+ 1 - 0
src/map/mercenary.h

@@ -44,6 +44,7 @@ int merc_hom_vaporize(struct map_session_data *sd, int flag);
 int merc_resurrect_homunculus(struct map_session_data *sd, unsigned char per, short x, short y);
 void merc_hom_revive(struct homun_data *hd, unsigned int hp, unsigned int sp);
 void merc_reset_stats(struct homun_data *hd);
+int merc_hom_shuffle(struct homun_data *hd); // [Zephyrus]
 void merc_save(struct homun_data *hd);
 int merc_call_homunculus(struct map_session_data *sd);
 int merc_create_homunculus_request(struct map_session_data *sd, int class_);

+ 13 - 0
src/map/script.c

@@ -4022,6 +4022,7 @@ BUILDIN_FUNC(awake);
 BUILDIN_FUNC(getvariableofnpc);
 BUILDIN_FUNC(warpportal);
 BUILDIN_FUNC(homunculus_evolution) ;	//[orn]
+BUILDIN_FUNC(homunculus_shuffle); // [Zephyrus]
 BUILDIN_FUNC(eaclass);
 BUILDIN_FUNC(roclass);
 BUILDIN_FUNC(setitemscript);
@@ -4364,6 +4365,7 @@ struct script_function buildin_func[] = {
 	BUILDIN_DEF(getvariableofnpc,"rs"),
 	BUILDIN_DEF(warpportal,"iisii"),
 	BUILDIN_DEF2(homunculus_evolution,"homevolution",""),	//[orn]
+	BUILDIN_DEF2(homunculus_shuffle,"homshuffle",""),	//[Zephyrus]
 	BUILDIN_DEF(eaclass,"*"),	//[Skotlex]
 	BUILDIN_DEF(roclass,"i*"),	//[Skotlex]
 	BUILDIN_DEF(checkvending,"*"),
@@ -8744,6 +8746,17 @@ BUILDIN_FUNC(homunculus_evolution)
 	return 0;
 }
 
+// [Zephyrus]
+BUILDIN_FUNC(homunculus_shuffle)
+{
+	TBL_PC *sd;
+	sd=script_rid2sd(st);
+	if(merc_is_hom_active(sd->hd))
+		merc_hom_shuffle(sd->hd);
+
+	return 0;
+}
+
 //These two functions bring the eA MAPID_* class functionality to scripts.
 BUILDIN_FUNC(eaclass)
 {