summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
authorskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-09-08 18:45:51 +0000
committerskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-09-08 18:45:51 +0000
commit7a308b07b92f9aa82b0e3d8dc987d69f3535b7e2 (patch)
tree2b7f00c9f373b187f821c63127187120770f66f1 /src/map
parent9e9b198e6d0b810fa52f888b32653b5370fe65b3 (diff)
downloadhercules-7a308b07b92f9aa82b0e3d8dc987d69f3535b7e2.tar.gz
hercules-7a308b07b92f9aa82b0e3d8dc987d69f3535b7e2.tar.bz2
hercules-7a308b07b92f9aa82b0e3d8dc987d69f3535b7e2.tar.xz
hercules-7a308b07b92f9aa82b0e3d8dc987d69f3535b7e2.zip
- 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://rathena.svn.sourceforge.net/svnroot/rathena/trunk@8680 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map')
-rw-r--r--src/map/clif.c4
-rw-r--r--src/map/clif.h2
-rw-r--r--src/map/pc.c33
-rw-r--r--src/map/pc.h5
-rw-r--r--src/map/skill.c46
5 files changed, 37 insertions, 53 deletions
diff --git a/src/map/clif.c b/src/map/clif.c
index 3b2395812..a8970a8b1 100644
--- a/src/map/clif.c
+++ b/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]);
}
diff --git a/src/map/clif.h b/src/map/clif.h
index 94255b31f..067be9dc5 100644
--- a/src/map/clif.h
+++ b/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]
diff --git a/src/map/pc.c b/src/map/pc.c
index 4af78ffe3..0ec41a6c2 100644
--- a/src/map/pc.c
+++ b/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;
+
// 位置の設定
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;
diff --git a/src/map/pc.h b/src/map/pc.h
index d1b7ea964..ee688cd41 100644
--- a/src/map/pc.h
+++ b/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];
diff --git a/src/map/skill.c b/src/map/skill.c
index 87df0e1ac..eea144311 100644
--- a/src/map/skill.c
+++ b/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;