Bläddra i källkod

- Cleaned up SG_HATE to use a new function, pc_set_hate_mob to handle setting.
- Updated pc_authok to initialize all mob_hate vars to -1
- Updated clif_hate_mob to receive the hate-type instead of skill-lv.


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

skotlex 18 år sedan
förälder
incheckning
0d30562da5
6 ändrade filer med 38 tillägg och 53 borttagningar
  1. 1 0
      Changelog-Trunk.txt
  2. 2 2
      src/map/clif.c
  3. 1 1
      src/map/clif.h
  4. 29 4
      src/map/pc.c
  5. 3 2
      src/map/pc.h
  6. 2 44
      src/map/skill.c

+ 1 - 0
Changelog-Trunk.txt

@@ -4,6 +4,7 @@ AS OF SVN REV. 5091, WE ARE NOW USING TRUNK.  ALL UNTESTED BUGFIXES/FEATURES GO
 IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
 
 2006/09/08
+	* Cleaned up SG_HATE, hope it works now. [Skotlex]
 	* Removed sg_miracle_skill_duration, replaced it with
 	  sg_miracle_skill_min_duration and sg_miracle_skill_max_duration, to specify
 	  a range for the duration of the skill. [Skotlex]

+ 2 - 2
src/map/clif.c

@@ -8034,7 +8034,7 @@ void clif_feel_info(struct map_session_data *sd, int feel_level)
  * Info about Star Glaldiator hate mob [Komurka]
  *------------------------------------------
  */
-void clif_hate_mob(struct map_session_data *sd, int skilllv,int mob_id)
+void clif_hate_mob(struct map_session_data *sd, int type,int mob_id)
 {
 	int fd=sd->fd;
 	WFIFOHEAD(fd,packet_len_table[0x20e]);
@@ -8046,7 +8046,7 @@ void clif_hate_mob(struct map_session_data *sd, int skilllv,int mob_id)
 	else //Really shouldn't happen...
 		malloc_tsetdword(WFIFOP(fd,2), 0, NAME_LENGTH);
 	WFIFOL(fd,26)=sd->bl.id;
-	WFIFOW(fd,30)=0xa00+skilllv-1;
+	WFIFOW(fd,30)=0xa00+type;
 	WFIFOSET(fd, packet_len_table[0x20e]);
 }
 

+ 1 - 1
src/map/clif.h

@@ -347,7 +347,7 @@ void clif_get_weapon_view(TBL_PC* sd, unsigned short *rhand, unsigned short *lha
 int clif_party_xy_remove(struct map_session_data *sd); //Fix for minimap [Kevin]
 void clif_parse_ReqFeel(int fd, struct map_session_data *sd, int skilllv); 
 void clif_feel_info(struct map_session_data *sd, int feel_level);
-void clif_hate_mob(struct map_session_data *sd, int skilllv,int mob_id);
+void clif_hate_mob(struct map_session_data *sd, int type,int mob_id);
 void clif_mission_mob(struct map_session_data *sd, unsigned short mob_id, unsigned short progress);
 
 // [blackhole89]

+ 29 - 4
src/map/pc.c

@@ -646,6 +646,9 @@ int pc_authok(struct map_session_data *sd, int login_id2, time_t connect_until_t
 	// Moved PVP timer initialisation before set_pos
 	sd->pvp_timer = -1;
 
+	for (i = 0; i < 3; i++)
+		sd->hate_mob[i] = -1;
+
 	// ˆÊ’u‚Ì�Ý’è
 	if ((i=pc_setpos(sd,sd->status.last_point.map, sd->status.last_point.x, sd->status.last_point.y, 0)) != 0) {
 		if(battle_config.error_log)
@@ -764,6 +767,28 @@ int pc_authfail(struct map_session_data *sd) {
 	return 0;
 }
 
+//Attempts to set a mob. 
+int pc_set_hate_mob(struct map_session_data *sd, int pos, struct block_list *bl)
+{
+	const char hate_var[3][NAME_LENGTH] = {"PC_HATE_MOB_SUN","PC_HATE_MOB_MOON","PC_HATE_MOB_STAR"};
+	int class_;
+	if (!sd || !bl || pos < 0 || pos > 2)
+		return 0;
+	if (sd->hate_mob[pos] != -1)	//Can't change hate targets.
+		return 0;
+
+	class_ = status_get_class(bl);
+	if (!pcdb_checkid(class_)) {
+		unsigned int max_hp = status_get_max_hp(bl);
+		if ((pos == 1 && max_hp < 6000) || (pos == 2 && max_hp < 20000))
+			return 0;
+	}
+	sd->hate_mob[pos] = class_;
+	pc_setglobalreg(sd,hate_var[pos],class_+1);
+	clif_hate_mob(sd,pos,class_);
+	return 1;
+}
+
 /*==========================================
  * Invoked once after the char/account/account2 registry variables are received. [Skotlex]
  *------------------------------------------
@@ -771,8 +796,8 @@ int pc_authfail(struct map_session_data *sd) {
 int pc_reg_received(struct map_session_data *sd)
 {
 	int i,j;
-	char feel_var[3][NAME_LENGTH] = {"PC_FEEL_SUN","PC_FEEL_MOON","PC_FEEL_STAR"};
-	char hate_var[3][NAME_LENGTH] = {"PC_HATE_MOB_SUN","PC_HATE_MOB_MOON","PC_HATE_MOB_STAR"};
+	const char feel_var[3][NAME_LENGTH] = {"PC_FEEL_SUN","PC_FEEL_MOON","PC_FEEL_STAR"};
+	const char hate_var[3][NAME_LENGTH] = {"PC_HATE_MOB_SUN","PC_HATE_MOB_MOON","PC_HATE_MOB_STAR"};
 	
 	sd->change_level = pc_readglobalreg(sd,"jobchange_level");
 	sd->die_counter = pc_readglobalreg(sd,"PC_DIE_COUNTER");
@@ -5829,7 +5854,7 @@ int pc_setregstr(struct map_session_data *sd,int reg,char *str)
 	return 0;
 }
 
-int pc_readregistry(struct map_session_data *sd,char *reg,int type) {
+int pc_readregistry(struct map_session_data *sd,const char *reg,int type) {
 	struct global_reg *sd_reg;
 	int i,max;
 	
@@ -5899,7 +5924,7 @@ char* pc_readregistry_str(struct map_session_data *sd,char *reg,int type) {
 	return NULL;
 }
 
-int pc_setregistry(struct map_session_data *sd,char *reg,int val,int type) {
+int pc_setregistry(struct map_session_data *sd,const char *reg,int val,int type) {
 	struct global_reg *sd_reg;
 	int i,*max, regmax;
 

+ 3 - 2
src/map/pc.h

@@ -234,8 +234,8 @@ int pc_setregstr(struct map_session_data *sd,int reg,char *str);
 #define pc_setaccountreg2(sd,reg,val) pc_setregistry(sd,reg,val,1)
 #define pc_readaccountreg2str(sd,reg) pc_readregistry_str(sd,reg,1)
 #define pc_setaccountreg2str(sd,reg,val) pc_setregistry_str(sd,reg,val,1)
-int pc_readregistry(struct map_session_data*,char*,int);
-int pc_setregistry(struct map_session_data*,char*,int,int);
+int pc_readregistry(struct map_session_data*,const char*,int);
+int pc_setregistry(struct map_session_data*,const char*,int,int);
 char *pc_readregistry_str(struct map_session_data*,char*,int);
 int pc_setregistry_str(struct map_session_data*,char*,char*,int);
 
@@ -286,6 +286,7 @@ int pc_delspiritball(struct map_session_data *sd,int,int);
 void pc_addfame(struct map_session_data *sd,int count);
 unsigned char pc_famerank(int char_id, int job);
 int pc_eventtimer(int tid,unsigned int tick,int id,int data); // for npc_dequeue
+int pc_set_hate_mob(struct map_session_data *sd, int pos, struct block_list *bl);
 
 extern struct fame_list smith_fame_list[MAX_FAME_LIST];
 extern struct fame_list chemist_fame_list[MAX_FAME_LIST];

+ 2 - 44
src/map/skill.c

@@ -5409,52 +5409,10 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, in
 		break;	
 
 	case SG_HATE:
-		if (sd && skilllv <= 3) {
+		if (sd) {
 			clif_skill_nodamage(src,bl,skillid,skilllv,1);
-			if (sd->hate_mob[skilllv-1] != -1)
-			{	//Can't change hate targets.
+			if (!pc_set_hate_mob(sd, skilllv-1, bl))
 				clif_skill_fail(sd,skillid,0,0);
-				break;
-			}
-			if(dstsd)  //PC
-			{
-				sd->hate_mob[skilllv-1] = dstsd->status.class_;
-				pc_setglobalreg(sd,"PC_HATE_MOB_STAR",sd->hate_mob[skilllv-1]+1);
-				clif_hate_mob(sd,skilllv,sd->hate_mob[skilllv-1]);
-				break;
-			}
-			if(dstmd) // mob
-			{ 
-				if (sd->hate_mob[skilllv-1] || tstatus->size != skilllv-1)
-				{	//Can't change hate targets / wrong target size
-					clif_skill_fail(sd,skillid,0,0);
-					break;
-				}
-				switch(skilllv)
-				{
-				case 1:
-					sd->hate_mob[0] = dstmd->class_;
-					pc_setglobalreg(sd,"PC_HATE_MOB_SUN",sd->hate_mob[0]+1);
-					clif_hate_mob(sd,skilllv,sd->hate_mob[skilllv-1]);
-					break;
-				case 2:
-					if (tstatus->max_hp>=6000)
-					{
-						sd->hate_mob[1] = dstmd->class_;
-						pc_setglobalreg(sd,"PC_HATE_MOB_MOON",sd->hate_mob[1]+1);
-						clif_hate_mob(sd,skilllv,sd->hate_mob[skilllv-1]);
-					} else clif_skill_fail(sd,skillid,0,0);
-					break;
-				case 3:
-					if (tstatus->max_hp>=20000)
-					{
-						sd->hate_mob[2] = dstmd->class_;
-						pc_setglobalreg(sd,"PC_HATE_MOB_STAR",sd->hate_mob[2]+1);
-						clif_hate_mob(sd,skilllv,sd->hate_mob[skilllv-1]);
-					} else clif_skill_fail(sd,skillid,0,0);
-					break;
-				}
-			}
 		}
 		break;