summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
authorDracoRPG <DracoRPG@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-07-24 16:58:29 +0000
committerDracoRPG <DracoRPG@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-07-24 16:58:29 +0000
commit252476c27cc0829e15fb1f08a50a52e1ec5041b5 (patch)
tree9eb0ac9a0b65aa0cf1ffdf28fce668b6cb523f7a /src/map
parent104696a9505921e4b76ba117dec81efc34622a1a (diff)
downloadhercules-252476c27cc0829e15fb1f08a50a52e1ec5041b5.tar.gz
hercules-252476c27cc0829e15fb1f08a50a52e1ec5041b5.tar.bz2
hercules-252476c27cc0829e15fb1f08a50a52e1ec5041b5.tar.xz
hercules-252476c27cc0829e15fb1f08a50a52e1ec5041b5.zip
Random Homunculus cleanup
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@7857 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map')
-rw-r--r--src/map/clif.c93
-rw-r--r--src/map/mercenary.c56
2 files changed, 61 insertions, 88 deletions
diff --git a/src/map/clif.c b/src/map/clif.c
index f78f1ff90..37b80ce33 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -105,7 +105,7 @@ static const int packet_len_table[MAX_PACKET_DB] = {
//#0x200
26, -1, 26, 10, 18, 26, 11, 34, 14, 36, 10, 0, 0, -1, 32, 10, // 0x20c change to 0 (was 19)
22, 0, 26, 26, 42, -1, -1, 2, 2,282,282,10, 10, -1, -1, 66,
- 10, -1, -1, 8, 10, 2,282, 18, 18, 15, 58, 57, 64, 5, 69, 5,
+ 10, -1, -1, 8, 10, 2,282, 18, 18, 15, 58, 57, 64, 5, 71, 5,
12, 26, 9, 11, -1, -1, 10, 2, 282, 11, 4, 36, -1,-1, 4, 2,
-1, -1, -1, -1, -1, 3, 4, 8, -1, 3, 70, 4, 8,12, 4, 10,
3, 32, -1, 3, 3, 5, 5, 8, 2, 3, -1, -1, 4,-1, 4
@@ -1463,11 +1463,8 @@ int clif_hominfo(struct map_session_data *sd, int flag)
nullpo_retr(0, hd);
-// if ( sd->hd )
-// return 0 ;
-
status = &hd->battle_status;
- memset(buf,0,71); //packet_len_table[0x22e]);
+ memset(buf,0,packet_len_table[0x22e]);
WBUFW(buf,0)=0x22e;
memcpy(WBUFP(buf,2),sd->homunculus.name,NAME_LENGTH);
WBUFB(buf,26)=sd->homunculus.rename_flag * 2;
@@ -1476,7 +1473,7 @@ int clif_hominfo(struct map_session_data *sd, int flag)
WBUFW(buf,27)=sd->homunculus.level;
WBUFW(buf,29)=sd->homunculus.hunger;
WBUFW(buf,31)=(unsigned short) (hd->master->homunculus.intimacy / 100) ;
- WBUFW(buf,33)=0; // equip id
+ WBUFW(buf,33)=0; // equip id
WBUFW(buf,35)=status->rhw.atk2;
WBUFW(buf,37)=status->matk_max;
WBUFW(buf,39)=status->hit;
@@ -1492,17 +1489,14 @@ int clif_hominfo(struct map_session_data *sd, int flag)
WBUFL(buf,59)=sd->homunculus.exp;
WBUFL(buf,63)=hd->exp_next;
WBUFW(buf,67)=sd->homunculus.skillpts;
- WBUFW(buf,69)=1; //hd->attackable; FIXME: Attackable? When exactly is a homun not attackable? [Skotlex]
- clif_send(buf,/*packet_len_table[0x22e]*/71,&sd->bl,SELF);
+ WBUFW(buf,69)=1; // FIXME: Attackable? When exactly is a homun not attackable? [Skotlex]
+ clif_send(buf,packet_len_table[0x22e],&sd->bl,SELF);
return 0;
}
-/*==========================================
- *
- *------------------------------------------
- */
void clif_send_homdata(struct map_session_data *sd, int type, int param) { //[orn]
int fd;
+
nullpo_retv(sd);
nullpo_retv(sd->hd);
@@ -1515,7 +1509,7 @@ void clif_send_homdata(struct map_session_data *sd, int type, int param) { //[or
return;
}
-// like skillinfoblock, just for homunculi.
+
int clif_homskillinfoblock(struct map_session_data *sd) { //[orn]
int fd;
int i,j,c,len=4,id/*, inf2*/;
@@ -1570,38 +1564,37 @@ void clif_homskillup(struct map_session_data *sd, int skill_num) { //[orn]
return;
}
-// Request a Homunculus name change
void clif_parse_ChangeHomunculusName(int fd, struct map_session_data *sd) { //[orn]
- RFIFOHEAD(fd);
+
nullpo_retv(sd);
- nullpo_retv(sd->hd);
+
+ if(sd->hd == NULL)
+ return;
+
+ RFIFOHEAD(fd);
memcpy(sd->homunculus.name,RFIFOP(fd,2),24);
- sd->homunculus.rename_flag = 1 ;
+ sd->homunculus.rename_flag = 1;
clif_hominfo(sd,0);
clif_charnameack(sd->fd,&sd->hd->bl);
}
-// Somebody who is less lazy than me rename this to ReturnToMaster or something
void clif_parse_HomMoveToMaster(int fd, struct map_session_data *sd) { //[orn]
- RFIFOHEAD(fd);
+
nullpo_retv(sd);
- nullpo_retv(sd->hd);
- if ( sd->hd && status_isdead(&sd->hd->bl) )
- return ;
+ if(sd->hd == NULL || status_isdead(&sd->hd->bl) || sd->homunculus.vaporize)
+ return;
- unit_walktoxy(&sd->hd->bl, sd->bl.x,sd->bl.y-1, 0); //move to master
+ unit_walktoxy(&sd->hd->bl, sd->bl.x,sd->bl.y-1, 0);
}
-// Request a Homunculus move-to-position
void clif_parse_HomMoveTo(int fd,struct map_session_data *sd) { //[orn]
int x,y,cmd;
nullpo_retv(sd);
- nullpo_retv(sd->hd);
- if ( sd->hd && status_isdead(&sd->hd->bl) )
- return ;
+ if(sd->hd == NULL || status_isdead(&sd->hd->bl) || sd->homunculus.vaporize)
+ return;
cmd = RFIFOW(fd,0);
x = RFIFOB(fd,packet_db[sd->packet_ver][cmd].pos[0]) * 4 +
@@ -1612,18 +1605,17 @@ void clif_parse_HomMoveTo(int fd,struct map_session_data *sd) { //[orn]
unit_walktoxy(&(sd->hd->bl),x,y,0);
}
-// Request the Homunculus attacking a bl
void clif_parse_HomAttack(int fd,struct map_session_data *sd) { //[orn]
struct block_list *target;
+
nullpo_retv(sd);
- nullpo_retv(sd->hd);
-
- target=map_id2bl(RFIFOL(fd,6));
+
+ if(sd->hd == NULL || status_isdead(&sd->hd->bl) || sd->homunculus.vaporize || sd->hd->bl.id != RFIFOL(fd,2))
+ return;
- if ( sd->hd && target && ( status_isdead(&sd->hd->bl) || status_isdead(target) ) )
- return ;
+ if ((target = map_id2bl(RFIFOL(fd,6))) == NULL || status_isdead(target))
+ return;
- if(sd->hd->bl.id != RFIFOL(fd,2)) return;
merc_stop_walking(sd->hd, 1);
merc_stop_attack(sd->hd);
if ( sd->hd && target ) {
@@ -1634,10 +1626,13 @@ void clif_parse_HomAttack(int fd,struct map_session_data *sd) { //[orn]
void clif_parse_HomMenu(int fd, struct map_session_data *sd) { //[orn]
int cmd;
- cmd = RFIFOW(fd,0);
+
RFIFOHEAD(fd);
- if ( sd->hd && status_isdead(&sd->hd->bl) )
- return ;
+ cmd = RFIFOW(fd,0);
+
+ if(sd->hd == NULL || status_isdead(&sd->hd->bl) || sd->homunculus.vaporize)
+ return;
+
merc_menu(sd,RFIFOB(fd,packet_db[sd->packet_ver][cmd].pos[0]));
}
@@ -1658,27 +1653,6 @@ int clif_hom_food(struct map_session_data *sd,int foodid,int fail) //[orn]
}
/*==========================================
- * orn
- *------------------------------------------
- */
-int clif_hwalkok(struct homun_data *hd)
-{
- int fd;
-
- nullpo_retr(0, hd);
-
- fd=hd->master->fd;
- WFIFOHEAD(fd, packet_len_table[0x87]);
- WFIFOW(fd,0)=0x87;
- WFIFOL(fd,2)=gettick();
- WFIFOPOS2(fd,6,hd->bl.x,hd->bl.y,hd->ud.to_x,hd->ud.to_y);
- WFIFOB(fd,11)=0x88;
- WFIFOSET(fd,packet_len_table[0x87]);
-
- return 0;
-}
-
-/*==========================================
*
*------------------------------------------
*/
@@ -9678,7 +9652,8 @@ static void clif_parse_UseSkillToId_homun(struct homun_data *hd, struct map_sess
{
int lv;
- if (!hd) return;
+ if (!hd)
+ return;
if (skillnotok_hom(skillnum, hd)) //[orn]
return;
diff --git a/src/map/mercenary.c b/src/map/mercenary.c
index 9521f7071..b04d304ea 100644
--- a/src/map/mercenary.c
+++ b/src/map/mercenary.c
@@ -34,8 +34,6 @@
#include "mercenary.h"
#include "charsave.h"
-typedef char char32[32];
-
static int dirx[8]={0,-1,-1,-1,0,1,1,1}; //[orn]
static int diry[8]={1,1,0,-1,-1,-1,0,1}; //[orn]
@@ -45,11 +43,6 @@ static int diry[8]={1,1,0,-1,-1,-1,0,1}; //[orn]
struct homunculus_db homunculus_db[MAX_HOMUNCULUS_CLASS]; //[orn]
struct skill_tree_entry hskill_tree[MAX_HOMUNCULUS_CLASS][MAX_SKILL_TREE];
-char32 merc_skillname[20] = {"NULL","HLIF_HEAL","HLIF_AVOID","HLIF_BRAIN","HLIF_CHANGE",
- "HAMI_CASTLE","HAMI_DEFENCE","HAMI_SKIN","HAMI_BLOODLUST",
- "HFLI_MOON","HFLI_FLEET","HFLI_SPEED","HFLI_SBR44",
- "HVAN_CAPRICE","HVAN_CHAOTIC","HVAN_INSTRUCT","HVAN_EXPLOSION"};
-
void merc_load_exptables(void);
int mercskill_castend_id( int tid, unsigned int tick, int id,int data );
static int merc_hom_hungry(int tid,unsigned int tick,int id,int data);
@@ -111,11 +104,6 @@ void merc_load_exptables(void)
}
-char *merc_hom_skill_get_name(int id)
-{
- return merc_skillname[id-HM_SKILLBASE];
-}
-
void merc_damage(struct homun_data *hd,struct block_list *src,int hp,int sp)
{
nullpo_retv(hd);
@@ -150,6 +138,7 @@ int merc_hom_dead(struct homun_data *hd, struct block_list *src)
int merc_hom_delete(struct homun_data *hd, int flag)
{
nullpo_retr(0, hd);
+
// Delete homunculus
if ( flag&1 ) { //sabbath
intif_homunculus_requestdelete(hd->master->homunculus.hom_id) ;
@@ -568,7 +557,6 @@ int merc_menu(struct map_session_data *sd,int menunum)
switch(menunum) {
case 0:
- merc_hom_food(sd, sd->hd);
break;
case 1:
merc_hom_food(sd, sd->hd);
@@ -585,7 +573,7 @@ int merc_menu(struct map_session_data *sd,int menunum)
int merc_hom_food(struct map_session_data *sd, struct homun_data *hd)
{
- int i, k, emotion;
+ int i, k, intimacy, emotion;
if(hd->master->homunculus.vaporize)
return 1 ;
@@ -599,27 +587,28 @@ int merc_hom_food(struct map_session_data *sd, struct homun_data *hd)
pc_delitem(sd,i,1,0);
if ( hd->master->homunculus.hunger >= 91 ) {
- hd->master->homunculus.intimacy -= 50 ;
- emotion = 16 ;
+ intimacy = -50;
+ emotion = 16;
} else if ( hd->master->homunculus.hunger >= 76 ) {
- hd->master->homunculus.intimacy -= 30 ;
- emotion = 19 ;
+ intimacy = -30;
+ emotion = 19;
} else if ( hd->master->homunculus.hunger >= 26 ) {
- hd->master->homunculus.intimacy += 80 ;
- emotion = 2 ;
+ intimacy = 80;
+ emotion = 2;
} else if ( hd->master->homunculus.hunger >= 11 ) {
- hd->master->homunculus.intimacy += 100 ;
- emotion = 2 ;
+ intimacy = 100;
+ emotion = 2;
} else {
- hd->master->homunculus.intimacy += 50 ;
- emotion = 2 ;
+ intimacy = 50;
+ emotion = 2;
}
+ hd->master->homunculus.intimacy += intimacy;
+ if(hd->master->homunculus.intimacy < 0)
+ hd->master->homunculus.intimacy = 0;
if(hd->master->homunculus.intimacy > 100000)
hd->master->homunculus.intimacy = 100000;
- if(hd->master->homunculus.intimacy < 0)
- hd->master->homunculus.intimacy = 0 ;
- emotion = 5 ; // Thanks
+ //emotion = 5 ; // FIXME: why the code above and now always set emotion to Thanks?
hd->master->homunculus.hunger += 10; //dunno increase value for each food
if(hd->master->homunculus.hunger > 100)
hd->master->homunculus.hunger = 100;
@@ -629,6 +618,13 @@ int merc_hom_food(struct map_session_data *sd, struct homun_data *hd)
clif_send_homdata(sd,SP_INTIMATE,sd->homunculus.intimacy / 100);
clif_hom_food(sd,hd->homunculusDB->foodID,1);
+ if(hd->master->homunculus.intimacy == 0) {
+ merc_stop_walking(hd, 1);
+ merc_stop_attack(hd);
+ clif_emotion(&hd->master->bl, 23) ; //omg
+ merc_hom_delete(hd,1) ;
+ }
+
return 0;
}
@@ -662,9 +658,11 @@ static int merc_hom_hungry(int tid,unsigned int tick,int id,int data)
}
if(hd->master->homunculus.hunger < 0) {
hd->master->homunculus.hunger = 0;
- hd->master->homunculus.intimacy -= 100 ;
+ hd->master->homunculus.intimacy -= 100;
+ if(hd->master->homunculus.intimacy < 0)
+ hd->master->homunculus.intimacy = 0;
clif_send_homdata(sd,SP_INTIMATE,sd->homunculus.intimacy / 100);
- if ( hd->master->homunculus.intimacy <= 0 ) {
+ if(hd->master->homunculus.intimacy == 0) {
merc_stop_walking(hd, 1);
merc_stop_attack(hd);
clif_emotion(&hd->master->bl, 23) ; //omg